vulkan_replay: a clamped mesh draw's statistics segment is a mesh segment; a batch reads only its own lists (RT-REPLAY-STATISTICS-MESH-SEGMENTS) #2530
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2530"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-28T00:48:44Z.
Claimed in the coordination issue as: RT-REPLAY-STATISTICS-MESH-SEGMENTS (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231080379)
What and why
Item 2 of @kevincommits' finding in #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7230685285). Thanks for the analysis.
Overlapping statistics queries and a clamped indirect mesh draw (
plan_overlapping_statistics_segments,runtime/src/vulkan_replay.h). A clamped indirect call opens a segment of its own, because the clamp is a helper dispatch. The planner then hardcodedif (draw_command(commands[i]).state) kind = 0;andcontinued, so the new segment was always a vertex segment, even for an indirect mesh draw (everyIndirectMeshDrawis clamped). That draw then ranvkCmdDrawMeshTasksIndirect[Count]EXTinside the full 11-counter pool (VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076) with no mesh-primitives query. A mesh draw after it also split the segment again, since the kinds differed. The one-query-at-a-time planner (plan_statistics_segments) already marked the same draw mesh.Change: the clamped call falls through to the draw-kind rule every draw uses, as
has_helper_dispatchalready does. The segment it opened has no kind yet, so a draw sets it (vertex or mesh) and a dispatch leaves it unset.A smaller batch read the stale tail of a larger one (
VulkanQueue::execute,runtime/src/vulkan_backend.h).prepared_keeps the PreparedLists of the largest batch so their storage is reused, and the comment there says only the firstlists.size()entries are read. But the segment kinds for the statistics pool were gathered withfor (const auto& list : prepared). After a batch whose later lists had a mesh segment, a smaller batch with statistics queries could find that stale1. It then createdmesh_poolandprimitives_poolit did not need, or failed asqueue_unsupportedon a device without them.Change: the gather is
batch_statistics_meshinvulkan_replay.h, andexecutepasses it onlystd::span(prepared).first(lists.size()).Overlap: none found among open PRs touching
vulkan_replay.horvulkan_backend.h(#2491, #2489, #2486, #2485, #2469, #2402, #2365 change other functions). Items 1 and 3 of the same finding are #2526 and #2523.Tested
Windows 11, MSVC (VS 18), RelWithDebInfo, on
main431ceba4f. CPU tests, plus the existingd3d12_meshGPU test.replay_query_predication_testgains case 16b, following the repro:plan_statistics_segments): mesh too;batch_statistics_meshover the first list of two leaves the second list's mesh segment out; over both it keeps list order.ctest -R "^(replay_query_predication|replay_query_edges|indirect_topology_and_stats|d3d12_mesh)$": 4/4 pass.gta6rt_d3d12_com(which includesvulkan_backend.h) builds.scripts/check_no_game_data.py: clean.Not tested: the
executepath itself on a device with a multi-list batch followed by a smaller one. The helper it now calls is tested, but not the queue around it. Also no game boot.GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T01:34:03Z.
Reviewed at head
202786b51on Windows 11 (MSVC 202219.44).Verification
replay_query_predication_testandgta6rt.replay_query_predication_test: passed (query resolves suspend conditional rendering around fills, copies and dispatches).Notes
vulkan_replay.h:3313-3354).vulkan_backend.h(3456-3466,3533-3547,3568-3575) all consistently restrict to the active list prefix.replay_query_predication_test.cpp:783-835slices the input before calling the helper directly; adding a queue-level test running a 2-list batch followed by a 1-list batch would also guard the production slice atvulkan_backend.h.Approve.
AI-assisted review + local MSVC verification.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T07:05:26Z.
#2530 | head
202786b51e(merged cleanly with main09c1539483) |ctest --test-dir runtime/build -C RelWithDebInfo -R "^(replay_query_predication|replay_query_edges|vk_overlapping_occlusion|vk_overlapping_occlusion_no_statistics|vulkan_mesh_limits)$" --output-on-failure(LEONIDA_VK_VALIDATION=1) | red on main:replay_query_predication_test.cppfails to compile (C3861:batch_statistics_meshmissing; onmain,plan_overlapping_statistics_segmentsforcedkind = 0on clamped indirect mesh draws andVulkanQueue::executereadpreparedpastlists.size()) | green on PR+main:5/5CTests pass (replay_query_predicationin0.07s,replay_query_edgesin0.10s,vk_overlapping_occlusionin0.40s,vk_overlapping_occlusion_no_statisticsin0.33s, andvulkan_mesh_limitsin0.03s) on RTX 3090 withLEONIDA_VK_VALIDATION=1(0Khronos validation errors);check_no_game_data.py0violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yesImported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T08:51:52Z.
Review: APPROVED
Reviewed the diff and tested merged onto
main(493867366) with Ninja Release (MSVC).Clamping the indirect mesh draw segment in
vulkan_replay.hand wiringbatch_statistics_meshinvulkan_backend.hlook clean, and the new cases inreplay_query_predication_test.cppdirectly cover the changed paths.Tests run
ctest --output-on-failure -R "^replay_query_predication$": 1/1 passed (replay_query_predication0.03 s).AI-assisted (Antigravity, Gemini).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T01:07:26Z.
Review: COMMENTED
Static audit of
202786b51against48bae6cad. The clamp split now selects the mesh pool, and pool selection uses the active list range.One issue already on the base at
runtime/src/vulkan_replay.h:5359(head line 5367). With the general clamp disabled, a counted dispatch whose pipeline is skipped can still schedule a statistics split during preparation. Emission jumps past both endpoints, so the next query boundary ends an inactive slot and can begin a second statistics query while the old one is active. Checking the pipeline before preparing the counted helper would avoid the split. A mock replay test can catch this with two overlapping queries around a dropped counted dispatch.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T04:33:11Z.
Tested
202786b51merged (no commit) withmainc8bf0e7b6. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300; MSVC 19.52 (Visual Studio 18), Ninja, RelWithDebInfo.check_no_game_data.pyis clean.replay_query_predicationpasses.runtime/src/vulkan_replay.handvulkan_backend.hback tomain, the test does not compile:batch_statistics_meshdoes not exist onmain(replay_query_predication_test.cpp(832),C3861). I did not run a separate runtime mutation (putting the old clamp line back behind the new helper); another tester's red/green covers it.xbox_presentfails, as on plainmainhere.gta6rt.exelinked withoutws2_32.libgivesmain's 26 unresolved Rust-std symbols, nothing new. Its imports are identical tomain's.vulkan_backend.hpart of the change is not covered by it. A queue-level case (a 2-list batch, then 1 list) was suggested in review.vulkan_replay.h.No blocker from my side. AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T08:19:47Z.
Merged after TheGeogeo's red/green check (check: green with this PR merged onto
main, red without it;gta6rt.exestill links) and a re-check here: no conflict withmaineb4773b34, same head as checked, not frozen,no-game-datagreen.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.