Repository navigation
fix(shader): keep the 24-bit factor reads of 16-bit multiplies - #8280
Merged
oneandonlydean merged 1 commit intoOct 20, 2026
Merged
oneandonlydean merged 1 commit into
oneandonlydean merged 1 commit into
Conversation
boykopovar#7018 reads the low-half factors of v_mul_lo_u16 and v_pk_mul_lo_u16 as 24-bit fields because AMD's Windows driver stores the full 32-bit product when it knows both factors fit in 16 bits. boykopovar#7673's fold of BitFieldUExtract(x, 0, n) into x removed those reads when the program had masked the factors to 16 bits, so agc_driver_mul_lo_u16_high_half failed again on that driver. The folder now keeps a field read that a multiply uses. 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.
|
12 tasks done
12 tasks done
12 tasks done
TheSovietWaffle
added a commit
to TheSovietWaffle/AnyPS5
that referenced
this pull request
Oct 20, 2026
boykopovar#8280 keeps the 24-bit factor reads of v_mul_lo_u16 and v_pk_mul_lo_u16 so AMD's Windows driver cannot see that the factors fit in 16 bits. A negated packed factor is read as that field XORed with 0x8000, so two cases now run v_pk_mul_lo_u16 with neg_lo on a low lane and neg_hi on a high lane, with the other half of both factors masked to zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Fixes #8271:
agc_driver_mul_lo_u16_high_halffails on AMD's Windows driver 32.0.21045.5002 since #7673 (also reported for an RDNA 2 iGPU in #8266).#7018 reads the low-half factors of
v_mul_lo_u16andv_pk_mul_lo_u16as 24-bit fields (BitFieldUExtract(raw, 0, 24)). That is what the GPU does, and it also hides the factors' width from AMD's Windows driver, which stores the full 32-bit product when it knows both factors fit in 16 bits (the 16-bit integer multiplies entry inshader.md). #7673 added a fold ofBitFieldUExtract(x, 0, n)intoxwhenxhas no bits at or aboven. When the program has already masked both factors to 16 bits (v_and_b32 v4, 0xffff, v4), that fold removes the 24-bit reads, and the driver is back to(x & 0xffff) * (y & 0xffff) & 0xffffand stores 0xfffe0001 for 0xffff * 0xffff.The folder now leaves a
BitFieldUExtractin place when anIMul32uses it. The fold still applies to every other field read. The debt entry says so.Tested
Windows 11 26200, RX 6700 XT (gfx1031), AMD driver 32.0.21045.5002, Release,
ANYPS5_REQUIRE_VULKAN=1, onmain7d876ad3b:agc_driver_mul_lo_u16_high_halfagc_constant_bit_testIMul32check removedthread 0 (0xffffffff, 0xffffffff, 0x00000000) wrote 0xfffe0001, expected 0x00000001a 24-bit field read that a multiply uses is kept, even for a factor masked to 16 bitsmaina98590decfails the GPU test the same way, andmainwith perf(shader): fold masks, shifts and field extracts through bits they do not use #7673 reverted passes it 3/3.APS5_DUMP_COMPUTE_PIPELINESfor the masked-factors case, the module onmaindiffers from the one with perf(shader): fold masks, shifts and field extracts through bits they do not use #7673 reverted only in the twoOpBitFieldUExtract ... 0 24factor reads (and a repeated& 0xffff), see AGC: agc_driver_mul_lo_u16_high_half fails on AMD's Windows driver since #7673 #8271.agc_constant_bit_testgains two cases that run without a GPU, so CI (lavapipe, which doesn't miscompile this) still catches the fold coming back. One checks that a 24-bit field read of a value masked to 16 bits still folds into the value; the other, that the same read is kept when a multiply uses it.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, layer built from Vulkan-ValidationLayers; withVK_LOADER_DEBUG=layerthis tree's run logsInsert instance layer "VK_LAYER_KHRONOS_validation"),ANYPS5_NO_SHADER_CACHE=1,ctest -Vonagc_constant_bit_test,agc_driver_mul_lo_u16_high_half,agc_integer_narrowingandagc_driver_sdwa_integer_clamp: 0VUID-messages onmaina98590dec(where the GPU test fails as above) and with this PR (4 of 4 pass), and nowas not found but was requestedline.ctest --parallel 4 --timeout 120onmain7d876ad3bwith this PR: 1717 tests, 2 failed:log_macrosandlog_macros_timestamps, because ccache rewrites__FILE__in local builds here.Not tested: other AMD GPUs and driver versions; #8266 has the same failure on an RDNA 2 iGPU with this driver.
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