Repository navigation
Description
Found while translating every pixel/vertex program pair that an offline pass could carve from a package shader archive, not only the pipelines a startup run happens to create. The census below is what tools/startup/gfx2hlsl.py --pending refuses on that population.
Population
- 1,171 adjacent pixel → vertex program pairs carved from the archive's zlib streams, each written once per recorded root signature (3), so 3,513 requests.
- 132 requests translated and compiled with FXC; 3,381 were refused.
- Counts below are distinct program pairs per refusal. A pair can be refused for a different reason under each root signature, so the column sums to more than 1,171.
Refusals
| Pairs | Refusal | Existing work |
|---|---|---|
| 846 | ds_write_b32 (NGG vertex programs, see below) |
none for gfx2hlsl; #1541 / #1566 cover compute LDS only |
| 215 | s_load through sN holding None |
none found |
| 136 | s_load through sN holding ('ptrhi', ('root', N)) |
none found |
| 118 | descriptor operand s[N:N] holds None |
none found |
| 59 | v_lshrrev_b64 |
lowered in pixel_aot (#964), not in gfx2hlsl; #1703 tests only the 32-bit shifts |
| 9 | v_cvt_f32_i32 with ['mul:2'] |
#1705 / #1707 |
| 3 | operand 'off' |
#1674 / #1676 |
| 2 | numeric use of sN holding descnum |
none found |
| 2 | v_swap_b32 |
lowered in pixel_aot (#771) |
| 1 each | image_gather4_lz, s_bfm_b64, buffer_load_format_x, buffer format BUF_FMT_2_10_10_10_UNORM, buffer format BUF_FMT_8_8_8_8_UINT, buffer format BUF_FMT_16_16_SNORM, operand '|vN|', s_load through sN holding ('ud', N), v_cmp_class_f16, export target mrtz, numeric use of sN holding ptr |
s_bfm_b32 and v_cmp_class_f16 are lowered in pixel_aot (#601, #612) |
The largest group: NGG vertex programs
Every ds_write_b32 refusal is in a vertex program (2,538 of 2,538 refused requests), and every one of those programs has the same shape:
s_sendmsg 0x9(GS_ALLOC_REQ) once;exp target_20(primitive export) andexp pos0, plusparam0… exports;- LDS traffic between barriers: 7,617
ds_write_b32and 7,617ds_read_b32, 12,693s_barrier, and a fewds_read_b64,ds_read2_b32,ds_write_b128,ds_write2_b32,ds_write2st64_b32,ds_write2_b64.
That is the RDNA 2 NGG (primitive shader) form: the wave allocates vertex and primitive export space, exchanges per-vertex values through LDS and exports the primitive itself. A desktop vertex shader has no LDS, no barrier and no primitive export, so this cannot be lowered instruction by instruction. Options to evaluate:
- Recognise the common NGG pass-through pattern (the LDS round trip only moves a lane's own vertex values and the primitive export is the identity triangle list) and drop it, keeping the
pos/paramexports. - Lower NGG programs to a mesh shader, where group-shared memory, barriers and primitive output exist (
SetMeshOutputCountsfor theGS_ALLOC_REQcounts).
Done when
- The NGG group has a decided lowering, with a source-built fixture assembled from documented encodings (not archive bytes) and a negative control, split into its own issue if it is larger than one PR.
- Each "none found" row above has an issue or is explained (for the three provenance refusals: which loads the tracker cannot resolve, and whether a root-constant pointer high word can be resolved from the root signature).
- The rows already lowered in
pixel_aotare either shared withgfx2hlslor have a reason to stay separate.
Not in this issue: pipelines whose programs are DXBC containers in the executable, and pairings that are not adjacent in the archive.
AI-assisted (Claude Code).
Activity
NiiRoZz commentedon Nov 24, 2026
Correction: per-pair recount
The table above counts refusals per request, and every pair was written once per recorded root signature (3). A pair bound with a root signature it does not use can be refused for that reason alone, so the per-request counts mix translator gaps with combinations the title never creates. Recounted per pair:
ds_write_b32(NGG vertex programs, unchanged)v_lshrrev_b64v_cvt_f32_i32 with ['mul:2'](#1705 / #1707)operand 'off'(#1674 / #1676)image_gather4_lz,s_bfm_b64,operand '|vN|'s_load through sN holding None(138 pairs),s_load through sN holding ('ptrhi', ('root', N))(136),descriptor operand s[N:N] holds None(15), and single pairs forv_swap_b32,v_cmp_class_f16,buffer_load_format_x, three buffer formats,export target mrtzand thenumeric userefusals. Because these depend on which root is supplied, the provenance rows are most likely root mismatches, not tracker gaps. They should be re-measured with the root each pipeline actually uses before they are treated as translator work.The NGG group and the root-independent rows stand. The "Done when" item about the three provenance refusals becomes: measure them per pipeline with its own root signature first.
Reproduction: the offline request writer and the parallel
--pendingscan used for this census are in the pull requests linked from this issue.AI-assisted (Claude Code).
R0Y00 commentedon Nov 24, 2026
Use the corrected per-pair census. Please measure the descriptor/provenance refusals again with each pipeline's observed root signature before assigning them as translator bugs. For NGG, the LDS/barrier/primitive-export pattern is a classification, not proof it is an identity pass-through. A useful first slice would be a source-built identity triangle and a contrasting case with a cross-lane dependency or non-identity primitive, comparing positions, parameters and primitive indices. Keep production lowering open until those cases separate cleanly. Smaller root-independent instruction gaps can proceed separately.
NiiRoZz commentedon Nov 24, 2026
Agreed on all points. The plan:
s_load … holding None,ptrhianddescriptor operandgroups per pipeline with the root signature that pipeline was observed with, from run captures. I won't treat them as translator gaps until then. The offline request writer (startup: write shader requests from the shader archive before a run #1750) currently writes each pair once per recorded root, which is exactly the confound you point out.v_lshrrev_b64(56 pairs), theimage_gather4_lz,s_bfm_b64and|vN|singletons.v_cvt_f32_i32 mul:2andoperand 'off'stay with startup: accept output modifiers on float-result conversions #1707 and startup: translate the SMEM offset 'off' as the literal 0 in gfx2hlsl #1676.AI-assisted (Claude Code).
NiiRoZz commentedon Nov 24, 2026
Results for items 1 to 3 of the plan above, re-measured pair by pair on
mainat67319a17(all 1,171 pairs under every recorded root; nothing from an older translator commit is mixed in).1. Per pair. 1,171 pairs are 964 distinct code pairs (they differ only in the program header). 104 translate and compile under the census's three roots, as before. 846 have an NGG vertex program, classified from the instruction stream rather than from the first refusal.
2. Provenance refusals with observed root signatures.
s_loadwith a register offset through the resource heap. That one is a real tracker gap.3. NGG, classification only. 602 distinct programs, 324 distinct LDS/barrier/message/primitive-export shapes. In a linear slice of each program: the primitive payload depends on loaded memory in 602 of 602, LDS addresses are lane-invariant in 602 of 602, and 31 pairs also use readlane/writelane/permlane. None fits "own-lane values plus identity primitive". This comes from slices that ignore branches (one program read by hand), so culling, compaction and primitive count versus allocation are still open. Proposed first slice, as specified in the comment above:
GS_ALLOC_REQwith constant counts; each lane exports a position and one parameter computed from its own lane index; lane 0 exports the primitive (0, 1, 2); optional LDS write and read-back at a lane-dependent address.4. Root-independent instruction gaps, with ownership checked today. For rows with an open PR, that PR's head was run on the affected pairs: it removes its own refusal everywhere, but most pairs then stop at the next gap.
v_lshrrev_b64buffer_store_dwordx3buffer_store_dwordx3(behind the row above)v_readfirstlane_b32without a proven uniform sources_bfm_b64v_subrev_f32_dppv_cndmaskwith NEG on an immediatev_mul_hi_u32pos1BUF_FMT_16_16_16_16_FLOATThe
v_cvt_f32_i32 mul:2row is fixed by merged #1707. A tail of one to four pairs each remains (class compares, bit tests, a few buffer formats and export targets). The translator stops at the first refusal, so gaps behind it are undercounted.Not in the original census: translations that compile but cannot draw correctly.
a16image addressing is ignored byimage_load/image_sample: 3 translating pairs.AI-assisted (Claude Code).
Leyukaka commentedon Nov 24, 2026
Claiming three of the root-independent rows from the table above.
1.
v_readfirstlane_b32without a proven uniform source, straight-line slice: #1931.v_cvt_i32_f32of a fixed buffer word marks a VGPR uniform.v_cvt_u32_f32,v_cvt_i32_f32,v_cvt_f32_ubyte0,v_mul_f32,v_fma_f32,v_fmaak_f32,v_rcp_f32,v_mov_b32). Every source must be a constant, user data, a fixed buffer word, a scalar value not derived from a lane mask, or an already-uniform VGPR.exec, a single SGPR destination), and test: pin two integer-op refusals in the translator #1780's refusal cases keep refusing.2.
v_cndmaskwith NEG on an immediate: #1932.-1.3.
buffer_store_dwordx3: design first.gfx2hlslhas no store handler, andsrvis the manifest's only resource-view line, so a store needs both halves. Whether the 84 pairs in the table use the form below is not measured yet. Proposed first slice, for review before any code:buffer_store_dwordto_dwordx4in theoffform (scalar byte offset plus immediate), through a fixed root-table descriptor, asRWByteAddressBufferStore*. These stay refused:glc,slcanddlc;offenandidxen;uav <slot> table <param> <byte offset>line under anx2w-manifest 2header. The runtime reader does not check the version line today and ignores lines it does not know. So the same change makes it read the version and reject an unknown version or line. It also bumps the shader cache revision (x2w-startup-shader-5), so an older runtime never loads a store translation.d3d12_draw.inl):CreateUnorderedAccessViewover the resolved backing buffer, only when that buffer is UAV-capable and authoritative for later accesses;x2w-manifestformat and the translated root signature (create_translated_root). This overlaps startup: cache translated graphics pipelines #1641 and startup: apply stream rasterizer state on translated draws #1567 ind3d12_draw.inl; the merge order is to agree.Does this split, translator and runtime landing together behind version 2, match what you want?
Environment: Windows 11 build 26300, Python 3.14.10, MSVC 14.44.35207.
AI-assisted.
NiiRoZz commentedon Nov 24, 2026
Correction to the NGG figures in my earlier comment here. They came from a register-sensitive hash and from slices that ignored branches. A control-flow-aware re-analysis of the same 602 programs (846 pairs), with 13 programs re-read by hand in an independent review, changes three statements:
Confirmed
s_barrier; other waves read them back withv_readfirstlane. The wave-0 guard is resolved in 593 of them (591 automatically, 2 by hand) and inferred in the other 8. So the LDS traffic is a group-wide broadcast of scalars, not per-vertex data.GS_ALLOC_REQis sent withm0 = P<<12 | V, both counts loaded from memory (601).tid < Vand primitive exports totid < P(602).min(V-1, idx)with no flag bit ORed in (602).Inferred only
The 1 program with lane-dependent LDS addresses is different in kind: it reads LDS at addresses other lanes wrote, after a barrier, which looks like a real cross-lane exchange.
By pairs: 582 plain, 261 in the group of 176, 2 reduction, 1 lane-dependent.
First slice. A source-built check is ready locally: six cases (identity, LDS broadcast, reversed primitive, null primitive, two waves, masked ALU) assembled from documented encodings, anchored to literal values from the public LLVM and Mesa sources, run by a reference model in both wave orders and compared under three interpretations. Group-shared LDS matches every case. Lane-private LDS with counts honoured differs only where LDS carries data. Lane-private LDS with counts ignored differs in every contrast case except the masked-ALU one. It covers these three interpretations only and says nothing about a production lowering. I can open it as a PR if that is useful.
AI-assisted (Claude Code).
JB2WIN commentedon Nov 24, 2026
Taking the
v_swap_b32row (2 pairs) fortools/startup/gfx2hlsl.py. It is already lowered inpixel_aot(#771), where both destinations take the old value of the other register: read both sources first, then write both. Evidence: a device-freetests/startup_gfx2hlsl_*check in the style of the existing ones, with a self-swap, a swap whose destination is read again later, and refusal controls for modifiers and DPP/SDWA spellings. I'll leaves_bfm_b64andv_cmp_class_f16for a separate PR each, if no one else wants them.AI-assisted (Claude Code).
coordination: claim startup/gfx2hlsl-swap (v_swap_b32 in gfx2hlsl, R0…
startup: source-built NGG identity and contrast cases with a referenc…
startup: NGG cases report real interpretation outputs; decode control…
startup: NGG cases pin encoder words to golden vectors; null bit stat…
startup: NGG cases anchor field layouts to public sources; wave order…
startup: NGG cases credit the s3 location of the wave info to mesh_en…
startup: NGG cases gain a binary mode that reassembles them with llvm-mc
Leyukaka commentedon Nov 24, 2026
Dated snapshot (2026-11-24) of every refusal site, not only the first, from the
--refusalsdiagnostic in #1978, run onmainat889cd3f4plus that PR.Input.
Caveats.
holding desc/ptrrows likely are).psunless noted)s_load with a register offset through ('resheap',)descriptor operand s[N:N] holds Nones_bfm_b64v_fma_mix_f32operand 'src_scc'operand '|vN|'s_bitcmp1_b32/s_bitcmp0_b32v_readfirstlane_b32 requires a proven uniform sourcenumeric use of sN holding desc/holding ptrs_addk_i32/s_mulk_i32v_add_f32_dpp/v_add_nc_u32_dpp/v_sub_f32_dppv_cube{ma,sc,tc}_f32/v_cubeid_f32/image dimension SQ_RSRC_IMG_CUBEs_bitset1_b32s_nor_b32/s_nand_b32on a lane maskexport target nullimage_sample_c_lzsampler: unsupported mip filterv_med3_i32s_lshl1_add_u32What the counts show.
#1978 produces the same table for any cache, and with #1750 for an archive-written one.
AI-assisted.
262 remaining items
shader: support 64-bit source operands in gfx2hlsl (Part of #1723) (#…
tedin7 commentedon Nov 26, 2026
Claiming: the pixel-stage resource-heap image record in
gfx2hlsl.py:s_load_dwordx8at a register offset (index shifted left by 5) through the resource heap, with the index read from a table buffer word as the compute form of #2580 already models (translator and manifest first; runtime binding as a separate slice). Draft PR soon.Claiming:
image_gather4_lzwith a repeat (wrap) sampler ingfx2hlsl.py(CLAMP_X / CLAMP_Y of 0 for the native Gather form; WARP readback at the u/v = 0 and 1 edges). Draft PR soon.AI-assisted; commands listed were executed locally.
startup: treat wave32 vcc_hi as an ordinary scalar register in gfx2hl…
startup: spill lane masks to VGPR lanes in compute
shader: support BUF_FMT_2_10_10_10_UNORM fetch format in gfx2hlsl (Pa…
tedin7 commentedon Nov 26, 2026
Claiming: raise the mesh parameter range from param0..12 to param0..31 (ISA 10.2; the 32-vector D3D12 budget still applies) in mesh_param_link.py and the mesh export recognizer, with a param18/param28 pairing draw (Draft PR soon).
AI-assisted; commands listed were executed locally.
startup: refuse a lane mask read as numeric data by the remaining ALU…
tedin7 commentedon Nov 26, 2026
Claiming: NVIDIA pipeline-creation failure (
NVVM compilation failed: 3) in the buffer_store_format xyzw store helper of gfx2hlsl (Draft PR soon).AI-assisted; commands listed were executed locally.
tedin7 commentedon Nov 26, 2026
Releasing all of our open translator claims in this issue. We withdrew the related Python gfx2hlsl PRs because translation is moving to the native C++ frontend (see #870): #2030 #2079 #2096 #2741 #2745 #2747 #2755 #2758 #2760 #2761 #2763 #2772 #2784 #2786 #2789 #2791 #2792 #2793 #2796. Anything we claimed here that is not already merged is free for anyone to take. The branches stay available if any part is useful.
startup: spill descriptors, pointers and lane masks to VGPR lanes in …
shader: clear the lane-mask mark on scalar writes of descriptor data …
mumba17 commentedon Nov 26, 2026
Held locally during the C++ rewrite: low-half readers of a plain
v_interp_p2_f16result, plus two notesI'm not opening a PR, since translator work is paused for the C++ frontend. This is in case any of it is useful there.
1. Low-half readers (local branch, not pushed).
interp_f16_scancurrently accepts onlyv_cvt_f32_f16as a reader of a plainp2destination. The branch also accepts:v_fma_mix*source withop_sel_hiset andop_selclear (a binary16 low half;Stage.mixalready lowers it asf16tof32of bits 15:0);v_pack_b32_f16source whoseop_selbit is clear (lowered with a0xffffmask).v_fma_mix_f32andv_pack_b32_f16also define their whole destination. The high half, a binary32fma_mixsource and av_fma_mixlo/hi_f16destination stay refused. It overlaps tedin7's withdrawn #2789 (samefma_mixrule) and addsv_pack_b32_f16.Tests: four accepted/refused variants in
startup_gfx2hlsl_interp_f16_check.py, hand-encoded and checked with the translator's decoder (llvm-mc 15binarymode not run locally). Draws on WARP and RTX 3090 (driver 32.0.16.1664, Windows 26300): thefma_mixstage exports 1.5 from the low half ofattr0.x, thepackof theattr0.xhalves exports the vertex word0xc0003e00, and a mutant of each must fail.ctest -j 1 -R "mesh57|mesh_cbv_order|startup_gfx2hlsl": 342/342 at d4dfe97.2. Soundness gap on main (found by tedin7 in #2789, confirmed at d4dfe97).
parse('exp mrt0 v4, v5, v5, v5 done vm')returns operands['mrt0 v4', 'v5', ...], so the scan never sees the first exported register. A plainp2result exported only as channel x is not checked for its undefined upper half.3. Counts from a local capture (RTX 3090, counts only). 95 distinct slot 57 G-buffer pixel programs, lowered alone through
MeshPixelStageafter #2824:s_loadwith a register offset through the resource heap: 47v_fma_mix(38) orv_pack_b32_f16(1) read of ap2result: 39sampler from a descriptor: 6; other: 3With the low-half rule, 2 of the 39 stop next at a
v_mul_f16read of the upper half, and 37 at "unmodelledv_interp_p2_f16result across a branch". The scan carries no state across branches, so a C++ design that tracks the defined half per register across blocks would cover them.@R0Y00 do you want any of this as notes or tests for the C++ frontend, as a PR against the Python translator, or not at all? I'll hold it until you say.
AI-assisted (Claude Code).
shader: accept SGPR, hex literal and zero sources in gfx2hlsl packed …
SimSalabimse commentedon Dec 1, 2026
I'm picking up the native side of this: the gfx1013 native graphics frontend still refuses NGG-style vertex shaders (LDS
ds_write_b32/ds_read,v_mbcnt,s_sendmsgGS alloc,s_barrier) as a graphics wave/control-flow instruction, and it's the top refusal in my runs.Plan: recognise the pass-through NGG VS shape only (lane-private LDS slots with a disjointness proof along the lines of tedin7's earlier work, alloc counts equal to the wave counts, identity primitive export) and lower it to a plain VS. Anything not proven stays refused with a specific reason. Linux tests with identity and contrast cases via llvm-mc. I have a first version on my fork (branch local/ngg-vs-passthrough) with Linux tests; it gets a Windows run next, then a draft PR.
Draft PR: #3711
AI-Assisted