Skip to content

Shaders: a descriptor read only as data takes the kind of its entry's… - #1130

Closed
felicienradio wants to merge 1 commit into
Marvisak:mainfrom
felicienradio:shader/descriptor-data-same-entry
Closed

felicienradio wants to merge 1 commit into
Marvisak:mainfrom
felicienradio:shader/descriptor-data-same-entry

Conversation

@felicienradio

Copy link
Copy Markdown

… use

The console compiler reads sizes from a descriptor's bits (a texture's height and base level, say) in a loop of its own, apart from the loop that samples through the same heap entry. That load's dwords were never used as a resource, so its kind was unknown and the program was refused ("a descriptor read only as data"). Another load of the same entry (the same parameter and offset, and the same computed term or the first lane of the same VGPR in a waterfall pass) that is used as a resource now gives the kind, and the fields are rebuilt from the host view as for any descriptor read as data.

Translation census over the title's 26,503 containers, on #439's tree: 22,656 translated instead of 21,909 (747 more, none lost); the refusal falls from 819 programs to 53, and 19 of the others reach a later one. Of the shaders a run on an RTX 3060 refused, 172 more translate.

… use

The console compiler reads sizes from a descriptor's bits (a texture's
height and base level, say) in a loop of its own, apart from the loop
that samples through the same heap entry. That load's dwords were never
used as a resource, so its kind was unknown and the program was refused
("a descriptor read only as data"). Another load of the same entry (the
same parameter and offset, and the same computed term or the first lane
of the same VGPR in a waterfall pass) that is used as a resource now
gives the kind, and the fields are rebuilt from the host view as for any
descriptor read as data.

Translation census over the title's 26,503 containers, on Marvisak#439's tree:
22,656 translated instead of 21,909 (747 more, none lost); the refusal
falls from 819 programs to 53, and 19 of the others reach a later one.
Of the shaders a run on an RTX 3060 refused, 172 more translate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SDn5GupcrERtCYPyoztdtG
@pablogonz12

pablogonz12 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Independent check on Linux (RX 9070 XT, RADV/Mesa 26.3.1, dxil-spirv master, spirv-val 1.3). Your head 98f073d applied alone onto origin/main ffe310e, then the offline four-stage check over the 751-program world dump plus the 52-program BVH capture (768 programs after 35 duplicate containers are skipped):

translated translate refusals "a descriptor read only as data" spirv-val / pipeline failures
main ffe310e 666 102 4 (2 compute, 2 pixel) 10 / 0
your head 669 99 0 10 / 0

All 4 clear and no other class grows except one: a pixel program that main refused with "a descriptor read only as data" now reaches "a scalar memory read as data" (pixel 3 -> 4), so net +3 here. The 10 spirv-val failures are the same pre-existing ones; the RADV pipeline stage adds nothing.

For comparison, my own attempt at the same 4 (raw buffer view, commit 61085ee in our tree, not pushed) also clears them, with one landing on "a descriptor's address or format read as data" (669 translated, like yours). Yours and #1067 are the better fixes; I did not open a competing PR.

Not tested: the full archive (only these dumps), in-game, native Windows.

@shortselow-byte

Copy link
Copy Markdown

#1067 and #1130 both remove the refusal "a descriptor read only as data", in different ways, and neither mentions the other:

Tested on Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT, both on main ffe310e (neither has a CI run yet):

workspace tests clippy (default, --all-features) policy
#1067 6d30fd7 343 passed, 0 failed clean ok
#1130 98f073d 343 passed, 0 failed clean ok

They conflict in lower.rs (descriptor_data), so whichever merges second needs a rebase. They combine naturally: in #1067's version, match use_at.or_else(|| self.same_entry_use(site)), so #1130's lookup runs first and #1067's table/heap fallback only when no other load of the entry is used. With that one-line resolution (local, not pushed), both new tests pass together (a_descriptor_only_read_as_data_gives_its_views_size on the AMD device and WARP, a_descriptor_read_only_as_data_takes_the_kind_of_its_entrys_use), the workspace has 344 passed, 0 failed, and both clippy runs are clean.

That order would also keep #1067's 2D guess for heap entries that #1130 can't name, instead of using it first.

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Reviewed 98f073d and tested multi-descriptor s_load_dwordx16 + twin-load cases. One concrete offset/alignment bug in same_entry_use:

  • same_entry_use compares b.offset == a.offset without adding 4 * u32::from(other_first), and returns the other load's first (other_first) as site's own first (Source::Loaded { load: site, first }).
  • False match & wiped dwords: If another instruction loads two 8-dword descriptors via s_load_dwordx16 at 0x0 and samples other_first = 8 (entry 0x20), while site runs s_load_dwordx8 at 0x0 (entry 0x0, e.g. a CBV), b.offset == a.offset (0 == 0) falsely matches entry 0x20, shifts heap_index to 0x20, and computes rel = k.wrapping_sub(8) so every k in 0..8 becomes Val::Missing.
  • Missed twin match: Conversely, if site loads entry 0x20 directly (first = 0) while the resource access came from s_load_dwordx16 at 0x0 (other_first = 8), 0x0 != 0x20 fails to match the twin load.

Matching b.offset.wrapping_add(4 * u32::from(other_first)) == (a.offset & !31) while keeping site's own first = 0 and intra-slot offset in_slot = (a.offset & 31) / 4 (rel = (in_slot + k).wrapping_sub(u32::from(first))) resolves both cases cleanly. Verified with dxil.dll + RTX 5090 & WARP readback in fuzeofficlal/VIctory@66a9fde.

yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
Conflicts kept both sides: the split execute/submit (breadcrumbs cleared at the start of submit), the debug pixel shader and the breadcrumb stage notes, the view-heap-cap and wave keys of the shader cache with the breadcrumb key, and the single-exit block with the breadcrumb loops. Tests added by Marvisak#1084/Marvisak#1130/Marvisak#1269 initialise Parts with crumbs: None.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Zipettte

Copy link
Copy Markdown

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 98f073d: cargo test -p victory-shader passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

@alessiodeia

Copy link
Copy Markdown
Contributor

In-game data for 98f073d on an RTX 2070 SUPER (Turing, 32..32), driver 617.42, Windows 11. On this tree it is what clears the class, and it composes with #979.

Base tree: main ffe310e + #439 bf0f951 + #493 #587 #282 #876 #67 #490 #464 #984 + fix/unaligned-buffer-srv + the #840/#916 fork branches. Diag build, Series X, VICTORY_D3D12_DRED=1, 30 minutes per run, no device removal in any run. A regression below means a program that translated in the reference run and is unusable in the new one; programs a run never loaded don't count.

Run unusable programs a descriptor read only as data regressions
base tree 503 208 –
+ #979's two commits (b6a9bdc, c8353a8) 453 184 0
+ this PR + #1065 261 0 0 (vs either run above)

I haven't run a tree with @fuzeofficlal's offset correction for same_entry_use applied, so these numbers are for 98f073d as is.

No game data attached. AI-assisted (Claude Code).

@sinan-cmyk

Copy link
Copy Markdown

Offline measurement on a retail dump, and the shader tests on Ada

Result: +240 programs over main, 0 lost.

Offline. I merged head 98f073d onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,964 with this PR.

Failure on main Gained
emit: a descriptor read only as data 240

All 240 are among the programs that #1402 gains (its "a descriptor read only as data" part comes from #1067). Note: 72 more programs that fail with "a descriptor read only as data" on main now emit DXIL that the validator rejects ("Entry function performs some operation that is incompatible with the shader stage"). They still count as failing, but the emitted code is wrong rather than refused.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 121, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

@ScarionWorkspace

Copy link
Copy Markdown

#1067 vs #1130 head-to-head, full archive, bare main. Windows 11, RX 9070 XT, Rust 1.98.1, dxil.dll from SDK 10.0.26100. victory translate --list --validate over shaders.rpf + the executable (1.0.2.1, 25,901 programs), each PR alone merged onto main ffe310e, compared program by program:

validated "a descriptor read only as data" gained lost
main 21,736 394 – –
#1067 (6d30fd7) 22,031 17 +295 0
#1130 (98f073d) 21,976 53 +240 0
both, #1130's same_entry_use tried before #1067's table fallback 22,012 17 +276 0

AI-assisted (Claude); counts only, no game data.

@sinan-cmyk

Copy link
Copy Markdown

Stacked on #1402: no change, and the validator errors are gone

Result: 0 gained, 0 lost, and no failure reason changes on top of #1402. On main this PR gained 240 programs, and all of them are among #1402's gains (via #1067).

The 72 validator errors I reported on main do not appear on #1402. With the merge, 0 programs fail with "Entry function performs some operation that is incompatible with the shader stage".

The merge conflicts in 4 hunks of emit/lower.rs. I kept #1402's match use_at in descriptor_data, but made it match use_at.or_else(|| self.same_entry_use(site)), so this PR's same-entry lookup runs before #1067's table-range guess. Both helpers and both sets of tests are kept. cargo test --locked -p victory-shader --lib: 138 passed, 0 failed.

Method: victory translate --validate --list on shaders.rpf (1.0.2.1), dxil.dll 1.8.2502.11, compared program by program (25,889 programs), against #1402 at 2310409. AI-assisted (Claude Code). No shader names or data are included, per the asset policy.

@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

A descriptor read only as data takes its kind from another load of the same entry: exactly what main's descriptor_data does (75677cb, same parameter/offset/first-lane rule).

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
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.

10 participants