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

master
Ptolemy 2021-01-21 17:29:54 -08:00 committed by Ansariel
parent fe1ecfe7cc
commit 3ac4e2a4fc
1 changed files with 16 additions and 11 deletions

View File

@ -1454,24 +1454,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;
S32 swap_method = 0;
S32 cur_format = 0;
GLint swap_query = WGL_SWAP_METHOD_ARB;
BOOL found_format = FALSE;
while (!found_format && wglGetPixelFormatAttribivARB(mhDC, pixel_format, 0, 1, &swap_query, &swap_method))
// 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?