Skip to content

Runtime: M1.5 — the first draw whose VS and PS are translator output, PSO found by hash (D3D-53, Depends on #291) - #907

Closed
AlxcBTW wants to merge 19 commits into
ItsNotRexed:mainfrom
AlxcBTW:m15-translated-draw-v2
Closed

AlxcBTW wants to merge 19 commits into
ItsNotRexed:mainfrom
AlxcBTW:m15-translated-draw-v2

Conversation

@AlxcBTW

@AlxcBTW AlxcBTW commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Replaces draft #699. #291 has landed in main, so this branch is rebuilt on main and carries only the M1.5 changes (translated draw test, build.py FSSM output, test-device shaderDrawParameters).

AlxcBTW and others added 6 commits November 22, 2026 05:24
…ameters

Every translated shader declares Int64 (64-bit addresses) and lists shaderInt64 in
its index metadata, but neither the standalone device nor the test device enabled
it: vkCreateShaderModule was a validation error and the first translated draw
lost the queue. The test device also enables shaderDrawParameters, which the
translator's zero-based VS ids (PR 436) will need. Two names in the test device
no longer shadow each other after the merge with main. The standalone-device
change is PR 291's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vs_m15.asm and ps_m15.asm are hand-written RDNA2 (gfx1013), built by
test/shaders/build.py through llvm-mc and tools/rdna2spirv.py. build.py now also
writes the synthetic FSSM program a shader's header asks for (fssm-at, fssm-data)
to fssm/, so the translator records its fssm_sha256 in index.json.
d3d12_translated_draw_test creates a graphics PSO from containers carrying those
programs; the layer finds both stages by hash in the translator's own index. It
covers a descriptor-table root argument and root constants (s0..s5), vertex fetch
through a V# the application wrote into a descriptor slot (s_load, then
buffer_load_dwordx4 idxen), the PS reading constants through the code base
(s_getpc_b64), and compares a float render target bit for bit. All draws use
StartVertexLocation 0, so the result is the same with and without PR 436's
zero-based ids; verified both ways. docs/d3d12_vulkan.md records the milestone and
the measurement that a V# cannot point at an upload buffer (48-bit base, negative
console VA).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… log a missing shaderInt64

PR 436's translated vertex shaders read BaseVertex/BaseInstance, so the production device
must enable shaderDrawParameters before 436 lands (same lines as 436, so they merge). A GPU
without shaderInt64 cannot load any translated shader (all declare Int64): say so once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ter edge assert, softer 436 and V# docs

make_vsharp used OOB_SELECT raw with stride 32, which on hardware checks the byte offset
against num_records; the test only passed because the translator ignores OOB_SELECT. It now
encodes a gfx10::Buffer with OobSelect::structured. The 32 diagonal pixels must be the clear
colour (a right edge under the top-left rule). Docs: 436 is not in the tree (identical result
with its translator change applied); the V# failure follows from the upload buffer lying below
the arena, which is allocation order, so the rule stays: anything behind a V# is an arena range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/shims/d3d12_com.h
#	runtime/shims/d3d12_vulkan_device.cpp
…s in vulkan_replay.h, C4459)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kapitche

Copy link
Copy Markdown
Contributor

Tested 69b1d11 on Windows 11 with two GPUs on one machine (MSVC 14.51, llvm-mc 23.1.6 with AMDGPU, spirv-tools from conda-forge): M1.5 draws correctly on both

NVIDIA GeForce RTX 4080 SUPER (32.0.16.1714) Intel UHD Graphics 770 (32.0.101.6129)
d3d12_translated_draw_test exit 0 exit 0
result 3 draws, 4064/4096 pixels exact, 32 edge pixels on the diagonal (all clear colour) identical
  • ctest: 33/33. The Intel run uses VK_LOADER_DRIVERS_DISABLE=*nv*.
  • So the translator ↔ layer contract worked end to end on both vendors: user SGPRs from the descriptor table and root constants, V# vertex fetch, the code base read, and PS exports.

Two notes:

  1. My first build had no LLVM_MC and no SDK spirv-as/spirv-val, so d3d12_translated_draw_test simply wasn't built and ctest still said 33/33. The message(STATUS ...) explains why, but it's easy to miss. Anyone posting a "tested" result here should check that the test actually ran.
  2. Both runs log [rt] d3d12: no translated vs for FSSM sha256 7ab17a57… once before the draws. Is that a deliberate negative lookup, a PSO whose shader isn't in the index on purpose? If so, a word in the test output would stop it looking like a failure.

@DiazE117

Copy link
Copy Markdown
Contributor

Windows + RTX 4070 SUPER (Ada) test of 69b1d11: M1.5 draws correctly

Windows 11 Pro, NVIDIA GeForce RTX 4070 SUPER, driver 610.88, Vulkan SDK 1.4.363.0, MSVC 19.44, Ninja, LLVM_MC = llvm-mc 21.1.8 (Ubuntu in WSL). The build log shows Translating vs_m15 and ps_m15 and 2 shaders: 2 translated, 2 pass spirv-val, so d3d12_translated_draw_test was built and ran. That is the check @kapitche warned about.

  • ctest with LEONIDA_VK_VALIDATION=1: 33/33 pass.
  • d3d12_translated_draw_test: exit 0 with and without validation, 0 validation messages. M1.5: translated VS+PS found by FSSM hash drew three draws; 4064 of 4096 pixels exact, 32 edge pixels on the triangle's diagonal (0 its colour, 32 the clear colour). This is identical to the RTX 4080 SUPER and UHD 770 runs. The no translated vs for FSSM sha256 7ab17a57… line appears once here too.

One leftover warning from the C4459 fix in 69b1d11:

runtime/src/vulkan_replay.h(1507): warning C4459: declaration of 'extent' hides global declaration
runtime/test/d3d12_translated_draw_test.cpp(66): note: see declaration of '`anonymous-namespace'::extent'

The commit renamed size, but the test's constexpr UINT extent = 64; (line 66) still shadows the local extent in vulkan_replay.h:1507 (the color-clear path in prepare<>), which is instantiated in this translation unit. Renaming it (for example to target_extent) should clear the last C4459. It's harmless at runtime.

AI-assisted (Claude Code): it built the PR head, ran the tests on my GPU and wrote this report.

@Thatters

Copy link
Copy Markdown
Contributor

Tested 69b1d11 on a desktop RTX 5070 Ti (Blackwell): M1.5 draws correctly, with 0 validation messages.

  • GPU: NVIDIA GeForce RTX 5070 Ti (desktop), driver 621.24, Vulkan SDK 1.4.363.0
  • OS: Windows 11 Pro 25H2 (26200.9974)
  • Toolchain: MSVC 14.51.36231 (VS 18 Build Tools), Ninja, RelWithDebInfo (scripts/build_runtime.ps1)
  • Shader tools: LLVM_MC = Ubuntu LLVM 21.1.8 through WSL; SPIRV-Tools v2026.4
  • Shaders: CMake translated vs_m15/ps_m15 itself (generated/m15_shaders: both .fssm, index.json, both .spv).
Test LEONIDA_D3D12=vulkan + LEONIDA_VK_VALIDATION=1
d3d12_translated_draw_test pass pass, 0 VUIDs: three draws, 4064/4096 pixels exact, 32 diagonal edge pixels = clear colour (0 with the triangle's colour)
d3d12_draw_test, d3d12_compute_test, d3d12_descriptor_test, d3d12_present_test, d3d12_method_variants_test pass, 0 VUIDs
ctest 33/33 (gameinput disabled, no SDL3), 0 VUIDs

One small build note: 69b1d11 renames the global size, but extent at d3d12_translated_draw_test.cpp:66 still triggers C4459 here. It is shadowed by a local at runtime/src/vulkan_replay.h:1507 (declaration of 'extent' hides global declaration). That's 1× C4459, beside the 21× C4456 that vulkan_replay.h already has on main. A warning only; it doesn't affect the result.

No game files used. AI-assisted.

@poke900310-lgtm

Copy link
Copy Markdown

Two small things I hit testing #699's head (b6dfa23) that look like they're still in this PR at 69b1d11. I've only re-checked the code here, not re-run it.

  • With the Visual Studio generator (-G "Visual Studio 17 2022"), the build stops with MSB8066 on d3d12_translated_draw_test's custom command. In runtime/CMakeLists.txt:742, "PATH=${LEONIDA_SPIRV_TOOLS_NATIVE};$ENV{PATH}" is split at the semicolon into separate arguments, and you can see that in the generated vcxproj. Ninja builds it fine, which is probably why every run in this thread is green. Escaping the semicolon (or passing PATH through a small wrapper) should fix it.
  • scripts/run_gpu_tests.py collects every runtime/test/shaders/*.asm, so the new ps_m15.asm shows up as "FAIL ps_m15 no checker defined" (85/86 on my run). A checker, or a skip entry for the m15 pair, would clear it on every GPU.

Otherwise the draw itself matched the other runs on RDNA4: RX 9070 XT, driver 32.0.32015.16001, Ninja build, validation on. That gave 4064/4096 exact, the 32 edge pixels at clear colour, 0 validation errors, and ctest 28/28.

(AI-assisted run on this machine.)

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Verified PS selection between two valid hashes in the same library on 69b1d114cc98c41365372505972c6bbbaa406a72. I held the translated VS, geometry and PS scale table fixed. Both synthetic PS programs were 272 bytes. One unused tag byte at FSSM offset 0xfc distinguished keys A and B. B's translated shader exchanged red and green at export; both read identical constants at 0x100.

  • Creating two PSOs and binding A → B → A across the three draws produced exactly the predicted RGBA32F values in all 4,096 pixels on RTX 5080 and Radeon Graphics, with Vulkan validation enabled. The second quad read (1.125, 0.25, 0.875, 1); the final triangle switched back to A and read (0.75, 0.25, 0.75, 1).
  • For the negative control I swapped only the two PS SHA-256 values in the index and launched the same executable again. Exactly 2,544 covered pixels changed on each GPU (1,024 + 1,024 + 496); the remaining 1,552 stayed clear. Every changed pixel had just red and green exchanged. The original oracle failed as expected.
  • With the valid VS still bound, both an unindexed PS tag value and the valid VS container supplied in the PS slot returned E_INVALIDARG and a null PSO.

This extends the existing unknown-VS test through actual stage-specific PS selection and repeated binds. All inputs were source-built; no production files changed. AI-assisted.

AlxcBTW and others added 3 commits November 22, 2026 11:08
Conflicts (both sides kept): runtime/CMakeLists.txt (stub list), d3d12_com.h, d3d12_vulkan_device.cpp (arena buffers
with main's ray-tracing buffers and deferred destruction, calibrated timestamps, instance extensions, sampler
registration next to the window presenter), command_list.h, vulkan_backend.h, vulkan_replay.h, vk_test_device.h,
d3d12_state_map_test.cpp, docs and README. vulkan_present.h takes main's resource and tracker locks.

CI (linux-gpu-tests): ps_m15 and vs_m15 belong to d3d12_translated_draw_test. run_gpu_tests.py still assembles and
translates them but reports them as skipped (OTHER_HARNESS) instead of "no checker defined".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main moved (c0ac5fd): vulkan_replay.h takes main's checked buffer copies (predicated copies, overlap and overflow
refusals). README's Xbox row is rebuilt from both sides (the previous merge commit had committed a zero-filled
README.md; this restores it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlxcBTW
AlxcBTW marked this pull request as ready for review November 22, 2026 10:50
ItsNotRexed#119 is in main now, so the presenter files come from main (vulkan_present.h, the present tests and their ctest
registration). Conflicts (both sides kept): runtime/CMakeLists.txt, d3d12_com.h, d3d12_vulkan_device.cpp (rgb96_
next to the PR's graphics code), docs and README.

This PR's tests d3d12_compute_test, d3d12_draw_test and d3d12_translated_draw_test were built but never run by ctest
(tests/test_ctest_registration.py). They are registered now, and exit 77 (skipped) when there is no Vulkan 1.3
device, like d3d12_present_test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlxcBTW and others added 4 commits November 22, 2026 13:03
…ameters

Every translated shader declares Int64 (64-bit addresses) and lists shaderInt64 in
its index metadata, but neither the standalone device nor the test device enabled
it: vkCreateShaderModule was a validation error and the first translated draw
lost the queue. The test device also enables shaderDrawParameters, which the
translator's zero-based VS ids (PR 436) will need. Two names in the test device
no longer shadow each other after the merge with main. The standalone-device
change is PR 291's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vs_m15.asm and ps_m15.asm are hand-written RDNA2 (gfx1013), built by
test/shaders/build.py through llvm-mc and tools/rdna2spirv.py. build.py now also
writes the synthetic FSSM program a shader's header asks for (fssm-at, fssm-data)
to fssm/, so the translator records its fssm_sha256 in index.json.
d3d12_translated_draw_test creates a graphics PSO from containers carrying those
programs; the layer finds both stages by hash in the translator's own index. It
covers a descriptor-table root argument and root constants (s0..s5), vertex fetch
through a V# the application wrote into a descriptor slot (s_load, then
buffer_load_dwordx4 idxen), the PS reading constants through the code base
(s_getpc_b64), and compares a float render target bit for bit. All draws use
StartVertexLocation 0, so the result is the same with and without PR 436's
zero-based ids; verified both ways. docs/d3d12_vulkan.md records the milestone and
the measurement that a V# cannot point at an upload buffer (48-bit base, negative
console VA).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… log a missing shaderInt64

PR 436's translated vertex shaders read BaseVertex/BaseInstance, so the production device
must enable shaderDrawParameters before 436 lands (same lines as 436, so they merge). A GPU
without shaderInt64 cannot load any translated shader (all declare Int64): say so once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ter edge assert, softer 436 and V# docs

make_vsharp used OOB_SELECT raw with stride 32, which on hardware checks the byte offset
against num_records; the test only passed because the translator ignores OOB_SELECT. It now
encodes a gfx10::Buffer with OobSelect::structured. The 32 diagonal pixels must be the clear
colour (a right edge under the top-left rule). Docs: 436 is not in the tree (identical result
with its translator change applied); the V# failure follows from the upload buffer lying below
the arena, which is allocation order, so the rule stays: anything behind a V# is an arena range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlxcBTW and others added 2 commits November 22, 2026 13:03
…s in vulkan_replay.h, C4459)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… d3d12_translated_draw with ctest

ps_m15 and vs_m15 are still assembled and translated by run_gpu_tests.py but reported as skipped (OTHER_HARNESS) instead of 'no checker defined'. d3d12_translated_draw_test is registered with ctest.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
AlxcBTW and others added 2 commits November 22, 2026 13:31
ItsNotRexed#291 landed in main, so this branch is rebuilt on main with only the M1.5 changes; this commit keeps the push a fast-forward.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Thatters

Copy link
Copy Markdown
Contributor

Retested at the new head c2d294b on the same RTX 5070 Ti / 621.24 / Windows 11 / MSVC 14.51 + Ninja setup:
M1.5 still draws correctly, and both of @poke900310-lgtm's points behave as below.

Check Result
d3d12_translated_draw_test, LEONIDA_D3D12=vulkan, validation off / on pass / pass, 0 VUIDs: three draws, 4064/4096 exact, 32 diagonal edge pixels = clear colour
ctest (validation on) 90/90 passed, 0 VUIDs, now including d3d12_translated_draw; d3d12_rgb9e5_rtv skips (no RGB9E5 RTVs on this adapter), gameinput disabled
scripts/run_gpu_tests.py 115/147 passed, 0 failed, 32 skipped: 30 wave64-only (no 64-wide subgroup) and ps_m15/vs_m15 as "run by d3d12_translated_draw_test" (the "no checker defined" FAIL is gone)

Still open:

  • C4459 on extent: the global constexpr UINT extent at runtime/test/d3d12_translated_draw_test.cpp:66 still triggers 1×
    runtime\src\vulkan_replay.h(1908): warning C4459: declaration of 'extent' hides global declaration. fabf4e5 renames
    size, but extent is the one still shadowed. It's the only warning in the build now (main's C4456s are gone).
  • MSB8066 with the VS generator (from @poke900310-lgtm): I only build with Ninja, so I can't confirm it, but
    runtime/CMakeLists.txt:1136 still passes "PATH=${LEONIDA_SPIRV_TOOLS_NATIVE};$ENV{PATH}" unescaped.

No game files used. AI-assisted.

@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted Windows x64 retest of c2d294b8092bf4f0aa843f41292764c28c9287d1 against main at 41f448261e1de8a410b4d760e69a7e5656cef858. This follows the earlier generator report, whose Visual Studio run was on #699 at b6dfa23, with a source check of #907 at 69b1d11. There is also a separate GPU run on 69b1d11.

  • Visual Studio 17 2022 still fails on this head. A fresh x64 RelWithDebInfo build of d3d12_translated_draw_test exits 1. The shader custom step prints no such file or directory, followed by Microsoft.CppCommon.targets(254,5): error MSB8066 for index.json.rule (custom build exited with code 1). The generated .vcxproj splits PATH at the semicolon, emitting ...\Bin";"C:\... as separate arguments to cmake -E env. In a disposable copy I changed only the CMake wrapper to cmake -E env --modify "PATH=path_list_prepend:${LEONIDA_SPIRV_TOOLS_NATIVE}" "LLVM_MC=${LEONIDA_LLVM_MC}" .... A fresh Visual Studio generation then built the target with 2/2 shaders translated and validated. Its index, both FSSM files, and both SPIR-V modules matched Ninja byte for byte.
  • Ninja passes on the unmodified head. Both vs_m15 and ps_m15 translated and passed a separate spirv-val --target-env vulkan1.2 check. I verified both src_sha256 and fssm_sha256 fields against regenerated assembler output and the synthetic FSSM files. CTest registers d3d12_translated_draw with skip code 77. The runner source sends both _m15 fixtures through OTHER_HARNESS to d3d12_translated_draw_test, consistent with Thatters' runtime skip result on this head.
  • Valid-only offscreen draws pass on both adapters. The RTX 3080 (616.64 / 32.0.16.1664) and AMD Radeon(TM) Graphics iGPU (32.0.21030.2001) each exited 0 after the PSO resolved the valid VS and PS by their indexed FSSM hashes. On each GPU, three draws gave 4,064/4,096 bit-exact pixels plus all 32 diagonal edge pixels at the clear colour, with zero validation messages. Each process used one ICD, an empty implicit layer path, and Khronos synchronization validation. The scratch test omitted the deliberate unindexed-VS case and reused the exact-head runtime objects and generated shaders.

Windows 11 25H2, MSVC 19.38.33145 x64, uv Python 3.12.13, Vulkan SDK 1.4.363.0 (SPIRV-Tools 2026.4), and WSL LLVM 21.1.8 for AMDGPU assembly. Only the M1.5 target and its dependencies were built. The tracked worktree is clean.

"PATH=<spirv-tools>;$ENV{PATH}" was split at its semicolons into separate cmake -E env
arguments in the generated .vcxproj, so the custom build stopped with MSB8066; Ninja kept it
whole. The separators are escaped with $<SEMICOLON> on Windows (':' elsewhere). Built
d3d12_translated_draw_test with -G "Visual Studio 17 2022" and with Ninja; both pass on a
Radeon 880M and an RTX 5070. Reported by @whattheflop in ItsNotRexed#907.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
…io generator

The M1.5/M2/M3 custom commands passed "PATH=<spirv-tools>;$ENV{PATH}" through cmake -E env.
The Visual Studio generator splits it at the semicolons, and a PATH entry ending in a
backslash escapes the next quote on the generated command line, so the step stops with
"no such file or directory" and MSB8066; Ninja happened to keep it whole. The commands now
set only LEONIDA_SPIRV_TOOLS, and runtime/test/shaders/build.py puts that folder in front of
PATH itself. Reported by @whattheflop in #907.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
…ulkan_replay.h)

The test's global `constexpr UINT extent = 64` is hidden by a local `extent` in runtime/src/vulkan_replay.h,
so every MSVC build of the runtime prints `warning C4459: declaration of 'extent' hides global declaration`.
It came in with #907, whose earlier fix renamed the global `size` to `extent` for the same reason. The
global is now `target_extent`, a name nothing under runtime/ uses; the test is otherwise unchanged.

Tested on Windows 11 Pro 25H2, MSVC 14.51 + Ninja (scripts/build_runtime.ps1), RTX 5070 Ti / 621.24: the
build has no C4459 (main's 49x C4456 in vulkan_replay.h remain; #1743 handles them). d3d12_translated_draw_test
passes with validation off and on: three draws, 4064/4096 exact, 32 edge pixels, 0 VUIDs. Full ctest with
validation: 106/107; the one failure is d3d12_draw's bundle-blend check, which fails on main too (#1793).
No game files. AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

7 participants