Repository navigation
OLD-10061: the index buffer view's size bounds the index fetch in the Vulkan replay (carries #326) - #1123
OLD-10061: the index buffer view's size bounds the index fetch in the Vulkan replay (carries #326)#1123TimIdle wants to merge 9 commits into
Conversation
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Reviewed and verified. Crucial fix for index buffer out-of-bounds fetches in D3D12 Vulkan replay (OLD-10061). Correctly bounds index fetches to IndexBufferView size: in-view fetches bind normally, fully out-of-view/null binds the zero page, and boundary crossings copy valid indices with trailing zeros into a scratch buffer with VK_BUFFER_USAGE_INDEX_BUFFER_BIT. Verified on Windows 11 with MSVC/RTX 2050 in d3d12_draw_test and replay_index_view_test. 100% clean-room.
|
Tested
AI-assisted: yes |
|
Thank you for the Wine run on the RTX 3060 Ti. With the native Windows run in the description, both test files now pass on two hosts. |
|
Recommendation: [MERGE] Reasoning: Carries #326: the Vulkan replay bounds index fetches by the D3D12 index buffer view (out-of-view reads return 0 via the zero page) instead of reading past the view. Fixes wrong-pixel rendering; adds a dedicated test plus Impact level: 5/10 |
…ide the view are 0
…from a staged copy
… proxy reference check
…draw without a GPU
…ndex table main now puts a 256 KiB table of quad-list indices (kQuadIndexCount 32-bit indices) right after the 64 KiB zero page, so the first committed buffer of the null index view check starts at 320 KiB, not 64 KiB. Only the expected address changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aged index copy main's prepare_quad_indices already reads only the index view and zero-fills the rest, from p.index_buffer, p.index_size and draw.first. A staged copy would rebase the indices to 0 under it. replay_index_view_test covers a quad list that straddles the view and one with no index buffer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…follows main's quad index table main gives ScratchBuffers an extra_usage set by its creator and vulkan_scratch_test checks that a chunk carries only what was asked. The staged index copy now asks for INDEX_BUFFER there, on every GPU, instead of in vulkan_scratch.h. The first arena allocation follows the 64 KiB zero page and main's quad index table of 16 Ki quads of 6 indices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0ab9467 to
b403c27
Compare
|
Rebased onto |
|
Closing this one, no review yet and CI is red. Will reopen if it is still needed. |
Claimed in the coordination issue as: OLD-10061 (claim)
What and why
This carries forward
old-pr/10061by @tedin7 (draft #326). The six commits are rebased ontomainwith tedin7 kept as author. Three commits of mine follow. One moves the arena address the draw test expects, sincemainnow puts the quad index table after the zero page. One leaves indexed quad lists tomain's expansion pass. One asks for the index-buffer use throughmain's new scratchextra_usageinstead of invulkan_scratch.h.In D3D12, an index fetch outside the index buffer view reads 0.
vkCmdBindIndexBufferbinds to the end of the buffer instead, so the replay read real index data past the view and lit the wrong pixels.vkCmdBeginRendering. The device asks its scratch buffers forVK_BUFFER_USAGE_INDEX_BUFFER_BITfor this, on every GPU.main's expansion pass (prepare_quad_indices), which already reads only the view and zero-fills the rest. An index buffer found throughtitle_memoryis bounded the same way as one found throughbuffer_at.@Sigtryggur-Mani-Gudmundsson checked the series on Linux (RTX 4070 Ti, synchronization validation) in #326 and noted that the Windows D3D12 entry point was untested. This PR adds that run.
Tested
Native Windows 11 10.0.26300, MSVC 19.44, RelWithDebInfo,
LEONIDA_REQUIRE_VULKAN=ON, onmain42537e7plus the nine commits.d3d12_draw_testwith the fixd3d12_draw_testwithmain'svulkan_replay.handvulkan_scratch.h(run on955d9be, before the rebase)line 1171: view_out_red == 0replay_index_view_test(no GPU)main's headers, since it checks the newPreparedDrawfields)replay_index_view_testwith the quad-list branch taken outquad straddle: the buffer and view size go to the expansion pass, no stagingctest -j 6gameinputandgameinput_scriptdisabled.Not covered:
ExecuteIndirectwithDRAW_INDEXEDbinds no index buffer in the replay, so these bounds never reach indirect indexed draws. #499 works on that path.A huge index count past a small view asks scratch for
count * index sizebytes. If that allocation fails, the list is refused. I did not hit this. It is a limit, not a measured failure.GPUs tested: NVIDIA GeForce RTX 2050 (Ampere GA107, laptop), driver 621.24, 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. (No translator rule here.)🤖 Generated with Claude Code