From f814088de85936a917f92eee829c2d1565f6eb5c Mon Sep 17 00:00:00 2001 From: NiiRoZz Date: Wed, 25 Nov 2026 02:28:51 +0100 Subject: [PATCH 1/3] startup: count ExecuteIndirect calls by refusal reason and signature kind The slot-61 refusal log stops after 16 lines, so a run could not tell how many calls fall under each reason. Keep 64-bit counters per outcome (forwarded, graphics pipeline, compute pipeline, placeholder signature, other) and signature kind, and print one x2w-render indirect line beside the render totals heartbeat. Forwarding is unchanged. startup_indirect_draw_indexed now refuses one call per counted reason, presents 300 empty frames and asserts the line; the count-control run expects one forwarded call too many and must report the mismatch. Co-Authored-By: Claude Fable 5.2 --- CMakeLists.txt | 3 ++ CMakePresets.json | 2 +- docs/startup-runtime.md | 8 ++++ src/startup_stubs/d3d12_xs_device.cpp | 36 ++++++++++++-- tests/startup_indirect_draw_indexed.cpp | 63 ++++++++++++++++++++++++- 5 files changed, 106 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6abe7740dd..9d48b3412a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -926,6 +926,9 @@ foreach(backend IN ITEMS warp hardware) set_tests_properties(startup_indirect_mesh_${backend} PROPERTIES TIMEOUT 30 SKIP_RETURN_CODE 77) endforeach() set_tests_properties(startup_indirect_draw_indexed_hardware startup_indirect_draw_hardware PROPERTIES SKIP_RETURN_CODE 77) +# Negative control for the x2w-render indirect line: one forwarded call too many must be reported as a mismatch. +add_test(NAME startup_indirect_counts_control_warp COMMAND startup_indirect_draw_indexed warp count-control) +set_tests_properties(startup_indirect_counts_control_warp PROPERTIES TIMEOUT 30 PASS_REGULAR_EXPRESSION "indirect line mismatch") # OMSetRenderTargets with a single descriptor range, handles that hold no view, and a cleared copied descriptor. add_executable(startup_rtv_bind tests/startup_rtv_bind.cpp) diff --git a/CMakePresets.json b/CMakePresets.json index 6d31bf8805..9363051854 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -42,7 +42,7 @@ "displayName": "Windows pull request smoke tests", "filter": { "include": { - "name": "^(desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_indirect_(dispatch|draw(_indexed)?|mesh)_warp)$" + "name": "^(desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_indirect_(dispatch|draw(_indexed)?|mesh|counts_control)_warp)$" } } }, diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index f2785aa286..29025c85c5 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -542,6 +542,14 @@ With `-Render`, `d3d12_xs` prints a running total to `stderr.txt` every 300 fram x2w-render totals: ... translated draws N (not drawn M), pipelines translated P / missing Q, ... ``` +Next to it, one line counts every `ExecuteIndirect` call (command-list slot 61) since the start, forwarded or by refusal reason, then by signature kind (`draw`, `drawindexed`, `dispatch`, `dispatchmesh`, or `other` for a placeholder or unknown signature); a reason with no calls reads `0`: + +``` +x2w-render indirect: forwarded: drawindexed 3; refused graphics-pipeline: drawindexed 1; compute-pipeline: dispatch 1; placeholder-signature: other 1; other: drawindexed 2 +``` + +`graphics-pipeline` is a draw without a matching desktop pipeline and root, `compute-pipeline` a dispatch without a desktop compute pipeline and root, and `other` every remaining refusal. The `x2w-render ExecuteIndirect refused` lines still stop after 16. `startup_indirect_draw_indexed_warp` checks this line; `startup_indirect_counts_control_warp` expects one forwarded call too many and must report the mismatch. + Compare the last line of each run. More translated draws and fewer "not drawn" mean a translator change reached real draws. "missing" is a live count of pipelines still waiting for a manifest. It can grow while things improve, if the run gets further and requests new pipelines. ### 4. Census, then rank diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index 105d7b93f1..fc3130edac 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -1982,11 +1982,19 @@ void __stdcall list_compute_root(Wrapper* self, void* root) if (pass.compute_root) list->SetComputeRootSignature(pass.compute_root); } +// Slot-61 calls by outcome and signature kind (IndirectCommand; none counts placeholder and unknown +// signatures), reported with the render totals. 64-bit and never reset, so they neither wrap nor stall. +enum { indirect_forwarded, indirect_graphics_pipeline, indirect_compute_pipeline, indirect_placeholder, indirect_other, + indirect_outcomes }; +volatile LONG64 indirect_calls[indirect_outcomes][5]; + // The guest method has independent resource and byte-offset arguments. void __stdcall list_execute_indirect(Wrapper* self, void* signature, UINT count, void* argument, u64 offset, void* count_buffer, u64 count_offset) { - const auto refuse = [](const char* reason) { + IndirectCommand kind = IndirectCommand::none; + const auto refuse = [&kind](const char* reason, int outcome = indirect_other) { + InterlockedIncrement64(&indirect_calls[outcome][static_cast(kind)]); static LONG refusals; if (first_calls(refusals, 16)) log("x2w-render ExecuteIndirect refused: %s", reason); }; @@ -1998,11 +2006,12 @@ void __stdcall list_execute_indirect(Wrapper* self, void* signature, UINT count, if (count != 1 || count_buffer || count_offset) return refuse("requires one command and no count buffer"); Wrapper* sig = as_wrapper(signature); if (!sig || sig->own().kind != command_signature_kind || !sig->own().real) - return refuse("missing or placeholder signature"); + return refuse("missing or placeholder signature", indirect_placeholder); const Wrapper* device = self->own().list_device; if (!device || sig->own().signature_device != device) return refuse("requires a supported signature from this device"); const auto command = sig->own().indirect_command; + kind = command; const bool indexed = command == IndirectCommand::draw_indexed; const bool mesh = command == IndirectCommand::dispatch_mesh; const bool graphics = indexed || mesh || command == IndirectCommand::draw; @@ -2014,7 +2023,8 @@ void __stdcall list_execute_indirect(Wrapper* self, void* signature, UINT count, else bytes = sizeof(D3D12_DRAW_ARGUMENTS); if (type != D3D12_COMMAND_LIST_TYPE_DIRECT || !pass.indirect_graphics.root || pass.indirect_graphics.root != pass.graphics_root || pass.indirect_graphics.mesh != mesh) - return refuse("indirect graphics requires a direct list with a matching desktop pipeline and root"); + return refuse("indirect graphics requires a direct list with a matching desktop pipeline and root", + indirect_graphics_pipeline); if (!pass.targets_bound || pass.target_count != 1 || !pass.target0 || pass.target_formats[0] != pass.indirect_graphics.target_format || pass.dsv_format != DXGI_FORMAT_UNKNOWN || !pass.viewport_set || !pass.scissor_set) @@ -2025,7 +2035,7 @@ void __stdcall list_execute_indirect(Wrapper* self, void* signature, UINT count, if (samples.Count != 1 || samples.Quality) return refuse("draw requires a single-sample render target"); } else if (!pass.compute_pipeline || !pass.compute_root) { - return refuse("requires a desktop compute pipeline and root"); + return refuse("requires a desktop compute pipeline and root", indirect_compute_pipeline); } else if (sig->own().signature_root && sig->own().signature_root != pass.compute_root) { return refuse("signature root constants require the bound compute root"); } @@ -2071,6 +2081,7 @@ void __stdcall list_execute_indirect(Wrapper* self, void* signature, UINT count, } require_state(self, resource, argument_state); list->ExecuteIndirect(static_cast(sig->own().real), count, resource, offset, nullptr, 0); + InterlockedIncrement64(&indirect_calls[indirect_forwarded][static_cast(kind)]); } // List slot 34 (desktop 30 + 4), SetGraphicsRootSignature. The title's parameters are tracked for translated // draws either way. A root signature that indexes a descriptor heap directly is not set on the desktop list: the @@ -3645,6 +3656,23 @@ HRESULT __stdcall queue_present(Wrapper* self, UINT planes, const void* plane_pa heap_root_refusals[static_cast(x2w_startup::RealRootDecision::sampler_heap_missing)], heap_root_refusals[static_cast(x2w_startup::RealRootDecision::both_heaps_missing)], heap_root_refusals[static_cast(x2w_startup::RealRootDecision::state_not_restorable)]); + if (render_mode() && frame % 300 == 0) { + // Slot-61 calls since the start, by outcome, then by signature kind (zero kinds left out). + static const char* const outcomes[] = {"forwarded", "refused graphics-pipeline", "compute-pipeline", + "placeholder-signature", "other"}; + static const char* const kinds[] = {"other", "dispatch", "draw", "drawindexed", "dispatchmesh"}; + char line[512]; + int n = std::snprintf(line, sizeof(line), "x2w-render indirect:"); + for (int o = 0; o < indirect_outcomes; ++o) { + n += std::snprintf(line + n, sizeof(line) - n, "%s %s:", o ? ";" : "", outcomes[o]); + const int start = n; + for (int k = 0; k < 5; ++k) + if (const LONG64 calls = indirect_calls[o][k]) + n += std::snprintf(line + n, sizeof(line) - n, " %s %lld", kinds[k], static_cast(calls)); + if (n == start) n += std::snprintf(line + n, sizeof(line) - n, " 0"); + } + log("%s", line); + } if (render_mode() && frame % 300 == 0) { // Which command-list slots the title called in the last 300 frames, per frame. char line[2048]; diff --git a/tests/startup_indirect_draw_indexed.cpp b/tests/startup_indirect_draw_indexed.cpp index 75b6e689e1..cb755c24ad 100644 --- a/tests/startup_indirect_draw_indexed.cpp +++ b/tests/startup_indirect_draw_indexed.cpp @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include extern "C" __declspec(dllimport) HRESULT WINAPI D3D12XboxCreateDevice(IUnknown*, const void*, REFIID, void**); @@ -405,14 +407,53 @@ bool run(ID3D12Device* device, ID3D12Device* guest, ID3D12RootSignature* writer_ std::printf("%s: %u/%u non-clear pixels, argument guards intact\n", label, painted, width * height); return pixels_match; } +// Three calls refused before any argument is read, one per counted reason; the list is closed and dropped. +void refuse_each_reason(ID3D12Device* guest, ID3D12CommandSignature* draw_indexed) +{ + D3D12_INDIRECT_ARGUMENT_DESC dispatch{}; + dispatch.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH; + const D3D12_COMMAND_SIGNATURE_DESC dispatch_desc{sizeof(D3D12_DISPATCH_ARGUMENTS), 1, &dispatch, 0}; + ComPtr dispatch_signature; + check(guest->CreateCommandSignature(&dispatch_desc, nullptr, IID_PPV_ARGS(&dispatch_signature)), "create guest dispatch signature"); + ComPtr allocator; + check(guest->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator)), "create guest allocator"); + const auto list = begin_guest_list(guest, allocator.Get()); + using Execute = void (WINAPI*)(IUnknown*, IUnknown*, UINT, IUnknown*, UINT64, IUnknown*, UINT64); + const auto execute = slot(list.Get(), 61); + execute(list.Get(), nullptr, 1, nullptr, 0, nullptr, 0); // placeholder signature + execute(list.Get(), draw_indexed, 1, nullptr, 0, nullptr, 0); // no desktop graphics pipeline bound + execute(list.Get(), dispatch_signature.Get(), 1, nullptr, 0, nullptr, 0); // no desktop compute pipeline bound + check(slot(list.Get(), 9)(list.Get()), "close refusal list"); +} + +// 300 empty console presents (queue slot 32) reach the render-totals heartbeat; nothing is shown. +std::string indirect_line(ID3D12Device* guest, const std::wstring& log_path) +{ + const D3D12_COMMAND_QUEUE_DESC desc{}; + ComPtr queue; + check(guest->CreateCommandQueue(&desc, __uuidof(ID3D12CommandQueue), reinterpret_cast(queue.GetAddressOf())), + "create guest queue"); + using Present = HRESULT (WINAPI*)(IUnknown*, UINT, const void*, const void*); + const std::array planes{}; + const std::array present{}; + for (int frame = 0; frame < 300; ++frame) slot(queue.Get(), 32)(queue.Get(), 0, planes.data(), present.data()); + std::ifstream file(log_path, std::ios::binary); + std::string line, found; + while (std::getline(file, line)) + if (line.rfind("x2w-render indirect:", 0) == 0) found = line; + while (!found.empty() && (found.back() == '\r' || found.back() == '\n')) found.pop_back(); + return found; +} } // namespace int main(int argc, char** argv) try { DrawKind kind = DrawKind::indexed; + // "count-control" is the negative control: it expects one forwarded call too many. + const bool count_control = argc == 3 && std::strcmp(argv[2], "count-control") == 0; if (argc == 3 && std::strcmp(argv[2], "draw") == 0) kind = DrawKind::vertices; else if (argc == 3 && std::strcmp(argv[2], "mesh") == 0) kind = DrawKind::mesh; - else if (argc != 2) return 2; + else if (argc != 2 && !count_control) return 2; const bool indexed = kind == DrawKind::indexed; const bool mesh = kind == DrawKind::mesh; const bool warp = std::strcmp(argv[1], "warp") == 0; @@ -443,6 +484,12 @@ int main(int argc, char** argv) try (!mesh || supports_mesh(probe.Get()))) break; } } + wchar_t directory[MAX_PATH]; + if (!GetTempPathW(MAX_PATH, directory)) return 4; + const std::wstring log_path = std::wstring(directory) + L"x2w_indirect_counts_" + std::to_wstring(GetCurrentProcessId()) + L".log"; + DeleteFileW(log_path.c_str()); + SetEnvironmentVariableW(L"X2W_TRAP_LOG", log_path.c_str()); + SetEnvironmentVariableA("X2W_PRESENT_SIGNATURE_EVERY", "0"); DXGI_ADAPTER_DESC1 desc{}; check(adapter->GetDesc1(&desc), "get selected adapter description"); std::printf("adapter: %ls, debug layer %s\n", desc.Description, debug ? "enabled" : "unavailable"); @@ -510,6 +557,20 @@ int main(int argc, char** argv) try !verify(left.Get(), false, Refusal::short_argument, "short argument range")) return 1; if (indexed ? !verify(left.Get(), false, Refusal::invalid_index, "invalid index range") : !verify(left.Get(), false, Refusal::missing_viewport, "missing viewport")) return 1; + if (indexed) { + // Forwarded: the three unrefused runs. Other reasons: the short argument range and the invalid index range. + refuse_each_reason(guest.Get(), signature.Get()); + const std::string line = indirect_line(guest.Get(), log_path); + DeleteFileW(log_path.c_str()); + const std::string expected = std::string("x2w-render indirect: forwarded: drawindexed ") + (count_control ? "4" : "3") + + "; refused graphics-pipeline: drawindexed 1; compute-pipeline: dispatch 1; placeholder-signature: other 1; " + "other: drawindexed 2"; + if (line != expected) { + std::fprintf(stderr, "indirect line mismatch:\n got '%s'\n expected '%s'\n", line.c_str(), expected.c_str()); + return 1; + } + std::printf("%s\n", line.c_str()); + } if (info) { for (UINT64 i = 0; i < info->GetNumStoredMessages(); ++i) { SIZE_T bytes = 0; From 6d9eb4ab5b56322151d2337fcb4d755c3ec31eaa Mon Sep 17 00:00:00 2001 From: NiiRoZz Date: Wed, 25 Nov 2026 02:47:45 +0100 Subject: [PATCH 2/3] startup: keep the indirect-count log to the indexed run; pin the control to the counts The draw and mesh variants no longer set X2W_TRAP_LOG, so they leave no log file; the control must report the observed and the wrong forwarded count; the line buffer fits every outcome with 19-digit counts; the docs paragraph follows the totals comparison. Co-Authored-By: Claude Fable 5.2 --- CMakeLists.txt | 3 ++- docs/startup-runtime.md | 6 +++--- src/startup_stubs/d3d12_xs_device.cpp | 2 +- tests/startup_indirect_draw_indexed.cpp | 8 +++++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d48b3412a..675592b202 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -928,7 +928,8 @@ endforeach() set_tests_properties(startup_indirect_draw_indexed_hardware startup_indirect_draw_hardware PROPERTIES SKIP_RETURN_CODE 77) # Negative control for the x2w-render indirect line: one forwarded call too many must be reported as a mismatch. add_test(NAME startup_indirect_counts_control_warp COMMAND startup_indirect_draw_indexed warp count-control) -set_tests_properties(startup_indirect_counts_control_warp PROPERTIES TIMEOUT 30 PASS_REGULAR_EXPRESSION "indirect line mismatch") +set_tests_properties(startup_indirect_counts_control_warp PROPERTIES TIMEOUT 30 + PASS_REGULAR_EXPRESSION "got +'x2w-render indirect: forwarded: drawindexed 3;[^']*'[^e]*expected +'x2w-render indirect: forwarded: drawindexed 4;") # OMSetRenderTargets with a single descriptor range, handles that hold no view, and a cleared copied descriptor. add_executable(startup_rtv_bind tests/startup_rtv_bind.cpp) diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 29025c85c5..2d5df7be0f 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -542,7 +542,9 @@ With `-Render`, `d3d12_xs` prints a running total to `stderr.txt` every 300 fram x2w-render totals: ... translated draws N (not drawn M), pipelines translated P / missing Q, ... ``` -Next to it, one line counts every `ExecuteIndirect` call (command-list slot 61) since the start, forwarded or by refusal reason, then by signature kind (`draw`, `drawindexed`, `dispatch`, `dispatchmesh`, or `other` for a placeholder or unknown signature); a reason with no calls reads `0`: +Compare the last line of each run. More translated draws and fewer "not drawn" mean a translator change reached real draws. "missing" is a live count of pipelines still waiting for a manifest. It can grow while things improve, if the run gets further and requests new pipelines. + +Beside the totals line, one line counts every `ExecuteIndirect` call (command-list slot 61) since the start, forwarded or by refusal reason, then by signature kind (`draw`, `drawindexed`, `dispatch`, `dispatchmesh`, or `other` for a placeholder or unknown signature); a reason with no calls reads `0`: ``` x2w-render indirect: forwarded: drawindexed 3; refused graphics-pipeline: drawindexed 1; compute-pipeline: dispatch 1; placeholder-signature: other 1; other: drawindexed 2 @@ -550,8 +552,6 @@ x2w-render indirect: forwarded: drawindexed 3; refused graphics-pipeline: drawin `graphics-pipeline` is a draw without a matching desktop pipeline and root, `compute-pipeline` a dispatch without a desktop compute pipeline and root, and `other` every remaining refusal. The `x2w-render ExecuteIndirect refused` lines still stop after 16. `startup_indirect_draw_indexed_warp` checks this line; `startup_indirect_counts_control_warp` expects one forwarded call too many and must report the mismatch. -Compare the last line of each run. More translated draws and fewer "not drawn" mean a translator change reached real draws. "missing" is a live count of pipelines still waiting for a manifest. It can grow while things improve, if the run gets further and requests new pipelines. - ### 4. Census, then rank The first refusal hides the rest. Run the [refusal census](experiments.md#startup-translator-refusal-census) on a copy of the cache: diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index fc3130edac..8a0f9b30c5 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -3661,7 +3661,7 @@ HRESULT __stdcall queue_present(Wrapper* self, UINT planes, const void* plane_pa static const char* const outcomes[] = {"forwarded", "refused graphics-pipeline", "compute-pipeline", "placeholder-signature", "other"}; static const char* const kinds[] = {"other", "dispatch", "draw", "drawindexed", "dispatchmesh"}; - char line[512]; + char line[1024]; // fits every outcome with five 19-digit counts int n = std::snprintf(line, sizeof(line), "x2w-render indirect:"); for (int o = 0; o < indirect_outcomes; ++o) { n += std::snprintf(line + n, sizeof(line) - n, "%s %s:", o ? ";" : "", outcomes[o]); diff --git a/tests/startup_indirect_draw_indexed.cpp b/tests/startup_indirect_draw_indexed.cpp index cb755c24ad..f8074ef2d1 100644 --- a/tests/startup_indirect_draw_indexed.cpp +++ b/tests/startup_indirect_draw_indexed.cpp @@ -487,9 +487,11 @@ int main(int argc, char** argv) try wchar_t directory[MAX_PATH]; if (!GetTempPathW(MAX_PATH, directory)) return 4; const std::wstring log_path = std::wstring(directory) + L"x2w_indirect_counts_" + std::to_wstring(GetCurrentProcessId()) + L".log"; - DeleteFileW(log_path.c_str()); - SetEnvironmentVariableW(L"X2W_TRAP_LOG", log_path.c_str()); - SetEnvironmentVariableA("X2W_PRESENT_SIGNATURE_EVERY", "0"); + if (indexed) { + DeleteFileW(log_path.c_str()); + SetEnvironmentVariableW(L"X2W_TRAP_LOG", log_path.c_str()); + SetEnvironmentVariableA("X2W_PRESENT_SIGNATURE_EVERY", "0"); + } DXGI_ADAPTER_DESC1 desc{}; check(adapter->GetDesc1(&desc), "get selected adapter description"); std::printf("adapter: %ls, debug layer %s\n", desc.Description, debug ? "enabled" : "unavailable"); From 6c815078d32c36a5438f03820c3afb87a8cf4f8c Mon Sep 17 00:00:00 2001 From: NiiRoZz Date: Wed, 25 Nov 2026 03:46:25 +0100 Subject: [PATCH 3/3] startup: make the indirect-count control fail-proof; count early refusals under the signature kind The control's pattern held a semicolon, so CMake split it into a list and the expected-string half always matched. It now holds no semicolon and requires the mismatch report's observed line with the real counts. The signature kind is read before the first refusal, so a two-command call is counted as other under its kind; the fixture now sends one. Co-Authored-By: Claude Fable 5.2 --- CMakeLists.txt | 3 ++- docs/startup-runtime.md | 4 ++-- src/startup_stubs/d3d12_xs_device.cpp | 6 +++--- tests/startup_indirect_draw_indexed.cpp | 8 +++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 675592b202..3d977743b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -928,8 +928,9 @@ endforeach() set_tests_properties(startup_indirect_draw_indexed_hardware startup_indirect_draw_hardware PROPERTIES SKIP_RETURN_CODE 77) # Negative control for the x2w-render indirect line: one forwarded call too many must be reported as a mismatch. add_test(NAME startup_indirect_counts_control_warp COMMAND startup_indirect_draw_indexed warp count-control) +# "got" is printed only for a mismatch, and the pattern holds the real counts. No semicolons: CMake would split it. set_tests_properties(startup_indirect_counts_control_warp PROPERTIES TIMEOUT 30 - PASS_REGULAR_EXPRESSION "got +'x2w-render indirect: forwarded: drawindexed 3;[^']*'[^e]*expected +'x2w-render indirect: forwarded: drawindexed 4;") + PASS_REGULAR_EXPRESSION "got +'x2w-render indirect: forwarded: drawindexed 3. refused graphics-pipeline: drawindexed 1. compute-pipeline: dispatch 1. placeholder-signature: other 1. other: drawindexed 3'") # OMSetRenderTargets with a single descriptor range, handles that hold no view, and a cleared copied descriptor. add_executable(startup_rtv_bind tests/startup_rtv_bind.cpp) diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 2d5df7be0f..7a9da90346 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -547,10 +547,10 @@ Compare the last line of each run. More translated draws and fewer "not drawn" m Beside the totals line, one line counts every `ExecuteIndirect` call (command-list slot 61) since the start, forwarded or by refusal reason, then by signature kind (`draw`, `drawindexed`, `dispatch`, `dispatchmesh`, or `other` for a placeholder or unknown signature); a reason with no calls reads `0`: ``` -x2w-render indirect: forwarded: drawindexed 3; refused graphics-pipeline: drawindexed 1; compute-pipeline: dispatch 1; placeholder-signature: other 1; other: drawindexed 2 +x2w-render indirect: forwarded: drawindexed 3; refused graphics-pipeline: drawindexed 1; compute-pipeline: dispatch 1; placeholder-signature: other 1; other: drawindexed 3 ``` -`graphics-pipeline` is a draw without a matching desktop pipeline and root, `compute-pipeline` a dispatch without a desktop compute pipeline and root, and `other` every remaining refusal. The `x2w-render ExecuteIndirect refused` lines still stop after 16. `startup_indirect_draw_indexed_warp` checks this line; `startup_indirect_counts_control_warp` expects one forwarded call too many and must report the mismatch. +`graphics-pipeline` is a draw without a matching desktop pipeline and root, `compute-pipeline` a dispatch without a desktop compute pipeline and root, and `other` every remaining refusal, counted under the signature's kind whenever the signature is known. The `x2w-render ExecuteIndirect refused` lines still stop after 16. `startup_indirect_draw_indexed_warp` checks this line; `startup_indirect_counts_control_warp` expects one forwarded call too many and must report the mismatch. ### 4. Census, then rank diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index 8a0f9b30c5..794acda455 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -1992,7 +1992,9 @@ volatile LONG64 indirect_calls[indirect_outcomes][5]; void __stdcall list_execute_indirect(Wrapper* self, void* signature, UINT count, void* argument, u64 offset, void* count_buffer, u64 count_offset) { - IndirectCommand kind = IndirectCommand::none; + // Every refusal is counted under the signature's kind, including those before the signature is checked. + Wrapper* sig = as_wrapper(signature); + IndirectCommand kind = sig && sig->own().kind == command_signature_kind ? sig->own().indirect_command : IndirectCommand::none; const auto refuse = [&kind](const char* reason, int outcome = indirect_other) { InterlockedIncrement64(&indirect_calls[outcome][static_cast(kind)]); static LONG refusals; @@ -2004,14 +2006,12 @@ void __stdcall list_execute_indirect(Wrapper* self, void* signature, UINT count, if (type != D3D12_COMMAND_LIST_TYPE_DIRECT && type != D3D12_COMMAND_LIST_TYPE_COMPUTE) return refuse("requires a direct or compute command list"); if (count != 1 || count_buffer || count_offset) return refuse("requires one command and no count buffer"); - Wrapper* sig = as_wrapper(signature); if (!sig || sig->own().kind != command_signature_kind || !sig->own().real) return refuse("missing or placeholder signature", indirect_placeholder); const Wrapper* device = self->own().list_device; if (!device || sig->own().signature_device != device) return refuse("requires a supported signature from this device"); const auto command = sig->own().indirect_command; - kind = command; const bool indexed = command == IndirectCommand::draw_indexed; const bool mesh = command == IndirectCommand::dispatch_mesh; const bool graphics = indexed || mesh || command == IndirectCommand::draw; diff --git a/tests/startup_indirect_draw_indexed.cpp b/tests/startup_indirect_draw_indexed.cpp index f8074ef2d1..24a1a8d038 100644 --- a/tests/startup_indirect_draw_indexed.cpp +++ b/tests/startup_indirect_draw_indexed.cpp @@ -407,7 +407,8 @@ bool run(ID3D12Device* device, ID3D12Device* guest, ID3D12RootSignature* writer_ std::printf("%s: %u/%u non-clear pixels, argument guards intact\n", label, painted, width * height); return pixels_match; } -// Three calls refused before any argument is read, one per counted reason; the list is closed and dropped. +// Calls refused before any argument is read: one per counted reason, and one with two commands, which is +// counted as other under its signature's kind. The list is closed and dropped. void refuse_each_reason(ID3D12Device* guest, ID3D12CommandSignature* draw_indexed) { D3D12_INDIRECT_ARGUMENT_DESC dispatch{}; @@ -423,6 +424,7 @@ void refuse_each_reason(ID3D12Device* guest, ID3D12CommandSignature* draw_indexe execute(list.Get(), nullptr, 1, nullptr, 0, nullptr, 0); // placeholder signature execute(list.Get(), draw_indexed, 1, nullptr, 0, nullptr, 0); // no desktop graphics pipeline bound execute(list.Get(), dispatch_signature.Get(), 1, nullptr, 0, nullptr, 0); // no desktop compute pipeline bound + execute(list.Get(), draw_indexed, 2, nullptr, 0, nullptr, 0); // two commands check(slot(list.Get(), 9)(list.Get()), "close refusal list"); } @@ -560,13 +562,13 @@ int main(int argc, char** argv) try if (indexed ? !verify(left.Get(), false, Refusal::invalid_index, "invalid index range") : !verify(left.Get(), false, Refusal::missing_viewport, "missing viewport")) return 1; if (indexed) { - // Forwarded: the three unrefused runs. Other reasons: the short argument range and the invalid index range. + // Forwarded: the three unrefused runs. Other reasons: the short argument range, the invalid index range and two commands. refuse_each_reason(guest.Get(), signature.Get()); const std::string line = indirect_line(guest.Get(), log_path); DeleteFileW(log_path.c_str()); const std::string expected = std::string("x2w-render indirect: forwarded: drawindexed ") + (count_control ? "4" : "3") + "; refused graphics-pipeline: drawindexed 1; compute-pipeline: dispatch 1; placeholder-signature: other 1; " - "other: drawindexed 2"; + "other: drawindexed 3"; if (line != expected) { std::fprintf(stderr, "indirect line mismatch:\n got '%s'\n expected '%s'\n", line.c_str(), expected.c_str()); return 1;