Repository navigation
Conversation
…ze, and pipe config Layout::new and Layout::new_3d previously recomputed the GF(2) offset tables and allocated six Vec<u32>s on every call (called twice per placed texture in CreatePlacedResourceX). Because the tables depend only on (is_3d, mode, elem_log2, pipe_cfg) and only base_xor varies per texture, cache the immutable tables as &'static [u32] in a bounded RwLock<HashMap<...>> and make Layout Copy. Invalid combinations return None without inserting into the cache. Measured in release mode on Intel Core i9-9900K (4,000 calls, mode 25 / BC7): 3.15 us/call (table rebuild alone, excluding 6 Vec allocs) -> 0.048 us/call (65.3x faster, zero per-call heap allocations). Part of xcl-dev#449. Assisted-by: Antigravity (Gemini 4 Neon)
Owner
Author
|
Upstream PR xcl-dev#1048 was closed or merged. |
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.
Part of xcl-dev#449 (item 2: cache
gpu::tiling::Layout::from_bitsoffset tables).Layout::newandLayout::new_3dpreviously recomputed the GF(2) bit-offset tables and allocated sixVec<u32>s on every call (CreatePlacedResourceXconstructsxg::Texture::newtwice per texture). Because the tables depend only on(is_3d, mode, elem_log2, pipe_cfg)and onlybase_xorvaries per texture, this caches the immutable tables as&'static [u32]in a boundedRwLock<HashMap<...>>and makesLayoutCopy.Overlap note: touches only
crates/xcl/src/gpu/tiling.rslines9-155and adds one unit test at the end oftiling.rs— disjoint from xcl-dev#901 (detile/image_layoutfrom line 178 onward).What is in it
crates/xcl/src/gpu/tiling.rs:HashonPipeConfigandCopyonLayout, changing private offset tables (ox/oy/oz/hx/hy/hz) fromVec<u32>to&'static [u32].LAYOUT_CACHE(OnceLock<RwLock<HashMap<(bool, u32, u32, PipeConfig), Layout>>>) incached_layout, canonicalizingPipeConfigfor non-XOR modes (!is_xor(mode)) and caching only valid combinations (invalid calls returnNonewithout inserting or allocating).layout_cache_shares_tables_and_isolates_base_xorverifying pointer sharing,base_xorisolation across callers, non-XORPipeConfigsharing, 2D vs 3D thick separation, and non-caching of invalid keys.Measured speedup (
--release, Intel Core i9-9900K, 4,000 calls, mode 25 / BC7)Vec<u32>heap allocations/drops):3.15 us/call(12,594 usfor 4,000 calls)Layout::new(25, 4, cfg):0.048 us/call(193 usfor 4,000 calls) — 65.3x faster, 0 per-call heap allocations.Tested
26300), Intel Core i9-9900K, AMD Radeon RX 6800 (16337 MiB VRAM, driver32.0.21045.29003),rustc 1.100.0(x86_64-pc-windows-msvc), DXC1.9.2602.17(debugfor tests,releasefor benchmark & smoke runs).cargo test -p xcl --lib gpu::tiling::: 15 passed, 0 failed.XCL_REQUIRE_GPU=wave64,mesh+cargo test --workspace --no-fail-fast -- --test-threads=4ond9fcdce: 725 passed, 3 failed, 41 ignored, 0 GPU skipped (xcllib: 683 passed / 3 failed / 21 ignored; integration/e2e: 42 passed / 0 failed / 20 ignored;XCL_SAMPLE_*unset).placed_title_textures_share_vram_and_preserve_pixels(3D 64x64x64 4 mips: subresource 2 mismatch, fixed by open PR D3D12.X: map a one-slice title texture's packed mips where D3D12 addresses them xcl-dev/xcl#470) plus its 2VRAM_TEST_LOCKPoisonErrorcascades.Regression run
Both runs below on
YouKnowWho(60 s, release):main(09940bb87fa1):PR head (
d9fcdce14bb3):Not tested
XCL_SAMPLE_*unset).AI use
Mirror of xcl-dev#1048 (auto-synced, do not edit).