Repository navigation
fix(shader): declare f16 and f64 DenormPreserve together when their modes are shared - #11483
tibzejoker wants to merge 3 commits into
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
I checked the float-control gating and paired emission, the recompile cache key, and the serializer’s format-gated backward compatibility. The submitted Windows and RADV results are detailed, and the automated policy checks pass. The branch is 87 commits behind current (merge base ); CONTRIBUTING requires keeping branches current. Please rebase onto current , resolve the serializer-version interaction with open #11351 if needed, and rerun the focused tests on the rebased head. I’ll review the new head.
MarcZX10
left a comment
There was a problem hiding this comment.
I checked the float-control gating and paired DenormPreserve emission, the recompile cache key, and the serializer’s format-gated backward compatibility. The submitted Windows and RADV results are detailed, and the automated policy checks pass. The branch is 87 commits behind current upstream/main (merge base e476a8a); CONTRIBUTING requires keeping branches current. Please rebase onto current main, resolve the serializer-version interaction with open #11351 if needed, and rerun the focused tests on the rebased head. I’ll review the new head.
95a385d to
406bf3f
Compare
|
@MarcZX10 rebased: head
|
|
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.
|
|
On the overlap table: these PRs all bump the request serializer format, so they edit the same version pins in |
MarcZX10
left a comment
There was a problem hiding this comment.
Correction to my earlier review: its formatting omitted the branch refs. I fetched the current PR head 406bf3fdc2d5 and verified it is 2 commits ahead and 0 behind current upstream/main (48c160c58b58); the merge is clean. The stale-base concern is resolved.
Thanks for clarifying the serializer overlap with #11351. I agree those are independent changes that only need sequential serializer version numbers, so Depends on: none is appropriate.
I reviewed the coupled-mode device gating, cache-key and request serialization propagation, and paired SPIR-V execution-mode emission. The Vulkan rule for 32_BIT_ONLY requires identical denormal modes for 16-bit and 64-bit types; this change emits both when the device supports both and the shader uses either. The current policy checks pass. The PR reports focused NVIDIA results and a separate RADV run; I did not rerun the GPU tests locally.
|
Thanks @MarcZX10 for the review and for checking the branch freshness. |
THEMANnt
left a comment
There was a problem hiding this comment.
Reviewed 406bf3fdc2d5 against 48c160c58b58. No actionable findings.
The device gate requires Float64, Vulkan 32_BIT_ONLY, and preserve support for both widths. Either backend path that emits DenormPreserve also emits the paired 16/64 mode. The coupled flag is carried through the cache key and request format 47; older format 46 requests default it to false.
Validation: GCC 15.3.0, CMake 4.3.3 and Ninja 1.13.2 built libSceAgcDriver, shader_recompiler_agc_driver, the serializer/f16/f64 tests and agc_shader_replay. Focused CTest passed 4/4; replay fixture tests passed 2/2. Both replay mode switches materialized the fixture. A review-only cache-key assertion passed; removing the cache-key append made it fail as expected. On the exact-head Actions run, eligibility passed while Windows, Linux, relinker, ASan, register-context and write-watch jobs were skipped.
The local build used a cached base integration (035ac96) with the PR source overlay, not a full checkout of the pinned base/head pair. No local 32_BIT_ONLY GPU was exercised; the PR's RADV results remain author-reported.
|
More RADV coverage for the coupling, from @tablefrogpillow on #11351 (comment), on the switched version of this change, Mesa 25.2.8, validation layer on:
|
|
@tibzejoker, the 860M run of this PR itself, without any variable: head On RADV the coupling turns on by itself. Every device creation in the focused set logs this line, 74 per run; on The focused set is the one in the description:
The branch now conflicts with Logs of every run above, with an index in AI assisted: yes |
|
A run on the case Tested lists as not covered: AMD's Windows driver. Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release,
This head now conflicts with
The layer was active on both sides: each log has 19 Not run: the full AI-assisted: yes (Claude Code) |
406bf3f to
5a8a216
Compare
|
Rebased on Focused set from the description with @Lander0606 @ycbuzi thanks for the RADV 860M and AMD Windows runs. AI-assisted: yes (Claude Code) |
|
Same AMD Windows comparison on the rebased head
The layer check before each side wrote a 28-line log, as before. The serializer format change to 49 doesn't change anything here. AI-assisted: yes (Claude Code) |
|
@tibzejoker this no longer merges into main: Note: #10547, #11483 and #10846 all need the next request-serializer version, so whichever lands first takes 50 and each later one takes the next number after it. |
|
Rebased on Focused set from the description, with
The UHD 770 failure is AI-assisted: yes (Claude Code) |
agc_shader_replay --unpreserved-f16-f64-denorms clears float16DenormPreserve and float64DenormPreserve, as on a 32_BIT_ONLY device before the coupling; --coupled-f16-f64-denorms sets both with coupledF16F64Denorms, as on such a device now. Requests saved on another GPU can then show both module shapes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PHJtpJ4hw3KWJhobipK8ia
80cb2cd to
09ee954
Compare
|
Rebased onto
I re-ran the focused set with the same command as the body: validation layer inserted in every run (100 per run),
The Intel failure is the same on both sides: @Nesyth heads-up for #15719: if it ends up serializing its new target field too, the next free format after this PR is 57. AI-assisted: yes (Claude Code) |
Stale: rebase-only request; the conflict is handled by a merge-main from our side.
Credit: PR author tibzejoker. Main moved the recompile request serialization to version 56 (compute VGPR counts) while this PR also used version 56 for coupledF16F64Denorms. Conflicts in core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp, core/shader/recompiler/tests/RequestSerializerTests.cpp and core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp: main keeps version 56, the coupledF16F64Denorms flag is now written and read at version 57 after main's compute block, the writer emits 57 and the accepted range is 1..57, and the tests that assert the current version, its prefix and its tail bytes were moved to 57, and the unsupported-future-version checks now use 58.
|
An RDNA 3.5 data point for "RDNA has a single f16/f64 denormal field in Setup:
Rows: one per run. The constants are built in the program. Forms: for each width there is one input test and one output test. The input test adds the largest denormal and the smallest denormal; the result is the smallest normal if input denormals are kept, and 0 if they are flushed. The output test multiplies the smallest normal by 0.5; the result is a denormal if output denormals are kept, and 0 if they are flushed.
Results for all 32 runs, the same at IEEE 0 and IEEE 1 and for every f32 field:
The f32 results follow only the f32 field, with the same bit meaning: bit 0 keeps inputs and bit 1 keeps outputs. MODE was So gfx1151 has one denormal field for f16 and f64, in MODE bits 7:6, separate from the f32 field in bits 5:4. Preserving f16 and f64 denormals together, as this PR does on a This measures the hardware only. It says nothing about RADV's Not run: the recompiler side (no Windows build of the runner here), and the PR's tests. AI-assisted: yes (measurement scripted with Claude Code; rows and results checked by me). |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The reviewed change at a1c260d762d3113a9bc7555748d33e8c637f63c3 consistently enables and emits both denormal execution modes for coupled f16/f64 devices; no checks were run in this review.
What I ran
No commands were run. I inspected the prepared diff and targeted changed source ranges with the provided reader.
Results
| Check | Result | Note |
|---|---|---|
| Diff and source review | passed | Coupled mode and serialization paths inspected |
| Tests | not run | Author-reported results were not independently run |
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests and device behavior were not independently verified. Read: VulkanDevice.cpp, Float16Conversion.cpp, ShaderMemory.cpp (changed ranges), F64FmaSubnormals.cpp, ShaderReplay.cpp, CacheKey.hpp, RequestSerializer.cpp, Recompiler.cpp, Recompiler.hpp, SpirvEmitter.hpp, SpirvEmitterHelpers.hpp (diff only), SpirvEmitterState.hpp, SpirvEmitter.cpp, SpirvModuleSetup.cpp, SpirvModuleEmitter.cpp, RequestSerializerTests.cpp (diff only), and shader.md. No changed files were excluded from review; full text was not read for VulkanDevice.cpp and ShaderMemory.cpp because they exceeded the prepared bundle limits.
To get this to a good state
Nothing is required.
|
I tried to merge main into this and stopped. This PR adds |
What
Part of #11183. On a device whose f16 and f64 denormal modes are tied together, both are now preserved, and every module that declares
DenormPreservefor one of the two widths declares it for the other.Vulkan's
denormBehaviorIndependence=VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLYmeans an entry point must use the same denormal execution mode for 16-bit and 64-bit floats (VkShaderFloatControlsIndependence). #2977 enabledDenormPreserve64 only with independenceALLand noted that "the backend does not yet emit coupled execution modes for32_BIT_ONLYorNONE".float16DenormPreservehas the sameALLcondition. RADV reports32_BIT_ONLY, so on RADV today:DenormPreserve64), andagc_driver_f64_fma_subnormalschecks the result only where the driver keeps them;v_cvt_f32_f16and the other f16 -> f32 reads use the decoded integer emulation instead ofUnpackHalf2x16, because that path needsfloat16DenormPreserve;DenormPreserve16 by themselves (their condition,Float16withRoundingModeRTEandDenormPreserve16 supported, does not look at the independence), so a module with both those conversions and f64 code declares a 16-bit mode with no 64-bit one. None of the 78 GTA V compute modules below has both.RDNA has a single f16/f64 denormal field in
FLOAT_MODE(bits 7:6), so preserving both together is also the console's shape.Change:
VulkanDevice: with Float64 enabled,32_BIT_ONLY,shaderDenormPreserveFloat16andshaderDenormPreserveFloat64, the device setsSpirvTarget::coupledF16F64Denorms,float16DenormPreserveandfloat64DenormPreserve, and logs[float-controls] f16 and f64 denormals share one mode on this device: DenormPreserve 16 and 64 are declared together. With independenceALLorNONE, or a missing preserve property, nothing changes.EmitF16DenormPreserveand the newEmitF64DenormPreserveeach declare the other when the flag is set. They are the only places that emit the 16-bit and 64-bitDenormPreservemodes (git grep ExecutionModeDenorm), so every module declares both or neither.agc_shader_replay --unpreserved-f16-f64-denorms/--coupled-f16-f64-denormsreplay a saved request in the two shapes, so the size numbers below can be reproduced from requests saved on any GPU.Landing order with #11351 (agreed on #11351): #11351 landed with format 54, and #9020 then took 55. This PR now takes 56 (57 is the first unsupported version), with its flag written after #11351's two.
Tested
Windows 11 Pro, MinGW-w64 GCC 15.2.0 (WinLibs r7), Ninja, Release,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON(spirv-val on every module), onmain48c160c58b.SPIR-V checks (no device needed):
agc_driver_f64_denorm_preserve_spirv: an f64 shader declaresDenormPreserve64 and not 16 with independent modes, and both withcoupledF16F64Denorms;agc_float16_conversion: a native f16 conversion declaresDenormPreserve16 and not 64 with independent modes, and both when coupled.With the two coupling lines removed from
SpirvModuleEmitter.cpp, both tests fail; with them, both pass.Serializer:
request_serializerround-trips the flag both ways, reads a format 55 request as false and rejects a truncated one;agc_shader_memorypins format 56.Focused tests,
maina7e789e5b5vs this PR (09ee9542f8),ctest -R "(^agc.*(f16|float16|f64|convert|pack|interpolation|denorm)|request_serializer|shader_memory|agc_float16_conversion)" -E "^agc_driver_bda_device$" -V,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationwithVK_LOADER_DEBUG=layer(100Insert instance layer "VK_LAYER_KHRONOS_validation"lines per run, nowas not found but was requested by env var VK_INSTANCE_LAYERS),ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1:mainVUID-linesNeither device reports
32_BIT_ONLY, so neither takes the new path: this run is the no-change control. On Intel the f64 tests skip (no Float64). The one failure isagc_driver_packed_float_blend, from feat(agc): blend into 11_11_10 float color targets in the pixel shader #9020, on both trees.RADV, Radeon 860M (Mesa 26.2.5, Fedora 44, GCC 13.3), by @Lander0606, on the same change behind a switch (
test/coupled-f16-f64-denormsfe10c0205c, on top of perf(shader): keep native f16 conversion NaN results when a startup probe matches RDNA #11351), validation layer 1.4.341,ctest -j1 -V -R "^agc.*(f16|float16|f64|convert|pack|interpolation)" -E "^agc_driver_bda_device$":^agc(-j8)Every device creation logs the
share one modeline. The 13 f64 tests of the set pass withDenormPreserve64 on (f64_fma_subnormals,f64_rounding_denormal_modes,div_fixup_f64_denormal_modes, ...), and so dointerpolation_modesandpixel_exec_interpolation. The only full-suite failure isagc_driver_tessellation(the Mesa 26.2.5 crash), on both. NoVUID-line, but @Lander0606 also checked that the layer does not flag an uncoupled declaration (VUID-RuntimeSpirv-denormBehaviorIndependence-06289stayed silent with the f64 half removed), which is why the two SPIR-V checks above test the coupling directly. On lavapipe (denormBehaviorIndependencenot32_BIT_ONLY) the flag stays off. A rerun on this branch is offered.Size, Grand Theft Auto V compute shaders (the requests of perf(shader): compute v_pk_fma_f16 and v_pk_fmac_f16 with OpFmaKHR #11265 saved on the RTX 4090, replayed with
agc_shader_replay --spv; 78 of them recompile on currentmain):--unpreserved-f16-f64-denorms(a32_BIT_ONLYdevice onmain)--coupled-f16-f64-denorms(the same device with this PR)ALL, unchanged by this PR)0x25b393000(RCAS) 102,227 -> 90,517 (-11.5 %),0x25b433400112,824 -> 110,242 (-2.3 %),0x25b3c4e00-0.6 %,0x25b3c3a00-1.0 %; modules that change nothing else gain the 4 words of the second mode. Both coupled modules checked withspirv-val --target-env vulkan1.3(0x25b393000: 16 and 64;0x25b433400, which has Float64: 64 and 16).What is and is not measured. The path is taken only on
32_BIT_ONLYdevices (RADV here). Measured: module shape, size and test correctness on RADV. Not measured: frame time or pipeline creation on such a device (no title runs on the 860M). Not tested: AMD's Windows driver, MoltenVK.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
https://claude.ai/code/session_01PHJtpJ4hw3KWJhobipK8ia