#1584

Runtime: milestone M3 synthetic gate — depth/stencil, MRT, barriers, occlusion query, 3 frames in flight, all pixels exact

DraftAlxcBTWwants to merge intofrom

What and why

This is the synthetic part of milestone M3 in docs/d3d12_vulkan.md §6, claimed in #1380. M3 is the last gate before the game's own first frames. The new d3d12_m3_frame_test uses only the D3D12 API on the proxy and translator-output shaders (vs_m3.asm, ps_m3.asm, ps_m3_post.asm, hand-written RDNA2):

  • Pass 1: draws three rectangles with OMSetRenderTargets into two render targets (R8G8B8A8_UNORM and R32_FLOAT) and a D24_UNORM_S8_UINT depth/stencil buffer.
    • Depth test LESS with write; stencil REPLACE (refs 1, 2) and EQUAL.
    • The far rectangle is drawn inside an OCCLUSION query, resolved with ResolveQueryData into a readback buffer.
  • Resource barriers: RT → PIXEL_SHADER_RESOURCE|COPY_SOURCE, and RT → COPY_SOURCE.
  • Pass 2: the first target is sampled through an SRV in a descriptor table (the M2 path) by a translated PS into a third target.
  • Frames: six frames in a ring of three slots, so three frames in flight. Each slot has its own fence (Signal, SetEventOnCompletion with an event, Wait), and root constants change every frame.
  • Check: every pixel of all three targets, with the float target bit-exact, plus the occlusion sample count, compared against a CPU reference: error 0, exact count.

No layer change was needed: everything M3 asks for, apart from render passes, already works.

Not covered:

  • render passes (BeginRenderPass, D3D-27, @Ryx69) and occlusion during pipeline statistics (D3D-162);
  • BINARY_OCCLUSION, MSAA, depth/stencil copies and read-only DSVs;
  • the game's own first frames, which need the executable.

The generic shader harness skips the fixtures (OTHER_HARNESS). The §6 M3 row now says "Synthetic part met".

Depends on: #1489 (M2, which contains #907). Until #1489 lands, this diff shows M1.5 + M2 + M3.

Tested

  • AMD Radeon 880M (26.11.2) and NVIDIA RTX 5070 Laptop (617.42), Windows 11, MSVC 19.44, LEONIDA_VK_VALIDATION=1 (synchronization validation included), head 1a156425:
    • d3d12_m3_frame: 6 frames × 3 targets × 4096 pixels, error 0; 3555 occlusion samples in total, exact on both GPUs.
    • d3d12_m2_textured: passes on both.
    • 0 validation errors.
  • Full ctest:
    • AMD: 90/90.
    • NVIDIA: all pass except d3d12_vulkan_device, which fails on main too (placed UNORM clear rounding, being fixed separately, see #1380).
  • Mutation check: with the depth test removed from the CPU reference, the test fails as it should.
  • run_gpu_tests.py --filter _m3: 3/3 translated, spirv-val clean, skipped as run by d3d12_m3_frame_test.
  • tests/test_ctest_registration.py and tests/test_shader_checks.py: 45 passed.

Checklist

  • No game data, keys or online access
  • Tested on two GPUs
  • Docs updated (docs/d3d12_vulkan.md §6, M3 row)

AI-assisted (Claude Code).

🤖 Generated with Claude Code

Activity

28
whattheflop1h ago

Independent AI-assisted Windows GPU verification of the published draft head 1a156425c7e887300f867b07e81c6819a54bddd2. GitHub recorded base 99f99890c5ebe186ef2f9fe8ff6d675745d9e621, which was also the merge base. Upstream main was 41f448261e1de8a410b4d760e69a7e5656cef858. This run used the published head as-is. M3 is @AlxcBTW's claim from #1380 (claim).

Stock offscreen d3d12_m3_frame_test exited 0 on the GeForce RTX 3080 (616.64) and the Ryzen 7 9800X3D Radeon iGPU (Windows driver 32.0.21030.2001). The Vulkan loader showed one vendor ICD per process, the empty implicit-layer search path, and VK_LAYER_KHRONOS_validation 1.4.363.0 in both the instance and device dispatch chains. The layer's startup report listed Synchronization on both GPUs. There were zero validation errors, warnings, or reported sync hazards in both completed stock runs.

  • Shaders: 3/3 new M3 fixtures translated and passed spirv-val. Including the reused vs_m2, 4/4 shaders used by M3 translated and passed, with all four independently rechecked using spirv-val --target-env vulkan1.3.
  • Readbacks: Each GPU matched the CPU reference for 6 frames × 3 targets × 4,096 pixels = 73,728 pixel comparisons, with zero mismatches on every target in every frame. The R32_FLOAT target matched bit for bit.
  • Precise occlusion: For frames 0–5, actual and expected counts matched on both GPUs at 800, 709, 624, 545, 472, 405, totaling 3,555.
  • Queue: The test rotates three independent slots on one queue, signals each slot's fence after submission, and waits before reusing the slot. A scratch build that only added logging and nonblocking fence reads sampled 1, 2, 3, 1, 2, 3 incomplete slot fences after submits on NVIDIA and 1, 1, 1, 1, 1, 1 on AMD. This measures sampled fence completion. GPU execution overlap was unmeasured. An initial NVIDIA diagnostic launch hit its 45-second timeout, with its last log at Vulkan device setup. The retry under the stock executable name completed with the same pixel and occlusion results and zero validation errors or warnings.

Windows 11 25H2 (26200.9974), MSVC 19.38.33145, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0, uv-managed Python 3.12.13, and WSL LLVM 21.1.8 llvm-mc with AMDGPU.

Scope was synthetic indexed offscreen draws through the D3D12-to-Vulkan proxy: MRT, D24S8 depth and stencil via OMSetRenderTargets, transitions, precise occlusion resolve, descriptor-table SRV sampling in pass two, and same-queue fence reuse. Coverage excludes BeginRenderPass, occlusion during pipeline statistics, binary occlusion, MSAA, depth/stencil copies, read-only DSVs, cross-queue dependencies, presentation, and retail game frames. The standalone M2 test and broader suite were outside this run.

AlxcBTW1h ago

Thanks @whattheflop, that's a careful run. 73,728 pixel comparisons and the per-frame occlusion counts (800 … 405, 3,555 in total) match on an RTX 3080 and the 9800X3D's Radeon iGPU, with sync validation on.

Your fence sampling (1,2,3,1,2,3 on NVIDIA and 1,1,1,… on AMD) is also useful. It shows that NVIDIA really has up to three slots in flight, so the reuse wait is exercised there. On AMD the GPU drains each frame before the next sample, so the ring is mostly exercised for correctness, not overlap. I'll put that in the docs row.

AI-assisted (Claude Code).

This pull request is a draft

Merging is unavailable until it is marked ready for review.