Repository navigation
perf(shader): flush f32 denormals through the DenormFlushToZero execution mode - #6953
Closed
alfalfa-star wants to merge 1 commit into
Closed
alfalfa-star wants to merge 1 commit into
alfalfa-star wants to merge 1 commit into
Conversation
…tion mode With APS5_NATIVE_F32_FTZ=1 on a device that supports the DenormFlushToZero float-controls mode for 32-bit floats, shaders whose float mode flushes f32 denormals declare DenormFlushToZero instead of emulating the flush after every f32 operation. Shader validation accepts the execution mode as a float-controls mode. APS5_NATIVE_F32_FTZ_PIXEL_ONLY=1 limits it to pixel shaders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.
|
CnRJay
reviewed
Oct 16, 2026
CnRJay
left a comment
Contributor
There was a problem hiding this comment.
Off by default, so the risk is limited to the switch, but it isn't ready to be made default and has gaps now.
- No test. The change alters the SPIR-V of every f32 shader when the switch is set, and nothing checks either the emitted
OpExecutionMode ... DenormFlushToZero 32or that results still match the emulated flush. A shader test that runsv_mul_f32/v_add_f32/v_mac_f32on denormal inputs and outputs under both settings (the wayagc_driver_mad_f32does it) would show whether the driver flushes inputs as well as results. The execution mode lets the implementation flush operands too, which the emulated flush does not do for every instruction, so the results can differ on ops the old path left alone (conversions, min/max, compares). APS5_NATIVE_F32_FTZ_PIXEL_ONLYchanges the emitted module but is read innativeFloat32FlushToZero(request), outside the request. The first switch reaches the cache key throughsupportedCapabilities; this one doesn't, so a disk cache written with it off serves a module built without the mode when it's on, and the other way around. Take both from the request.state->capabilities.push_back(spv::CapabilityDenormFlushToZero)has no duplicate check, unlike theDenormPreserveline above it.- The measurement "will follow in a comment". The point of the PR is shader cost, so it needs GPU time per dispatch/draw (
APS5_PROFILE_GPU=1is fine for that, as #5353 shows) and the summary lines of main and this PR on the same scene in PPSA01802, warm cache. "About 24 fps in our local test build" is not that.
Contributor
Author
|
Closing in favour of #6503, which does the same thing more safely. I compared the two on
AI-assisted: yes (Claude Code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PS5 shaders usually run with f32 denormals flushed to zero (the float mode in the shader registers). The recompiler emulates this by flushing the result of every f32 operation in SPIR-V, which adds compares and selects around most ALU instructions. In GPU-heavy titles such as Kena: Bridge of Spirits (PPSA01802) this makes the shaders noticeably more expensive.
With
APS5_NATIVE_F32_FTZ=1, on a device that supportsDenormFlushToZerofor 32-bit floats (VK_KHR_shader_float_controls), a shader whose float mode flushes f32 denormals declares theDenormFlushToZeroexecution mode instead of emulating the flush. Shaders whose float mode keeps denormals are unchanged, and so is everything when the device lacks the capability. Shader validation now accepts the mode as a float-controls execution mode.APS5_NATIVE_F32_FTZ_PIXEL_ONLY=1limits it to pixel shaders.Off by default.
Tested
AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.4, Arch Linux (kernel 7.2.9), Kena: Bridge of Spirits (PPSA01802).
agc_driver_tessellationsegfaults on main without this change;guest_kernel_fcntlis flaky under load and passes on rerun).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