Skip to content

v0.22.6

Choose a tag to compare

@kolkov kolkov released this 18 Nov 19:58
· 16 commits to main since this release

Added

  • The ballot-mask built-in variables are now written on MSL, HLSL and DXIL (card P2-IR-042). Those backends
    have no such built-in, so each mask is synthesised from the invocation's lane index and the subgroup size per
    32-bit word — never from a ballot of true, which holds only the active lanes while the spec's mask spans
    every invocation of the subgroup. A new internal package holds the extension's equations as the semantic
    oracle, exhaustively tested over every power-of-two size up to 128 and every lane; each writer's test
    transcribes its emitted formula line for line and checks it against the oracle. HLSL writes helper functions
    calling WaveGetLaneIndex/WaveGetLaneCount; MSL declares each mask as a kernel local over
    thread_index_in_simdgroup/threads_per_simdgroup; DXIL builds the vec4 through
    dx.op.waveGetLaneIndex/dx.op.waveGetLaneCount, and IDxcValidator accepts the emitted DXIL for every mask.
    The GLSL subgroup matrix's mask row now compiles through its SPIR-V, MSL and HLSL legs. A mask as a struct
    member stays refused on MSL with the limitation named (no attribute could carry it).

  • Ballot-mask built-in variables across the IR, both frontends and the backends that can express them (card
    P2-IR-041, ADR-014 D5). The IR gains ir.BuiltinSubgroupEqMask, GeMask, GtMask, LeMask and LtMask
    — vec4 inputs whose bit i is set when i = ID / i >= ID / i > ID / i <= ID / i < ID (ID = the subgroup
    invocation id, bits above the subgroup size zero), SPIR-V's SubgroupEqMask … SubgroupLtMask BuiltIns
    (4416–4420), none of which Rust naga has. Validation adds the BALLOT operation class to the CapSubgroup the
    subgroup variables already needed. The GLSL frontend lowers gl_SubgroupEqMask … gl_SubgroupLtMask
    (previously refused), gated by the ballot family's extension; the SPIR-V frontend maps the five decorations;
    the SPIR-V backend writes the decorated Input variables with GroupNonUniformBallot, and the GLSL text
    backend writes the variable names — and now requests the subgroup extensions for any shader that merely
    reads one of the nine subgroup variables, a gap that left a scalar-only use without its #extension.
    MSL, HLSL and DXIL refuse the five with a named limitation: the spec's mask spans every invocation while a
    ballot of true holds only the active lanes, so a correct synthesis needs lane-and-subgroup-size word
    arithmetic — its own card (P2-IR-042) with a Go evaluator of the equations as the oracle. Verified end to
    end: glslang accepts the source, the emitted SPIR-V passes spirv-val with the five decorated Input
    variables, the GLSL output round-trips, and the MSL/HLSL refusals are asserted by the matrix.

  • Clustered subgroup forms across the IR, both frontends and the backends that can express them (card
    P2-IR-040, ADR-014 D4). The IR gains ir.CollectiveOperationClusteredReduce and a ClusterSize uint32
    field on ir.StmtSubgroupCollectiveOperation — the clustered reductions of GL_KHR_shader_subgroup
    (subgroupClusteredAdd/Mul/Min/Max/And/Or/Xor, "an integral constant expression. At least 1. A power of
    2.") and SPIR-V's ClusteredReduce group operation with its optional Cluster Size operand, none of which
    Rust naga has. Validation adds valid.SubgroupClustered (the bit Rust reserved and left commented out),
    requires the size to be at least 1 and a power of 2, requires it to stay 0 on every other collective, and
    refuses the votes under it. The GLSL frontend lowers the seven builtins with glslang's error texts for a
    non-constant, zero, negative or non-power-of-2 size, and the SPIR-V frontend maps ClusteredReduce with
    its constant operand. The SPIR-V backend writes the native form with GroupNonUniformClustered, the GLSL
    text backend writes the builtins; MSL, HLSL (before the SM 6.5 multi-prefix operations) and DXIL have no
    clustered form and refuse with a named limitation — a shuffle-based emulation is future work. Verified end
    to end: spirv-val on the emitted SPIR-V, glslang on every matrix source, and the GLSL subgroup matrix;
    unit tests pin the IR shape, the operand rules, the frontend mappings and each backend's output or refusal.

  • Ballot bit operations across the IR, both frontends and every backend (card P2-IR-039, ADR-014 D3).
    The IR gains ir.StmtSubgroupBallotBit and the ir.SubgroupBallotBitOperation enum (Extract, Count,
    InclusiveCount, ExclusiveCount, FindLSB, FindMSB, InverseBallot) — the seven ballot bit forms of
    GL_KHR_shader_subgroup_ballot and SPIR-V's GroupNonUniformBallot capability, none of which Rust naga
    has. The result reuses ir.ExprSubgroupOperationResult (bool for extract and inverse ballot, u32 for the
    counts and finds); validation is the existing BALLOT class with Mask vec4 and Index a u32 scalar
    read by extract only. The GLSL frontend lowers subgroupBallotBitExtract, subgroupBallotBitCount,
    subgroupBallotInclusiveBitCount, subgroupBallotExclusiveBitCount, subgroupBallotFindLSB,
    subgroupBallotFindMSB and subgroupInverseBallot (previously refused or unrecognized), converting an
    ivec4 mask or int index to uint as glslang does; the SPIR-V frontend maps the five OpGroupNonUniform*
    opcodes. Every backend writes the forms: SPIR-V natively (opcodes 340–344), GLSL text as the builtins, and
    HLSL, MSL and DXIL as arithmetic over the four mask words (countbits/firstbitlow/firstbithigh,
    metal::popcount/ctz/clz, dx.op.unaryBits Countbits/FirstbitLo/FirstbitHi), masked to the subgroup
    size as the SPIR-V and GLSL specs require — the wave count intrinsics count the live wave's predicate, not
    a mask value, so they are not used. MSL threads the subgroup size and lane index kernel inputs to callees
    by value. Verified end to end: spirv-val on the emitted SPIR-V, dxc cs_6_0 on the emitted HLSL,
    IDxcValidator on the emitted DXIL (including the conversions and a mixed-builtin module), and the GLSL
    subgroup matrix; unit tests per layer pin the IR shape, the operand rules and each backend's output.

Fixed

  • valid.MissingCapabilities now reports SUBGROUP for an elect-only module (found while implementing
    P2-IR-039; card P2-IR-038 follow-up). The capability collector listed the ballot, collective and gather
    statements but not StmtSubgroupElect, so a module whose only subgroup operation was an elect passed a
    backend's MissingCapabilities gate even when subgroups were unsupported. Elect and the new ballot bit
    statement are now collected; a gate-table case pins it, proven to fail on the previous code.