Repository navigation
d3d12: a pipeline registers its shaders' literal S#s (they sampled through the fallback) - #2887
Conversation
|
Code read of AI-assisted review (Claude Code). |
|
AI-assisted independent review of
|
|
Thanks @whattheflop for the careful two-revision review. On the two open points:
|
|
Tested e77a4f8 (merged onto main 77444fa) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: partial pass. The build and regressions are checked, but not the new test.
AI-assisted (Claude). |
|
Thanks @FaKL-Code. That covers the regressions on a second NVIDIA card: 120/120, and 48 tests clean under validation. The gap you name is covered here, with
The pixel-level check of the same path is #2906, which draws through a game PS whose S# is a literal. |
|
Tested e77a4f8 merged onto main 1628210 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
e77a4f8 to
7be6847
Compare
…ples a T# (TEST-524) d3d12_first_light_textured_test draws the first-light mesh through the D3D12 layer with the game's VS and $PS_PassthroughCopy, picked by census (780 of 12,101 PS do one image_sample and nothing else; 148 of those link with the VS). The PS loads its T# through the table pointer in s8 and samples with a literal S#; the root signature puts a one-SRV table at s8:s9 behind eight padding constants. first_light.py --texture ramp writes texture.bin, a 64x64 coordinate ramp (texel (x, y) holds its own centre, so bilinear sampling gives back the UV), and expected.raw, the CPU reference at every covered pixel's UV. RTX 3060: 12,804 pixels, the same coverage as d3d12_first_light, worst channel error 0.00028 against a 0.002 tolerance; point sampling is off by up to 1/128, which is what this draw gave before ProjectLeonida#2887. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7be6847 to
41a6489
Compare
…ples a T# (TEST-524) d3d12_first_light_textured_test draws the first-light mesh through the D3D12 layer with the game's VS and $PS_PassthroughCopy, picked by census (780 of 12,101 PS do one image_sample and nothing else; 148 of those link with the VS). The PS loads its T# through the table pointer in s8 and samples with a literal S#; the root signature puts a one-SRV table at s8:s9 behind eight padding constants. first_light.py --texture ramp writes texture.bin, a 64x64 coordinate ramp (texel (x, y) holds its own centre, so bilinear sampling gives back the UV), and expected.raw, the CPU reference at every covered pixel's UV. RTX 3060: 12,804 pixels, the same coverage as d3d12_first_light, worst channel error 0.00028 against a 0.002 tolerance; point sampling is off by up to 1/128, which is what this draw gave before ProjectLeonida#2887. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s harness path Since the rebase onto 7e1aecf, --texture ramp exited with a TypeError: write_textured_inputs stored "texture": "ramp" and files["texture"], which harness_env reads as the --dds dict. The ramp's keys are now layer_texture*; a unit test feeds harness_env a ramp manifest (fails on the old keys). The vk_harness tests skip a ramp folder, which only the D3D12-layer test can draw. docs/first_light.md §7: the command names its --out, and the count without ProjectLeonida#2887 is 19,041 channels (measured here and on three other GPUs). Found by @zzEmmazz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Two cleanups reported by @zzEmmazz on #2906, now in this PR:
|
…ples a T# (TEST-524) d3d12_first_light_textured_test draws the first-light mesh through the D3D12 layer with the game's VS and $PS_PassthroughCopy, picked by census (780 of 12,101 PS do one image_sample and nothing else; 148 of those link with the VS). The PS loads its T# through the table pointer in s8 and samples with a literal S#; the root signature puts a one-SRV table at s8:s9 behind eight padding constants. first_light.py --texture ramp writes texture.bin, a 64x64 coordinate ramp (texel (x, y) holds its own centre, so bilinear sampling gives back the UV), and expected.raw, the CPU reference at every covered pixel's UV. RTX 3060: 12,804 pixels, the same coverage as d3d12_first_light, worst channel error 0.00028 against a 0.002 tolerance; point sampling is off by up to 1/128, which is what this draw gave before ProjectLeonida#2887. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s harness path Since the rebase onto 7e1aecf, --texture ramp exited with a TypeError: write_textured_inputs stored "texture": "ramp" and files["texture"], which harness_env reads as the --dds dict. The ramp's keys are now layer_texture*; a unit test feeds harness_env a ramp manifest (fails on the old keys). The vk_harness tests skip a ramp folder, which only the D3D12-layer test can draw. docs/first_light.md §7: the command names its --out, and the count without ProjectLeonida#2887 is 19,041 channels (measured here and on three other GPUs). Found by @zzEmmazz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
How much of the game this affects. This is a census of the full translated corpus on my 1.0.2.1 copy (
So on |
#2887 added the fixture to the M2 build; with no entry in OTHER_HARNESS the GPU suite reported it as "no checker defined". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5cd7fe7 to
7e9c460
Compare
…ples a T# (TEST-524) d3d12_first_light_textured_test draws the first-light mesh through the D3D12 layer with the game's VS and $PS_PassthroughCopy, picked by census (780 of 12,101 PS do one image_sample and nothing else; 148 of those link with the VS). The PS loads its T# through the table pointer in s8 and samples with a literal S#; the root signature puts a one-SRV table at s8:s9 behind eight padding constants. first_light.py --texture ramp writes texture.bin, a 64x64 coordinate ramp (texel (x, y) holds its own centre, so bilinear sampling gives back the UV), and expected.raw, the CPU reference at every covered pixel's UV. RTX 3060: 12,804 pixels, the same coverage as d3d12_first_light, worst channel error 0.00028 against a 0.002 tolerance; point sampling is off by up to 1/128, which is what this draw gave before ProjectLeonida#2887. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s harness path Since the rebase onto 7e1aecf, --texture ramp exited with a TypeError: write_textured_inputs stored "texture": "ramp" and files["texture"], which harness_env reads as the --dds dict. The ramp's keys are now layer_texture*; a unit test feeds harness_env a ramp manifest (fails on the old keys). The vk_harness tests skip a ramp folder, which only the D3D12-layer test can draw. docs/first_light.md §7: the command names its --out, and the count without ProjectLeonida#2887 is 19,041 channels (measured here and on three other GPUs). Found by @zzEmmazz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…names what it counts pick_entry's comment had ended up above the new helper, and the log line ended in "words" while printing the number of literal S#s. Reported by @zzEmmazz on ProjectLeonida#2906. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7e9c460 to
6a726e7
Compare
…ples a T# (TEST-524) d3d12_first_light_textured_test draws the first-light mesh through the D3D12 layer with the game's VS and $PS_PassthroughCopy, picked by census (780 of 12,101 PS do one image_sample and nothing else; 148 of those link with the VS). The PS loads its T# through the table pointer in s8 and samples with a literal S#; the root signature puts a one-SRV table at s8:s9 behind eight padding constants. first_light.py --texture ramp writes texture.bin, a 64x64 coordinate ramp (texel (x, y) holds its own centre, so bilinear sampling gives back the UV), and expected.raw, the CPU reference at every covered pixel's UV. RTX 3060: 12,804 pixels, the same coverage as d3d12_first_light, worst channel error 0.00028 against a 0.002 tolerance; point sampling is off by up to 1/128, which is what this draw gave before ProjectLeonida#2887. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s harness path Since the rebase onto 7e1aecf, --texture ramp exited with a TypeError: write_textured_inputs stored "texture": "ramp" and files["texture"], which harness_env reads as the --dds dict. The ramp's keys are now layer_texture*; a unit test feeds harness_env a ramp manifest (fails on the old keys). The vk_harness tests skip a ramp folder, which only the D3D12-layer test can draw. docs/first_light.md §7: the command names its --out, and the count without ProjectLeonida#2887 is 19,041 channels (measured here and on three other GPUs). Found by @zzEmmazz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased the stack on
On an RTX 3060: |
|
Tested 6a726e7 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran AI-assisted. |
|
Tested
|
|
Tested 6a726e7 (merged onto main 98fa503) on RTX 3060, driver 617.14, Windows 11: pass Ran: ctest, ctest with LEONIDA_VK_VALIDATION=1, the unregistered *_test.exe, and run_gpu_tests.py native and with LEONIDA_W64_EMULATE=1. Failures that also happen on main 98fa503 are excluded: d3d12_clear (format mismatch vs WARP, see #521). AI-assisted: the build and test run were done with Claude Code on my machine; the numbers above are its unedited output. |
…ples a T# (TEST-524) d3d12_first_light_textured_test draws the first-light mesh through the D3D12 layer with the game's VS and $PS_PassthroughCopy, picked by census (780 of 12,101 PS do one image_sample and nothing else; 148 of those link with the VS). The PS loads its T# through the table pointer in s8 and samples with a literal S#; the root signature puts a one-SRV table at s8:s9 behind eight padding constants. first_light.py --texture ramp writes texture.bin, a 64x64 coordinate ramp (texel (x, y) holds its own centre, so bilinear sampling gives back the UV), and expected.raw, the CPU reference at every covered pixel's UV. RTX 3060: 12,804 pixels, the same coverage as d3d12_first_light, worst channel error 0.00028 against a 0.002 tolerance; point sampling is off by up to 1/128, which is what this draw gave before ItsNotRexed#2887. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s harness path Since the rebase onto 7e1aecf, --texture ramp exited with a TypeError: write_textured_inputs stored "texture": "ramp" and files["texture"], which harness_env reads as the --dds dict. The ramp's keys are now layer_texture*; a unit test feeds harness_env a ramp manifest (fails on the old keys). The vk_harness tests skip a ramp folder, which only the D3D12-layer test can draw. docs/first_light.md §7: the command names its --out, and the count without ItsNotRexed#2887 is 19,041 channels (measured here and on three other GPUs). Found by @zzEmmazz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claim: #2716 (new D3D item, found by TEST-524).
What was wrong
Some game shaders build their S# from immediates instead of loading it from a sampler table. One is the game's
$PS_PassthroughCopy:0x92, 0xC00000, 0x14500000, 0= CLAMP_LAST_TEXEL, bilinear, mip point, MAX_LOD 12. The translator lists these per shader (literal_samplersin the index). Since no heap slot names such an S#, the runtime has to register it itself.docs/design.mdsaid it does.It didn't.
rt::d3d12::register_samplers(#1169) is called only byd3d12_descriptor_test, andShaderLibrarydoesn't readliteral_samplersat all. Such a shader's hash lookup therefore found the fallback sampler (index 0) and sampled with the wrong filter and address modes.How it showed up
The TEST-524 draw is the real model, the game's VS, and
$PS_PassthroughCopythrough the D3D12 layer, on an RTX 3060 (driver 616.64, Vulkan SDK 1.4.363.1). It sampled a 64x64 coordinate-ramp texture and was compared with a bilinear CPU reference over 12,804 covered pixels:mainOn
mainevery output value is a texel centre (a multiple of 1/128), which is point sampling.How much of the game this affects
Census of the full translated corpus (26,501 shaders,
literal_samplersper index entry, counts only): 6,114 shaders (23%) build at least one S# from immediates, including 3,788 PS (31% of all PS), 800 MS and 1,421 CS. They use only 19 distinct S#, among them trilinear (4,636 uses), border clamp (2,424), a depth-compare LESS_EQUAL sampler (2,318) and anisotropic ones. Onmainall of them sampled through the fallback. Table in the PR comments.The change
ShaderEntry::literal_samplers(runtime/src/shader_library.h) is read from the index.register_literal_samplers()(runtime/shims/d3d12_vulkan_device.cpp) is called byCreateGraphicsPipelineStatefor each stage that uses the bindless set, and byCreateComputePipelineState. It goes throughbind_sampler, the same pathCreateSamplerandregister_samplersuse. It is idempotent, and a failure (no set, or a full sampler array) is logged once.docs/design.md, the "Literal samplers" row: when the registration happens, the bug, and the test.Test (no game files)
runtime/test/shaders/ps_m2_literal.asmisps_m2with its S# built froms_movliterals. Ind3d12_m2_textured_test:bindless_hash_lookupof the S# key is 0 (the fallback);On
mainthe test fails at the "after" check (line 189: bindless_hash_lookup(device.p, key) != 0). With this change it passes.Also passing on the RTX 3060:
d3d12_descriptor,shader_library,d3d12_vulkan_device,d3d12_first_light,d3d12_translated_drawandd3d12_pipeline_library.Thanks
e77a4f8a.SampledImageArrayDynamicIndexingcapability.d3d12_m2_textured20/20 and clean under validation).scripts/run_gpu_tests.pyjudgingps_m2_literalas a self-checking shader (reported on TEST-924: every texture format the game uses, from a real game texture, through the D3D12 layer (all 20 formats) #4251).5cd7fe73run on an AMD RDNA2 iGPU (26.10.1) and an RTX 5080 (616.92).By @rafaelpssz, with Claude Code (AI-assisted).