Repository navigation
Conversation
kacper-serewis
left a comment
There was a problem hiding this comment.
D3D-391 at f506039. Restore the target array size guard in prepare_draw (vulkan_replay.h:1893). A direct replay caller can supply a count and pipeline format list both larger than eight. Update command_list.h:407 to describe the shared snapshot allocation on the first draw after invalidation. MSVC x64 CPU checks passed for copy/move recording, snapshot replacement and release on reset. Command measured 296 bytes. COM invalidation and Vulkan preparation were inspected in source. AI-assisted.
|
Review note about memory allocation. An AI tool helped me to read the diff. I did not build or measure the change. Result of the check The stale flag is correct. Three functions change Possible problem Many titles call
The shared block helps only when a sequence of draws uses the same buffers. Suggestions
Test Add a counter to the test. Count the draws and count the view blocks. Call |
slopradish
left a comment
There was a problem hiding this comment.
Reviewed the CPU path against our fork's ported Draw/command variant.
The core change is correct: moving the two fixed arrays behind a shared_ptr drops the variant floor from 984 to 296 bytes, and the block is rebuilt on exactly the three state changes that can alter it (OMSetRenderTargets, set_vertex_buffers with count>0, reset_state). The if (count) guard on vertex-buffer invalidation is right — count=0 changes no slot, and an explicit unbind arrives as a view with a null BufferLocation, which does invalidate.
One note on the write-up: the 3890 -> 3824 us frame number is explicitly measured on a mix with no draws, so it is noise. The result worth citing is the 984 -> 296 byte command size, which is measured directly. The per-draw allocation cost remains unmeasured as you note — worth a follow-up once the draw path joins the bench.
CPU-only review; no GPU run from me.
|
Follow-up to my approve: @kacper-serewis is right about the missing array bound in |
kacper-serewis
left a comment
There was a problem hiding this comment.
D3D-391 draw-containing CPU comparison. Median ns/draw (parent f847748 / #3693 f506039 / #3784 2fa5423): sparse unchanged 320/114/121; sparse changing 335/319/123; dense unchanged 330/106/316; dense changing 307/327/294. Nine interleaved rounds, 16,384 draws per fresh list, Windows x64 Clang 22.1.8 -O2. All recorded bindings and draw order verified after each sample. Production CommandList::draw timed including storage growth; harness modeled COM state/cache invalidation, excluding COM entry, destruction and replay. Shared machine, small differences inconclusive. Dense repeated bindings favored shared snapshots and sparse changing bindings favored list-owned storage. AI-assisted.
|
Both review points are in at bd5e274. kacper-serewis, slopradish: the target loop keeps slot < draw.views->render_targets.size() next to the count and colour-format bounds, and the DrawViews comment now states that the block is allocated on the first draw after a state change and shared by the draws after it. shdann: the per-draw rebind case is now handled where it starts. set_vertex_buffers and OMSetRenderTargets compare the incoming values against the ones bound before they invalidate, so calling IASetVertexBuffers with the buffers already bound does not start a new block. A title that sets one mesh per draw therefore allocates no view blocks in steady state, rather than one per draw. I kept the refcounted block instead of taking the storage from the command list because of execute_bundle: a block stays valid when a Draw is copied into the parent list, while an index into the source list's vectors needs rebasing there. #3784 takes the list-owned route and rebases explicitly, and in kacper's comparison the two land about even. Checks after the change: replay_cpu_bench, d3d12_com_test and command_list_test build with MSVC 14.52; replay_cpu_bench --self-test passes; Command is still 296 bytes. d3d12_com_test is still not run here, since the GPU is busy with other work. |
|
Tested bd5e274 merged onto current main aa2988c on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: does not build against current main (
AI-assisted (Claude). |
bd5e274 to
3c3749d
Compare
|
Rebased onto
Your probe's numbers reproduce here. Same machine,
So a title that rebinds its buffers per draw pays about 200 ns and one allocation per draw, and the frame as a whole moves about 1%. I won't hide that: the block is a On this head, MSVC 14.52 (VS 18 BuildTools) and Vulkan SDK 1.4.363.1: the whole runtime builds clean, 451 targets, no warnings beyond the pre-existing |
|
A correction to the frame number in my reply above: that one was a single run. Alternating the two binaries six times on this machine gives frame 14791 / 17093 / 14961 us on The body now carries those ranges and the trade in full. The list-owned storage in #3784 removes the per-draw allocation if the maintainers would rather the record path stayed allocation-free for a rebinding draw; I would rather see this closed in #3784's favour than argue the row back to where it was on main. |
|
Tested 3c3749d on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran AI-assisted. |
|
Tested |
- replay_cpu_bench: #3693 moved a draw's render targets and vertex buffers into Draw::views (D3D-391); the bench builds a DrawViews block instead of writing the old inline arrays. - xgameruntime_user_test links file_system.cpp, which now defines rt::fs::game_dir that xgameruntime.cpp calls. - check_sparse_queue_family: a vkCreateInstance refused because the api_dump/validation layer is not installed is the documented "layer absent" skip (77), not a failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d (D3D-391) prepare_draw lost the bound on the target array when the count moved behind the views block. A direct replay caller can pass a count and a colour-format list both above eight, so the loop needs all three bounds. Rebinding the values already bound no longer invalidates the block. A title that sets one mesh per draw through IASetVertexBuffers would otherwise allocate a block per draw, which is the case the shared snapshot was meant to avoid.
3c3749d to
9c70d7b
Compare
|
@kacper-serewis both points are in on the rebased head
On the rebase itself: the @Vonsek @Exopus-0x65f7ad0 the head changed to Local on this machine: |
D3D-391, claimed in the coordination issue (#4816).
Rebased onto
mainat98fa503f8, head9c70d7b40. TheDrawViewsmove this PR opened with has since landed onmainthrough2ce837826, so the rebase dropped it and this branch now carries only the parts that were still missing upstream: the review points from @kacper-serewis, @slopradish and @shdann. Mergeable, no conflicts.What is in the branch
prepare_drawnow testsslot < draw.views->render_targets.size()beside the count and the pipeline's colour-format count. Checkingslot < p.colors.size()alone is not enough: a direct replay caller can supply a count and a format list both larger than the eight slotsDrawViewsholds, andmainstill readsdraw.views->render_targets[slot]with only those two bounds. (@kacper-serewis, @slopradish)DrawViewscomment says what owns the block. It now states that the shim allocates one block on the first draw after the render targets or the bound vertex buffers change, that the draws after it share it, and that a call which rebinds the values already bound does not start a new one. (@kacper-serewis)OMSetRenderTargetsandset_vertex_bufferscompare the incoming views against the bound ones and only setdraw_views_stale_when something differs, which is the case @shdann raised: a title that sets the same buffers before every draw would otherwise build and allocate a block per draw.Cost
The block is 984 bytes by value in the command variant and 296 bytes out of line — measured, not estimated. With the no-op rebind check the steady case for a title that re-sets the same state allocates nothing. Where a title really does change its views per draw, the cost is one block (one
make_shared, ~200 ns) and one copy of the 8 targets + 32 vertex-buffer slots per draw; on the bench frame, which records 16,384 draws that each change state, that shows as the frame taking 1–4 ms more thanmain's. #3784 removes that allocation if the maintainers prefer list-owned storage. The bench numbers in the earlier comments here were measured atf506039c9, before the rebase.Tested
Windows 11 26200, MSVC (VS BuildTools), Python not involved; no GPU is named because everything below is CPU-only, and no game files are used.
scripts/build_runtime.ps1 -jobs 4gta6rt.exebuilt, no errorsctest -R d3d12_comd3d12_com,d3d12_compute)ctest -R 'vk_command_replay|d3d12_trace|d3d12_com'd3d12_comis the test that walks the shim's recording path this PR touches;vk_command_replayexercisesprepare_drawwith the bound added in point 1. The GPU results earlier in this thread (@Vonsek on RDNA2 iGPU and RTX 5080, @Exopus-0x65f7ad0 on RTX 5060 Ti) were on3c3749d0and earlier, so a re-check on9c70d7b40is welcome.Depends on: nothing.