Skip to content

Shaders/GPU: port experimental GTX compute and vertex fallback to current main - #2203

Draft
ElSeba0811 wants to merge 4 commits into
Marvisak:mainfrom
ElSeba0811:codex/gtx-upstream-update
Draft

ElSeba0811 wants to merge 4 commits into
Marvisak:mainfrom
ElSeba0811:codex/gtx-upstream-update

Conversation

@ElSeba0811

Copy link
Copy Markdown

This brings our experimental compute + vertex fallback onto 940d32f, so it can work with main's root UAVs, title-memory views and write marks. I'm testing on a GTX 1070 Ti (8 GB, no mesh shaders), i7-9700K and 16 GB RAM.

Related to #3 and the discussion on #961. This is our separate GTX branch, including additional guest-wave and validation work. I'm opening it as a draft because correct world rendering and playable FPS are still unverified.

What changed

  • Port the compute/vertex mesh path, eligible wave64 schedules and bounded indirect argument conversion while retaining upstream's memory/view bindings and helper-lane handling. Private scratch uses space 3 and the pulling vertex shader uses SRV 254.
  • Bound scratch reuse and allow an idle snapshot-pool cap. Match the descriptor heap and shader clamp to the GTX's one-million-view limit; remapping excess title descriptors remains unfinished.
  • Supply texture-view dimensions, mip levels and type through the view metadata table without eagerly creating placed textures. Keep unsupported descriptor-bit reads refused.
  • Fix module UAV flags and use validator 1.8 with matching PSV metadata for compute shaders using implicit derivatives.
  • Include handwritten synthetic regression tests and build/test instructions.

The three commits keep the fallback port, later shader fixes and documentation separate.

What we actually verified

  • Five new validator tests pass. The old implementation fails the two tests that reproduce the bugs.
  • Latest shader library run: 274 passed, 2 failed, 11 ignored. Both failures reproduce with identical values on untouched 940d32f: a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware. Their assertions remain unchanged.
  • Explicit image-view and compute-sampling checks pass on GTX 1070 Ti and WARP. Earlier port checks passed four mesh tests, two election tests and four indirect tests on each relevant adapter; the image update was followed by mesh/indirect regressions.
  • Both workspace/all-targets Clippy configurations pass with -D warnings. Asset policy passes for all 193 files, and git diff --check passes. The upstream tree has unrelated formatting differences.
  • Offline census: 14,240/14,240 emitted vertex/pixel programs validate; 2,621/2,621 emitted compute programs validate. There are still 7 vertex/pixel and 58 compute translation refusals. Native-mesh validation is 8,694/8,765. The last validator fixes added 867 vertex + 735 compute passes without changing any other census outcome; the earlier image metadata fix added 35 pixel programs.

Those census counts are validator results, not proof that every shader runs through the GTX fallback. No title pipelines are created by that scan.

Still open

The first game trial of the final binary initialized D3D12, then our external system-memory guard stopped it after 14.8 seconds. No frames were captured, so we have no rendering or FPS improvement to claim from this build. D3D12 debug-layer validation was unavailable on this PC.

Wave64 support is limited to eligible schedules, some programs are still refused, and oversized descriptor heaps still need remapping. This is a reviewable experimental starting point, not a playable-game release.

The runtime source matches the locally tested executable with SHA-256 757ac37856f0d563c0c0c226f02f8fc3e24af887d20b47f5340d1a4a888b25f2; the later commit changes documentation only. No game files, extracted shaders, binaries or raw game logs are included.

AI-assisted implementation, review and validation with Codex and Claude.

Preserve buffer address words while exposing image-view dimensions, mip
levels and type through the view metadata table. Inspect placed textures
without creating host textures; retain conservative descriptor-bit checks.

Declare UAVsAtEveryStage for non-pixel/non-compute module UAVs. Compute
implicit derivatives use validator 1.8 and matching PSV runtime info.
Add handwritten regression fixtures and GTX/WARP sampling checks.

Five validator regressions pass; shader suite 274 passed, two known
upstream GTX failures, 11 ignored. This is not a gameplay claim.
Implemented and reviewed with Claude and Codex assistance.

@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.

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Large mixed PR: experimental GTX compute/vertex fallbacks ported — big surface, shader+gpu+docs. Shader half testable but the port is big enough that I'd want it split or at least Windows CI evidence before merge. Static review only here.

@sinan-cmyk

Copy link
Copy Markdown

Your census reproduces, and most of the gain overlaps open PRs

I merged head e35c044 onto main 940d32f and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. Compared program by program with main (25,889 programs): +1,637 validated, 0 lost (23,918 → 25,555). That matches your 867 + 735 + 35.

Overlap with other PRs, measured the same way on 940d32f:

Gained here Failure on main Same programs as
867 "Flags must match usage" all 867 that #1989 gains (and #1977, now closed)
735 "Entry function performs some operation that is incompatible with the shader stage" 735 of the 777 that #2091 gains (from its #1065 commit)
35 "a descriptor read only as data" gained only here, among the PRs I have measured

So for the census, the validator fixes in this PR duplicate #1989 and #1065. Only the 35 from the image metadata change are new. #2091 has 42 programs that this PR does not gain.

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

@L1DRE

L1DRE commented Nov 25, 2026

Copy link
Copy Markdown

Tried e35c044 on another GTX 1070 Ti: 8 GB, driver 582.53, i5-12400F, 32 GB RAM, Windows 11 23H2 (22631), title on an HDD. I used the diag build and your four variables (VICTORY_MESH_COMPUTE, VICTORY_MESH_WAVE64_DAG, VICTORY_MESH_INDIRECT, VICTORY_SNAPSHOT_POOL_MIB=128), plus VICTORY_TEXTURE_MIP_DROP=2. Win11 didn't need the Agility opt-in. The D3D12 debug layer and DRED both work on this PC, so here is what they named.

1. The 2560x1440 BGRA render target is refused (E_INVALIDARG, format 86, flags 5). It's the same case as #904. With 85 | 86 | 115 => 28 and 67 => 10 in pc_format, it's created.

2. alias_copy overruns its buffer when the two formats have different texel sizes. The debug layer stops at CopyTextureRegion: the placed footprint needs 8192 bytes (R16G16B16A16_FLOAT, 32x32, RowPitch 256), but the buffer has 8064. The pair is R32 (a=42) aliased to RGBA16F (b=10). Both have RowPitch 256 and 32 rows, so the take_while check passes. The row sizes differ, though (128 vs 256 bytes), and the buffer is sized from a's total. The device was removed ("a host command list did not close", then 0x887A0001). The fix compares the row sizes from GetCopyableFootprints as well, and sizes the buffer to the larger total:

-            host.device
-                .GetCopyableFootprints(d, 0, n, 0, Some(f.as_mut_ptr()), Some(rows.as_mut_ptr()), None, Some(&mut total));
+            host.device.GetCopyableFootprints(d, 0, n, 0, Some(f.as_mut_ptr()), Some(rows.as_mut_ptr()), Some(row_bytes.as_mut_ptr()), Some(&mut total));
...
-    let (fa, ra, total) = footprints(&da, count(&da));
-    let (fb, rb, _) = footprints(&db, count(&db));
+    let (fa, ra, sa, total_a) = footprints(&da, count(&da));
+    let (fb, rb, sb, total_b) = footprints(&db, count(&db));
+    let total = total_a.max(total_b);
...
-            ... && ra[i] == rb[i] && x.Footprint.Depth == y.Footprint.Depth
+            ... && ra[i] == rb[i] && sa[i] == sb[i] && x.Footprint.Depth == y.Footprint.Depth

This code is upstream (texture.rs), not from this PR. #1 just made the mismatch reachable, because 9E5 (4 bytes) became RGBA16F (8 bytes).

3. The world hangs the GPU in the BVH and ray-traced passes. With 1 and 2, the run reaches the world and then gets DEVICE_HUNG after about 30 s, with frames taking 16 s on the GPU. This branch translates all five XboxBvhBuilder programs, including 28918b71 and caa78b8c, the two that moe-miau found hanging on #189. With those two skipped, DRED stops in the ray-traced pass:

a list stopped at command 52 of 74 (op 5): indirect kind 2 max 1 [compute f607780aa8e502d0]

That is presumably walking a BVH that was never built. With VICTORY_SKIP_PIPELINES=28918b7150a7aad5,caa78b8ca62bc3d6,f607780aa8e502d0, there is no device removal.

Result with 1, 2 and the three skips: 22+ minutes in the world, then I closed it.

before (my old local stack on ffe310e) this PR + fixes + skips
time in world 2:29-3:11, then VRAM exhaustion 22+ min, no removal
peak dedicated VRAM 7.85 GB, pinned 7.4-7.6 GB, stable
title copies per world frame 0.8-1.5 GB about 0.2 GB
draws/frame up to about 1,650 up to 2,265 (2,529 indexing the heap)
ms/frame 1,300-6,500 1,300-20,000
out-of-memory failures hundreds 0

The intro credits render (the pink text over black), and audio plays. The world itself stays black. Process RAM is about 20-21 GB.

Other debug layer messages, which didn't remove the device:

  • ExecuteIndirect and DrawInstanced: a resource in NON_PIXEL_SHADER_RESOURCE|PIXEL_SHADER_RESOURCE is "invalid for use as a depth-read" (expected DEPTH_READ). This came up 30 times.
  • DrawIndexedInstanced: a vertex buffer is still in UNORDERED_ACCESS. This came up once.
  • At submission, a barrier's before state is UNORDERED_ACCESS, but the layer assumed VERTEX_AND_CONSTANT_BUFFER at first use.
  • About 160 CreateComputeShader "wants wave lane count of 64" refusals. That's expected without Shaders: emulate Wave64 compute shaders on Wave32 and narrower hosts #189.

One run per configuration, loaded from an HDD. Counts, hashes and times only; no game data attached. The two fixes are local commits on top of e35c044. I can push them to a branch if that's easier.

This comment and the investigation were done with AI assistance (Claude Code), on my own machine.

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.

4 participants