summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorSimon Kallweit <64953474+skallweitNV@users.noreply.github.com>2025-10-08 20:18:23 +0200
committerGitHub <noreply@github.com>2025-10-08 18:18:23 +0000
commit4b3fd0a4536f873649e6fcdefbaf2f8b6f0897e0 (patch)
tree1d6369221c8e1786f97de0d36fce3d9b955c4150 /source/slang
parente4d1200cb45260b2a114d6f4f8f8d0b389a7da56 (diff)
Improve texture loads and stores on CUDA (#8644)
- fix handling layer and mip level - add support for 1D layered textures - reduce code by using macros - assert when trying to emit unsupported intrinsics There is a new set of unit tests in slang-rhi for exhaustive testing of shader loads/stores on textures. These fixes allow to enable most of these tests. Formatted loads/stores on surfaces are not supported in PTX ISA, so this would require codegen for the conversion which in theory should be possible but not as part of the CUDA prelude.
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/hlsl.meta.slang41
1 files changed, 19 insertions, 22 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index ff2762b23..26c2a43cb 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -3654,32 +3654,29 @@ extension _Texture<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,format>
__intrinsic_asm ".Load";
case cuda:
if (isArray != 0)
+ {
+ switch(Shape.flavor)
{
- static_assert(Shape.flavor == $(SLANG_TEXTURE_2D) || Shape.flavor == $(SLANG_TEXTURE_3D),
- "Integer coordinates are supported for texture reads only for 2D and 3D textures and 2D array textures.");
-
- if (Shape.flavor == $(SLANG_TEXTURE_2D))
- {
- __intrinsic_asm "tex2DArrayfetch_int<$T0>($0, ($1).x, ($1).y, ($1).z)";
- }
- else
- {
- __intrinsic_asm "<invalid intrinsic>";
- }
+ case $(SLANG_TEXTURE_1D):
+ __intrinsic_asm "tex1DArrayfetch_int<$T0>($0, ($1).x, ($1).y, ($1).z)";
+ case $(SLANG_TEXTURE_2D):
+ __intrinsic_asm "tex2DArrayfetch_int<$T0>($0, ($1).x, ($1).y, ($1).z, ($1).w)";
}
- else
+ }
+ else
+ {
+ switch(Shape.flavor)
{
- switch(Shape.flavor)
- {
- case $(SLANG_TEXTURE_2D):
- __intrinsic_asm "tex2Dfetch_int<$T0>($0, ($1).x, ($1).y)";
- case $(SLANG_TEXTURE_3D):
- __intrinsic_asm "tex3Dfetch_int<$T0>($0, ($1).x, ($1).y, ($1).z)";
- case $(SLANG_TEXTURE_CUBE):
- default:
- __intrinsic_asm "<invalid intrinsic>";
- }
+ case $(SLANG_TEXTURE_1D):
+ __intrinsic_asm "tex1Dfetch_int<$T0>($0, ($1).x, ($1).y)";
+ case $(SLANG_TEXTURE_2D):
+ __intrinsic_asm "tex2Dfetch_int<$T0>($0, ($1).x, ($1).y, ($1).z)";
+ case $(SLANG_TEXTURE_3D):
+ __intrinsic_asm "tex3Dfetch_int<$T0>($0, ($1).x, ($1).y, ($1).z, ($1).w)";
}
+ }
+ static_assert(false, "Unsupported 'Load' of 'texture' for 'cuda' target");
+ __intrinsic_asm "<invalid intrinsic>";
case metal:
switch (Shape.flavor)
{