Repository navigation
runtime: map a PSO-cache graphics user-data record to a root signature, and draw with it - #4732
YaBulochka wants to merge 2 commits into
Conversation
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). |
…record D3D-479's next step after the record mapper (ItsNotRexed#4732): the portable RootSignature map_user_record produces is converted to a D3D12_VERSIONED_ROOT_SIGNATURE_DESC, serialized by the host d3d12.dll and created through the Xbox-ABI proxy, then used by a real draw. runtime/test/d3d12_pso_usersig_draw_test.cpp builds two synthetic records of the shape ItsNotRexed#4358 measures: a 0x401 constants parameter before one SRV table, and the same constants before one table holding an SRV and a CBV range. Both map and both root signatures are created; the two draws use vs_draw.vert and a new ps_pso_usersig.frag so the record's constants show up as s0/s1 (a clip-space offset) and s2/s3 (a tint) of the 32 user-data dwords the layer packs, with the table VA at s4:s5. All 4096 pixels of a 64x64 R8G8B8A8 target match (top-left 64,128,0,255; bottom-right 192,32,0,255; background 0,0,255,255). The mapper's zero-count, extra-slot and SRV/CBV-mismatch refusals are checked at CPU level before the GPU part. LEONIDA_VK_VALIDATION=1 is honoured as in the neighbouring GPU tests, and a missing layer fails instead of silently running without it. ctest d3d12_pso_usersig_draw, skip code 77. Depends on: ItsNotRexed#4732 (pso_user_signature) and ItsNotRexed#4358 (cache format).
|
Tested
AI-assisted (Gemini 4 Neon). |
|
Tested e00f393 on Intel UHD 770 (driver 32.0.101.7088), Windows 11, MSVC 19.44, Vulkan SDK 1.4.357.0: pass. Native MSVC build of d3d12_pso_usersig_draw_test, run with LEONIDA_VK_VALIDATION=1: exit 0, harness prints "device: Intel(R) UHD Graphics 770 (validation on)", 0 VUID lines on stderr.
AI-assisted. |
|
Tested
Not run: other GPUs/vendors, Linux. No game files. AI-assisted (Claude Code). Edited: an earlier version said the Vulkan SDK and its validation layer weren't installed. SDK 1.4.363.0 had been installed the night before this run; the results above are unchanged. |
|
Tested e00f393 on NVIDIA GeForce RTX 4080, driver 617.42, Windows 11 (clang-cl cross-build): pso_user_signature_test exits 0 with "all checks passed", and d3d12_pso_usersig_draw_test exits 0 with no FAIL lines. The draw test printed no pixel summary in this run, so the pass rests on its exit code. AI-assisted. |
…record D3D-479's next step after the record mapper (ItsNotRexed#4732): the portable RootSignature map_user_record produces is converted to a D3D12_VERSIONED_ROOT_SIGNATURE_DESC, serialized by the host d3d12.dll and created through the Xbox-ABI proxy, then used by a real draw. runtime/test/d3d12_pso_usersig_draw_test.cpp builds two synthetic records of the shape ItsNotRexed#4358 measures: a 0x401 constants parameter before one SRV table, and the same constants before one table holding an SRV and a CBV range. Both map and both root signatures are created; the two draws use vs_draw.vert and a new ps_pso_usersig.frag so the record's constants show up as s0/s1 (a clip-space offset) and s2/s3 (a tint) of the 32 user-data dwords the layer packs, with the table VA at s4:s5. All 4096 pixels of a 64x64 R8G8B8A8 target match (top-left 64,128,0,255; bottom-right 192,32,0,255; background 0,0,255,255). The mapper's zero-count, extra-slot and SRV/CBV-mismatch refusals are checked at CPU level before the GPU part. LEONIDA_VK_VALIDATION=1 is honoured as in the neighbouring GPU tests, and a missing layer fails instead of silently running without it. ctest d3d12_pso_usersig_draw, skip code 77. Depends on: ItsNotRexed#4732 (pso_user_signature) and ItsNotRexed#4358 (cache format).
e00f393 to
ca5d45a
Compare
|
Independent Windows GPU recheck of ca5d45a3 on an RTX 3080 Ti (driver 621.35, Vulkan SDK 1.4.363.0). The focused I ran the valid mapping and draw cases from the fixture. Synthetic inputs only. AI-assisted. |
…record D3D-479's next step after the record mapper (ItsNotRexed#4732): the portable RootSignature map_user_record produces is converted to a D3D12_VERSIONED_ROOT_SIGNATURE_DESC, serialized by the host d3d12.dll and created through the Xbox-ABI proxy, then used by a real draw. runtime/test/d3d12_pso_usersig_draw_test.cpp builds two synthetic records of the shape ItsNotRexed#4358 measures: a 0x401 constants parameter before one SRV table, and the same constants before one table holding an SRV and a CBV range. Both map and both root signatures are created; the two draws use vs_draw.vert and a new ps_pso_usersig.frag so the record's constants show up as s0/s1 (a clip-space offset) and s2/s3 (a tint) of the 32 user-data dwords the layer packs, with the table VA at s4:s5. All 4096 pixels of a 64x64 R8G8B8A8 target match (top-left 64,128,0,255; bottom-right 192,32,0,255; background 0,0,255,255). The mapper's zero-count, extra-slot and SRV/CBV-mismatch refusals are checked at CPU level before the GPU part. LEONIDA_VK_VALIDATION=1 is honoured as in the neighbouring GPU tests, and a missing layer fails instead of silently running without it. ctest d3d12_pso_usersig_draw, skip code 77. Depends on: ItsNotRexed#4732 (pso_user_signature) and ItsNotRexed#4358 (cache format).
ca5d45a to
6c4fadf
Compare
|
checked: rebased onto The rebase only clashed in
|
|
Tested Windows 11, MSVC 14.44.35207 (VS Build Tools 2022,
Control. The whole feature is new in this PR: Commands: |
|
Tested Full runtime AI-assisted (Claude Code). |
…record D3D-479's next step after the record mapper (ProjectLeonida#4732): the portable RootSignature map_user_record produces is converted to a D3D12_VERSIONED_ROOT_SIGNATURE_DESC, serialized by the host d3d12.dll and created through the Xbox-ABI proxy, then used by a real draw. runtime/test/d3d12_pso_usersig_draw_test.cpp builds two synthetic records of the shape ProjectLeonida#4358 measures: a 0x401 constants parameter before one SRV table, and the same constants before one table holding an SRV and a CBV range. Both map and both root signatures are created; the two draws use vs_draw.vert and a new ps_pso_usersig.frag so the record's constants show up as s0/s1 (a clip-space offset) and s2/s3 (a tint) of the 32 user-data dwords the layer packs, with the table VA at s4:s5. All 4096 pixels of a 64x64 R8G8B8A8 target match (top-left 64,128,0,255; bottom-right 192,32,0,255; background 0,0,255,255). The mapper's zero-count, extra-slot and SRV/CBV-mismatch refusals are checked at CPU level before the GPU part. LEONIDA_VK_VALIDATION=1 is honoured as in the neighbouring GPU tests, and a missing layer fails instead of silently running without it. ctest d3d12_pso_usersig_draw, skip code 77. Depends on: ProjectLeonida#4732 (pso_user_signature) and ProjectLeonida#4358 (cache format).
6c4fadf to
c5a07fa
Compare
|
Rebased onto Tests (Linux, clang-cl + xwin Windows SDK cross-build, RelWithDebInfo, Wine 11.x):
The |
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, ProjectLeonida#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: ProjectLeonida#4358 (cache decoder and docs/pso_cache.md).
…record D3D-479's next step after the record mapper (ProjectLeonida#4732): the portable RootSignature map_user_record produces is converted to a D3D12_VERSIONED_ROOT_SIGNATURE_DESC, serialized by the host d3d12.dll and created through the Xbox-ABI proxy, then used by a real draw. runtime/test/d3d12_pso_usersig_draw_test.cpp builds two synthetic records of the shape ProjectLeonida#4358 measures: a 0x401 constants parameter before one SRV table, and the same constants before one table holding an SRV and a CBV range. Both map and both root signatures are created; the two draws use vs_draw.vert and a new ps_pso_usersig.frag so the record's constants show up as s0/s1 (a clip-space offset) and s2/s3 (a tint) of the 32 user-data dwords the layer packs, with the table VA at s4:s5. All 4096 pixels of a 64x64 R8G8B8A8 target match (top-left 64,128,0,255; bottom-right 192,32,0,255; background 0,0,255,255). The mapper's zero-count, extra-slot and SRV/CBV-mismatch refusals are checked at CPU level before the GPU part. LEONIDA_VK_VALIDATION=1 is honoured as in the neighbouring GPU tests, and a missing layer fails instead of silently running without it. ctest d3d12_pso_usersig_draw, skip code 77. Depends on: ProjectLeonida#4732 (pso_user_signature) and ProjectLeonida#4358 (cache format).
c5a07fa to
6cf6f7a
Compare
|
One more rebase: |
|
Tested
|
|
Addendum: the head moved to |
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.The draw: a mapped record actually renders
runtime/test/d3d12_pso_usersig_draw_test.cppbuilds two synthetic records of the measured shape and turns each into a root signature through the same mapper:0x401constants parameter (4 dwords) and one SRV table (SS=1, II=0);II=2).The portable
RootSignatureis converted to aD3D12_VERSIONED_ROOT_SIGNATURE_DESC1.1 (D3D12_ROOT_PARAMETER1/D3D12_DESCRIPTOR_RANGE1), serialized with the hostD3D12SerializeVersionedRootSignature, created through the Xbox-ABI proxy, and the layer parses the blob back intos0..s31. The graphics PSO addsALLOW_INPUT_ASSEMBLER_INPUT_LAYOUTbecause a record carries no flags and an input layout requires it; that is the only field the test adds and it is documented in the source.Two draws into a 64x64
R8G8B8A8_UNORMtarget, each with its own mapped signature, check 4096/4096 pixels:Root constants reach the VS (clip-space offset) and the PS (tint); the table lands in
s4:s5. The mapper's negative cases (zero count, an extra0x42slot, an SRV/CBV kind mismatch) are checked at CPU level.Verified with the xwin cross build under Wine and Proton 11.0 on RADV:
The test honours
LEONIDA_VK_VALIDATION=1; under Wine it refuses to start when the layer is not enumerable, like the neighbouring tests. With the Khronos layer forced as an implicit layer it runs with no VUID from this test; the one device-creation message it sees (VUID-vkCreateDevice-ppEnabledExtensionNames-01387,VK_EXT_external_memory_dma_bufwithoutVK_KHR_external_memory_fd) also reproduces ind3d12_draw, so it is a pre-existing layer-side device-creation gap, not this test's.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.