tombox-xshader: rebuild image descriptor words read by ALU from the bound view #381
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!381
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-381"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@SchmashinPrunes on GitHub · 2026-11-25 14:44 UTC · original
SchmashinPrunes:desc-words-from-view→main· +295 −1 · 4 files · 1 commits · openThis is the translator fix proposed under the OPEN entry "Trackmania video boards black" (r32j_2 root cause) in
docs/BLOCKERS.md: synthesise descriptor words read by ALU fromGetDimensionsof the bound resource, and fail loudly on fields that can't be rebuilt. That entry names an owner (a2a4751). If that work is already in progress, close this one.The bug
A T# loaded from a root table is resolved statically.
hlsl.rsemits only// (descriptor fetch from root table — resolved statically)and never writes the destination SGPRs. A shader that also reads those words as data gets 0. The downsample compute shaders in that entry take the destination size from the width/height fields of dword 2 andBASE_LEVELof dword 3, so the size comes out as 1x1 and every thread samples one texel.The change
New module
hlsl/desc_words.rs:Recording the reads. In the resource pass, every ALU read of a word of a static image descriptor is recorded with the bits it uses.
s_bfe_*/v_bfe_*with constant fields,s_and_b32/v_and_b32with a constant mask, ands_lshr_b32/v_lshrrev_b32by a constant give exact bits; any other read counts as all 32 bits. Not counted as reads:s_mov,s_cmov);Rebuilding the words. At the descriptor load, if an image instruction resolved that descriptor to
texN/uavN, the words that are read get written fromGetDimensionsof the view. Field positions are from Mesa's gfx10 register tables (SQ_IMG_RSRC_WORD*) and itsac_build_gfx10_texture_descriptor. Values are relative to the view, the same convention the translator already uses for mips:WIDTH_LO[31:30]WIDTH_HI[11:0],HEIGHT[27:14]RESOURCE_LEVEL[31]BASE_LEVEL[15:12]LAST_LEVEL[19:16]TYPE[31:28]DEPTH[12:0]BASE_ARRAY[28:16]ARRAY_PITCH[3:0]MAX_MIP[7:4]LAST_LEVELRefusing the rest. A read of any other bits is refused, and the error names the field and the instruction. Those fields are the base address,
MIN_LOD,FORMAT,DST_SEL,SW_MODE,BC_SWIZZLE,PITCH_MSB, the dword 5 hardware fields, the metadata words, and cubeDEPTH. The PC view doesn't carry any of them. Durango (GCN) shaders are untouched, since their T# layout differs.Not covered
Behaviour change to check against the corpus
A shader that reads one of the fields above used to translate and silently get 0. It now fails to translate. The likely case is a null-texture test that compares the base address with 0. Before this change such a test always took the "null" branch. Running the title corpora will show how many shaders that affects.
Tests
New
tests/exec_mem/desc_words.rs:image_descriptor_words_read_by_salu_come_from_the_view: 7 pixel-shader cases. Each loads the T#, binds it withimage_get_resinfoorimage_load, then extracts the fields with SALU the way a compiler expandsGetDimensions: width rebuilt fromWIDTH_LO | WIDTH_HI << 2, height,LAST_LEVEL,TYPE,BASE_LEVEL,DEPTH,BASE_ARRAYandMAX_MIP. Images:WIDTH_LO);image_descriptor_fields_without_a_pc_source_are_refused: reads ofDST_SEL, the base address,FORMATandSW_MODEare refused with the field named; an in-place edit of dword 3 still translates.Results (Windows 11, DXC from
TOMBOX_DXC_DIR):hlsl.rschangetombox-xshadersuiteTOMBOX_EXEC_HW=1), execThe PR gate is clean.
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.