fix(shader): apply cube output modifiers whenever IEEE mode is off #5799
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5799"
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 SleglJan on 2026-10-14T11:39:15Z.
What
v_cubeid_f32,v_cubesc_f32,v_cubetc_f32andv_cubema_f32refuse any output modifier (mul:2,mul:4,div:2) withVOP3 source modifiers are not implemented. PPSA11386 (007 First Light) stops there on currentmain, within seconds of start, onv_cubeid_f32 v, v, -v, -v div:2.Measured on RDNA2 (Ryzen 9 7950X3D iGPU, gfx1036, not the PS5's gfx1013) with
tools/hw-oracle, 2048 inputs (edge cases and random), all four instructions with each modifier, in all 16 combinations of IEEE mode, the four f32 denormal values and f16/f64 denormals flushed or kept, with round to nearest even and DX10_CLAMP=1:v_mul_f32_e64 ... div:2in the same kernels follows #1851's rule (ignored with f32 output denormals kept). With IEEE mode on it is ignored.main's bit-level f32 output modifier result on every row: of the 24,576 results per mode, 21,768 differ from the unmodified value and all of them match; NaN and infinity pass unchanged, denormal and zero results become +0,div:2below 2^-125 gives a signed zero,muloverflow a signed infinity.clampapplies after the modifier. The negated-source form 007 uses behaves the same.Changes:
scaleF32Result.floatCubeapplies it whenever IEEE mode is off and then writes with the modifier cleared, soclampis still applied after it.floatCubedoes not use the generic gate (outputModifierApplies), which drops the modifier with IEEE mode off and f32 output denormals kept; for these four the hardware applies it there. In the usual mode (IEEE off, f32 denormals flushed) the two agree.Vop3CubeClamp.cppbecomes an execution test, and its run and check helpers take the kernel, rows and names instead of being duplicated. The output modifier entry indocs/dev/debt/shader.mdrecords the cube rule.Only round to nearest even is modelled. The same 2048 rows in the other three round modes (IEEE mode off, f32 denormals flushed and kept) differ from round to nearest even where a result overflows to infinity: the hardware rounds the overflow as the mode says (to the largest finite value when rounding toward zero), in
v_cubema_f32's own result as well as inmul:2andmul:4. The translation gives infinity there, asmainalready does forv_cubema_f32without a modifier. The only other difference is the sign of three zerov_cubema_f32results with a NaN input when rounding toward negative infinity. The debt entry records both.Overlap: #2463 (closed by the intake pause) accepted the modifier with the generic gate.
Tested
BUILD_TESTING=ON. The measurements below were made with this branch onmain23e93c05; it was then rebased without conflicts ontomain145cb82f, wheretools/check_conventions.py --base upstream/mainandgit diff --checkpass and the 19vop3execution tests,agc_driver_vop3_cube_clampincluded, pass on lavapipe.ANYPS5_ENABLE_SPIRV_TOOLS=ONas in CI: 1107/1121;main23e93c05built the same way fails the same 14 (hardware_oracle,guest_syslog,guest_allocator_failures,agc_driver_bc_block_copy,agc_driver_depth_compare_copy,agc_compute_pipeline_replay,autorun_exit_status,guest_none_relocations,guest_module_args,linux_executable_exports,linux_entry_argv,linux_program_header_order,linux_input_program_headers,linux_guest_stack).agc_driver_stencil_ref_export).agc_driver_vop3_cube_clamp: a 16-instruction kernel (all four instructions with each modifier, the negated-source form, clamp with each modifier) over 32 rows (two of them with a signaling NaN input), compiled with no float mode, IEEE=0 with f32 denormals flushed (0xc0) and kept (0xf0), and IEEE=1 with both, against two tables captured on gfx1036 (IEEE=0 and IEEE=1; the hardware gives the same results with f32 denormals flushed or kept). With only the test applied tomain23e93c05it fails on the decoder refusal. Mutations caught: the generic f32 gate (#2463's behaviour; fails at IEEE=0 with f32 denormals kept), applying the modifier in IEEE mode, never applying it, and skipping the signaling NaN quieting when a modifier is present (fails on a signaling NaN row with IEEE=1).main23e93c05every run ends on the decoder refusal (terminatewithVOP3 source modifiers are not implemented). With this change every run gets past it, compiles about a thousand shaders and stops at its first presentation onbindless image table has 18960 entries (0 materials), limit 16. Along the way 63 to 72 shaders are logged as not prepared after registration; none of the reasons names a cube instruction or an output modifier (GetImageResource dword 0 is not a valid runtime value, the clip distance limit, static bindless image capacity, bindless storage image tables).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)tools/hw-oracle🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T17:18:33Z.
Run on an Apple GPU, as a third device next to the RTX 3080 and lavapipe.
GPUs tested: Apple M2 Max, MoltenVK 1.4.2 (Vulkan 1.4.357), macOS 27.2, x86-64 under Rosetta
maindoes not run the GPU tests on macOS yet, so I tested onmacos-portatb7eb6b6b(mugurc/AnyPS5) with this PR's diff applied, not onmain. Release build, LunarG Vulkan SDK 1.4.363.0. The suite isctest -R agc -E 'flip|display|lds_atomics64' -j1 --timeout 30. Without the PR, 22 tests fail on this branch, all of them known macOS failures listed in #1. Head2acac0828. One conflict, inRdnaVectorOpDecoder.cpp(supportsNativeVop3ResultModifiers): the branch doesn't haveisNativeVop3F16TernaryOpcodein that condition yet, so I kept only this PR's|| isCubeOpcode(opcode). Everything else applies cleanly, exceptdocs/.agc_driver_vop3_cube_clamppasses. With only the test file applied to the unchanged branch, it fails withVOP3 source modifiers are not implemented, so the new cases do run on this device.agc_driver_f32_output_modifieris among them on this branch without the PR, and the cube modifier cases here still match the gfx1036 tables.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:09:46Z.
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.
core/shader/recompiler/Translation/include/Translation/TranslationContext.hppcore/shader/recompiler/Translation/src/FloatInstructions.cppcore/shader/recompiler/Translation/src/FloatInstructions.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdImported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-16T15:27:27Z.
Windows cross-test on current main
4524944396: author-preservede32f5e161port at df0e8a7c5, followed by #6317 and #6332, integration head 00abe7efa. GCC 15.2 / Release / SPIRV-Tools OFF / RTX 5070 Ti, Vulkan required. Fresh patched libraries and fixtures built successfully.agc_driver_vop3_cube_clampPASS 0.66 s, exercising the included oracle expectations with IEEE on/off and f32 denormals flushed/kept. Seven adjacent controls (shader memory, SPIR-V module, graphics, shared writes, write tracking, position invariance, constant phi) also pass: 8/8 total 6.24 s, no skips. This is a combined-stack Windows cross-test, not a full-suite result or new independent hardware oracle. Source/conventions clean; public integration branch: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-oct16-current-main .007 is currently preparing a cold shader cache without the earlier cube stop; no rendered-gameplay or FPS claim yet. AI-assisted: Codex; title data stays local.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T00:41:28Z.
The Windows run (@Scramblrrrr, RTX 5070 Ti,
agc_driver_vop3_cube_clampplus seven adjacent controls) and the Apple M2 Max run (@jotitadev, red without the PR and green with it) are a third and fourth device next to the RTX 3080 and lavapipe. Both are on a port or a combined stack, not this head on current main, so we'll run it there.