mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:00:52 +01:00
[PR #1989] runtime: unshuffle DirectStorage stripes in a single sequential output pass (RT-DSTORAGE-SWIZZLE-LINEAR-WRITE-AND-TESTS) #1996
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#1996
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/1989
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:perf/rt-dstorage-swizzle-linear-write📝 Commits (1)
5564eccruntime: unshuffle DirectStorage stripes in a single sequential output pass📊 Changes
3 files changed (+135 additions, -7 deletions)
View changed files
📝
runtime/CMakeLists.txt(+3 -0)📝
runtime/src/dstorage_swizzle.h(+26 -7)➕
runtime/test/dstorage_swizzle_test.cpp(+106 -0)📄 Description
Item ID:
RT-DSTORAGE-SWIZZLE-LINEAR-WRITE-AND-TESTS(claimed in #1608)Summary
Optimizes and hardens
leonida::dstorage::unshuffle()(runtime/src/dstorage_swizzle.h), used by the DirectStorage shim (runtime/shims/dstorage.cpp:1150) to macro-unshuffle swizzled BC texture streams:outwith 16 KiB / 32 KiB strides across the full multi-megabyte destination buffer 3–5 separate times (thrashing cache/TLB and breaking write-combining). Inverting the loop to outer-by-group / inner-by-stripe emits each destination group contiguously from start to end in one linear pass while reading 3–5 sequential plane streams.input/outspans cleanly (overflow-free pointer distance check) instead of invokingstd::memcpyUB, and handles empty spans in O(1).runtime/test/dstorage_swizzle_test.cppwired intoruntime/CMakeLists.txt(dstorage_swizzle), verifying byte-exact parity against the stripe-major reference across all 4 modes and multiple group counts, empty inputs, invalid modes/sizes, overlapping span rejection, and adjacent non-overlapping slices.Benchmarks (
-O2, 32 MiB texture, 16-iteration average, bit-exact A/B vsupstream/main)Testing & Disclosure
clang++ -std=c++20 -g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer -Wall -Wextra -Werror runtime/test/dstorage_swizzle_test.cpp: PASSclang++ -std=c++20 -g -O1 -fsanitize=thread -fno-omit-frame-pointer -Wall -Wextra -Werror runtime/test/dstorage_swizzle_test.cpp: PASSclang++ -std=c++20 -O2 -Wall -Wextra -Werror runtime/test/dstorage_swizzle_test.cpp: PASSpython3 -I scripts/check_no_game_data.py runtime/src/dstorage_swizzle.h runtime/test/dstorage_swizzle_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.