Skip to content

Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) - #146

Merged
ivall merged 2 commits into
xcl-dev:mainfrom
ozimchuk:console-list-user-sgprs
Nov 23, 2026
Merged

ivall merged 2 commits into
xcl-dev:mainfrom
ozimchuk:console-list-user-sgprs

Conversation

@ozimchuk

Copy link
Copy Markdown
Contributor

xbox_bvh_builder_builds_on_the_gpu and xbox_bvh_builder_builds_a_tlas_on_the_gpu fail on main: every ray that should hit misses, and the TLAS header is all zeros. They only do anything with XCL_PROBE_BVH_GPU / XCL_PROBE_BVH_TLAS set, so a normal cargo test stays green.

Cause

Since 18cb400 the root arguments of a compute dispatch go into user SGPRs s4… while they fit, and the rest into the table at s[0:1] (console_list::layout_from_blob). That is what the console's compiler emits now. The shaders inside XboxBvhBuilder.dll were built the earlier way, the one HANDOFF describes first ("determined on 52 shaders of XboxBvhBuilder.dll"): four user SGPRs whatever the root signature, s4 the group id, every argument read from the table.

The builder's first dispatch has a root signature of two descriptors and 16 constants. XCL puts the descriptors in s4…s7 and the constants in the table. The shader starts:

s_and_b32  s3, s1, 0xff
s_mov_b32  s2, s0
v_lshl_add_u32 v0, s4, 5, v0        ; s4 = group id
s_load_dword s5, s[2:3], 0x10       ; its count: table +0x10
v_cmpx_gt_u32 s5, v0
s_cbranch_execz …                   ; nothing to do
s_load_dwordx2 s[0:1], s[2:3], 0x0  ; a buffer's address: table +0

At +0x10 of the table it finds a constant that is 0, and leaves. All ten dispatches of a build run, none writes: after the list the destination and the scratch buffer are untouched.

Change

The number of user SGPRs is in each shader (COMPUTE_PGM_RSRC2, which CsInterface already reads to place the group id). It is now kept per translated compute pipeline (real::pso_user_sgprs) and caps the inline part (console_list::inline_for): never more bytes in registers than the shader has registers above s3. Used in both places that lay arguments out, the console list replay and bind_abi (with only the first, the BLAS test passed and the TLAS test did not). Parameters stay whole (the inline part ends where the last parameter that fits ends), and the entry is forgotten with the pipeline, like its root signature. A shader the rule fits gets what it got before; with the count unknown the rule applies as before.

Tests

New, no GPU: xbox_bvh_builder_shaders_get_no_argument_in_a_register_they_do_not_have (needs XCL_SAMPLE_DLLS). It finds every compute shader in XboxBvhBuilder.dll by its DXBC header and compares the user SGPRs of its stage descriptor with the layout from its own RTS0:

XboxBvhBuilder.dll: 52 compute shaders; by the layout's rule alone 48 would get arguments in registers they do not have

The same line on Windows 11 (26200) and under Wine. Also a unit test for inline_for.

With XCL_CONSOLE_LISTS=1 XCL_PROBE_BVH_GPU=1 XCL_PROBE_BVH_TLAS=1, on main at 484dd57:

main this branch
…builds_on_the_gpu, AMD iGPU (RADV) round 1: ray … left: None, right: Some(38) 64 and 200 triangles: 500 rays match brute force each (91 / 257 hits)
…builds_a_tlas_on_the_gpu, AMD iGPU header [0, 0, …], left: None, right: Some((38, 110)) 800 rays match brute force (69 hits)
both, RTX 5060 Ti (split wave64) the same failures the same passes

cargo test -p xcl --lib on the AMD GPU: 369 passed / 6 failed on main, 370 / the same 6 here (the new unit test). The six are not about this: two are my packaging (tests/data/llvm-amdgpu not next to the binary), three are RADV's ACO (gpu_format_stores_atomics_global_lds, gpu_f64_roots, gpu_f64_math_random: they pass with RADV_DEBUG=llvm and on NVIDIA), one is Wine (get_proc_address_and_load_library_ex_reject_null_name: last error 87, not 127); gpu_pso_e2e (6 / 6 with a retail shader pack), gpu_compute_e2e and the test title are unchanged.

What I could not check

The GPU runs are on Linux: Wine with vkd3d-proton, GNU toolchain build, and a vkd3d-proton patched to accept the objects whose vtable XCL replaces (a separate topic). On Windows only the no-GPU test was run. Since the argument layout is XCL's own code I expect the two GPU tests to fail on main and pass here on Windows as well; could you run them with the probe variables set?

AI-assisted.

🤖 Generated with Claude Code

ozimchuk and others added 2 commits November 23, 2026 17:22
…than it has

Root arguments of a compute dispatch go into user SGPRs s4… while they fit
and the rest into the table at s[0:1] (18cb400, measured on the console
compiler's output). XboxBvhBuilder.dll's shaders were built differently:
four user SGPRs whatever the root signature, s4 the group id, every
argument read from the table. For a root signature of two descriptors and
16 constants XCL put the descriptors in s4…s7 and the constants in the
table; the builder's first shader then read a constant where its count is
(`s_load_dword s5, s[2:3], 0x10`), found 0 and left. All of its dispatches
ran and none wrote: the BLAS and TLAS came out empty.

The number of user SGPRs is in each shader (COMPUTE_PGM_RSRC2, already
read for the group id's place). It is now kept per translated compute
pipeline (`real::pso_user_sgprs`, forgotten with the pipeline) and caps
the inline part (`console_list::inline_for`) in both places that lay
arguments out: the console list replay and `bind_abi`. Parameters stay
whole. A shader the rule fits is unaffected, and so is one whose count is
not known.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ot have

Every compute shader inside XboxBvhBuilder.dll (XCL_SAMPLE_DLLS), found by
its DXBC header: the user SGPRs its stage descriptor gives against the
argument layout from its own RTS0 part. All 52 have four user SGPRs; by
the layout's rule alone 48 of them would get arguments in s4 and up.
Runs in milliseconds and needs no device.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).

BBareth pushed a commit to BBareth/xcl that referenced this pull request Nov 23, 2026
…d title-list BVH builder slots

- Encode RDNA2 BVH descriptors (desc::bvh_words) for RAYTRACING_ACCELERATION_STRUCTURE SRVs in console descriptor heaps instead of zeroing the slot when pResource is NULL, and preserve them across descriptor copies.
- Fix image_bvh64_intersect_ray to use the full 64-bit node pointer (including vaddr[1]) and 48-bit BVH base address when selecting UMA memory windows, so BVH nodes above 4 GiB (including sparse title windows) resolve cleanly.
- Fix axis-aligned grazing rays (0 * inf = NaN) and reject NaN/inverted child boxes in both HLSL bvh_intersect and CPU bvh::intersect_node; add console prebuild_size and compressed-header helpers.
- Wire XboxBvhBuilder.dll command list slots xcl-dev#146 (global UAV barrier) and xcl-dev#148 (AllocateUploadMemory in UMA) into default title command lists (and size extended vtables to cover all console slots).
- Add configurable CheckFeatureSupport(D3D12_OPTIONS5) RaytracingTier reporting (config.raytracing / XCL_RAYTRACING: auto, tier1_1, tier1_0, off) with one-time tier logging in real and null backends.
- Add unit, multi-window GPU, and testtitle end-to-end tests.
BBareth pushed a commit to BBareth/xcl that referenced this pull request Nov 23, 2026
Raytracing SRVs in console heaps, 64-bit multi-window BVH traversal, title-list BVH builder slots (xcl-dev#146 barrier, xcl-dev#148 AllocateUploadMemory). Conflict in bind.rs: both sides kept.
@ozimchuk
ozimchuk deleted the console-list-user-sgprs branch November 24, 2026 04:56
IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 24, 2026
…cl-dev#970)

A console depth buffer that is also a UAV has no ALLOW_UNORDERED_ACCESS on
the PC and its UAVs were null views: what the title's shaders wrote there
was lost (the retail title of xcl-dev#505 moves its D16 shadow maps into the
UNORDERED_ACCESS layout before it renders depth into them).

With XCL_DEPTH_UAV_TWINS=1, such a depth buffer of one plane (R16 / R32
typeless) gets a twin: a texture of the same format and size with unordered
access and no depth, kept as the depth buffer's private data. Its UAVs are
views of the twin, and at the title's enhanced barriers (xcl-dev#146) into the
UNORDERED_ACCESS layout the depth buffer is copied to the twin, at those
out of it the twin back (in console-recorded lists the copies are recorded
in the stream). XCL applies none of the title's enhanced barriers, so the
copies' transitions start from the PC state the depth buffer was made in
(kept at CreatePlacedResourceX; DEPTH_WRITE when not known). Depth and
stencil formats keep null views: the PC has no UAV format for them.

Off by default: without the variable nothing changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
R1kkku pushed a commit to R1kkku/xcl that referenced this pull request Nov 24, 2026
…#970)

A console depth buffer that shaders write too has no ALLOW_UNORDERED_ACCESS
on the PC (pc_resource_desc drops it) and its UAVs are null views, so the
writes are lost. The title's barriers that use such a resource as a UAV are
now counted and logged (the first 8, then every power of two):
- transitions from or to UNORDERED_ACCESS and UAV barriers naming it, both
  for PC-format lists (resource_barrier_x) and console-recorded ones
  (console_list replay);
- enhanced texture barriers (xcl-dev#146, D3D12_BARRIER_GROUP) with the
  UNORDERED_ACCESS layout or access. XCL still turns xcl-dev#146 into one global
  UAV barrier; only the description is read here.
The null-view warning gives its total instead of stopping at 4.

Measured on the retail title of xcl-dev#505 (RTX 5080, 300 s runs, A at 15 s):
no legacy barrier touches these resources; enhanced barriers move D16
shadow maps (768x768x6, 1024x1024, 512x512) into or out of the
UNORDERED_ACCESS layout once the world starts loading (62-64 s; 12 in a
run with every one logged).

No behaviour change: every barrier goes to the PC as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 24, 2026
…#970)

A console depth buffer that shaders write too has no ALLOW_UNORDERED_ACCESS
on the PC (pc_resource_desc drops it) and its UAVs are null views, so the
writes are lost. The title's barriers that use such a resource as a UAV are
now counted and logged (the first 8, then every power of two):
- transitions from or to UNORDERED_ACCESS and UAV barriers naming it, both
  for PC-format lists (resource_barrier_x) and console-recorded ones
  (console_list replay);
- enhanced texture barriers (xcl-dev#146, D3D12_BARRIER_GROUP) with the
  UNORDERED_ACCESS layout or access. XCL still turns xcl-dev#146 into one global
  UAV barrier; only the description is read here.
The null-view warning gives its total instead of stopping at 4.

Measured on the retail title of xcl-dev#505 (RTX 5080, 300 s runs, A at 15 s):
no legacy barrier touches these resources; enhanced barriers move D16
shadow maps (768x768x6, 1024x1024, 512x512) into or out of the
UNORDERED_ACCESS layout once the world starts loading (62-64 s; 12 in a
run with every one logged).

No behaviour change: every barrier goes to the PC as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 24, 2026
…vall#970)

A console depth buffer that is also a UAV has no ALLOW_UNORDERED_ACCESS on
the PC and its UAVs were null views: what the title's shaders wrote there
was lost (the retail title of ivall#505 moves its D16 shadow maps into the
UNORDERED_ACCESS layout before it renders depth into them).

With XCL_DEPTH_UAV_TWINS=1, such a depth buffer of one plane (R16 / R32
typeless) gets a twin: a texture of the same format and size with unordered
access and no depth, kept as the depth buffer's private data. Its UAVs are
views of the twin, and at the title's enhanced barriers (ivall#146) into the
UNORDERED_ACCESS layout the depth buffer is copied to the twin, at those
out of it the twin back (in console-recorded lists the copies are recorded
in the stream). XCL applies none of the title's enhanced barriers, so the
copies' transitions start from the PC state the depth buffer was made in
(kept at CreatePlacedResourceX; DEPTH_WRITE when not known). Depth and
stencil formats keep null views: the PC has no UAV format for them.

Off by default: without the variable nothing changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepdev237 added a commit to deepdev237/xcl that referenced this pull request Nov 24, 2026
Log the title list, resource and access masks from slot xcl-dev#146 next to the indirect calls forwarded to the PC. This helps correlate the same resource when investigating xcl-dev#675 without adding GPU commands.

Assisted-by: OpenAI Codex (gpt-6.2-sol)
IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 24, 2026
…#970)

A console depth buffer that shaders write too has no ALLOW_UNORDERED_ACCESS
on the PC (pc_resource_desc drops it) and its UAVs are null views, so the
writes are lost. The title's barriers that use such a resource as a UAV are
now counted and logged (the first 8, then every power of two):
- transitions from or to UNORDERED_ACCESS and UAV barriers naming it, both
  for PC-format lists (resource_barrier_x) and console-recorded ones
  (console_list replay);
- enhanced texture barriers (xcl-dev#146, D3D12_BARRIER_GROUP) with the
  UNORDERED_ACCESS layout or access. XCL still turns xcl-dev#146 into one global
  UAV barrier; only the description is read here.
The null-view warning gives its total instead of stopping at 4.

Measured on the retail title of xcl-dev#505 (RTX 5080, 300 s runs, A at 15 s):
no legacy barrier touches these resources; enhanced barriers move D16
shadow maps (768x768x6, 1024x1024, 512x512) into or out of the
UNORDERED_ACCESS layout once the world starts loading (62-64 s; 12 in a
run with every one logged).

No behaviour change: every barrier goes to the PC as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 24, 2026
…cl-dev#970)

A console depth buffer that is also a UAV has no ALLOW_UNORDERED_ACCESS on
the PC and its UAVs were null views: what the title's shaders wrote there
was lost (the retail title of xcl-dev#505 moves its D16 shadow maps into the
UNORDERED_ACCESS layout before it renders depth into them).

With XCL_DEPTH_UAV_TWINS=1, such a depth buffer of one plane (R16 / R32
typeless) gets a twin: a texture of the same format and size with unordered
access and no depth, kept as the depth buffer's private data. Its UAVs are
views of the twin, and at the title's enhanced barriers (xcl-dev#146) into the
UNORDERED_ACCESS layout the depth buffer is copied to the twin, at those
out of it the twin back (in console-recorded lists the copies are recorded
in the stream). XCL applies none of the title's enhanced barriers, so the
copies' transitions start from the PC state the depth buffer was made in
(kept at CreatePlacedResourceX; DEPTH_WRITE when not known). Depth and
stencil formats keep null views: the PC has no UAV format for them.

Off by default: without the variable nothing changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
IvyNotFound pushed a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
…rceBarrier

Console command list slot xcl-dev#146 is ID3D12GraphicsCommandList7::Barrier(NumBarrierGroups, pBarrierGroups) on both older and newer layouts; previously it emitted only a wildcard UAV barrier, dropping every texture layout transition.

- Parse D3D12_BARRIER_GROUP (GLOBAL, TEXTURE, BUFFER) safely with readable() checks; unparseable calls fall back to the legacy global UAV barrier.
- Map D3D12_BARRIER_LAYOUT 0..=31 including 0x1F (DIRECT_QUEUE_GENERIC_READ_COMPUTE_QUEUE_ACCESSIBLE) and fall back to access bits for console-only layouts > 0x1F; align device xcl-dev#127/xcl-dev#133 initial layout states with texture-vs-buffer awareness.
- Track whole-resource states across xcl-dev#127/xcl-dev#133 creation, legacy xcl-dev#26, and enhanced xcl-dev#146 (cleared on res_release) for UNDEFINED Before layouts, forward emitted transitions to title_textures::note_transitions, emit wildcard aliasing barriers for UNDEFINED placed textures, keep non-UAV textures out of UNORDERED_ACCESS, and skip states disallowed on compute/copy lists.
raylitebull added a commit that referenced this pull request Nov 25, 2026
…olves

Command list #146 (uav_barrier_x) synced depth+UAV enhanced barriers and PlacedUav format-alias pairs, but never checked D3D12_BARRIER_TYPE_TEXTURE transitions on TitlePlaced format-alias writers (such as R9G9B9E5 lighting targets), leaving aliased SRVs stale under enhanced barriers.

Add format_alias::filter_enhanced_barriers and call sync_title_writers in uav_barrier_x. Also translate console target formats in resolve_subresource_x and resolve_subresource_region_x via device_x::pc_target_format.

Assisted-by: Antigravity (Gemini 4 Neon High)
koboshchan pushed a commit to koboshchan/xcl that referenced this pull request Nov 26, 2026
…olves

Command list xcl-dev#146 (uav_barrier_x) synced depth+UAV enhanced barriers and PlacedUav format-alias pairs, but never checked D3D12_BARRIER_TYPE_TEXTURE transitions on TitlePlaced format-alias writers (such as R9G9B9E5 lighting targets), leaving aliased SRVs stale under enhanced barriers.

Add format_alias::filter_enhanced_barriers and call sync_title_writers in uav_barrier_x. Also translate console target formats in resolve_subresource_x and resolve_subresource_region_x via device_x::pc_target_format.

Assisted-by: Antigravity (Gemini 4 Neon High)
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
The null device's plain lists ran the console memory slots (xcl-dev#60/xcl-dev#61/
xcl-dev#69-xcl-dev#72/xcl-dev#89/xcl-dev#93) as logging stubs, so the title's console_list_methods
check read back 0x0 on the null backend while the identical immediate
host writes already passed on Vulkan lists. The vtable now wires the
same VulList_* functions into Kind::CommandList; GetDevice (xcl-dev#7),
the UAV barrier (xcl-dev#146) and AllocateUploadMemory (xcl-dev#148) stay
Vulkan-only with their slices (barrier/upload ride with raytracing,
which still fails on null at the OPTIONS5 tail-zero assert).

Failing-first: the new null_list_shares_the_console_memory_methods
test fails pre-route (slot 69 stub writes nothing) and passes now
(write32/fill/copy/timestamp land, pre-satisfied wait returns,
kickoff is a silent no-op), mirroring the title's asserts.
Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 797
passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots:
null 12->11 FAILs (Write32 fixed, byte-identical remainder), Vulkan 9
unchanged with the real present (640x360 token 0x1 on Intel Arc).
Retail HOLDS (SIGSEGV exe+0x2237320, exit 139, called_stubs 20,
0 d3d12).
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
The null device wrote RaytracingTier at +8 but left the oversized-probe
tail untouched, so the title's raytracing_surface check died at the
16-byte 0xAA tail assert on null while the identical probe passed on
Vulkan. Port the Vulkan tail-zero block (bytes past 12 zeroed, 4 KiB
sanity cap) into the null Device_CheckFeatureSupport.

Failing-first: new null_check_feature_support_zeroes_options5_tail test
fails pre-fix ([170 x4] vs [0 x4]) and passes now; other-feature and
short-struct probes pass through untouched on both paths.
Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 798
passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots:
null stays 11 FAILs (raytracing now clears the tail assert and stops one
leg deeper at the AS SRV descriptor, which needs the Vulkan-only RTAS
view + xcl-dev#146/xcl-dev#148 — that is the unlocked next slice, not this one; all
other null FAILs byte-identical to the pre-fix baseline, 0 non-GPU),
Vulkan 9 unchanged. Retail HOLDS (SIGSEGV exe+0x2237320, exit 139,
called_stubs 20, 0 d3d12).
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
…ev#148 (XS)

The null device left slot xcl-dev#18 a logging stub, so the title's
raytracing_surface leg 2 read heap zeros ([0 x4]) instead of the RDNA2
BVH words; legs 3 (xcl-dev#148 upload, xcl-dev#146 barrier) were Vulkan-list-only, so
the default title list had stubs there too. All three are pure
host-memory operations (descriptor-word write, aligned zeroed alloc, a
coherent single-queue no-op barrier), so the null objects share the
Vulkan implementations with no GPU needed — same precedent as the xcl-dev#3
Execute leg sharing the console memory methods.

Failing-first: new null_device_serves_the_raytracing_surface test fails
pre-fix ([0 x4] vs the BVH words) and passes now; other view dimensions
and nulls still pass through untouched (existing Vulkan helper test).
Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 799
passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots:
null 12->11 FAILs (raytracing_surface now PASSES; every other FAIL
byte-identical, 0 new non-GPU), Vulkan 10 total incl. files (9 D3D12.X,
raytracing absent — paths untouched). Retail HOLDS (SIGSEGV
exe+0x2237320, exit 139, called_stubs 20, 0 d3d12).
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.

2 participants