GPU: speed up packed rectangle vertex expansion #196
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/196"
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?
Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-24T01:18:42Z.
Summary
Rectangle draws expand their vertices on the CPU when the command list is submitted. For a 12-byte vertex with a float2 position and four UNORM8 color channels, select the layout once per batch and use fixed-size copies. Compute the fourth vertex's channels as
clamp(v0 + v2 - v1, 0, 255)on the original bytes. The generic calculation's floating-point error after rescaling is below half a channel step, so it rounds to the same byte.The fourth position uses the original addition and subtraction order. The generic path handles other layouts and nonfinite positions. The regression test compares every output byte across all four supported color formats, both element orders, floating-point edge cases, color saturation, and partial input and output.
Synthetic release benchmark
Windows, Ryzen 9 5900X, Rust 1.100.0 x86_64-pc-windows-msvc. The benchmark compares the original general-purpose implementation with the production dispatcher. Both paths use preallocated buffers and deterministic synthetic vertices. Times are medians of nine samples with alternating measurement order.
The benchmark measures CPU vertex expansion for this layout. GPU execution, layout frequency in live workloads, and frame time were unmeasured.
Validation
cargo +stable-x86_64-pc-windows-msvc test --workspace --locked -- --test-threads=1passed (265 passed, five ignored). Test host GPU was an AMD Radeon RX 6800 with Windows driver 32.0.21045.29003.cargo +stable-x86_64-pc-windows-msvc test --release --locked -p victory-gpu primitive::tests -- --test-threads=1passed.cargo +stable-x86_64-pc-windows-msvc clippy --locked -p victory-gpu --all-targetspassed with existing warnings in other files.cargo +stable-x86_64-pc-windows-msvc run --locked -p xtask -- policypassed.AI-assisted. The benchmark and new test use generated fixtures.
Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:31:53Z.
Tested
3c0b609under Wine 11.22 + vkd3d-proton 3.1 (Arch Linux x86_64, AMD RX 9060 XT, RADV 26.3.1), Windows build with a native Microsoftd3dcompiler_47: pass, no regression.victory_gpu: 42 passed, 2 failed, 2 ignored — the two failures are the environment-onlya_rejected_blob_gives_an_empty_libraryand #128; the ignored ones are the texture-check benchmarks.No game data used.
Imported from Marvisak/VIctory. Originally posted by juliptree on 2026-11-24T01:38:20Z.
Independently tested
3c0b60969fon Windows with a Ryzen 7 7800X3D and Rust 1.100.0 MSVC. All three release primitive::tests passed. Across three runs of the included benchmark, median before → after times were 115.16 → 12.25 ns/rect for batches of 1, 118.28 → 3.08 for 64, and 90.41 → 2.61 for 1,024.These timings measure CPU vertex expansion for the synthetic packed position/color layout. AI-assisted testing and write-up.
(Chatgpt)
Pull request closed