From 45cc7a18a55a25114932a8e531a25c5d3780414c Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Fri, 24 May 2024 18:42:48 -0400 Subject: If no sample is set with a `Texture(.*)MS[]` operation, set sample to 0. (#4225) * push fix: if no sample, set to 0 for textureMS * push fixes to hlsl [] operator + test so it will error --- source/slang/hlsl.meta.slang | 20 ++++++++++++++++++++ tests/bugs/gh-4200.slang | 17 +++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/bugs/gh-4200.slang diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 11470212a..e1dc8a59a 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -2564,6 +2564,26 @@ extension __TextureImpl location) -> T + { + __glsl_extension(GL_EXT_samplerless_texture_functions) + [__readNone] + [ForceInline] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1_samplerless)] + get + { + __target_switch + { + case cpp: + case hlsl: + __intrinsic_asm "($0).sample[$1]"; + case metal: + case glsl: + case spirv: + return Load(location, 0); + } + } + } __subscript(vector location, int sampleIndex) -> T { __glsl_extension(GL_EXT_samplerless_texture_functions) diff --git a/tests/bugs/gh-4200.slang b/tests/bugs/gh-4200.slang new file mode 100644 index 000000000..e9ea1d34d --- /dev/null +++ b/tests/bugs/gh-4200.slang @@ -0,0 +1,17 @@ +//TEST:SIMPLE(filecheck=CHECK_SPV): -target spirv -emit-spirv-directly -entry computeMain -stage compute +//TEST:SIMPLE(filecheck=CHECK_HLSL): -target hlsl -entry computeMain -stage compute + +//CHECK_SPV: OpEntryPoint +//CHECK_HLSL: computeMain + +Texture2DMS Src : register(t1); +RWBuffer Dst : register(u2); + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() +{ +// CHECK_SPV: Sample %int_0 +// CHECK_HLSL: [{{.*}}1{{.*}}] + Dst[0] = Src[int2(1)]; +} \ No newline at end of file -- cgit v1.2.3