Repository navigation
runtime: map a PSO-cache graphics user-data record to a root signature - #4732
YaBulochka wants to merge 1 commit into
Conversation
Add a portable mapper for one decoded graphics-stage record from the PS\0\x09 PSO cache (D3D-479; format in docs/pso_cache.md, ItsNotRexed#4358): one descriptor table per distinct 0x42 SS, one D3D12_DESCRIPTOR_RANGE per (SS, II) slot pair, one 32-bit-constants parameter per 0x401 entry, then rt::rootsig::pack into the 32 user-data dwords. What the record does not carry is not invented: the parameter order is Record or ascending SS (both labelled hypotheses), the 0x401 base register is 0 with a note, the visibility comes from the caller, and an undecoded extra 0x42 slot refuses the record instead of producing a partial mapping. One record is one stage's user-data block, so it maps to its own root signature; a graphics PSO carries 3-5 distinct records and concatenating them would double-count parameters. CPU test runtime/test/pso_user_signature_test.cpp (ctest pso_user_signature, no GPU or game data) covers the measured shape, both orders, interleaved tables, the extra-slot and slot-pair refusals, the spill rule, and the canonical codec round-trip. Depends on: ItsNotRexed#4358 (cache decoder and docs/pso_cache.md).
Kam471
left a comment
There was a problem hiding this comment.
Built and ran pso_user_signature_test at 02f734242 on Windows 11: all checks passed, exit 0.
The new portable mapping (runtime/src/pso_user_signature.{h,cpp}) reduces one PSO-cache graphics user-data record to RootSignature parameters: distinct 0x42 SS -> one descriptor table, each (SS, II) -> one range, each 0x401 -> 32-bit constants, samplers/0x100 -> no dword, and records with unpaired slots are refused rather than silently dropping user data. The tests cover the 32-dword packing rule, the one-dword-per-table case, the spill refusal and the mapping order. The header documents what the record does not carry (parameter order, base register, visibility) instead of guessing. No blocking issue.
|
At Please reject this ambiguous binding with a reason when the record does not supply a distinct register. This keeps the caller from using an invalid signature. To reproduce on Windows 11, save these two files in a new folder next to the PR checkout. Name the checkout
cmake_minimum_required(VERSION 3.20)
project(probe LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(src ../head/runtime/src)
add_executable(probe main.cpp ${src}/pso_user_signature.cpp ${src}/root_signature.cpp)
target_include_directories(probe PRIVATE ${src})
target_link_libraries(probe PRIVATE d3d12)
#include "pso_user_signature.h"
#include <windows.h>
#include <d3d12.h>
#include <cstdio>
int main() {
rt::pso::UserRecord record{{{0x401,1,1},{0x401,1,1}}, {}};
auto r = rt::pso::map_user_record(record);
if (!r.ok || r.signature.params.size()!=2) return 1;
D3D12_ROOT_PARAMETER p[2]{};
for (int i=0;i<2;i++) {
auto &v=r.signature.params[i];
p[i].ParameterType=D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
p[i].Constants={v.shader_register,v.register_space,v.num_values};
p[i].ShaderVisibility=(D3D12_SHADER_VISIBILITY)v.visibility;
}
D3D12_ROOT_SIGNATURE_DESC d{2,p,0,nullptr,D3D12_ROOT_SIGNATURE_FLAG_NONE};
for (int n=0;n<=1;n++) {
p[1].Constants.ShaderRegister+=n;
ID3DBlob *blob=nullptr,*err=nullptr;
auto hr=D3D12SerializeRootSignature(&d,D3D_ROOT_SIGNATURE_VERSION_1,&blob,&err);
std::printf("map_ok=%d registers=%u,%u serialize=0x%08lx %s\n",r.ok,p[0].Constants.ShaderRegister,p[1].Constants.ShaderRegister,hr,err?(char*)err->GetBufferPointer():"");
if (blob) blob->Release();
if (err) err->Release();
}
}AI-assisted. |
|
Re-ran at head Result: all checks passed (63 checks), exit 0. Confirms the earlier Windows 11 run at the same SHA on this machine class. No game data. AI-assisted (Devin). |
|
Reviewed on Linux: the mapping module is careful — every unplaceable record shape is refused with a specific error rather than guessed, notes are phrased for tests, and all fixtures are hand-built records (no cache file, no game data); API use matches the existing root_signature.h. It could not be compiled on this verifier host (no cmake builds), so correctness rests on the CI build legs, which were still queued. Note the header comments reference PR #4358's decoder and docs/pso_cache.md, which are not in this tree yet — comments only, so nothing breaks, but the constants land ahead of their documentation. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
Starts the graphics side of the PSO-cache work: a portable reduction from one decoded graphics-stage user-data record (
PS\0\x09cache, #4358) to the layer'srt::rootsig::RootSignature, packed with the existingrt::rootsig::pack. No d3d12.h, no Vulkan, no cache file.The mapping is deliberately conservative:
0x42table index (SS) becomes one descriptor-table parameter; each(SS, II)pair becomes one range (IIis the D3D12 range type order), with the entry's base register/space/count;0x401entry becomes a 32-bit-constants parameter ofadwords;0x2(sampler) and0x100consume no user-data dword and are reported as notes;What the record does not carry is not invented: the root-parameter order (
Order::RecordorOrder::Table, both marked as hypotheses), the0x401base shader register (0 with a note), and the stage visibility (caller-supplied) are explicit options/notes. One record is one stage's block, so it produces its own signature; the current layer packs a single block for all graphics stages (#4312), which is why the synthetic pipeline will use the record of the stage it exercises.runtime/test/pso_user_signature_test.cpphas 63 checks: the measured shape (SRV table +0x401constants, CBV table), both orders, interleaved tables, the console-dword diagnostic (27 vs 32), every refusal, and the canonicalencode/decoderound-trip. Linux build andctest: 51/51, includingpso_user_signature.Dependency:
docs/pso_cache.mdand the decoder this consumes are in #4358; the header refers to that PR until it lands. Next step is the Windows/Wine synthetic draw test (root signature from such a record, one triangle, readback), which needs the cross build and is not in this PR.Claim: D3D-479, #4683.