Repository navigation
d3d12: CreateRootSignature registers the root signature's static samplers - #3494
Conversation
…lers The Vulkan device parsed a root signature's static samplers and dropped them, so a shader holding one's S# by value missed in the hash table and sampled through the fallback sampler. Each one now gets a sampler in set 0 and a key in the hash table at root-signature creation, encoded as CreateSampler2 encodes the same description (1.0, 1.1 and 1.2 blobs, the static border-colour enum, the 1.2 flags). d3d12_descriptor_test checks the key before and after for four root signatures and samples with three of them on the GPU. docs/d3d12_vulkan.md no longer says both that they are registered and that they are not. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
0xTehuti
left a comment
There was a problem hiding this comment.
Tested \6f66c4b5\ on NVIDIA GeForce RTX 2070 SUPER (TU104, Turing), driver 595.79, Windows 11 Pro x64, Vulkan 1.4.329. Built with MSVC 19.44 (VS 2022 Community), Ninja 1.13, CMake 4.4, RelWithDebInfo.
- Static samplers registration: \d3d12_descriptor_test.exe\ confirmed all 4 of 4 root signatures (versions 1.0, 1.1 and 1.2) registered their S# keys in set 0 without a heap slot.
- Lifetime outliving root signatures: S# keys preserved after root signature reference release (\�efore == after).
- Draw/Sample execution on hardware:
- Root signature 1.0 static sampler: 64/64 texels wrapped (8 would match clamp).
- Root signature 1.1 static sampler: 64/64 texels wrapped (8 would match clamp).
- Root signature 1.2 static sampler: 64/64 texels wrapped (8 would match clamp).
- Unregistered literal control: 64/64 texels clamped as expected.
- CTest: \ctest -R d3d12_descriptor\ passed 1/1 (0.48s, exit 0).
Clean registration of static samplers into the bindless descriptor set. LGTM.
|
Windows + GPU check: AMD Radeon RX 9070 (RDNA4), Windows 11, MSVC Release, Vulkan SDK 1.4.363. Tested head 6f66c4b merged onto AI-assisted (Claude Code); runs on my machine. |
|
Tested 6f66c4b merged onto main aa2988c on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
Claim: #3232 (comment)
The problem
CreateRootSignatureon the Vulkan device parses a root signature's static samplers (parsed.sig.static_samplers,runtime/src/root_signature.cpp) and then uses onlyparsed.sig.params. Nothing registers the samplers.docs/d3d12_vulkan.mdsays two things about it: §3.5 "The layer registers every static sampler's S# in the hash table, so a shader that loads it by value works", and §3.2 "static samplers of root signatures, which are not registered yet". The second was the true one. A shader that holds a static sampler's S# by value misses in the hash table and samples through the fallback sampler at index 0.The change
CreateRootSignatureregisters each static sampler: a sampler in set 0 and a key in the hash table, without a heap slot, exactly asCreateSampler/CreateSampler2register a heap slot's S#. It covers 1.0, 1.1 and 1.2 blobs, the fiveD3D12_STATIC_BORDER_COLORvalues (two of them UINT) and the 1.2Flags.D3D12_SAMPLER_DESC2moves out ofCreateSampler2intosampler2_words, so both paths encode the same description to the same key.CreateSampler2itself is unchanged in behaviour.CreateSampler2refuses) is logged once and not registered; the root signature is still created. What the PC runtime answers for such a blob is not measured here.docs/d3d12_vulkan.md: the "not registered yet" clause is gone and §3.5 says where and how the registration happens.Cost:
bind_samplerkeys its entries by the S# and returns early for one it already has, as forCreateSampler, so a title's many root signatures cost one sampler and one hash-table entry per distinct static sampler, not per root signature. An entry is never removed (the same as a heap slot's).Not touched: the literal-S# path (
rt::d3d12::register_samplers, #1169, #2887). Whether the game's shaders reach their static samplers by value or through a driver table is still open in §3.5; this covers the by-value case the doc already promised.Tests
Windows 11, MSVC 14.44 (VS 2022), the CMake and Ninja that Visual Studio ships (3.31.6), SDK 10.0.26100, RelWithDebInfo, NVIDIA RTX 4090 (driver 621.14). No game files.
d3d12_descriptor_test, new static-sampler cases. Four root signatures from the PC runtime's own serializer, each with one static sampler and no parameter: 1.0, 1.1 and 1.2 with a POINT sampler that wraps in U, and a 1.1 one with aBORDERaddress andOPAQUE_WHITE_UINT. For each: the S# has no hash-table entry beforeCreateRootSignatureand one after, and still has it after the root signature is released.cs_sample.compthrough set 0): sampling with each wrapping static sampler's S# one tile to the right in UCreateRootSignaturewithout the registrationd3d12_descriptor_testfails at the "entry after creation" checkctest(141 tests)gameinputis disabled (no SDL3)python -I tests/test_docs_links.py,test_docs_list_items.py,test_docs_repo_paths.py,test_docs_design_rows.pyNot tested:
OPAQUE_WHITE_UINTborder) is checked for its hash-table key only; it is not sampled on the GPU.CreateSampler2refuses) and the "no room in the bindless set" path have no test.d3d12.dllcannot serialize 1.2 (the test prints "skipped" for that version and still requires three).AI-assisted (Claude Code).
🤖 Generated with Claude Code