summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2024-09-23 19:46:32 -0700
committerGitHub <noreply@github.com>2024-09-23 19:46:32 -0700
commitef3552d9cbde0c06ddc77150b8ab68674d8422d3 (patch)
tree99da915f30fa4d91d77591231b66f62eda5dd8a0 /tests
parent3e950e11f46fa3d2a84f04345ea860907ae9715a (diff)
Feature/wgsl intrinsic texture gather (#5141)
This PR implements the texture gather functions for WGSL. The pattern was very similar to how Metal was implemented. Before copy and paste from the Metal implementation, I had to clean up the Metal implementation to make it more readable and maintainable. Gather functions are available only for 2D and 3D textures. Their `array` and `depth` variants may or may not be supported depending on the target. `static_assert` ensures that Gather functions are available only for 2D and 3D textures. Removed incorrect use of "$p" argument for targeting GLSL.
Diffstat (limited to 'tests')
-rw-r--r--tests/wgsl/texture-sampler-less.slang8
-rw-r--r--tests/wgsl/texture.slang8
2 files changed, 12 insertions, 4 deletions
diff --git a/tests/wgsl/texture-sampler-less.slang b/tests/wgsl/texture-sampler-less.slang
index 1a6cb5341..893e867b7 100644
--- a/tests/wgsl/texture-sampler-less.slang
+++ b/tests/wgsl/texture-sampler-less.slang
@@ -311,23 +311,27 @@ bool TEST_texture(
// https://www.w3.org/TR/WGSL/#texturegather
// ==================================
-#if 0
+ // WGSL: textureGather({{.*}}t2D
&& all(Tv4(T(0)) == t2D.Gather(float2(u, u)))
+ // WGSL: textureGather({{.*}}tCube
&& all(Tv4(T(0)) == tCube.Gather(normalize(float3(u, 1 - u, u))))
+ // WGSL: textureGather({{.*}}t2DArray
&& all(Tv4(T(0)) == t2DArray.Gather(float3(u, u, 0)))
+ // WGSL: textureGather({{.*}}tCubeArray
&& all(Tv4(T(0)) == tCubeArray.Gather(float4(normalize(float3(u, 1 - u, u)), 0)))
#if TEST_WHEN_CONSTEXPR_WORKS_FOR_OFFSET
// Offset variant
+ // W-GSL: textureGather({{.*}}t2D
&& all(Tv4(T(0)) == t2D.Gather(float2(u2, u), int2(0, 0)))
+ // W-GSL: textureGather({{.*}}t2DArray
&& all(Tv4(T(0)) == t2DArray.Gather(float3(u2, u, 0), int2(0, 0)))
#endif // #if TEST_WHEN_CONSTEXPR_WORKS_FOR_OFFSET
-#endif
// =====================================
// T SampleGrad()
diff --git a/tests/wgsl/texture.slang b/tests/wgsl/texture.slang
index 999555a55..af39cf52a 100644
--- a/tests/wgsl/texture.slang
+++ b/tests/wgsl/texture.slang
@@ -346,21 +346,25 @@ bool TEST_texture(
// https://www.w3.org/TR/WGSL/#texturegather
// ==================================
-#if 0
+ // WGSL: textureGather({{.*}}t2D
&& all(Tv4(T(0)) == t2D.Gather(samplerState, float2(u, u)))
+ // WGSL: textureGather({{.*}}tCube
&& all(Tv4(T(0)) == tCube.Gather(samplerState, normalize(float3(u, 1 - u, u))))
+ // WGSL: textureGather({{.*}}t2DArray
&& all(Tv4(T(0)) == t2DArray.Gather(samplerState, float3(u, u, 0)))
+ // WGSL: textureGather({{.*}}tCubeArray
&& all(Tv4(T(0)) == tCubeArray.Gather(samplerState, float4(normalize(float3(u, 1 - u, u)), 0)))
// Offset variant
+ // WGSL: textureGather({{.*}}t2D
&& all(Tv4(T(0)) == t2D.Gather(samplerState, float2(u2, u), int2(0, 0)))
+ // WGSL: textureGather({{.*}}t2DArray
&& all(Tv4(T(0)) == t2DArray.Gather(samplerState, float3(u2, u, 0), int2(0, 0)))
-#endif
// =====================================
// T SampleGrad()