opengl32: Support PFD_DEPTH_DONTCARE flag in wglChoosePixelFormat().

With this flag set native implementation ignores cDepthBits but
cares to find a zero depth format if possible.

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2021-02-11 13:04:51 +03:00 committed by Alexandre Julliard
parent 6341546fde
commit 45f8b6924a
2 changed files with 16 additions and 1 deletions

View file

@ -330,6 +330,18 @@ static void test_choosepixelformat(void)
ok( test_pfd(&pfd, NULL), "PFD_STEREO_DONTCARE failed\n" );
pfd.dwFlags &= ~PFD_STEREO_DONTCARE;
pfd.cAuxBuffers = 0;
pfd.dwFlags |= PFD_DEPTH_DONTCARE;
pfd.cDepthBits = 24;
ok( test_pfd(&pfd, &ret_fmt), "PFD_DEPTH_DONTCARE failed.\n" );
ok( !ret_fmt.cDepthBits, "Got unexpected cDepthBits %u.\n", ret_fmt.cDepthBits );
pfd.cStencilBits = 8;
ok( test_pfd(&pfd, &ret_fmt), "PFD_DEPTH_DONTCARE, depth 24, stencil 8 failed.\n" );
ok( !ret_fmt.cDepthBits || ret_fmt.cDepthBits == 24, "Got unexpected cDepthBits %u.\n", ret_fmt.cDepthBits );
ok( ret_fmt.cStencilBits == 8, "Got unexpected cStencilBits %u.\n", ret_fmt.cStencilBits );
pfd.cDepthBits = 0;
pfd.cStencilBits = 0;
pfd.dwFlags &= ~PFD_DEPTH_DONTCARE;
}
static void WINAPI gl_debug_message_callback(GLenum source, GLenum type, GLuint id, GLenum severity,

View file

@ -563,7 +563,7 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd)
continue;
}
}
if (ppfd->cDepthBits)
if (ppfd->cDepthBits && !(ppfd->dwFlags & PFD_DEPTH_DONTCARE))
{
if (((ppfd->cDepthBits > best.cDepthBits) && (format.cDepthBits > best.cDepthBits)) ||
((format.cDepthBits >= ppfd->cDepthBits) && (format.cDepthBits < best.cDepthBits)))
@ -599,6 +599,9 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd)
continue;
}
}
if (ppfd->dwFlags & PFD_DEPTH_DONTCARE && format.cDepthBits < best.cDepthBits)
goto found;
continue;
found: