Repository navigation
xshader: fix swapped GFX10 FLAT load_dwordx3/load_dwordx4 opcodes - #7
Open
marquezinii wants to merge 1 commit into
Open
marquezinii wants to merge 1 commit into
marquezinii wants to merge 1 commit into
Conversation
The FLAT/GLOBAL table had the two swapped. GFX10 uses the same order as MUBUF (LLVM FLATInstructions.td, FLAT_Real_Base_gfx10 and FLAT_Real_AllAddr_gfx10). A global_load_dwordx3 from a code-section table was translated as four loads and also overwrote the register after its destination range; a dwordx4 load left its last register unwritten.
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.
The FLAT mnemonic table mapped opcode
0x0etoflat_load_dwordx3and0x0ftoflat_load_dwordx4. On GFX10 it is the other way round, in the same order as the MUBUF table in the same file (0x0edwordx4,0x0fdwordx3). Source: LLVMllvm/lib/Target/AMDGPU/FLATInstructions.td,FLAT_Real_Base_gfx10<0x00e>/<0x00f>and the matchingGLOBAL_*andSCRATCH_*_gfx10entries.The translator takes the dword count from the mnemonic, so the code-table load path (
s_getpc_b64+global_load_dword*) got it wrong both ways. A dwordx3 load read four dwords and also wrote the register after its destination range. A dwordx4 load left its last register unwritten.The fix swaps the two entries.
Verification
New test
global_load_dwordx3_and_dwordx4_write_their_own_register_countintests/synthetic.rs. It translates a small compute program (s_getpc_b64, twov_mov_b32,global_load_dwordx{4,3} v[4:..], v[0:1], off) for each opcode, then checks which ofv4..v7the HLSL writes and what the decoded mnemonic is.masterat 4f66ea9flat_load_dwordx4 (op 0xe) and v7,left: false, right: trueOn this branch,
cargo test --locked --release --workspacepasses (synthetic: 16 passed, 1 ignored). The CI DLL build (-p d3d12_xs -p xmem -p xcrdapi -p acphal -p dxcompiler_xs -p mfplatwith+crt-static) also succeeds. I ran both on Windows 11 with rustc 1.99.1, not the 1.100.0 that CI pins.I didn't run this against game shaders, so I don't know how many shaders in the packages use either opcode.