Commit b18c33e9 by Shao Committed by Commit Bot

Remove arraySize in TInterfaceBlock

This patch intends to remove the field 'arraySize' in TInterfaceBlock. The field 'arraySize' in TInterfaceBlock is redundant because: 1. If the interface block has instance name, it is recorded as one symbol as a whole, and its array size is recorded in the TType of the symbol. 2. If the interface block doesn't have instance name, its members are recorded separately, and it cannot be declared as an interface block array. This patch can make the implementation of Geometry Shader easier when we set array size to the built-in interface block 'gl_in' and other user-defined unsized input interface blocks during the compilation of a Geometry Shader. BUG=angleproject:1941 TEST=angle_end2end_test Change-Id: I9a51aab9b8f9ea7e88af157505c092426cee7e6e Reviewed-on: https://chromium-review.googlesource.com/615759 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 41ac68e7
...@@ -3517,7 +3517,7 @@ TIntermDeclaration *TParseContext::addInterfaceBlock( ...@@ -3517,7 +3517,7 @@ TIntermDeclaration *TParseContext::addInterfaceBlock(
} }
TInterfaceBlock *interfaceBlock = TInterfaceBlock *interfaceBlock =
new TInterfaceBlock(&blockName, fieldList, instanceName, arraySize, blockLayoutQualifier); new TInterfaceBlock(&blockName, fieldList, instanceName, blockLayoutQualifier);
TType interfaceBlockType(interfaceBlock, typeQualifier.qualifier, blockLayoutQualifier, TType interfaceBlockType(interfaceBlock, typeQualifier.qualifier, blockLayoutQualifier,
arraySize); arraySize);
......
...@@ -149,11 +149,9 @@ class TInterfaceBlock : public TFieldListCollection ...@@ -149,11 +149,9 @@ class TInterfaceBlock : public TFieldListCollection
TInterfaceBlock(const TString *name, TInterfaceBlock(const TString *name,
TFieldList *fields, TFieldList *fields,
const TString *instanceName, const TString *instanceName,
int arraySize,
const TLayoutQualifier &layoutQualifier) const TLayoutQualifier &layoutQualifier)
: TFieldListCollection(name, fields), : TFieldListCollection(name, fields),
mInstanceName(instanceName), mInstanceName(instanceName),
mArraySize(arraySize),
mBlockStorage(layoutQualifier.blockStorage), mBlockStorage(layoutQualifier.blockStorage),
mMatrixPacking(layoutQualifier.matrixPacking), mMatrixPacking(layoutQualifier.matrixPacking),
mBinding(layoutQualifier.binding) mBinding(layoutQualifier.binding)
...@@ -162,8 +160,6 @@ class TInterfaceBlock : public TFieldListCollection ...@@ -162,8 +160,6 @@ class TInterfaceBlock : public TFieldListCollection
const TString &instanceName() const { return *mInstanceName; } const TString &instanceName() const { return *mInstanceName; }
bool hasInstanceName() const { return mInstanceName != nullptr; } bool hasInstanceName() const { return mInstanceName != nullptr; }
bool isArray() const { return mArraySize > 0; }
int arraySize() const { return mArraySize; }
TLayoutBlockStorage blockStorage() const { return mBlockStorage; } TLayoutBlockStorage blockStorage() const { return mBlockStorage; }
TLayoutMatrixPacking matrixPacking() const { return mMatrixPacking; } TLayoutMatrixPacking matrixPacking() const { return mMatrixPacking; }
int blockBinding() const { return mBinding; } int blockBinding() const { return mBinding; }
...@@ -176,7 +172,6 @@ class TInterfaceBlock : public TFieldListCollection ...@@ -176,7 +172,6 @@ class TInterfaceBlock : public TFieldListCollection
private: private:
const TString *mInstanceName; // for interface block instance names const TString *mInstanceName; // for interface block instance names
int mArraySize; // 0 if not an array
TLayoutBlockStorage mBlockStorage; TLayoutBlockStorage mBlockStorage;
TLayoutMatrixPacking mMatrixPacking; TLayoutMatrixPacking mMatrixPacking;
int mBinding; int mBinding;
...@@ -495,7 +490,10 @@ class TType ...@@ -495,7 +490,10 @@ class TType
bool array; bool array;
unsigned int arraySize; unsigned int arraySize;
// 0 unless this is an interface block, or interface block member variable // This is set only in the following two cases:
// 1) Represents an interface block.
// 2) Represents the member variable of an unnamed interface block.
// It's nullptr also for members of named interface blocks.
TInterfaceBlock *interfaceBlock; TInterfaceBlock *interfaceBlock;
// 0 unless this is a struct // 0 unless this is a struct
......
...@@ -363,11 +363,14 @@ TString UniformHLSL::uniformBlocksHeader(const ReferencedSymbols &referencedInte ...@@ -363,11 +363,14 @@ TString UniformHLSL::uniformBlocksHeader(const ReferencedSymbols &referencedInte
const TType &nodeType = interfaceBlockIt->second->getType(); const TType &nodeType = interfaceBlockIt->second->getType();
const TInterfaceBlock &interfaceBlock = *nodeType.getInterfaceBlock(); const TInterfaceBlock &interfaceBlock = *nodeType.getInterfaceBlock();
unsigned int arraySize = static_cast<unsigned int>(interfaceBlock.arraySize()); // nodeType.isInterfaceBlock() == false means the node is a field of a uniform block which
// doesn't have instance name, so this block cannot be an array.
unsigned int interfaceBlockArraySize =
nodeType.isInterfaceBlock() ? nodeType.getArraySize() : 0;
unsigned int activeRegister = mUniformBlockRegister; unsigned int activeRegister = mUniformBlockRegister;
mUniformBlockRegisterMap[interfaceBlock.name().c_str()] = activeRegister; mUniformBlockRegisterMap[interfaceBlock.name().c_str()] = activeRegister;
mUniformBlockRegister += std::max(1u, arraySize); mUniformBlockRegister += std::max(1u, interfaceBlockArraySize);
// FIXME: interface block field names // FIXME: interface block field names
...@@ -376,9 +379,9 @@ TString UniformHLSL::uniformBlocksHeader(const ReferencedSymbols &referencedInte ...@@ -376,9 +379,9 @@ TString UniformHLSL::uniformBlocksHeader(const ReferencedSymbols &referencedInte
interfaceBlocks += uniformBlockStructString(interfaceBlock); interfaceBlocks += uniformBlockStructString(interfaceBlock);
} }
if (arraySize > 0) if (interfaceBlockArraySize > 0)
{ {
for (unsigned int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) for (unsigned int arrayIndex = 0; arrayIndex < interfaceBlockArraySize; arrayIndex++)
{ {
interfaceBlocks += interfaceBlocks +=
uniformBlockString(interfaceBlock, activeRegister + arrayIndex, arrayIndex); uniformBlockString(interfaceBlock, activeRegister + arrayIndex, arrayIndex);
...@@ -429,7 +432,7 @@ TString UniformHLSL::uniformBlockInstanceString(const TInterfaceBlock &interface ...@@ -429,7 +432,7 @@ TString UniformHLSL::uniformBlockInstanceString(const TInterfaceBlock &interface
{ {
return ""; return "";
} }
else if (interfaceBlock.isArray()) else if (arrayIndex != GL_INVALID_INDEX)
{ {
return DecoratePrivate(interfaceBlock.instanceName()) + "_" + str(arrayIndex); return DecoratePrivate(interfaceBlock.instanceName()) + "_" + str(arrayIndex);
} }
......
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