fix(glx): match GetDrawableAttributes and MakeCurrent to Xorg - #118
Merged
Conversation
…wable A GLXWindow/GLXPixmap XID is a fresh client-allocated id with no X resource behind it, so resolving GLX_WIDTH/GLX_HEIGHT from the GLX XID itself always missed and reported 0x0. Mesa's loader_dri3 sizes its buffer from these fields and fails with "failed to create drawable"; measured on the wire against libGLX_nvidia (2026-08-03): a 64x32 backing drawable was reported as 0x0. Resolve from the backing X drawable recorded at create time, as Xorg does (pGlxDraw->pDraw->width/height, glxcmds.c:1891).
Add GlxDrawableKind { Window, Pixmap, Pbuffer } (no Default impl, so a
missed construction site is a compile error) and set it at all three
glx_drawables.insert sites plus the resource-allocator test literal.
ChangeDrawableAttributes now records only GLX_EVENT_MASK and ignores
every other attribute, matching Xorg's single-case switch
(glxcmds.c:1494-1503). Re-key the is_pbuffer checks in
drawable_attributes_for and glx_pbuffer_geometry onto the kind,
preserving both 0x0-pbuffer behaviours (backing-pixmap 1x1 fallthrough
and the GetGeometry BadDrawable guard).
Restructure drawable_attributes_for around Xorg's exact branch (glxcmds.c:1863-1914): Y_INVERTED/WIDTH/HEIGHT/SCREEN always; the TEXTURE_TARGET/EVENT_MASK/FBCONFIG_ID block (plus PRESERVED_CONTENTS for pbuffers, STEREO_TREE_EXT for windows) only with a GLX record; DRAWABLE_TYPE last, WINDOW_BIT for the no-record fallthrough. A naked X window no longer gets a bogus GLX_FBCONFIG_ID = 0 (measured defect against libGLX_nvidia), and GLX_RENDER_TYPE is dropped — Xorg never sends it for a drawable. Delete the generic ChangeDrawableAttributes override pass; the event_mask field recorded in the previous commit is the only state. GET_DRAWABLE_ATTRIBUTES now emits Xorg's two distinct error codes instead of a silent Success: a naked X pixmap gets GLXBadDrawable (GLX_FIRST_ERROR + 2; glxproto.h:43 — GLXVND forwards pixmaps, then dixLookupWindow fails), and an XID that is not a drawable at all gets core BadDrawable (the GLXVND dispatch stub errors before DoGetDrawableAttributes is reached). Add the missing GLX_STEREO_TREE_EXT and ERROR_GLX_BAD_DRAWABLE constants with citations.
Parse the request body, which the arm ignored entirely: the new context XID sits at body[4..8] for minor 5 (MakeCurrent) and body[12..16] for minor 26 (MakeContextCurrent), per glxproto.h:225-233 and :471-481. The release form (context == None) now returns contextTag = 0 — tag 0 is reserved by the protocol to mean "no context current" — instead of allocating a fresh monotonic tag, matching Xorg (vndcmds.c:232-234, :271-273). Measured defect: yserver.log showed tag=1 then tag=2, the second being the release.
…nment # Conflicts: # docs/status.md
Owner
|
Thx. |
ariel3259
added a commit
to ariel3259/yserver
that referenced
this pull request
Aug 7, 2026
PR joske#118 (glx-reply-xorg-alignment) was squash-merged upstream as 247b7a4, so the reply-alignment commits this branch carries individually now exist on master as one commit. The content is identical, so git collapsed the duplication cleanly -- the branch's net diff against upstream/master is now purely the vendor-name work. Conflicts resolved: - process_request.rs, GET_DRAWABLE_ATTRIBUTES error arm: took upstream's 47b0633 (fix(glx): preserve minor opcode in drawable errors), switching the unknown-XID path from emit_x11_error to emit_x11_error_with_minor and passing u16::from(header.data). The pixmap arm directly above already reported the minor opcode; this brings the core BadDrawable arm in line, and the paired assertions on buf[8..10]/buf[10] in glx_get_drawable_attributes_unknown_xid_returns_core_bad_drawable came in with it. - process_request.rs tests: kept glx_vendor_names_query_answers_from_server_state, which upstream does not have -- an adjacency conflict, not a semantic one. - docs/status.md: kept both entries. Upstream's direct-scanout idle paint starvation note and this branch's GLX_VENDOR_NAMES_EXT / BackendCapabilities notes are independent. Verified: cargo clippy --all-targets -D warnings and the full test suite (1474 tests) on yserver-core and yserver-protocol, plus cargo +nightly fmt --check. The yserver crate could not be built here -- its build script needs glslc, which is not installed in this environment -- but no conflict touched that crate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(glx): match GetDrawableAttributes and MakeCurrent to Xorg
Branch:
glx-reply-xorg-alignment, opened againstmaster. Merged with currentmaster(2252 tests,clippy --all-targets -- -D warningsand+nightly fmt --checkclean).The hardware numbers below were measured on this branch before the merge with current
master.master's new commits touch the Present/TFP wait paths rather than the GLX reply arms, and the tree is green, but the probe has not been re-run against the exact merged tree.Problem
NVIDIA's
libGLX_nvidiacould not bind a GL context against yserver. Clients died with:Serial 0 was the clue: yserver never emits that error. Its
MAKE_CURRENThandler always replies with a contextTag and cannot fail, and libglvnd 1.7.0 does not synthesiseBadAlloceither (it producesBadAccess/BadMatch/GLXBadContext/GLXBadDrawable). The error was fabricated client-side bylibGLX_nvidiaafter reading a reply it considered impossible.This hit KWin (
QGLXContext: Failed to create dummy context), Steam, and games.Root cause
GetDrawableAttributesreportedGLX_FBCONFIG_ID = 0— a nonexistent id — for a bare X window.drawable_attributes_forlooked the XID up inglx_drawablesand fell back to0when absent, but a GLX 1.2 "naked window" is not in that table by definition.Xorg has an explicit path for this case (
glx/glxcmds.c:1873-1914) and omits the attribute entirely rather than sending a bogus one. It also always sendsGLX_DRAWABLE_TYPE, which yserver never sent, and never sendsGLX_RENDER_TYPE, which yserver did.Fix
Six commits, aligning the two replies with Xorg's observable behaviour:
loader_dri3too, which sizes its buffers from this reply.MakeCurrentreturnscontextTag = 0when releasing (context == 0), matchingglx/vndcmds.c:232-234,272. yserver previously returned a fresh incrementing tag.Verification
Measured on an RTX 5060 Ti, NVIDIA 610.57.04, open kernel modules, over a real KMS session.
The causal proof is a single difference in the client trace against the pre-fix baseline:
GetDrawableAttributeswent from7 attribsto5 attribs. Everything before that point is byte-identical. Immediately after, the baseline didMakeCurrentand died; with the fix, NVIDIA continues intoDRI3::SetDRMDeviceInUse→GetSupportedModifiers→PixmapFromBuffers→MakeCurrent.Probe result after the fix:
The
BadAllocis gone. Steam — a 32-bit client that previously crashed on launch with the exact signature above — now starts, as does Hollow Knight.Notes
docs/status.mdupdated (entry dated 2026-08-04).docs/superpowers/.QUERY_CONTEXTanswers 0 attributes where Xorg answersFBCONFIG_ID/RENDER_TYPE/SCREEN, and fbconfig synthesis produces 2 configs against XWayland's 168.cargo clippy --all-targets -- -D warningsclean,cargo +nightly fmt --checkclean. All commits signed.🤖 Generated with Claude Code