Commit b120eac2 by Jamie Madill Committed by Shannon Woods

Update the shader translator to use new enums for ES3 shader vertex input and fragment outputs.

This fixes many corner cases and error messages with ES3 syntax. TRAC #23268 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens Authored-by: Jamie Madill
parent f8dc4fb6
...@@ -93,6 +93,8 @@ enum TQualifier ...@@ -93,6 +93,8 @@ enum TQualifier
EvqInvariantVaryingIn, // readonly, fragment shaders only EvqInvariantVaryingIn, // readonly, fragment shaders only
EvqInvariantVaryingOut, // vertex shaders only read/write EvqInvariantVaryingOut, // vertex shaders only read/write
EvqUniform, // Readonly, vertex and fragment EvqUniform, // Readonly, vertex and fragment
EvqVertexInput, // Vertex shader input
EvqFragmentOutput, // Fragment shader output
// pack/unpack input and output // pack/unpack input and output
EvqInput, EvqInput,
...@@ -168,6 +170,8 @@ inline const char* getQualifierString(TQualifier q) ...@@ -168,6 +170,8 @@ inline const char* getQualifierString(TQualifier q)
case EvqInvariantVaryingIn: return "invariant varying"; break; case EvqInvariantVaryingIn: return "invariant varying"; break;
case EvqInvariantVaryingOut:return "invariant varying"; break; case EvqInvariantVaryingOut:return "invariant varying"; break;
case EvqUniform: return "uniform"; break; case EvqUniform: return "uniform"; break;
case EvqVertexInput: return "in"; break;
case EvqFragmentOutput: return "out"; break;
case EvqIn: return "in"; break; case EvqIn: return "in"; break;
case EvqOut: return "out"; break; case EvqOut: return "out"; break;
case EvqInOut: return "inout"; break; case EvqInOut: return "inout"; break;
......
...@@ -1397,7 +1397,7 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node) ...@@ -1397,7 +1397,7 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node)
out << decorateUniform(name, node->getType()); out << decorateUniform(name, node->getType());
} }
} }
else if (qualifier == EvqAttribute) else if (qualifier == EvqAttribute || qualifier == EvqVertexInput)
{ {
mReferencedAttributes[name] = node; mReferencedAttributes[name] = node;
out << decorate(name); out << decorate(name);
...@@ -1407,7 +1407,7 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node) ...@@ -1407,7 +1407,7 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node)
mReferencedVaryings[name] = node; mReferencedVaryings[name] = node;
out << decorate(name); out << decorate(name);
} }
else if (qualifier == EvqFragColor) else if (qualifier == EvqFragColor || qualifier == EvqFragmentOutput)
{ {
out << "gl_Color[0]"; out << "gl_Color[0]";
mUsesFragColor = true; mUsesFragColor = true;
......
...@@ -316,6 +316,7 @@ bool TParseContext::lValueErrorCheck(int line, const char* op, TIntermTyped* nod ...@@ -316,6 +316,7 @@ bool TParseContext::lValueErrorCheck(int line, const char* op, TIntermTyped* nod
case EvqConst: message = "can't modify a const"; break; case EvqConst: message = "can't modify a const"; break;
case EvqConstReadOnly: message = "can't modify a const"; break; case EvqConstReadOnly: message = "can't modify a const"; break;
case EvqAttribute: message = "can't modify an attribute"; break; case EvqAttribute: message = "can't modify an attribute"; break;
case EvqVertexInput: message = "can't modify an input"; break;
case EvqUniform: message = "can't modify a uniform"; break; case EvqUniform: message = "can't modify a uniform"; break;
case EvqVaryingIn: message = "can't modify a varying"; break; case EvqVaryingIn: message = "can't modify a varying"; break;
case EvqInput: message = "can't modify an input"; break; case EvqInput: message = "can't modify an input"; break;
...@@ -628,12 +629,19 @@ bool TParseContext::samplerErrorCheck(int line, const TPublicType& pType, const ...@@ -628,12 +629,19 @@ bool TParseContext::samplerErrorCheck(int line, const TPublicType& pType, const
bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType) bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType)
{ {
if ((pType.qualifier == EvqVaryingIn || pType.qualifier == EvqVaryingOut || pType.qualifier == EvqAttribute) && switch (pType.qualifier)
pType.type == EbtStruct) { {
case EvqVaryingIn:
case EvqVaryingOut:
case EvqAttribute:
case EvqVertexInput:
case EvqFragmentOutput:
if (pType.type == EbtStruct)
{
error(line, "cannot be used with a structure", getQualifierString(pType.qualifier)); error(line, "cannot be used with a structure", getQualifierString(pType.qualifier));
return true; return true;
} }
}
if (pType.qualifier != EvqUniform && samplerErrorCheck(line, pType, "samplers must be uniform")) if (pType.qualifier != EvqUniform && samplerErrorCheck(line, pType, "samplers must be uniform"))
return true; return true;
...@@ -717,7 +725,7 @@ bool TParseContext::arraySizeErrorCheck(int line, TIntermTyped* expr, int& size) ...@@ -717,7 +725,7 @@ bool TParseContext::arraySizeErrorCheck(int line, TIntermTyped* expr, int& size)
// //
bool TParseContext::arrayQualifierErrorCheck(int line, TPublicType type) bool TParseContext::arrayQualifierErrorCheck(int line, TPublicType type)
{ {
if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqConst)) { if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqVertexInput) || (type.qualifier == EvqConst)) {
error(line, "cannot declare arrays of this qualifier", TType(type).getCompleteString().c_str()); error(line, "cannot declare arrays of this qualifier", TType(type).getCompleteString().c_str());
return true; return true;
} }
...@@ -1151,16 +1159,20 @@ TPublicType TParseContext::addFullySpecifiedType(TQualifier qualifier, const TPu ...@@ -1151,16 +1159,20 @@ TPublicType TParseContext::addFullySpecifiedType(TQualifier qualifier, const TPu
} }
else else
{ {
if (qualifier == EvqAttribute && typeSpecifier.type == EbtBool) switch (qualifier)
{
case EvqVertexInput:
case EvqFragmentOutput:
case EvqVaryingIn:
case EvqVaryingOut:
if (typeSpecifier.type == EbtBool)
{ {
error(typeSpecifier.line, "cannot be bool", getQualifierString(qualifier)); error(typeSpecifier.line, "cannot be bool", getQualifierString(qualifier));
recover(); recover();
} }
break;
if ((qualifier == EvqVaryingIn || qualifier == EvqVaryingOut) && typeSpecifier.type == EbtBool) default: break;
{
error(typeSpecifier.line, "cannot be bool", getQualifierString(qualifier));
recover();
} }
} }
......
...@@ -232,9 +232,9 @@ bool CollectAttribsUniforms::visitAggregate(Visit, TIntermAggregate* node) ...@@ -232,9 +232,9 @@ bool CollectAttribsUniforms::visitAggregate(Visit, TIntermAggregate* node)
case EOpDeclaration: { case EOpDeclaration: {
const TIntermSequence& sequence = node->getSequence(); const TIntermSequence& sequence = node->getSequence();
TQualifier qualifier = sequence.front()->getAsTyped()->getQualifier(); TQualifier qualifier = sequence.front()->getAsTyped()->getQualifier();
if (qualifier == EvqAttribute || qualifier == EvqUniform) if (qualifier == EvqAttribute || qualifier == EvqVertexInput || qualifier == EvqUniform)
{ {
TVariableInfoList& infoList = qualifier == EvqAttribute ? TVariableInfoList& infoList = (qualifier == EvqAttribute || qualifier == EvqVertexInput) ?
mAttribs : mUniforms; mAttribs : mUniforms;
for (TIntermSequence::const_iterator i = sequence.begin(); for (TIntermSequence::const_iterator i = sequence.begin();
i != sequence.end(); ++i) i != sequence.end(); ++i)
......
...@@ -1389,22 +1389,22 @@ storage_qualifier ...@@ -1389,22 +1389,22 @@ storage_qualifier
} }
| IN_QUAL { | IN_QUAL {
ES3_ONLY("in", $1.line, "storage qualifier"); ES3_ONLY("in", $1.line, "storage qualifier");
$$.qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqSmoothIn : EvqAttribute; $$.qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqSmoothIn : EvqVertexInput;
$$.line = $1.line; $$.line = $1.line;
} }
| OUT_QUAL { | OUT_QUAL {
ES3_ONLY("out", $1.line, "storage qualifier"); ES3_ONLY("out", $1.line, "storage qualifier");
$$.qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqFragColor : EvqSmoothOut; $$.qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentOutput : EvqSmoothOut;
$$.line = $1.line; $$.line = $1.line;
} }
| CENTROID IN_QUAL { | CENTROID IN_QUAL {
ES3_ONLY("centroid in", $1.line, "storage qualifier"); ES3_ONLY("centroid in", $1.line, "storage qualifier");
$$.qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqCentroidIn : EvqAttribute; $$.qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexInput;
$$.line = $1.line; $$.line = $1.line;
} }
| CENTROID OUT_QUAL { | CENTROID OUT_QUAL {
ES3_ONLY("centroid out", $1.line, "storage qualifier"); ES3_ONLY("centroid out", $1.line, "storage qualifier");
$$.qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqFragColor : EvqCentroidOut; $$.qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentOutput : EvqCentroidOut;
$$.line = $1.line; $$.line = $1.line;
} }
| UNIFORM { | UNIFORM {
......
...@@ -3756,7 +3756,7 @@ yyreduce: ...@@ -3756,7 +3756,7 @@ yyreduce:
{ {
ES3_ONLY("in", (yyvsp[(1) - (1)].lex).line, "storage qualifier"); ES3_ONLY("in", (yyvsp[(1) - (1)].lex).line, "storage qualifier");
(yyval.interm.type).qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqSmoothIn : EvqAttribute; (yyval.interm.type).qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqSmoothIn : EvqVertexInput;
(yyval.interm.type).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm.type).line = (yyvsp[(1) - (1)].lex).line;
} }
break; break;
...@@ -3765,7 +3765,7 @@ yyreduce: ...@@ -3765,7 +3765,7 @@ yyreduce:
{ {
ES3_ONLY("out", (yyvsp[(1) - (1)].lex).line, "storage qualifier"); ES3_ONLY("out", (yyvsp[(1) - (1)].lex).line, "storage qualifier");
(yyval.interm.type).qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqFragColor : EvqSmoothOut; (yyval.interm.type).qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentOutput : EvqSmoothOut;
(yyval.interm.type).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm.type).line = (yyvsp[(1) - (1)].lex).line;
} }
break; break;
...@@ -3774,7 +3774,7 @@ yyreduce: ...@@ -3774,7 +3774,7 @@ yyreduce:
{ {
ES3_ONLY("centroid in", (yyvsp[(1) - (2)].lex).line, "storage qualifier"); ES3_ONLY("centroid in", (yyvsp[(1) - (2)].lex).line, "storage qualifier");
(yyval.interm.type).qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqCentroidIn : EvqAttribute; (yyval.interm.type).qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqCentroidIn : EvqVertexInput;
(yyval.interm.type).line = (yyvsp[(1) - (2)].lex).line; (yyval.interm.type).line = (yyvsp[(1) - (2)].lex).line;
} }
break; break;
...@@ -3783,7 +3783,7 @@ yyreduce: ...@@ -3783,7 +3783,7 @@ yyreduce:
{ {
ES3_ONLY("centroid out", (yyvsp[(1) - (2)].lex).line, "storage qualifier"); ES3_ONLY("centroid out", (yyvsp[(1) - (2)].lex).line, "storage qualifier");
(yyval.interm.type).qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqFragColor : EvqCentroidOut; (yyval.interm.type).qualifier = (context->shaderType == SH_FRAGMENT_SHADER) ? EvqFragmentOutput : EvqCentroidOut;
(yyval.interm.type).line = (yyvsp[(1) - (2)].lex).line; (yyval.interm.type).line = (yyvsp[(1) - (2)].lex).line;
} }
break; break;
......
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