Skip to content

Shader tests: bind raw SRVs in the waterfall buffer test - #102

Open
vicennpacheco wants to merge 1 commit into
fxceless:mainfrom
vicennpacheco:fix/waterfall-raw-buffer-views
Open

vicennpacheco wants to merge 1 commit into
fxceless:mainfrom
vicennpacheco:fix/waterfall-raw-buffer-views

Conversation

@vicennpacheco

Copy link
Copy Markdown

Problem

emit::waterfall_tests::lanes_load_from_the_buffer_their_nested_arms_chose fails on AMD GCN 5 hardware (Vega 8 / gfx90c):

  • Expected: [100..115, 216..223, 0..0]
  • Got: [100..107, 0..0]

Root cause

WATERFALL_JOINED_BUFFER_WAVE32 lowers its untyped buffer_load_dword ... offen to a ByteAddressBuffer handle (dx.op.annotateHandle with ResourceProperties { i32 11, i32 0 }, dx.op.rawBufferLoad.f32, verified with dxc -dumpbin), matching victory-gpu's raw_window contract that binds structured views as raw (DXGI_FORMAT_R32_TYPELESS, D3D12_BUFFER_SRV_FLAG_RAW).

However, the test created Stride::Structured(4) SRVs (DXGI_FORMAT_UNKNOWN, NumElements = 32, StructureByteStride = 4, Flags = NONE). On GCN 5, structured V# descriptors store NUM_RECORDS in elements (32) rather than bytes (unlike RDNA / GFX10+), so raw byte-offset loads (lane * 4) pass bounds checks only for lanes 0..7 (0..28 < 32) and return 0 for lanes 8..23 (32..92 >= 32). (Doubling first/second to 64 elements with Stride::Structured(4) confirmed this directly: lanes 0..15 succeeded and lanes 16..23 returned 0.)

Fix

Bind Stride::Raw for both buffer SRVs in lanes_load_from_the_buffer_their_nested_arms_chose, matching the emitted ByteAddressBuffer handle and victory-gpu's raw_window host views.

Verification

Tested on Windows 11, AMD Radeon Vega 8 iGPU (Ryzen 7 5825U, GCN 5 / gfx90c, PCI 1002:15E7, AMD driver 31.0.21921.13001), Rust 1.98.1 (x86_64-pc-windows-msvc), without game files:

  • cargo test -p victory-shader --lib -- waterfall_tests: 5 passed, 0 failed (both Vega 8 hardware and WARP)
  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-shader --lib -- waterfall_tests: 5 passed, 0 failed, no debug-layer errors
  • cargo clippy -p victory-shader --tests -- -D warnings: clean

(AI-assisted investigation and patch.)

`lower` annotates untyped buffer loads as `ByteAddressBuffer`
(`ResourceProperties { 11, 0 }`), matching `victory-gpu`'s `raw_window`
host views. `lanes_load_from_the_buffer_their_nested_arms_chose` bound
`Stride::Structured(4)` instead, which on AMD GCN 5 (Vega 8, gfx90c)
truncates raw byte offsets against `NumElements` (32), returning zeros
from lane 8 onward.

Bind `Stride::Raw` so the test views match the emitted DXIL handle.
@HAL9000RELOADED

Copy link
Copy Markdown

RX 7900 XTX (RDNA3), Windows 10 + #402, main d510ee4: lanes_load_from_the_buffer_their_nested_arms_chose passes with this PR and also on main without it, so the GCN 5 failure doesn't reproduce on RDNA3. No regression. Run table: #129 (#129 (comment)).

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