Commit bdcc54a4 by Geoff Lang

Support writing interface blocks in OutputGLSL.

BUG=angleproject:882 BUG=angleproject:1149 Change-Id: Iea0b1d0bc586ec9517a06793386c91890b7a5115 Reviewed-on: https://chromium-review.googlesource.com/297086Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent d8edb518
...@@ -96,6 +96,11 @@ void TOutputGLSLBase::writeVariableType(const TType &type) ...@@ -96,6 +96,11 @@ void TOutputGLSLBase::writeVariableType(const TType &type)
{ {
out << "invariant "; out << "invariant ";
} }
if (type.getBasicType() == EbtInterfaceBlock)
{
TInterfaceBlock *interfaceBlock = type.getInterfaceBlock();
declareInterfaceBlockLayout(interfaceBlock);
}
TQualifier qualifier = type.getQualifier(); TQualifier qualifier = type.getQualifier();
if (qualifier != EvqTemporary && qualifier != EvqGlobal) if (qualifier != EvqTemporary && qualifier != EvqGlobal)
{ {
...@@ -134,6 +139,11 @@ void TOutputGLSLBase::writeVariableType(const TType &type) ...@@ -134,6 +139,11 @@ void TOutputGLSLBase::writeVariableType(const TType &type)
mDeclaredStructs.insert(structure->uniqueId()); mDeclaredStructs.insert(structure->uniqueId());
} }
} }
else if (type.getBasicType() == EbtInterfaceBlock)
{
TInterfaceBlock *interfaceBlock = type.getInterfaceBlock();
declareInterfaceBlock(interfaceBlock);
}
else else
{ {
if (writeVariablePrecision(type.getPrecision())) if (writeVariablePrecision(type.getPrecision()))
...@@ -1287,3 +1297,70 @@ void TOutputGLSLBase::declareStruct(const TStructure *structure) ...@@ -1287,3 +1297,70 @@ void TOutputGLSLBase::declareStruct(const TStructure *structure)
out << "}"; out << "}";
} }
void TOutputGLSLBase::declareInterfaceBlockLayout(const TInterfaceBlock *interfaceBlock)
{
TInfoSinkBase &out = objSink();
out << "layout(";
switch (interfaceBlock->blockStorage())
{
case EbsUnspecified:
case EbsShared:
// Default block storage is shared.
out << "shared";
break;
case EbsPacked:
out << "packed";
break;
case EbsStd140:
out << "std140";
break;
default:
UNREACHABLE();
break;
}
out << ", ";
switch (interfaceBlock->matrixPacking())
{
case EmpUnspecified:
case EmpColumnMajor:
// Default matrix packing is column major.
out << "column_major";
break;
case EmpRowMajor:
out << "row_major";
break;
default:
UNREACHABLE();
break;
}
out << ") ";
}
void TOutputGLSLBase::declareInterfaceBlock(const TInterfaceBlock *interfaceBlock)
{
TInfoSinkBase &out = objSink();
out << hashName(interfaceBlock->name()) << "{\n";
const TFieldList &fields = interfaceBlock->fields();
for (size_t i = 0; i < fields.size(); ++i)
{
const TField *field = fields[i];
if (writeVariablePrecision(field->type()->getPrecision()))
out << " ";
out << getTypeName(*field->type()) << " " << hashName(field->name());
if (field->type()->isArray())
out << arrayBrackets(*field->type());
out << ";\n";
}
out << "}";
}
...@@ -66,6 +66,9 @@ class TOutputGLSLBase : public TIntermTraverser ...@@ -66,6 +66,9 @@ class TOutputGLSLBase : public TIntermTraverser
bool structDeclared(const TStructure *structure) const; bool structDeclared(const TStructure *structure) const;
void declareStruct(const TStructure *structure); void declareStruct(const TStructure *structure);
void declareInterfaceBlockLayout(const TInterfaceBlock *interfaceBlock);
void declareInterfaceBlock(const TInterfaceBlock *interfaceBlock);
void writeBuiltInFunctionTriplet(Visit visit, const char *preStr, bool useEmulatedFunction); void writeBuiltInFunctionTriplet(Visit visit, const char *preStr, bool useEmulatedFunction);
TInfoSinkBase &mObjSink; TInfoSinkBase &mObjSink;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment