return sw::Shader::PARAMETER_VOID;
}
+ bool OutputASM::hasFlatQualifier(TIntermTyped *operand)
+ {
+ const TQualifier qualifier = operand->getQualifier();
+ return qualifier == EvqFlat || qualifier == EvqFlatOut || qualifier == EvqFlatIn;
+ }
+
unsigned int OutputASM::registerIndex(TIntermTyped *operand)
{
if(isSamplerRegister(operand))
{
for(int i = 0; i < varying->totalRegisterCount(); i++)
{
- if(componentCount >= 1) pixelShader->semantic[var + i][0] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, var + i);
- if(componentCount >= 2) pixelShader->semantic[var + i][1] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, var + i);
- if(componentCount >= 3) pixelShader->semantic[var + i][2] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, var + i);
- if(componentCount >= 4) pixelShader->semantic[var + i][3] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, var + i);
+ bool flat = hasFlatQualifier(varying);
+
+ if(componentCount >= 1) pixelShader->semantic[var + i][0] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, var + i, flat);
+ if(componentCount >= 2) pixelShader->semantic[var + i][1] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, var + i, flat);
+ if(componentCount >= 3) pixelShader->semantic[var + i][2] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, var + i, flat);
+ if(componentCount >= 4) pixelShader->semantic[var + i][3] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, var + i, flat);
}
}
}
void assignLvalue(TIntermTyped *dst, TIntermTyped *src);
int lvalue(sw::Shader::DestinationParameter &dst, Temporary &address, TIntermTyped *node);
sw::Shader::ParameterType registerType(TIntermTyped *operand);
+ bool hasFlatQualifier(TIntermTyped *operand);
unsigned int registerIndex(TIntermTyped *operand);
int writeMask(TIntermTyped *destination, int index = 0);
int readSwizzle(TIntermTyped *argument, int size);
for(int i = 0; i < registers; i++)
{
- if(components >= 1) vertexBinary->output[out + i][0] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i);
- if(components >= 2) vertexBinary->output[out + i][1] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i);
- if(components >= 3) vertexBinary->output[out + i][2] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i);
- if(components >= 4) vertexBinary->output[out + i][3] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i);
+ bool flat = pixelBinary->semantic[in + i][0].flat;
+
+ if(components >= 1) vertexBinary->output[out + i][0] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i, flat);
+ if(components >= 2) vertexBinary->output[out + i][1] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i, flat);
+ if(components >= 3) vertexBinary->output[out + i][2] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i, flat);
+ if(components >= 4) vertexBinary->output[out + i][3] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i, flat);
}
}
else // Vertex varying is declared but not written to
{
for(int component = 0; component < 4; component++)
{
- if(context->pixelShader->semantic[interpolant][component].active())
+ const Shader::Semantic &semantic = context->pixelShader->semantic[interpolant][component];
+
+ if(semantic.active())
{
bool flat = point;
- switch(context->pixelShader->semantic[interpolant][component].usage)
+ switch(semantic.usage)
{
- case Shader::USAGE_TEXCOORD: flat = point && !sprite; break;
- case Shader::USAGE_COLOR: flat = flatShading; break;
+ case Shader::USAGE_TEXCOORD: flat = point && !sprite; break;
+ case Shader::USAGE_COLOR: flat = semantic.flat || flatShading; break;
}
state.interpolant[interpolant].component |= 1 << component;
for(int component = 0; component < 4; component++)
{
int project = context->isProjectionComponent(interpolant - 2, component) ? 1 : 0;
+ const Shader::Semantic& semantic = context->pixelShader->semantic[interpolant][component - project];
- if(context->pixelShader->semantic[interpolant][component - project].active())
+ if(semantic.active())
{
int input = interpolant;
for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{
- if(context->pixelShader->semantic[interpolant][component - project] == context->vertexShader->output[i][component - project])
+ if(semantic == context->vertexShader->output[i][component - project])
{
input = i;
break;
bool flat = point;
- switch(context->pixelShader->semantic[interpolant][component - project].usage)
+ switch(semantic.usage)
{
- case Shader::USAGE_TEXCOORD: flat = point && !sprite; break;
- case Shader::USAGE_COLOR: flat = flatShading; break;
+ case Shader::USAGE_TEXCOORD: flat = point && !sprite; break;
+ case Shader::USAGE_COLOR: flat = semantic.flat || flatShading; break;
}
state.gradient[interpolant][component].attribute = input;
{
for(int component = 0; component < 4; component++)
{
- int index = context->pixelShader->semantic[interpolant][component].index;
+ const Shader::Semantic& semantic = context->pixelShader->semantic[interpolant][component];
- switch(context->pixelShader->semantic[interpolant][component].usage)
+ switch(semantic.usage)
{
case 0xFF:
break;
case Shader::USAGE_TEXCOORD:
- state.gradient[interpolant][component].attribute = T0 + index;
- state.gradient[interpolant][component].flat = point && !sprite;
+ state.gradient[interpolant][component].attribute = T0 + semantic.index;
+ state.gradient[interpolant][component].flat = semantic.flat || (point && !sprite);
break;
case Shader::USAGE_COLOR:
- state.gradient[interpolant][component].attribute = C0 + index;
- state.gradient[interpolant][component].flat = flatShading;
+ state.gradient[interpolant][component].attribute = C0 + semantic.index;
+ state.gradient[interpolant][component].flat = semantic.flat || flatShading;
break;
default:
ASSERT(false);
struct Semantic
{
- Semantic(unsigned char usage = 0xFF, unsigned char index = 0xFF) : usage(usage), index(index), centroid(false)
+ Semantic(unsigned char usage = 0xFF, unsigned char index = 0xFF, bool flat = false) : usage(usage), index(index), centroid(false), flat(flat)
{
}
unsigned char usage;
unsigned char index;
bool centroid;
+ bool flat;
};
void optimize();