xshader: initial MODE from PGM_RSRC1, fixture scan for its FSSM location #309
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!309
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/309/head"
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?
@QuentinDanblon on GitHub · 2026-11-23 17:31 UTC · original
QuentinDanblon:pr/f16-omod-initial-mode→main· +945 −16 · 4 files · 3 commits · closed without mergingLibrary / area:
tombox-xshader(hlsl.rs,hlsl/mode.rs,tests/exec.rs),d3d12_xs/src/shader_xlat.rs(one log line per shader hash)Exports changed (exports.txt rows): none
Source of the behaviour:
docs/BLOCKERS.md, "f16 output modifiers depend on the initial MODE" (gfx1036 measurement): an omod on an f16 VALU result acts only with MODE IEEE 0 and f16/f64 denormals flushed.AMDGPUUsagecompute_pgm_rsrc1 table,SIDefines.h) and Mesa (MIT,sid.hS_00B848_*): PGM_RSRC1 field layout, register granules, and that the CP loads FLOAT_MODE / DX10_CLAMP / IEEE_MODE into MODE at wave launch. Facts only, no code taken.What it does
The translator always assumed MODE
0xf0at entry. This PR lets the initial MODE come from the stage's PGM_RSRC1, and reports when it does not have it.mode::mode_from_pgm_rsrc1maps FLOAT_MODE [19:12] to MODE [7:0], DX10_CLAMP [21] to MODE [8], IEEE_MODE [23] to MODE [9]. PRIV, DEBUG_MODE and the register counts are dropped.reachable/analyzestart from that MODE, andtb_hw1(the MODE copy read bys_getregand the f16 omod check) is initialised with it. The f32 and f16/f64 denormal paths follow the same value.hlsl::translate_with_pgm_rsrc1(ex, feeds_ps, rsrc1)for a caller that has the value.0xf0stays the default. Behaviour on main does not change, except for the log line below.Translated.unknowns: Vec<String>, andd3d12_xslogs it once per shader hash (shader_xlat"UNKNOWN hash=...").Finding the location: a fixture test, for whoever has fixtures
hlsl::mode::tests::pgm_rsrc1_candidates_in_every_fssm_fixture, same gating and fixture walk as the #257 RSRC2 test (tombox_fixtures_shaders,analysis/shaders,TOMBOX_SHADER_DUMPS). For each fixture of any stage it counts the VGPRs and SGPRs the ISA names and the wave size, then lists every dword before the ISA preamble that fits as PGM_RSRC1:It prints the dword 4 bytes before #257's RSRC2 (0x12c for sub-version 5, 0x134 for sub-version 6; the hardware registers RSRC1/RSRC2 are consecutive), and per sub-version the offsets that fit every fixture. It asserts no location. It fails only if the reader reads Durango, if a table entry does not fit every fixture, or with "not proven" under two FSSM fixtures. I have no fixtures, so here it is ignored (forced: "not proven: 0 FSSM fixtures").
If someone with fixtures (the people who ran the #257 test) runs
cargo test -p tombox-xshader --release --lib pgm_rsrc1_candidates -- --nocaptureand 0x12c / 0x134 fit every fixture,
PGM_RSRC1_ATcan be filled in a separate PR.Commit 3 (
23b199c): one fixture run should settle the container layoutThe scan now also looks for RSRC2 on every stage and probes two layouts, so a single run on real fixtures can decide where the registers sit. Printing only, no location is asserted, nothing goes into a production table.
Command for anyone with fixtures (
TOMBOX_SHADER_DUMPS=<dir>if they are not underanalysis/shaders):Tests: two new unit tests on synthetic containers (USER_SGPR match with MSB and +8, must-be-zero bits, LDS, per-stage aggregation keeping 0x138/0x134 for compute when a pixel shader has RSRC2 elsewhere; a full descriptor at 0x104, the 0x130 overlap, a code region with 64x1x1, a merged GS). Mutation: ignoring byte 0xD6 makes both fail.
tombox-xshaderlib on WARP: 122 passed, 0 failed, 4 ignored. Gate: 0 problems.Limits: byte 0xD6 is read even when 0xE8 holds no table, where its meaning is not established. PS, GS and HS have no reserved RSRC2 bits on gfx10.3, so their filter rests on USER_SGPR and TRAP/EXCP. Whether a Vertex shader without a slot uses the VS or the GS registers (NGG) is a guess, printed per fixture.
Not covered, not claimed
SPI_SHADER_PGM_RSRC1_*stages and are only checked for compute.For you
hlsl.rs, next tomode::analyze) and #306 (Translatedgetsunknownshere andgather_lod_blindthere). Both are side-by-side additions. I can rebase on whichever lands first.unknownsis generic; #306'sgather_lod_blindis the same idea for one case. If you prefer one mechanism, I can fold #306's intounknowns, in whichever PR lands second.image_mimg_queryintests/exec.rsexpects 3 array layers at level 1, while the gfx1036 measurement indocs/BLOCKERS.md("image_get_resinfo array layers are not minified",max(1, layers >> (BASE_LEVEL + level))) gives 1. The test encodes the current unminified behaviour. I did not touch it; it moves when that OPEN item is done.Tests
On
ba84a79(basef89e410), WARP and RTX 5090 (TOMBOX_EXEC_HW=1), Windows 11.f16_omod_follows_initial_mode_from_pgm_rsrc1(tests/exec.rs), 58 cases:v_add_f16/v_mul_f16with each omod and clamp under 7 PGM_RSRC1 values (f16 denormals kept or flushed, IEEE on or off, DX10_CLAMP, PRIV, DEBUG_MODE and register counts set, all zero), ans_setregafter a flushing or keeping RSRC1,v_add_f32of a denormal under 4 FLOAT_MODE values, and theunknownsline present only without PGM_RSRC1. Passes on both.hlsl::modeunit tests: RSRC1 to MODE mapping; the reader on synthetic sub-version 5/6 containers (table hit, unknown sub-version, location past the ISA, short blob, Durango refused, production table empty); the reachable set seeded by the initial MODE;rsrc1_scan_checks_register_granules_and_reserved_bits_on_synthetic_containers.Mutations: initialising
tb_hw1with0xf0again makes 26 of the 58 cases fail; swapping the wave32/wave64 granules makes the scan unit test fail. Both restored.Full
tombox-xshadersuite on WARP: 350 passed, 0 failed, 19 ignored.pr_gate.py --base origin/main: 0 problems.cargo test -p tombox-xshaderpasses for what is listed aboveNo game or console files and no binaries included
No fake success: nothing is read from an unproven location; the unknown MODE is logged
🤖 Generated with Claude Code
@QuentinDanblon on GitHub · 2026-11-23 18:13 UTC · original
@GDAgent, a request since you have the fixtures (and ran the #257 test): could you run the scan on this branch (
23b199c) and attach or paste the summary at the end of the output?(
TOMBOX_SHADER_DUMPS=<dir>if they are not underanalysis/shaders.) It needs neither #289 nor #257. It uses the user SGPR byte at 0xD6 from #289 as a second, independent key for RSRC2 on every stage, and checks two layouts (AMDHSA kernel descriptor vs code region at 0xC0/0xC8). One run should tell where PGM_RSRC1 sits, whether 0x130 holds in sub-version 5, and where the graphics-stage RSRC2 is, which BLOCKERS lists as not checked. The only things it prints are offsets and decoded register fields.@omonkeyz on GitHub · 2026-11-25 13:49 UTC · original
Applied on main in
4c7c544(cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.Pull request closed