Commit 04ea03e4 by Jamie Madill Committed by Commit Bot

Make default block member info a constant.

Instead of generating a struct each time we can use a constexpr constructor to use a single representation. Bug: angleproject:3024 Change-Id: I14dec65a4f6ac9ab2f7e7af444862e4ceab88d8c Reviewed-on: https://chromium-review.googlesource.com/c/1392395Reviewed-by: 's avatarJiajia Qin <jiajia.qin@intel.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 76f66954
......@@ -27,27 +27,20 @@ struct InterfaceBlock;
struct BlockMemberInfo
{
BlockMemberInfo()
: offset(-1),
arrayStride(-1),
matrixStride(-1),
isRowMajorMatrix(false),
topLevelArrayStride(-1)
{}
constexpr BlockMemberInfo() = default;
BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix)
constexpr BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix)
: offset(offset),
arrayStride(arrayStride),
matrixStride(matrixStride),
isRowMajorMatrix(isRowMajorMatrix),
topLevelArrayStride(-1)
isRowMajorMatrix(isRowMajorMatrix)
{}
BlockMemberInfo(int offset,
int arrayStride,
int matrixStride,
bool isRowMajorMatrix,
int topLevelArrayStride)
constexpr BlockMemberInfo(int offset,
int arrayStride,
int matrixStride,
bool isRowMajorMatrix,
int topLevelArrayStride)
: offset(offset),
arrayStride(arrayStride),
matrixStride(matrixStride),
......@@ -55,15 +48,26 @@ struct BlockMemberInfo
topLevelArrayStride(topLevelArrayStride)
{}
static BlockMemberInfo getDefaultBlockInfo() { return BlockMemberInfo(-1, -1, -1, false, -1); }
// A single integer identifying the offset of an active variable.
int offset = -1;
// A single integer identifying the stride between array elements in an active variable.
int arrayStride = -1;
int offset;
int arrayStride;
int matrixStride;
bool isRowMajorMatrix;
int topLevelArrayStride; // Only used for shader storage block members.
// A single integer identifying the stride between columns of a column-major matrix or rows of a
// row-major matrix.
int matrixStride = -1;
// A single integer identifying whether an active variable is a row-major matrix.
bool isRowMajorMatrix = false;
// A single integer identifying the number of active array elements of the top-level shader
// storage block member containing the active variable.
int topLevelArrayStride = -1;
};
constexpr BlockMemberInfo kDefaultBlockMemberInfo;
class BlockLayoutEncoder
{
public:
......
......@@ -523,7 +523,7 @@ class FlattenUniformVisitor : public sh::VariableNameVisitor
{
LinkedUniform linkedUniform(variable.type, variable.precision, fullNameWithArrayIndex,
variable.arraySizes, getBinding(), getOffset(), mLocation,
-1, sh::BlockMemberInfo::getDefaultBlockInfo());
-1, sh::kDefaultBlockMemberInfo);
linkedUniform.mappedName = fullMappedNameWithArrayIndex;
linkedUniform.active = mMarkActive;
linkedUniform.staticUse = mMarkStaticUse;
......
......@@ -48,7 +48,7 @@ GLuint ActiveVariable::activeShaderCount() const
}
LinkedUniform::LinkedUniform()
: typeInfo(nullptr), bufferIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo())
: typeInfo(nullptr), bufferIndex(-1), blockInfo(sh::kDefaultBlockMemberInfo)
{}
LinkedUniform::LinkedUniform(GLenum typeIn,
......@@ -77,7 +77,7 @@ LinkedUniform::LinkedUniform(const sh::Uniform &uniform)
: sh::Uniform(uniform),
typeInfo(&GetUniformTypeInfo(type)),
bufferIndex(-1),
blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo())
blockInfo(sh::kDefaultBlockMemberInfo)
{
ASSERT(!isArrayOfArrays());
ASSERT(!isArray() || !isStruct());
......@@ -139,7 +139,7 @@ size_t LinkedUniform::getElementComponents() const
}
BufferVariable::BufferVariable()
: bufferIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo()), topLevelArraySize(-1)
: bufferIndex(-1), blockInfo(sh::kDefaultBlockMemberInfo), topLevelArraySize(-1)
{}
BufferVariable::BufferVariable(GLenum typeIn,
......
......@@ -238,7 +238,7 @@ bool InterfaceBlockInfo::getBlockMemberInfo(const std::string &name,
auto infoIter = mBlockLayout.find(name);
if (infoIter == mBlockLayout.end())
{
*infoOut = sh::BlockMemberInfo::getDefaultBlockInfo();
*infoOut = sh::kDefaultBlockMemberInfo;
return false;
}
......
......@@ -715,7 +715,7 @@ bool ProgramGL::getUniformBlockMemberInfo(const std::string & /* memberUniformNa
if (uniformIndex == GL_INVALID_INDEX)
{
*memberInfoOut = sh::BlockMemberInfo::getDefaultBlockInfo();
*memberInfoOut = sh::kDefaultBlockMemberInfo;
return false;
}
......@@ -744,7 +744,7 @@ bool ProgramGL::getShaderStorageBlockMemberInfo(const std::string & /* memberNam
if (index == GL_INVALID_INDEX)
{
*memberInfoOut = sh::BlockMemberInfo::getDefaultBlockInfo();
*memberInfoOut = sh::kDefaultBlockMemberInfo;
return false;
}
......
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