Fixes Combat Mission: Battle for Normandy (GL game) failing to initialize GL on start. Looks like the game depends specifically on cAlphaShift being 24 (seemingly without any other prior checks, simply surfing through gdi32.DescribePixelFormat).
The shifts in winex11.drv are obviously wrong currently: alpha channel doesn't preceded BGR in BGRA format (which is also confirmed by the test). cAlphaShift is a bit trickier though, that is marked as unsupported on Deck. Here on real hardware AMD desktop it is 24 (and alpha bits are 8). That's not the case on one Testbot machine though (win11_nv64) where both cAlphaShift and cAlphaBits are 0. So I made the test to accept such case as well.
From: Paul Gofman pgofman@codeweavers.com
--- dlls/opengl32/tests/opengl.c | 15 ++++++++++++++- dlls/winex11.drv/opengl.c | 13 ++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 6979e00792e..a9fdd436e26 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -288,7 +288,20 @@ static void test_choosepixelformat(void) pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32; - ok( test_pfd(&pfd, NULL), "Simple pfd failed\n" ); + ok( test_pfd(&pfd, &ret_fmt), "Simple pfd failed\n" ); + ok( ret_fmt.cColorBits == 32, "Got %u.\n", ret_fmt.cColorBits ); + ok( !ret_fmt.cBlueShift, "Got %u.\n", ret_fmt.cBlueShift ); + ok( ret_fmt.cBlueBits == 8, "Got %u.\n", ret_fmt.cBlueBits ); + ok( ret_fmt.cRedBits == 8, "Got %u.\n", ret_fmt.cRedBits ); + ok( ret_fmt.cGreenBits == 8, "Got %u.\n", ret_fmt.cGreenBits ); + ok( ret_fmt.cGreenShift == 8, "Got %u.\n", ret_fmt.cGreenShift ); + ok( ret_fmt.cRedShift == 16, "Got %u.\n", ret_fmt.cRedShift ); + ok( !ret_fmt.cAlphaBits || ret_fmt.cAlphaBits == 8, "Got %u.\n", ret_fmt.cAlphaBits ); + if (ret_fmt.cAlphaBits) + ok( ret_fmt.cAlphaShift == 24, "Got %u.\n", ret_fmt.cAlphaShift ); + else + ok( !ret_fmt.cAlphaShift, "Got %u.\n", ret_fmt.cAlphaShift ); + pfd.dwFlags |= PFD_DOUBLEBUFFER_DONTCARE; ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); pfd.dwFlags |= PFD_STEREO_DONTCARE; diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 565df8bb4c6..8bdcdbe2402 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1601,14 +1601,17 @@ static int describe_pixel_format( int iPixelFormat, PIXELFORMATDESCRIPTOR *ppfd, pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_BLUE_SIZE, &bb); pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &ab);
- ppfd->cRedBits = rb; - ppfd->cRedShift = gb + bb + ab; ppfd->cBlueBits = bb; - ppfd->cBlueShift = ab; + ppfd->cBlueShift = 0; ppfd->cGreenBits = gb; - ppfd->cGreenShift = bb + ab; + ppfd->cGreenShift = bb; + ppfd->cRedBits = rb; + ppfd->cRedShift = gb + bb; ppfd->cAlphaBits = ab; - ppfd->cAlphaShift = 0; + if (ab) + ppfd->cAlphaShift = rb + gb + bb; + else + ppfd->cAlphaShift = 0; } else { ppfd->cRedBits = 0; ppfd->cRedShift = 0;