Commit fc43d273 by Jamie Madill

Remove the sh::InterfaceBlock::dataSize member.

We can replace this by doing the same calculation in the HLSL-side code. BUG=angle:466 Change-Id: Iecae4a92e9037e851419ce73e6267094ee8071a2 Reviewed-on: https://chromium-review.googlesource.com/207251Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent d4116ff3
...@@ -245,6 +245,33 @@ void HLSLBlockEncoder::skipRegisters(unsigned int numRegisters) ...@@ -245,6 +245,33 @@ void HLSLBlockEncoder::skipRegisters(unsigned int numRegisters)
mCurrentOffset += (numRegisters * ComponentsPerRegister); mCurrentOffset += (numRegisters * ComponentsPerRegister);
} }
size_t HLSLInterfaceBlockDataSize(const sh::InterfaceBlock &interfaceBlock)
{
switch (interfaceBlock.layout)
{
case BLOCKLAYOUT_SHARED:
case BLOCKLAYOUT_PACKED:
{
HLSLBlockEncoder hlslEncoder(NULL, HLSLBlockEncoder::ENCODE_PACKED);
hlslEncoder.encodeInterfaceBlockFields(interfaceBlock.fields);
return hlslEncoder.getBlockSize();
}
break;
case BLOCKLAYOUT_STANDARD:
{
Std140BlockEncoder stdEncoder(NULL);
stdEncoder.encodeInterfaceBlockFields(interfaceBlock.fields);
return stdEncoder.getBlockSize();
}
break;
default:
UNREACHABLE();
return 0;
}
}
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, HLSLBlockEncoder *encoder, void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, HLSLBlockEncoder *encoder,
const std::vector<BlockMemberInfo> &blockInfo, ShShaderOutput outputType) const std::vector<BlockMemberInfo> &blockInfo, ShShaderOutput outputType)
{ {
......
...@@ -22,6 +22,7 @@ struct InterfaceBlockField; ...@@ -22,6 +22,7 @@ struct InterfaceBlockField;
struct BlockMemberInfo; struct BlockMemberInfo;
struct Uniform; struct Uniform;
struct Varying; struct Varying;
struct InterfaceBlock;
class BlockLayoutEncoder class BlockLayoutEncoder
{ {
...@@ -95,6 +96,9 @@ class HLSLBlockEncoder : public BlockLayoutEncoder ...@@ -95,6 +96,9 @@ class HLSLBlockEncoder : public BlockLayoutEncoder
HLSLBlockEncoderStrategy mEncoderStrategy; HLSLBlockEncoderStrategy mEncoderStrategy;
}; };
// This method returns the data size of an interface block in HLSL, according to its layout.
size_t HLSLInterfaceBlockDataSize(const sh::InterfaceBlock &interfaceBlock);
// This method assigns values to the variable's "registerIndex" and "elementIndex" fields. // This method assigns values to the variable's "registerIndex" and "elementIndex" fields.
// "elementIndex" is only used for structures. // "elementIndex" is only used for structures.
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, ShShaderOutput outputType); void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, ShShaderOutput outputType);
......
...@@ -162,7 +162,6 @@ struct InterfaceBlock ...@@ -162,7 +162,6 @@ struct InterfaceBlock
{ {
InterfaceBlock() InterfaceBlock()
: arraySize(0), : arraySize(0),
dataSize(0),
layout(BLOCKLAYOUT_PACKED), layout(BLOCKLAYOUT_PACKED),
isRowMajorLayout(false), isRowMajorLayout(false),
staticUse(false) staticUse(false)
...@@ -171,7 +170,6 @@ struct InterfaceBlock ...@@ -171,7 +170,6 @@ struct InterfaceBlock
InterfaceBlock(const char *name, unsigned int arraySize) InterfaceBlock(const char *name, unsigned int arraySize)
: name(name), : name(name),
arraySize(arraySize), arraySize(arraySize),
dataSize(0),
layout(BLOCKLAYOUT_SHARED), layout(BLOCKLAYOUT_SHARED),
isRowMajorLayout(false), isRowMajorLayout(false),
staticUse(false) staticUse(false)
...@@ -180,7 +178,6 @@ struct InterfaceBlock ...@@ -180,7 +178,6 @@ struct InterfaceBlock
std::string name; std::string name;
std::string mappedName; std::string mappedName;
unsigned int arraySize; unsigned int arraySize;
size_t dataSize;
BlockLayoutType layout; BlockLayoutType layout;
bool isRowMajorLayout; bool isRowMajorLayout;
bool staticUse; bool staticUse;
......
...@@ -31,7 +31,6 @@ static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLa ...@@ -31,7 +31,6 @@ static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLa
{ {
HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo, HLSLBlockEncoder::ENCODE_PACKED); HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo, HLSLBlockEncoder::ENCODE_PACKED);
hlslEncoder.encodeInterfaceBlockFields(interfaceBlock->fields); hlslEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
interfaceBlock->dataSize = hlslEncoder.getBlockSize();
} }
break; break;
...@@ -39,7 +38,6 @@ static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLa ...@@ -39,7 +38,6 @@ static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLa
{ {
Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo); Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo);
stdEncoder.encodeInterfaceBlockFields(interfaceBlock->fields); stdEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
interfaceBlock->dataSize = stdEncoder.getBlockSize();
} }
break; break;
......
...@@ -2305,19 +2305,21 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, c ...@@ -2305,19 +2305,21 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, c
BlockInfoItr blockInfoItr = interfaceBlock.blockInfo.cbegin(); BlockInfoItr blockInfoItr = interfaceBlock.blockInfo.cbegin();
defineUniformBlockMembers(interfaceBlock.fields, "", blockIndex, &blockInfoItr, &blockUniformIndexes); defineUniformBlockMembers(interfaceBlock.fields, "", blockIndex, &blockInfoItr, &blockUniformIndexes);
size_t dataSize = sh::HLSLInterfaceBlockDataSize(interfaceBlock);
// create all the uniform blocks // create all the uniform blocks
if (interfaceBlock.arraySize > 0) if (interfaceBlock.arraySize > 0)
{ {
for (unsigned int uniformBlockElement = 0; uniformBlockElement < interfaceBlock.arraySize; uniformBlockElement++) for (unsigned int uniformBlockElement = 0; uniformBlockElement < interfaceBlock.arraySize; uniformBlockElement++)
{ {
UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, uniformBlockElement, interfaceBlock.dataSize); UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, uniformBlockElement, dataSize);
newUniformBlock->memberUniformIndexes = blockUniformIndexes; newUniformBlock->memberUniformIndexes = blockUniformIndexes;
mUniformBlocks.push_back(newUniformBlock); mUniformBlocks.push_back(newUniformBlock);
} }
} }
else else
{ {
UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, GL_INVALID_INDEX, interfaceBlock.dataSize); UniformBlock *newUniformBlock = new UniformBlock(interfaceBlock.name, GL_INVALID_INDEX, dataSize);
newUniformBlock->memberUniformIndexes = blockUniformIndexes; newUniformBlock->memberUniformIndexes = blockUniformIndexes;
mUniformBlocks.push_back(newUniformBlock); mUniformBlocks.push_back(newUniformBlock);
} }
......
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