Repository navigation
Conversation
…dy has The PC runtime keeps one root signature object per serialized signature: a second CreateRootSignature from the same bytes, from the same buffer or another one, returns the same pointer with one more reference, and the last Release destroys it (WARP and an NVIDIA device). The layer made a new object per call, and SetGraphics/ComputeRootSignature with a different object zeroes the root arguments, so switching between two handles made from the same bytes lost arguments the PC runtime keeps. The device now maps a signature's content hash to the live object. The map owns nothing; the caller's reference is taken under the lock a dying signature needs to leave the map, so an entry past its last Release is never handed out and is replaced instead. d3d12_compute_test checks identity, counts, device references, private data and release order against the measured values and prints the host's own answers, runs four threads creating and releasing the same bytes, and uses a really different signature (the 1.1 serialization) for the case where a switch must clear the arguments. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
I reviewed the final-release path at eef1f893. I think the cache needs one more lifetime guarantee before merging. The inherited I’d serialize the final reference transition and cache removal with lookup, and release the lock before deleting the object. Keeping |
|
Verified head
AI-assisted. |
|
Independent Windows + RTX 5080 GPU verification of Build & Tests
Code check
(AI-assisted) |
Review of the first commit: the lookup in CreateRootSignature took its reference through a cached pointer whose object could already be in its destructor, since Object::Release starts the delete as soon as the count reaches zero and the map entry was only removed inside the destructor. RootSignature now has its own count. Release decrements it under the map's lock and, at zero, removes the entry in the same critical section; the object is deleted after the lock is dropped. A signature the lookup finds is therefore alive and stays alive while the lookup adds its reference, and the "AddRef returned 1" case is gone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks @thehollowedone, you are right, and it is fixed in The first commit took the map's lock only inside What changed, as you suggested:
Cost: every Re-run on the same machine (Windows 11, MSVC 19.42, RTX 3080 Ti 616.56): @smowlyy, your run was on AI-assisted (Claude Code). |
|
Tested
Independent check, claim. AI-assisted (Claude Code). |
|
Thanks for the update. I rechecked f135530d. Lookup takes its reference under the same lock that covers the last decrement and cache removal. Deletion and On Windows 11, RTX 3080 Ti (621.35), MSVC 19.44, and Vulkan SDK 1.4.363, a focused The temporary fixture covered these identity and rebind cases. Concurrency was reviewed statically. Synthetic inputs only. AI-assisted. |
Claim: #8504 (comment)
@ItsNotRexed: an exe PR, as you asked.
What
ID3D12Device::CreateRootSignaturenow returns the live root signature object for bytes it already made one from, with one more reference, as the PC runtime does.Before, every call made a new object.
SetGraphicsRootSignature/SetComputeRootSignaturekeep the bound root arguments only when the same object is set again (bind_rootind3d12_com.cpp, unchanged here); a different object resets them to zero. So a title that creates a signature twice from the same bytes and switches between the two handles kept its arguments on the PC runtime, where both handles are one object, and lost them here.The device keeps a map from a signature's content (the SHA-256 the object already carries for the PSO cache) to the live object:
Releasetakes its entry out of the map under the map's lock, then deletes the object after the lock is dropped;The Xbox proxy forwards device slot 16 to this same function and does not wrap root signatures, so the console path gets the same behaviour (
d3d12_compute_testruns through the proxy).Why
Measured on this machine, the same on WARP and the NVIDIA device, no debug layer:
mainReach: a run reported in #8186 counts 1,250 root signature creates by the title, one per program (in that run 1,204 of them stopped in the title's own code before reaching the device), so creates from repeated bytes are plausible; I have not measured how many repeat. Two more things are not known: whether the console's D3D12 runtime deduplicates the same way, and whether the title relies on arguments surviving such a switch. If the console does not deduplicate, the title already re-sets its arguments after every switch and this change is invisible to it; if it does, the layer dropped arguments the title expected to keep. Either way the change follows the PC runtime and cannot take arguments away.
Not D3D-879 (the root argument spill, #8278 / #7318).
Tested
Windows 11 (10.0.26200), MSVC 19.42 (VS 2022 Build Tools), RelWithDebInfo, NVIDIA RTX 3080 Ti, driver 616.56, Vulkan SDK 1.4.363.0. No game files.
main@867d922f0'sd3d12_vulkan_device.cpp): exit 1.main(element 0: got 6007, 6100 and 0, want 6007, 6100 and 6000): the arguments were zeroed.root signature identity: 2 of 2 host adapter(s) gave the same 13 answers, and the three dispatches match; 30 of 30 runs in a loop on the current head.d3d12_close_parity_testtreats WARP, so a d3d12.dll that behaves differently does not break the test; under Wine the host part is skipped (vkd3d makes an object per call).GetDeviceon what they get; no failure, and the bytes then make a fresh object with one reference.d3d12_bundle_test(14 scenarios, 25 host comparisons),d3d12_multithread_test,d3d12_pipeline_library_test,d3d12_descriptor_test,d3d12_set0_compute_test,d3d12_draw_test,d3d12_com_test,d3d12_private_data_test,xs_proxy_mock_test,device_proxy_test.python -I scripts/check_no_game_data.pyon the two changed files: exit 0.Not tested, and limits:
Releaseof a root signature now takes the device's root-signature mutex for the decrement (AddRefstays lock-free).d3d12_bundle_test's "release right after recording" now receives a signature that something else still holds, so it no longer destroys the object there. It passes.d3d12_vulkan_device_testfails onmainand with this PR at the same line (tiles == 1, d3d12_vulkan_device: check PC CreateReservedResource2 behind the Xbox proxy, not through slot 78 #7125), so it says nothing here.AI-assisted (Claude Code).
🤖 Generated with Claude Code