summaryrefslogtreecommitdiff
path: root/source/slang/core.meta.slang
diff options
context:
space:
mode:
authorYong He <yonghe@google.com>2019-01-25 17:44:24 -0800
committerYong He <yonghe@google.com>2019-01-25 18:11:57 -0800
commiteefe2539373a2e17eda2f11c420908c0aebcac6d (patch)
treed56d36118b83ba23cc1b817035ab4f5b54034c99 /source/slang/core.meta.slang
parent864c38ee72991f414f2478ccacb462bfb11b4bca (diff)
Add GLSL translation rules for `SampleCmp`, `asint` and `asfloat`.
Diffstat (limited to 'source/slang/core.meta.slang')
-rw-r--r--source/slang/core.meta.slang26
1 files changed, 15 insertions, 11 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index 0e8458218..e6bad3f50 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -875,15 +875,22 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, float bias, ";
sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
}
-
- // `SampleCmp()` and `SampleCmpLevelZero`
- sb << "float SampleCmp(SamplerComparisonState s, ";
- sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
- sb << "float compareValue";
- sb << ");\n";
-
int baseCoordCount = kBaseTextureTypes[tt].coordCount;
int arrCoordCount = baseCoordCount + isArray;
+ if (arrCoordCount <= 3)
+ {
+ // `SampleCmp()` and `SampleCmpLevelZero`
+ sb << "__target_intrinsic(glsl, \"texture($p, vec" << arrCoordCount + 1 << "($2, $3))\")";
+ sb << "float SampleCmp(SamplerComparisonState s, ";
+ sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
+ sb << "float compareValue";
+ sb << ");\n";
+ sb << "__target_intrinsic(glsl, \"texture($p, vec" << arrCoordCount + 1 << "($2, $3))\")";
+ sb << "float SampleCmpLevelZero(SamplerComparisonState s, ";
+ sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
+ sb << "float compareValue";
+ sb << ");\n";
+ }
if (arrCoordCount < 3)
{
int extCoordCount = arrCoordCount + 1;
@@ -923,10 +930,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << ", vec" << baseCoordCount << "(0.0)";
sb << ")$z\")\n";
}
- sb << "float SampleCmpLevelZero(SamplerComparisonState s, ";
- sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
- sb << "float compareValue";
- sb << ");\n";
+
if( baseShape != TextureFlavor::Shape::ShapeCube )
{