Skip to content

GPU and shaders: publish bounded descriptor size metadata - #1971

Open
thatirishguyyy wants to merge 2 commits into
Marvisak:mainfrom
thatirishguyyy:review/victory-host-descriptor-metadata
Open

thatirishguyyy wants to merge 2 commits into
Marvisak:mainfrom
thatirishguyyy:review/victory-host-descriptor-metadata

Conversation

@thatirishguyyy

Copy link
Copy Markdown

Follow-up to #1067. Size-only shader queries can read descriptor metadata from the host heap. The runtime supplies supported size, view type, and mip fields from the actual view. Existing buffer addresses are preserved, deferred views are populated at first bind, and out-of-range slots resolve to a zero row.

Validation

  • On 940d32f6, both tracked PS_PuddleDetect variants emit DXIL and pass the Windows SDK validator. Three host metadata tests and the synthetic shader readback passed on WARP, including slot rewrites, clearing, and out-of-range reads.
  • On the earlier 170ab232 base, the bounded prototype added 36 DXIL-valid shaders and lost none across 26,096 programs.
  • World rendering and AMD hardware stability remain unverified for this branch.

AI-assisted with Codex.

Supply size and view fields from the host descriptor heap to size-only shader queries. Keep buffer address fields, preserve deferred views on first bind, and select a zero row outside the heap.

AI-assisted.
Derive implicit view kinds from the resource shape and reject unknown explicit view kinds. AI-assisted.
@thatirishguyyy
thatirishguyyy marked this pull request as ready for review November 25, 2026 02:02
@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at 1ae8ad3. victory-shader: 244 passed, with only #1744's 3 NVIDIA failures. victory-gpu: 144 passed, 2 failed, with only the two NVIDIA heap-cap failures main also has (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views). Same as main on this hardware. Not run: a title.

AI-assisted (Claude Code).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed PR: victory-shader part macOS-tested in batch queue; victory-gpu part Windows-only static.

Publish bounded descriptor size metadata (gpu+shader): shader half macOS-tested separately, GPU half Windows-only.

@thatirishguyyy

Copy link
Copy Markdown
Author

Exact-base follow-up: comparing 940d32f6 with PR head 1ae8ad32 across 26,096 programs, this PR adds 36 DXIL-valid shaders with zero validation regressions and clears all 36 descriptor read only as data refusals.

If anyone already reaches the prologue on a working build, could you run a paired comparison from the same checkpoint, with #1971 as the only code change? Please report the base commit or PR stack, GPU and driver, whether visible draws or effects change in the same scene, and whether either run hangs. AI-assisted.

@DesertGamer

Copy link
Copy Markdown

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

@akimfomin

Copy link
Copy Markdown

Thatirishguyyy, PortBridge connected the exact 1ae8ad326 metadata writer and production upload allocation to a small independent HLSL readback through D3D12 root SRV t1, space2. On an RTX 4070 Ti SUPER all 80 output words matched across four fenced submissions: a deferred 36×22 array view, a rewrite to 18×11 on the same table address, a separate heap's two rows, and the original table after clearing. Both out-of-range indices returned zero every time.

Exact source construction and sanitized raw native words. This checks the real metadata allocation and writer with fixture-owned heap selection. The production shader translator's lowering and a title run remain outside this check. The fixture did not request the D3D12 debug layer. AI-assisted PortBridge verification (OpenAI Codex).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. Publish bounded descriptor size metadata — shader half verified here (144 green); the victory-gpu half is Windows-only and was staticked separately. Bounded metadata prevents oversized descriptor tables.

@zed6000

zed6000 commented Nov 25, 2026

Copy link
Copy Markdown

Measured offline on the title's shaders (the method in #1247): merged onto main 940d32f (a clean merge) and compared program by program (victory translate --validate --list, shaders.rpf 1.0.2.1, dxil.dll 1.8.2502).

+36 programs, 0 lost. All 36 failed on main with "a descriptor read only as data", so this PR clears that reason on this title completely. It also merges cleanly together with #1989, #1065 and #1883: the four together give +1,683 programs and 0 lost, and cargo test -p victory-shader --lib passes (252/0) on an RX 7900 XTX. Offline counts only; no program names or data.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work.

The view-address table (HostHeap::view_addresses, write_address in crates/victory-gpu/src/descriptor/host.rs) grows to 16 bytes per slot and gets a count row and a null row. The new view_size_words fills in descriptor dwords 1–3 (width, height, resource type, last level), and Lower::view_addresses in crates/victory-shader/src/emit/lower.rs now reads dwords 0–3 with a bounds check. The type codes (8–15), the width split (2 bits in dword 1, the rest in dword 2), height at bit 14 and last level at bit 16 match the published GFX10 image descriptor layout. CI (check) passes, and the offline count (+36 programs, 0 lost) has been confirmed independently.

What it needs:

  • State the evidence. This changes what translated shaders read from descriptors, so please name the reference for the bit layout in the PR (the public RDNA ISA guide or Mesa's register definitions). Also add a short comment at view_size_words.
  • Buffer size units. For buffer views, dword 2 gets NumElements, while dword 1 keeps stride 0 (the shortcut in view_addresses). With stride 0, the hardware's record count is in bytes, so a program that derives a typed or structured buffer's size from these words gets a value off by the element size. Either write bytes (element_size is already in this file) together with a matching stride, or leave buffer views out of the size fields.
  • Fields that silently read 0. Before, any read of dwords 2–3 refused the program ("a descriptor read only as data"). Now every read of those dwords succeeds, and every field except width, height, type and last level reads as 0: format bits in dword 1, swizzle, base level and tiling in dword 3, and so on. A program that uses those bits now gets wrong values instead of being refused. Either restrict this to size queries (for example, check that only the size fields are used), or document this as a shortcut: with the consequence.
  • Small things: the depth and array size (dword 4) are not provided, so a 3D or array size query still reads nothing useful. In the test module, run rustfmt on the one-line if ... { return None; } and remove the doubled blank lines.

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants