Commit 930df975 by Alexis Hetu Committed by Alexis Hétu

Support for fragment output location

Fragment output layout qualifiers may contain location, which was currently ignored by SwiftShader. Pre-declared fragment outputs that have a valid location at the correct location within the fragmentOutputs array to solve this. Fixes all failures in WebGL 2 tests: all/deqp/functional/gles3/fragmentoutput/* Change-Id: I30e004449fb90713984b3481abb24c5d0cd6e867 Reviewed-on: https://swiftshader-review.googlesource.com/16788Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 3bb01956
...@@ -676,6 +676,9 @@ namespace glsl ...@@ -676,6 +676,9 @@ namespace glsl
declareVarying(symbol, -1); declareVarying(symbol, -1);
} }
break; break;
case EvqFragmentOut:
declareFragmentOutput(symbol);
break;
default: default:
break; break;
} }
...@@ -3148,6 +3151,34 @@ namespace glsl ...@@ -3148,6 +3151,34 @@ namespace glsl
} }
} }
void OutputASM::declareFragmentOutput(TIntermTyped *fragmentOutput)
{
int requestedLocation = fragmentOutput->getType().getLayoutQualifier().location;
if((requestedLocation >= 0) && (requestedLocation < sw::RENDERTARGETS))
{
if(fragmentOutputs.size() <= requestedLocation)
{
while(fragmentOutputs.size() < requestedLocation)
{
fragmentOutputs.push_back(nullptr);
}
fragmentOutputs.push_back(fragmentOutput);
}
else if(!fragmentOutputs[requestedLocation])
{
fragmentOutputs[requestedLocation] = fragmentOutput;
}
else
{
mContext.error(fragmentOutput->getLine(), "Fragment output location aliasing", "fragment shader");
}
}
else if(requestedLocation >= sw::RENDERTARGETS)
{
mContext.error(fragmentOutput->getLine(), "Fragment output location larger or equal to MAX_DRAW_BUFFERS", "fragment shader");
}
}
int OutputASM::uniformRegister(TIntermTyped *uniform) int OutputASM::uniformRegister(TIntermTyped *uniform)
{ {
const TType &type = uniform->getType(); const TType &type = uniform->getType();
......
...@@ -297,6 +297,7 @@ namespace glsl ...@@ -297,6 +297,7 @@ namespace glsl
void setPixelShaderInputs(const TType& type, int var, bool flat); void setPixelShaderInputs(const TType& type, int var, bool flat);
void declareVarying(TIntermTyped *varying, int reg); void declareVarying(TIntermTyped *varying, int reg);
void declareVarying(const TType &type, const TString &name, int registerIndex); void declareVarying(const TType &type, const TString &name, int registerIndex);
void declareFragmentOutput(TIntermTyped *fragmentOutput);
int uniformRegister(TIntermTyped *uniform); int uniformRegister(TIntermTyped *uniform);
int attributeRegister(TIntermTyped *attribute); int attributeRegister(TIntermTyped *attribute);
int fragmentOutputRegister(TIntermTyped *fragmentOutput); int fragmentOutputRegister(TIntermTyped *fragmentOutput);
......
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