glx/xlib: count the alpha channel in GLX_BUFFER_SIZE (Tomb Raider I-III under gamescope)

Merged
UT
7d ago
+11-1

Problem

Tomb Raider I-III Remastered (OpenGL) dies about 3 s after its window maps under gamescope, while the same container renders at 60 fps under the in-app X server (RP6, payload 20261104.1, Proton 10 arm64ec, Wrapper/Turnip).

WINEDEBUG=+wgl,+opengl on both backends shows the only difference. The game calls wglChoosePixelFormatARB asking for 32 colour bits (a minimum match in Wine's chooser):

backendformats Wine offersresult
in-app X server (one visual, depth 32)color 32 8,8,8,8 depth 24 stencil 8match, 60 fps
gamescope / Xwayland (default visual depth 24)color 24 8,8,8,8 depth 24 stencil 8 (x2)0 formats → err:wgl:set_pixel_format Invalid format -5265184 → null call, exit

Both backends load the same guest libGL (this branch's xlib GLX emulation, Server GLX vendor: Brian Paul), whose fbconfigs are the X visuals and whose GLX_BUFFER_SIZE is visinfo->depth. With the forced alpha channel that gives 24 colour bits plus 8 alpha bits on Xwayland, which no Windows driver ever reports: a DRI GLX fbconfig for the same channels says 32, and Wine copies GLX_BUFFER_SIZE straight into cColorBits.

Fix

In get_config(), count the alpha bits in GLX_BUFFER_SIZE when the visual depth only covers the RGB channels. Depth-32 visuals (the in-app X server) are unchanged.

The second commit adds a README section saying what this branch ships in GameNative (extra_libs.tzst → usr/lib/libGL.so.1.5.0, used by both display servers, built from c1567e9609) and how to build it.

Provenance of the shipped binary vs this branch

The shipped libGL.so.1.5.0 reports git-c1567e9609, five commits behind this branch's head (Pipetto's May 2026 commits: Winlator window properties, dri-options hack, two Mali fixes). The test binary below is c1567e9609 + this fix, so the device A/B differs from the shipped file only in the fix.

Testing on the RP6 (gamescope, container unchanged apart from the swapped archive)

  • Shipped libGL: crash at window map as above (launch2, launch4).
  • Patched libGL (emutls build): dlopen failed: cannot locate symbol "__emutls_v._glapi_tls_Context" against the shipped libglapi.so.0. Rebuilt with -fno-emulated-tls.
  • Patched libGL (ELF TLS): Wine now lists color 32 8,8,8,8, wglChoosePixelFormatARB returns format 1, SetPixelFormat(1) succeeds, the game creates its context and issues draw calls (about 200 swaps/s in the traced run). No crash.
  • Remaining issue, outside this library: the screen stays black with audio playing. gamescope's session blind (session_game_window_absent) paints black because the game loads dxgi/d3d11 and the shim binds a Vulkan override surface that never presents, while the GL frames arrive on the X window's own surface. That is a gamescope change, tracked separately.