From 85c971650d6e3373dcd80fd63b75cb62e351c405 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 21 Jan 2021 17:29:54 -0800 Subject: SL-14705: Merge Sovereign Engineer's fix for name tags showing in front with AMD GPUs: Fix GL_INVALID_OPERATION when copying stencil to default window framebuffer on AMD graphics on windows --- indra/llwindow/llwindowwin32.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 6831071cd1..0db9886d03 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1474,24 +1474,29 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO LL_INFOS("Window") << "pixel formats done." << LL_ENDL ; - S32 swap_method = 0; - S32 cur_format = num_formats-1; - GLint swap_query = WGL_SWAP_METHOD_ARB; - - BOOL found_format = FALSE; - - while (!found_format && wglGetPixelFormatAttribivARB(mhDC, pixel_format, 0, 1, &swap_query, &swap_method)) + S32 swap_method = 0; + S32 cur_format = 0; + GLint swap_query = WGL_SWAP_METHOD_ARB; + + // SL-14705 Fix name tags showing in front of objects with AMD GPUs. + // On AMD hardware we need to iterate from the first pixel format to the end. + // Spec: + // https://www.khronos.org/registry/OpenGL/extensions/ARB/WGL_ARB_pixel_format.txt + while (wglGetPixelFormatAttribivARB(mhDC, pixel_formats[cur_format], 0, 1, &swap_query, &swap_method)) { - if (swap_method == WGL_SWAP_UNDEFINED_ARB || cur_format <= 0) + if (swap_method == WGL_SWAP_UNDEFINED_ARB) { - found_format = TRUE; + break; } - else + else if (cur_format >= (S32)(num_formats - 1)) { - --cur_format; + cur_format = 0; + break; } + + ++cur_format; } - + pixel_format = pixel_formats[cur_format]; if (mhDC != 0) // Does The Window Have A Device Context? -- cgit v1.2.3 From 96a23e0b07857b75d48d3cd7528579982382bc4c Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 22 Jan 2021 16:39:02 -0800 Subject: SL-14705: Update contributions.txt --- doc/contributions.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/contributions.txt b/doc/contributions.txt index c91587d5c3..08a0b79343 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -1354,6 +1354,7 @@ Sovereign Engineer SL-11079 OPEN-343 SL-11625 + SL-14705 SpacedOut Frye VWR-34 VWR-45 -- cgit v1.2.3 From d0fcbd4427cd0b1abea975cb0ba144bfc9169861 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 22 Jan 2021 16:48:31 -0800 Subject: SL-14705: Cleanup U32 S32 cast --- indra/llwindow/llwindowwin32.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 0db9886d03..afe0c2cc6a 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1476,6 +1476,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO S32 swap_method = 0; S32 cur_format = 0; +const S32 max_format = (S32)num_formats - 1; GLint swap_query = WGL_SWAP_METHOD_ARB; // SL-14705 Fix name tags showing in front of objects with AMD GPUs. @@ -1488,7 +1489,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO { break; } - else if (cur_format >= (S32)(num_formats - 1)) + else if (cur_format >= max_format) { cur_format = 0; break; -- cgit v1.2.3