Commit 107c7247 by Olli Etuaho Committed by Commit Bot

ShaderVariable: separate fields for staticUse and active

Thus far the compiler has used the "staticUse" flag to mark variables that should have rather been marked "active", meaning that the code may actually execute in a way that accesses the variable. There's a clear definition for this use of the term "active" in the GLES 3.0.5 spec, section 2.12.6, and in GLES 3.1 section 7.3.1. Having separate fields for recording static use and "activeness" of a variable is the first step to fixing this. According to the spec, usually only active resources should be considered when checking use against max limits. Also, only active uniforms get assigned a location. libANGLE code now correctly checks the active flag rather than the static use flag in these cases. The static use field still mirrors the active field for now, since some code in Chromium also needs to be fixed to use the active field correctly before the two can diverge. After Chromium is fixed, we can fix ANGLE so that static use information is recorded earlier during compilation and will accurately reflect whether variables are statically used. Currently the compiler only records variables once some static use may already have been pruned from the AST. BUG=angleproject:2262 TEST=angle_unittests, angle_end2end_tests Change-Id: I025bb71361246ae00c911a1f8b66ec045f665f29 Reviewed-on: https://chromium-review.googlesource.com/970962Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent c26214de
...@@ -126,7 +126,12 @@ struct ShaderVariable ...@@ -126,7 +126,12 @@ struct ShaderVariable
// and flattenedOffsetInParentArrays of a[2][1] would be 2*4 + 1 = 9. // and flattenedOffsetInParentArrays of a[2][1] would be 2*4 + 1 = 9.
unsigned int flattenedOffsetInParentArrays; unsigned int flattenedOffsetInParentArrays;
// Static use means that the variable is accessed somewhere in the shader source.
bool staticUse; bool staticUse;
// A variable is active unless the compiler determined that it is not accessed by the shader.
// All active variables are statically used, but not all statically used variables are
// necessarily active. GLES 3.0.5 section 2.12.6. GLES 3.1 section 7.3.1.
bool active;
std::vector<ShaderVariable> fields; std::vector<ShaderVariable> fields;
std::string structName; std::string structName;
...@@ -279,6 +284,7 @@ struct InterfaceBlock ...@@ -279,6 +284,7 @@ struct InterfaceBlock
int binding; int binding;
bool staticUse; bool staticUse;
bool active;
BlockType blockType; BlockType blockType;
std::vector<InterfaceBlockField> fields; std::vector<InterfaceBlockField> fields;
}; };
......
...@@ -83,6 +83,7 @@ void MarkStaticallyUsed(ShaderVariable *variable) ...@@ -83,6 +83,7 @@ void MarkStaticallyUsed(ShaderVariable *variable)
} }
} }
variable->staticUse = true; variable->staticUse = true;
variable->active = true;
} }
} }
...@@ -96,6 +97,7 @@ ShaderVariable *FindVariableInInterfaceBlock(const ImmutableString &name, ...@@ -96,6 +97,7 @@ ShaderVariable *FindVariableInInterfaceBlock(const ImmutableString &name,
// Set static use on the parent interface block here // Set static use on the parent interface block here
namedBlock->staticUse = true; namedBlock->staticUse = true;
namedBlock->active = true;
return FindVariable(name, &namedBlock->fields); return FindVariable(name, &namedBlock->fields);
} }
...@@ -284,6 +286,7 @@ void CollectVariablesTraverser::recordBuiltInVaryingUsed(const ImmutableString & ...@@ -284,6 +286,7 @@ void CollectVariablesTraverser::recordBuiltInVaryingUsed(const ImmutableString &
Varying info; Varying info;
setBuiltInInfoFromSymbolTable(name, &info); setBuiltInInfoFromSymbolTable(name, &info);
info.staticUse = true; info.staticUse = true;
info.active = true;
info.isInvariant = mSymbolTable->isVaryingInvariant(name); info.isInvariant = mSymbolTable->isVaryingInvariant(name);
varyings->push_back(info); varyings->push_back(info);
(*addedFlag) = true; (*addedFlag) = true;
...@@ -298,6 +301,7 @@ void CollectVariablesTraverser::recordBuiltInFragmentOutputUsed(const ImmutableS ...@@ -298,6 +301,7 @@ void CollectVariablesTraverser::recordBuiltInFragmentOutputUsed(const ImmutableS
OutputVariable info; OutputVariable info;
setBuiltInInfoFromSymbolTable(name, &info); setBuiltInInfoFromSymbolTable(name, &info);
info.staticUse = true; info.staticUse = true;
info.active = true;
mOutputVariables->push_back(info); mOutputVariables->push_back(info);
(*addedFlag) = true; (*addedFlag) = true;
} }
...@@ -311,6 +315,7 @@ void CollectVariablesTraverser::recordBuiltInAttributeUsed(const ImmutableString ...@@ -311,6 +315,7 @@ void CollectVariablesTraverser::recordBuiltInAttributeUsed(const ImmutableString
Attribute info; Attribute info;
setBuiltInInfoFromSymbolTable(name, &info); setBuiltInInfoFromSymbolTable(name, &info);
info.staticUse = true; info.staticUse = true;
info.active = true;
info.location = -1; info.location = -1;
mAttribs->push_back(info); mAttribs->push_back(info);
(*addedFlag) = true; (*addedFlag) = true;
...@@ -325,6 +330,7 @@ InterfaceBlock *CollectVariablesTraverser::recordGLInUsed(const TType &glInType) ...@@ -325,6 +330,7 @@ InterfaceBlock *CollectVariablesTraverser::recordGLInUsed(const TType &glInType)
InterfaceBlock info; InterfaceBlock info;
recordInterfaceBlock("gl_in", glInType, &info); recordInterfaceBlock("gl_in", glInType, &info);
info.staticUse = true; info.staticUse = true;
info.active = true;
mPerVertexInAdded = true; mPerVertexInAdded = true;
mInBlocks->push_back(info); mInBlocks->push_back(info);
...@@ -385,6 +391,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -385,6 +391,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
info.type = GL_NONE; info.type = GL_NONE;
info.precision = GL_NONE; info.precision = GL_NONE;
info.staticUse = true; info.staticUse = true;
info.active = true;
ShaderVariable nearInfo(GL_FLOAT); ShaderVariable nearInfo(GL_FLOAT);
const char kNearName[] = "near"; const char kNearName[] = "near";
...@@ -392,6 +399,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -392,6 +399,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
nearInfo.mappedName = kNearName; nearInfo.mappedName = kNearName;
nearInfo.precision = GL_HIGH_FLOAT; nearInfo.precision = GL_HIGH_FLOAT;
nearInfo.staticUse = true; nearInfo.staticUse = true;
nearInfo.active = true;
ShaderVariable farInfo(GL_FLOAT); ShaderVariable farInfo(GL_FLOAT);
const char kFarName[] = "far"; const char kFarName[] = "far";
...@@ -399,6 +407,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -399,6 +407,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
farInfo.mappedName = kFarName; farInfo.mappedName = kFarName;
farInfo.precision = GL_HIGH_FLOAT; farInfo.precision = GL_HIGH_FLOAT;
farInfo.staticUse = true; farInfo.staticUse = true;
farInfo.active = true;
ShaderVariable diffInfo(GL_FLOAT); ShaderVariable diffInfo(GL_FLOAT);
const char kDiffName[] = "diff"; const char kDiffName[] = "diff";
...@@ -406,6 +415,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -406,6 +415,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
diffInfo.mappedName = kDiffName; diffInfo.mappedName = kDiffName;
diffInfo.precision = GL_HIGH_FLOAT; diffInfo.precision = GL_HIGH_FLOAT;
diffInfo.staticUse = true; diffInfo.staticUse = true;
diffInfo.active = true;
info.fields.push_back(nearInfo); info.fields.push_back(nearInfo);
info.fields.push_back(farInfo); info.fields.push_back(farInfo);
...@@ -476,6 +486,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -476,6 +486,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
info.type = GL_INT; info.type = GL_INT;
info.precision = GL_HIGH_INT; // Defined by spec. info.precision = GL_HIGH_INT; // Defined by spec.
info.staticUse = true; info.staticUse = true;
info.active = true;
info.location = -1; info.location = -1;
mAttribs->push_back(info); mAttribs->push_back(info);
mInstanceIDAdded = true; mInstanceIDAdded = true;
...@@ -510,6 +521,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -510,6 +521,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
info.arraySizes.back() = 1u; info.arraySizes.back() = 1u;
} }
info.staticUse = true; info.staticUse = true;
info.active = true;
mOutputVariables->push_back(info); mOutputVariables->push_back(info);
mFragDataAdded = true; mFragDataAdded = true;
} }
...@@ -883,9 +895,11 @@ bool CollectVariablesTraverser::visitBinary(Visit, TIntermBinary *binaryNode) ...@@ -883,9 +895,11 @@ bool CollectVariablesTraverser::visitBinary(Visit, TIntermBinary *binaryNode)
} }
ASSERT(namedBlock); ASSERT(namedBlock);
namedBlock->staticUse = true; namedBlock->staticUse = true;
namedBlock->active = true;
unsigned int fieldIndex = static_cast<unsigned int>(constantUnion->getIConst(0)); unsigned int fieldIndex = static_cast<unsigned int>(constantUnion->getIConst(0));
ASSERT(fieldIndex < namedBlock->fields.size()); ASSERT(fieldIndex < namedBlock->fields.size());
namedBlock->fields[fieldIndex].staticUse = true; namedBlock->fields[fieldIndex].staticUse = true;
namedBlock->fields[fieldIndex].active = true;
if (traverseIndexExpression) if (traverseIndexExpression)
{ {
......
...@@ -32,17 +32,17 @@ bool InterpolationTypesMatch(InterpolationType a, InterpolationType b) ...@@ -32,17 +32,17 @@ bool InterpolationTypesMatch(InterpolationType a, InterpolationType b)
} }
ShaderVariable::ShaderVariable() ShaderVariable::ShaderVariable()
: type(0), precision(0), flattenedOffsetInParentArrays(0), staticUse(false) : type(0), precision(0), flattenedOffsetInParentArrays(0), staticUse(false), active(false)
{ {
} }
ShaderVariable::ShaderVariable(GLenum typeIn) ShaderVariable::ShaderVariable(GLenum typeIn)
: type(typeIn), precision(0), flattenedOffsetInParentArrays(0), staticUse(false) : type(typeIn), precision(0), flattenedOffsetInParentArrays(0), staticUse(false), active(false)
{ {
} }
ShaderVariable::ShaderVariable(GLenum typeIn, unsigned int arraySizeIn) ShaderVariable::ShaderVariable(GLenum typeIn, unsigned int arraySizeIn)
: type(typeIn), precision(0), flattenedOffsetInParentArrays(0), staticUse(false) : type(typeIn), precision(0), flattenedOffsetInParentArrays(0), staticUse(false), active(false)
{ {
ASSERT(arraySizeIn != 0); ASSERT(arraySizeIn != 0);
arraySizes.push_back(arraySizeIn); arraySizes.push_back(arraySizeIn);
...@@ -60,6 +60,7 @@ ShaderVariable::ShaderVariable(const ShaderVariable &other) ...@@ -60,6 +60,7 @@ ShaderVariable::ShaderVariable(const ShaderVariable &other)
arraySizes(other.arraySizes), arraySizes(other.arraySizes),
flattenedOffsetInParentArrays(other.flattenedOffsetInParentArrays), flattenedOffsetInParentArrays(other.flattenedOffsetInParentArrays),
staticUse(other.staticUse), staticUse(other.staticUse),
active(other.active),
fields(other.fields), fields(other.fields),
structName(other.structName) structName(other.structName)
{ {
...@@ -73,6 +74,7 @@ ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other) ...@@ -73,6 +74,7 @@ ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other)
mappedName = other.mappedName; mappedName = other.mappedName;
arraySizes = other.arraySizes; arraySizes = other.arraySizes;
staticUse = other.staticUse; staticUse = other.staticUse;
active = other.active;
flattenedOffsetInParentArrays = other.flattenedOffsetInParentArrays; flattenedOffsetInParentArrays = other.flattenedOffsetInParentArrays;
fields = other.fields; fields = other.fields;
structName = other.structName; structName = other.structName;
...@@ -83,8 +85,8 @@ bool ShaderVariable::operator==(const ShaderVariable &other) const ...@@ -83,8 +85,8 @@ bool ShaderVariable::operator==(const ShaderVariable &other) const
{ {
if (type != other.type || precision != other.precision || name != other.name || if (type != other.type || precision != other.precision || name != other.name ||
mappedName != other.mappedName || arraySizes != other.arraySizes || mappedName != other.mappedName || arraySizes != other.arraySizes ||
staticUse != other.staticUse || fields.size() != other.fields.size() || staticUse != other.staticUse || active != other.active ||
structName != other.structName) fields.size() != other.fields.size() || structName != other.structName)
{ {
return false; return false;
} }
...@@ -454,6 +456,7 @@ InterfaceBlock::InterfaceBlock() ...@@ -454,6 +456,7 @@ InterfaceBlock::InterfaceBlock()
isRowMajorLayout(false), isRowMajorLayout(false),
binding(-1), binding(-1),
staticUse(false), staticUse(false),
active(false),
blockType(BlockType::BLOCK_UNIFORM) blockType(BlockType::BLOCK_UNIFORM)
{ {
} }
...@@ -471,6 +474,7 @@ InterfaceBlock::InterfaceBlock(const InterfaceBlock &other) ...@@ -471,6 +474,7 @@ InterfaceBlock::InterfaceBlock(const InterfaceBlock &other)
isRowMajorLayout(other.isRowMajorLayout), isRowMajorLayout(other.isRowMajorLayout),
binding(other.binding), binding(other.binding),
staticUse(other.staticUse), staticUse(other.staticUse),
active(other.active),
blockType(other.blockType), blockType(other.blockType),
fields(other.fields) fields(other.fields)
{ {
...@@ -486,6 +490,7 @@ InterfaceBlock &InterfaceBlock::operator=(const InterfaceBlock &other) ...@@ -486,6 +490,7 @@ InterfaceBlock &InterfaceBlock::operator=(const InterfaceBlock &other)
isRowMajorLayout = other.isRowMajorLayout; isRowMajorLayout = other.isRowMajorLayout;
binding = other.binding; binding = other.binding;
staticUse = other.staticUse; staticUse = other.staticUse;
active = other.active;
blockType = other.blockType; blockType = other.blockType;
fields = other.fields; fields = other.fields;
return *this; return *this;
......
...@@ -44,6 +44,7 @@ void WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var) ...@@ -44,6 +44,7 @@ void WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var)
stream->writeString(var.mappedName); stream->writeString(var.mappedName);
stream->writeIntVector(var.arraySizes); stream->writeIntVector(var.arraySizes);
stream->writeInt(var.staticUse); stream->writeInt(var.staticUse);
stream->writeInt(var.active);
stream->writeString(var.structName); stream->writeString(var.structName);
ASSERT(var.fields.empty()); ASSERT(var.fields.empty());
} }
...@@ -56,6 +57,7 @@ void LoadShaderVar(BinaryInputStream *stream, sh::ShaderVariable *var) ...@@ -56,6 +57,7 @@ void LoadShaderVar(BinaryInputStream *stream, sh::ShaderVariable *var)
var->mappedName = stream->readString(); var->mappedName = stream->readString();
stream->readIntVector<unsigned int>(&var->arraySizes); stream->readIntVector<unsigned int>(&var->arraySizes);
var->staticUse = stream->readBool(); var->staticUse = stream->readBool();
var->active = stream->readBool();
var->structName = stream->readString(); var->structName = stream->readString();
} }
...@@ -64,10 +66,10 @@ void WriteShaderVariableBuffer(BinaryOutputStream *stream, const ShaderVariableB ...@@ -64,10 +66,10 @@ void WriteShaderVariableBuffer(BinaryOutputStream *stream, const ShaderVariableB
stream->writeInt(var.binding); stream->writeInt(var.binding);
stream->writeInt(var.dataSize); stream->writeInt(var.dataSize);
stream->writeInt(var.vertexStaticUse); stream->writeInt(var.vertexActive);
stream->writeInt(var.fragmentStaticUse); stream->writeInt(var.fragmentActive);
stream->writeInt(var.computeStaticUse); stream->writeInt(var.computeActive);
stream->writeInt(var.geometryStaticUse); stream->writeInt(var.geometryActive);
stream->writeInt(var.memberIndexes.size()); stream->writeInt(var.memberIndexes.size());
for (unsigned int memberCounterIndex : var.memberIndexes) for (unsigned int memberCounterIndex : var.memberIndexes)
...@@ -80,10 +82,10 @@ void LoadShaderVariableBuffer(BinaryInputStream *stream, ShaderVariableBuffer *v ...@@ -80,10 +82,10 @@ void LoadShaderVariableBuffer(BinaryInputStream *stream, ShaderVariableBuffer *v
{ {
var->binding = stream->readInt<int>(); var->binding = stream->readInt<int>();
var->dataSize = stream->readInt<unsigned int>(); var->dataSize = stream->readInt<unsigned int>();
var->vertexStaticUse = stream->readBool(); var->vertexActive = stream->readBool();
var->fragmentStaticUse = stream->readBool(); var->fragmentActive = stream->readBool();
var->computeStaticUse = stream->readBool(); var->computeActive = stream->readBool();
var->geometryStaticUse = stream->readBool(); var->geometryActive = stream->readBool();
unsigned int numMembers = stream->readInt<unsigned int>(); unsigned int numMembers = stream->readInt<unsigned int>();
for (unsigned int blockMemberIndex = 0; blockMemberIndex < numMembers; blockMemberIndex++) for (unsigned int blockMemberIndex = 0; blockMemberIndex < numMembers; blockMemberIndex++)
...@@ -103,9 +105,9 @@ void WriteBufferVariable(BinaryOutputStream *stream, const BufferVariable &var) ...@@ -103,9 +105,9 @@ void WriteBufferVariable(BinaryOutputStream *stream, const BufferVariable &var)
stream->writeInt(var.blockInfo.isRowMajorMatrix); stream->writeInt(var.blockInfo.isRowMajorMatrix);
stream->writeInt(var.blockInfo.topLevelArrayStride); stream->writeInt(var.blockInfo.topLevelArrayStride);
stream->writeInt(var.topLevelArraySize); stream->writeInt(var.topLevelArraySize);
stream->writeInt(var.vertexStaticUse); stream->writeInt(var.vertexActive);
stream->writeInt(var.fragmentStaticUse); stream->writeInt(var.fragmentActive);
stream->writeInt(var.computeStaticUse); stream->writeInt(var.computeActive);
} }
void LoadBufferVariable(BinaryInputStream *stream, BufferVariable *var) void LoadBufferVariable(BinaryInputStream *stream, BufferVariable *var)
...@@ -119,9 +121,9 @@ void LoadBufferVariable(BinaryInputStream *stream, BufferVariable *var) ...@@ -119,9 +121,9 @@ void LoadBufferVariable(BinaryInputStream *stream, BufferVariable *var)
var->blockInfo.isRowMajorMatrix = stream->readBool(); var->blockInfo.isRowMajorMatrix = stream->readBool();
var->blockInfo.topLevelArrayStride = stream->readInt<int>(); var->blockInfo.topLevelArrayStride = stream->readInt<int>();
var->topLevelArraySize = stream->readInt<int>(); var->topLevelArraySize = stream->readInt<int>();
var->vertexStaticUse = stream->readBool(); var->vertexActive = stream->readBool();
var->fragmentStaticUse = stream->readBool(); var->fragmentActive = stream->readBool();
var->computeStaticUse = stream->readBool(); var->computeActive = stream->readBool();
} }
void WriteInterfaceBlock(BinaryOutputStream *stream, const InterfaceBlock &block) void WriteInterfaceBlock(BinaryOutputStream *stream, const InterfaceBlock &block)
......
...@@ -213,7 +213,7 @@ bool ValidateInterfaceBlocksCount(GLuint maxInterfaceBlocks, ...@@ -213,7 +213,7 @@ bool ValidateInterfaceBlocksCount(GLuint maxInterfaceBlocks,
GLuint blockCount = 0; GLuint blockCount = 0;
for (const sh::InterfaceBlock &block : interfaceBlocks) for (const sh::InterfaceBlock &block : interfaceBlocks)
{ {
if (block.staticUse || block.layout != sh::BLOCKLAYOUT_PACKED) if (block.active || block.layout != sh::BLOCKLAYOUT_PACKED)
{ {
blockCount += (block.arraySize ? block.arraySize : 1); blockCount += (block.arraySize ? block.arraySize : 1);
if (blockCount > maxInterfaceBlocks) if (blockCount > maxInterfaceBlocks)
...@@ -646,7 +646,7 @@ void LogLinkMismatch(InfoLog &infoLog, ...@@ -646,7 +646,7 @@ void LogLinkMismatch(InfoLog &infoLog,
bool IsActiveInterfaceBlock(const sh::InterfaceBlock &interfaceBlock) bool IsActiveInterfaceBlock(const sh::InterfaceBlock &interfaceBlock)
{ {
// Only 'packed' blocks are allowed to be considered inactive. // Only 'packed' blocks are allowed to be considered inactive.
return interfaceBlock.staticUse || interfaceBlock.layout != sh::BLOCKLAYOUT_PACKED; return interfaceBlock.active || interfaceBlock.layout != sh::BLOCKLAYOUT_PACKED;
} }
// VariableLocation implementation. // VariableLocation implementation.
...@@ -2440,7 +2440,9 @@ bool Program::linkValidateShaderInterfaceMatching(const Context *context, ...@@ -2440,7 +2440,9 @@ bool Program::linkValidateShaderInterfaceMatching(const Context *context,
} }
} }
// We permit unmatched, unreferenced varyings // We permit unmatched, unreferenced varyings. Note that this specifically depends on
// whether the input is statically used - a statically used input should fail this test even
// if it is not active. GLSL ES 3.00.6 section 4.3.10.
if (!matched && input.staticUse) if (!matched && input.staticUse)
{ {
infoLog << GetShaderTypeString(consumingShader->getType()) << " varying " << input.name infoLog << GetShaderTypeString(consumingShader->getType()) << " varying " << input.name
......
...@@ -114,7 +114,7 @@ class UniformLinker final : angle::NonCopyable ...@@ -114,7 +114,7 @@ class UniformLinker final : angle::NonCopyable
std::vector<LinkedUniform> *imageUniforms, std::vector<LinkedUniform> *imageUniforms,
std::vector<LinkedUniform> *atomicCounterUniforms, std::vector<LinkedUniform> *atomicCounterUniforms,
GLenum shaderType, GLenum shaderType,
bool markStaticUse, bool markActive,
int binding, int binding,
int offset, int offset,
int *location); int *location);
...@@ -126,7 +126,7 @@ class UniformLinker final : angle::NonCopyable ...@@ -126,7 +126,7 @@ class UniformLinker final : angle::NonCopyable
std::vector<LinkedUniform> *imageUniforms, std::vector<LinkedUniform> *imageUniforms,
std::vector<LinkedUniform> *atomicCounterUniforms, std::vector<LinkedUniform> *atomicCounterUniforms,
GLenum shaderType, GLenum shaderType,
bool markStaticUse, bool markActive,
int binding, int binding,
int offset, int offset,
int *location); int *location);
...@@ -138,12 +138,12 @@ class UniformLinker final : angle::NonCopyable ...@@ -138,12 +138,12 @@ class UniformLinker final : angle::NonCopyable
std::vector<LinkedUniform> *imageUniforms, std::vector<LinkedUniform> *imageUniforms,
std::vector<LinkedUniform> *atomicCounterUniforms, std::vector<LinkedUniform> *atomicCounterUniforms,
GLenum shaderType, GLenum shaderType,
bool markStaticUse, bool markActive,
int binding, int binding,
int offset, int offset,
int *location); int *location);
// markStaticUse is given as a separate parameter because it is tracked here at struct // markActive is given as a separate parameter because it is tracked here at struct
// granularity. // granularity.
ShaderUniformCount flattenUniformImpl(const sh::ShaderVariable &uniform, ShaderUniformCount flattenUniformImpl(const sh::ShaderVariable &uniform,
const std::string &fullName, const std::string &fullName,
...@@ -152,7 +152,7 @@ class UniformLinker final : angle::NonCopyable ...@@ -152,7 +152,7 @@ class UniformLinker final : angle::NonCopyable
std::vector<LinkedUniform> *imageUniforms, std::vector<LinkedUniform> *imageUniforms,
std::vector<LinkedUniform> *atomicCounterUniforms, std::vector<LinkedUniform> *atomicCounterUniforms,
GLenum shaderType, GLenum shaderType,
bool markStaticUse, bool markActive,
int binding, int binding,
int offset, int offset,
int *location); int *location);
...@@ -225,9 +225,9 @@ class InterfaceBlockLinker : angle::NonCopyable ...@@ -225,9 +225,9 @@ class InterfaceBlockLinker : angle::NonCopyable
int topLevelArraySize, int topLevelArraySize,
GLenum shaderType) const = 0; GLenum shaderType) const = 0;
virtual size_t getCurrentBlockMemberIndex() const = 0; virtual size_t getCurrentBlockMemberIndex() const = 0;
virtual void updateBlockMemberStaticUsedImpl(const std::string &fullName, virtual void updateBlockMemberActiveImpl(const std::string &fullName,
GLenum shaderType, GLenum shaderType,
bool staticUse) const = 0; bool active) const = 0;
using ShaderBlocks = std::pair<GLenum, const std::vector<sh::InterfaceBlock> *>; using ShaderBlocks = std::pair<GLenum, const std::vector<sh::InterfaceBlock> *>;
std::vector<ShaderBlocks> mShaderBlocks; std::vector<ShaderBlocks> mShaderBlocks;
...@@ -263,9 +263,9 @@ class UniformBlockLinker final : public InterfaceBlockLinker ...@@ -263,9 +263,9 @@ class UniformBlockLinker final : public InterfaceBlockLinker
int topLevelArraySize, int topLevelArraySize,
GLenum shaderType) const override; GLenum shaderType) const override;
size_t getCurrentBlockMemberIndex() const override; size_t getCurrentBlockMemberIndex() const override;
void updateBlockMemberStaticUsedImpl(const std::string &fullName, void updateBlockMemberActiveImpl(const std::string &fullName,
GLenum shaderType, GLenum shaderType,
bool staticUse) const override; bool active) const override;
std::vector<LinkedUniform> *mUniformsOut; std::vector<LinkedUniform> *mUniformsOut;
}; };
...@@ -285,9 +285,9 @@ class ShaderStorageBlockLinker final : public InterfaceBlockLinker ...@@ -285,9 +285,9 @@ class ShaderStorageBlockLinker final : public InterfaceBlockLinker
int topLevelArraySize, int topLevelArraySize,
GLenum shaderType) const override; GLenum shaderType) const override;
size_t getCurrentBlockMemberIndex() const override; size_t getCurrentBlockMemberIndex() const override;
void updateBlockMemberStaticUsedImpl(const std::string &fullName, void updateBlockMemberActiveImpl(const std::string &fullName,
GLenum shaderType, GLenum shaderType,
bool staticUse) const override; bool active) const override;
std::vector<BufferVariable> *mBufferVariablesOut; std::vector<BufferVariable> *mBufferVariablesOut;
}; };
......
...@@ -35,7 +35,7 @@ std::vector<VarT> GetActiveShaderVariables(const std::vector<VarT> *variableList ...@@ -35,7 +35,7 @@ std::vector<VarT> GetActiveShaderVariables(const std::vector<VarT> *variableList
for (size_t varIndex = 0; varIndex < variableList->size(); varIndex++) for (size_t varIndex = 0; varIndex < variableList->size(); varIndex++)
{ {
const VarT &var = variableList->at(varIndex); const VarT &var = variableList->at(varIndex);
if (var.staticUse) if (var.active)
{ {
result.push_back(var); result.push_back(var);
} }
......
...@@ -13,39 +13,36 @@ ...@@ -13,39 +13,36 @@
namespace gl namespace gl
{ {
StaticallyUsed::StaticallyUsed() ActiveVariable::ActiveVariable()
: vertexStaticUse(false), : vertexActive(false), fragmentActive(false), computeActive(false), geometryActive(false)
fragmentStaticUse(false),
computeStaticUse(false),
geometryStaticUse(false)
{ {
} }
StaticallyUsed::~StaticallyUsed() ActiveVariable::~ActiveVariable()
{ {
} }
StaticallyUsed::StaticallyUsed(const StaticallyUsed &rhs) = default; ActiveVariable::ActiveVariable(const ActiveVariable &rhs) = default;
StaticallyUsed &StaticallyUsed::operator=(const StaticallyUsed &rhs) = default; ActiveVariable &ActiveVariable::operator=(const ActiveVariable &rhs) = default;
void StaticallyUsed::setStaticUse(GLenum shaderType, bool used) void ActiveVariable::setActive(GLenum shaderType, bool used)
{ {
switch (shaderType) switch (shaderType)
{ {
case GL_VERTEX_SHADER: case GL_VERTEX_SHADER:
vertexStaticUse = used; vertexActive = used;
break; break;
case GL_FRAGMENT_SHADER: case GL_FRAGMENT_SHADER:
fragmentStaticUse = used; fragmentActive = used;
break; break;
case GL_COMPUTE_SHADER: case GL_COMPUTE_SHADER:
computeStaticUse = used; computeActive = used;
break; break;
case GL_GEOMETRY_SHADER_EXT: case GL_GEOMETRY_SHADER_EXT:
geometryStaticUse = used; geometryActive = used;
break; break;
default: default:
...@@ -53,23 +50,23 @@ void StaticallyUsed::setStaticUse(GLenum shaderType, bool used) ...@@ -53,23 +50,23 @@ void StaticallyUsed::setStaticUse(GLenum shaderType, bool used)
} }
} }
void StaticallyUsed::unionReferencesWith(const StaticallyUsed &other) void ActiveVariable::unionReferencesWith(const ActiveVariable &other)
{ {
vertexStaticUse |= other.vertexStaticUse; vertexActive |= other.vertexActive;
fragmentStaticUse |= other.fragmentStaticUse; fragmentActive |= other.fragmentActive;
computeStaticUse |= other.computeStaticUse; computeActive |= other.computeActive;
geometryStaticUse |= other.geometryStaticUse; geometryActive |= other.geometryActive;
} }
ShaderType StaticallyUsed::getFirstStaticUseShaderType() const ShaderType ActiveVariable::getFirstShaderTypeWhereActive() const
{ {
if (vertexStaticUse) if (vertexActive)
return SHADER_VERTEX; return SHADER_VERTEX;
if (fragmentStaticUse) if (fragmentActive)
return SHADER_FRAGMENT; return SHADER_FRAGMENT;
if (computeStaticUse) if (computeActive)
return SHADER_COMPUTE; return SHADER_COMPUTE;
if (geometryStaticUse) if (geometryActive)
return SHADER_GEOMETRY; return SHADER_GEOMETRY;
UNREACHABLE(); UNREACHABLE();
...@@ -115,7 +112,7 @@ LinkedUniform::LinkedUniform(const sh::Uniform &uniform) ...@@ -115,7 +112,7 @@ LinkedUniform::LinkedUniform(const sh::Uniform &uniform)
LinkedUniform::LinkedUniform(const LinkedUniform &uniform) LinkedUniform::LinkedUniform(const LinkedUniform &uniform)
: sh::Uniform(uniform), : sh::Uniform(uniform),
StaticallyUsed(uniform), ActiveVariable(uniform),
typeInfo(uniform.typeInfo), typeInfo(uniform.typeInfo),
bufferIndex(uniform.bufferIndex), bufferIndex(uniform.bufferIndex),
blockInfo(uniform.blockInfo) blockInfo(uniform.blockInfo)
...@@ -125,7 +122,7 @@ LinkedUniform::LinkedUniform(const LinkedUniform &uniform) ...@@ -125,7 +122,7 @@ LinkedUniform::LinkedUniform(const LinkedUniform &uniform)
LinkedUniform &LinkedUniform::operator=(const LinkedUniform &uniform) LinkedUniform &LinkedUniform::operator=(const LinkedUniform &uniform)
{ {
sh::Uniform::operator=(uniform); sh::Uniform::operator=(uniform);
StaticallyUsed::operator=(uniform); ActiveVariable::operator=(uniform);
typeInfo = uniform.typeInfo; typeInfo = uniform.typeInfo;
bufferIndex = uniform.bufferIndex; bufferIndex = uniform.bufferIndex;
blockInfo = uniform.blockInfo; blockInfo = uniform.blockInfo;
......
...@@ -20,26 +20,26 @@ namespace gl ...@@ -20,26 +20,26 @@ namespace gl
{ {
struct UniformTypeInfo; struct UniformTypeInfo;
struct StaticallyUsed struct ActiveVariable
{ {
StaticallyUsed(); ActiveVariable();
StaticallyUsed(const StaticallyUsed &rhs); ActiveVariable(const ActiveVariable &rhs);
virtual ~StaticallyUsed(); virtual ~ActiveVariable();
StaticallyUsed &operator=(const StaticallyUsed &rhs); ActiveVariable &operator=(const ActiveVariable &rhs);
ShaderType getFirstStaticUseShaderType() const; ShaderType getFirstShaderTypeWhereActive() const;
void setStaticUse(GLenum shaderType, bool used); void setActive(GLenum shaderType, bool used);
void unionReferencesWith(const StaticallyUsed &other); void unionReferencesWith(const ActiveVariable &other);
bool vertexStaticUse; bool vertexActive;
bool fragmentStaticUse; bool fragmentActive;
bool computeStaticUse; bool computeActive;
bool geometryStaticUse; bool geometryActive;
}; };
// Helper struct representing a single shader uniform // Helper struct representing a single shader uniform
struct LinkedUniform : public sh::Uniform, public StaticallyUsed struct LinkedUniform : public sh::Uniform, public ActiveVariable
{ {
LinkedUniform(); LinkedUniform();
LinkedUniform(GLenum type, LinkedUniform(GLenum type,
...@@ -71,7 +71,7 @@ struct LinkedUniform : public sh::Uniform, public StaticallyUsed ...@@ -71,7 +71,7 @@ struct LinkedUniform : public sh::Uniform, public StaticallyUsed
sh::BlockMemberInfo blockInfo; sh::BlockMemberInfo blockInfo;
}; };
struct BufferVariable : public sh::ShaderVariable, public StaticallyUsed struct BufferVariable : public sh::ShaderVariable, public ActiveVariable
{ {
BufferVariable(); BufferVariable();
BufferVariable(GLenum type, BufferVariable(GLenum type,
...@@ -90,7 +90,7 @@ struct BufferVariable : public sh::ShaderVariable, public StaticallyUsed ...@@ -90,7 +90,7 @@ struct BufferVariable : public sh::ShaderVariable, public StaticallyUsed
// Parent struct for atomic counter, uniform block, and shader storage block buffer, which all // Parent struct for atomic counter, uniform block, and shader storage block buffer, which all
// contain a group of shader variables, and have a GL buffer backed. // contain a group of shader variables, and have a GL buffer backed.
struct ShaderVariableBuffer : public StaticallyUsed struct ShaderVariableBuffer : public ActiveVariable
{ {
ShaderVariableBuffer(); ShaderVariableBuffer();
ShaderVariableBuffer(const ShaderVariableBuffer &other); ShaderVariableBuffer(const ShaderVariableBuffer &other);
......
...@@ -292,7 +292,10 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog, ...@@ -292,7 +292,10 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog,
const sh::Varying *output = ref.second.fragment; const sh::Varying *output = ref.second.fragment;
// Only pack statically used varyings that have a matched input or output, plus special // Only pack statically used varyings that have a matched input or output, plus special
// builtins. // builtins. Note that we pack all statically used varyings even if they are not active.
// GLES specs are a bit vague on whether it's allowed to only pack active varyings, though
// GLES 3.1 spec section 11.1.2.1 says that "device-dependent optimizations" may be used to
// make vertex shader outputs fit.
if ((input && output && output->staticUse) || if ((input && output && output->staticUse) ||
(input && input->isBuiltIn() && input->staticUse) || (input && input->isBuiltIn() && input->staticUse) ||
(output && output->isBuiltIn() && output->staticUse)) (output && output->isBuiltIn() && output->staticUse))
......
...@@ -727,13 +727,13 @@ void GetShaderVariableBufferResourceProperty(const ShaderVariableBuffer &buffer, ...@@ -727,13 +727,13 @@ void GetShaderVariableBufferResourceProperty(const ShaderVariableBuffer &buffer,
} }
break; break;
case GL_REFERENCED_BY_VERTEX_SHADER: case GL_REFERENCED_BY_VERTEX_SHADER:
params[(*outputPosition)++] = static_cast<GLint>(buffer.vertexStaticUse); params[(*outputPosition)++] = static_cast<GLint>(buffer.vertexActive);
break; break;
case GL_REFERENCED_BY_FRAGMENT_SHADER: case GL_REFERENCED_BY_FRAGMENT_SHADER:
params[(*outputPosition)++] = static_cast<GLint>(buffer.fragmentStaticUse); params[(*outputPosition)++] = static_cast<GLint>(buffer.fragmentActive);
break; break;
case GL_REFERENCED_BY_COMPUTE_SHADER: case GL_REFERENCED_BY_COMPUTE_SHADER:
params[(*outputPosition)++] = static_cast<GLint>(buffer.computeStaticUse); params[(*outputPosition)++] = static_cast<GLint>(buffer.computeActive);
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -1425,13 +1425,13 @@ GLint GetUniformResourceProperty(const Program *program, GLuint index, const GLe ...@@ -1425,13 +1425,13 @@ GLint GetUniformResourceProperty(const Program *program, GLuint index, const GLe
return static_cast<GLint>(uniform.blockInfo.isRowMajorMatrix); return static_cast<GLint>(uniform.blockInfo.isRowMajorMatrix);
case GL_REFERENCED_BY_VERTEX_SHADER: case GL_REFERENCED_BY_VERTEX_SHADER:
return uniform.vertexStaticUse; return uniform.vertexActive;
case GL_REFERENCED_BY_FRAGMENT_SHADER: case GL_REFERENCED_BY_FRAGMENT_SHADER:
return uniform.fragmentStaticUse; return uniform.fragmentActive;
case GL_REFERENCED_BY_COMPUTE_SHADER: case GL_REFERENCED_BY_COMPUTE_SHADER:
return uniform.computeStaticUse; return uniform.computeActive;
case GL_ATOMIC_COUNTER_BUFFER_INDEX: case GL_ATOMIC_COUNTER_BUFFER_INDEX:
return (uniform.isAtomicCounter() ? uniform.bufferIndex : -1); return (uniform.isAtomicCounter() ? uniform.bufferIndex : -1);
...@@ -1468,13 +1468,13 @@ GLint GetBufferVariableResourceProperty(const Program *program, GLuint index, co ...@@ -1468,13 +1468,13 @@ GLint GetBufferVariableResourceProperty(const Program *program, GLuint index, co
return static_cast<GLint>(bufferVariable.blockInfo.isRowMajorMatrix); return static_cast<GLint>(bufferVariable.blockInfo.isRowMajorMatrix);
case GL_REFERENCED_BY_VERTEX_SHADER: case GL_REFERENCED_BY_VERTEX_SHADER:
return bufferVariable.vertexStaticUse; return bufferVariable.vertexActive;
case GL_REFERENCED_BY_FRAGMENT_SHADER: case GL_REFERENCED_BY_FRAGMENT_SHADER:
return bufferVariable.fragmentStaticUse; return bufferVariable.fragmentActive;
case GL_REFERENCED_BY_COMPUTE_SHADER: case GL_REFERENCED_BY_COMPUTE_SHADER:
return bufferVariable.computeStaticUse; return bufferVariable.computeActive;
case GL_TOP_LEVEL_ARRAY_SIZE: case GL_TOP_LEVEL_ARRAY_SIZE:
return bufferVariable.topLevelArraySize; return bufferVariable.topLevelArraySize;
......
...@@ -1286,7 +1286,7 @@ void DynamicHLSL::getPixelShaderOutputKey(const gl::ContextState &data, ...@@ -1286,7 +1286,7 @@ void DynamicHLSL::getPixelShaderOutputKey(const gl::ContextState &data,
const std::string &elementString = const std::string &elementString =
(outputVariable.isArray() ? Str(outputLocation.arrayIndex) : ""); (outputVariable.isArray() ? Str(outputLocation.arrayIndex) : "");
ASSERT(outputVariable.staticUse); ASSERT(outputVariable.active);
PixelShaderOutputVariable outputKeyVariable; PixelShaderOutputVariable outputKeyVariable;
outputKeyVariable.type = outputVariable.type; outputKeyVariable.type = outputVariable.type;
......
...@@ -221,7 +221,7 @@ void UniformBlockInfo::getShaderBlockInfo(const gl::Context *context, gl::Shader ...@@ -221,7 +221,7 @@ void UniformBlockInfo::getShaderBlockInfo(const gl::Context *context, gl::Shader
{ {
for (const sh::InterfaceBlock &interfaceBlock : shader->getUniformBlocks(context)) for (const sh::InterfaceBlock &interfaceBlock : shader->getUniformBlocks(context))
{ {
if (!interfaceBlock.staticUse && interfaceBlock.layout == sh::BLOCKLAYOUT_PACKED) if (!interfaceBlock.active && interfaceBlock.layout == sh::BLOCKLAYOUT_PACKED)
continue; continue;
if (mBlockSizes.count(interfaceBlock.name) > 0) if (mBlockSizes.count(interfaceBlock.name) > 0)
...@@ -234,7 +234,7 @@ void UniformBlockInfo::getShaderBlockInfo(const gl::Context *context, gl::Shader ...@@ -234,7 +234,7 @@ void UniformBlockInfo::getShaderBlockInfo(const gl::Context *context, gl::Shader
size_t UniformBlockInfo::getBlockInfo(const sh::InterfaceBlock &interfaceBlock) size_t UniformBlockInfo::getBlockInfo(const sh::InterfaceBlock &interfaceBlock)
{ {
ASSERT(interfaceBlock.staticUse || interfaceBlock.layout != sh::BLOCKLAYOUT_PACKED); ASSERT(interfaceBlock.active || interfaceBlock.layout != sh::BLOCKLAYOUT_PACKED);
// define member uniforms // define member uniforms
sh::Std140BlockEncoder std140Encoder; sh::Std140BlockEncoder std140Encoder;
...@@ -1806,14 +1806,14 @@ void ProgramD3D::initializeUniformBlocks() ...@@ -1806,14 +1806,14 @@ void ProgramD3D::initializeUniformBlocks()
D3DUniformBlock d3dUniformBlock; D3DUniformBlock d3dUniformBlock;
if (uniformBlock.vertexStaticUse) if (uniformBlock.vertexActive)
{ {
ASSERT(vertexShaderD3D != nullptr); ASSERT(vertexShaderD3D != nullptr);
unsigned int baseRegister = vertexShaderD3D->getUniformBlockRegister(uniformBlock.name); unsigned int baseRegister = vertexShaderD3D->getUniformBlockRegister(uniformBlock.name);
d3dUniformBlock.vsRegisterIndex = baseRegister + uniformBlockElement; d3dUniformBlock.vsRegisterIndex = baseRegister + uniformBlockElement;
} }
if (uniformBlock.fragmentStaticUse) if (uniformBlock.fragmentActive)
{ {
ASSERT(fragmentShaderD3D != nullptr); ASSERT(fragmentShaderD3D != nullptr);
unsigned int baseRegister = unsigned int baseRegister =
...@@ -1821,7 +1821,7 @@ void ProgramD3D::initializeUniformBlocks() ...@@ -1821,7 +1821,7 @@ void ProgramD3D::initializeUniformBlocks()
d3dUniformBlock.psRegisterIndex = baseRegister + uniformBlockElement; d3dUniformBlock.psRegisterIndex = baseRegister + uniformBlockElement;
} }
if (uniformBlock.computeStaticUse) if (uniformBlock.computeActive)
{ {
ASSERT(computeShaderD3D != nullptr); ASSERT(computeShaderD3D != nullptr);
unsigned int baseRegister = unsigned int baseRegister =
...@@ -1916,12 +1916,12 @@ void ProgramD3D::updateUniformBufferCache(const gl::Caps &caps, ...@@ -1916,12 +1916,12 @@ void ProgramD3D::updateUniformBufferCache(const gl::Caps &caps,
GLuint blockBinding = mState.getUniformBlockBinding(uniformBlockIndex); GLuint blockBinding = mState.getUniformBlockBinding(uniformBlockIndex);
// Unnecessary to apply an unreferenced standard or shared UBO // Unnecessary to apply an unreferenced standard or shared UBO
if (!uniformBlock.vertexStaticUse() && !uniformBlock.fragmentStaticUse()) if (!uniformBlock.vertexActive() && !uniformBlock.fragmentActive())
{ {
continue; continue;
} }
if (uniformBlock.vertexStaticUse()) if (uniformBlock.vertexActive())
{ {
unsigned int registerIndex = uniformBlock.vsRegisterIndex - reservedVertex; unsigned int registerIndex = uniformBlock.vsRegisterIndex - reservedVertex;
ASSERT(registerIndex < caps.maxVertexUniformBlocks); ASSERT(registerIndex < caps.maxVertexUniformBlocks);
...@@ -1935,7 +1935,7 @@ void ProgramD3D::updateUniformBufferCache(const gl::Caps &caps, ...@@ -1935,7 +1935,7 @@ void ProgramD3D::updateUniformBufferCache(const gl::Caps &caps,
mVertexUBOCache[registerIndex] = blockBinding; mVertexUBOCache[registerIndex] = blockBinding;
} }
if (uniformBlock.fragmentStaticUse()) if (uniformBlock.fragmentActive())
{ {
unsigned int registerIndex = uniformBlock.psRegisterIndex - reservedFragment; unsigned int registerIndex = uniformBlock.psRegisterIndex - reservedFragment;
ASSERT(registerIndex < caps.maxFragmentUniformBlocks); ASSERT(registerIndex < caps.maxFragmentUniformBlocks);
...@@ -2120,7 +2120,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters(const gl::Context *context) ...@@ -2120,7 +2120,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters(const gl::Context *context)
{ {
for (const sh::Uniform &computeUniform : computeShader->getUniforms(context)) for (const sh::Uniform &computeUniform : computeShader->getUniforms(context))
{ {
if (computeUniform.staticUse) if (computeUniform.active)
{ {
defineUniformBase(computeShader, computeUniform, &uniformMap); defineUniformBase(computeShader, computeUniform, &uniformMap);
} }
...@@ -2131,7 +2131,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters(const gl::Context *context) ...@@ -2131,7 +2131,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters(const gl::Context *context)
gl::Shader *vertexShader = mState.getAttachedVertexShader(); gl::Shader *vertexShader = mState.getAttachedVertexShader();
for (const sh::Uniform &vertexUniform : vertexShader->getUniforms(context)) for (const sh::Uniform &vertexUniform : vertexShader->getUniforms(context))
{ {
if (vertexUniform.staticUse) if (vertexUniform.active)
{ {
defineUniformBase(vertexShader, vertexUniform, &uniformMap); defineUniformBase(vertexShader, vertexUniform, &uniformMap);
} }
...@@ -2140,7 +2140,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters(const gl::Context *context) ...@@ -2140,7 +2140,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters(const gl::Context *context)
gl::Shader *fragmentShader = mState.getAttachedFragmentShader(); gl::Shader *fragmentShader = mState.getAttachedFragmentShader();
for (const sh::Uniform &fragmentUniform : fragmentShader->getUniforms(context)) for (const sh::Uniform &fragmentUniform : fragmentShader->getUniforms(context))
{ {
if (fragmentUniform.staticUse) if (fragmentUniform.active)
{ {
defineUniformBase(fragmentShader, fragmentUniform, &uniformMap); defineUniformBase(fragmentShader, fragmentUniform, &uniformMap);
} }
......
...@@ -97,11 +97,11 @@ struct D3DUniformBlock ...@@ -97,11 +97,11 @@ struct D3DUniformBlock
{ {
} }
bool vertexStaticUse() const { return vsRegisterIndex != GL_INVALID_INDEX; } bool vertexActive() const { return vsRegisterIndex != GL_INVALID_INDEX; }
bool fragmentStaticUse() const { return psRegisterIndex != GL_INVALID_INDEX; } bool fragmentActive() const { return psRegisterIndex != GL_INVALID_INDEX; }
bool computeStaticUse() const { return csRegisterIndex != GL_INVALID_INDEX; } bool computeActive() const { return csRegisterIndex != GL_INVALID_INDEX; }
unsigned int vsRegisterIndex; unsigned int vsRegisterIndex;
unsigned int psRegisterIndex; unsigned int psRegisterIndex;
......
...@@ -204,7 +204,7 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo ...@@ -204,7 +204,7 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo
for (const sh::InterfaceBlock &interfaceBlock : mData.getUniformBlocks()) for (const sh::InterfaceBlock &interfaceBlock : mData.getUniformBlocks())
{ {
if (interfaceBlock.staticUse) if (interfaceBlock.active)
{ {
unsigned int index = static_cast<unsigned int>(-1); unsigned int index = static_cast<unsigned int>(-1);
bool blockRegisterResult = bool blockRegisterResult =
......
...@@ -192,7 +192,7 @@ gl::LinkResult ProgramGL::link(const gl::Context *context, ...@@ -192,7 +192,7 @@ gl::LinkResult ProgramGL::link(const gl::Context *context,
// Bind attribute locations to match the GL layer. // Bind attribute locations to match the GL layer.
for (const sh::Attribute &attribute : mState.getAttributes()) for (const sh::Attribute &attribute : mState.getAttributes())
{ {
if (!attribute.staticUse || attribute.isBuiltIn()) if (!attribute.active || attribute.isBuiltIn())
{ {
continue; continue;
} }
......
...@@ -138,13 +138,13 @@ gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext, ...@@ -138,13 +138,13 @@ gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext,
std::string setBindingString = "set = 1, binding = " + Str(textureCount); std::string setBindingString = "set = 1, binding = " + Str(textureCount);
ASSERT(samplerUniform.vertexStaticUse || samplerUniform.fragmentStaticUse); ASSERT(samplerUniform.vertexActive || samplerUniform.fragmentActive);
if (samplerUniform.vertexStaticUse) if (samplerUniform.vertexActive)
{ {
InsertLayoutSpecifierString(&vertexSource, samplerUniform.name, setBindingString); InsertLayoutSpecifierString(&vertexSource, samplerUniform.name, setBindingString);
} }
if (samplerUniform.fragmentStaticUse) if (samplerUniform.fragmentActive)
{ {
InsertLayoutSpecifierString(&fragmentSource, samplerUniform.name, setBindingString); InsertLayoutSpecifierString(&fragmentSource, samplerUniform.name, setBindingString);
} }
......
...@@ -457,7 +457,7 @@ void ProgramVk::getUniformImpl(GLint location, T *v, GLenum entryPointType) cons ...@@ -457,7 +457,7 @@ void ProgramVk::getUniformImpl(GLint location, T *v, GLenum entryPointType) cons
} }
ASSERT(linkedUniform.typeInfo->componentType == entryPointType); ASSERT(linkedUniform.typeInfo->componentType == entryPointType);
const gl::ShaderType shaderType = linkedUniform.getFirstStaticUseShaderType(); const gl::ShaderType shaderType = linkedUniform.getFirstShaderTypeWhereActive();
ASSERT(shaderType != gl::ShaderType::SHADER_TYPE_INVALID); ASSERT(shaderType != gl::ShaderType::SHADER_TYPE_INVALID);
const DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType]; const DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
......
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