Repository navigation
runtime: harden Depth24Converter bounds, rollback, and semaphore-cached collect (RT-VK-DEPTH24-CONVERTER-OVERFLOW-AND-COLLECT) - #1988
Open
IlyassRS3 wants to merge 1 commit into
Conversation
Contributor
|
#1988 | head 7267cd0 (merged cleanly with main 4150b1a) | |
4 tasks done
Contributor
|
Checked
AI-assisted (Claude Code). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)