summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLujin Wang <143145775+lujinwangnv@users.noreply.github.com>2025-09-26 16:07:13 -0700
committerGitHub <noreply@github.com>2025-09-26 23:07:13 +0000
commit99de1a6203f676955f80de8c93c0f56c91d4ca96 (patch)
tree2db039fb597a55cf455747eda31d35f578ceda0c /tests
parente9f74ebfa83cd6aca39d7e3da2801cd47935bd1a (diff)
Add SPV_NV_bindless_texture support (#8534)
Treat DescriptorHandle as uint64_t instead of uint2. Implement target-specific SPIR-V emission with the bindless texture support. For OpImageTexelPointer, Image must have a type of OpTypePointer with Type OpTypeImage. Fix the issue by using [constref] in __subscript. Add a test coverage for various texture/sampler handle types. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/descriptor-handle/desc-handle-nv-bindless-texture.slang64
-rw-r--r--tests/metal/atomic-texture-buffer.slang60
2 files changed, 94 insertions, 30 deletions
diff --git a/tests/language-feature/descriptor-handle/desc-handle-nv-bindless-texture.slang b/tests/language-feature/descriptor-handle/desc-handle-nv-bindless-texture.slang
new file mode 100644
index 000000000..0f4dfb619
--- /dev/null
+++ b/tests/language-feature/descriptor-handle/desc-handle-nv-bindless-texture.slang
@@ -0,0 +1,64 @@
+//TEST:SIMPLE(filecheck=SAMPLER): -target spirv -capability spvBindlessTextureNV -stage compute -entry computeMain -DSAMPLER
+//TEST:SIMPLE(filecheck=COMBINED_IMAGE_SAMPLER): -target spirv -capability spvBindlessTextureNV -stage compute -entry computeMain -DCOMBINED_IMAGE_SAMPLER
+//TEST:SIMPLE(filecheck=SAMPLED_IMAGE): -target spirv -capability spvBindlessTextureNV -stage compute -entry computeMain -DSAMPLED_IMAGE
+//TEST:SIMPLE(filecheck=STORAGE_IMAGE): -target spirv -capability spvBindlessTextureNV -stage compute -entry computeMain -DSTORAGE_IMAGE
+
+[[vk::binding(0)]] RWTexture1D<float> t1;
+[[vk::binding(1)]] RWTexture1D<float> t2;
+[[vk::binding(2)]] RWTexture1D<float> t3;
+[[vk::binding(3)]] Texture1D<float> t4;
+
+#ifdef SAMPLER
+//SAMPLER: [[SType:%[0-9]+]] = OpTypeSampler
+//SAMPLER: OpConvertUToSamplerNV [[SType]]
+//SAMPLER: OpSampledImage
+uniform SamplerState.Handle sampler;
+#endif
+
+#ifdef COMBINED_IMAGE_SAMPLER
+//COMBINED_IMAGE_SAMPLER: [[SIType:%[0-9]+]] = OpTypeSampledImage
+//COMBINED_IMAGE_SAMPLER: OpConvertUToSampledImageNV [[SIType]]
+uniform Sampler1DShadow.Handle combinedSampler;
+#endif
+
+#ifdef SAMPLED_IMAGE
+//SAMPLED_IMAGE: [[IType0:%[0-9]+]] = OpTypeImage
+//SAMPLED_IMAGE: [[IType1:%[0-9]+]] = OpTypeImage
+//SAMPLED_IMAGE: OpConvertUToSampledImageNV [[IType1]]
+//SAMPLED_IMAGE: OpImageFetch
+uniform Texture1D<float>.Handle texture;
+#endif
+
+#ifdef STORAGE_IMAGE
+//STORAGE_IMAGE: OpConvertUToSampledImageNV
+//STORAGE_IMAGE: OpImageRead
+//STORAGE_IMAGE: OpConvertUToSampledImageNV
+//STORAGE_IMAGE: OpImageRead
+uniform RWTexture1D<float>.Handle rwTexture1;
+uniform RWTexture2D<float>.Handle rwTexture2;
+#endif
+
+[shader("compute")]
+[numthreads(8, 8, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ t1[0] = t2[0] + t2[0] + t4[0];
+
+#ifdef SAMPLER
+ t1[2] = t4.Sample(sampler, 0);
+#endif
+
+#ifdef COMBINED_IMAGE_SAMPLER
+ t1[8] = combinedSampler.Sample(0);
+#endif
+
+#ifdef SAMPLED_IMAGE
+ t1[0] = texture[0];
+#endif
+
+#ifdef STORAGE_IMAGE
+ t1[11] = rwTexture1[0];
+ t1[12] = rwTexture2[0];
+#endif
+}
+
diff --git a/tests/metal/atomic-texture-buffer.slang b/tests/metal/atomic-texture-buffer.slang
index 9f24018c7..a8f909255 100644
--- a/tests/metal/atomic-texture-buffer.slang
+++ b/tests/metal/atomic-texture-buffer.slang
@@ -30,37 +30,37 @@ void test()
#endif //FLOAT
// buffer
-// METAL: .atomic_fetch_add
-// METAL: .atomic_fetch_and
-// METAL: .atomic_fetch_max
-// METAL: .atomic_fetch_min
-// METAL: .atomic_fetch_or
-// METAL: .atomic_fetch_xor
-// METAL: .atomic_fetch_add
-// METAL: .atomic_fetch_and
-// METAL: .atomic_fetch_max
-// METAL: .atomic_fetch_min
-// METAL: .atomic_fetch_or
-// METAL: .atomic_fetch_xor
-// METAL: .atomic_exchange
-// METAL: .atomic_compare_exchange_weak
-// METAL: .atomic_compare_exchange_weak
+// METAL: ->atomic_fetch_add
+// METAL: ->atomic_fetch_and
+// METAL: ->atomic_fetch_max
+// METAL: ->atomic_fetch_min
+// METAL: ->atomic_fetch_or
+// METAL: ->atomic_fetch_xor
+// METAL: ->atomic_fetch_add
+// METAL: ->atomic_fetch_and
+// METAL: ->atomic_fetch_max
+// METAL: ->atomic_fetch_min
+// METAL: ->atomic_fetch_or
+// METAL: ->atomic_fetch_xor
+// METAL: ->atomic_exchange
+// METAL: ->atomic_compare_exchange_weak
+// METAL: ->atomic_compare_exchange_weak
-// METAL: .atomic_fetch_add
-// METAL: .atomic_fetch_and
-// METAL: .atomic_fetch_max
-// METAL: .atomic_fetch_min
-// METAL: .atomic_fetch_or
-// METAL: .atomic_fetch_xor
-// METAL: .atomic_fetch_add
-// METAL: .atomic_fetch_and
-// METAL: .atomic_fetch_max
-// METAL: .atomic_fetch_min
-// METAL: .atomic_fetch_or
-// METAL: .atomic_fetch_xor
-// METAL: .atomic_exchange
-// METAL: .atomic_compare_exchange_weak
-// METAL: .atomic_compare_exchange_weak
+// METAL: ->atomic_fetch_add
+// METAL: ->atomic_fetch_and
+// METAL: ->atomic_fetch_max
+// METAL: ->atomic_fetch_min
+// METAL: ->atomic_fetch_or
+// METAL: ->atomic_fetch_xor
+// METAL: ->atomic_fetch_add
+// METAL: ->atomic_fetch_and
+// METAL: ->atomic_fetch_max
+// METAL: ->atomic_fetch_min
+// METAL: ->atomic_fetch_or
+// METAL: ->atomic_fetch_xor
+// METAL: ->atomic_exchange
+// METAL: ->atomic_compare_exchange_weak
+// METAL: ->atomic_compare_exchange_weak
InterlockedAdd(intBuffer[0], valInt);
InterlockedAnd(intBuffer[0], valInt);
InterlockedMax(intBuffer[0], valInt);