perf(shader): run packed 16-bit integer ALU as 16-bit vectors with shaderInt16 #16887
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16887"
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 boykopovar/AnyPS5. Originally posted by Ducengarth on 2026-11-07T20:31:43Z.
What
On a device with
shaderInt16, the VOP3P packed 16-bit integer instructions become one two-component 16-bit vector operation instead of being split into lanes:v_pk_mul_lo_u16v_pk_lshlrev_b16,v_pk_lshrrev_b16,v_pk_ashrrev_i16v_pk_min_i16,v_pk_max_i16,v_pk_min_u16,v_pk_max_u16v_pk_add_i16/u16,v_pk_sub_i16/u16andv_pk_mad_i16/u16Today each of them extracts both 16-bit lanes of every source, computes each lane in 32-bit arithmetic and repacks the result. #6118 measured the FSR4 Showcase program
0x275580000at 550,218 SPIR-V words, 52 % of it integer ALU from its 2,872v_pk_mad_u16. Its pipeline build (10 s on an RTX 5060 Ti) is about twice the title's wait.How:
IAdd16x2,ISub16x2,IMul16x2,ShiftLeftLogical16x2,ShiftRightLogical16x2,ShiftRightArithmetic16x2,SMin16x2,SMax16x2,UMin16x2,UMax16x2) take and return the U32 word that holds both lanes, like the existingFPAdd16x2family.OpIAdd,OpISub,OpIMul, shift (count masked to 4 bits per lane) or GLSL.std.450 min/max.SpirvSpecializationalready removes the bitcast pairs between chained operations.readPackedU16Sourceappliesop_sel,op_sel_hiandneg_lo/neg_hito the 32-bit source word, with the same source read and modifiers as the lane path.ConstantFolderfolds the new opcodes, and they are value-numbered byRedundantValueEliminator.shaderInt16when available and advertisesCapabilityInt16;ShaderDeviceProfilechecks it against the enabled features.agc_shader_replay --shader-int16replays a saved request with the capability, so requests dumped before this change can be measured.The lane path stays, unchanged, for the clamped add, sub and mad forms (core SPIR-V has no saturating integer add) and for devices without
shaderInt16; recorded indocs/dev/debt/shader.md. The lane code's results are the reference: mul_lo, shifts and min/max keep ignoringclamp, as the lane code does.Not touched: the f16 packed path, BDA, image mode switches and the f32 NaN rules, which other open work covers (#13538, #11183, #14260).
Tested
Windows 11 Pro N (10.0.26300), NVIDIA GeForce RTX 3090 Ti, driver 621.14, WinLibs GCC 15.2.0, Release,
ANYPS5_ENABLE_SPIRV_TOOLS=OFF(the release configuration). No title or homebrew; no PS5.agc_driver_packed_integer_native(new): 64 cases cover all 14 instructions, the fourop_sel/op_sel_hiselections,neg_lo/neg_hi, inline integer constants, literals and fully constant (folded) sources. They run over 64 lanes of edge and random inputs. The program is recompiled with and withoutCapabilityInt16, and both outputs must match a CPU reference bit for bit. The test also checks that only the Int16 module declares 16-bit integers.neg_hias 0x8000 makes it fail (332 mismatches), and so does making the arithmetic-shift and signed-max folds unsigned.agc_driver_packed_alu,agc_driver_packed_integer_negateandagc_driver_packed_integer_clamppass on the native path.ctest -R "^agc_driver_|^agc_|^shader_|^vector_"withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 --parallel 5, same machine:maindd00a9c54e: 1442/1442 pass.main8f7c957ed0, the validation-layer set below passes again: 120/120 tests, layer inserted, noVUID-, the same 20 warnings. The full focused suite and the benchmark ran on the previous base,dd00a9c54e. The rebase changed only one file of this PR,SpirvAluEmitterMath.cpp, wheremainedited code away from the new functions.maine67e806b1finto this branch (the only conflict was the neighbouring new entry indocs/dev/debt/shader.md),agc_driver_packed_alu,agc_driver_packed_integer_clamp,agc_driver_packed_integer_nativeandagc_driver_packed_integer_negatepass on the RTX 3090 Ti under the validation layer: layer inserted 4 times, nowas not foundmessage, noVUID-.agc_driver_packed_integer_nativereports 11,767 SPIR-V words with Int16 against 11,905 lane by lane. The full focused suite, the rest of the validation set and the benchmark were not rerun on this base.maindd00a9c54eand this branch:ctest -R "^agc_driver_.*(packed|integer|16|_alu|vop3|mul_lo|sdwa)" -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.main119/119 and this branch 120/120 pass.Insert instance layer "VK_LAYER_KHRONOS_validation"in every test that opens a device. The two that do not insert it are the CPU-only*_spirvtests, the same two on both sides.was not found but was requested by env var VK_INSTANCE_LAYERS.VUID-. Both have the same 20Undefined-Value-ShaderOutputNotConsumed-DynamicRenderingwarnings.Synthetic benchmark, not in the repository: a compute program of K packed integer instructions (mad_u16, mad_i16 with op_sel, ashrrev by 8, add, max with 0, mul_lo, sub, lshlrev, min_u16 with neg), checked against a CPU reference on every run. Each module is salted with a new literal so the driver cache cannot serve it. Pipeline creation is the median over 3 rounds × 4 modules, run in turn on
main, this branch withInt16, and this branch without it.main18.0–19.4 ms, this branch 15.9–17.5 ms, Int16 removed 17.9–18.8 ms.u16vec2maps to nativev_pk_*instructions on RDNA. The FSR4 programs from #6118 need a dumped request;agc_shader_replay --shader-int16measures them.Historical title trace comparison
Dark Alliance (PPSA02681 01.009.000), boot sequence, presents 300 through 899 at 3840x2160. These are existing captures from 2026-11-09, recovered from the local capture artifacts on 2026-11-11. They compare this PR's base,
maine67e806b1f, with the current PR head,37f2db1670, on the same recorded i9-9900K / RTX 3090 Ti / NVIDIA 621.14 / Windows 10.0.26300 configuration. The capture series followed separate warm-up runs of both staged copies. The recorded switches areAPS5_PLAYGO_UNLISTED_CHUNKS=0,1andAPS5_TRACE_FRAMES=300:600; the trace output directory is normalized to<path>in the summaries. Neither capture reports dropped events or a dirty source tree.This window shows no demonstrated frame-rate improvement: p50 is 16.893 ms on main and 16.884 ms on the PR, while p99 is 19.961 ms and 22.331 ms. It is not a measurement of FSR4 Showcase or of the cold pipeline builds in the synthetic benchmark above. These historical captures are not a rerun against today's main.
The two event traces, summary files, digests and original gzip SHA-256 hashes are available together. The uploaded event traces are losslessly decompressed JSON and can be loaded in Perfetto. The summaries retain their original
.json.gztrace names;trace_digest.pyalso matches the corresponding plain.jsonfiles.python3 tools/performance_compare.py main-3-summary.jsonl pk16-3-summary.jsonl --require-matching-contextpasses with no recorded configuration differences. Digests below were regenerated withtools/trace_digest.py <trace> --frames 2 --top 5from main2ecc68bda2on 2026-11-11.Summary lines, main then PR:
main-3 trace digest
frames 300:600 from present 300: 600 presents, frame p50 16.9 / p90 17.9 / p99 20.0 / max 78.5 ms, GPU busy 0.7 ms per present
NVIDIA GeForce RTX 3090 Ti, NVIDIA 621.14, Windows 10.0.26300, 3840x2160, commit
e67e806b1f, dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 32.9, Driver.WorkerWait.idle_and_completion_poll 32.1, VideoOut.Flip 2.7, Driver.Present 1.5, VideoOut.Flip.present 1.5
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
pk16-3 trace digest
frames 300:600 from present 300: 600 presents, frame p50 16.9 / p90 17.9 / p99 22.3 / max 59.4 ms, GPU busy 0.7 ms per present
NVIDIA GeForce RTX 3090 Ti, NVIDIA 621.14, Windows 10.0.26300, 3840x2160, commit
37f2db1670, dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 32.9, Driver.WorkerWait.idle_and_completion_poll 32.1, VideoOut.Flip 2.5, VideoOut.Flip.present 1.3, Driver.Present 1.3
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
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
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T22:27:00Z.
Review: COMMENTED
The Intel and Turing cells you list as not measured, for correctness. Head
420fe45e18merged ontomain302864d48c(clean). Windows 11 x64, WinLibs GCC 15.2.0 r7, Release,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1.main(clamp, negate)So the 64
agc_driver_packed_integer_nativecases match the CPU reference bit for bit with and withoutCapabilityInt16on both drivers, and the lane path's clamp and negate tests are unchanged. On Intel the test reports 11,767 SPIR-V words with Int16 against 11,901 lane by lane. No validation layer on this machine, and no pipeline timings taken.AI-assisted: yes.