From 4083a34188a8863723f0f28fbaef5ee015eee4b6 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Fri, 24 Apr 2026 15:33:03 -0700 Subject: [PATCH] wgl: Use an hwnd xor hdc for framebuffers It seems maybe hdcs can get recycled? Fixes: 28058221 ("wgl: Support contexts created from non-window DCs") (cherry picked from commit 3f35e6525323d8f51a670dd4b3eb970664beef5e) Part-of: --- .pick_status.json | 2 +- src/gallium/frontends/wgl/stw_context.c | 3 ++- src/gallium/frontends/wgl/stw_framebuffer.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index e02a6a74726..364f3696296 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1194,7 +1194,7 @@ "description": "wgl: Use an hwnd xor hdc for framebuffers", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "2805822141bb392cc282d9ffaad2ff49f57a23e0", "notes": null diff --git a/src/gallium/frontends/wgl/stw_context.c b/src/gallium/frontends/wgl/stw_context.c index 7297d3f1e51..c43f65e1ad0 100644 --- a/src/gallium/frontends/wgl/stw_context.c +++ b/src/gallium/frontends/wgl/stw_context.c @@ -543,8 +543,9 @@ get_unlocked_refd_framebuffer_from_dc(HDC hDC) * those here. */ int iPixelFormat = stw_pixelformat_guess(hDC); + HWND hWnd = WindowFromDC(hDC); if (iPixelFormat) - fb = stw_framebuffer_create(hDC, WindowFromDC(hDC), stw_pixelformat_get_info(iPixelFormat), STW_FRAMEBUFFER_WGL_WINDOW, stw_dev->fscreen); + fb = stw_framebuffer_create(hWnd ? NULL : hDC, hWnd, stw_pixelformat_get_info(iPixelFormat), STW_FRAMEBUFFER_WGL_WINDOW, stw_dev->fscreen); if (!fb) return NULL; } diff --git a/src/gallium/frontends/wgl/stw_framebuffer.c b/src/gallium/frontends/wgl/stw_framebuffer.c index 820f3dd5ac2..64dc59d7b2d 100644 --- a/src/gallium/frontends/wgl/stw_framebuffer.c +++ b/src/gallium/frontends/wgl/stw_framebuffer.c @@ -475,7 +475,7 @@ stw_framebuffer_from_hdc_locked(HDC hdc) hwnd = WindowFromDC(hdc); - return stw_framebuffer_from_hwnd_hdc_locked(hwnd, hdc); + return stw_framebuffer_from_hwnd_hdc_locked(hwnd, hwnd ? NULL : hdc); }