mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #1988] runtime: harden Depth24Converter bounds, rollback, and semaphore-cached collect (RT-VK-DEPTH24-CONVERTER-OVERFLOW-AND-COLLECT) #1995
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#1995
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/1988
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rt-vk-depth24-converter-overflow-and-collect📝 Commits (1)
7267cd0runtime: harden Depth24Converter bounds, rollback, and semaphore-cached collect📊 Changes
3 files changed (+489 additions, -35 deletions)
View changed files
📝
runtime/CMakeLists.txt(+9 -0)📝
runtime/src/vulkan_depth24.h(+86 -35)➕
runtime/test/vulkan_depth24_unit_test.cpp(+394 -0)📄 Description
Item ID:
RT-VK-DEPTH24-CONVERTER-OVERFLOW-AND-COLLECT(claimed in #1608)Summary
Hardens and optimizes
leonida::Depth24Converter(runtime/src/vulkan_depth24.h), which backsD24_UNORM_S8_UINTcopies on GPUs without native D24 (including MoltenVK/macOS and AMD/Intel drivers) as well as 96-bitR32G32B32texel repacks:Functions::load(): rejects nullPFN_vkGetDeviceProcAddrorVK_NULL_HANDLEdevice before dereferencingget, soloaded()returnsfalseand~Depth24Converter()skips all teardown calls safely.prepare()/make_part()/scratch()/run():(height - 1) * app_row_words + aw,(slices - 1) * app_slice_words + one_slice_words,span_words * 4,app_offset + span_bytes,sw * h * s * 4, callerscratch_offset % 4/scratch_offset + total_scratch_bytes, andmake_part()'swindow + range > app_sizeagainstuint64_twrap.whileloops (which could wrapuint64_tinapp_bytes/scratch_bytes) with exact O(1) division, and validatesmax_range_ > 256and row/slice feasibility before allocating any internal scratch buffer.scratch()against alignment/addition wrap and uses bitmask alignment (& ~(alignment - 1)).run()against unloaded/zero extents and uses(extent - 1u) / 8u + 1usowidth/heightnearUINT32_MAXcannot wrap to 0 workgroups.make_part()failure: clearspartsand restoreswhole.scratch/whole.scratch_offsetif descriptor allocation fails partway through a multi-part copy.collect()andforget():vkGetSemaphoreCounterValue()per distinctVkSemaphorewithin eachcollect()pass (avoiding redundant per-batch driver calls and repeatedDeviceFaultDiagnostics::observe()calls on a lost semaphore).std::vector::erase()loops with in-place compaction + singleresize().runtime/test/vulkan_depth24_unit_test.cppwired intoruntime/CMakeLists.txt(vulkan_depth24_unit) covering all 6 areas with mock Vulkan dispatch callbacks (no GPU or Vulkan loader required).Testing & Disclosure
clang++ -std=c++20 -g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer -Wall -Wextra -Werror -Wno-missing-field-initializers -I<vulkan-headers> runtime/test/vulkan_depth24_unit_test.cpp: PASSclang++ -std=c++20 -g -O1 -fsanitize=thread -fno-omit-frame-pointer -Wall -Wextra -Werror -Wno-missing-field-initializers -I<vulkan-headers> runtime/test/vulkan_depth24_unit_test.cpp: PASSclang++ -std=c++20 -O2 -Wall -Wextra -Werror -Wno-missing-field-initializers -I<vulkan-headers> runtime/test/vulkan_depth24_unit_test.cpp: PASSpython3 -I scripts/check_no_game_data.py runtime/src/vulkan_depth24.h runtime/test/vulkan_depth24_unit_test.cpp runtime/CMakeLists.txt: PASSpython3 -I tests/test_text_write_line_endings.py: PASS (3/3)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.