mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:55:52 +01:00
[PR #2009] runtime: speed up uav_clear format lookup and channel pack/unpack with unit tests (RT-UAV-CLEAR-FAST-PACK-AND-UNIT-TESTS) #2018
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#2018
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/2009
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:perf/rt-uav-clear-fast-pack-and-tests📝 Commits (1)
f133273runtime: speed up uav_clear format lookup and channel pack/unpack with unit tests📊 Changes
3 files changed (+282 additions, -11 deletions)
View changed files
📝
runtime/CMakeLists.txt(+5 -0)📝
runtime/src/uav_clear.h(+107 -11)➕
runtime/test/uav_clear_unit_test.cpp(+170 -0)📄 Description
Claim:
RT-UAV-CLEAR-FAST-PACK-AND-UNIT-TESTS(claim comment#7170281757on #1608).Problem
In
runtime/src/uav_clear.h:layout(VkFormat)linearly scanned all 45Layoutentries on everyClearUnorderedAccessViewUint/ClearUnorderedAccessViewFloatcall (up to 45 comparisons forR8_*formats).detail::put()anddetail::get()packed and unpacked every channel one bit at a time (for (unsigned i = 0; i < c.bits; ++i)— up to 128 loop iterations per element forR32G32B32A32_*) without guarding out-of-bounds(offset, bits)pairs.uav_clear.hindependently of a live Vulkan/D3D12 device.Fix
layout(VkFormat)with aconstexpr switchverified at compile time by astatic_assertoverlayouts[].detail::put()/detail::get()with bounds-checked byte-aligned (8/16/32-bit) fast paths and a 64-bit word shift/mask path for packed sub-byte channels (10:10:10:2,11:11:10,5:6:5,1:5:5:5,4:4:4:4).unormscale computation insidecase Kind::unorm:inencode().uav_clear_unit(runtime/test/uav_clear_unit_test.cpp) verifying all 45 formats, exhaustive bit-exact parity ofput()/get()against a bit-by-bit reference across widths1..32, bounds guards, NaN/Inf/edge float conversions, cross-format decodes, andraw_element().Benchmark (
clang++ -std=c++20 -O2, bit-exact A/B across all 45 formats)encode()+decode()sweep (500,000 iterations):981.25 ms->388.01 ms(2.53x faster)R32G32B32A32_UINT,R8G8B8A8_UNORM,A2B10G10R10_UINT_PACK32,R8_SINT, 5M calls):237.19 ms->83.14 ms(2.85x faster)encode()+decode().Verification
runtime/test/uav_clear_unit_test.cppcleanly under:clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werrorclang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werrorclang++ -std=c++20 -O2 -Wall -Wextra -Werrorpython3 -I scripts/check_no_game_data.py runtime/src/uav_clear.h runtime/test/uav_clear_unit_test.cpp runtime/CMakeLists.txtandpython3 -I tests/test_text_write_line_endings.py: all passed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.