Commit 17e2e2f2 by Alexis Hetu Committed by Alexis Hétu

Fragment output location fix

The previous fix wasn't handling the case where the same fragment output variable would go through declareFragmentOutput() multiple times, so this cl fixes it. Fixes all dEQP-GLES3.functional.shaders.random failures. Still fixes original WebGL2 conformance tests failures in: all/deqp/functional/gles3/fragmentoutput Change-Id: Ia9c4f5ed5c444ab0c020cac8be511fcaad23c55d Reviewed-on: https://swiftshader-review.googlesource.com/16928Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 40f48ab8
......@@ -3180,29 +3180,55 @@ namespace glsl
void OutputASM::declareFragmentOutput(TIntermTyped *fragmentOutput)
{
int requestedLocation = fragmentOutput->getType().getLayoutQualifier().location;
if((requestedLocation >= 0) && (requestedLocation < sw::RENDERTARGETS))
int registerCount = fragmentOutput->totalRegisterCount();
if(requestedLocation < 0)
{
if(fragmentOutputs.size() <= (size_t)requestedLocation)
mContext.error(fragmentOutput->getLine(), "Invalid fragment output location", "fragment shader");
}
else if((requestedLocation + registerCount) > sw::RENDERTARGETS)
{
mContext.error(fragmentOutput->getLine(), "Fragment output location larger or equal to MAX_DRAW_BUFFERS", "fragment shader");
}
else
{
int currentIndex = lookup(fragmentOutputs, fragmentOutput);
if(requestedLocation != currentIndex)
{
while(fragmentOutputs.size() < (size_t)requestedLocation)
if(currentIndex != -1)
{
fragmentOutputs.push_back(nullptr);
mContext.error(fragmentOutput->getLine(), "Multiple locations for fragment output", "fragment shader");
}
else
{
if(fragmentOutputs.size() <= (size_t)requestedLocation)
{
while(fragmentOutputs.size() < (size_t)requestedLocation)
{
fragmentOutputs.push_back(nullptr);
}
for(int i = 0; i < registerCount; i++)
{
fragmentOutputs.push_back(fragmentOutput);
}
}
else
{
for(int i = 0; i < registerCount; i++)
{
if(!fragmentOutputs[requestedLocation + i])
{
fragmentOutputs[requestedLocation + i] = fragmentOutput;
}
else
{
mContext.error(fragmentOutput->getLine(), "Fragment output location aliasing", "fragment shader");
return;
}
}
}
}
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)
......
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