Commit 2b538b85 by Jamie Madill

Rename some constants in BlockLayoutEncoder for clarity.

TRAC #23748 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens
parent c2141fb3
...@@ -50,7 +50,7 @@ void BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &fi ...@@ -50,7 +50,7 @@ void BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &fi
ASSERT(field.fields.empty()); ASSERT(field.fields.empty());
getBlockLayoutInfo(field.type, field.arraySize, field.isRowMajorMatrix, &arrayStride, &matrixStride); getBlockLayoutInfo(field.type, field.arraySize, field.isRowMajorMatrix, &arrayStride, &matrixStride);
const BlockMemberInfo memberInfo(mCurrentOffset * ComponentSize, arrayStride * ComponentSize, matrixStride * ComponentSize, field.isRowMajorMatrix); const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, field.isRowMajorMatrix);
if (mBlockInfoOut) if (mBlockInfoOut)
{ {
...@@ -67,7 +67,7 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is ...@@ -67,7 +67,7 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is
getBlockLayoutInfo(type, arraySize, isRowMajorMatrix, &arrayStride, &matrixStride); getBlockLayoutInfo(type, arraySize, isRowMajorMatrix, &arrayStride, &matrixStride);
const BlockMemberInfo memberInfo(mCurrentOffset * ComponentSize, arrayStride * ComponentSize, matrixStride * ComponentSize, isRowMajorMatrix); const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, isRowMajorMatrix);
if (mBlockInfoOut) if (mBlockInfoOut)
{ {
...@@ -79,7 +79,7 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is ...@@ -79,7 +79,7 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is
void BlockLayoutEncoder::nextRegister() void BlockLayoutEncoder::nextRegister()
{ {
mCurrentOffset = rx::roundUp(mCurrentOffset, RegisterSize); mCurrentOffset = rx::roundUp(mCurrentOffset, ComponentsPerRegister);
} }
Std140BlockEncoder::Std140BlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut) Std140BlockEncoder::Std140BlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut)
...@@ -100,7 +100,7 @@ void Std140BlockEncoder::exitAggregateType() ...@@ -100,7 +100,7 @@ void Std140BlockEncoder::exitAggregateType()
void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
{ {
// We assume we are only dealing with 4 byte components (no doubles or half-words currently) // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == ComponentSize); ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
int numComponents = gl::UniformComponentCount(type); int numComponents = gl::UniformComponentCount(type);
size_t baseAlignment = 0; size_t baseAlignment = 0;
...@@ -109,19 +109,19 @@ void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, ...@@ -109,19 +109,19 @@ void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize,
if (gl::IsMatrixType(type)) if (gl::IsMatrixType(type))
{ {
baseAlignment = RegisterSize; baseAlignment = ComponentsPerRegister;
matrixStride = RegisterSize; matrixStride = ComponentsPerRegister;
if (arraySize > 0) if (arraySize > 0)
{ {
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix); const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
arrayStride = RegisterSize * numRegisters; arrayStride = ComponentsPerRegister * numRegisters;
} }
} }
else if (arraySize > 0) else if (arraySize > 0)
{ {
baseAlignment = RegisterSize; baseAlignment = ComponentsPerRegister;
arrayStride = RegisterSize; arrayStride = ComponentsPerRegister;
} }
else else
{ {
...@@ -143,9 +143,9 @@ void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool ...@@ -143,9 +143,9 @@ void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool
} }
else if (gl::IsMatrixType(type)) else if (gl::IsMatrixType(type))
{ {
ASSERT(matrixStride == RegisterSize); ASSERT(matrixStride == ComponentsPerRegister);
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix); const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
mCurrentOffset += RegisterSize * numRegisters; mCurrentOffset += ComponentsPerRegister * numRegisters;
} }
else else
{ {
......
...@@ -27,10 +27,10 @@ class BlockLayoutEncoder ...@@ -27,10 +27,10 @@ class BlockLayoutEncoder
void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields); void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields);
void encodeInterfaceBlockField(const InterfaceBlockField &field); void encodeInterfaceBlockField(const InterfaceBlockField &field);
void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix); void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
size_t getBlockSize() { return mCurrentOffset * ComponentSize; } size_t getBlockSize() { return mCurrentOffset * BytesPerComponent; }
static const size_t ComponentSize = 4u; static const size_t BytesPerComponent = 4u;
static const unsigned int RegisterSize = 4u; static const unsigned int ComponentsPerRegister = 4u;
protected: protected:
size_t mCurrentOffset; size_t mCurrentOffset;
......
...@@ -29,7 +29,7 @@ void HLSLBlockEncoder::exitAggregateType() ...@@ -29,7 +29,7 @@ void HLSLBlockEncoder::exitAggregateType()
void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
{ {
// We assume we are only dealing with 4 byte components (no doubles or half-words currently) // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == ComponentSize); ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
int matrixStride = 0; int matrixStride = 0;
int arrayStride = 0; int arrayStride = 0;
...@@ -37,23 +37,23 @@ void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, b ...@@ -37,23 +37,23 @@ void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, b
if (gl::IsMatrixType(type)) if (gl::IsMatrixType(type))
{ {
nextRegister(); nextRegister();
matrixStride = RegisterSize; matrixStride = ComponentsPerRegister;
if (arraySize > 0) if (arraySize > 0)
{ {
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix); const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
arrayStride = RegisterSize * numRegisters; arrayStride = ComponentsPerRegister * numRegisters;
} }
} }
else if (arraySize > 0) else if (arraySize > 0)
{ {
nextRegister(); nextRegister();
arrayStride = RegisterSize; arrayStride = ComponentsPerRegister;
} }
else else
{ {
int numComponents = gl::UniformComponentCount(type); int numComponents = gl::UniformComponentCount(type);
if ((numComponents + (mCurrentOffset % RegisterSize)) > RegisterSize) if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) > ComponentsPerRegister)
{ {
nextRegister(); nextRegister();
} }
...@@ -72,10 +72,10 @@ void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool i ...@@ -72,10 +72,10 @@ void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool i
if (gl::IsMatrixType(type)) if (gl::IsMatrixType(type))
{ {
ASSERT(matrixStride == RegisterSize); ASSERT(matrixStride == ComponentsPerRegister);
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix); const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
const int numComponents = gl::MatrixComponentCount(type, isRowMajorMatrix); const int numComponents = gl::MatrixComponentCount(type, isRowMajorMatrix);
mCurrentOffset += RegisterSize * (numRegisters - 1); mCurrentOffset += ComponentsPerRegister * (numRegisters - 1);
mCurrentOffset += numComponents; mCurrentOffset += numComponents;
} }
else else
......
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