From 672b3c3382c7bef99a646561ad75f4209c3c32ab Mon Sep 17 00:00:00 2001
From: Guilherme da Silva Fernandes Almeida
<153012160+guialmm@users.noreply.github.com>
Date: Thu, 26 Nov 2026 19:09:24 -0300
Subject: [PATCH] Mesh fallback: the table is the only binding, as the loader
binds it
The compute shader reads the capacities of u0 and u1 with GetDimensions,
which is undefined for root descriptors: NVIDIA returns 0 there and drops
every group, so msfb_ngg_strips_rootdesc drew 0x00badbad on an RTX 3060.
Nothing binds the fallback that way (the loader always uses the table), so
the root-descriptor variant and its runner support are removed and the
contract says why.
---
docs/shader-translation.md | 3 +-
.../Cases/MeshStageRunner.cs | 11 ++---
.../FiveStar.Shaders.Tests/MeshShaderTests.cs | 2 +-
.../UserDataBindingTests.cs | 3 +-
.../Warp/MeshFallbackJob.cs | 3 --
.../Warp/PipelineFactory.cs | 11 +----
.../FiveStar.Shaders.Tests/Warp/RootLayout.cs | 3 --
.../FiveStar.Shaders.Tests/Warp/WarpRunner.cs | 43 +++----------------
8 files changed, 15 insertions(+), 64 deletions(-)
diff --git a/docs/shader-translation.md b/docs/shader-translation.md
index a7457329..b3086569 100644
--- a/docs/shader-translation.md
+++ b/docs/shader-translation.md
@@ -471,7 +471,8 @@ strip. The record size `GS_VTX_DW` is derived from the LDS write offsets between
| FMA | `mad` (the prelude's exact `fma32` exists but is slow): fused on AMD and NVIDIA, unfused on WARP. `v_mad_f32`, `v_mac_f32`, `v_madak_f32` and `v_madmk_f32`, unfused on AMD, are `mad_unfused`: a `precise` product and sum, which dxc does not mark fast, so no driver contracts them (NVIDIA did) |
| `v_fract_f32` | `fract_f32`: `frac`, clamped to 0x3F7FFFFF as AMD does (`frac` of a small negative value rounds to 1.0 on NVIDIA) |
-**Mesh fallback contract** (register space 9, bound through a descriptor table):
+**Mesh fallback contract** (register space 9, bound through a descriptor table; not as root descriptors, since the
+compute shader reads the capacities of `u0` and `u1` with GetDimensions, which root descriptors leave undefined):
| Binding | Content |
|---|---|
diff --git a/tests/FiveStar.Shaders.Tests/Cases/MeshStageRunner.cs b/tests/FiveStar.Shaders.Tests/Cases/MeshStageRunner.cs
index 1bd80432..f1775a53 100644
--- a/tests/FiveStar.Shaders.Tests/Cases/MeshStageRunner.cs
+++ b/tests/FiveStar.Shaders.Tests/Cases/MeshStageRunner.cs
@@ -25,7 +25,6 @@ public sealed partial class MeshStageRunner
{
public const string Native = "ms_ngg_strips";
public const string FallbackTable = "msfb_ngg_strips";
- public const string FallbackRoot = "msfb_ngg_strips_rootdesc";
public const string FallbackOverflow = "msfb_overflow_dropped";
/// The program with the mesh launch payload (TranslationOptions.MeshPayload): drawn without the stage, and through the fallback.
@@ -207,7 +206,7 @@ public MeshStageRunner(WarpFixture fixture)
_fixture = fixture;
}
- public static IReadOnlyList Variants => [Native, FallbackTable, FallbackRoot, FallbackOverflow, Supersteps, SuperstepFallback, SuperstepCarry, Payload, PayloadFallback];
+ public static IReadOnlyList Variants => [Native, FallbackTable, FallbackOverflow, Supersteps, SuperstepFallback, SuperstepCarry, Payload, PayloadFallback];
/// Draws a variant; compiles a native mesh shader with the DXIL backend.
public IReadOnlyList Run(string variant, bool direct = false)
@@ -236,19 +235,15 @@ private List RunFallback(string variant, string mesh, byte[] pixel, Fram
var (compute, vertex) = MeshComputeFallback.Rewrite(mesh);
var stride = int.Parse(StridePattern().Match(compute).Groups[1].Value, CultureInfo.InvariantCulture);
var groups = variant == FallbackOverflow ? 3 : 1;
- var rootConstants = variant == FallbackRoot ? 16 : 60;
var job = new MeshFallbackJob(
_fixture.Workbench.Compile(variant + "_cs", compute, "cs"),
_fixture.Workbench.Compile(variant + "_vs", vertex, "vs"),
pixel,
framebuffer,
- bindings with { RootConstantCount = rootConstants },
+ bindings with { RootConstantCount = 60 },
groups,
MaxOutputs * stride,
- MaxOutputs * 12)
- {
- RootDescriptors = variant == FallbackRoot,
- };
+ MaxOutputs * 12);
if (variant == FallbackOverflow)
{
diff --git a/tests/FiveStar.Shaders.Tests/MeshShaderTests.cs b/tests/FiveStar.Shaders.Tests/MeshShaderTests.cs
index 1d381bad..62d5c689 100644
--- a/tests/FiveStar.Shaders.Tests/MeshShaderTests.cs
+++ b/tests/FiveStar.Shaders.Tests/MeshShaderTests.cs
@@ -9,7 +9,7 @@ namespace FiveStar.Shaders.Tests;
///
/// An NGG program through the two-phase mesh path, drawn natively and through the mesh-to-compute fallback (descriptor
-/// table, root descriptors, and an overflowing dispatch whose extra group must be dropped). A variant whose regions
+/// table, and an overflowing dispatch whose extra group must be dropped). A variant whose regions
/// WARP's 4-lane waves skip while the 64-lane console wave runs them is classified as right on 4 lanes and draws so.
///
public sealed class MeshShaderTests : IClassFixture
diff --git a/tests/FiveStar.Shaders.Tests/UserDataBindingTests.cs b/tests/FiveStar.Shaders.Tests/UserDataBindingTests.cs
index b95b992c..c3701d70 100644
--- a/tests/FiveStar.Shaders.Tests/UserDataBindingTests.cs
+++ b/tests/FiveStar.Shaders.Tests/UserDataBindingTests.cs
@@ -11,7 +11,7 @@ namespace FiveStar.Shaders.Tests;
///
/// The loader's two ways of passing user SGPRs, a root CBV over 128 dwords and 32 root constants
/// (--user-data-constants), give each stage the reference result: compute, pixel, vertex, geometry, and mesh drawn
-/// natively and through the fallback (whose root descriptors share the root signature with the constants). All but the
+/// natively and through the fallback (whose table shares the root signature with the constants). All but the
/// geometry program read user SGPRs: the compute output descriptor, the pixel and vertex values, the mesh counts.
/// FIVESTAR_WARP_USER_DATA runs the whole suite either way.
///
@@ -35,7 +35,6 @@ public void Every_stage_reads_its_user_sgprs(UserDataBinding binding)
["geometry"] = new GeometryStageRunner(fixture).Run(),
["mesh"] = mesh.Run(MeshStageRunner.Native),
["mesh fallback, table"] = mesh.Run(MeshStageRunner.FallbackTable),
- ["mesh fallback, root descriptors"] = mesh.Run(MeshStageRunner.FallbackRoot),
};
var failed = runs.Where(run => run.Value.Count != 0).Select(run => $"{run.Key}: {run.Value.Count} mismatches, {string.Join("; ", run.Value.Take(4))}");
diff --git a/tests/FiveStar.Shaders.Tests/Warp/MeshFallbackJob.cs b/tests/FiveStar.Shaders.Tests/Warp/MeshFallbackJob.cs
index 709515e6..308298d5 100644
--- a/tests/FiveStar.Shaders.Tests/Warp/MeshFallbackJob.cs
+++ b/tests/FiveStar.Shaders.Tests/Warp/MeshFallbackJob.cs
@@ -20,7 +20,4 @@ public sealed record MeshFallbackJob(
int IndexBytes)
{
public IReadOnlyList StaleIndices { get; init; } = [];
-
- /// Bind u0..u2 / t0 as root descriptors instead of a descriptor table.
- public bool RootDescriptors { get; init; }
}
diff --git a/tests/FiveStar.Shaders.Tests/Warp/PipelineFactory.cs b/tests/FiveStar.Shaders.Tests/Warp/PipelineFactory.cs
index 2997ea99..c1564d80 100644
--- a/tests/FiveStar.Shaders.Tests/Warp/PipelineFactory.cs
+++ b/tests/FiveStar.Shaders.Tests/Warp/PipelineFactory.cs
@@ -19,16 +19,7 @@ public static ID3D12RootSignature RootSignature(ID3D12Device device, int rootCon
| RootSignatureFlags.SamplerHeapDirectlyIndexed | RootSignatureFlags.AllowInputAssemblerInputLayout;
var parameters = new List { UserData(rootConstants, binding) };
- if (layout == RootLayout.FallbackRoot)
- {
- for (uint register = 0; register < FallbackUavs; register++)
- {
- parameters.Add(new RootParameter1(RootParameterType.UnorderedAccessView, new RootDescriptor1(register, FallbackSpace), ShaderVisibility.All));
- }
-
- parameters.Add(new RootParameter1(RootParameterType.ShaderResourceView, new RootDescriptor1(0, FallbackSpace), ShaderVisibility.All));
- }
- else if (layout == RootLayout.FallbackTable)
+ if (layout == RootLayout.FallbackTable)
{
var volatileFlags = DescriptorRangeFlags.DataVolatile | DescriptorRangeFlags.DescriptorsVolatile;
DescriptorRange1[] ranges =
diff --git a/tests/FiveStar.Shaders.Tests/Warp/RootLayout.cs b/tests/FiveStar.Shaders.Tests/Warp/RootLayout.cs
index 8778cfc8..4924503f 100644
--- a/tests/FiveStar.Shaders.Tests/Warp/RootLayout.cs
+++ b/tests/FiveStar.Shaders.Tests/Warp/RootLayout.cs
@@ -11,7 +11,4 @@ public enum RootLayout
/// Mesh fallback: u0..u2 and t0 (space 9) through a descriptor table.
FallbackTable,
-
- /// Mesh fallback: u0..u2 and t0 (space 9) as root descriptors.
- FallbackRoot,
}
diff --git a/tests/FiveStar.Shaders.Tests/Warp/WarpRunner.cs b/tests/FiveStar.Shaders.Tests/Warp/WarpRunner.cs
index 448b93dd..24a37e86 100644
--- a/tests/FiveStar.Shaders.Tests/Warp/WarpRunner.cs
+++ b/tests/FiveStar.Shaders.Tests/Warp/WarpRunner.cs
@@ -105,8 +105,7 @@ public WarpResult MeshFallback(MeshFallbackJob job)
{
return Run(recording =>
{
- var layout = job.RootDescriptors ? RootLayout.FallbackRoot : RootLayout.FallbackTable;
- var root = recording.Own(PipelineFactory.RootSignature(_device.Device, job.Bindings.RootConstantCount, layout, _userData));
+ var root = recording.Own(PipelineFactory.RootSignature(_device.Device, job.Bindings.RootConstantCount, RootLayout.FallbackTable, _userData));
recording.CreateHeaps(job.Bindings);
var formats = recording.CreateTargets(job.Framebuffer);
@@ -116,7 +115,7 @@ public WarpResult MeshFallback(MeshFallbackJob job)
recording.BeginStatistics();
recording.SetComputeRoot(root, job.Bindings);
- BindFallback(recording, job, buffers, compute: true);
+ recording.List.SetComputeRootDescriptorTable(1, recording.ResourceTable(FallbackSlot));
recording.List.SetPipelineState(compute);
recording.List.Dispatch((uint)job.Groups, 1, 1);
@@ -124,7 +123,7 @@ public WarpResult MeshFallback(MeshFallbackJob job)
Transition(recording, buffers.Indices, ResourceStates.UnorderedAccess, ResourceStates.IndexBuffer);
Transition(recording, buffers.Counter, ResourceStates.UnorderedAccess, ResourceStates.IndirectArgument);
recording.SetGraphicsRoot(root, job.Bindings);
- BindFallback(recording, job, buffers, compute: false);
+ recording.List.SetGraphicsRootDescriptorTable(1, recording.ResourceTable(FallbackSlot));
recording.List.SetPipelineState(draw);
DrawIndirect(recording, job, buffers);
@@ -141,42 +140,14 @@ private static (ID3D12Resource Vertices, ID3D12Resource Indices, ID3D12Resource
var indices = recording.FilledBuffer([.. job.StaleIndices], job.IndexBytes, ResourceStates.UnorderedAccess, flags);
var counter = recording.FilledBuffer([0, 1, 0, 0, 0, 0, 0, 0], CounterBytes, ResourceStates.UnorderedAccess, flags);
- if (!job.RootDescriptors)
- {
- recording.CreateRawUav(vertices, job.VertexBytes / 4, FallbackSlot);
- recording.CreateRawUav(indices, job.IndexBytes / 4, FallbackSlot + 1);
- recording.CreateRawUav(counter, CounterBytes / 4, FallbackSlot + 2);
- recording.CreateRawSrv(vertices, job.VertexBytes / 4, FallbackSlot + 3);
- }
+ recording.CreateRawUav(vertices, job.VertexBytes / 4, FallbackSlot);
+ recording.CreateRawUav(indices, job.IndexBytes / 4, FallbackSlot + 1);
+ recording.CreateRawUav(counter, CounterBytes / 4, FallbackSlot + 2);
+ recording.CreateRawSrv(vertices, job.VertexBytes / 4, FallbackSlot + 3);
return (vertices, indices, counter);
}
- private static void BindFallback(
- Recording recording, MeshFallbackJob job, (ID3D12Resource Vertices, ID3D12Resource Indices, ID3D12Resource Counter) buffers, bool compute)
- {
- var list = recording.List;
-
- if (!job.RootDescriptors && compute)
- {
- list.SetComputeRootDescriptorTable(1, recording.ResourceTable(FallbackSlot));
- }
- else if (!job.RootDescriptors)
- {
- list.SetGraphicsRootDescriptorTable(1, recording.ResourceTable(FallbackSlot));
- }
- else if (compute)
- {
- list.SetComputeRootUnorderedAccessView(1, buffers.Vertices.GPUVirtualAddress);
- list.SetComputeRootUnorderedAccessView(2, buffers.Indices.GPUVirtualAddress);
- list.SetComputeRootUnorderedAccessView(3, buffers.Counter.GPUVirtualAddress);
- }
- else
- {
- list.SetGraphicsRootShaderResourceView(4, buffers.Vertices.GPUVirtualAddress);
- }
- }
-
private void DrawIndirect(
Recording recording, MeshFallbackJob job, (ID3D12Resource Vertices, ID3D12Resource Indices, ID3D12Resource Counter) buffers)
{