Repository navigation
runtime: support dynamic topologies in indirect draws and report per-reason skip counts (RT-INDIRECT-TOPOLOGIES-AND-STATS) - #1896
Conversation
…reason skip counts (RT-INDIRECT-TOPOLOGIES-AND-STATS)
madvillain91
left a comment
There was a problem hiding this comment.
Reviewed diff and independently verified commit 79a76a75c on native Windows 11 + MSVC + NVIDIA Ampere GPU (filling in the Windows/MSVC/GPU verification noted as untested in the PR description, against main 71a769d7d):
Environment
- OS: Windows 11 26H2 (build 26300.9711)
- Compiler: VS 2022 Build Tools (MSVC
19.44.35230.0, Ninja,RelWithDebInfo) - Vulkan SDK:
1.4.363.0 - GPU: NVIDIA GeForce RTX 3070 Ti (Ampere, 8192 MiB), driver
617.14, Vulkan1.4.351
Checks run
git diff --check: clean- Clean isolated MSVC 19.44 build of all 7 targets: 0 errors
indirect_topology_and_stats_test: PASS (verified all 10 supported topologies,RECTLISTfallback/safe skip, and per-reason breakdown[mesh=500, topology=11, divisor=500])d3d12_state_map_test: PASS (verified new per-reason summary line[topology=1, first_instance=1, entry=1, robust_index=1, count_limit=1, multi_draw=1, count_feature=1, raw_count_limit=1, argument_usage=1, count_usage=1, divisor=1, index_view=1, stateless=4])replay_pipeline_compiles_test: PASSd3d12_execute_indirect_validation_test(LEONIDA_VK_VALIDATION=1): PASS, 0 validation errors (51 parity cases (WARP=live, HW=NVIDIA GeForce RTX 3070 Ti), positive GPU dispatch ok, 0 failures,[pipeline=10])d3d12_indirect_zero_test(LEONIDA_VK_VALIDATION=1): PASS, 0 validation errors (matched WARP and native RTX 3070 Ti)d3d12_indirect_rt_test(LEONIDA_VK_VALIDATION=1): PASS, 0 validation errorsvk_command_replay_test(LEONIDA_VK_VALIDATION=1): PASS, 0 validation errors (cases A–L)
Diff notes
topology_supported()cleanly matches the dynamic topologies supported bydetail::vulkan_topology()plus consoleRECTLIST(17), while keepingUNDEFINED,QUADLIST, and patch lists skipped.- Routing
indirect_rect_variantaway fromvk.compilesinto synchronouspipeline->variant(unbound)ensures an unexpandable synchronous pipeline cleanly records areplay_skip(topology) instead of failing the whole command list withunsupported, while preservingunsupportedfor direct draws. Counts::report()preserves the existing log prefix, bounds-checkssnprintfwrites, and incrementsby_reason[reason]beforenote(event)so power-of-2 reports include the triggering skip.
Not checked
- Retail world-frame boot profiling or a GPU execution test specifically issuing non-
TRIANGLELISTindirect draws end-to-end throughExecuteIndirect.
LGTM from this Windows 11 + MSVC + NVIDIA RTX 3070 Ti verification (AI-assisted verification; synthetic test fixtures only, no game data).
|
Retail result in the world phase (RTX 5080, NVIDIA 621.24, Windows 11; merged onto #1592, #424/#429 and the rest of the tree of 7167396852,
So the tiled deferred lighting was never drawn without it: the G-buffer held a textured scene while the HDR buffer had only sky and emissive lights. No device loss in the run with it (26 minutes). Two notes, neither against this pull request:
|
|
Independent RX 6700 XT readback report for
I adapted only the geometry, arguments and pixel-rendering topology in On the parent, a direct single draw filled the expected 576 red pixels; the indirect draw emitted nothing and missed all 576. The two-record case missed 1,152 pixels. The parent fixtures stop on their first failed non-indexed comparison, before testing the indexed case. On the PR, all 18 indirect image comparisons per run matched both the direct rendering and the expected colors at every pixel. This includes DRAW and DRAW_INDEXED, single and multi-record draws, and GPU count-buffer inputs 0/1/2/3 with maxCount=2. The PR's Fedora 45, RX 6700 XT (NAVI22), Mesa RADV 26.2.7, Wine Staging 11.21, clang-cl/LLD 23.1.5, RelWithDebInfo. Synthetic triangle-strip coverage only; mesh dispatch, other topologies, retail world geometry and FPS were outside this run. AI-assisted (Codex). Coordination claim. |
|
Merged, thanks! Tested
AI-assisted (Claude Code, Claude Opus 5.5). |
Item ID:
RT-INDIRECT-TOPOLOGIES-AND-STATS(claimed in #1608).Context
In retail world-frame runs on RTX 5080 (#1608,
@DadaCap), 93% of indirect graphics calls were skipped at recording (recorded=4096 emitted=3918 record_skips=53405) with the only logged skip reasons beingmesh indirectandtopology, while[rt] indirect graphics:only printed aggregate totals without breaking down counts by reason.Both
d3d12_com.cpp(record_indirect) andvulkan_replay.h(prepare_draw) previously gated stateful indirect draws toD3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST(4) only, even though graphics pipelines already enableVK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGYandVK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE,emit_commands()already sets dynamic topology and strip primitive restart before emittingvkCmdDraw*Indirect*, andprepare_draw()already selects theGraphicsPipeline::rectangle_stagegeometry-shader variant for consoleRECTLIST(17).Changes
Shared indirect topology predicate (
runtime/src/indirect_draw_stats.h,runtime/shims/d3d12_com.cpp,runtime/src/vulkan_replay.h):leonida::indirect_stats::topology_supported(uint32_t)allowing allD3D_PRIMITIVE_TOPOLOGYvalues thatdetail::vulkan_topology()maps directly without CPU vertex/index-count expansion:POINTLIST(1),LINELIST(2),LINESTRIP(3),TRIANGLELIST(4),TRIANGLESTRIP(5),*_ADJ(10..13), and consoleRECTLIST(17).UNDEFINED(0),QUADLIST(19, requires CPUcount/4expansion), and patch lists (33..64) remain skipped withindirect_stats::topology.RECTLISTdraw targets a synchronous (!async_build) pipeline that cannot build arectangle_stagevariant (e.g., already has a GS, nogeometryShader, or unsupported VS outputs),prepare_draw()skips the indirect draw cleanly withindirect_stats::topologyinstead of failing the whole command list withReplayResult::unsupported(direct draws retainunsupported).record_indirect's viewport check inruntime/shims/d3d12_com.cppwithrecord_draw'sany_nonempty_viewport()so multi-viewport draws with an empty slot 0 and non-empty slot >0 are not dropped.Per-reason skip counters (
runtime/src/indirect_draw_stats.h):Counts::by_reason[reason_count], incremented beforenote(event)so power-of-2 reports include the triggering skip.Counts::report()preserves the exact[rt] indirect graphics: recorded=... emitted=... record_skips=... replay_skips=...prefix and appends a single-line[reason=count, ...]breakdown when any skip reason is non-zero.Portable unit tests (
runtime/test/indirect_topology_and_stats_test.cpp,runtime/CMakeLists.txt):topology_supported()across0..100, fullprepare+emitreplay across all 10 supported topologies (indexed/non-indexed, fixed/counted, allstrip_cut/ index-format combinations),RECTLISTbuilt-in GS vsrectangle_stagevariant vs unexpandable safe skip (with and withoutvk.compiles), direct-drawunsupportedpreservation, unsupported topology skips,Counts::report()formatting, and concurrentskip()accounting.Verification
indirect_topology_and_stats_test.cpp(Clang 20, C++20,-Wall -Wextra -Werror):skip()race check)-O2× 3: PASSruntime/test/d3d12_state_map_test.cpp: PASS (includingtopology_quad_listskip assertion)runtime/test/replay_pipeline_compiles_test.cpp: PASSmain:TRIANGLESTRIPindirect draw fails onmain(emitted=0) and passes on this branch (emitted=1).python3 -I scripts/check_no_game_data.pyon all 5 touched files andpython3 -I tests/test_text_write_line_endings.pypassed.