mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:00:52 +01:00
[PR #1892] runtime: guard draw zero-clears, AtomicCopyBuffer aliasing/overflow, and zero_image_aspect scratch (RT-VK-REPLAY-DRAW-ZERO-AND-ATOMIC-GUARDS) #1903
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1903
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1892
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:rt-vk-replay-draw-zero-and-atomic-guards📝 Commits (1)
461ecf7runtime: guard draw zero-clears, AtomicCopyBuffer aliasing/overflow, and zero_image_aspect scratch📊 Changes
3 files changed (+421 additions, -6 deletions)
View changed files
📝
runtime/CMakeLists.txt(+11 -0)📝
runtime/src/vulkan_replay.h(+35 -6)➕
runtime/test/replay_draw_zero_and_atomic_guards_test.cpp(+375 -0)📄 Description
Item:
RT-VK-REPLAY-DRAW-ZERO-AND-ATOMIC-GUARDSClaim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7165529828
Summary
Fixes three replay correctness bugs in
runtime/src/vulkan_replay.h:zero_clear_unavailable()skipsDraw/IndirectRasterDrawattachments (null-pointer crash):emit()callsdetail::to_attachment()->detail::initialize()on every bound color and depth/stencil attachment of a non-skipped draw, invokingvk.clear_color_image/vk.clear_depth_stencil_imagefor anyUNDEFINEDpiece.zero_clear_unavailable()previously inspected copies, clears, and barriers, omitting draws (draw_command(command).state) and omittingplanes_for_layout()for coupled depth/stencil ranges — allowingemit()to dereference a nullvk.clear_color_imageorvk.clear_depth_stencil_image(SIGSEGV onmain).d.colorsandd.depthfor every non-skipped draw and usesdetail::planes_for_layout(resource, range, vk.separate_depth_stencil_layouts)insidemissing().AtomicCopyBufferpreparation misses overflow & same-VkBufferaliasing self-overlap (VUID-vkCmdCopyBuffer-pRegions-00117):CommandList::atomic_copy()only comparesResourceIds (copy.dst == copy.src), so two distinct placed/arenaResourceIds backed by overlapping byte ranges of the sameVkBufferbypassed overlap rejection;prepare()also lackedUINT64_MAXchecks onbuffer_offset + offsetandoffset + bytes, plus a zero-size guard.VkBufferoverlap checks asCopyBuffer.zero_image_aspect()drops zero-initialization on unaligned scratch offsets:vk.copy_scratch(fill_bytes, ...)returns a 4-byte-aligned offset for an 8-byte or 16-byte block/texel format (e.g. 1x1 BC1/BC7/RGBA32F whereneeded == align),padleaves((fill_bytes - pad) / align) * align == 0 < fmt.bytes, causingzero_image_aspect()to returnfalseand leave the image uninitialized.fill_bytes + (align - 1)(overflow-guarded, with fallback tofill_bytesfor exact-sized aligned pools), checksscratch != VK_NULL_HANDLE, and capsusabletofill_bytes.No overlap with open PRs
#787,#1123,#1179, or#1877.Verification
runtime/test/replay_draw_zero_and_atomic_guards_test.cpp(CTestreplay_draw_zero_and_atomic_guards):clang++ -std=c++20 -Wall -Wextra -Wno-missing-field-initializers -Wno-switch -Wno-unused-private-field -Werror -O1 -g -fsanitize=address,undefined: passedclang++ -std=c++20 -O1 -g -fsanitize=thread: passedclang++ -std=c++20 -O2(3 runs): passedreplay_clear_gate_test,replay_copy_offset_test,replay_texture_barrier_test,replay_query_edges_testmain:test_draw_zero_clear_unavailable_color_and_depth: SIGSEGV (returncode=-11) onmain-> passes on branchtest_atomic_copy_overflow_and_aliasing_overlap: fails (returncode=1) onmain-> passes on branchtest_zero_image_aspect_unaligned_scratch_offset: fails (returncode=1) onmain-> passes on branchpython3 -I scripts/check_no_game_data.pyon all changed files: passedpython3 -I tests/test_text_write_line_endings.py: passed (3 tests)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.