Skip to content

gfx2hlsl: startup refusals with no open issue or PR (claimable items) #2463

Backlog

Description

@NiiRoZz

First-refusal census of locally captured startup shader requests, translated with current main plus a local merge of the open translator PRs. Counts only; the inputs are private and not attached. The items below are the refusals for which I found no open issue or PR. Each is small enough to claim on its own; say so in a comment before starting.

Task status

Check the claim and PR status below before starting work.

Already tracked elsewhere (not duplicated)

Largest groups from the same census and where they live:

Refs #870, #2274.

Activity

  1. JVProg commented on Nov 25, 2026

    @JVProg
    Contributor

    I'm claiming the first item, "Compute manifest raises on a sampler with LOD limits". I will reproduce it with a source-built fixture, check the compute loader side of smpl, and cover the plain and comparison forms as controls. The other items stay free.

    AI-assisted (Claude Code).

  2. JVProg commented on Nov 25, 2026

    @JVProg
    Contributor

    Update on the first item (compute manifest and LOD-limited samplers), including the loader side.

    I opened #2482 for the manifest fix. The stand-in problem remains:

    The stand-in does not load compute translations yet. docs/startup-runtime.md says so ("The stand-in does not load the result yet and still creates a placeholder"). So #2482 lets the translator publish the manifest, but does not make that compute pipeline run in the startup runtime, and it does not change the stand-in.

    I reproduced the TypeError on 1a0e506d with image_sample_l and image_sample_lz through a constant sampler. In #2482 the graphics and compute manifests share one method for the smp / smpc / smpl lines.

    Local checks of those changes on top of 1a0e506d, run before the commit (38517b69; Release, Windows 11 build 26300):

    • The new check in tests/startup_image_sample_lod_check.py fails with the same TypeError without the fix and passes with it. Its controls are a mip-filter-none sampler (smp) and a comparison sampler (smpc).
    • The existing parser and decoder in translated_sampler_bindings.h accept the smpl line. 44 selected sampler and compute CTest tests passed on WARP and an RX 9070 XT (driver 32.0.32029.2010).
    • In a temporary local harness (not part of the fix), I built the static sampler from the compute manifest with that decoder and dispatched three translated shaders on both adapters. All 12 dispatches read the expected mip: with smpl 1, 1 and 2; with the line changed to smp as a control 2, 0 and 0. The D3D12 debug layer was not available in this harness. This does not exercise a runtime load path, because there is none.
    • The test's compute instruction words reuse existing helpers; I did not reassemble them with llvm-mc.

    AI-assisted (Claude Code).

  3. ChazY11 commented on Nov 25, 2026

    @ChazY11
    Contributor

    Claiming the third item, s_getpc_b64 refused in a pixel stage — the one the census says is "not investigated;
    the first step is to name the exact form and what consumes the pair". I will start there rather than at a lowering,
    because the deliverable you describe is identification, and I would rather report what the pair feeds than guess at
    a semantic.

    What I will do, in this order, and report even if the answer is "no small change is possible":

    1. locate the refusal and name the exact form (s_getpc_b64 s[a:b] and any _e32/_e64 variants the decoder
      produces for the captured requests);
    2. find every consumer of the pair in the tree (s_add_u32/s_addc_u32 against a label constant is the usual
      shape, but I will check rather than assume) and whether the value is used as an absolute address, a
      PC-relative delta, or only as a symbol for a table base;
    3. state whether the pair is provably a constant offset from the instruction address (in which case a guarded
      lowering that reuses the existing calculated_pc bookkeeping may be possible) or whether the consumed value
      escapes the model — in which case the refusal stays and the item closes as "correctly refused, reason named".

    I have no access to the captured requests themselves, so item 1 will be driven by the decoder and the fixtures in
    the tree; if the exact form depends on bytes I cannot see, I will say so instead of inventing one.

    Not touching the other four items. Refusal-count context I can reproduce here if it helps: 137-entry Linux check
    list all green, 63 startup_gfx2hlsl_* checks green, and the gfx2hlsl family runs on this host without D3D12.

    AI-assisted.

  4. RavenCurseBurg commented on Nov 25, 2026

    @RavenCurseBurg
    Contributor

    Compute cube coordinate instructions, verified on three adapters. The existing lowering in #2035 already gives the four correct compute results for the six faces and the finite tie cases below. The PR was closed to shorten the Windows test queue. Its current head is cb8fb26.

    I assembled an 80-byte gfx1013 compute program with LLVM 15. Eighteen lanes each load a distinct float3 from a raw SRV, compute face ID, S, T and signed major × 2, and write four words to a UAV. The four additional vectors tie X/Y, X/Z, Y/Z and all three axes. Eight more lanes cover every combination of positive and negative zero on X/Y/Z. All eight select +Z, retaining the signs of X, -Y and Z in the three other outputs. The first cube operation on upstream main a6c8d80 is refused with v_cubeid_f32. On #2035 the same bytes translate and compile with DXC cs_6_0.

    Output compared on Intel UHD 770, RTX 4060 and WARP Mismatched words per adapter, out of 320
    Original translation 0
    Face ID reads X and Y in reverse order 5
    Change the sign of S 18
    Change the sign of T 18
    Discard the sign of the major axis 9
    Require strict Z-major comparisons 25

    The tie control first fails for (4, 2, -4), returning face +X instead of -Z at output word 28. The 320-word comparison includes 248 untouched words. Intel driver 32.0.101.5973, NVIDIA 32.0.15.9579, WARP 10.0.26100.9711. The local debug layer was unavailable.

    Source, input vectors, output words and commands. The program only exercises coordinate ALU. The 21 private requests in the census still need a rerun after integration. The standalone test can be taken independently when #2035 is resumed.

    Replacement PR. I reran the same 18-thread compute program on #2514 at 7a2887ba. All three adapters matched the 72 result and 248 sentinel words with DXC defaults and with -Gis. All five controls were detected on each adapter. Per-device results and the source adapted to the replacement lowering.

    AI-assisted with Codex (GPT-6.2 Astra, xhigh).

  5. ChazY11 commented on Nov 25, 2026

    @ChazY11
    Contributor

    Item 3 is delivered as #2484 (s_getpc_b64 now names the reason instead of reporting the mnemonic alone), and I
    will not claim a second item — see the note on item 2 below, which is why.

    Item 2 (s_load_dword* through a pointer joined at a branch target): I could not reproduce the refusal shape from
    the tree alone, so I am leaving it unclaimed.
    What I tried, on main at a6c8d80d, translating synthetic programs
    through Stage.translate():

    straight line, pointer from two s_mov_b32, then s_load_dword s0, s[4:5], 0x0
      -> refused: s_load through s4 holding ('const', 256)
    
    same program with s_cbranch_scc1 0x10 over one arm, pointer untouched on both
      -> IndexError in my harness (the branch scan needs pipe state I did not reconstruct)
    

    So the tree-side repro of the straight-line case refuses for a reason that is not the join at all: a constant is
    not a descriptor, and the message says so. The shape the census reports needs a real descriptor/pointer symbol that
    survives a join, and reproducing that needs a program whose pointer comes from a resource binding rather than a
    literal — which is exactly the part of my synthetic harness that does not work yet (the IndexError above is my
    missing pipe state, not the translator).

    Whoever takes it: the acceptance text ("the pointer symbol survives a join when its write dominates and no path
    rewrites it, with a negative control where one arm rewrites it") is implementable against
    tests/startup_gfx2hlsl_join_symbols_check.py, which already builds the branch/dominance fixtures — that is where I
    would start rather than in a bespoke harness, which is what I got wrong here.

    AI-assisted.

  6. RavenCurseBurg commented on Nov 25, 2026

    @RavenCurseBurg
    Contributor

    I am working on item 2, the pointer copied before a branch target and then used by s_load_dword*.

    I reproduced the distinction using a synthetic gfx1013 pixel program, an actual root descriptor table, and the pipeline constructor from tests/startup_gfx2hlsl_join_symbols_check.py. With #2460 (661c9a1a) and #2069 (99e1c69f) merged locally, the straight-line version below gives srv 0 tex2d table 0 32. With the extra conditional blocks, it refuses the load through s24 as joined, even when the second block only writes s30.

    s_cmp_eq_u32 s9, 0
    s_cbranch_scc1 1
    s_mov_b32 s24, 5
    s_mov_b32 s26, s8
    s_add_u32 s26, s26, 32
    s_mov_b32 s24, s26
    s_mov_b32 s25, 0
    s_cmp_eq_u32 s9, 1
    s_cbranch_scc1 1
    s_mov_b32 s30, 17
    ; ... load an image descriptor with s_load_dwordx8 s[16:23], s[24:25], 0 ...

    Replacing the final move with s_add_u32 s24, s24, 32 makes the incoming addresses genuinely different and must keep the refusal. Copying the unadvanced entry pointer in the positive fixture already works on both main and #2460. Implementation and Windows results. The forward-branch change is in draft #2507, based on the updated #2069 at a747241f. The incremental commit makes the two equal addresses agree and keeps the differing-address case refused. Five bindings and six refusals passed, all eleven full gfx1013 programs matched their LLVM 15 assembly, and 66 existing translator checks passed. In a separate 350-program comparison, all 49 accepted programs selected the correct binding and all 220 with multiple possible offsets refused. The other 81 were conservative refusals.

    The actual guest command list read two distinct textures at byte 0 and 32. On this exact commit, five programs × FXC/DXC × Intel UHD 770 / RTX 4060 / WARP produced 30 images matching all 32 pixels. Deliberately changing only the manifest offset changed all 32 pixels in each of 30 controls. The Windows Server 2025 CPU, FXC WARP and DXC WARP checks also passed. The source-built fixtures establish these cases; private census impact still needs the project-side retest.

    AI-assisted with Codex (GPT-6.2 Astra, xhigh).

  7. Ybucaille commented on Nov 25, 2026

    @Ybucaille
    Contributor

    I'm claiming the fifth item, s_mov_b32 inside a block skipped per lane by s_cbranch_execz, defining vcc that is live at the join (compute). The other items are claimed or delivered (1 JVProg #2482, 2 RavenCurseBurg, 3 ChazY11 #2484, 4 RavenCurseBurg #2035).

    Scope, to avoid overlap: #2466 accepts s_and_b64 / s_orn2_b64 with exec at an execz target in vertex and pixel stages, and #2274 covers exec writes inside an execz block in compute. This item is the compute case where the skipped block writes vcc through a scalar move and the join reads it. I will start from a source-built gfx1013 compute fixture that reproduces the refusal on current main (with #2461), then work out what the join must hold for a lane that skipped the block, with a negative control where the value differs between the two paths.

    AI-assisted (Claude Code).

  8. ChazY11 commented on Nov 25, 2026

    @ChazY11
    Contributor

    A one-source operand list on 35 scalar ALU ops raises IndexError, not a refusal

    Found by fuzzing the scalar table rather than by reading: for every opcode in the table, call the handler with one
    source instead of two.

    Probe().one('s_or_b32', 's_or_b32 s1, s2')
    File "tools/startup/gfx2hlsl.py", line 1953, in one
        term = self.lower(base, asm, ops, mods)
    File "tools/startup/gfx2hlsl.py", line 2198, in lower
        return self.scalar(base, ops)
    File "tools/startup/gfx2hlsl.py", line 2473, in scalar
        expr = text.format(*values)
    IndexError: Replacement index 1 out of range for positional args tuple
    

    values has one element because srcs has one, while the template still wants {1}. Per the project's own
    convention that is translator crash in <op>: IndexError, not a refusal naming the instruction — the same class
    issue #2463 is cataloguing.

    How many

    单源短形态 → IndexError: 35 个操作码
    s_add_i32 s_add_u32 s_and_b32 s_and_b64 s_andn2_b32 s_andn2_b64 s_ashr_i32 s_bfe_u32
    s_lshl1_add_u32 s_lshl2_add_u32 s_lshl3_add_u32 s_lshl4_add_u32 s_lshl_b32 s_lshr_b32
    s_max_i32 s_max_u32 s_min_i32 s_min_u32 s_mul_hi_u32 s_mul_i32 s_nand_b32 s_nand_b64
    s_nor_b32 s_nor_b64 s_or_b32 s_or_b64 s_orn2_b32 s_orn2_b64 s_pack_hh_b32_b16
    s_sub_i32 s_sub_u32 s_xnor_b32 s_xnor_b64 s_xor_b32 s_xor_b64
    
    三操作数形态(多一个源):0 个异常
    

    So the three-operand form is fine — the extra source is refused somewhere and the message is well-formed.
    Only the short form crashes, and it does so for every op whose template has two placeholders.

    Note this is a different dispatch branch from the arity guards in #2469: those fire earlier in lower() for
    their own subsets, and s_or_b32 reaches scalar() at line 2198 without passing one. That is why the guards
    already on main do not cover this.

    Where the guard belongs

    Line 2472–2473:

    values = [self.u(t) for t in srcs]
    expr = text.format(*values)

    The handler knows how many placeholders the template needs; a check that len(values) matches the highest index
    used in text, raising Unsupported('%s with %d operands, expected %d' % ...), covers all 35 in one place and
    uses the message shape the rest of the table already uses. I would put it immediately before text.format rather
    than in each handler.

    My own mistake, stated so the count is trustworthy

    The first pass reported seven more ops (s_mov_b32, s_mov_b64, s_not_b32, s_not_b64, s_brev_b32,
    s_sext_i32_i8/i16) failing with AttributeError. That was my probe, not the translator: I gave the probe
    masks = {} (a dict) where set_s expects a set, and getattr(self, 'masks', set()).discard(n) does not exist on a
    dict. With masks = set() those seven are clean. The 35 above are all IndexError from the format string.

    Scope of the measurement

    This is the single-instruction handler path, which is what the existing arity fixtures use too. I did not drive a
    whole program through translate_request to see the recorded reason string; if you want that as the repro line in
    the issue, it is the same call one level up.


    If this is in scope for #2463, I can prepare the guard plus a fixture in the shape of startup_gfx2hlsl_scalar_arity_check.py
    (all 35 ops, the short form refused with the message, the complete form still translating, and the existing
    negative control that disabling the guard brings the IndexError back). Say the word and I will open it against
    the handlers you prefer, or leave it to the maintainers of the surrounding work.

    AI-assisted; the fuzz pass and the traceback were produced locally on Windows 11 build 26300.9974, no build needed.

  9. ChazY11 commented on Nov 25, 2026

    @ChazY11
    Contributor

    Prepared the guard and its fixture on a local branch so it is ready if you want it, not opened as a PR and not
    pushed — the finding is in the comment above, and the claim is yours to assign.

    Branch startup/scalar-table-short-arity, one commit 17f76a58, against 394f24f8:

    tools/startup/gfx2hlsl.py                           +  the guard, immediately before `text.format(*values)`
    tests/startup_gfx2hlsl_scalar_table_arity_check.py   +  the check
    CMakeLists.txt  AGENTS.md  .github/workflows/...     +  the three-way registration
    

    The guard, in scalar():

    needed = max((int(i) for i in re.findall(r'\{(\d+)\}', text)), default=-1) + 1
    if len(srcs) < needed:
        raise Unsupported('%s with %d operands, expected %d' % (base, len(ops), needed + 1))

    Verified here, all pure Python:

    python -B tests/startup_gfx2hlsl_scalar_table_arity_check.py
        the SCA table has two-source templates: ok
        no two-source template crashes on a short source list: ok
        every short form is refused with the operand count it needs: ok
        a complete form is never refused for its operand count: ok
        control: without the guard the short form raises IndexError: ok
        the one template with its own arity check still refuses without the guard: ok
        scalar table arity checks: 0 failed
    
    gfx2hlsl family after the change: 67 checks, 0 red
    guard text changed to `if False:` -> the check exits 1; restored -> exits 0
    

    One detail the control had to account for: 35 of the 36 templates come back to IndexError with the guard
    disabled. s_bfm_b32 stays refused because it carries its own arity message, so the control asserts 35 plus a
    separate check that the remaining one still refuses by its own message — rather than counting it as a survivor and
    loosening the threshold.

    Say whether you want it as a PR, want it folded into another branch, or would rather the maintainers of #2469's
    follow-ups take it, and I will act accordingly. If the answer is "leave it", it stays unopened.

    AI-assisted.

  10. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    ChazY11, please open the scalar short-arity guard as a focused PR against current main, referencing this issue. The complete-form control and the separate s_bfm_b32 refusal cover the two diagnostic paths. Keep the return as an instruction-specific Unsupported, and leave the existing pointer-join and lane-mask claims with their authors.

  11. ChazY11 commented on Nov 25, 2026

    @ChazY11
    Contributor

    Opened as requested: #2515, rebased onto 6d2d3bed, one commit.

    It keeps the three points you named: the return is the same instruction-specific
    Unsupported('%s with %d operands, expected %d') the rest of the table uses; the fixture asserts that a
    complete form is never refused for its operand count; and s_bfm_b32 is handled as its own diagnostic path —
    the negative control excludes it by name and asserts separately that it still refuses by its own message, rather
    than counting it as a survivor.

    The pointer-join and lane-mask claims are untouched and stay with their authors.

    startup_gfx2hlsl_* family on the branch: 67 checks, 0 red. With the guard turned into if False: the new check
    exits 1, restored it exits 0.

    AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions