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
// and flattenedOffsetInParentArrays of a[2][1] would be 2*4 + 1 = 9.
unsigned int flattenedOffsetInParentArrays;
// Static use means that the variable is accessed somewhere in the shader source.
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::string structName;
......@@ -279,6 +284,7 @@ struct InterfaceBlock
int binding;
bool staticUse;
bool active;
BlockType blockType;
std::vector<InterfaceBlockField> fields;
};
......
......@@ -83,6 +83,7 @@ void MarkStaticallyUsed(ShaderVariable *variable)
}
}
variable->staticUse = true;
variable->active = true;
}
}
......@@ -96,6 +97,7 @@ ShaderVariable *FindVariableInInterfaceBlock(const ImmutableString &name,
// Set static use on the parent interface block here
namedBlock->staticUse = true;
namedBlock->active = true;
return FindVariable(name, &namedBlock->fields);
}
......@@ -284,6 +286,7 @@ void CollectVariablesTraverser::recordBuiltInVaryingUsed(const ImmutableString &
Varying info;
setBuiltInInfoFromSymbolTable(name, &info);
info.staticUse = true;
info.active = true;
info.isInvariant = mSymbolTable->isVaryingInvariant(name);
varyings->push_back(info);
(*addedFlag) = true;
......@@ -298,6 +301,7 @@ void CollectVariablesTraverser::recordBuiltInFragmentOutputUsed(const ImmutableS
OutputVariable info;
setBuiltInInfoFromSymbolTable(name, &info);
info.staticUse = true;
info.active = true;
mOutputVariables->push_back(info);
(*addedFlag) = true;
}
......@@ -311,6 +315,7 @@ void CollectVariablesTraverser::recordBuiltInAttributeUsed(const ImmutableString
Attribute info;
setBuiltInInfoFromSymbolTable(name, &info);
info.staticUse = true;
info.active = true;
info.location = -1;
mAttribs->push_back(info);
(*addedFlag) = true;
......@@ -325,6 +330,7 @@ InterfaceBlock *CollectVariablesTraverser::recordGLInUsed(const TType &glInType)
InterfaceBlock info;
recordInterfaceBlock("gl_in", glInType, &info);
info.staticUse = true;
info.active = true;
mPerVertexInAdded = true;
mInBlocks->push_back(info);
......@@ -385,6 +391,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
info.type = GL_NONE;
info.precision = GL_NONE;
info.staticUse = true;
info.active = true;
ShaderVariable nearInfo(GL_FLOAT);
const char kNearName[] = "near";
......@@ -392,6 +399,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
nearInfo.mappedName = kNearName;
nearInfo.precision = GL_HIGH_FLOAT;
nearInfo.staticUse = true;
nearInfo.active = true;
ShaderVariable farInfo(GL_FLOAT);
const char kFarName[] = "far";
......@@ -399,6 +407,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
farInfo.mappedName = kFarName;
farInfo.precision = GL_HIGH_FLOAT;
farInfo.staticUse = true;
farInfo.active = true;
ShaderVariable diffInfo(GL_FLOAT);
const char kDiffName[] = "diff";
......@@ -406,6 +415,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
diffInfo.mappedName = kDiffName;
diffInfo.precision = GL_HIGH_FLOAT;
diffInfo.staticUse = true;
diffInfo.active = true;
info.fields.push_back(nearInfo);
info.fields.push_back(farInfo);
......@@ -476,6 +486,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
info.type = GL_INT;
info.precision = GL_HIGH_INT; // Defined by spec.
info.staticUse = true;
info.active = true;
info.location = -1;
mAttribs->push_back(info);
mInstanceIDAdded = true;
......@@ -510,6 +521,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
info.arraySizes.back() = 1u;
}
info.staticUse = true;
info.active = true;
mOutputVariables->push_back(info);
mFragDataAdded = true;
}
......@@ -883,9 +895,11 @@ bool CollectVariablesTraverser::visitBinary(Visit, TIntermBinary *binaryNode)
}
ASSERT(namedBlock);
namedBlock->staticUse = true;
namedBlock->active = true;
unsigned int fieldIndex = static_cast<unsigned int>(constantUnion->getIConst(0));
ASSERT(fieldIndex < namedBlock->fields.size());
namedBlock->fields[fieldIndex].staticUse = true;
namedBlock->fields[fieldIndex].active = true;
if (traverseIndexExpression)
{
......
......@@ -32,17 +32,17 @@ bool InterpolationTypesMatch(InterpolationType a, InterpolationType b)
}
ShaderVariable::ShaderVariable()
: type(0), precision(0), flattenedOffsetInParentArrays(0), staticUse(false)
: type(0), precision(0), flattenedOffsetInParentArrays(0), staticUse(false), active(false)
{
}
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)
: type(typeIn), precision(0), flattenedOffsetInParentArrays(0), staticUse(false)
: type(typeIn), precision(0), flattenedOffsetInParentArrays(0), staticUse(false), active(false)
{
ASSERT(arraySizeIn != 0);
arraySizes.push_back(arraySizeIn);
......@@ -60,6 +60,7 @@ ShaderVariable::ShaderVariable(const ShaderVariable &other)
arraySizes(other.arraySizes),
flattenedOffsetInParentArrays(other.flattenedOffsetInParentArrays),
staticUse(other.staticUse),
active(other.active),
fields(other.fields),
structName(other.structName)
{
......@@ -73,6 +74,7 @@ ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other)
mappedName = other.mappedName;
arraySizes = other.arraySizes;
staticUse = other.staticUse;
active = other.active;
flattenedOffsetInParentArrays = other.flattenedOffsetInParentArrays;
fields = other.fields;
structName = other.structName;
......@@ -83,8 +85,8 @@ bool ShaderVariable::operator==(const ShaderVariable &other) const
{
if (type != other.type || precision != other.precision || name != other.name ||
mappedName != other.mappedName || arraySizes != other.arraySizes ||
staticUse != other.staticUse || fields.size() != other.fields.size() ||
structName != other.structName)
staticUse != other.staticUse || active != other.active ||
fields.size() != other.fields.size() || structName != other.structName)
{
return false;
}
......@@ -454,6 +456,7 @@ InterfaceBlock::InterfaceBlock()
isRowMajorLayout(false),
binding(-1),
staticUse(false),
active(false),
blockType(BlockType::BLOCK_UNIFORM)
{
}
......@@ -471,6 +474,7 @@ InterfaceBlock::InterfaceBlock(const InterfaceBlock &other)
isRowMajorLayout(other.isRowMajorLayout),
binding(other.binding),
staticUse(other.staticUse),
active(other.active),
blockType(other.blockType),
fields(other.fields)
{
......@@ -486,6 +490,7 @@ InterfaceBlock &InterfaceBlock::operator=(const InterfaceBlock &other)
isRowMajorLayout = other.isRowMajorLayout;
binding = other.binding;
staticUse = other.staticUse;
active = other.active;
blockType = other.blockType;
fields = other.fields;
return *this;
......
......@@ -44,6 +44,7 @@ void WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var)
stream->writeString(var.mappedName);
stream->writeIntVector(var.arraySizes);
stream->writeInt(var.staticUse);
stream->writeInt(var.active);
stream->writeString(var.structName);
ASSERT(var.fields.empty());
}
......@@ -56,6 +57,7 @@ void LoadShaderVar(BinaryInputStream *stream, sh::ShaderVariable *var)
var->mappedName = stream->readString();
stream->readIntVector<unsigned int>(&var->arraySizes);
var->staticUse = stream->readBool();
var->active = stream->readBool();
var->structName = stream->readString();
}
......@@ -64,10 +66,10 @@ void WriteShaderVariableBuffer(BinaryOutputStream *stream, const ShaderVariableB
stream->writeInt(var.binding);
stream->writeInt(var.dataSize);
stream->writeInt(var.vertexStaticUse);
stream->writeInt(var.fragmentStaticUse);
stream->writeInt(var.computeStaticUse);
stream->writeInt(var.geometryStaticUse);
stream->writeInt(var.vertexActive);
stream->writeInt(var.fragmentActive);
stream->writeInt(var.computeActive);
stream->writeInt(var.geometryActive);
stream->writeInt(var.memberIndexes.size());
for (unsigned int memberCounterIndex : var.memberIndexes)
......@@ -80,10 +82,10 @@ void LoadShaderVariableBuffer(BinaryInputStream *stream, ShaderVariableBuffer *v
{
var->binding = stream->readInt<int>();
var->dataSize = stream->readInt<unsigned int>();
var->vertexStaticUse = stream->readBool();
var->fragmentStaticUse = stream->readBool();
var->computeStaticUse = stream->readBool();
var->geometryStaticUse = stream->readBool();
var->vertexActive = stream->readBool();
var->fragmentActive = stream->readBool();
var->computeActive = stream->readBool();
var->geometryActive = stream->readBool();
unsigned int numMembers = stream->readInt<unsigned int>();
for (unsigned int blockMemberIndex = 0; blockMemberIndex < numMembers; blockMemberIndex++)
......@@ -103,9 +105,9 @@ void WriteBufferVariable(BinaryOutputStream *stream, const BufferVariable &var)
stream->writeInt(var.blockInfo.isRowMajorMatrix);
stream->writeInt(var.blockInfo.topLevelArrayStride);
stream->writeInt(var.topLevelArraySize);
stream->writeInt(var.vertexStaticUse);
stream->writeInt(var.fragmentStaticUse);
stream->writeInt(var.computeStaticUse);
stream->writeInt(var.vertexActive);
stream->writeInt(var.fragmentActive);
stream->writeInt(var.computeActive);
}
void LoadBufferVariable(BinaryInputStream *stream, BufferVariable *var)
......@@ -119,9 +121,9 @@ void LoadBufferVariable(BinaryInputStream *stream, BufferVariable *var)
var->blockInfo.isRowMajorMatrix = stream->readBool();
var->blockInfo.topLevelArrayStride = stream->readInt<int>();
var->topLevelArraySize = stream->readInt<int>();
var->vertexStaticUse = stream->readBool();
var->fragmentStaticUse = stream->readBool();
var->computeStaticUse = stream->readBool();
var->vertexActive = stream->readBool();
var->fragmentActive = stream->readBool();
var->computeActive = stream->readBool();
}
void WriteInterfaceBlock(BinaryOutputStream *stream, const InterfaceBlock &block)
......
......@@ -213,7 +213,7 @@ bool ValidateInterfaceBlocksCount(GLuint maxInterfaceBlocks,
GLuint blockCount = 0;
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);
if (blockCount > maxInterfaceBlocks)
......@@ -646,7 +646,7 @@ void LogLinkMismatch(InfoLog &infoLog,
bool IsActiveInterfaceBlock(const sh::InterfaceBlock &interfaceBlock)
{
// 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.
......@@ -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)
{
infoLog << GetShaderTypeString(consumingShader->getType()) << " varying " << input.name
......
......@@ -114,7 +114,7 @@ class UniformLinker final : angle::NonCopyable
std::vector<LinkedUniform> *imageUniforms,
std::vector<LinkedUniform> *atomicCounterUniforms,
GLenum shaderType,
bool markStaticUse,
bool markActive,
int binding,
int offset,
int *location);
......@@ -126,7 +126,7 @@ class UniformLinker final : angle::NonCopyable
std::vector<LinkedUniform> *imageUniforms,
std::vector<LinkedUniform> *atomicCounterUniforms,
GLenum shaderType,
bool markStaticUse,
bool markActive,
int binding,
int offset,
int *location);
......@@ -138,12 +138,12 @@ class UniformLinker final : angle::NonCopyable
std::vector<LinkedUniform> *imageUniforms,
std::vector<LinkedUniform> *atomicCounterUniforms,
GLenum shaderType,
bool markStaticUse,
bool markActive,
int binding,
int offset,
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.
ShaderUniformCount flattenUniformImpl(const sh::ShaderVariable &uniform,
const std::string &fullName,
......@@ -152,7 +152,7 @@ class UniformLinker final : angle::NonCopyable
std::vector<LinkedUniform> *imageUniforms,
std::vector<LinkedUniform> *atomicCounterUniforms,
GLenum shaderType,
bool markStaticUse,
bool markActive,
int binding,
int offset,
int *location);
......@@ -225,9 +225,9 @@ class InterfaceBlockLinker : angle::NonCopyable
int topLevelArraySize,
GLenum shaderType) const = 0;
virtual size_t getCurrentBlockMemberIndex() const = 0;
virtual void updateBlockMemberStaticUsedImpl(const std::string &fullName,
GLenum shaderType,
bool staticUse) const = 0;
virtual void updateBlockMemberActiveImpl(const std::string &fullName,
GLenum shaderType,
bool active) const = 0;
using ShaderBlocks = std::pair<GLenum, const std::vector<sh::InterfaceBlock> *>;
std::vector<ShaderBlocks> mShaderBlocks;
......@@ -263,9 +263,9 @@ class UniformBlockLinker final : public InterfaceBlockLinker
int topLevelArraySize,
GLenum shaderType) const override;
size_t getCurrentBlockMemberIndex() const override;
void updateBlockMemberStaticUsedImpl(const std::string &fullName,
GLenum shaderType,
bool staticUse) const override;
void updateBlockMemberActiveImpl(const std::string &fullName,
GLenum shaderType,
bool active) const override;
std::vector<LinkedUniform> *mUniformsOut;
};
......@@ -285,9 +285,9 @@ class ShaderStorageBlockLinker final : public InterfaceBlockLinker
int topLevelArraySize,
GLenum shaderType) const override;
size_t getCurrentBlockMemberIndex() const override;
void updateBlockMemberStaticUsedImpl(const std::string &fullName,
GLenum shaderType,
bool staticUse) const override;
void updateBlockMemberActiveImpl(const std::string &fullName,
GLenum shaderType,
bool active) const override;
std::vector<BufferVariable> *mBufferVariablesOut;
};
......
......@@ -35,7 +35,7 @@ std::vector<VarT> GetActiveShaderVariables(const std::vector<VarT> *variableList
for (size_t varIndex = 0; varIndex < variableList->size(); varIndex++)
{
const VarT &var = variableList->at(varIndex);
if (var.staticUse)
if (var.active)
{
result.push_back(var);
}
......
......@@ -13,39 +13,36 @@
namespace gl
{
StaticallyUsed::StaticallyUsed()
: vertexStaticUse(false),
fragmentStaticUse(false),
computeStaticUse(false),
geometryStaticUse(false)
ActiveVariable::ActiveVariable()
: vertexActive(false), fragmentActive(false), computeActive(false), geometryActive(false)
{
}
StaticallyUsed::~StaticallyUsed()
ActiveVariable::~ActiveVariable()
{
}
StaticallyUsed::StaticallyUsed(const StaticallyUsed &rhs) = default;
StaticallyUsed &StaticallyUsed::operator=(const StaticallyUsed &rhs) = default;
ActiveVariable::ActiveVariable(const ActiveVariable &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)
{
case GL_VERTEX_SHADER:
vertexStaticUse = used;
vertexActive = used;
break;
case GL_FRAGMENT_SHADER:
fragmentStaticUse = used;
fragmentActive = used;
break;
case GL_COMPUTE_SHADER:
computeStaticUse = used;
computeActive = used;
break;
case GL_GEOMETRY_SHADER_EXT:
geometryStaticUse = used;
geometryActive = used;
break;
default:
......@@ -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;
fragmentStaticUse |= other.fragmentStaticUse;
computeStaticUse |= other.computeStaticUse;
geometryStaticUse |= other.geometryStaticUse;
vertexActive |= other.vertexActive;
fragmentActive |= other.fragmentActive;
computeActive |= other.computeActive;
geometryActive |= other.geometryActive;
}
ShaderType StaticallyUsed::getFirstStaticUseShaderType() const
ShaderType ActiveVariable::getFirstShaderTypeWhereActive() const
{
if (vertexStaticUse)
if (vertexActive)
return SHADER_VERTEX;
if (fragmentStaticUse)
if (fragmentActive)
return SHADER_FRAGMENT;
if (computeStaticUse)
if (computeActive)
return SHADER_COMPUTE;
if (geometryStaticUse)
if (geometryActive)
return SHADER_GEOMETRY;
UNREACHABLE();
......@@ -115,7 +112,7 @@ LinkedUniform::LinkedUniform(const sh::Uniform &uniform)
LinkedUniform::LinkedUniform(const LinkedUniform &uniform)
: sh::Uniform(uniform),
StaticallyUsed(uniform),
ActiveVariable(uniform),
typeInfo(uniform.typeInfo),
bufferIndex(uniform.bufferIndex),
blockInfo(uniform.blockInfo)
......@@ -125,7 +122,7 @@ LinkedUniform::LinkedUniform(const LinkedUniform &uniform)
LinkedUniform &LinkedUniform::operator=(const LinkedUniform &uniform)
{
sh::Uniform::operator=(uniform);
StaticallyUsed::operator=(uniform);
ActiveVariable::operator=(uniform);
typeInfo = uniform.typeInfo;
bufferIndex = uniform.bufferIndex;
blockInfo = uniform.blockInfo;
......
......@@ -20,26 +20,26 @@ namespace gl
{
struct UniformTypeInfo;
struct StaticallyUsed
struct ActiveVariable
{
StaticallyUsed();
StaticallyUsed(const StaticallyUsed &rhs);
virtual ~StaticallyUsed();
ActiveVariable();
ActiveVariable(const ActiveVariable &rhs);
virtual ~ActiveVariable();
StaticallyUsed &operator=(const StaticallyUsed &rhs);
ActiveVariable &operator=(const ActiveVariable &rhs);
ShaderType getFirstStaticUseShaderType() const;
void setStaticUse(GLenum shaderType, bool used);
void unionReferencesWith(const StaticallyUsed &other);
ShaderType getFirstShaderTypeWhereActive() const;
void setActive(GLenum shaderType, bool used);
void unionReferencesWith(const ActiveVariable &other);
bool vertexStaticUse;
bool fragmentStaticUse;
bool computeStaticUse;
bool geometryStaticUse;
bool vertexActive;
bool fragmentActive;
bool computeActive;
bool geometryActive;
};
// Helper struct representing a single shader uniform
struct LinkedUniform : public sh::Uniform, public StaticallyUsed
struct LinkedUniform : public sh::Uniform, public ActiveVariable
{
LinkedUniform();
LinkedUniform(GLenum type,
......@@ -71,7 +71,7 @@ struct LinkedUniform : public sh::Uniform, public StaticallyUsed
sh::BlockMemberInfo blockInfo;
};
struct BufferVariable : public sh::ShaderVariable, public StaticallyUsed
struct BufferVariable : public sh::ShaderVariable, public ActiveVariable
{
BufferVariable();
BufferVariable(GLenum type,
......@@ -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
// contain a group of shader variables, and have a GL buffer backed.
struct ShaderVariableBuffer : public StaticallyUsed
struct ShaderVariableBuffer : public ActiveVariable
{
ShaderVariableBuffer();
ShaderVariableBuffer(const ShaderVariableBuffer &other);
......
......@@ -292,7 +292,10 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog,
const sh::Varying *output = ref.second.fragment;
// 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) ||
(input && input->isBuiltIn() && input->staticUse) ||
(output && output->isBuiltIn() && output->staticUse))
......
......@@ -727,13 +727,13 @@ void GetShaderVariableBufferResourceProperty(const ShaderVariableBuffer &buffer,
}
break;
case GL_REFERENCED_BY_VERTEX_SHADER:
params[(*outputPosition)++] = static_cast<GLint>(buffer.vertexStaticUse);
params[(*outputPosition)++] = static_cast<GLint>(buffer.vertexActive);
break;
case GL_REFERENCED_BY_FRAGMENT_SHADER:
params[(*outputPosition)++] = static_cast<GLint>(buffer.fragmentStaticUse);
params[(*outputPosition)++] = static_cast<GLint>(buffer.fragmentActive);
break;
case GL_REFERENCED_BY_COMPUTE_SHADER:
params[(*outputPosition)++] = static_cast<GLint>(buffer.computeStaticUse);
params[(*outputPosition)++] = static_cast<GLint>(buffer.computeActive);
break;
default:
UNREACHABLE();
......@@ -1425,13 +1425,13 @@ GLint GetUniformResourceProperty(const Program *program, GLuint index, const GLe
return static_cast<GLint>(uniform.blockInfo.isRowMajorMatrix);
case GL_REFERENCED_BY_VERTEX_SHADER:
return uniform.vertexStaticUse;
return uniform.vertexActive;
case GL_REFERENCED_BY_FRAGMENT_SHADER:
return uniform.fragmentStaticUse;
return uniform.fragmentActive;
case GL_REFERENCED_BY_COMPUTE_SHADER:
return uniform.computeStaticUse;
return uniform.computeActive;
case GL_ATOMIC_COUNTER_BUFFER_INDEX:
return (uniform.isAtomicCounter() ? uniform.bufferIndex : -1);
......@@ -1468,13 +1468,13 @@ GLint GetBufferVariableResourceProperty(const Program *program, GLuint index, co
return static_cast<GLint>(bufferVariable.blockInfo.isRowMajorMatrix);
case GL_REFERENCED_BY_VERTEX_SHADER:
return bufferVariable.vertexStaticUse;
return bufferVariable.vertexActive;
case GL_REFERENCED_BY_FRAGMENT_SHADER:
return bufferVariable.fragmentStaticUse;
return bufferVariable.fragmentActive;
case GL_REFERENCED_BY_COMPUTE_SHADER:
return bufferVariable.computeStaticUse;
return bufferVariable.computeActive;
case GL_TOP_LEVEL_ARRAY_SIZE:
return bufferVariable.topLevelArraySize;
......
......@@ -1286,7 +1286,7 @@ void DynamicHLSL::getPixelShaderOutputKey(const gl::ContextState &data,
const std::string &elementString =
(outputVariable.isArray() ? Str(outputLocation.arrayIndex) : "");
ASSERT(outputVariable.staticUse);
ASSERT(outputVariable.active);
PixelShaderOutputVariable outputKeyVariable;
outputKeyVariable.type = outputVariable.type;
......
......@@ -221,7 +221,7 @@ void UniformBlockInfo::getShaderBlockInfo(const gl::Context *context, gl::Shader
{
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;
if (mBlockSizes.count(interfaceBlock.name) > 0)
......@@ -234,7 +234,7 @@ void UniformBlockInfo::getShaderBlockInfo(const gl::Context *context, gl::Shader
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
sh::Std140BlockEncoder std140Encoder;
......@@ -1806,14 +1806,14 @@ void ProgramD3D::initializeUniformBlocks()
D3DUniformBlock d3dUniformBlock;
if (uniformBlock.vertexStaticUse)
if (uniformBlock.vertexActive)
{
ASSERT(vertexShaderD3D != nullptr);
unsigned int baseRegister = vertexShaderD3D->getUniformBlockRegister(uniformBlock.name);
d3dUniformBlock.vsRegisterIndex = baseRegister + uniformBlockElement;
}
if (uniformBlock.fragmentStaticUse)
if (uniformBlock.fragmentActive)
{
ASSERT(fragmentShaderD3D != nullptr);
unsigned int baseRegister =
......@@ -1821,7 +1821,7 @@ void ProgramD3D::initializeUniformBlocks()
d3dUniformBlock.psRegisterIndex = baseRegister + uniformBlockElement;
}
if (uniformBlock.computeStaticUse)
if (uniformBlock.computeActive)
{
ASSERT(computeShaderD3D != nullptr);
unsigned int baseRegister =
......@@ -1916,12 +1916,12 @@ void ProgramD3D::updateUniformBufferCache(const gl::Caps &caps,
GLuint blockBinding = mState.getUniformBlockBinding(uniformBlockIndex);
// Unnecessary to apply an unreferenced standard or shared UBO
if (!uniformBlock.vertexStaticUse() && !uniformBlock.fragmentStaticUse())
if (!uniformBlock.vertexActive() && !uniformBlock.fragmentActive())
{
continue;
}
if (uniformBlock.vertexStaticUse())
if (uniformBlock.vertexActive())
{
unsigned int registerIndex = uniformBlock.vsRegisterIndex - reservedVertex;
ASSERT(registerIndex < caps.maxVertexUniformBlocks);
......@@ -1935,7 +1935,7 @@ void ProgramD3D::updateUniformBufferCache(const gl::Caps &caps,
mVertexUBOCache[registerIndex] = blockBinding;
}
if (uniformBlock.fragmentStaticUse())
if (uniformBlock.fragmentActive())
{
unsigned int registerIndex = uniformBlock.psRegisterIndex - reservedFragment;
ASSERT(registerIndex < caps.maxFragmentUniformBlocks);
......@@ -2120,7 +2120,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters(const gl::Context *context)
{
for (const sh::Uniform &computeUniform : computeShader->getUniforms(context))
{
if (computeUniform.staticUse)
if (computeUniform.active)
{
defineUniformBase(computeShader, computeUniform, &uniformMap);
}
......@@ -2131,7 +2131,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters(const gl::Context *context)
gl::Shader *vertexShader = mState.getAttachedVertexShader();
for (const sh::Uniform &vertexUniform : vertexShader->getUniforms(context))
{
if (vertexUniform.staticUse)
if (vertexUniform.active)
{
defineUniformBase(vertexShader, vertexUniform, &uniformMap);
}
......@@ -2140,7 +2140,7 @@ void ProgramD3D::defineUniformsAndAssignRegisters(const gl::Context *context)
gl::Shader *fragmentShader = mState.getAttachedFragmentShader();
for (const sh::Uniform &fragmentUniform : fragmentShader->getUniforms(context))
{
if (fragmentUniform.staticUse)
if (fragmentUniform.active)
{
defineUniformBase(fragmentShader, fragmentUniform, &uniformMap);
}
......
......@@ -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 psRegisterIndex;
......
......@@ -204,7 +204,7 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo
for (const sh::InterfaceBlock &interfaceBlock : mData.getUniformBlocks())
{
if (interfaceBlock.staticUse)
if (interfaceBlock.active)
{
unsigned int index = static_cast<unsigned int>(-1);
bool blockRegisterResult =
......
......@@ -192,7 +192,7 @@ gl::LinkResult ProgramGL::link(const gl::Context *context,
// Bind attribute locations to match the GL layer.
for (const sh::Attribute &attribute : mState.getAttributes())
{
if (!attribute.staticUse || attribute.isBuiltIn())
if (!attribute.active || attribute.isBuiltIn())
{
continue;
}
......
......@@ -138,13 +138,13 @@ gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext,
std::string setBindingString = "set = 1, binding = " + Str(textureCount);
ASSERT(samplerUniform.vertexStaticUse || samplerUniform.fragmentStaticUse);
if (samplerUniform.vertexStaticUse)
ASSERT(samplerUniform.vertexActive || samplerUniform.fragmentActive);
if (samplerUniform.vertexActive)
{
InsertLayoutSpecifierString(&vertexSource, samplerUniform.name, setBindingString);
}
if (samplerUniform.fragmentStaticUse)
if (samplerUniform.fragmentActive)
{
InsertLayoutSpecifierString(&fragmentSource, samplerUniform.name, setBindingString);
}
......
......@@ -457,7 +457,7 @@ void ProgramVk::getUniformImpl(GLint location, T *v, GLenum entryPointType) cons
}
ASSERT(linkedUniform.typeInfo->componentType == entryPointType);
const gl::ShaderType shaderType = linkedUniform.getFirstStaticUseShaderType();
const gl::ShaderType shaderType = linkedUniform.getFirstShaderTypeWhereActive();
ASSERT(shaderType != gl::ShaderType::SHADER_TYPE_INVALID);
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