Shaders: recover record counts for descriptor-only structured buffers #329
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/329"
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 Marvisak/VIctory. Originally posted by Raxstreams on 2026-11-24T02:20:35Z.
Some compute shaders load a four-dword buffer descriptor and test its record count without ever issuing a buffer access. The emitter previously needed a resource instruction to infer the view type and stopped at
a descriptor read only as data.For a static table load at an exact binding offset, the emitter can recover the record count with
GetDimensionswhen the native metadata supplies a valid structured stride and the original PSV0 declarations confirm a structured buffer. Conflicting declarations across register spaces, unknown bindings, and dynamic ranges keep the existing unsupported path.On Windows with an RTX 3080 Ti, the isolated
CS_MinTimestepReduceshader validated and created a D3D12 compute pipeline on this branch, based on upstream main. A synthetic GPU test checks the actual returned counts for buffers with 3 and 11 records and covers conflicting declarations. All 70 shader library tests and the repository asset-policy check passed.This is independent of the SGPR spill work in #298 and #309 and leaves the world-rendering issue open.
Imported from Marvisak/VIctory. Originally posted by SpaghettiMaster545 on 2026-11-24T03:12:45Z.
Tested
02564c5merged alone ontomaind2a4bae, with the title, againstmainon the same machine.VICTORY_CACHE_DIR, scripted keys into story mode, until the host GPU failure (#71, unrelated).a descriptor read only as data: onmain, 21 programs stop with this reason (15–21 over three runs, depending on how far each run gets). With this PR, 1 of those 21 translates and 20 still stop with the same reason. No program stops with it that did not onmain.main, nothing that ran there stops with this PR.So on this title the PR's case covers one of the programs with this reason. The other 20 load the descriptor in some other way than a static table load at an exact binding offset with a native structured stride, or lack one of the conditions the PR checks. I have not looked at which.
Not tested
(Claude Code, Claude Opus 5.5: ran the title on both builds and compared the logs program by program.)
Imported from Marvisak/VIctory. Originally posted by EduAzevedo on 2026-11-24T04:55:06Z.
Measured
02564c5on the retail shaders (v1.0.2.1, Series X package), offline withvictory translate --jobs 8 --list, all 26,148 programs, againstmaind2a4bae, alone and merged with #309 (64c7188, clean merge):maina descriptor read only as data19 more programs translate (18 pixel, 1 compute); none that translate on
mainstop. For comparison on the same corpus, #180 takesa descriptor read only as datato 1 (with or without #309), so the two overlap; I have not measured them together.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by EduAzevedo on 2026-11-24T05:02:56Z.
Follow-up to the overlap question above, from the same logs: the 19 programs this PR makes translate do not translate with #180 (
5ff639e, alone or with #309). With #180, 18 of them get pasta descriptor read only as dataand stop ata scalar memory read as data; the other 1 is the singlea descriptor read only as dataprogram #180 leaves. So on the title's shaders the two are complementary rather than redundant: this PR finishes those 19, #180 covers the other ~160.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T12:56:22Z.
Review: COMMENTED
Tested
02564c5on Windows 11, RTX 5070, MSVC:cargo test -p victory-shader -- --test-threads=170 passed, andcargo clippy -p victory-shader --all-targetsis clean.victory translate --validate --pipelineson the local title executable still reports 12 of 12 programs, so the new path isn't hit there. The PR adds no tests.The guards are careful: a static table load only, exact
table_offset_dwords * 4match, 4 dwords, SRV or UAV, a stride of 4 to 2048 that's a multiple of 4, and every covering PSV0 declaration structured. That's the right shape, since a wrong guess here mis-annotates a handle. Two requests before approving:s_load_dwordx4of a table entry whoseNUM_RECORDSdword only feeds a compare, with matching PSV0 and nativeused. One case where it lowers toGetDimensionswith the stride annotation, and one where the PSV0 declaration is typed or raw and it still refuses. Nothing in the suite reaches theNonearm today.declares_structured_bufferreads PSV0's resource table with a hard-coded layout (infosize at 0, count and stride at4 + info). That holds for the PSV versions dxc emits today, but a short comment naming the PSV version it assumes would help the next change there.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:14:58Z.
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/mod.rs,crates/victory-shader/src/emit/valu_tests.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.