Skip to content

xshader: keep a compute root's layout when the runtime appends its private root SRVs - #296

Open
NickStallman wants to merge 1 commit into
brcly:mainfrom
NickStallman:fix/xshader-root-constants-private-srv
Open

NickStallman wants to merge 1 commit into
brcly:mainfrom
NickStallman:fix/xshader-root-constants-private-srv

Conversation

@NickStallman

Copy link
Copy Markdown
Contributor

The bug

The runtime appends two private root SRVs to a compute root when a program needs them: the heap index map (t0, space32766) and the buffer stride table (t1, space32766). The translator matched a compute root by its exact parameter count in two places:

  • sampler_heap::constants accepts table, constants and table, table, constants. With an SRV appended neither form matched, so the root constants were not declared and the registers they fill stayed 0.
  • The dispatch-ID registers are derived from the parameter count (4 + nparams, and the two-table check), so an appended parameter could move them.

The translation still compiled and ran, with zeros where the title's constants should be.

What it affects today

Of the 25,397 recorded ProjectScarlett requests, 127 are compute programs translated against a root with the stride table appended, and all 127 lose their root constants on main. 123 are CS_RaytracingResolve; the others are CS_ComputeImposterTransform, the two CS_EntityFireReduceClassification variants and one I could not name. In the resolve kernels the constants are four words: one is multiplied into a buffer index and one selects the kernel's mode.

All 127 are among the compute programs that only translate since #216, the set whose replacement with no-ops got a run past the Xid 109 in #232. That is a correlation, not a finding. A ProjectScarlett run with only this change still hit the Xid 109 at the same point, so it doesn't fix the hang on its own (see #232). It is still wrong output for those 127 programs, and it would also hit the roots #294 gives the index map to, since most of those have root constants.

The change

sampler_heap::guest_params gives the root without its trailing space-32766 root SRVs. The console program was compiled without them, so they take no launch register. The compute forms of constants and the dispatch-ID calculation use it. The pixel form, which names the index map itself, is unchanged.

Tests

  • the_runtimes_private_root_srvs_leave_a_compute_roots_layout_alone translates a program under table, constants with the flag, then with the index map, the stride table, and both appended. It fails on main at the first appended root (the constant buffer and its register load are missing).
  • cargo test for tools/shader-compiler: 411 passed. python -m unittest discover -s tests -q: 426 ran, OK.
  • Offline, every recorded request translated with main and with this change: 0 recovered, 0 regressed (23,720 translated, 1,569 refused and 108 failed on both sides). Outputs: 23,701 byte-identical, 127 changed. Each changed output only gains the cbuffer TBIndex… declaration and its register loads.

Checks

  • python tuxbox.py check passed on this branch, on AMD and NVIDIA:
    • AMD Raphael iGPU (1002:13c0), RADV (Mesa 26.0.8), GE-Proton11-14: the full python tuxbox.py check --adapter 1002:13c0 --proton … --prefix … --windows-dxc … passed, 132 gates.
    • RTX 5090 (10de:2b85), driver 620.70.10, GE-Proton11-14: the same full check passed, 132 gates.
  • Changed behaviour is covered by a Lanes scenario. No Lanes scenario dispatches a program with root constants under a root that gets a private SRV appended. The unit test covers the emitter. A scenario for the index-map form fits best with d3d12: give direct-indexed compute roots with tables the resource index map #294, which first appends the map to such roots.

🤖 Generated with Claude Code

…ivate root SRVs

The runtime appends the heap index map and the stride table to a root as root
SRVs in space 32766. Two places matched a compute root by its exact parameter
count: the root-constant layouts (`table, constants` and `table, table,
constants`) and the registers that hold the dispatch IDs. With an SRV appended
the constants were no longer declared and their registers stayed zero. That
already affects programs translated with the stride table: 127 of the recorded
ProjectScarlett requests gain their root constants back, and nothing else in
25,397 requests changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant