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)
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,
const std::vector<BlockMemberInfo> &blockInfo, ShShaderOutput outputType)
{
......
......@@ -22,6 +22,7 @@ struct InterfaceBlockField;
struct BlockMemberInfo;
struct Uniform;
struct Varying;
struct InterfaceBlock;
class BlockLayoutEncoder
{
......@@ -95,6 +96,9 @@ class HLSLBlockEncoder : public BlockLayoutEncoder
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.
// "elementIndex" is only used for structures.
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, ShShaderOutput outputType);
......
......@@ -162,7 +162,6 @@ struct InterfaceBlock
{
InterfaceBlock()
: arraySize(0),
dataSize(0),
layout(BLOCKLAYOUT_PACKED),
isRowMajorLayout(false),
staticUse(false)
......@@ -171,7 +170,6 @@ struct InterfaceBlock
InterfaceBlock(const char *name, unsigned int arraySize)
: name(name),
arraySize(arraySize),
dataSize(0),
layout(BLOCKLAYOUT_SHARED),
isRowMajorLayout(false),
staticUse(false)
......@@ -180,7 +178,6 @@ struct InterfaceBlock
std::string name;
std::string mappedName;
unsigned int arraySize;
size_t dataSize;
BlockLayoutType layout;
bool isRowMajorLayout;
bool staticUse;
......
......@@ -31,7 +31,6 @@ static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLa
{
HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo, HLSLBlockEncoder::ENCODE_PACKED);
hlslEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
interfaceBlock->dataSize = hlslEncoder.getBlockSize();
}
break;
......@@ -39,7 +38,6 @@ static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLa
{
Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo);
stdEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
interfaceBlock->dataSize = stdEncoder.getBlockSize();
}
break;
......
......@@ -2305,19 +2305,21 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, c
BlockInfoItr blockInfoItr = interfaceBlock.blockInfo.cbegin();
defineUniformBlockMembers(interfaceBlock.fields, "", blockIndex, &blockInfoItr, &blockUniformIndexes);
size_t dataSize = sh::HLSLInterfaceBlockDataSize(interfaceBlock);
// create all the uniform blocks
if (interfaceBlock.arraySize > 0)
{
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;
mUniformBlocks.push_back(newUniformBlock);
}
}
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;
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