Skip to content

d3d12: a refused recorded call is logged once per call site, so a failing Close names its cause - #9612

Closed
madaraXor wants to merge 2 commits into
ProjectLeonida:mainfrom
madaraXor:d3d12-invalid-list-cause
Closed

madaraXor wants to merge 2 commits into
ProjectLeonida:mainfrom
madaraXor:d3d12-invalid-list-cause

Conversation

@madaraXor

@madaraXor madaraXor commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: #9522 (comment) (new D3D item)

What and why

When the layer refuses a recorded call, check() in runtime/shims/d3d12_com.cpp only sets the list's invalid flag. Close then returns E_INVALIDARG and ExecuteCommandLists refuses the list, with nothing in the log. On a retail boot every Close failed (171,277 in 240 s on an RX 6700 XT) and nothing said why. Finding the cause took a rebuild with per-line logging: ClearRenderTargetView had been given an untranslated console CPU handle, which #7880 now translates (measured in #8851).

  • check() takes a std::source_location default argument, so none of its 127 call sites change. The first refusal at each call site prints one line with the method and the line:
    [rt] d3d12: ID3D12GraphicsCommandList::ClearRenderTargetView refused a recorded call (d3d12_com.cpp:736); the list is invalid, so its Close returns E_INVALIDARG (logged once per call site)
  • The method name is taken from source_location::function_name(): the identifier before the parameter list, which handles MSVC's full signature and a bare name. 67 of the 127 sites are in methods that record nothing in the D3D12 trace before their check (RSSetViewports, OMSetRenderTargets, the UAV clears, …), so the name can't come from the trace.
  • The private helpers that check (atomic_copy, clear_unordered_access, bind_root, parameter, constants, address, defer, verify_bundle_descriptor_heaps, record_dispatch, record_draw) take the same defaulted std::source_location and pass it on, so a refusal inside one names the D3D12 method that called it (e.g. AtomicCopyBufferUINT, not atomic_copy; found in review). A bundle's deferred call runs in a lambda, which MSVC names Method::<lambda_N>::operator (), so method_of takes the identifier before ::<lambda.
  • One bit per source line keeps the refusals a title repeats every frame down to one relaxed atomic OR after the first. Nothing changes on the success path or in what Close returns.
  • docs/boot.md's triage step 6 points at the line.

Tested

Windows 10 22H2 (19045), AMD Radeon RX 6700 XT (gfx1031), AMD driver 32.0.21045.29003, MSVC 14.42 (VS 2022 Build Tools) RelWithDebInfo, Vulkan SDK 1.4.363.0, on main 5d74c2723.

  • New d3d12_refused_call_log: pass (head dbb13b047). It records ClearRenderTargetView with a null view, RSSetViewports with 17 viewports and Dispatch with no compute pipeline (refused inside record_dispatch) three times on a direct list: every Close returns E_INVALIDARG, and stderr names each of the three methods exactly once (Dispatch, never record_dispatch). A valid list closes with S_OK and logs nothing.
  • Negative control: with main's d3d12_com.cpp the new test fails at its first log check (line 113).
  • Full ctest -j6 at both heads (d52e2c49a, dbb13b047): the same 9 failures with and without this change, all on main on this card (root_signature_oracle, d3d12_vulkan_device, d3d12_texture_tiles, d3d12_close_parity, d3d12_execute_indirect_validation, d3d12_depth_resolve, d3d12_pso_validation, d3d12_mesh, d3d12_set_descriptor_heaps). vk_queue_query_sync fails intermittently here either way (1, 1, 0, 1, 1 over five runs); it doesn't link gta6rt_d3d12_com.
  • python -I tests/test_docs_*.py: unchanged. The four that fail (cli_flags, design_rows, env_vars, links) fail the same way on main without this change.
  • scripts/check_no_game_data.py on the changed files and git diff --check: clean.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

…ling Close names its cause

A recorded call the layer refuses only set the list's invalid flag: Close returned E_INVALIDARG and
ExecuteCommandLists refused the list with nothing in the log. On a retail boot every Close failed, and finding
the cause (ClearRenderTargetView given an untranslated console CPU handle, cleared since by ItsNotRexed#7880) took a
rebuild with per-line logging.

check() now takes a std::source_location default argument, so none of its 127 call sites change, and the
first refusal at each site prints one [rt] line with the method and the line. A per-line bit keeps the
refusals a title repeats every frame to one atomic OR after the first.

d3d12_refused_call_log_test records ClearRenderTargetView with a null view and RSSetViewports with one
viewport too many three times: every Close returns E_INVALIDARG and stderr names each method once; a valid
list closes with S_OK and logs nothing. docs/boot.md's triage step points at the line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thehollowedone

Copy link
Copy Markdown

Independent Windows check of d52e2c49. RTX 3080 Ti, NVIDIA 621.35, MSVC 19.44.35230, Vulkan SDK 1.4.363.0.

  • Stock d3d12_refused_call_log passed. All three refused lists closed with E_INVALIDARG. ClearRenderTargetView and RSSetViewports each logged once, and the valid list closed with S_OK without a refusal diagnostic.
  • A separate synthetic run repeated two different checks within DispatchMesh: a group count above the limit and a dispatch without a pipeline. All six refused lists closed with E_INVALIDARG, with one diagnostic per source line. Both runs had zero Khronos core or synchronization validation errors and no skips.

One wording suggestion for the boot guide: “If a recorded call caused Close to fail, look earlier in the log for the refusal diagnostic.” An unfinished query can also produce E_INVALIDARG without going through the new logger. Boot guide · Close implementation

Synthetic inputs only. AI-assisted.

@ThomasSAMP

Copy link
Copy Markdown

Tested d52e2c49a (on main 5d74c2723, no merge needed) on AMD Radeon RX 9070 XT (RDNA4), AMD driver 32.0.32029.2010, Windows 11 Pro 26300, MSVC 14.44 (VS 2022, RelWithDebInfo), Vulkan SDK 1.4.363.0: pass.

  • d3d12_refused_call_log_test: PASS with LEONIDA_VK_VALIDATION=0 and =1 (0 validation messages). stderr names ClearRenderTargetView (d3d12_com.cpp:736) and RSSetViewports (d3d12_com.cpp:452) once each over the three refused lists.
  • Negative control: with main's runtime/shims/d3d12_com.cpp and the PR's test, the test fails at line 113: count_of(log, "ID3D12GraphicsCommandList::ClearRenderTargetView refused a recorded call") == 1, as the description says.
  • d3d12_close_parity_test (it links the changed gta6rt_d3d12_com): pass with validation on and off, 113 cases, 0 failures. It fails on main on the author's RX 6700 XT, but passes here on RDNA4.
  • The build adds no warnings in the changed files. The only warnings come from vulkan_present.h:669 and d3d12_vulkan_device.cpp:7794/7796, which this PR doesn't touch.

Not run: the full ctest, or anything that needs game files.

AI-assisted (Claude Code).

@Henergyque

Copy link
Copy Markdown

Tested d52e2c49a on NVIDIA GeForce RTX 5060 Ti (Blackwell), driver 621.24 (32.0.16.2124), Windows 11 build 26300, no Resizable BAR, MSVC (VS 2022) RelWithDebInfo, Vulkan SDK 1.4.363.1: pass.

One thing from reading the code (non-blocking): when the refusing check() is inside a private helper, function_name() names the helper, not the D3D12 method. So this run printed ID3D12GraphicsCommandList::atomic_copy refused a recorded call (d3d12_com.cpp:1107) for what is an AtomicCopyBufferUINT/UINT64 call (lines 773/778). The same applies to the other helper sites at lines 1099-1428: clear_unordered_access, bind_root, first_dword, constants, defer, verify_bundle_descriptor_heaps and record_dispatch. The line number still pins it down. But the ID3D12GraphicsCommandList:: prefix on a name that isn't a method could send someone grepping for a method that doesn't exist. Two possible fixes:

  • give those helpers a std::source_location where = std::source_location::current() parameter, which the public methods pass through to check(), so the line names the API call;
  • or drop the interface prefix when the name isn't a public method.

AI-assisted (Claude Code) review and test run.

…called it

check() logged its own call site, so a refusal inside a private helper named the helper:
"ID3D12GraphicsCommandList::atomic_copy" for an AtomicCopyBufferUINT call (found in review on ProjectLeonida#9612).
The helpers that check (atomic_copy, clear_unordered_access, bind_root, parameter, constants, address,
defer, verify_bundle_descriptor_heaps, record_dispatch, record_draw) now take a defaulted
std::source_location and pass it on, so the logged line is the public method's call. A bundle's deferred
call runs in a lambda, which MSVC names "Method::<lambda_N>::operator ()": method_of takes the
identifier before "::<lambda".

d3d12_refused_call_log_test adds Dispatch with no compute pipeline, refused in record_dispatch: the line
names Dispatch and never record_dispatch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@madaraXor

Copy link
Copy Markdown
Author

@Henergyque thanks, good catch: done in dbb13b047. The helpers that check (atomic_copy, clear_unordered_access, bind_root, parameter, constants, address, defer, verify_bundle_descriptor_heaps, record_dispatch, record_draw) now take a defaulted std::source_location and pass it to check(), so the line names the public method's call. A bundle's deferred call runs in a lambda, which MSVC names Method::<lambda_N>::operator (), so method_of takes the identifier before ::<lambda there.

The test adds Dispatch with no compute pipeline (refused in record_dispatch): the line reads ID3D12GraphicsCommandList::Dispatch refused a recorded call (d3d12_com.cpp:413), and the test checks that record_dispatch never appears. RX 6700 XT, AMD 32.0.21045.29003, Windows 10 19045, MSVC 14.42: the test passes, and full ctest -j6 shows the same 9 failures as main on this card, plus vk_queue_query_sync's intermittent one (it doesn't link gta6rt_d3d12_com).

@ThomasSAMP thanks for the RDNA4 run.

AI-assisted (Claude Code).

@Zipettte

Copy link
Copy Markdown

Tested on AMD Radeon RX 7700 XT (RDNA3), AMD Windows driver 32.0.32029.2010, Windows 11, MSVC 14.51 Release, at d52e2c4. Full ctest -j 8, out of 240 tests:

No regression. The only failures are the same 5 as on main dde82f2 on this card (vk_queue_query_sync, d3d12_vulkan_device tiles == 1, d3d12_texture_tiles, d3d12_depth_resolve, d3d12_pipeline_library_host; tracked in #8426). Every test this PR adds or touches passes.

AI-assisted (Claude Code).

@Henergyque

Copy link
Copy Markdown

@madaraXor thanks. Re-tested dbb13b047 on the same setup (RTX 5060 Ti, 621.24, Windows 11 26300, no Resizable BAR, MSVC RelWithDebInfo). I applied the PR's diff to main 5d74c2723 (git fetch of this repo returns 403 right now, so I took the diff through the API): pass.

  • d3d12_refused_call_log: passed.
  • Full ctest -j6: 273/276, the same 3 known failures as on main (d3d12_vulkan_device, d3d12_depth_resolve, d3d12_indirect_rt). No regression.
  • Across the full run every refused-call line now names a public method. The one that read atomic_copy before now reads ID3D12GraphicsCommandList::AtomicCopyBufferUINT64 refused a recorded call (d3d12_com.cpp:785). The others are ResolveSubresourceRegion (:708, twice), ResolveSubresource (:692, :694), DiscardResource (:763) and WriteBufferImmediate (:773). No helper name appears anywhere.

AI-assisted (Claude Code) test run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants