summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-07-18 15:26:20 -0700
committerGitHub <noreply@github.com>2017-07-18 15:26:20 -0700
commit4c3d56a304de60ce722bee8418da929ae8895adc (patch)
tree2cc4e5645e56df929d1a8eee1815f26ab4a7c3e9 /source
parenta01014567cccc2582547ed10870352629ffd6484 (diff)
parent4d6da3a1177f27807d47ca46ec25ed96eda4642c (diff)
Merge pull request #121 from tfoleyNV/gaussian-blur-fixes
Gaussian blur fixes
Diffstat (limited to 'source')
-rw-r--r--source/slang/emit.cpp46
-rw-r--r--source/slang/slang-stdlib.cpp3
2 files changed, 49 insertions, 0 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 76dc9c75f..8660b5f93 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -1943,6 +1943,52 @@ struct EmitVisitor
}
break;
+ case 'z':
+ // If we are calling a D3D texturing operation in the form t.Foo(s, ...),
+ // where `t` is a `Texture*<T>`, then this is the step where we try to
+ // properly swizzle the output of the equivalent GLSL call into the right
+ // shape.
+ assert(argCount > 0);
+ if (auto memberExpr = callExpr->FunctionExpr.As<MemberExpressionSyntaxNode>())
+ {
+ auto base = memberExpr->BaseExpression;
+ if (auto baseTextureType = base->Type->As<TextureType>())
+ {
+ auto elementType = baseTextureType->elementType;
+ if (auto basicType = elementType->As<BasicExpressionType>())
+ {
+ // A scalar result is expected
+ Emit(".x");
+ }
+ else if (auto vectorType = elementType->As<VectorExpressionType>())
+ {
+ // A vector result is expected
+ auto elementCount = GetIntVal(vectorType->elementCount);
+
+ if (elementCount < 4)
+ {
+ char const* swiz[] = { "", ".x", ".xy", ".xyz", "" };
+ Emit(swiz[elementCount]);
+ }
+ }
+ else
+ {
+ // What other cases are possible?
+ }
+ }
+ else
+ {
+ assert(!"unexpected");
+ }
+
+ }
+ else
+ {
+ assert(!"unexpected");
+ }
+ break;
+
+
default:
assert(!"unexpected");
break;
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp
index b26fc8a8e..a62db693c 100644
--- a/source/slang/slang-stdlib.cpp
+++ b/source/slang/slang-stdlib.cpp
@@ -2024,9 +2024,12 @@ namespace Slang
sb << "__intrinsic void GetDimensions(out uint dim);\n";
+ sb << "__intrinsic(glsl, \"texelFetch($P, $0)$z\")\n";
sb << "__intrinsic T Load(int location);\n";
+
sb << "__intrinsic T Load(int location, out uint status);\n";
+ sb << "__intrinsic(glsl, \"texelFetch($P, int($0))$z\")\n";
sb << "__intrinsic __subscript(uint index) -> T";
if (kBaseBufferAccessLevels[aa].access != SLANG_RESOURCE_ACCESS_READ)