wgl: Add driconf options for controlling latency and swap interval

Latency is hooked up to a new winsys framebuffer interface method. Swap
interval replaces the previous environment variable. This does make the
environment variable lowercase but that seems worth the break to be able
to set it from driconf.

Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31157>
This commit is contained in:
Jesse Natalie 2024-09-12 16:23:04 -07:00 committed by Marge Bot
parent 64885821c2
commit e9ce526714
4 changed files with 28 additions and 8 deletions

View file

@ -110,6 +110,11 @@ init_screen(const struct stw_winsys *stw_winsys, HDC hdc)
static const driOptionDescription gallium_driconf[] = {
#include "pipe-loader/driinfo_gallium.h"
DRI_CONF_SECTION("WGL")
DRI_CONF_WGL_FRAME_LATENCY(2)
DRI_CONF_WGL_SWAP_INTERVAL(1)
DRI_CONF_SECTION_END
};
static void
@ -121,6 +126,8 @@ init_options()
driver_name ? driver_name : "", NULL, NULL, NULL, 0, NULL, 0);
u_driconf_fill_st_options(&stw_dev->st_options, &stw_dev->option_cache);
stw_dev->swap_interval = driQueryOptioni(&stw_dev->option_cache, "wgl_swap_interval");
}
char *
@ -161,14 +168,6 @@ stw_init(const struct stw_winsys *stw_winsys)
goto error1;
}
/* Per WGL_EXT_swap_control, the default swap interval is 1. */
stw_dev->swap_interval = 1;
/* env var override for WGL_EXT_swap_control, useful for testing/debugging */
const char *s = os_get_option("WGL_SWAP_INTERVAL");
if (s) {
stw_dev->swap_interval = atoi(s);
}
stw_dev->refresh_rate = get_refresh_rate();
stw_dev->initialized = true;

View file

@ -324,6 +324,11 @@ stw_framebuffer_create(HWND hWnd, const struct stw_pixelformat_info *pfi, enum s
fb->winsys_framebuffer =
stw_dev->stw_winsys->create_framebuffer(stw_dev->screen, hWnd, pfi->iPixelFormat);
if (fb->winsys_framebuffer && fb->winsys_framebuffer->set_latency) {
int latency = driQueryOptioni(&stw_dev->option_cache, "wgl_frame_latency");
fb->winsys_framebuffer->set_latency(fb->winsys_framebuffer, latency);
}
#ifdef _GAMING_XBOX
fb->prev_wndproc = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)&stw_call_window_proc_xbox);
#endif

View file

@ -67,6 +67,10 @@ struct stw_winsys_framebuffer
void
(*flush_frontbuffer)(struct stw_winsys_framebuffer *fb,
struct pipe_context *context);
void
(*set_latency)(struct stw_winsys_framebuffer *fb,
int latency);
};
struct stw_winsys

View file

@ -558,6 +558,18 @@
DRI_CONF_OPT_B(v3d_nonmsaa_texture_size_limit, def, \
"Report the non-MSAA-only texture size limit")
/**
* \brief wgl specific configuration options
*/
#define DRI_CONF_WGL_FRAME_LATENCY(def) \
DRI_CONF_OPT_I(wgl_frame_latency, def, 1, 16, \
"Override default maximum frame latency")
#define DRI_CONF_WGL_SWAP_INTERVAL(def) \
DRI_CONF_OPT_I(wgl_swap_interval, def, 1, 4, \
"Override default swap interval")
/**
* \brief virgl specific configuration options
*/