Repository navigation
Textures: a layout's high-coordinate tables hold one period, not 65536 entries - #435
Conversation
…6 entries Layout::from_bits built the tables for the coordinates above a block (hx, hy, hz) over the whole 16-bit range. For a 2D surface the z table alone is 65536 u32 entries – 256 KiB – and every xg::Texture builds its own Layout, so each live tiled title texture carried about 256 KiB of CPU memory. The entries depend only on the coordinate bits the block's pattern masks use. Each table now covers the power of two above the highest such bit (one entry when no bit is used); offset_z already indexes the tables modulo their length, so every offset is unchanged. The test compares every 2D and thick 3D mode, element size and pipe configuration against the full-range tables, for coordinates up to and past 16 bits, and fails before the change (a 2D z table of 65536 entries).
|
Test run of Tested
Review of the change: the high-coordinate tables are read only in Not tested: no retail title or regression run (I have no unpacked game), no Run and report by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
Code audit + NVIDIA RTX 5080 test run on ReviewLooks clean and mathematically exact:
Tested
Not tested
AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above. |
|
Test report on AMD RDNA3: RX 7800 XT (16 GB), driver 32.0.32015.7029, Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug build. No retail data was used. Tested: the PR head
Not tested: a regression run on a title, a release build, and the head merged onto current AI use: Claude Code ran the commands and drafted this comment; the runs are real runs on the hardware above. |
|
Independent CPU-side layout construction benchmark on an Intel Core i5-8400, Windows 11 Home 26200.9974, Rust 1.100.0 x86_64-pc-windows-msvc. Compared base Tested: identical temporary release-mode Cargo example calling
Not tested: retail performance, memory savings in a running title, or the full workspace suite. This benchmark measures only synthetic layout construction, with no GPU or game files needed. AI use: OpenAI Codex (GPT-6) wrote the temporary benchmark, ran both builds and the tests, and drafted the report. |
|
Test report on a retail title streaming its world – the run listed under Not tested. Machine: Intel Core i7-7700K (4 cores / 8 threads), 16 GB RAM, NVIDIA GeForce RTX 5080 16 GB (driver 610.47), Windows 10 22H2 (19045), rustc 1.100.0. The newer retail title of the README, the same pad script (
Not tested: AMD and Intel GPUs; more than one run of each build; the frame rate in the world (not reached). AI use: Claude Code with Claude Fable 5.2 ran the builds and runs and wrote this report; every number is from a run on the machine named. No game files are attached. |
Check every tiling mode, element size and pipe configuration: offsets one-to-one and in bounds, equal to addrlib's swizzle equations across the full coordinate range (guarding ivall#435), tile / detile round trips, the detile fast paths from ivall#451 and ivall#602 against a texel-by-texel reader, mip chains and volumes without overlaps, and invalid input giving None. Assisted-by: Claude Code (Claude Opus 5.5)
Part of #248 (memory while a title streams its world).
Every
xg::Texturebuilds its owngpu::tiling::Layout, andLayout::from_bitsbuilt the tables for the coordinates above a block (hx,hy,hz) over the whole 16-bit coordinate range. For a 2D surface the z table alone is 65,536u32entries, so 256 KiB of CPU memory per live tiled title texture. The entries depend only on the coordinate bits the block's pattern masks actually use, which is 1 to 32 entries. Each table now covers the power of two above the highest such bit, or one entry when none is used.offset_zalready indexes the tables modulo their length, so every offset is unchanged.What is in it
crates/xcl/src/gpu/tiling.rs:Layout::from_bitssizes each high-coordinate table from the OR of the masksbits[..blk]use on that axis, above the in-block bits.high_coordinate_tables_keep_their_offsets_at_one_period. Every 2D mode and thick 3D mode, element size and pipe configuration in the existing test sets is compared against tables of the full 16-bit range, for coordinates up to 2^18 and past 32 bits. It fails before the change ("2D mode 1 e 0 …: 65536 z entries").Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 677 passed, 0 failed, 41 ignored.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.cargo test --release -p xcl --lib tiling: 12 passed. The new test fails with the old table size.Regression run
main:
PR:
The main run was the first after a fresh build of a new main and filled the shader cache; I don't attribute the frame difference to this change.
Not tested
AI use