Repository navigation
perf(shader): reuse the source of a bitcast round trip - #7677
tibzejoker wants to merge 1 commit into
Conversation
|
This pull request is labeled |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
AMD run, since the description covers an RTX 4090. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release,
AI-assisted |
|
About the performance-report request: I captured the requested warm-cache traces (GTA V PPSA04264, open world, RTX 4090). Two things make them a poor fit for this change:
This change only makes modules smaller. Its effect is on pipeline creation, so I measured that directly: cold NVIDIA AI-assisted (Claude Code). |
9232951 to
7e3b891
Compare
7e3b891 to
5a0dd8b
Compare
5a0dd8b to
c07b6bd
Compare
|
First Linux run of this PR, on AMD with RADV. Head AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release. Full suite ( Comparing the JUnit output with This checks correctness only; I did not measure performance. GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38 AI-assisted: yes |
|
Thanks @DavidAmsellem for the RADV run on gfx1100: same single failure as AI-assisted: yes (Claude Code) |
c07b6bd to
9c81eac
Compare
Registers are 32-bit words, so a float result is bitcast to u32 when it is written and back to f32 when it is read: the emitted module carries pairs of OpBitcast that return to the type of the first one's source. A bitcast back to that type now returns the source itself, which dominates every use of the first bitcast. The module notes the result type and the bitcast source of each function instruction; Unary and EmitNative bitcasts look them up. Test: agc_bitcast_round_trip recompiles v_cvt_f32_u32 results added with v_add_f32 and requires no bitcast back to the type of a bitcast's source; it fails on main (one of six) and passes with this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XBXM4pgkMHYEtqN1EQni2P
9c81eac to
9ff723b
Compare
What
Guest registers are 32-bit words. A float result is bitcast to
u32when it is written to a register, and back tof32when it is read, so emitted modules carry pairs ofOpBitcastthat return to the type of the first one's source. This change makes a bitcast back to that type return the source itself. The source dominates every use of the first bitcast, so the module stays valid.To support this,
SpirvModulerecords the result type and the bitcast source of each function instruction. BothUnaryandEmitNativebitcasts look them up.Tested
Windows 11, MinGW GCC 15.2, RTX 4090 (616.92):
agc_bitcast_round_trip. It recompilesv_cvt_f32_u32results added withv_add_f32and requires that no bitcast goes back to the type of a bitcast's source. It fails onmain(one of six bitcasts) and passes with this change.ctest -R ^agc_: 727/728. The failure isagc_driver_bda_device, which fails onmaintoo.APS5_DUMP_SHADERSwere dispatched on synthetic guest memory withmainand with this change. Every byte they wrote was identical. SPIR-V words over these 72 went from 1,930,912 to 1,898,324 (-1.7 %); for example compute 0x143978f00 went from 8,545 to 8,457 words, and 0x25b390800 from 647,759 to 642,443.This is a small size win: every round trip removed is one instruction the driver no longer compiles.
Performance capture
GTA V (PPSA04264), open world from the same save, RTX 4090, one run each, same session. Base =
main47a266c + #6488 + #6848 + a local bench aid (keyboard pad input while an IME session is open), because GTA V does not run on plainmain;c0206c244d15is this PR on top of it. Traces: fork release perf-7673-7677-20261019.These frame times do not measure this change. The trace buffer of queue worker 0 fills after about 3.7 s (
trace_dropped), and in the open world frame time follows where the save respawns. This PR shortens shader compiles: the SPIR-V word counts and the cold compile times under Tested are the measurement.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01XBXM4pgkMHYEtqN1EQni2P