shader: decode buffer FORMAT 47 (10_10_10_2 SSCALED) from hardware descriptors #3384
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3384
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3382"
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?
@tedin7 on GitHub · 2026-11-28 17:24 UTC · original
tedin7:upprs-sscaled→main· +206 −37 · 25 files · 6 commits · openPart of #870
What this unblocks: buffer_load_format_* from a hardware descriptor whose FORMAT field is 47 (BUF_FMT_10_10_10_2_SSCALED), which was refused as an unsupported FORMAT.
What changed:
tools/startup/gfx2hlsl.py: newBUF_FMT_10_10_10_2_SSCALEDentry (FORMAT 47). Each field is sign-extended and converted to a float without dividing; x is the 2-bit field in bits 1:0, y, z and w are the 10-bit fields above it. No DXGI typed view has this layout, so it is listed inDESCRIPTOR_ONLY_FORMATS.src/startup_stubs/formatted_buffer.h: the runtime accepts code 47.startup_vertex_fetch_sscaled_{controls,warp,hardware}(sixteen elements at an unaligned stride read back bit for bit against a CPU reference, plus mutants for the removed case, dropped sign extension and wrong field order); the sibling format-count check and the word3 table check account for the descriptor-only format.Verification:
python3 -B tests/startup_vertex_fetch_sscaled_check.py controls,python3 -B tests/startup_vertex_fetch_formats_check.py controls,python3 -B tests/startup_buffer_format_word3_table_check.py: pass.66a993b6d:x2w_pipe.py win2025 3382 --host aws-1 --targets offscreen_check,startup_buffer_format_word3_check --regex '^startup_(vertex_fetch|buffer_format_word3)' --force: dev 9/9 and release 9/9 passed (includesstartup_vertex_fetch_sscaled_warpand_hardware).float(int(w << 30) >> 30)->float(uint(w << 30) >> 30)in the SSCALED entry),x2w_pipe.py win2025 3382 --host aws-1 --patch <mutant> --skip-release --regex '^startup_vertex_fetch':startup_vertex_fetch_sscaled_warpandstartup_vertex_fetch_sscaled_hardwarefail (4/6 pass).Draft until an independent peer review and the Win2025 WARP gate pass.
Thanks to @Makto94 for the testing that found this.
AI-assisted; commands listed were executed locally.
@KelboLive on GitHub · 2026-11-28 20:35 UTC · original · approved these changes
LGTM — clean addition for an otherwise unreachable format.
Adds BUF_FMT_10_10_10_2_SSCALED (FORMAT 47) decode to gfx2hlsl.py: four signed fields packed in one dword (x=2-bit, y/z/w=10-bit each), sign-extended and converted to float without division. No DXGI typed view has this layout, so only hardware descriptors reach it. Runtime formatted_buffer.h now accepts FORMAT 47. Test fixture checks 16 elements bit-exact against CPU reference, with mutations (case removed, sign extension dropped, wrong field order) all failing correctly.
Ready to land.
@KelboLive on GitHub · 2026-11-28 21:57 UTC · original · approved these changes
LGTM — clean extension of MTBUF formatted loads to the SRV byte window.
Extends the SRV byte window path to formatted loads (tbuffer_load_format_x).
requires_identity_dst_selthreads from manifest through cache encoding, binder, and dispatch refusal.indirect_table_bufferchecks identity DST_SEL and component mapping before binding.gfx1013_compute_mtbuf.inldetects the zero-stride rewrite and routes throughbyte_window_srv. Writable MTBUF byte windows refuse without a verified view contract. New teststartup_compute_mtbuf_window_check.pycovers identity readback, swapped X/Y refusal, CBV-token refusal, and cold/warm cache manifest equality. Existing tests updated for raw and formatted window loads.Ready to land.
@tedin7 on GitHub · 2026-11-28 21:58 UTC · original
Merged current
maininto this branch (merge commit, no force push); head is now0abb4b208, no conflicts and no change to the PR's own files.Verification (Windows Server 2025, D3D12 WARP, head
0abb4b208):x2w_pipe.py win2025 3382 --regex '^startup_(vertex_fetch|buffer_format_word3)'-> 9/9 passed, includingstartup_vertex_fetch_sscaled_warpand_hardware. The sign-extension mutant from the PR body fails these two tests, as before.KelboLive approved
66a993b6; the only change since is the main merge. Marking this Ready.@MasterDomino ready for review and merge when you have time.
AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-28 21:58 UTC · original · edited 2026-11-28 22:03 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
0abb4b2ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-28 22:03 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
0abb4b2083ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@ -15,3 +15,3 @@switch (code) {case 1: case 5: case 14: case 22: case 23: case 24: case 27:case 29: case 50: case 56: case 60: case 64: case 71: case 74: case 77:case 29: case 47: case 50: case 56: case 60: case 64: case 71: case 74: case 77:@chatgpt-codex-connector[bot] on GitHub · 2026-11-28 22:03 UTC · original
When reusing a shader cache containing an already-translated
buffer_load_format_*pipeline, this gate now accepts FORMAT 47 even though the cached bytecode has no corresponding switch case and returnsDESC_FORMAT_UNKNOWNNaNs for identity selectors. The Python and runtime cache revisions remain unchanged: the source-built MUBUF fixture retains key170fc67bcc26ed98across this commit,load_translation()loads the existing bytecode, andpending_keys()skips complete results. Consequently, upgrading the runtime and translator can replace the previous explicit refusal with incorrect shader results without ever running the new decoder. Bump the synchronized cache revisions or otherwise invalidate existing translations alongside this acceptance change.Useful? React with 👍 / 👎.
@ -170,2 +175,4 @@'BUF_FMT_32_32_FLOAT': 64, 'BUF_FMT_16_16_16_16_FLOAT': 71, 'BUF_FMT_32_32_32_FLOAT': 74,'BUF_FMT_32_32_32_32_FLOAT': 77}# Formats only a hardware descriptor reaches: no DXGI typed view has their layout.DESCRIPTOR_ONLY_FORMATS = frozenset({'BUF_FMT_10_10_10_2_SSCALED'})@chatgpt-codex-connector[bot] on GitHub · 2026-11-28 22:03 UTC · original
This introduces the first descriptor-only decoded format, changing a public capability without the documentation update required by
AGENTS.md. A repository-wide search forSSCALEDandstartup_vertex_fetch_sscaledfinds no README or experiment entry;docs/experiments.mdstill states that the DXGI table equalsDESC_FORMAT_CODES, and its documented vertex-fetch filter excludes the new fixture. Update the capability documentation to explain descriptor-only FORMAT 47 support and provide the new reproduction command.AGENTS.md reference: AGENTS.md:L329-L330
Useful? React with 👍 / 👎.
@tedin7 on GitHub · 2026-11-28 22:21 UTC · original
Both findings are addressed in
025f16dd0(pushed on top of themainmerge, no force push).buffer_load_format_*translation does, so the startup shader cache revisions are bumped fromx2w-startup-shader-29/29csto30/30csin the runtime (d3d12_draw.inl), the native request reader (shader_compute_request.cpp),gfx2hlsl.py,patch_manifest.py, the revision-pinned tests (new known-answer keys, recomputed with an independent FNV, including the framed compute key) and the docs. The archived revision-28 fallback is unchanged. A cache written before this change now has other keys, so it is retranslated. Mutant: reverting only the runtime literal to 29 failsstartup_gfx2hlsl_fract_check("the two literals are identical").docs/experiments.mdnow describes FORMAT 47 as the first descriptor-only decoded format (not in the DXGI table), the field layout, the cache revision bump, and the reproduction commandctest --preset dev --no-tests=error -R '^startup_vertex_fetch_sscaled_(controls|warp|hardware)$' -V.Verification (Windows Server 2025, D3D12 WARP, dev and release, head
025f16dd0):x2w_pipe.py win2025 3382 --regex '^(startup_vertex_fetch|startup_buffer_format_word3|startup_compute_request|startup_gfx2hlsl_(export_null|mul24)|startup_packed_(position|target)|startup_shader_cache|startup_indirect_draw_indexed|startup_resource_retire_title|startup_ui_texture_bands|native_startup_request_cache|native_compile_dxil_rekey|patch_manifest)'-> 44/46 passed. The two failures arenative_startup_request_cache_warpand_hardware("compute dispatch output mismatch"). The same two fail with the revision bump reverted (--patchof the reverse of this commit), so they are not caused by this change; I did not look into them further here.AI-assisted; commands listed were executed locally.
@Leyukaka on GitHub · 2026-11-29 05:57 UTC · original · reviewed
Comment at
025f16dd, no blocking finding. Reading only: the diff and the code around it, against main212d4b5f. Nothing was built or run.Semantics. Code 47 is
BUF_FMT_10_10_10_2_SSCALED(tools/disasm_rdna2.py:1281). docs/experiments.md:6599 says AMD names list fields from the most significant bit, so x is bits 1:0, y 11:2, z 21:12, w 31:22. gfx2hlsl.py:146-147 extracts those fields with an arithmetic>>onintand no division. DST_SEL 1 gives 1.0, since the format is not inDESC_ONE_INTEGER(:181).Scope not in the body.
tbuffer()/load_format()(gfx2hlsl.py:7714-7731) accept anyFETCH_FORMATSname, sotbuffer_load_format_* format:[BUF_FMT_10_10_10_2_SSCALED]is now translated as well. No test covers that path.Cache revision. 29/29cs become 30/30cs in d3d12_draw.inl:393-394, shader_compute_request.cpp:180/191, gfx2hlsl.py:12973/12983, tools/patch_manifest.py:24 and the pinned tests. Side effect: the request readers called by compile_dxil compare against the current revision and 28 only, so a revision-29 capture is now rejected while a revision-28 one is still accepted (shader_compute_request.cpp:295-298, :317-318):
Docs still stale.
DESC_FORMAT_CODES"; the check now addsDESCRIPTOR_ONLY_FORMATS(startup_buffer_format_word3_table_check.py:37).x2w-startup-shader-29bin its example.Tests (tests/startup_vertex_fetch_sscaled_check.py).
expected(order=(1, 0, 2, 3)). Only the reference is swapped, so it shows that x and y differ in the data, which :82 already asserts. The reference decodes withFIELDS(:25), written from the same reading of the name as the translation, so a misread layout would pass on both sides. The layout rests on experiments.md:6599, not on this test.descword3straight into the constants (:68) and never reachesformatted_buffer_supported(d3d12_draw.inl:2677). Droppingcase 47:from formatted_buffer.h is caught only by text matches on the header (:84, startup_vertex_fetch_formats_check.py:299, startup_buffer_format_word3_table_check.py:33). startup_buffer_format_word3_check.cpp:91-92 executes the function for 0, 2 and 77; adding 47 there would cover it.CI. Neither the
prfilter (CMakePresets.json:51) nor the Linux Python list (windows.ymlpython-linux, tests/checks/python-linux) selectsstartup_vertex_fetch_sscaled_*,startup_vertex_fetch_formats_controls,startup_gfx2hlsl_fractornative_compile_dxil_rekey, so the checks on this PR do not run the new tests. The recomputed keys do run there:startup_shader_cache_key(pr filter),startup_compute_request_offlineandstartup_buffer_format_word3_table(windows.yml:304, :389).Merge.
git merge-treeagainst main212d4b5fis clean; main is still at revision 29. #3412 (24755d1f) addskey_parts = G.fnv(b'x2w-startup-shader-29')in tests/startup_gfx2hlsl_ps57in_check.py and compares it withpipeline_key(), and its gfx2hlsl.py hunk edits the lines directly around the revision literal (:12973 here). Whichever merges second has to resolve that hunk and move the test literal to 30.@Leyukaka on GitHub · 2026-11-29 12:50 UTC · original
git merge-tree --write-tree origin/main 025f16dd(main77d1ba4d) conflicts in two files, both from #3450 (ea68a605):tools/startup/gfx2hlsl.py,pipeline_key: main added the slot 57.ps57inparagraph to the docstring, next to the revision line. Resolution: main's docstring with yourfnv(b'x2w-startup-shader-30').docs/experiments/native-startup-request-cache.md: main added thereq_<key>.ps57insentence above the compute line. Resolution: main's sentence with yourx2w-startup-shader-30cs.Also open: #3437 needs a bump of the same revision (main is at
29/29cs), so whichever of the two merges second takes31/31cs.@JohnConnorNPC on GitHub · 2026-11-29 12:55 UTC · original
Review of
025f16ddagainst main77d1ba4d. Verdict: hold (conflicts), with one rebase item nobody has raised yet. The FORMAT 47 decode itself looks right to me. On the default launcher path (X2W_NATIVE_SHADERS_ONLY=1since #3451) gfx2hlsl manifests aren't loaded (load_compute_translation:if (native_shaders_only()) { tr.manifest_retry.found(); return nullptr; }). So the decode reaches-Translateruns only.MUST
git merge-tree --write-tree origin/main 025f16dd, resolvedpipeline_keyas main's docstring plusfnv(b'x2w-startup-shader-30'), then ranpython -B tests/startup_shader_cache_key_check.py.check_slot57_entry:assert gfx2hlsl.pipeline_key(*vector, slot57_entry=entry) == 0x9ffda271506f7dc6→AssertionError.0x7bc40f6441693a1c(no layout) and0xff83a450bf031030(withb"ia\x00\xfe"). I computed them with an independent FNV-1a: it reproduces main's0xa837b162afd547ce/0x9ffda271506f7dc6/0x06315afc32bae986for revision 29, and your0x1fe778b573d7abccfor revision 30.startup shader cache key checks: passed).startup_vertex_fetch_sscaled_check.py controls,startup_vertex_fetch_formats_check.py controls,startup_buffer_format_word3_table_check.py,startup_gfx2hlsl_fract_check.py,startup_compute_request_offline_check.pyandstartup_shader_cache_rekey_check.pyall exit 0.NIT
git grep -n 'startup-shader-29'on the merged tree also findsdocs/experiments/patch-manifests.md:103(x2w-startup-shader-29b), which Leyukaka mentioned. It's only an example, but moving it to 30 keeps the revision grep clean.Checks I ran: Linux, Python 3.13, the pure-Python checks above. No Windows, WARP or GPU run.
AI-assisted.
@tedin7 on GitHub · 2026-11-30 13:57 UTC · original
Merged current
main(077bff3ac) and updated the slot-57 revision-30 cache keys for the merge; targeted Linux shader checks pass locally.@ -15,3 +15,3 @@switch (code) {case 1: case 5: case 14: case 22: case 23: case 24: case 27:case 29: case 50: case 56: case 60: case 64: case 71: case 74: case 77:case 29: case 47: case 50: case 56: case 60: case 64: case 71: case 74: case 77:@tedin7 on GitHub · 2026-11-30 16:37 UTC · original
Revision 30 (already on this branch) changes the graphics and compute cache keys, so results translated before FORMAT 47 support are not reused.
0a7b7b1b9adds a check to tests/startup_shader_cache_rekey_check.py: completed revision 29 results stay pending under the current revision. Linux: startup_shader_cache_rekey_check passes; the revision 29 negative control fails as expected.@ -170,2 +175,4 @@'BUF_FMT_32_32_FLOAT': 64, 'BUF_FMT_16_16_16_16_FLOAT': 71, 'BUF_FMT_32_32_32_FLOAT': 74,'BUF_FMT_32_32_32_32_FLOAT': 77}# Formats only a hardware descriptor reaches: no DXGI typed view has their layout.DESCRIPTOR_ONLY_FORMATS = frozenset({'BUF_FMT_10_10_10_2_SSCALED'})@tedin7 on GitHub · 2026-11-30 16:37 UTC · original
FORMAT 47 is documented in docs/experiments.md with its reproduction commands.
0a7b7b1b9also corrects the table description: the DXGI table agrees with FETCH_DXGI and maps to DESC_FORMAT_CODES, and descriptor-only FORMAT 47 has no DXGI entry.@R0Y00 on GitHub · 2026-12-03 05:53 UTC · original · requested changes
I tried
0a7b7b1bagainstmain8a2f84d1. The four textual conflicts can keep Mesh57 revision 4 and the revision-28 archive reader while changing the startup graphics/compute defaults to 30/30cs. Ingfx2hlsl.py, keepkey = fnv(revision)and changeCOMPUTE_REVISIONto 30cs so callers can still replay revision-28 requests.Two additional blockers appear after those conflicts are resolved. CMake stops at
tests/cmake/shader_compute_request.cmake:43because the graphics-key mutation still matches a revision-29 source literal. Update the anchor to match 30 and keep its replacement at 28. With only the anchor updated, four C++ tests fail because the default request keys are still pinned to revision 29. Updating the following literals intests/shader_compute_request_check.cpp(including repeated uses of the graphics base/IA keys) fixed all four, while the revision-28 and Mesh57 expectations stayed intact:68dd3dd5ec7937e11ac02124c180b873681421e4cb1376db5a87c679916d5dbdb863c429258a6e342160c269f41c14622c7c0048e2be50da2c787348e2bb2b6cab2e2ac5e178f56f02f32d6edefb6d69e3497235e62c7fd6c7b5e0a10ff8bda8de551e26d6dbfad60dbcdd7b9a369e78a8770504ec549e9ffff859707afb9c79On the local trial, the format-47 controls, WARP and RTX 4060 Laptop readbacks, offline compute request and both rekey checks passed (Windows build 26300, MSVC Debug, WARP 10.0.26100.9818, RTX driver 32.0.16.1656). After the key updates the five C++ key/reader/negative-control checks passed. The corrected mutation still catches substituting the revision-28 default. These local edits were not pushed. #3883's revision-31 changes conflict with #3384 when combined, so whichever lands second needs to advance the effective startup revision and update the same test fixtures.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.