From 2eab112e20801f1ac881391b24489c1c1610d63f Mon Sep 17 00:00:00 2001
From: Guilherme da Silva Fernandes Almeida
<153012160+guialmm@users.noreply.github.com>
Date: Thu, 26 Nov 2026 14:40:22 -0300
Subject: [PATCH] Tests: compute cases bind their literal sampler; the integer
gathers clamp on NVIDIA too
cs_typed_uint_gather and cs_typed_sint_gather sample a literal S#, which
reads the desktop sampler at its StaticSampler slot. ComputeCase bound no
samplers, so that slot was empty: WARP clamped the edge lanes and NVIDIA
wrapped them, one texel off (from #9, diagnosed there by upipibi).
ComputeCase now takes Samplers like the pixel cases, and the gathers bind
their sampler with PixelMemoryCases.LiteralSampler.
---
tests/FiveStar.Shaders.Tests/Cases/ComputeCase.cs | 3 +++
tests/FiveStar.Shaders.Tests/Cases/ComputeCaseRunner.cs | 6 +++---
tests/FiveStar.Shaders.Tests/Cases/PixelMemoryCases.cs | 2 +-
tests/FiveStar.Shaders.Tests/Cases/TypedViewCases.cs | 3 +++
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tests/FiveStar.Shaders.Tests/Cases/ComputeCase.cs b/tests/FiveStar.Shaders.Tests/Cases/ComputeCase.cs
index bb81cc6f..e6231d0c 100644
--- a/tests/FiveStar.Shaders.Tests/Cases/ComputeCase.cs
+++ b/tests/FiveStar.Shaders.Tests/Cases/ComputeCase.cs
@@ -41,6 +41,9 @@ public sealed record ComputeCase(string Name, string Program, int Outputs, Func<
/// Textures at their heap slots; a writable one is read back for under its slot.
public IReadOnlyList Textures { get; init; } = [];
+ /// Samplers at their heap slots: the desktop sampler a literal S# reads (unbound slots differ per driver).
+ public IReadOnlyList Samplers { get; init; } = [];
+
public int LdsBytes { get; init; }
public bool Raw { get; init; }
diff --git a/tests/FiveStar.Shaders.Tests/Cases/ComputeCaseRunner.cs b/tests/FiveStar.Shaders.Tests/Cases/ComputeCaseRunner.cs
index 878e62c7..73821195 100644
--- a/tests/FiveStar.Shaders.Tests/Cases/ComputeCaseRunner.cs
+++ b/tests/FiveStar.Shaders.Tests/Cases/ComputeCaseRunner.cs
@@ -103,7 +103,7 @@ public IReadOnlyList RunDirect(ComputeCase testCase)
var output = new BufferResource(ComputeCase.OutputHeap, [.. Enumerable.Repeat(testCase.Fill, testCase.TotalThreads * testCase.Outputs)], Writable: true);
var ring = new BufferResource(ProbeRingSlot, new uint[(MeshProbe.RecordsOffset / sizeof(uint)) + (ProbeRecords * MeshProbeRecord.Dwords)], Writable: true);
- var bindings = new Bindings { UserSgprs = user[..ComputeCase.UserSgprCount], Buffers = [output, ring, .. testCase.Buffers], Textures = testCase.Textures };
+ var bindings = new Bindings { UserSgprs = user[..ComputeCase.UserSgprCount], Buffers = [output, ring, .. testCase.Buffers], Textures = testCase.Textures, Samplers = testCase.Samplers };
var (x, y, z) = testCase.Groups;
var result = _fixture.Runner.Compute(new ComputeJob(shader, x, y, z, bindings));
@@ -130,7 +130,7 @@ public IReadOnlyList RunDirect(ComputeCase testCase)
uint[] user = [.. ComputeCase.Descriptor(ComputeCase.OutputHeap), .. testCase.SecondDescriptor, .. testCase.User, .. new uint[ComputeCase.UserSgprCount]];
var output = new BufferResource(ComputeCase.OutputHeap, [.. Enumerable.Repeat(testCase.Fill, testCase.TotalThreads * testCase.Outputs)], Writable: true);
var table = new BufferResource(ProbeRingSlot, new uint[Slots * SlotDwords], Writable: true);
- var bindings = new Bindings { UserSgprs = user[..ComputeCase.UserSgprCount], Buffers = [output, table, .. testCase.Buffers], Textures = testCase.Textures };
+ var bindings = new Bindings { UserSgprs = user[..ComputeCase.UserSgprCount], Buffers = [output, table, .. testCase.Buffers], Textures = testCase.Textures, Samplers = testCase.Samplers };
var (x, y, z) = testCase.Groups;
var result = _fixture.Runner.Compute(new ComputeJob(shader, x, y, z, bindings));
@@ -158,7 +158,7 @@ private List Run(ComputeCase testCase, Func? vari
var shader = Build(testCase, variant, direct);
uint[] user = [.. ComputeCase.Descriptor(ComputeCase.OutputHeap), .. testCase.SecondDescriptor, .. testCase.User, .. new uint[ComputeCase.UserSgprCount]];
var output = new BufferResource(ComputeCase.OutputHeap, [.. Enumerable.Repeat(testCase.Fill, testCase.TotalThreads * testCase.Outputs)], Writable: true);
- var bindings = new Bindings { UserSgprs = user[..ComputeCase.UserSgprCount], Buffers = [output, .. testCase.Buffers], Textures = testCase.Textures };
+ var bindings = new Bindings { UserSgprs = user[..ComputeCase.UserSgprCount], Buffers = [output, .. testCase.Buffers], Textures = testCase.Textures, Samplers = testCase.Samplers };
var (x, y, z) = testCase.Groups;
var result = _fixture.Runner.Compute(new ComputeJob(shader, x, y, z, bindings));
diff --git a/tests/FiveStar.Shaders.Tests/Cases/PixelMemoryCases.cs b/tests/FiveStar.Shaders.Tests/Cases/PixelMemoryCases.cs
index b3ace7bc..3d3a59ee 100644
--- a/tests/FiveStar.Shaders.Tests/Cases/PixelMemoryCases.cs
+++ b/tests/FiveStar.Shaders.Tests/Cases/PixelMemoryCases.cs
@@ -343,7 +343,7 @@ private static uint Lit(int texel)
}
/// The desktop sampler a literal S# gets, at its slot (StaticSampler, DesktopSampler).
- private static SamplerResource LiteralSampler(uint[] words, bool comparison)
+ internal static SamplerResource LiteralSampler(uint[] words, bool comparison)
{
var description = System.Runtime.InteropServices.MemoryMarshal.Cast(Translation.DesktopSampler.Describe(words, comparison))[0];
diff --git a/tests/FiveStar.Shaders.Tests/Cases/TypedViewCases.cs b/tests/FiveStar.Shaders.Tests/Cases/TypedViewCases.cs
index eb0eadfd..07d5f52c 100644
--- a/tests/FiveStar.Shaders.Tests/Cases/TypedViewCases.cs
+++ b/tests/FiveStar.Shaders.Tests/Cases/TypedViewCases.cs
@@ -356,6 +356,9 @@ s_waitcnt vmcnt(0)
{
User = [TextureHeap, 0, 0, viewClass],
Textures = [new TextureResource(TextureHeap, format, Width, Height, texels)],
+
+ // The gather reads its literal S#'s desktop sampler: unbound, WARP clamps the edge lanes and NVIDIA wraps them.
+ Samplers = [PixelMemoryCases.LiteralSampler([0x92, 0xc00000, 0x4000000, 0], comparison: false)],
};
}
}