Repository navigation
perf(shader): share the cosine fallback polynomial - #13268
oneandonlydean merged 2 commits into
Conversation
|
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.
|
|
Windows GPU run of head Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, Radeon RX 6700 XT with AMD proprietary driver 26.10.1 (Vulkan 1.4.315), WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
AI-assisted: yes (Claude Code). |
✅ NVIDIA GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validation IDs already present on main (3 IDs in 380 tests)Skipped (41)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
@oneandonlydean @MarcZX10 Requesting a review decision on this optimization with the fresh confirmation report now in the description. Four predeclared pairs on main The rationale remains selecting the cosine argument before evaluating its unchanged polynomial, sharing the evaluation rather than emitting it twice. The report retains all unfavorable results and exact timing provenance; I have not relabeled the optimization as a refactor or added repetitions to seek a positive result. The reported matched Radeon fixtures and 29,184-output comparison preserve correctness; the Windows AMD and NVIDIA reports add separately scoped coverage. Would you accept this code/work reduction with the explicitly inconclusive gameplay result, or is another specific measurement required before it is worth landing? No new build, GPU run or capture is claimed by this follow-up. AI-assisted: yes (Codex). |
Re-checked — merged before reviewGitHub shows #13268 merged at |
What
EmitFPCosevaluates the same six-FMA cosine polynomial for the low and high ranges, then selects one result. Select the argument first so those ranges share one evaluation, reducing generated native code without changing the accuracy correction.This does not change the guest instruction semantics introduced in #3770 (
3a3504850a), the exact cycle reduction in #1979, or the near-zero behavior in #2380 (909281c994). The transformation uses per-lane SPIR-VOpSelectwith identical arithmetic on the selected input; the fused exact-arithmetic path remains intact. No new console behavior is inferred.Tested
2026-10-31 current-main confirmation: inconclusive; no established gameplay gain.
Existing PR13268, unchanged production mechanism, measured alone. Fresh main b7d3fd3 versus local merge166b91ac75f4 of the original PR head26597cbde592. The local merge is preserved but not pushed. Public parent revisions and exact tree/patch hashes are in merge-provenance.json.
Four paired reductions average 0.126054%; two-sided95%Student-t(df3)CI [-0.175159,0.427268]%. The lower bound is negative, so this does not establish gameplay improvement. No extra runs or unchanged repeat.
Mean frame time 45.697881179→45.640246374ms; mean run FPS separately 21.882859683→21.910523162. Within-arm ranges 0.069026616/0.162684180ms, sample SDs 0.029919831/0.068227046ms.
Allten fixed-order attempts valid, eighttimed, no exclusions or replacements. Same savedcamp/Continue route, guest1920x1080, Wayland1152x648client/mailbox, matched focus/cache/input/provenance. 51native libraries and9unique guestmodules namespace-hashed withduplicatechecks, actualRADVICDverified. Nativecount51 includesupstreamAudio3d libkernel_sys dependency. Botharms differonlyAGC andVideoOutrevisiontext. No validation/profiling duringtiming; stdoutPTY; no drops.
AMD Ryzen5 7640HS / Radeon760M integratedsharedmemory GPU, RADV Mesa25.0.7-2+deb13u1, Debian13.7, Linux7.2.12-x64v3-xanmod1. Three matched Radeon fixtures pass with Khronos instance/device insertion, no skips/missinglayers/VUIDs. 29184bitidentical trigoutputs, unsupportedmodes unchanged. No currentnativecode/occupancy or full-gamecleanvalidation claim.
The historical two-pair result observed +0.608%FPS on olderbase, with acknowledged uncertainty; it is retained in the previous evidence Gist and not pooled with this cohort. Its untimed trace-capacity failure and expectedrevisionlabel correction remain disclosed there. This fresh outcome is not a universal regression or benefit. No combined-patch inference.
Each gzip trace is losslessly base64wrapped. Decode, verifySHA256 in provenance.json, then decompress. All8 summaries and trace_digest reports supplied. Only timings, protocol, digests, hashes and our measurement-hook source are public; no gamefiles, saves, shaders, ISA, screenshots, hardwarecaptures orconsolelogs. AI-assisted:yes(Codex).
All fresh traces, summaries, trace_digest reports, protocol and provenance.
Primary metric: window duration / presents per run. Fixed order: warm A, warm B, A1, B1, B2, A2, B3, A3, A4, B4. Individual frames are not independent repetitions. Fresh matched main/candidate/final hook-free fixtures: SinCosReduction, SinCosNearZero, Vop1FloatUnary. Trace dirty:null records dependency-symlink status failure; exact source and binary provenance is retained. Identical readiness-only hooks run outside timing and are absent from production. Historical full-game vertex/index binding VUIDs remain; no clean full-game validation claim.
Fresh main/candidate summary lines and trace_digest excerpts
{"commit":"b7d3fd3c5218","dirty":null,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"30:12"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.2.12-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 30:12","first_present":662,"ms":12018.198},"presents":263,"frame_ms":{"p50":45.627,"p90":46.196,"p99":46.911,"max":47.275},"gpu_busy_ms_per_present":42.678,"worker_busy_pct":{"queue worker 0x0":78.378},"top_phases_ms_per_frame":{"Driver.Packet":35.694,"Driver.Packet.draw":33.301,"Driver.Draw":33.263,"Driver.Draw.draw_enqueued":29.515,"Recorder.Sync":28.586,"VideoOut.Flip":9.045,"Driver.Present":9.038,"VideoOut.Flip.present":9.011},"trace_dropped":false,"trace":"aps5-trace-b7d3fd3c5218-278807.json.gz"} {"commit":"166b91ac75f4","dirty":null,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"30:12"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.2.12-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 30:12","first_present":611,"ms":12026.628},"presents":263,"frame_ms":{"p50":45.643,"p90":46.385,"p99":47.166,"max":47.483},"gpu_busy_ms_per_present":42.544,"worker_busy_pct":{"queue worker 0x0":78.329},"top_phases_ms_per_frame":{"Driver.Packet":35.689,"Driver.Packet.draw":33.149,"Driver.Draw":33.11,"Driver.Draw.draw_enqueued":29.46,"Recorder.Sync":28.293,"VideoOut.Flip":9.027,"Driver.Present":9.017,"VideoOut.Flip.present":8.99},"trace_dropped":false,"trace":"aps5-trace-166b91ac75f4-279552.json.gz"}seconds 30:12 from present 662: 263 presents, frame p50 45.6 / p90 46.2 / p99 46.9 / max 47.3 ms, GPU busy 42.7 ms per present
AMD Radeon 760M (RADV PHOENIX), radv Mesa 25.0.7-2+deb13u1, Linux 7.2.12-x64v3-xanmod1, 1920x1080, commit b7d3fd3, dropped: no
seconds 30:12 from present 611: 263 presents, frame p50 45.6 / p90 46.4 / p99 47.2 / max 47.5 ms, GPU busy 42.5 ms per present
AMD Radeon 760M (RADV PHOENIX), radv Mesa 25.0.7-2+deb13u1, Linux 7.2.12-x64v3-xanmod1, 1920x1080, commit 166b91ac75f4, dropped: no
Conventions pass for this evidence update. A fresh scan covers1,593open PRs; the two stale shared-file comparisons (#5021 lane/NaN, #12324 wave-scan) were manually reviewed and are unchanged, with no cosine-sharing overlap or required dependency. The PR code/head stays26597cbde592; no timing is transferred to later maincf5a1805e50c.
Earlier 2026-10-30 evidence (retained unchanged below; separate protocol and revisions):
AMD Radeon 760M / RADV Mesa 25.0.7-2+deb13u1, Debian 13, Linux 7.2.12-x64v3-xanmod1; GCC 15.2.0 Release with SPIRV-Tools enabled and the default minimal optimizer.
The same three focused fixtures pass on current main
25dd440de1and final candidate26597cbde592:agc_driver_sin_cos_near_zero,agc_driver_sin_cos_reduction(including this PR's boundary cases on both arms), andagc_driver_vop1_float_unary. Both arms ran verbose ctest withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Logs confirm actual Radeon execution and validation-layer insertion for all three fixtures, with no missing-layer warning, skip or VUID error. Earlier paired checks on the measured source also pass. CI and other GPUs have not been tested.A driver-compiled synthetic sine/cosine kernel changes from 193 to 187 native instructions, 1,188 to 1,140 code bytes, and 48 to 32 allocated VGPRs. SGPRs stay at 128, branches at four, spills/scratch at zero, and reported theoretical subgroups/SIMD at 16. This is a synthetic native-code reduction, not captured linked gameplay ISA or a demonstrated occupancy gain. Five supported float-mode/fused-arithmetic settings produce 11,200 bit-identical sine/cosine outputs from 5,600 inputs; all ten emitted SPIR-V modules validate. The fused path was exercised on RADV; actual MoltenVK hardware was not tested.
PPSA28997 (God of War Sons of Sparta 01.008.001), stationary camp, prospective A1/B1/B2/A2 after one warmup per arm. All four captures pass scene, focus, save/input, loaded-library, cache and trace-drop audits. Main: 20.88761 FPS (20.87920–20.89602); candidate: 21.01464 FPS (20.96757–21.06174), observed +0.608%; pairs +0.793% and +0.423%. Mean GPU time: 44.2795 to 44.1280 ms/present. Two short pairs do not establish a significant or general gameplay speedup. The claim is the native-code reduction.
All four lossless traces, summaries, full trace_digest output, protocol, provenance hashes, synthetic statistics and validation comparison. Traces are base64-wrapped for Gist; the attached decoder checks original byte length and SHA256. No game-derived shader, ISA, save, screenshot, hardware capture or console log is published.
The first excluded baseline warmup's 30-second trace exceeded the default event capacity after 25.818 seconds. Before any measured pair, the windows were shortened to 12 seconds, with no buffer override; that warmup's timing is excluded. A 13-character expected commit abbreviation was also corrected to upstream's 12-character label after source/loaded-library verification, without editing traces or repeating a run. Both changes are disclosed in the protocol.
Measured revisions are
a5939f10a85fand55c0d6a1d776, with the identical attached first-present clock/screenshot hook;dirty:truehonestly records that hook. Only AgcDriver differs between arms; the other 49 loaded support libraries are identical. Timed windows use onlyAPS5_TRACE_SECONDS=90:12andAPS5_TRACE_DIR, with no validation/profiling or competing builds. Console output stays on a PTY; screenshots bracket timing. The final branch merges current main's unrelated export inventories: shader, AGC, VideoOut, kernel and libc sources are byte-identical to the measured counterparts, as recorded in the evidence. The gameplay timings are not relabeled as testing the final merge.Summary lines in order A1, B1, B2, A2:
{"commit":"a5939f10a85f","dirty":true,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"90:12"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.2.12-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 90:12","first_present":2374,"ms":12011.858},"presents":251,"frame_ms":{"p50":47.848,"p90":48.319,"p99":48.823,"max":48.949},"gpu_busy_ms_per_present":44.272,"worker_busy_pct":{"queue worker 0x0":79.116},"top_phases_ms_per_frame":{"Driver.Packet":37.699,"Driver.Packet.draw":34.645,"Driver.Draw":34.595,"Driver.Draw.draw_enqueued":30.327,"Recorder.Sync":28.793,"VideoOut.Flip":9.229,"Driver.Present":9.209,"VideoOut.Flip.present":9.182},"trace_dropped":false,"trace":"aps5-trace-a5939f10a85f-3404665.json.gz"} {"commit":"55c0d6a1d776","dirty":true,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"90:12"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.2.12-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 90:12","first_present":2160,"ms":12012.302},"presents":253,"frame_ms":{"p50":47.466,"p90":48.002,"p99":48.415,"max":48.557},"gpu_busy_ms_per_present":44.104,"worker_busy_pct":{"queue worker 0x0":78.979},"top_phases_ms_per_frame":{"Driver.Packet":37.333,"Driver.Packet.draw":34.412,"Driver.Draw":34.362,"Driver.Draw.draw_enqueued":30.374,"Recorder.Sync":28.996,"VideoOut.Flip":9.22,"Driver.Present":9.204,"VideoOut.Flip.present":9.176},"trace_dropped":false,"trace":"aps5-trace-55c0d6a1d776-3406187.json.gz"} {"commit":"55c0d6a1d776","dirty":true,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"90:12"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.2.12-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 90:12","first_present":2401,"ms":12018.562},"presents":252,"frame_ms":{"p50":47.708,"p90":48.159,"p99":48.643,"max":50.423},"gpu_busy_ms_per_present":44.152,"worker_busy_pct":{"queue worker 0x0":79.058},"top_phases_ms_per_frame":{"Driver.Packet":37.546,"Driver.Packet.draw":34.524,"Driver.Draw":34.474,"Driver.Draw.draw_enqueued":30.285,"Recorder.Sync":28.985,"VideoOut.Flip":9.211,"Driver.Present":9.194,"VideoOut.Flip.present":9.166},"trace_dropped":false,"trace":"aps5-trace-55c0d6a1d776-3407628.json.gz"} {"commit":"a5939f10a85f","dirty":true,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"90:12"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.2.12-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 90:12","first_present":2407,"ms":12021.533},"presents":251,"frame_ms":{"p50":47.941,"p90":48.416,"p99":49.116,"max":52.213},"gpu_busy_ms_per_present":44.287,"worker_busy_pct":{"queue worker 0x0":79.146},"top_phases_ms_per_frame":{"Driver.Packet":37.745,"Driver.Packet.draw":34.688,"Driver.Draw":34.639,"Driver.Draw.draw_enqueued":30.497,"Recorder.Sync":28.887,"VideoOut.Flip":9.219,"Driver.Present":9.193,"VideoOut.Flip.present":9.166},"trace_dropped":false,"trace":"aps5-trace-a5939f10a85f-3409147.json.gz"}Convention checks pass. The required overlap check reports no direct overlap; its three conflicting shared-file PRs (#5021, #11351, #12324) were reviewed manually and change lane shuffles/NaN tests, f16 conversion, and wave64 scan proofs respectively, with no cosine polynomial change.
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)