Repository navigation
Backlog
Labels
priority: P0Highest project priority
Description
Small, independent lowerings in tools/startup/gfx2hlsl.py, pixel stage. Each item can be taken by one person as its own pull request. They were found on pixel programs that are paired with mesh programs (#1760), so a pair is only usable when both stages translate.
Items (pick one, say so in a comment)
| Item | What is refused today | Notes |
|---|---|---|
| A | s_pack_hh_b32_b16 |
SOP2; packs the high halves of both sources into one 32-bit result. Check the operand order against the LLVM AMDGPU definition. |
| B | v_subrev_f32 with a DPP control |
Appears to be the quad-permute derivative idiom with the operands reversed; confirm from the encoding first. |
| C | v_interp_p1ll_f16 / v_interp_p2ll_f16 |
16-bit interpolation pair. #1926 prints the VINTRP selector; the f16 forms have no lowering. |
| D | image_sample_b |
LOD-bias sample. |
| E | Pixel-stage entry registers (SPI inputs) beyond the fixed-point position | The input-enable word selects which values the stage receives in its entry VGPRs: perspective and linear barycentrics at sample / center / centroid, position x/y/z/w, front face, ancillary bits, sample coverage. Only the fixed-point position is lowered. Each enabled input needs its HLSL equivalent, and a check that the entry registers a program reads match the enabled set. |
| F | image_store in a pixel stage |
Related to #1545 (compute); the pixel-stage path refuses separately. |
What a pull request needs
- One item per pull request.
- A source-built or hand-assembled fixture (no bytes from any retail software), with a negative control that fails when the lowering is disabled.
- The semantics cited from LLVM or Mesa in the commit message.
- The existing
tests/startup_gfx2hlsl_*_check.pyandtests/startup_translator_check.pystill passing. - A refusal that stays is better than a wrong translation: refuse precisely what the change does not cover.
Where the numbers come from
Aggregate counts from a private corpus, a sample of 1,500 mesh + pixel pairs: A 44, B 38, E 38, C 18, F 8, D 6 pairs stop at these refusals in the pixel stage. No shader bytes, keys or logs can be shared; a source-built fixture is the only acceptable input.
Related: #1723 (refusal census), #1760 (mesh programs), #1545, #1926.
Metadata
Metadata
Assignees
Labels
priority: P0Highest project priority
Activity
[-]help wanted: gfx2hlsl pixel-stage lowerings in small batches (s_pack_hh, v_subrev_f32 DPP, v_interp f16, image_sample_b, SPI inputs)[/-][+]help wanted: GPU translation, part 1 (pixel shaders)[/+]avt0m4t48 commentedon Nov 24, 2026
I’ll take item A,
s_pack_hh_b32_b16, in the startup pixel translator. I’ll use a source-built fixture with distinct source halfwords and a negative control for the operand order.JB2WIN commentedon Nov 24, 2026
I'll take item B,
v_subrev_f32with a DPP control, in the startup pixel translator. First I'll confirm the form from the encoding and LLVM 15: which DPP controls appear, whether it is the quad-permute derivative idiom, and whatbound_ctrland the row/bank masks are. Then the lowering will cover exactly the controls that are established, with a source-built fixture that uses distinct per-lane values, the reversed operand order, and a negative control for a wrong lane pattern. Any other DPP control stays refused.AI-assisted (Claude Code).
coordination: claim startup/gfx2hlsl-subrev-dpp (v_subrev_f32 DPP in …
JB2WIN commentedon Nov 24, 2026
Findings for item B (
v_subrev_f32with DPP) before any code. Nothing is built yet.Semantics.
pix[n].srca = pix[(n&0x3c) + sel[n%4]].srca. DPP applies to src0 only, and the row and bank masks gate the destination write.V_SUBREV_F32isD = S1 - S0.Mesa ACO's derivative idiom (
aco_instruction_selection.cppatmesa-24.0.0,ddx_fine) is two instructions:tl = v_mov_b32_dpp src quad_perm:[0,0,2,2], thenv_sub_f32_dpp dst, src, tl quad_perm:[1,1,3,3], i.e.tr - tl.ddy_fineis the same with[0,1,0,1]and[2,3,2,3].The single-register form
v_subrev_f32_dpp vD, vS, vS quad_perm:[...]is not a fine derivative. It givesD(n) = S(n) - S(perm[n%4]), which is 0 in one lane of each pair. With[0,0,2,2], for example, the left lanes get 0 and the right lanesx1 - x0.gfx2hlsl has no lane model, so a lane-dependent result like this cannot be expressed in SM 5. A derivative mapping is only exact for the two-register form, where src1 provably comes from a
v_mov_b32_dppof the same unchanged source.Encodings (LLVM 15.0.7, gfx1013):
v_subrev_f32_dpp v1, v0, v0 quad_perm:[1,1,3,3] row_mask:0xf bank_mask:0xf0A0200FA FF00F500quad_perm:[0,0,2,2]FF00A000bound_ctrl:1-v0disasm_rdna2.pydecodes all of these, and gfx2hlsl refuses them asv_subrev_f32_dpp.@bigdog, which shape do the 38 pairs use? Without bytes, three things would be enough:
quad_permthe instruction carries;v_mov_b32_dppof the same source comes right before it.If it is the two-register pair, I would lower exactly that fused pair to
ddx_fine/ddy_fineand refuse everything else. If it is the single-register form, it needs a lane model and is a bigger item.AI-assisted (Claude Code).
JB2WIN commentedon Nov 24, 2026
I'll also take item D,
image_sample_b(LOD-bias sample), next to the existingimage_sample/image_sample_llowering, asSampleBiasin the pixel stage. The bias comes first in the address registers, as in the RDNA 2 MIMG address layout; I'll cite the ISA and Mesa for the operand order. Evidence: a check in the style ofstartup_image_sample_l_check.py, plus refusals for the forms not covered (_b_cl,_c_b, offsets, a16 and a non-pixel stage).AI-assisted (Claude Code).
coordination: claim startup/gfx2hlsl-sample-b (image_sample_b, R0Y00#…
Ybucaille commentedon Nov 24, 2026
I'll take item C,
v_interp_p1ll_f16/v_interp_p2ll_f16, in the startup pixel translator. I'll check the semantics against LLVM 15 and Mesa first (high/low half selection, rounding), then add a source-built fixture with a negative control that fails when the lowering is disabled. Forms outside what the fixture covers stay refused.AI-assisted.
R0Y00 commentedon Nov 24, 2026
Item A is implemented in #2014, now on main at 481a1c6. The independent operand-order and unchanged-SCC controls passed. Keep the other rows on their existing claim threads.
Its3rr0rsWRLD commentedon Nov 24, 2026
Claude will take item E, starting with one slice:
ac_get_fs_input_vgpr_cnt.load_frag_coord_w_rcp.AI-assisted (Claude Code).
Ybucaille commentedon Nov 24, 2026
Item C is up in #2052. The pair is
v_interp_p1ll_f16/v_interp_p2_f16(notp2ll, which doesn't exist on gfx10), lowered for the x/y channels with matchinghighhalves; clamp, modifiers, z/w, mismatched halves and non-comprattributes stay refused. The CPU controls and the llvm-mc fixture check pass on Linux; the_warp/_hardwaredraws still need a Windows run.AI-assisted.
denn0x commentedon Nov 24, 2026
Thanks for checking the encoding first. In the sample (aggregate, decode only) every
v_subrev_f32with DPP has the same shape. None of them is the two-register fine-derivative pair:quad_perm:[0,0,0,0]withbound_ctrl:1, and the row and bank masks are full. Nov_mov_b32_dppof the same source comes right before it.D(n) = S(n) - S(quad base), so lane 0 gets 0, lane 1 gets the x difference and lane 2 gets the y difference.v_mov_b32_dpp quad_perm:[1,1,1,1]and/orquad_perm:[2,2,2,2], sometimesv_mul_f32_dppwith the same broadcast, before the register is overwritten. This holds for about 95 % of the instructions; the rest are read further away or not at all.ddx_coarse/ddy_coarseinaco_instruction_selection.cpp), with the first subtraction folded into one DPP instruction.So the idiom to recognise is the two-instruction pair
v_subrev_f32_dpp vD, vS, vS quad_perm:[0,0,0,0] bound_ctrl:1, then a broadcast of vD from quad lane 1 or 2. Lowered, that pair isddx_coarse(S)orddy_coarse(S).S3 - S0in lane 3. A lowering without a lane model therefore has to prove that only the broadcast reads vD, and refuse any other read of it.QuadReadLaneAton SM 6.0) expresses both instructions exactly, at the cost of requiring SM 6.Leyukaka commentedon Nov 25, 2026
Item F (
image_storein a pixel stage): what blocks it, from readingtools/startup/gfx2hlsl.pyandsrc/startup_stubs/d3d12_draw.inlat5a0b0aa. Nothing was run.image_storehandler; the instruction ends at the genericUnsupported.Pipeline.resource()collects image descriptors for both stages, andPipeline.common()declares every resource read-only atregister(tN)(ByteAddressBuffer/Texture*<float4>).srv,ud/udsrc,smp/smpc/smpheap,params,targetsandwmaskrecords;translate_to()appends thertv1request line. None of them describes a writable view.parse_root()reads each parameter's type, visibility and offset, and register, space and count only for root constants. It does not read descriptor ranges, so it cannot tell that a table entry is a UAV.d3d12_draw.inlparses those manifest lines and builds a root signature of constants, an optional SRV table and an optional sampler table. The only view it creates is a shader resource view.RWTexture2D<float4>at its ownuregister (independent of the render targets under a D3D12 root signature). It would emit the store under the current exec mask for the simplest case: 2D float data,dmask0x1/0x3/0x7/0xf, none ofglc/slc/dlc/d16/a16/unorm/r128/tfe/lwe.AI-assisted.
startup: lower image_sample_b in gfx2hlsl
Lower v_interp_p1ll_f16 and v_interp_p2_f16 in the pixel stage
Lower v_interp_p1ll_f16 and v_interp_p2_f16 in the pixel stage (#2052)
startup: lower image_sample_b in gfx2hlsl (#2051)
coordination: release startup/gfx2hlsl-sample-b (image_sample_b, R0Y0…
startup: lower pixel-stage image_store to a typed UAV store (#2155)
R0Y00 commentedon Nov 25, 2026
Item F's first translation slice landed in #2155 at
fbc8fac5. Windows Release ran the source-built control and the draw on WARP and RTX 4060 Laptop. Both drew the expected texels with EXEC active, preserved the sentinel texel with EXEC off, and detected the missing-guard mutation.The runtime still refuses these UAV manifests. A separate binding slice can reuse the same synthetic shader and compare two distinguishable writable textures, including a rejection when the table provides a missing, wrong-type, or out-of-range view. Verify the written texel and the untouched view.
roansystemlabs commentedon Nov 25, 2026
I'd like to take the pixel-stage UAV binding slice described above (also the unowned "Pixel-stage UAV binding" line in #2274). @rasptum, if you had already started it as the #2155 follow-up, I'll step back and review instead.
Plan (one PR):
uav N tex2d float table P Oinstead of dropping the translation; the translated root signature gets a UAV range, and at draw time the view is made from the table entry the same way the texture SRVs are, on mip 0 of a 2D texture.Evidence: the synthetic gfx1013 pixel program from #2155, assembled with LLVM 15, drawn through the runtime path on WARP and an RTX 3070 with the debug layer and a fenced readback, with two distinguishable writable textures. The stored texel must land only in the view the table names, and the other texture must stay unchanged word for word. On current main the same translation stops at "pixel-stage UAVs are not bound yet". Negative controls: swapped table entry, UA-flag guard removed, wrong mip, and EXEC off must each fail as predicted. Not tested: AMD or Intel GPUs and console hardware.
AI-assisted.
R0Y00 commentedon Nov 25, 2026
The #2155 single-draw binding follow-up is ready for a focused PR. Use the existing source-built shader and keep the two-texture fenced readback and refusal controls you listed. Main still refuses the pixel UAV manifest, and there is no landed compute-view helper to depend on. Keep the pixel binding self-contained and use any shared helper that is already on main when you open the PR. A shared helper can be extracted once the compute caller is also available to exercise it.
Please keep the existing claim here. If rasptum has a patch for the same slot, coordinate on one implementation and independently run the other adapter's check.
startup: accept fi:1 on the pixel-stage DPP16 quad forms under the wh…
tests: pin own lane minus quad lane 0 for v_subrev_f32_dpp with a bro…
gfx2hlsl: accept fi:1 on the pixel-stage DPP16 quad forms under the w…
startup: bind pixel-stage UAVs from the title's descriptor table
startup: bind pixel-stage UAVs from the title's descriptor table (#2448)