From bac1ceb83f718bc151de29da162dae2b4e8db185 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Thu, 22 Jan 2026 12:08:23 -0800 Subject: [PATCH] wgl: Add a driconf option to force pixel formats with GDI support Part-of: --- src/gallium/frontends/wgl/stw_device.c | 1 + src/gallium/frontends/wgl/stw_pixelformat.c | 5 +++++ src/util/driconf.h | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/gallium/frontends/wgl/stw_device.c b/src/gallium/frontends/wgl/stw_device.c index 9b098e02036..26cde86b59f 100644 --- a/src/gallium/frontends/wgl/stw_device.c +++ b/src/gallium/frontends/wgl/stw_device.c @@ -113,6 +113,7 @@ static const driOptionDescription gallium_driconf[] = { DRI_CONF_SECTION("WGL") DRI_CONF_WGL_FRAME_LATENCY(2) DRI_CONF_WGL_SWAP_INTERVAL(1) + DRI_CONF_WGL_REQUIRE_GDI_COMPAT(false) DRI_CONF_SECTION_END }; diff --git a/src/gallium/frontends/wgl/stw_pixelformat.c b/src/gallium/frontends/wgl/stw_pixelformat.c index 938fb551cfb..8b2647bce14 100644 --- a/src/gallium/frontends/wgl/stw_pixelformat.c +++ b/src/gallium/frontends/wgl/stw_pixelformat.c @@ -264,6 +264,9 @@ add_color_format_variants(const struct stw_pf_color_info *color_formats, bind_flags |= PIPE_BIND_DISPLAY_TARGET; } + bool require_gdi_compat = + driQueryOptionb(&stw_dev->option_cache, "wgl_require_gdi_compat"); + for (ms = 0; ms < ARRAY_SIZE(stw_pf_multisample); ms++) { unsigned samples = stw_pf_multisample[ms]; @@ -288,6 +291,8 @@ add_color_format_variants(const struct stw_pf_color_info *color_formats, } for (f = 0; f < ARRAY_SIZE(stw_pf_flag); f++) { + if (require_gdi_compat && (stw_pf_flag[f] & PFD_SUPPORT_GDI) == 0) + continue; for (acc = 0; acc < 2; acc++) { stw_pixelformat_add(stw_dev, extended, &color_formats[cfmt], depth, acc * 16, stw_pf_flag[f], samples); diff --git a/src/util/driconf.h b/src/util/driconf.h index de662e7d138..cd02661baa2 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -581,6 +581,10 @@ DRI_CONF_OPT_I(wgl_swap_interval, def, 1, 4, \ "Override default swap interval") +#define DRI_CONF_WGL_REQUIRE_GDI_COMPAT(def) \ + DRI_CONF_OPT_B(wgl_require_gdi_compat, def, \ + "Require all pixel formats to have PFD_SUPPORT_GDI flag") + /** * \brief virgl specific configuration options */