summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/slang/core.meta.slang4
-rw-r--r--tests/cross-compile/glsl-samplecmplevelzero.slang12
2 files changed, 15 insertions, 1 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index d99b241c0..5342800be 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -1944,7 +1944,7 @@ struct TextureTypeInfo
sb << "float" << base.coordCount + isArray << " location, ";
sb << "float compareValue";
sb << ");\n";
- sb << "__target_intrinsic(glsl, \"texture($p, vec" << arrCoordCount + 1 << "($2, $3))\")";
+ sb << "__target_intrinsic(glsl, \"textureLod($p, vec" << arrCoordCount + 1 << "($2, $3), 0)\")";
if (isReadOnly)
sb << "[__readNone]\n";
sb << "float SampleCmpLevelZero(SamplerComparisonState s, ";
@@ -2001,6 +2001,7 @@ struct TextureTypeInfo
// saying they only exclude `offset` for cube maps (which makes
// sense). I'm going to assume the documentation for `SampleCmp`
// is just wrong.
+ sb << "__target_intrinsic(glsl, \"textureOffset($p, vec" << arrCoordCount + 1 << "($2, $3), $4)\")";
if (isReadOnly)
sb << "[__readNone]\n";
sb << "float SampleCmp(SamplerComparisonState s, ";
@@ -2008,6 +2009,7 @@ struct TextureTypeInfo
sb << "float compareValue, ";
sb << "constexpr int" << base.coordCount << " offset);\n";
+ sb << "__target_intrinsic(glsl, \"textureLodOffset($p, vec" << arrCoordCount + 1 << "($2, $3), 0, $4)\")";
if (isReadOnly)
sb << "[__readNone]\n";
sb << "float SampleCmpLevelZero(SamplerComparisonState s, ";
diff --git a/tests/cross-compile/glsl-samplecmplevelzero.slang b/tests/cross-compile/glsl-samplecmplevelzero.slang
new file mode 100644
index 000000000..4bfd557cc
--- /dev/null
+++ b/tests/cross-compile/glsl-samplecmplevelzero.slang
@@ -0,0 +1,12 @@
+//TEST:CROSS_COMPILE(filecheck=CHECK): -profile ps_5_0 -entry main -target glsl
+
+// CHECK: float _S3 = (textureLod(sampler2DShadow(shadowMap_0,sampler_0), vec3((_S2), (0.0)), 0));
+// CHECK: float _S4 = (textureLodOffset(sampler2DShadow(shadowMap_0,sampler_0), vec3((_S2), (0.0)), 0, (ivec2(1, 1))));
+
+Texture2D shadowMap;
+SamplerComparisonState sampler;
+float4 main(float4 p : SV_POSITION)
+{
+ return shadowMap.SampleCmpLevelZero(sampler, float2(0.0), 0.0)
+ + shadowMap.SampleCmpLevelZero(sampler, float2(0.0), 0.0, int2(1,1));
+}