diff options
| author | Mukund Keshava <mkeshava@nvidia.com> | 2025-04-30 16:07:02 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-30 10:37:02 +0000 |
| commit | b0e150511a6a536c8ad9e74910b30ae179a10ec9 (patch) | |
| tree | cb749d757e0e556d987d6a30020971ed5a6aa41d /source | |
| parent | 41ac7a0d8b4e9c08eccc2153020900e0262cae84 (diff) | |
Add subscript operator support in cuda (#6830)
* cuda: Add support for subscript operator
This CL adds support for the subscript operator for Read Only
textures in cuda. Also adds a test for this.
Fixes #6781
* format code
* fix review comments
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 44b9a8860..a6e1196e3 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -3610,7 +3610,7 @@ extension _Texture<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,format> //@public: [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_metal_spirv_wgsl, texture_sm_4_1_samplerless)] + [require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, texture_sm_4_1_samplerless)] T Load(vector<int, Shape.dimensions+isArray+1> location) { __target_switch @@ -3618,6 +3618,34 @@ extension _Texture<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,format> case cpp: case hlsl: __intrinsic_asm ".Load"; + case cuda: + if (isArray != 0) + { + 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>"; + } + } + else + { + 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 metal: switch (Shape.flavor) { @@ -3824,7 +3852,7 @@ extension _Texture<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,format> { [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_metal_spirv_wgsl, texture_sm_4_1_samplerless)] + [require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, texture_sm_4_1_samplerless)] get { __target_switch @@ -3833,6 +3861,7 @@ extension _Texture<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,format> case hlsl: __intrinsic_asm ".operator[]"; case metal: + case cuda: return Load(__makeVector(location, 0)); case glsl: if (isCombined == 0) |
