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
ASSERT(field.fields.empty());
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)
{
......@@ -67,7 +67,7 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is
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)
{
......@@ -79,7 +79,7 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is
void BlockLayoutEncoder::nextRegister()
{
mCurrentOffset = rx::roundUp(mCurrentOffset, RegisterSize);
mCurrentOffset = rx::roundUp(mCurrentOffset, ComponentsPerRegister);
}
Std140BlockEncoder::Std140BlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut)
......@@ -100,7 +100,7 @@ void Std140BlockEncoder::exitAggregateType()
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)
ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == ComponentSize);
ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
int numComponents = gl::UniformComponentCount(type);
size_t baseAlignment = 0;
......@@ -109,19 +109,19 @@ void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize,
if (gl::IsMatrixType(type))
{
baseAlignment = RegisterSize;
matrixStride = RegisterSize;
baseAlignment = ComponentsPerRegister;
matrixStride = ComponentsPerRegister;
if (arraySize > 0)
{
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
arrayStride = RegisterSize * numRegisters;
arrayStride = ComponentsPerRegister * numRegisters;
}
}
else if (arraySize > 0)
{
baseAlignment = RegisterSize;
arrayStride = RegisterSize;
baseAlignment = ComponentsPerRegister;
arrayStride = ComponentsPerRegister;
}
else
{
......@@ -143,9 +143,9 @@ void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool
}
else if (gl::IsMatrixType(type))
{
ASSERT(matrixStride == RegisterSize);
ASSERT(matrixStride == ComponentsPerRegister);
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
mCurrentOffset += RegisterSize * numRegisters;
mCurrentOffset += ComponentsPerRegister * numRegisters;
}
else
{
......
......@@ -27,10 +27,10 @@ class BlockLayoutEncoder
void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields);
void encodeInterfaceBlockField(const InterfaceBlockField &field);
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 unsigned int RegisterSize = 4u;
static const size_t BytesPerComponent = 4u;
static const unsigned int ComponentsPerRegister = 4u;
protected:
size_t mCurrentOffset;
......
......@@ -29,7 +29,7 @@ void HLSLBlockEncoder::exitAggregateType()
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)
ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == ComponentSize);
ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
int matrixStride = 0;
int arrayStride = 0;
......@@ -37,23 +37,23 @@ void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, b
if (gl::IsMatrixType(type))
{
nextRegister();
matrixStride = RegisterSize;
matrixStride = ComponentsPerRegister;
if (arraySize > 0)
{
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
arrayStride = RegisterSize * numRegisters;
arrayStride = ComponentsPerRegister * numRegisters;
}
}
else if (arraySize > 0)
{
nextRegister();
arrayStride = RegisterSize;
arrayStride = ComponentsPerRegister;
}
else
{
int numComponents = gl::UniformComponentCount(type);
if ((numComponents + (mCurrentOffset % RegisterSize)) > RegisterSize)
if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) > ComponentsPerRegister)
{
nextRegister();
}
......@@ -72,10 +72,10 @@ void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool i
if (gl::IsMatrixType(type))
{
ASSERT(matrixStride == RegisterSize);
ASSERT(matrixStride == ComponentsPerRegister);
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
const int numComponents = gl::MatrixComponentCount(type, isRowMajorMatrix);
mCurrentOffset += RegisterSize * (numRegisters - 1);
mCurrentOffset += ComponentsPerRegister * (numRegisters - 1);
mCurrentOffset += numComponents;
}
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