Commit ae69d7e1 by Olli Etuaho

Output layout qualifiers in GLSL output

Output layout qualifiers for vertex shader attributes and fragment shader outputs. This applies both to ESSL output and GLSL output. If the source shader is in ESSL1, the code has no effect since there's no layout information in the AST. BUG=525930 TEST=angle_unittests, angle_end2end_tests Change-Id: I48b3aa56116c15d11599b030eed4c45be2c8fc7e Reviewed-on: https://chromium-review.googlesource.com/304550 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 839ce0b4
......@@ -89,6 +89,19 @@ void TOutputGLSLBase::writeBuiltInFunctionTriplet(
writeTriplet(visit, preString.c_str(), ", ", ")");
}
void TOutputGLSLBase::writeLayoutQualifier(const TType &type)
{
if (type.getQualifier() == EvqFragmentOut || type.getQualifier() == EvqVertexIn)
{
const TLayoutQualifier &layoutQualifier = type.getLayoutQualifier();
if (layoutQualifier.location >= 0)
{
TInfoSinkBase &out = objSink();
out << "layout(location = " << layoutQualifier.location << ") ";
}
}
}
void TOutputGLSLBase::writeVariableType(const TType &type)
{
TInfoSinkBase &out = objSink();
......@@ -876,6 +889,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
{
const TIntermSequence &sequence = *(node->getSequence());
const TIntermTyped *variable = sequence.front()->getAsTyped();
writeLayoutQualifier(variable->getType());
writeVariableType(variable->getType());
out << " ";
mDeclaringVariables = true;
......
......@@ -32,6 +32,7 @@ class TOutputGLSLBase : public TIntermTraverser
protected:
TInfoSinkBase &objSink() { return mObjSink; }
void writeTriplet(Visit visit, const char *preStr, const char *inStr, const char *postStr);
void writeLayoutQualifier(const TType &type);
void writeVariableType(const TType &type);
virtual bool writeVariablePrecision(TPrecision precision) = 0;
void writeFunctionParameters(const TIntermSequence &args);
......
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