Translated mesh programs: some waves get wrong register values on an RTX 5090 (128-lane groups that vote) #458

Closed
opened 2026-11-29 08:53:25 +00:00 by NickStallman · 8 comments
NickStallman commented 2026-11-29 08:53:25 +00:00 (Migrated from github.com)
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T08:53:25Z.


A translated mesh program decides a guest scalar branch by a vote in group memory (tb_page_ballot), and guards what the branch skips with if (tb_skip < T) { ... }. On an RTX 5090 (driver 620.70.10) the first lanes of a 128-lane group can have wrong values in registers such a block sets, although no lane skips it.

Self-contained shader, plain Vulkan

No D3D12, vkd3d-proton or Wine: a small runner and SPIR-V from DXC and dxil-spirv. Every lane must report 6.

Shader RTX 5090 AMD iGPU (RADV) lavapipe
3 of 98 forms of one source, as mesh wrong in lanes 0..31 right right
the other 95 (mesh and compute) right right right
those 3, reduced to two shaders (one below), as mesh wrong in lanes 0..31 (65536) not run right
the two as compute right not run right

The 3 forms with the branches as selects, with the first block as selects, or with the vote not used are right as mesh too. The reduced shader below has no barrier after the skip, so live values across barriers are not needed. Only 3 of 98 forms fail and small edits hide it, so we do not know the exact trigger.

Translated programs

Every export of every lane against the same program as compute, three groups, all vertex counts up to the program's limit:

Program Form RTX 5090 AMD iGPU
1 as translated wrong, 6,118 of 49,152 lanes with instanced input; right with plain input right
1 with the change right right
2 as translated wrong, 12,384 of 36,864 lanes right
2 with the change right right
3 as translated wrong, 13,344 of 38,784 lanes right
3 with the change right right
3 an earlier form of it that left reads' results in a branch wrong, 8,208 lanes right
4 as translated right right
4 with the change right right

Programs 2 to 4 ran with their bindless resources replaced by stubs, and as sized descriptors.

Other things that do not fix program 1: reading the value again (912 lanes wrong), an extra barrier, an atomic vote, atomic reads, a first-lane read of the decision. It is wrong with DXC 1.8.2505.1 and 1.9, -O0 included.

The change

In mesh programs that vote, a guarded block is not a block: each register write selects on the skip, and each memory access keeps a one-statement branch whose value is selected.

In a game

With only program 1's one block always run (a hand-made shader, not this change), in ProjectScarlett on an RTX 5090, the crash whose fault program counter ends in 0x70 (our largest class of device losses) happened in 0 of 10 runs, against 5 of 10 with the original (one-sided Fisher p = 0.016; interleaved runs, main at 28717263 plus #436, #389, #390 and diagnostics). Runs of the changed arm still lost the device later in other ways. The change itself has not been run in a game.

What this does and does not show

  • Shown: the translated programs compute wrong vertices on this card and the change makes these four right on both cards.
  • Shown: the fault is not in vkd3d-proton or Wine, and the reduced code is right on the other implementations where it ran.
  • Inferred: that the fault is in the NVIDIA mesh compiler. No driver dump or fix shows it.
  • Inferred: that the merges at the skips are the trigger. In the translated programs the more of them are removed the more lanes become right. In the plain shader any of many edits also hides it, so that is weaker.
  • Not tested: other NVIDIA cards or drivers, a discrete AMD card, the GPU cost.
Reduced shader (plain Vulkan, lanes 0..31 wrong on the 5090)
RWByteAddressBuffer report : register(u0);
ByteAddressBuffer input : register(t1);
groupshared uint bits[8];
uint2 ballot(uint tid, bool vote) {
    if (tid == 0u) { bits[0] = 0u; bits[1] = 0u; bits[2] = 0u; bits[3] = 0u; }
    GroupMemoryBarrierWithGroupSync();
    if (vote && (tid & 31u) == 0u) bits[tid >> 5] = 1u;
    GroupMemoryBarrierWithGroupSync();
    uint2 found = uint2(bits[tid >> 5], 0u);
    GroupMemoryBarrierWithGroupSync();
    return found;
}
uint2 evaluate(uint tid, uint group) {
    uint n = 0u;
    uint r = 0u, back = 0u, skip = 0u, q = 0u, rem = 0u;
    float4 live[6];
    { [unroll] for (uint i = 0; i < 6; ++i) live[i] = asfloat(input.Load4(64u + 16u * i)) + (float)tid; }
    uint first = 0u;
    uint word = input.Load(4u);
    bool skipped = ballot(tid, input.Load(0u) != 0u).x != 0u;
    if (skipped) skip = max(skip, 75u);
    if (skip < 75u) {
        n = (word & 127u) + 1u;
        r = uint(1.0 / (float)n * asfloat(input.Load(12u)));
    }
    uint s = r;
    if (skip < 75u) {
        uint e = back * s;
        q = (tid * s) >> 16;
        rem = tid - q * n;
        q = n <= rem ? q + 1u : q;
        rem = n <= rem ? rem - n : rem;
        q = n <= rem ? q + 1u : q;
        q += e * 0u;
        skip = max(skip, 79u);
    }
    if (skip < 79u) { q = 0u; n = 0u; }
    { [unroll] for (uint i = 0; i < 6; ++i) q += live[i].x + live[i].y + live[i].z + live[i].w > 1e30 ? 1u : 0u; }
    return uint2(n, q);
}
void tap(uint lane, uint group) {
    uint2 got = evaluate(lane, group);
    report.Store4(32u * lane, uint4(got.x, got.y, 0u, 0u));
}
struct V {
    float4 p : SV_Position;
};
[outputtopology("triangle")] [numthreads(128, 1, 1)]
void main(uint lane : SV_GroupIndex, uint3 group : SV_GroupID, out vertices V v[128], out indices uint3 t[128]) {
    tap(lane, group.x);
    SetMeshOutputCounts(3, 1);
    V one = (V)0;
    if (lane < 3u) v[lane] = one;
    if (lane == 0u) t[0] = uint3(0, 0, 0);
}
The larger one it comes from, for D3D12
// Self-contained: no title code. A mesh shader whose lanes agree, through a
// groupshared array, whether to skip a block; the block sets n and r; a second
// exchange follows; and a second block uses n and r. Each lane reports what it
// used. EXPECT: n_used = the input's n, for every lane.
#define ROOT "RootFlags(0), RootConstants(num32BitConstants=4, b0, space=9), UAV(u0, space=9), SRV(t0, space=9)"
#ifndef PRESSURE
#define PRESSURE 0
#endif
cbuffer C : register(b0, space9) { uint4 unused; };
RWByteAddressBuffer report : register(u0, space9);
ByteAddressBuffer input : register(t0, space9);   // word 0: skip (0). word 1: n. word 2: 1. word 3: scale bits
groupshared uint bits[8];
groupshared uint values[256];

uint2 ballot(uint tid, bool vote) {
    if (tid < 8u) bits[tid] = 0u;
    GroupMemoryBarrierWithGroupSync();
#ifdef OR_NOBRANCH
    InterlockedOr(bits[tid >> 5], uint(vote) << (tid & 31u));
#else
    if (vote) InterlockedOr(bits[tid >> 5], 1u << (tid & 31u));
#endif
    GroupMemoryBarrierWithGroupSync();
    uint h = (tid >> 6) * 2u;
#ifdef ATOMIC_READ
    uint2 found;
    InterlockedOr(bits[h], 0u, found.x);
    InterlockedOr(bits[h + 1u], 0u, found.y);
#else
    uint2 found = uint2(bits[h], bits[h + 1u]);
#endif
    GroupMemoryBarrierWithGroupSync();
    return found;
}

uint read(uint tid, uint value, uint lane) {
    values[tid] = value;
    GroupMemoryBarrierWithGroupSync();
    uint result = values[(tid & ~63u) | (lane & 63u)];
    GroupMemoryBarrierWithGroupSync();
    return result;
}

uint2 evaluate(uint tid, uint group) {
    uint n = (tid >> 6) << 24, r = 0u, back = 0u, skip = 0u, q = 0u, rem = 0u;
#if PRESSURE
    float4 live[PRESSURE];
    { [unroll] for (uint i = 0; i < PRESSURE; ++i) live[i] = asfloat(input.Load4(64u + 16u * i)) + (float)tid; }
#endif
    uint first = 0u;
#ifdef FIRST_READ
    uint2 a = ballot(tid, true);
    first = a.x != 0u ? firstbitlow(a.x) : a.y != 0u ? 32u + firstbitlow(a.y) : 0u;
    group = read(tid, group << 7, first) >> 7;
#endif
    uint word = input.Load(4u);
#ifdef SKIP_FROM_BUFFER
    bool skipped = input.Load(0u) != 0u;
#else
    bool skipped = any(ballot(tid, input.Load(0u) != 0u));
#endif
    if (skipped) skip = max(skip, 75u);
    if (skip < 75u) {
        n = (word & 127u) + 1u;
        back = 0u - n;
        r = uint(1.0 / (float)n * asfloat(input.Load(12u)));
    }
    uint2 b = ballot(tid, true);
    first = b.x != 0u ? firstbitlow(b.x) : b.y != 0u ? 32u + firstbitlow(b.y) : 0u;
#ifndef NO_READ
    uint s = read(tid, r, first);
#else
    uint s = r;
#endif
    if (skip < 75u) {
        uint e = back * s;
        q = (tid * s) >> 16;
        rem = tid - q * n;
        q = n <= rem ? q + 1u : q;
        rem = n <= rem ? rem - n : rem;
        q = n <= rem ? q + 1u : q;
        q += e * 0u;
        skip = max(skip, 79u);
    }
    if (skip < 79u) { q = 0u; n = 0u; }
#if PRESSURE
    { [unroll] for (uint i = 0; i < PRESSURE; ++i) q += live[i].x + live[i].y + live[i].z + live[i].w > 1e30 ? 1u : 0u; }
#endif
#ifdef THIRD
    uint2 c = ballot(tid, n != 0u);
    if (any(c) && skip == 99u) q += 1u;
#endif
    return uint2(n, q);
}

void tap(uint lane, uint group) {
    uint2 got = evaluate(lane, group);
    report.Store4(32u * (128u * (group & 3u) + lane), uint4(got.x, got.y, 5u, 0u));
}
#ifdef MESH
struct V { float4 p : SV_Position; float4 a[8] : TEXCOORD0; };
[RootSignature(ROOT)] [outputtopology("triangle")] [numthreads(128, 1, 1)]
void main(uint lane : SV_GroupIndex, uint3 group : SV_GroupID, out vertices V v[128], out indices uint3 t[128]) {
    tap(lane, group.x);
    SetMeshOutputCounts(128, 1);
    V one = (V)0;
    one.p = float4(0, 0, 0, 1);
    v[lane] = one;
    if (lane == 0u) t[0] = uint3(0, 0, 0);
}
#else
[RootSignature(ROOT)] [numthreads(128, 1, 1)]
void main(uint lane : SV_GroupIndex, uint3 group : SV_GroupID) { tap(lane, group.x); }
#endif
<!-- greyfinch-sync:brcly/TuxBox:issue:6676819294 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/458). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T08:53:25Z. --- A translated mesh program decides a guest scalar branch by a vote in group memory (`tb_page_ballot`), and guards what the branch skips with `if (tb_skip < T) { ... }`. On an RTX 5090 (driver 620.70.10) the first lanes of a 128-lane group can have wrong values in registers such a block sets, although no lane skips it. ### Self-contained shader, plain Vulkan No D3D12, vkd3d-proton or Wine: a small runner and SPIR-V from DXC and dxil-spirv. Every lane must report 6. | Shader | RTX 5090 | AMD iGPU (RADV) | lavapipe | | --- | --- | --- | --- | | 3 of 98 forms of one source, as mesh | wrong in lanes 0..31 | right | right | | the other 95 (mesh and compute) | right | right | right | | those 3, reduced to two shaders (one below), as mesh | wrong in lanes 0..31 (65536) | not run | right | | the two as compute | right | not run | right | The 3 forms with the branches as selects, with the first block as selects, or with the vote not used are right as mesh too. The reduced shader below has no barrier after the skip, so live values across barriers are not needed. Only 3 of 98 forms fail and small edits hide it, so we do not know the exact trigger. ### Translated programs Every export of every lane against the same program as compute, three groups, all vertex counts up to the program's limit: | Program | Form | RTX 5090 | AMD iGPU | | --- | --- | --- | --- | | 1 | as translated | wrong, 6,118 of 49,152 lanes with instanced input; right with plain input | right | | 1 | with the change | right | right | | 2 | as translated | wrong, 12,384 of 36,864 lanes | right | | 2 | with the change | right | right | | 3 | as translated | wrong, 13,344 of 38,784 lanes | right | | 3 | with the change | right | right | | 3 | an earlier form of it that left reads' results in a branch | wrong, 8,208 lanes | right | | 4 | as translated | right | right | | 4 | with the change | right | right | Programs 2 to 4 ran with their bindless resources replaced by stubs, and as sized descriptors. Other things that do not fix program 1: reading the value again (912 lanes wrong), an extra barrier, an atomic vote, atomic reads, a first-lane read of the decision. It is wrong with DXC 1.8.2505.1 and 1.9, -O0 included. ### The change In mesh programs that vote, a guarded block is not a block: each register write selects on the skip, and each memory access keeps a one-statement branch whose value is selected. ### In a game With only program 1's one block always run (a hand-made shader, not this change), in ProjectScarlett on an RTX 5090, the crash whose fault program counter ends in `0x70` (our largest class of device losses) happened in 0 of 10 runs, against 5 of 10 with the original (one-sided Fisher p = 0.016; interleaved runs, `main` at 28717263 plus #436, #389, #390 and diagnostics). Runs of the changed arm still lost the device later in other ways. The change itself has not been run in a game. ### What this does and does not show - Shown: the translated programs compute wrong vertices on this card and the change makes these four right on both cards. - Shown: the fault is not in vkd3d-proton or Wine, and the reduced code is right on the other implementations where it ran. - Inferred: that the fault is in the NVIDIA mesh compiler. No driver dump or fix shows it. - Inferred: that the merges at the skips are the trigger. In the translated programs the more of them are removed the more lanes become right. In the plain shader any of many edits also hides it, so that is weaker. - Not tested: other NVIDIA cards or drivers, a discrete AMD card, the GPU cost. <details><summary>Reduced shader (plain Vulkan, lanes 0..31 wrong on the 5090)</summary> ```hlsl RWByteAddressBuffer report : register(u0); ByteAddressBuffer input : register(t1); groupshared uint bits[8]; uint2 ballot(uint tid, bool vote) { if (tid == 0u) { bits[0] = 0u; bits[1] = 0u; bits[2] = 0u; bits[3] = 0u; } GroupMemoryBarrierWithGroupSync(); if (vote && (tid & 31u) == 0u) bits[tid >> 5] = 1u; GroupMemoryBarrierWithGroupSync(); uint2 found = uint2(bits[tid >> 5], 0u); GroupMemoryBarrierWithGroupSync(); return found; } uint2 evaluate(uint tid, uint group) { uint n = 0u; uint r = 0u, back = 0u, skip = 0u, q = 0u, rem = 0u; float4 live[6]; { [unroll] for (uint i = 0; i < 6; ++i) live[i] = asfloat(input.Load4(64u + 16u * i)) + (float)tid; } uint first = 0u; uint word = input.Load(4u); bool skipped = ballot(tid, input.Load(0u) != 0u).x != 0u; if (skipped) skip = max(skip, 75u); if (skip < 75u) { n = (word & 127u) + 1u; r = uint(1.0 / (float)n * asfloat(input.Load(12u))); } uint s = r; if (skip < 75u) { uint e = back * s; q = (tid * s) >> 16; rem = tid - q * n; q = n <= rem ? q + 1u : q; rem = n <= rem ? rem - n : rem; q = n <= rem ? q + 1u : q; q += e * 0u; skip = max(skip, 79u); } if (skip < 79u) { q = 0u; n = 0u; } { [unroll] for (uint i = 0; i < 6; ++i) q += live[i].x + live[i].y + live[i].z + live[i].w > 1e30 ? 1u : 0u; } return uint2(n, q); } void tap(uint lane, uint group) { uint2 got = evaluate(lane, group); report.Store4(32u * lane, uint4(got.x, got.y, 0u, 0u)); } struct V { float4 p : SV_Position; }; [outputtopology("triangle")] [numthreads(128, 1, 1)] void main(uint lane : SV_GroupIndex, uint3 group : SV_GroupID, out vertices V v[128], out indices uint3 t[128]) { tap(lane, group.x); SetMeshOutputCounts(3, 1); V one = (V)0; if (lane < 3u) v[lane] = one; if (lane == 0u) t[0] = uint3(0, 0, 0); } ``` </details> <details><summary>The larger one it comes from, for D3D12</summary> ```hlsl // Self-contained: no title code. A mesh shader whose lanes agree, through a // groupshared array, whether to skip a block; the block sets n and r; a second // exchange follows; and a second block uses n and r. Each lane reports what it // used. EXPECT: n_used = the input's n, for every lane. #define ROOT "RootFlags(0), RootConstants(num32BitConstants=4, b0, space=9), UAV(u0, space=9), SRV(t0, space=9)" #ifndef PRESSURE #define PRESSURE 0 #endif cbuffer C : register(b0, space9) { uint4 unused; }; RWByteAddressBuffer report : register(u0, space9); ByteAddressBuffer input : register(t0, space9); // word 0: skip (0). word 1: n. word 2: 1. word 3: scale bits groupshared uint bits[8]; groupshared uint values[256]; uint2 ballot(uint tid, bool vote) { if (tid < 8u) bits[tid] = 0u; GroupMemoryBarrierWithGroupSync(); #ifdef OR_NOBRANCH InterlockedOr(bits[tid >> 5], uint(vote) << (tid & 31u)); #else if (vote) InterlockedOr(bits[tid >> 5], 1u << (tid & 31u)); #endif GroupMemoryBarrierWithGroupSync(); uint h = (tid >> 6) * 2u; #ifdef ATOMIC_READ uint2 found; InterlockedOr(bits[h], 0u, found.x); InterlockedOr(bits[h + 1u], 0u, found.y); #else uint2 found = uint2(bits[h], bits[h + 1u]); #endif GroupMemoryBarrierWithGroupSync(); return found; } uint read(uint tid, uint value, uint lane) { values[tid] = value; GroupMemoryBarrierWithGroupSync(); uint result = values[(tid & ~63u) | (lane & 63u)]; GroupMemoryBarrierWithGroupSync(); return result; } uint2 evaluate(uint tid, uint group) { uint n = (tid >> 6) << 24, r = 0u, back = 0u, skip = 0u, q = 0u, rem = 0u; #if PRESSURE float4 live[PRESSURE]; { [unroll] for (uint i = 0; i < PRESSURE; ++i) live[i] = asfloat(input.Load4(64u + 16u * i)) + (float)tid; } #endif uint first = 0u; #ifdef FIRST_READ uint2 a = ballot(tid, true); first = a.x != 0u ? firstbitlow(a.x) : a.y != 0u ? 32u + firstbitlow(a.y) : 0u; group = read(tid, group << 7, first) >> 7; #endif uint word = input.Load(4u); #ifdef SKIP_FROM_BUFFER bool skipped = input.Load(0u) != 0u; #else bool skipped = any(ballot(tid, input.Load(0u) != 0u)); #endif if (skipped) skip = max(skip, 75u); if (skip < 75u) { n = (word & 127u) + 1u; back = 0u - n; r = uint(1.0 / (float)n * asfloat(input.Load(12u))); } uint2 b = ballot(tid, true); first = b.x != 0u ? firstbitlow(b.x) : b.y != 0u ? 32u + firstbitlow(b.y) : 0u; #ifndef NO_READ uint s = read(tid, r, first); #else uint s = r; #endif if (skip < 75u) { uint e = back * s; q = (tid * s) >> 16; rem = tid - q * n; q = n <= rem ? q + 1u : q; rem = n <= rem ? rem - n : rem; q = n <= rem ? q + 1u : q; q += e * 0u; skip = max(skip, 79u); } if (skip < 79u) { q = 0u; n = 0u; } #if PRESSURE { [unroll] for (uint i = 0; i < PRESSURE; ++i) q += live[i].x + live[i].y + live[i].z + live[i].w > 1e30 ? 1u : 0u; } #endif #ifdef THIRD uint2 c = ballot(tid, n != 0u); if (any(c) && skip == 99u) q += 1u; #endif return uint2(n, q); } void tap(uint lane, uint group) { uint2 got = evaluate(lane, group); report.Store4(32u * (128u * (group & 3u) + lane), uint4(got.x, got.y, 5u, 0u)); } #ifdef MESH struct V { float4 p : SV_Position; float4 a[8] : TEXCOORD0; }; [RootSignature(ROOT)] [outputtopology("triangle")] [numthreads(128, 1, 1)] void main(uint lane : SV_GroupIndex, uint3 group : SV_GroupID, out vertices V v[128], out indices uint3 t[128]) { tap(lane, group.x); SetMeshOutputCounts(128, 1); V one = (V)0; one.p = float4(0, 0, 0, 1); v[lane] = one; if (lane == 0u) t[0] = uint3(0, 0, 0); } #else [RootSignature(ROOT)] [numthreads(128, 1, 1)] void main(uint lane : SV_GroupIndex, uint3 group : SV_GroupID) { tap(lane, group.x); } #endif ``` </details>
NickStallman commented 2026-11-29 09:06:02 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T09:06:02Z.


Some prior art, so nobody starts from zero. None is an exact match, and no public report I found has this combination (mesh shader, workgroup vote, guarded block, wrong first subgroup on NVIDIA). These look related:

  • NVIDIA, "two or more nested levels of thread divergence, where reconvergence could fail" on Blackwell: fixed in 615.71.09, described for CUDA. Forum thread. An independent report with the same shape (a value set in one if, used in a later guarded statement, hidden by tiny edits) is modular/modular#7178. Whether the graphics path got the fix isn't stated.
  • RTX 5080, Vulkan compute, driver 617.14: guarded accumulators after a groupshared read and a barrier take the other path's value. shader-slang/slang#14415; an NVIDIA engineer there says a later driver fixes "a very similar-sounding bug".
  • Mesh shaders, NVIDIA, wrong data in some subgroups when helper functions aren't inlined: AnyPS5#15917 inlines everything in the module. Our SPIR-V has one helper call (dxil-spirv's ByteAddressMask), so this isn't excluded yet.

Two things in the issue above are weaker than they read. The trigger (the merge at the skip) is inferred: most small edits hide the fault, so a passing edit says little, and there's one known NVIDIA bug elsewhere that miscompiles selects too. And "reading the value again doesn't fix it" holds for the full export set, not for the smaller test.

Next tests, no driver change needed: inline or don't-inline that helper, compile with optimisation disabled, and a control that keeps the branches but changes as much code. Not tested: other NVIDIA cards, or the newer 620.73.04 driver.

<!-- greyfinch-sync:brcly/TuxBox:comment:7253536155 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/458#issuecomment-7253536155). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T09:06:02Z. --- Some prior art, so nobody starts from zero. **None is an exact match**, and no public report I found has this combination (mesh shader, workgroup vote, guarded block, wrong first subgroup on NVIDIA). These look related: - **NVIDIA, "two or more nested levels of thread divergence, where reconvergence could fail" on Blackwell:** fixed in 615.71.09, described for CUDA. [Forum thread](https://forums.developer.nvidia.com/t/615-release-feedback-discussion/382815). An independent report with the same shape (a value set in one `if`, used in a later guarded statement, hidden by tiny edits) is [modular/modular#7178](https://github.com/modular/modular/issues/7178). Whether the graphics path got the fix isn't stated. - **RTX 5080, Vulkan compute, driver 617.14:** guarded accumulators after a groupshared read and a barrier take the other path's value. [shader-slang/slang#14415](https://github.com/shader-slang/slang/issues/14415); an NVIDIA engineer there says a later driver fixes "a very similar-sounding bug". - **Mesh shaders, NVIDIA, wrong data in some subgroups when helper functions aren't inlined:** [AnyPS5#15917](https://github.com/boykopovar/AnyPS5/pull/15917) inlines everything in the module. Our SPIR-V has one helper call (dxil-spirv's `ByteAddressMask`), so this isn't excluded yet. **Two things in the issue above are weaker than they read.** The trigger (the merge at the skip) is inferred: most small edits hide the fault, so a passing edit says little, and there's one known NVIDIA bug elsewhere that miscompiles selects too. And "reading the value again doesn't fix it" holds for the full export set, not for the smaller test. Next tests, no driver change needed: inline or don't-inline that helper, compile with optimisation disabled, and a control that keeps the branches but changes as much code. Not tested: other NVIDIA cards, or the newer 620.73.04 driver.
NickStallman commented 2026-11-29 09:11:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T09:11:01Z.


A control, which answers part of the doubt above. 64 edits (reordering, different constants, extra statements) were applied to the two shrunk shaders, each in four versions: with the branch, with the branches as selects, with the first block as selects, and with the vote taken but not used.

Version RTX 5090 (mesh), 64 edits
With the branch wrong in 45
Branches as selects 0 wrong
First block as selects 0 wrong
Vote taken, no skip 0 wrong

So the same edits are wrong with the branch and right without it, which is much stronger evidence for the branch being necessary than single edits hiding the fault. The two shrunk shaders are also right on an AMD iGPU (RADV), as mesh and compute.

It doesn't explain why, and it doesn't rule out that a different shape (without the branch) fails. The related inlining question (above) is untested. A sweep of 41 counts of live values in a D3D12 mesh case, translated with and without our change, gave no wrong result either way, so that case is not a regression test.

<!-- greyfinch-sync:brcly/TuxBox:comment:7253591875 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/458#issuecomment-7253591875). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T09:11:01Z. --- **A control, which answers part of the doubt above.** 64 edits (reordering, different constants, extra statements) were applied to the two shrunk shaders, each in four versions: with the branch, with the branches as selects, with the first block as selects, and with the vote taken but not used. | Version | RTX 5090 (mesh), 64 edits | |---|---| | With the branch | **wrong in 45** | | Branches as selects | 0 wrong | | First block as selects | 0 wrong | | Vote taken, no skip | 0 wrong | So the same edits are wrong with the branch and right without it, which is much stronger evidence for the branch being necessary than single edits hiding the fault. The two shrunk shaders are also right on an AMD iGPU (RADV), as mesh and compute. It doesn't explain why, and it doesn't rule out that a different shape (without the branch) fails. The related inlining question (above) is untested. A sweep of 41 counts of live values in a D3D12 mesh case, translated with and without our change, gave no wrong result either way, so that case is not a regression test.
NickStallman commented 2026-11-29 09:27:12 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T09:27:12Z.


A correction to the first comment above: the ByteAddressMask helper call doesn't explain the failures seen in D3D12. vkd3d-proton doesn't emit it by default (read in its source; a dump of one program's compute form has one function and no calls; its mesh form on the 5090 isn't dumped yet). The call is in the reduced plain-Vulkan shaders only, so it can be a cause there. Whether those and the D3D12 programs fail for the same reason is inferred.

<!-- greyfinch-sync:brcly/TuxBox:comment:7253772588 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/458#issuecomment-7253772588). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T09:27:12Z. --- A correction to the first comment above: the `ByteAddressMask` helper call **doesn't explain the failures seen in D3D12**. vkd3d-proton doesn't emit it by default (read in its source; a dump of one program's compute form has one function and no calls; its mesh form on the 5090 isn't dumped yet). The call is in the reduced plain-Vulkan shaders only, so it can be a cause there. Whether those and the D3D12 programs fail for the same reason is inferred.
NickStallman commented 2026-11-29 11:13:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T11:13:01Z.


A correction: my control above was not the right one, and the branch is not established as the trigger. I ran the test that could disprove it, with the criterion set beforehand: the same 64 edits of the two reduced shaders, each also with changes that keep the skip branches. 45 of 64 are wrong unchanged.

Change to each edit (RTX 5090, mesh) Wrong ones made right Right ones made wrong
Skip branches as selects 45 of 45 0 of 19
First block as selects 45 of 45 0 of 19
Arithmetic masks for the selects 45 of 45 0 of 19
Selects elsewhere, branches kept 45 of 45 0 of 19
Four more live values, branches kept 45 of 45 0 of 19
One more branch, branches kept 17 of 45 5 of 19
A no-op xor, branches kept 2 of 45 0 of 19

So two changes that keep the branch hide it as often as removing it, and selects are no evidence that the branch causes it. Small changes (the xor) mostly don't. Please don't build on "the skip's merge" from this issue.

What also holds, on five reduced modules in plain Vulkan (compute forms are all right): the mesh fault stays with the ByteAddressMask helper inlined, marked Inline or DontInline, or absent (0 calls), with VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT (inlined or not), and with MaximallyReconvergesKHR and SubgroupUniformControlFlowKHR. A subgroup barrier after the merges made 2 of 5 right. So the helper call isn't needed for it, and neither the optimiser-disable bit nor these modes avoid it.

Still true: it's right on RADV, and for three translated programs the output with #459's change is right where the old one is wrong. That those programs fail for the same reason as the reduced ones is inferred. #459 is held as a draft.

<!-- greyfinch-sync:brcly/TuxBox:comment:7254959338 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/458#issuecomment-7254959338). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T11:13:01Z. --- **A correction: my control above was not the right one, and the branch is not established as the trigger.** I ran the test that could disprove it, with the criterion set beforehand: the same 64 edits of the two reduced shaders, each also with changes that keep the skip branches. 45 of 64 are wrong unchanged. | Change to each edit (RTX 5090, mesh) | Wrong ones made right | Right ones made wrong | |---|---|---| | Skip branches as selects | 45 of 45 | 0 of 19 | | First block as selects | 45 of 45 | 0 of 19 | | Arithmetic masks for the selects | 45 of 45 | 0 of 19 | | **Selects elsewhere, branches kept** | **45 of 45** | 0 of 19 | | **Four more live values, branches kept** | **45 of 45** | 0 of 19 | | One more branch, branches kept | 17 of 45 | 5 of 19 | | A no-op xor, branches kept | 2 of 45 | 0 of 19 | So two changes that keep the branch hide it as often as removing it, and selects are no evidence that the branch causes it. Small changes (the xor) mostly don't. Please don't build on "the skip's merge" from this issue. What also holds, on five reduced modules in plain Vulkan (compute forms are all right): the mesh fault stays with the `ByteAddressMask` helper inlined, marked Inline or DontInline, or absent (0 calls), with `VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT` (inlined or not), and with `MaximallyReconvergesKHR` and `SubgroupUniformControlFlowKHR`. A subgroup barrier after the merges made 2 of 5 right. So the helper call isn't needed for it, and neither the optimiser-disable bit nor these modes avoid it. Still true: it's right on RADV, and for three translated programs the output with #459's change is right where the old one is wrong. That those programs fail for the same reason as the reduced ones is inferred. #459 is held as a draft.
NickStallman commented 2026-11-29 12:04:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T12:04:40Z.


Progress, with the controls this time. On an RTX 5090 (620.70.10), in plain Vulkan and through D3D12:

  • Only exactly 128 threads fails. 32, 64, 96, 97, 100, 112 and 127 are right; 128 is wrong in every shape I tried (64×2, 32×4, 16×8, 1×128, ...) except one form. Padding shared memory, output limits, attributes, the required subgroup size, a task shader and a specialised 128 don't help.
  • The wrong value is one constant (0x10000 in the reduced shaders, or 0 in other variants), whatever the inputs; it is deterministic, and the right value is still there right after the first block ends (though that stored copy may be recomputed, so it doesn't prove where it is lost).
  • The lane number matters, not the block. 64 edits of the reduced shaders, 45 wrong: lane number from the thread id 0 of 45 fixed, a copy of the index 0, an extra unused load 0; index + zero or index ^ zero (a zero the compiler can't know) 45 of 45, none made wrong. In three translated title programs, the same index ^ zero is right in every export and size where the original, and the thread id, are wrong.

So what matters looks like what the compiler knows about the index in a full 128-lane group. I'd read it as a candidate workaround of one line, not as a cause, until a random sample of programs is run. It's the third idea that fitted the data I had, and two didn't survive, so please wait for that.

<!-- greyfinch-sync:brcly/TuxBox:comment:7255549984 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/458#issuecomment-7255549984). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T12:04:40Z. --- Progress, with the controls this time. On an RTX 5090 (620.70.10), in plain Vulkan and through D3D12: - **Only exactly 128 threads fails.** 32, 64, 96, 97, 100, 112 and 127 are right; 128 is wrong in every shape I tried (64×2, 32×4, 16×8, 1×128, ...) except one form. Padding shared memory, output limits, attributes, the required subgroup size, a task shader and a specialised 128 don't help. - **The wrong value is one constant** (0x10000 in the reduced shaders, or 0 in other variants), whatever the inputs; it is deterministic, and the right value is still there right after the first block ends (though that stored copy may be recomputed, so it doesn't prove where it is lost). - **The lane number matters, not the block.** 64 edits of the reduced shaders, 45 wrong: lane number from the thread id 0 of 45 fixed, a copy of the index 0, an extra unused load 0; `index + zero` or `index ^ zero` (a zero the compiler can't know) **45 of 45**, none made wrong. In three translated title programs, the same `index ^ zero` is right in every export and size where the original, and the thread id, are wrong. So what matters looks like what the compiler knows about the index in a full 128-lane group. I'd read it as a candidate workaround of one line, not as a cause, until a random sample of programs is run. It's the third idea that fitted the data I had, and two didn't survive, so please wait for that.
NickStallman commented 2026-11-29 13:16:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T13:16:33Z.


The test I said to wait for: 150 voting mesh programs picked at random (fixed seed, 30 per size class), none of them used for tuning, run as mesh against their compute form. 148 could run (2 use an unsupported resource kind); 147 of those did. Every vertex count sample, counts, indices and vertex words compared; textures and heap views stubbed.

RTX 5090 (620.70.10): wrong / right AMD iGPU (RADV): wrong / right
As translated today 48 / 99 0 / 147
Lane number ^ an unknown zero (root constant) 0 / 147 0 / 147
Lane number ^ (SV_GroupID.x >> 16) 0 / 147 0 / 147

Neither hidden form made a right program wrong. (One more program couldn't run in any form; its root was refused.)

What matters, by controls on 64 edits of the reduced shaders (45 wrong): hiding the zero from a folding compiler matters (group.x & 0 and SubgroupSize >> 8 fix 0 of 45; group.x >> 16 45 of 45); hiding the low bits doesn't (1 of 45), hiding the part lane >> 5 sees does (45 of 45); hiding it in that single use is enough in the reduced shaders, and hiding it in every other use isn't. So the compiler acts on "these 32 lanes share one value" for the vote word's index. A group.x >> 16 costs one xor and needs no resource: a D3D12 dispatch dimension is at most 65,535, so it is 0 in every legal dispatch.

Not explained: why only exactly 128 threads, and why only mesh. It's a workaround, and I'll post it as a PR when the final form and both cards' full checks are done. #459 is superseded.

If someone has another NVIDIA card (or a different driver, e.g. 620.73.04), the synthetic shader in the first post is enough to say whether it's the same.

<!-- greyfinch-sync:brcly/TuxBox:comment:7256417305 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/458#issuecomment-7256417305). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T13:16:33Z. --- The test I said to wait for: **150 voting mesh programs picked at random (fixed seed, 30 per size class), none of them used for tuning**, run as mesh against their compute form. 148 could run (2 use an unsupported resource kind); 147 of those did. Every vertex count sample, counts, indices and vertex words compared; textures and heap views stubbed. | | RTX 5090 (620.70.10): wrong / right | AMD iGPU (RADV): wrong / right | |---|---|---| | As translated today | **48 / 99** | 0 / 147 | | Lane number `^` an unknown zero (root constant) | 0 / 147 | 0 / 147 | | Lane number `^` (`SV_GroupID.x >> 16`) | 0 / 147 | 0 / 147 | Neither hidden form made a right program wrong. (One more program couldn't run in any form; its root was refused.) What matters, by controls on 64 edits of the reduced shaders (45 wrong): hiding the zero from a folding compiler matters (`group.x & 0` and `SubgroupSize >> 8` fix 0 of 45; `group.x >> 16` 45 of 45); hiding the low bits doesn't (1 of 45), hiding the part `lane >> 5` sees does (45 of 45); hiding it in that single use is enough in the reduced shaders, and hiding it in every other use isn't. So the compiler acts on "these 32 lanes share one value" for the vote word's index. A `group.x >> 16` costs one xor and needs no resource: a D3D12 dispatch dimension is at most 65,535, so it is 0 in every legal dispatch. Not explained: why only exactly 128 threads, and why only mesh. It's a workaround, and I'll post it as a PR when the final form and both cards' full checks are done. #459 is superseded. If someone has another NVIDIA card (or a different driver, e.g. 620.73.04), the synthetic shader in the first post is enough to say whether it's the same.
NickStallman commented 2026-11-29 13:20:51 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T13:20:51Z.


Two corrections and the PR.

  • "The first lanes" is wrong in general. In the population test, 27 of the 48 wrong programs are wrong in lanes 0..31, 14 within 0..63, and 7 elsewhere (64..95 alone in 3). The reduced shaders and the first three programs I looked at are the 0..31 kind.
  • #459 is closed: it makes right programs wrong, as its control had hinted.
  • The workaround is #473, a draft until both cards' full checks and a game run are in.
<!-- greyfinch-sync:brcly/TuxBox:comment:7256469800 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/458#issuecomment-7256469800). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T13:20:51Z. --- Two corrections and the PR. - **"The first lanes" is wrong in general.** In the population test, 27 of the 48 wrong programs are wrong in lanes 0..31, 14 within 0..63, and 7 elsewhere (64..95 alone in 3). The reduced shaders and the first three programs I looked at are the 0..31 kind. - **#459 is closed:** it makes right programs wrong, as its control had hinted. - The workaround is #473, a draft until both cards' full checks and a game run are in.
brcly commented 2026-11-29 21:58:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T21:58:14Z.


The workaround, #473 (hiding the lane number of voting mesh programs), is on main, and your population test showed it takes the RTX 5090 from 48 wrong programs to none with no regressions on AMD. The cause looks like the driver's handling of exactly 128-thread mesh groups, not ours. Closing as worked around. Reopen if you'd rather keep it open to track the driver side, or if a voting mesh program goes wrong again.

<!-- greyfinch-sync:brcly/TuxBox:comment:7263298856 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/458#issuecomment-7263298856). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T21:58:14Z. --- The workaround, #473 (hiding the lane number of voting mesh programs), is on `main`, and your population test showed it takes the RTX 5090 from 48 wrong programs to none with no regressions on AMD. The cause looks like the driver's handling of exactly 128-thread mesh groups, not ours. Closing as worked around. Reopen if you'd rather keep it open to track the driver side, or if a voting mesh program goes wrong again.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox#458
No description provided.