Repository navigation
shader: support BUF_FMT_2_10_10_10_UNORM fetch format in gfx2hlsl (Part of #1723) - #2006
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e05cff2676
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Ran it, broke it four ways — all caught — and checked the unpacking against the DXGI definitionWindows 11 build 26300.9974, device-free: out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_tbuffer_2101010_check.py
DXGI 24 maps to the format: ok
the SNORM sibling stays refused: ok
PASS exit 0
So the field order, the per-field mask and the divisor are each pinned, not only the text. The arithmetic, checked against
|
Merge matrix for the 16 open PRs that touch
|
| pair | overlap | what it is |
|---|---|---|
| #2007 vs #2003 | 923–955 | both add op_s_bfm_b64 |
| #2006 vs #2005 | 87–88 | both extend FETCH_FORMATS (10-10-10-2 UNORM vs 16-16 SNORM) |
But line overlap is only half the story
I merged the overlapping pairs, and then a pair that does not overlap:
#2006 + #2005 conflict: CMakeLists.txt
#2003 + #2007 conflict: AGENTS.md, tests/startup_gfx2hlsl_bfm_b64_check.py (AA), tools/startup/gfx2hlsl.py
#2012 + #1995 order-dependent:
merge 2012 then 1995 -> conflict only in CMakeLists.txt, gfx2hlsl.py merges to ONE op_v_swap_b32
merge 1995 then 2012 -> conflicts in CMakeLists.txt, tests/..._swap_check.py (AA), gfx2hlsl.py
and then BOTH implementations are present in that file
#2012 and #1995 add the same method at lines 1272 and 1304 — far apart, so nothing overlaps, yet they are the same feature. In one merge order
git silently keeps a single definition (one author's behaviour is lost with no marker); in the other it keeps both. Neither outcome is a rebase of
the other, and the reviewer would have to notice by reading the file.
So: line-overlap predicts textual conflicts, not duplicate additions. For a file where 16 people are each adding one handler, the dangerous
case is the one this matrix does not flag, and the two duplicate pairs above (#1995/#2012 on v_swap_b32, #2003/#2007 on s_bfm_b64) are
exactly that.
What I would do with this
- Land one of each duplicate pair first, and tell the other author to rebase onto it (I have already reviewed startup: lower s_bfm_b64 in gfx2hlsl #2007 at behaviour level and startup: lower v_swap_b32 in gfx2hlsl #1995
the same way, so both are safe choices). - For
#2006/#2005, whichever goes second needs a one-line rebase of two adjacent dict entries — trivial, but it will be a conflict rather
than a merge. - Everything else in the table is disjoint: any order among the remaining 12 lands without touching another PR's lines.
The script is 40 lines (merge-base, git diff -U0, range intersection) if you want it as a CI job — but a cheaper version is just "search the
open PR titles for the mnemonic", which would have caught both duplicates before either branch existed.
Applied to this PR
This PR is one half of the #2006 + #2005 overlap: both extend FETCH_FORMATS at lines 87–88, so whichever lands second needs a one-line
rebase of two adjacent dict entries. Nothing else here affects you.
Notes
- AI-assisted analysis, computed on
main7f149ac9.
e05cff2 to
2a92069
Compare
|
I ran an independent device readback against the translator at On WARP and a physical D3D12 adapter, I compiled the generated VS with DXC and invoked the same vertex body from the compute readback wrapper. Sixteen packed vertices at stride 5, offset 3 cover all four byte alignments and all four alpha levels. On each adapter all 64 decoded components and 256 surrounding sentinel words matched. Reading blue from green, dividing alpha by four and replacing the unaligned load with an aligned load each produced a readback mismatch. The existing device-free test also passed. Reproduce with |
2a92069 to
b8daf94
Compare
b8daf94 to
328b603
Compare
|
Thank you @ChazY11 for the four-mutation run and the DXGI cross-check of the unpacking, and @RavenCurseBurg for the independent WARP + hardware readback at AI-assisted; commands listed were executed locally. |
|
Thanks @ChazY11 for the merge matrix, and @RavenCurseBurg for the readback. I merged The diff against On the #2005 overlap: whichever of #2006 and #2005 lands second needs a small rebase of the adjacent Commands run locally on Linux:
The Windows WARP run is still pending on the new head. AI-assisted; commands listed were executed locally. |
|
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is. We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here. AI-assisted; commands listed were executed locally. |
… the descriptor switch (R0Y00#1723) Merge origin/main, add format 50 to DESC_FORMAT_CODES, the runtime supported-format list and the R10G10B10A2_UNORM word-3 mapping, and extend startup_vertex_fetch_formats with a packed-field reference, wrong references and mutations.
|
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
|
|
@MasterDomino: #2006 is ready for review/merge. What changed: merged current main into the branch (one docs conflict in Verification:
AI-assisted; commands listed were executed locally. |
MasterDomino
left a comment
There was a problem hiding this comment.
Reviewed c2320749.
The decode is right:
- x, y and z come from bits 9:0, 19:10 and 29:20, and w is bits 31:30 / 3. That's the R10G10B10A2 layout; llvm-mc 15 encodes
BUF_DATA_FORMAT_2_10_10_10+ UNORM as unified format 50. - Formats 44–49 and 51–55 stay refused.
- The earlier thread replies saying format 50 "decodes the 2-bit X field first" don't match the code or
docs/experiments.md. The code is the correct one.
Three things before merge:
- Cache revision.
mubuf_format's run-time FORMAT switch gainscase 50uin programs that already translate; 8 compute programs from the existing compute checks change. With the shim now accepting code 50, a cached shader from the current revision would return the 0x7fc0f0f0 sentinel.mainis now atx2w-startup-shader-19/19cs(since #2708). Please move both to20/20cs, or one past whatever lands first; the switch is emitted for every stage, so the graphics key moves too. - Runtime-shim regression.
tests/startup_buffer_format_word3_check.cppdoesn't listDXGI_FORMAT_R10G10B10A2_UNORM. Droppingcase 50fromformatted_buffer.h, or the R10G10B10A2 line frombuffer_format_word3.h, still passes that source-built check; only the text-parsing table checks fail. Please add it todecoded[], and check thatview_word3gives50u << 12 | identity. - Docs and description.
docs/experiments.mdstill says no D3D12 draw has been run for the format, butstartup_vertex_fetch_formats_warp/_hardwarenow read it back. The PR description still says Win2025 hasn't been run.
Runs: Windows 11 build 26300; AMD Radeon RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818.
- At
c2320749:ctest --preset dev -R "tbuffer|vertex_fetch_formats|buffer_format_word3|formatted"12/12. Format 50 reads back at stride 6 / offset 2 and through the descriptor path with 0 mismatches, and its three mutations fail. - Neighbours:
-R "startup_gfx2hlsl|startup_compute_|startup_mesh57_formatted"386/389:fma_mix_dispatch_hardware(#2746);startup_compute_dispatch_texture_warp/_hardware, which pass once merged with currentmain.
- On a local merge with
main:startup_vertex_fetch_formats_*stop at a source gate. That gate also fails onmainsince #2596, unrelated to this PR (noted on #2596). - Mutants caught: x/z swapped, alpha from bit 31, SNORM accepted with the UNORM decode, descriptor code 50 → 51, and DXGI 24 dropped. The two shim mutants above survive the source-built check.
AI-assisted; commands listed were executed locally.
R0Y00
left a comment
There was a problem hiding this comment.
Rebuilt the Release renderer and ran all seven format checks. Both WARP and RTX 4060 Laptop passed the packed format draws. The composed main extracts FORMAT and token handling through the shared word3 decoder, and the updated gate check catches clearing that check or skipping the decoder call. The packed normalization and field-order controls continue to run.
|
@R0Y00, thanks. My change request at
AI-assisted. |
…2 in the word3 check Move x2w-startup-shader-19/19cs to 20/20cs (the run-time FORMAT switch gains case 50), update the known-answer keys, add R10G10B10A2_UNORM to the decoded formats and to the view_word3 identity check, and refresh the docs.
MasterDomino
left a comment
There was a problem hiding this comment.
Approving a2e70c73. My change request is resolved.
- Cache revision: it moves to
x2w-startup-shader-20/20cs. No18/19literal is left insrc,toolsortests, apart from the fract check's historical seed comparison. - Source-built shim regression:
startup_buffer_format_word3_check.cppnow coversDXGI_FORMAT_R10G10B10A2_UNORM. Droppingcase 50fromformatted_buffer.hnow fails it:FAIL DXGI format 24: code 50. Restored, it passes again. - Vertex preflight gate: R0Y00's
6e9917f3fixed the gate, so the format-50 readback runs again on top ofmain.
Run at this head (Windows 11 build 26300, --preset dev; AMD Radeon RX 9070 XT, driver 32.0.32029.2010; WARP 10.0.26100.9818):
ctest --preset dev --no-tests=error -R 'buffer_format_word3|tbuffer|vertex_fetch_formats|shader_cache_key|compute_request_offline'10/10 passed, including startup_vertex_fetch_formats_warp and _hardware and startup_gfx2hlsl_tbuffer_2101010.
AI-assisted; commands listed were executed locally.
|
@MasterDomino all three points are fixed at
Win2025 (Windows Server 2025 build 26100, D3D12 WARP), Re-requesting review. AI-assisted; commands listed were executed locally. |
Part of #1723
What this unblocks: vertex shaders whose input layout uses packed 10-10-10-2 UNORM (
DXGI_FORMAT_R10G10B10A2_UNORM) no longer get refused withbuffer format BUF_FMT_2_10_10_10_UNORM.Changes:
tools/startup/gfx2hlsl.py:FETCH_FORMATSgainsBUF_FMT_2_10_10_10_UNORM(x, y, z = 10-bit fields / 1023, w = 2-bit field / 3, one dword read withldu).FETCH_DXGImaps DXGI 24 to it.tests/startup_gfx2hlsl_tbuffer_2101010_check.py(new, registered in CMake): constructed MTBUF bytes, decoded, translated, emitted expressions evaluated against a reference from the format definition. Also checks the SNORM sibling stays refused.Verification:
x2w-startup-shader-20/20cs(the run-time FORMAT switch gainscase 50); known-answer keys updated instartup_shader_cache_key_check.pyandstartup_compute_request_offline_check.py.tests/startup_buffer_format_word3_check.cppnow listsDXGI_FORMAT_R10G10B10A2_UNORMindecoded[]and checksview_word3gives50u << 12 | identity.docs/experiments.mdanddocs/startup-runtime.mddescribe the WARP/hardware draw readback and revision 20.a2e70c73d2b16e42a1bb0adbb016a37507f916da,ctest --preset dev|release -R '^(startup_gfx2hlsl_tbuffer_2101010|startup_buffer_format_word3|startup_vertex_fetch_formats_controls|startup_vertex_fetch_formats_warp|startup_shader_cache_key|startup_compute_request_offline)' --no-tests=error: dev 8/8 and release 8/8 passed. Tests:startup_gfx2hlsl_tbuffer_2101010,startup_buffer_format_word3,startup_buffer_format_word3_mapping_control,startup_buffer_format_word3_table,startup_shader_cache_key,startup_compute_request_offline,startup_vertex_fetch_formats_controls,startup_vertex_fetch_formats_warp.python3 -B tests/startup_gfx2hlsl_tbuffer_2101010_check.pyPASS; the same test against the unmodifiedgfx2hlsl.pyfromorigin/mainfails withUnsupported: buffer format BUF_FMT_2_10_10_10_UNORM.