diff options
| author | Yong He <yonghe@outlook.com> | 2019-01-28 10:48:10 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-28 10:48:10 -0800 |
| commit | f2579a60a3de45d5f48f1e1433ba736647988e8e (patch) | |
| tree | fe9c11d126e8ee656726d92ff55d6be1e81c45c5 /source/slang/core.meta.slang | |
| parent | 016f38981a52dd31aa4d3d35272c37f992a07862 (diff) | |
| parent | 71f1750dea041cb19eb6f25def585085dd171915 (diff) | |
Merge pull request #806 from csyonghe/texture-fix
Add GLSL translation rules for SampleCmp and bit reinterpretation functions
Diffstat (limited to 'source/slang/core.meta.slang')
| -rw-r--r-- | source/slang/core.meta.slang | 26 |
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 ) { |
