mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-09 03:29:43 -10:00
video: route display queries through display server, remove driver
boilerplate, fix resolution refresh rate parsing
Change 4 dispatch functions in video_driver.c to try the display
server first before falling back to the per-driver poke/ctx interface:
- video_driver_get_next_video_out
- video_driver_get_prev_video_out
- video_driver_get_video_output_size
- video_context_driver_get_metrics
On Win32, the display server now handles the above 4 queries via
dispserv_win32.c (wired in the previous commit). On other platforms
the display server slots are NULL so the poke/ctx fallback fires,
preserving existing behavior.
Remove the identical boilerplate wrapper functions that each Win32
graphics driver previously needed:
- d3d10_get_video_output_prev/next (gfx/drivers/d3d10.c)
- d3d11_get_video_output_prev/next (gfx/drivers/d3d11.c)
- d3d12_get_video_output_prev/next (gfx/drivers/d3d12.c)
- gdi_get_video_output_prev/next (gfx/drivers/gdi_gfx.c)
- gfx_ctx_wgl_get_video_output_prev/next (wgl_ctx.c)
- gfx_ctx_w_vk_get_video_output_prev/next (w_vk_ctx.c)
Fix resolution refresh rate parsing in menu_cbs_ok.c: the
resolution list format is "WIDTHxHEIGHT (RATE Hz)" but the parser
only skipped the space, not the opening parenthesis, causing
strtod("(120 Hz)") to return 0. Change the skip to a while loop
that advances past both spaces and '('.
This commit is contained in:
1 parent
7d9116a586
commit
6d708d4ddf
9 files changed
+28
-66
No files matched your search
@@ -23,6 +23,7 @@
|
||||
#include <windows.h>
|
||||
#include <ntverp.h>
|
||||
|
||||
|
||||
#ifndef COBJMACROS
|
||||
#define COBJMACROS
|
||||
#define COBJMACROS_DEFINED
|
||||
|
||||
+2
-14
@@ -3758,19 +3758,7 @@ static uint32_t d3d10_get_flags(void *data)
|
||||
}
|
||||
|
||||
#ifndef __WINRT__
|
||||
static void d3d10_get_video_output_prev(void *data)
|
||||
{
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
win32_get_video_output_prev(&width, &height);
|
||||
}
|
||||
|
||||
static void d3d10_get_video_output_next(void *data)
|
||||
{
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
win32_get_video_output_next(&width, &height);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const video_poke_interface_t d3d10_poke_interface = {
|
||||
@@ -3791,8 +3779,8 @@ static const video_poke_interface_t d3d10_poke_interface = {
|
||||
NULL, /* get_video_output_next */
|
||||
#else
|
||||
win32_get_video_output_size,
|
||||
d3d10_get_video_output_prev,
|
||||
d3d10_get_video_output_next,
|
||||
NULL, /* get_video_output_prev - handled by display server */
|
||||
NULL, /* get_video_output_next - handled by display server */
|
||||
#endif
|
||||
NULL, /* get_current_framebuffer */
|
||||
NULL, /* get_proc_address */
|
||||
|
||||
+2
-14
@@ -5360,19 +5360,7 @@ static bool d3d11_get_hw_render_interface(
|
||||
}
|
||||
|
||||
#ifndef __WINRT__
|
||||
static void d3d11_get_video_output_prev(void *data)
|
||||
{
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
win32_get_video_output_prev(&width, &height);
|
||||
}
|
||||
|
||||
static void d3d11_get_video_output_next(void *data)
|
||||
{
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
win32_get_video_output_next(&width, &height);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const video_poke_interface_t d3d11_poke_interface = {
|
||||
@@ -5393,8 +5381,8 @@ static const video_poke_interface_t d3d11_poke_interface = {
|
||||
NULL, /* get_video_output_next */
|
||||
#else
|
||||
win32_get_video_output_size,
|
||||
d3d11_get_video_output_prev,
|
||||
d3d11_get_video_output_next,
|
||||
NULL, /* get_video_output_prev - handled by display server */
|
||||
NULL, /* get_video_output_next - handled by display server */
|
||||
#endif
|
||||
NULL, /* get_current_framebuffer */
|
||||
NULL, /* get_proc_address */
|
||||
|
||||
+2
-14
@@ -6390,19 +6390,7 @@ static bool d3d12_get_hw_render_interface(
|
||||
}
|
||||
|
||||
#ifndef __WINRT__
|
||||
static void d3d12_get_video_output_prev(void *data)
|
||||
{
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
win32_get_video_output_prev(&width, &height);
|
||||
}
|
||||
|
||||
static void d3d12_get_video_output_next(void *data)
|
||||
{
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
win32_get_video_output_next(&width, &height);
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool d3d12_get_current_software_framebuffer(
|
||||
@@ -6509,8 +6497,8 @@ static const video_poke_interface_t d3d12_poke_interface = {
|
||||
NULL, /* get_video_output_next */
|
||||
#else
|
||||
win32_get_video_output_size,
|
||||
d3d12_get_video_output_prev,
|
||||
d3d12_get_video_output_next,
|
||||
NULL, /* get_video_output_prev - handled by display server */
|
||||
NULL, /* get_video_output_next - handled by display server */
|
||||
#endif
|
||||
NULL, /* get_current_framebuffer */
|
||||
NULL, /* get_proc_address */
|
||||
|
||||
+2
-14
@@ -968,19 +968,7 @@ static void gdi_unload_texture(void *data,
|
||||
|
||||
static uint32_t gdi_get_flags(void *data) { return 0; }
|
||||
|
||||
static void gdi_get_video_output_prev(void *data)
|
||||
{
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
win32_get_video_output_prev(&width, &height);
|
||||
}
|
||||
|
||||
static void gdi_get_video_output_next(void *data)
|
||||
{
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
win32_get_video_output_next(&width, &height);
|
||||
}
|
||||
|
||||
static const video_poke_interface_t gdi_poke_interface = {
|
||||
gdi_get_flags,
|
||||
@@ -990,8 +978,8 @@ static const video_poke_interface_t gdi_poke_interface = {
|
||||
win32_get_refresh_rate,
|
||||
NULL, /* set_filtering */
|
||||
win32_get_video_output_size,
|
||||
gdi_get_video_output_prev,
|
||||
gdi_get_video_output_next,
|
||||
NULL, /* get_video_output_prev - handled by display server */
|
||||
NULL, /* get_video_output_next - handled by display server */
|
||||
NULL, /* get_current_framebuffer */
|
||||
NULL, /* get_proc_address */
|
||||
NULL, /* set_aspect_ratio */
|
||||
|
||||
@@ -293,8 +293,6 @@ static uint32_t gfx_ctx_w_vk_get_flags(void *data)
|
||||
}
|
||||
|
||||
static void gfx_ctx_w_vk_set_flags(void *data, uint32_t flags) { }
|
||||
static void gfx_ctx_w_vk_get_video_output_prev(void *data) { }
|
||||
static void gfx_ctx_w_vk_get_video_output_next(void *data) { }
|
||||
|
||||
const gfx_ctx_driver_t gfx_ctx_w_vk = {
|
||||
gfx_ctx_w_vk_init,
|
||||
@@ -306,8 +304,8 @@ const gfx_ctx_driver_t gfx_ctx_w_vk = {
|
||||
win32_get_video_size,
|
||||
win32_get_refresh_rate,
|
||||
win32_get_video_output_size,
|
||||
gfx_ctx_w_vk_get_video_output_prev,
|
||||
gfx_ctx_w_vk_get_video_output_next,
|
||||
NULL, /* get_video_output_prev - handled by display server */
|
||||
NULL, /* get_video_output_next - handled by display server */
|
||||
win32_get_metrics,
|
||||
NULL,
|
||||
video_driver_update_title,
|
||||
|
||||
@@ -830,8 +830,6 @@ static void gfx_ctx_wgl_set_flags(void *data, uint32_t flags)
|
||||
|
||||
}
|
||||
|
||||
static void gfx_ctx_wgl_get_video_output_prev(void *data) { }
|
||||
static void gfx_ctx_wgl_get_video_output_next(void *data) { }
|
||||
|
||||
static bool gfx_ctx_wgl_create_surface(void *data)
|
||||
{
|
||||
@@ -904,8 +902,8 @@ const gfx_ctx_driver_t gfx_ctx_wgl = {
|
||||
win32_get_video_size,
|
||||
win32_get_refresh_rate,
|
||||
win32_get_video_output_size,
|
||||
gfx_ctx_wgl_get_video_output_prev,
|
||||
gfx_ctx_wgl_get_video_output_next,
|
||||
NULL, /* get_video_output_prev - handled by display server */
|
||||
NULL, /* get_video_output_next - handled by display server */
|
||||
win32_get_metrics,
|
||||
NULL,
|
||||
video_driver_update_title,
|
||||
|
||||
+12
-1
@@ -1980,6 +1980,8 @@ bool video_driver_get_video_output_size(unsigned *width, unsigned *height, char
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
const video_poke_interface_t *poke = video_st->poke;
|
||||
if (video_display_server_get_video_output_size(width, height, s, len))
|
||||
return true;
|
||||
if (!poke || !poke->get_video_output_size)
|
||||
return false;
|
||||
poke->get_video_output_size(video_st->data,
|
||||
@@ -2243,6 +2245,8 @@ bool video_driver_get_next_video_out(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
const video_poke_interface_t *poke = video_st->poke;
|
||||
if (video_display_server_get_video_output_next())
|
||||
return true;
|
||||
if (!poke || !poke->get_video_output_next)
|
||||
return false;
|
||||
poke->get_video_output_next(video_st->data);
|
||||
@@ -2253,6 +2257,8 @@ bool video_driver_get_prev_video_out(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
const video_poke_interface_t *poke = video_st->poke;
|
||||
if (video_display_server_get_video_output_prev())
|
||||
return true;
|
||||
if (!poke || !poke->get_video_output_prev)
|
||||
return false;
|
||||
poke->get_video_output_prev(video_st->data);
|
||||
@@ -3443,6 +3449,8 @@ bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics)
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
const gfx_ctx_driver_t *ctx = &video_st->current_video_context;
|
||||
void *ctx_data = (void*)video_st->context_data;
|
||||
if (video_display_server_get_metrics(metrics->type, metrics->value))
|
||||
return true;
|
||||
if (ctx->get_metrics)
|
||||
return ctx->get_metrics(ctx_data, metrics->type, metrics->value);
|
||||
return false;
|
||||
@@ -3637,7 +3645,10 @@ float video_driver_get_refresh_rate(void)
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
const video_poke_interface_t *poke = video_st->poke;
|
||||
if (poke && poke->get_refresh_rate)
|
||||
return poke->get_refresh_rate(video_st->data);
|
||||
{
|
||||
float rate = poke->get_refresh_rate(video_st->data);
|
||||
return rate;
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -7297,11 +7297,13 @@ int action_cb_push_dropdown_item_resolution(const char *path,
|
||||
|
||||
++end;
|
||||
height = (unsigned)strtoul(end, &end, 0);
|
||||
if (*end == ' ')
|
||||
/* Skip whitespace and opening parenthesis: "2160 (120 Hz)" → "120 Hz)" */
|
||||
while (*end == ' ' || *end == '(')
|
||||
++end;
|
||||
|
||||
refreshrate = (float)strtod(end, NULL);
|
||||
|
||||
|
||||
if (video_display_server_set_resolution(width, height,
|
||||
floor(refreshrate), refreshrate, 0, 0, 0, 0))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user