Commit 8b124c10 by Nicolas Capens

Implement broadcasting of gl_FragColor.

Bug 19353282 Change-Id: I4319ad1836de36cc4b91b04ed226f925f82013ee Reviewed-on: https://swiftshader-review.googlesource.com/5145Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent c98186ac
...@@ -2545,7 +2545,7 @@ namespace glsl ...@@ -2545,7 +2545,7 @@ namespace glsl
case EvqFrontFacing: pixelShader->vFaceDeclared = true; return 1; case EvqFrontFacing: pixelShader->vFaceDeclared = true; return 1;
case EvqPointCoord: return varyingRegister(operand); case EvqPointCoord: return varyingRegister(operand);
case EvqFragColor: return 0; case EvqFragColor: return 0;
case EvqFragData: return 0; case EvqFragData: return fragmentOutputRegister(operand);
case EvqFragDepth: return 0; case EvqFragDepth: return 0;
default: UNREACHABLE(operand->getQualifier()); default: UNREACHABLE(operand->getQualifier());
} }
......
...@@ -1128,7 +1128,7 @@ const TVariable *TParseContext::getNamedVariable(const TSourceLoc &location, ...@@ -1128,7 +1128,7 @@ const TVariable *TParseContext::getNamedVariable(const TSourceLoc &location,
// This validation is not quite correct - it's only an error to write to // This validation is not quite correct - it's only an error to write to
// both FragData and FragColor. For simplicity, and because users shouldn't // both FragData and FragColor. For simplicity, and because users shouldn't
// be rewarded for reading from undefined varaibles, return an error // be rewarded for reading from undefined variables, return an error
// if they are both referenced, rather than assigned. // if they are both referenced, rather than assigned.
if(mUsesFragData && mUsesFragColor) if(mUsesFragData && mUsesFragColor)
{ {
......
...@@ -91,6 +91,8 @@ namespace sw ...@@ -91,6 +91,8 @@ namespace sw
} }
} }
bool broadcastColor0 = true;
for(size_t i = 0; i < shader->getLength(); i++) for(size_t i = 0; i < shader->getLength(); i++)
{ {
const Shader::Instruction *instruction = shader->getInstruction(i); const Shader::Instruction *instruction = shader->getInstruction(i);
...@@ -475,6 +477,8 @@ namespace sw ...@@ -475,6 +477,8 @@ namespace sw
case Shader::PARAMETER_COLOROUT: case Shader::PARAMETER_COLOROUT:
if(dst.rel.type == Shader::PARAMETER_VOID) if(dst.rel.type == Shader::PARAMETER_VOID)
{ {
broadcastColor0 = (dst.index == 0) && broadcastColor0;
if(dst.x) { oC[dst.index].x = d.x; } if(dst.x) { oC[dst.index].x = d.x; }
if(dst.y) { oC[dst.index].y = d.y; } if(dst.y) { oC[dst.index].y = d.y; }
if(dst.z) { oC[dst.index].z = d.z; } if(dst.z) { oC[dst.index].z = d.z; }
...@@ -482,6 +486,7 @@ namespace sw ...@@ -482,6 +486,7 @@ namespace sw
} }
else else
{ {
broadcastColor0 = false;
Int a = relativeAddress(dst) + dst.index; Int a = relativeAddress(dst) + dst.index;
if(dst.x) { oC[a].x = d.x; } if(dst.x) { oC[a].x = d.x; }
...@@ -510,9 +515,19 @@ namespace sw ...@@ -510,9 +515,19 @@ namespace sw
Nucleus::setInsertBlock(returnBlock); Nucleus::setInsertBlock(returnBlock);
} }
for(int i = 0; i < RENDERTARGETS; i++) if(broadcastColor0)
{
for(int i = 0; i < RENDERTARGETS; i++)
{
c[i] = oC[0];
}
}
else
{ {
c[i] = oC[i]; for(int i = 0; i < RENDERTARGETS; i++)
{
c[i] = oC[i];
}
} }
} }
......
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