Repository navigation
feat(shader): request DenormPreserve 32 where the device preserves f32 denormals - #8697
Conversation
|
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.
|
|
The conventions failure is a missing environment-variable entry: |
…2 denormals The recompiler asked for DenormPreserve only for 16-bit and 64-bit floats, so a device that flushes 32-bit denormals by default (RADV, MoltenVK) flushed them whatever the guest's float mode said. target.float32DenormPreserve is set from shaderDenormPreserveFloat32 when denormBehaviorIndependence allows a 32-bit mode, is part of the cache key and of the request serialization (version 41), and makes the module declare DenormPreserve 32 unless the 32-bit flush is already taken in hardware. APS5_NO_HW_F32_PRESERVE=1 turns it off.
|
I prepared the missing documentation row and verified the one-line diff with | `APS5_NO_HW_F32_PRESERVE` | presence | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | | disables requesting the host f32 DenormPreserve mode |I did not open a standalone docs PR because the variable is not present on current |
|
Run on a device that advertises f32 denorm preserve, which the RTX 4090 run does not. Host: Arch Linux, kernel 7.2.11, AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5, GCC 16.2.1, Release, The merge conflicts with
|
d8dd4e0 to
3117837
Compare
|
@janzezno Thanks for the RADV run. It's the device class this change is for. The branch is now rebased onto If you have time, one more run would help: any title you can boot on that RX 7900 GRE, on |
|
Ran the rebased head Host: Arch Linux, kernel 7.2.11, AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5, GCC 16.2.1, Release, Title: ccleste 1.00 (PPSA59322), from darkxex/PS5_Celeste. The zip's sha256 is
The title gets as far on the PR as on Tests:
|
|
Supplemental Windows/Intel validation:
Required Vulkan, disabled shader cache, Khronos validation: no missing layer or VUID errors. No title or performance claim. AI-assisted: yes. |
Since #8697 every device with shaderDenormPreserveFloat32 and an independent f32 denormal behaviour gets DenormPreserve 32. RADV on Vega (GCN 5, Mesa 26.0.8) miscompiles the preserving forms of the transcendental ops: its v_log_f32 lowering picks the denormal scale with a v_cndmask_b32 that reads two SGPRs, which GFX9 cannot do, so log2(2.0) is 25.0 in some lanes and agc_driver_log_near_one, vop1_float_unary, fp16_overflow and float16_result_modifiers fail. ProbeFloat32DenormPreserve runs v_log_f32, v_sqrt_f32, v_rsq_f32, v_rcp_f32 and v_exp_f32 on normal values with and without the mode, after the flush probe. The mode only changes denormal handling, but Vulkan does not require these ops to be correctly rounded, so Float32ResultsAgree accepts each of the 256 result pairs when they are no further apart than the width of the interval the Vulkan precision bound allows around the exact result (sqrt's bound inherited from 1.0 / inversesqrt(), an absolute 2^-21 for log2 inputs in [0.5, 2.0]). When one falls outside, float32DenormPreserve stays off and the device keeps its default f32 denormal handling.
What
The recompiler asked the device for
DenormPreserveonly on 16-bit and 64-bit floats (float16DenormPreserve,float64DenormPreserve). On a device that flushes 32-bit denormals by default and can preserve them (RADV, for one) a 32-bit shader flushed them whatever the guest's float mode said, so the f32 denormal series (#5941, #6009, #6010, #6011), which flushes in the IR and relies on the hardware preserving what it does not flush, could not pass on those devices; the f32 rows pass only on CI's lavapipe 25.2.8, which is why a green CI hid it.This adds
target.float32DenormPreserve:VulkanDevicesets it fromshaderDenormPreserveFloat32whendenormBehaviorIndependenceis not NONE (a 32-bit mode can differ from the other widths), and adds theDenormPreservecapability.APS5_NO_HW_F32_PRESERVE=1turns it off, likeAPS5_NO_HW_F32_FLUSH.DenormPreserve 32when the flag is set and the hardware 32-bit flush (float32FlushToZero) is not in use; when the flush is in hardware, that mode wins.Behaviour change on devices that advertise
shaderDenormPreserveFloat32: every f32 shader now carriesDenormPreserve 32unless the hardware flush is used. Devices that do not advertise it (the RTX 4090 tested here; lavapipe 25.2.8 reports the same properties) get the same SPIR-V as before.Target()now carries the preserve flag intoProbeFloat32FlushToZero, so on devices that preserve f32 denormals (RADV, for one) the probe can choose the emulated flush instead of the hardware flush. That is a possible performance change, not a correctness one.Tested
Linux (CachyOS), GCC 16, Release, branch on main 2185dbf:
request_serializer,agc_shader_memory,agc_shader_disk_cache,agc_float16_conversionand the newagc_f32_denorm_preservepass; the new test checks that the flag emitsDenormPreserve 32with its capability, that an unset flag emits no 32-bit denormal mode, and that the hardware flush wins when both are set. Serialization: round trip with the flag on and off, a version 40 stream reads as unset, version 42 is rejected, the cache key changes.agc_driver(submit, f16, f32, f64) tests pass. That GPU reportsshaderDenormPreserveFloat32 = false, so it did not run the new path. lavapipe 25.2.8 reports the same properties (queried with vulkaninfo; the tests were not run on it).[float-controls]probe line, main versus this PR, plusagc_driverf32/f16/f64 and one title.shaderDenormPreserveFloat32 = true(RADV, Intel, MoltenVK), so the emittedDenormPreserve 32module has not run on hardware; Windows; a game.g++ 13.5 -fsyntax-onlycheck with the project flags.Checklist
main; no other open PR implements the same functions (perf(agc): probe the f32 denormal flush on MoltenVK #8578 changes the 32-bit flush probe and capability, not the preserve mode)NotImplemented_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)