tombox-xshader: offline fallback for shaders without RTS0 / memory-based root ABI — would this be welcome? #142
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#142
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@AntonioEspana on GitHub · 2026-11-22 15:17 UTC · original
Hi! I'd like to contribute to the shader translator and want to check the direction with you before writing code.
Current state (as I understand it, main @
c95a909)hlsl.rs:1861: "mubuf ... missing root signature for descriptor table"hlsl.rs:2152: "s_buffer_load ... missing root signature"xshader_prelaunch.rs:99marks MS/AS without RTS0 asRuntimeOnly, waiting for the PSO root signature at runtime.FORCE_MEMORY_BASED_ABIroot arguments read throughs[0:1]are not modelled.global_bind::refusal; no GPU-VA-to-resource map yet).Idea
A fallback translation mode for shaders whose root signature is unknown, or which use the memory-based root ABI:
s_load*/s_buffer_load*are resolved at runtime (bindlessResourceDescriptorHeapindex or a GPU-VA window lookup, extendingglobal_abi.rs), instead of statically per HLSL register.FORCE_MEMORY_BASED_ABIroot signatures.This would let offline/prelaunch translation (and the shader-compile hitches noted in BLOCKERS) cover shaders that are
RuntimeOnlytoday. It would also give the memory-based root ABI a translation path.Prior art
ivall/xcl takes a similar approach: user SGPRs and memory as generic runtime buffers, which lets it translate its whole sample pack. Its draw-time binding is unfinished too. XCL is GPL-2.0-only, so I would not copy any code. I would only use it as a reference for the approach and record it as "reference only" in THIRD_PARTY/CREDITS, like xvdtool.
Constraints on my side
I don't own a console or any dumps, so I can only validate with synthetic shaders (the RDNA2 assembler in the tests) and WARP tests. Real-title verification would be on your side.
Questions
hlsl/rootmem.rs/hlsl/global.rs, or in a new module?FORCE_MEMORY_BASED_ABIroot-argument path, or one of the other refusals listed in BLOCKERS (ds_swizzleoutside PS, atomic MUBUF with SGPR SOFFSET).@omonkeyz on GitHub · 2026-11-22 15:19 UTC · original
Thanks for asking before writing code, and for keeping XCL as a reference only. I've passed this to the shader-translator owner and will follow up here with an answer on the direction, the module location and a good first step.
@omonkeyz on GitHub · 2026-11-22 15:22 UTC · original
Answer from the shader-translator owner:
This fits as long as it's an opt-in fallback. The static RTS0 path stays the default, and the fallback is selected only when a shader has no RTS0 or uses the memory root ABI.
hlsl/rootmem.rs. Keepglobal_abi.rsfor the shared GPU-VA window and heap-index plumbing, and don't growglobal.rs.s[N]from that buffer gets the same values as the static path.Looking forward to the PR!
@enderrr9 on GitHub · 2026-11-23 18:05 UTC · original
I'd like to take step 2 for the memory-based root ABI, unless @AntonioEspana is already on it.
Context: #313, #315 and #316 cover amplification shaders on the
rootmem.rspath:The next gap there is that
rm_paramgives up at the firstTableroot parameter, so any root signature with a descriptor table refuses everything after it.Two questions before I write code:
FORCE_MEMORY_BASED_ABI, read throughs[0:1]), what does a descriptor-table parameter occupy on the console? Is it one dword (a heap index or offset) or two (a GPU VA of the first descriptor)? And is its slot size the same as for a root descriptor? If it's in your xgs12_10d notes, the layout alone is enough.global_abi.rsuses)? And should anything not provable from the root signature's ranges be refused at translate time?I'd keep it opt-in as you described, with synthetic WARP tests like the rootmem compute tests.
@AntonioEspana on GitHub · 2026-11-23 18:38 UTC · original
Not on it. Go ahead.
Those two questions are for omonkey: I don't have the console notes and can't answer the layout. One thing in case it helps:
user_data_abi::packin my PR counts a table as one dword and a root descriptor as two. That mirrors the static user-SGPR mapping (root_param_at), not anything verified for root memory, so please don't take it as evidence for the root-memory layout.@nineforge0 on GitHub · 2026-11-24 08:12 UTC · original · edited 2026-11-24 23:13 UTC
Regarding the open question about descriptor-table parameter sizes in console root memory:
We parsed the FSSM root layouts of all 9,282 mesh shader programs and 2,647 compute shaders from the retail shader database (
shaders.rpfentry 0). The data confirms:This matches the assumption in
user_data_abi::pack(table = 1 dword, root descriptor = 2).All mesh shaders start their root parameters at s8 (graphics) or s4 (compute). The layout is highly uniform: a single rootmem implementation handling 7 parameter types (Table, Descriptor, Constants, ResourceHeap, SamplerHeap, plus the two shadow variants) covers 100% of mesh shaders.
Full analysis and reproduction instructions: https://github.com/nineforge0/forge9/blob/main/docs/mesh_shader_binding_model.md
Tool:
forge9 fssm shaders.rpf 0 --roots(from forge9).Edit: the source is the title's shader database (
shaders.rpfentry 0), not the pipeline cache (entry 1). The numbers are unchanged.