tombox-xshader: structured-buffer GetDimensions stride is a DXC constant, and WARP hides stride mismatches that AMD hosts expose #376
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from omonkeyz/xbox-emulator. Originally posted by SchmashinPrunes on 2026-11-24T18:45:06Z.
Library / area: tombox-xshader, the structured-buffer byte-offset reads (
tb_sbw_*inhlsl.rs, used bys_buffer_load*), and how CI catches stride mismatches.Two measured facts relevant to #346 and #347. Those PRs fix the stride mismatches GPU-based validation found on The Matrix Awakens, but the fallback they keep, and CI's ability to notice the problem, rest on assumptions that don't hold.
1.
GetDimensionsnever returns the view's stridetb_sbw_*is commented "the element stride is a property of the view, not of the shader, so it is queried", and it computese = off / stfromGetDimensions(n, st). DXC compiles the stride output of a structured buffer'sGetDimensionsto a constant: the size of the declared element.dxc -T cs_6_0emitsbufferStore(..., i32 0, i32 0, i32 16, ...), soo[0]is always 16, whatever the view'sStructureByteStrideis. In other words,tb_sbw_*always addresses with the extent-guessed element size fromsbuf_words. #347 still falls back to that size for slots where the FSSM table gives no single stride (conflicting strides, other spaces, bindless, no table).2. WARP hides stride mismatches; AMD does not
I took
scalar_smem_loadswith the harness view fix from #375, kept the shader'sTbElematuint w[4](16 bytes), and created the UAV withStructureByteStride = 64:TOMBOX_EXEC_HW=1)The AMD values match exactly one model: indexing uses the view's 64-byte stride, while
stis the declared 16. For example, offset0x24in slot 1 givese = 2, w[1], so the read lands at 128 + 2·64 + 4 = 260 bytes, which is word 65 (0xa5004141), and that's what AMD returned. WARP evidently addresses with the shader's declared element, so it gets the right word anyway.So any remaining mismatch between a declared
TbElemand a title's view can't be seen on WARP-only CI, but gives wrong data on AMD hosts and, per #346/#347, on RDNA2 under GPU-based validation.Suggestions
GetDimensionsfor the stride. Fix the misleading comment either way.ubufN, and a separate case could assert that the translator's declared element matches a given view stride. That would catch regressions without needing an AMD host.Measurements:
origin/mainf89e410, RX 9060 XT on Windows 11, DXC fromTOMBOX_DXC_DIR. Happy to rerun anything on that card.🤖 Generated with Claude Code
Imported from omonkeyz/xbox-emulator. Originally posted by SchmashinPrunes on 2026-11-25T15:30:59Z.
Update: #347, now on main, sizes structured-buffer elements from the FSSM stride table, and slots that the PSV marks as raw are now declared
ByteAddressBuffer. So the cases measured here are covered whenever the table gives a stride.What remains is the fallback, where there's no single FSSM stride. There,
tb_sbw_*still callsGetDimensions, which DXC folds to the declared element size. The comment above it is therefore misleading, and a mismatch with the title's view would still read the wrong words on AMD hosts. Fixing that properly needs raw views from d3d12_xs, so I'm leaving it as a note here rather than a PR.