summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-03-30 16:53:07 -0700
committerGitHub <noreply@github.com>2018-03-30 16:53:07 -0700
commitbd66d4f90086eeff339f076f8cedfbf78e1989b6 (patch)
tree4fe943e2bc47015ea39444fb025e7b2f533dcac8 /source/slang/emit.cpp
parent87c50cf1644454cdc9e7f6d1262bee29bfc86e80 (diff)
Fix several issues discovered by Falcor (#467)
Fixes #466 Most of these are Vulkan-related regressions. * Kludge the definition of `GroupMemoryBarrierWithGroupSync()` for GLSL so that it works around parentheses that the emit logic now introduces. * Don't emit `static` for global constants when targetting GLSL * Emit the `flat` modifier for varying input/output with integer type, when targetting GLSL * Avoid checking parameter default-value expressions more than once, because this can crash when the checking introduces syntax that is not expected to appear in the input AST
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp53
1 files changed, 49 insertions, 4 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index bed2488a1..f6a87fcfa 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -4545,6 +4545,35 @@ struct EmitVisitor
}
+ // Emit the `flat` qualifier if the underlying type
+ // of the variable is an integer type.
+ void maybeEmitGLSLFlatModifier(
+ EmitContext*,
+ Type* valueType)
+ {
+ auto tt = valueType;
+ if(auto vecType = tt->As<VectorExpressionType>())
+ tt = vecType->elementType;
+ if(auto vecType = tt->As<MatrixExpressionType>())
+ tt = vecType->getElementType();
+
+ auto baseType = tt->As<BasicExpressionType>();
+ if(!baseType)
+ return;
+
+ switch(baseType->baseType)
+ {
+ default:
+ break;
+
+ case BaseType::Int:
+ case BaseType::UInt:
+ case BaseType::UInt64:
+ Emit("flat ");
+ break;
+ }
+ }
+
void emitIRVarModifiers(
EmitContext* ctx,
VarLayout* layout,
@@ -4601,12 +4630,24 @@ struct EmitVisitor
emit("uniform ");
break;
- case LayoutResourceKind::VertexInput:
- emit("in ");
+ case LayoutResourceKind::VaryingInput:
+ {
+ emit("in ");
+ if(layout->stage == Stage::Fragment)
+ {
+ maybeEmitGLSLFlatModifier(ctx, valueType);
+ }
+ }
break;
case LayoutResourceKind::FragmentOutput:
- emit("out ");
+ {
+ emit("out ");
+ if(layout->stage != Stage::Fragment)
+ {
+ maybeEmitGLSLFlatModifier(ctx, valueType);
+ }
+ }
break;
default:
@@ -5145,7 +5186,11 @@ struct EmitVisitor
{
auto valType = valDecl->getDataType();
- emit("static const ");
+ if( ctx->shared->target != CodeGenTarget::GLSL )
+ {
+ emit("static ");
+ }
+ emit("const ");
emitIRType(ctx, valType, getIRName(valDecl));
if (valDecl->getFirstBlock())