Commit 9c500951 by Shahbaz Youssefi Committed by Angle LUCI CQ

Vulkan: SPIR-V Gen: Fix user-defined blocks

The _u prefix was missing from blocks and their fields. Bug: angleproject:4889 Change-Id: I31f3b393bc81352c8cf7a433dd652692833fc3f7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2953368 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 5a737833
...@@ -119,25 +119,25 @@ const SpirvTypeData &SPIRVBuilder::getTypeData(const TType &type, TLayoutBlockSt ...@@ -119,25 +119,25 @@ const SpirvTypeData &SPIRVBuilder::getTypeData(const TType &type, TLayoutBlockSt
{ {
SpirvType spirvType = getSpirvType(type, blockStorage); SpirvType spirvType = getSpirvType(type, blockStorage);
const char *blockName = ""; const TSymbol *block = nullptr;
if (type.getStruct() != nullptr) if (type.getStruct() != nullptr)
{ {
blockName = type.getStruct()->name().data(); block = type.getStruct();
} }
else if (type.isInterfaceBlock()) else if (type.isInterfaceBlock())
{ {
blockName = type.getInterfaceBlock()->name().data(); block = type.getInterfaceBlock();
} }
return getSpirvTypeData(spirvType, blockName); return getSpirvTypeData(spirvType, block);
} }
const SpirvTypeData &SPIRVBuilder::getSpirvTypeData(const SpirvType &type, const char *blockName) const SpirvTypeData &SPIRVBuilder::getSpirvTypeData(const SpirvType &type, const TSymbol *block)
{ {
auto iter = mTypeMap.find(type); auto iter = mTypeMap.find(type);
if (iter == mTypeMap.end()) if (iter == mTypeMap.end())
{ {
SpirvTypeData newTypeData = declareType(type, blockName); SpirvTypeData newTypeData = declareType(type, block);
iter = mTypeMap.insert({type, newTypeData}).first; iter = mTypeMap.insert({type, newTypeData}).first;
} }
...@@ -209,7 +209,7 @@ spirv::IdRef SPIRVBuilder::getExtInstImportIdStd() ...@@ -209,7 +209,7 @@ spirv::IdRef SPIRVBuilder::getExtInstImportIdStd()
return mExtInstImportIdStd; return mExtInstImportIdStd;
} }
SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *blockName) SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const TSymbol *block)
{ {
// Recursively declare the type. Type id is allocated afterwards purely for better id order in // Recursively declare the type. Type id is allocated afterwards purely for better id order in
// output. // output.
...@@ -227,7 +227,7 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block ...@@ -227,7 +227,7 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block
subType.blockStorage = EbsUnspecified; subType.blockStorage = EbsUnspecified;
} }
const spirv::IdRef subTypeId = getSpirvTypeData(subType, blockName).id; const spirv::IdRef subTypeId = getSpirvTypeData(subType, block).id;
const unsigned int length = type.arraySizes.back(); const unsigned int length = type.arraySizes.back();
typeId = getNewId({}); typeId = getNewId({});
...@@ -254,15 +254,14 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block ...@@ -254,15 +254,14 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block
{ {
const TType &fieldType = *field->type(); const TType &fieldType = *field->type();
SpirvType fieldSpirvType = getSpirvType(fieldType, type.blockStorage); SpirvType fieldSpirvType = getSpirvType(fieldType, type.blockStorage);
const char *structName = ""; const TSymbol *structure = fieldType.getStruct();
// Propagate invariant to struct members. // Propagate invariant to struct members.
if (fieldType.getStruct() != nullptr) if (structure != nullptr)
{ {
fieldSpirvType.isInvariant = type.isInvariant; fieldSpirvType.isInvariant = type.isInvariant;
structName = fieldType.getStruct()->name().data();
} }
spirv::IdRef fieldTypeId = getSpirvTypeData(fieldSpirvType, structName).id; spirv::IdRef fieldTypeId = getSpirvTypeData(fieldSpirvType, structure).id;
fieldTypeIds.push_back(fieldTypeId); fieldTypeIds.push_back(fieldTypeId);
} }
...@@ -278,7 +277,7 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block ...@@ -278,7 +277,7 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block
imageType.isSamplerBaseImage = true; imageType.isSamplerBaseImage = true;
imageType.blockStorage = EbsUnspecified; imageType.blockStorage = EbsUnspecified;
const spirv::IdRef nonSampledId = getSpirvTypeData(imageType, "").id; const spirv::IdRef nonSampledId = getSpirvTypeData(imageType, nullptr).id;
typeId = getNewId({}); typeId = getNewId({});
spirv::WriteTypeSampledImage(&mSpirvTypeAndConstantDecls, typeId, nonSampledId); spirv::WriteTypeSampledImage(&mSpirvTypeAndConstantDecls, typeId, nonSampledId);
...@@ -315,7 +314,7 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block ...@@ -315,7 +314,7 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block
columnType.secondarySize = 1; columnType.secondarySize = 1;
columnType.blockStorage = EbsUnspecified; columnType.blockStorage = EbsUnspecified;
const spirv::IdRef columnTypeId = getSpirvTypeData(columnType, "").id; const spirv::IdRef columnTypeId = getSpirvTypeData(columnType, nullptr).id;
typeId = getNewId({}); typeId = getNewId({});
spirv::WriteTypeMatrix(&mSpirvTypeAndConstantDecls, typeId, columnTypeId, spirv::WriteTypeMatrix(&mSpirvTypeAndConstantDecls, typeId, columnTypeId,
...@@ -329,7 +328,7 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block ...@@ -329,7 +328,7 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block
componentType.primarySize = 1; componentType.primarySize = 1;
componentType.blockStorage = EbsUnspecified; componentType.blockStorage = EbsUnspecified;
const spirv::IdRef componentTypeId = getSpirvTypeData(componentType, "").id; const spirv::IdRef componentTypeId = getSpirvTypeData(componentType, nullptr).id;
typeId = getNewId({}); typeId = getNewId({});
spirv::WriteTypeVector(&mSpirvTypeAndConstantDecls, typeId, componentTypeId, spirv::WriteTypeVector(&mSpirvTypeAndConstantDecls, typeId, componentTypeId,
...@@ -377,13 +376,13 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block ...@@ -377,13 +376,13 @@ SpirvTypeData SPIRVBuilder::declareType(const SpirvType &type, const char *block
// binary size that gets written to disk cache. http://anglebug.com/4889 // binary size that gets written to disk cache. http://anglebug.com/4889
if (type.block != nullptr && type.arraySizes.empty()) if (type.block != nullptr && type.arraySizes.empty())
{ {
spirv::WriteName(&mSpirvDebug, typeId, blockName); spirv::WriteName(&mSpirvDebug, typeId, hashName(block).data());
uint32_t fieldIndex = 0; uint32_t fieldIndex = 0;
for (const TField *field : type.block->fields()) for (const TField *field : type.block->fields())
{ {
spirv::WriteMemberName(&mSpirvDebug, typeId, spirv::LiteralInteger(fieldIndex++), spirv::WriteMemberName(&mSpirvDebug, typeId, spirv::LiteralInteger(fieldIndex++),
field->name().data()); hashFieldName(field).data());
} }
} }
...@@ -665,7 +664,7 @@ void SPIRVBuilder::getImageTypeParameters(TBasicType type, ...@@ -665,7 +664,7 @@ void SPIRVBuilder::getImageTypeParameters(TBasicType type,
SpirvType sampledSpirvType; SpirvType sampledSpirvType;
sampledSpirvType.type = sampledType; sampledSpirvType.type = sampledType;
*sampledTypeOut = getSpirvTypeData(sampledSpirvType, "").id; *sampledTypeOut = getSpirvTypeData(sampledSpirvType, nullptr).id;
const bool isSampledImage = IsSampler(type); const bool isSampledImage = IsSampler(type);
...@@ -776,7 +775,7 @@ spirv::IdRef SPIRVBuilder::getBoolConstant(bool value) ...@@ -776,7 +775,7 @@ spirv::IdRef SPIRVBuilder::getBoolConstant(bool value)
SpirvType boolType; SpirvType boolType;
boolType.type = EbtBool; boolType.type = EbtBool;
const spirv::IdRef boolTypeId = getSpirvTypeData(boolType, "").id; const spirv::IdRef boolTypeId = getSpirvTypeData(boolType, nullptr).id;
mBoolConstants[asInt] = constantId = getNewId({}); mBoolConstants[asInt] = constantId = getNewId({});
if (value) if (value)
...@@ -802,7 +801,7 @@ spirv::IdRef SPIRVBuilder::getBasicConstantHelper(uint32_t value, ...@@ -802,7 +801,7 @@ spirv::IdRef SPIRVBuilder::getBasicConstantHelper(uint32_t value,
SpirvType spirvType; SpirvType spirvType;
spirvType.type = type; spirvType.type = type;
const spirv::IdRef typeId = getSpirvTypeData(spirvType, "").id; const spirv::IdRef typeId = getSpirvTypeData(spirvType, nullptr).id;
const spirv::IdRef constantId = getNewId({}); const spirv::IdRef constantId = getNewId({});
spirv::WriteConstant(&mSpirvTypeAndConstantDecls, typeId, constantId, spirv::WriteConstant(&mSpirvTypeAndConstantDecls, typeId, constantId,
...@@ -853,7 +852,7 @@ spirv::IdRef SPIRVBuilder::getCompositeConstant(spirv::IdRef typeId, const spirv ...@@ -853,7 +852,7 @@ spirv::IdRef SPIRVBuilder::getCompositeConstant(spirv::IdRef typeId, const spirv
return iter->second; return iter->second;
} }
void SPIRVBuilder::startNewFunction(spirv::IdRef functionId, const char *name) void SPIRVBuilder::startNewFunction(spirv::IdRef functionId, const TFunction *func)
{ {
ASSERT(mSpirvCurrentFunctionBlocks.empty()); ASSERT(mSpirvCurrentFunctionBlocks.empty());
...@@ -862,10 +861,7 @@ void SPIRVBuilder::startNewFunction(spirv::IdRef functionId, const char *name) ...@@ -862,10 +861,7 @@ void SPIRVBuilder::startNewFunction(spirv::IdRef functionId, const char *name)
mSpirvCurrentFunctionBlocks.back().labelId = getNewId({}); mSpirvCurrentFunctionBlocks.back().labelId = getNewId({});
// Output debug information. // Output debug information.
if (name) spirv::WriteName(&mSpirvDebug, functionId, hashFunctionName(func).data());
{
spirv::WriteName(&mSpirvDebug, functionId, name);
}
} }
void SPIRVBuilder::assembleSpirvFunctionBlocks() void SPIRVBuilder::assembleSpirvFunctionBlocks()
...@@ -929,7 +925,7 @@ spirv::IdRef SPIRVBuilder::declareSpecConst(TBasicType type, int id, const char ...@@ -929,7 +925,7 @@ spirv::IdRef SPIRVBuilder::declareSpecConst(TBasicType type, int id, const char
SpirvType spirvType; SpirvType spirvType;
spirvType.type = type; spirvType.type = type;
const spirv::IdRef typeId = getSpirvTypeData(spirvType, "").id; const spirv::IdRef typeId = getSpirvTypeData(spirvType, nullptr).id;
// Note: all spec constants are 0 initialized by the translator. // Note: all spec constants are 0 initialized by the translator.
if (type == EbtBool) if (type == EbtBool)
...@@ -1181,7 +1177,7 @@ const SpirvTypeData &SPIRVBuilder::getFieldTypeDataForAlignmentAndSize( ...@@ -1181,7 +1177,7 @@ const SpirvTypeData &SPIRVBuilder::getFieldTypeDataForAlignmentAndSize(
std::swap(fieldSpirvType.primarySize, fieldSpirvType.secondarySize); std::swap(fieldSpirvType.primarySize, fieldSpirvType.secondarySize);
} }
return getSpirvTypeData(fieldSpirvType, ""); return getSpirvTypeData(fieldSpirvType, nullptr);
} }
uint32_t SPIRVBuilder::calculateBaseAlignmentAndSize(const SpirvType &type, uint32_t SPIRVBuilder::calculateBaseAlignmentAndSize(const SpirvType &type,
...@@ -1206,7 +1202,7 @@ uint32_t SPIRVBuilder::calculateBaseAlignmentAndSize(const SpirvType &type, ...@@ -1206,7 +1202,7 @@ uint32_t SPIRVBuilder::calculateBaseAlignmentAndSize(const SpirvType &type,
baseType.blockStorage = EbsUnspecified; baseType.blockStorage = EbsUnspecified;
} }
const SpirvTypeData &baseTypeData = getSpirvTypeData(baseType, ""); const SpirvTypeData &baseTypeData = getSpirvTypeData(baseType, nullptr);
uint32_t baseAlignment = baseTypeData.baseAlignment; uint32_t baseAlignment = baseTypeData.baseAlignment;
// For std140 only: // For std140 only:
...@@ -1282,7 +1278,7 @@ uint32_t SPIRVBuilder::calculateBaseAlignmentAndSize(const SpirvType &type, ...@@ -1282,7 +1278,7 @@ uint32_t SPIRVBuilder::calculateBaseAlignmentAndSize(const SpirvType &type,
vectorType.primarySize = vectorType.secondarySize; vectorType.primarySize = vectorType.secondarySize;
vectorType.secondarySize = 1; vectorType.secondarySize = 1;
const SpirvTypeData &vectorTypeData = getSpirvTypeData(vectorType, ""); const SpirvTypeData &vectorTypeData = getSpirvTypeData(vectorType, nullptr);
uint32_t baseAlignment = vectorTypeData.baseAlignment; uint32_t baseAlignment = vectorTypeData.baseAlignment;
// For std140 only: // For std140 only:
...@@ -1310,7 +1306,7 @@ uint32_t SPIRVBuilder::calculateBaseAlignmentAndSize(const SpirvType &type, ...@@ -1310,7 +1306,7 @@ uint32_t SPIRVBuilder::calculateBaseAlignmentAndSize(const SpirvType &type,
SpirvType baseType = type; SpirvType baseType = type;
baseType.primarySize = 1; baseType.primarySize = 1;
const SpirvTypeData &baseTypeData = getSpirvTypeData(baseType, ""); const SpirvTypeData &baseTypeData = getSpirvTypeData(baseType, nullptr);
uint32_t baseAlignment = baseTypeData.baseAlignment; uint32_t baseAlignment = baseTypeData.baseAlignment;
uint32_t multiplier = type.primarySize != 3 ? type.primarySize : 4; uint32_t multiplier = type.primarySize != 3 ? type.primarySize : 4;
......
...@@ -252,7 +252,7 @@ class SPIRVBuilder : angle::NonCopyable ...@@ -252,7 +252,7 @@ class SPIRVBuilder : angle::NonCopyable
TLayoutBlockStorage getBlockStorage(const TType &type) const; TLayoutBlockStorage getBlockStorage(const TType &type) const;
SpirvType getSpirvType(const TType &type, TLayoutBlockStorage blockStorage) const; SpirvType getSpirvType(const TType &type, TLayoutBlockStorage blockStorage) const;
const SpirvTypeData &getTypeData(const TType &type, TLayoutBlockStorage blockStorage); const SpirvTypeData &getTypeData(const TType &type, TLayoutBlockStorage blockStorage);
const SpirvTypeData &getSpirvTypeData(const SpirvType &type, const char *blockName); const SpirvTypeData &getSpirvTypeData(const SpirvType &type, const TSymbol *block);
spirv::IdRef getTypePointerId(spirv::IdRef typeId, spv::StorageClass storageClass); spirv::IdRef getTypePointerId(spirv::IdRef typeId, spv::StorageClass storageClass);
spirv::IdRef getFunctionTypeId(spirv::IdRef returnTypeId, const spirv::IdRefList &paramTypeIds); spirv::IdRef getFunctionTypeId(spirv::IdRef returnTypeId, const spirv::IdRefList &paramTypeIds);
...@@ -313,7 +313,7 @@ class SPIRVBuilder : angle::NonCopyable ...@@ -313,7 +313,7 @@ class SPIRVBuilder : angle::NonCopyable
spirv::IdRef getCompositeConstant(spirv::IdRef typeId, const spirv::IdRefList &values); spirv::IdRef getCompositeConstant(spirv::IdRef typeId, const spirv::IdRefList &values);
// Helpers to start and end a function. // Helpers to start and end a function.
void startNewFunction(spirv::IdRef functionId, const char *name); void startNewFunction(spirv::IdRef functionId, const TFunction *func);
void assembleSpirvFunctionBlocks(); void assembleSpirvFunctionBlocks();
// Helper to declare a variable. Function-local variables must be placed in the first block of // Helper to declare a variable. Function-local variables must be placed in the first block of
...@@ -344,7 +344,7 @@ class SPIRVBuilder : angle::NonCopyable ...@@ -344,7 +344,7 @@ class SPIRVBuilder : angle::NonCopyable
spirv::Blob getSpirv(); spirv::Blob getSpirv();
private: private:
SpirvTypeData declareType(const SpirvType &type, const char *blockName); SpirvTypeData declareType(const SpirvType &type, const TSymbol *block);
const SpirvTypeData &getFieldTypeDataForAlignmentAndSize(const TType &type, const SpirvTypeData &getFieldTypeDataForAlignmentAndSize(const TType &type,
TLayoutBlockStorage blockStorage); TLayoutBlockStorage blockStorage);
......
...@@ -405,7 +405,7 @@ spirv::IdRef OutputSPIRVTraverser::getSymbolIdAndStorageClass(const TSymbol *sym ...@@ -405,7 +405,7 @@ spirv::IdRef OutputSPIRVTraverser::getSymbolIdAndStorageClass(const TSymbol *sym
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
const spirv::IdRef typeId = mBuilder.getSpirvTypeData(spirvType, "").id; const spirv::IdRef typeId = mBuilder.getSpirvTypeData(spirvType, nullptr).id;
const spirv::IdRef varId = mBuilder.declareVariable( const spirv::IdRef varId = mBuilder.declareVariable(
typeId, *storageClass, mBuilder.getDecorations(type), nullptr, name); typeId, *storageClass, mBuilder.getDecorations(type), nullptr, name);
...@@ -524,10 +524,10 @@ void OutputSPIRVTraverser::accessChainPushDynamicComponent(NodeData *data, ...@@ -524,10 +524,10 @@ void OutputSPIRVTraverser::accessChainPushDynamicComponent(NodeData *data,
SpirvType type; SpirvType type;
type.type = EbtUInt; type.type = EbtUInt;
const spirv::IdRef uintTypeId = mBuilder.getSpirvTypeData(type, "").id; const spirv::IdRef uintTypeId = mBuilder.getSpirvTypeData(type, nullptr).id;
type.primarySize = static_cast<uint8_t>(swizzleIds.size()); type.primarySize = static_cast<uint8_t>(swizzleIds.size());
const spirv::IdRef uvecTypeId = mBuilder.getSpirvTypeData(type, "").id; const spirv::IdRef uvecTypeId = mBuilder.getSpirvTypeData(type, nullptr).id;
const spirv::IdRef swizzlesId = mBuilder.getNewId({}); const spirv::IdRef swizzlesId = mBuilder.getNewId({});
spirv::WriteConstantComposite(mBuilder.getSpirvTypeAndConstantDecls(), uvecTypeId, spirv::WriteConstantComposite(mBuilder.getSpirvTypeAndConstantDecls(), uvecTypeId,
...@@ -1070,7 +1070,7 @@ spirv::IdRef OutputSPIRVTraverser::createConstructorMatrixFromScalar( ...@@ -1070,7 +1070,7 @@ spirv::IdRef OutputSPIRVTraverser::createConstructorMatrixFromScalar(
SpirvType columnType = mBuilder.getSpirvType(type, EbsUnspecified); SpirvType columnType = mBuilder.getSpirvType(type, EbsUnspecified);
columnType.secondarySize = 1; columnType.secondarySize = 1;
const spirv::IdRef columnTypeId = mBuilder.getSpirvTypeData(columnType, "").id; const spirv::IdRef columnTypeId = mBuilder.getSpirvTypeData(columnType, nullptr).id;
for (int columnIndex = 0; columnIndex < type.getCols(); ++columnIndex) for (int columnIndex = 0; columnIndex < type.getCols(); ++columnIndex)
{ {
...@@ -1117,7 +1117,7 @@ spirv::IdRef OutputSPIRVTraverser::createConstructorMatrixFromVectors( ...@@ -1117,7 +1117,7 @@ spirv::IdRef OutputSPIRVTraverser::createConstructorMatrixFromVectors(
SpirvType columnType = mBuilder.getSpirvType(type, EbsUnspecified); SpirvType columnType = mBuilder.getSpirvType(type, EbsUnspecified);
columnType.secondarySize = 1; columnType.secondarySize = 1;
const spirv::IdRef columnTypeId = mBuilder.getSpirvTypeData(columnType, "").id; const spirv::IdRef columnTypeId = mBuilder.getSpirvTypeData(columnType, nullptr).id;
// Chunk up the extracted components by column and construct intermediary vectors. // Chunk up the extracted components by column and construct intermediary vectors.
for (int columnIndex = 0; columnIndex < type.getCols(); ++columnIndex) for (int columnIndex = 0; columnIndex < type.getCols(); ++columnIndex)
...@@ -1175,15 +1175,16 @@ spirv::IdRef OutputSPIRVTraverser::createConstructorMatrixFromMatrix( ...@@ -1175,15 +1175,16 @@ spirv::IdRef OutputSPIRVTraverser::createConstructorMatrixFromMatrix(
SpirvType columnType = mBuilder.getSpirvType(type, EbsUnspecified); SpirvType columnType = mBuilder.getSpirvType(type, EbsUnspecified);
columnType.secondarySize = 1; columnType.secondarySize = 1;
const spirv::IdRef columnTypeId = mBuilder.getSpirvTypeData(columnType, "").id; const spirv::IdRef columnTypeId = mBuilder.getSpirvTypeData(columnType, nullptr).id;
if (parameterType.getCols() >= type.getCols() && parameterType.getRows() >= type.getRows()) if (parameterType.getCols() >= type.getCols() && parameterType.getRows() >= type.getRows())
{ {
// If the parameter is a larger matrix than the constructor type, extract the columns // If the parameter is a larger matrix than the constructor type, extract the columns
// directly and potentially swizzle them. // directly and potentially swizzle them.
SpirvType paramColumnType = mBuilder.getSpirvType(parameterType, EbsUnspecified); SpirvType paramColumnType = mBuilder.getSpirvType(parameterType, EbsUnspecified);
paramColumnType.secondarySize = 1; paramColumnType.secondarySize = 1;
const spirv::IdRef paramColumnTypeId = mBuilder.getSpirvTypeData(paramColumnType, "").id; const spirv::IdRef paramColumnTypeId =
mBuilder.getSpirvTypeData(paramColumnType, nullptr).id;
const bool needsSwizzle = parameterType.getRows() > type.getRows(); const bool needsSwizzle = parameterType.getRows() > type.getRows();
spirv::LiteralIntegerList swizzle = {spirv::LiteralInteger(0), spirv::LiteralInteger(1), spirv::LiteralIntegerList swizzle = {spirv::LiteralInteger(0), spirv::LiteralInteger(1),
...@@ -1219,7 +1220,7 @@ spirv::IdRef OutputSPIRVTraverser::createConstructorMatrixFromMatrix( ...@@ -1219,7 +1220,7 @@ spirv::IdRef OutputSPIRVTraverser::createConstructorMatrixFromMatrix(
paramComponentType.primarySize = 1; paramComponentType.primarySize = 1;
paramComponentType.secondarySize = 1; paramComponentType.secondarySize = 1;
const spirv::IdRef paramComponentTypeId = const spirv::IdRef paramComponentTypeId =
mBuilder.getSpirvTypeData(paramComponentType, "").id; mBuilder.getSpirvTypeData(paramComponentType, nullptr).id;
for (int columnIndex = 0; columnIndex < type.getCols(); ++columnIndex) for (int columnIndex = 0; columnIndex < type.getCols(); ++columnIndex)
{ {
...@@ -1307,7 +1308,8 @@ void OutputSPIRVTraverser::extractComponents(TIntermAggregate *node, ...@@ -1307,7 +1308,8 @@ void OutputSPIRVTraverser::extractComponents(TIntermAggregate *node,
{ {
SpirvType componentType = mBuilder.getSpirvType(argumentType, EbsUnspecified); SpirvType componentType = mBuilder.getSpirvType(argumentType, EbsUnspecified);
componentType.primarySize = 1; componentType.primarySize = 1;
const spirv::IdRef componentTypeId = mBuilder.getSpirvTypeData(componentType, "").id; const spirv::IdRef componentTypeId =
mBuilder.getSpirvTypeData(componentType, nullptr).id;
// For vector parameters, take components out of the vector one by one. // For vector parameters, take components out of the vector one by one.
for (int componentIndex = 0; componentIndex < argumentType.getNominalSize() && for (int componentIndex = 0; componentIndex < argumentType.getNominalSize() &&
...@@ -1329,7 +1331,7 @@ void OutputSPIRVTraverser::extractComponents(TIntermAggregate *node, ...@@ -1329,7 +1331,7 @@ void OutputSPIRVTraverser::extractComponents(TIntermAggregate *node,
SpirvType componentType = mBuilder.getSpirvType(argumentType, EbsUnspecified); SpirvType componentType = mBuilder.getSpirvType(argumentType, EbsUnspecified);
componentType.primarySize = 1; componentType.primarySize = 1;
componentType.secondarySize = 1; componentType.secondarySize = 1;
const spirv::IdRef componentTypeId = mBuilder.getSpirvTypeData(componentType, "").id; const spirv::IdRef componentTypeId = mBuilder.getSpirvTypeData(componentType, nullptr).id;
// For matrix parameters, take components out of the matrix one by one in column-major // For matrix parameters, take components out of the matrix one by one in column-major
// order. // order.
...@@ -2185,9 +2187,9 @@ bool OutputSPIRVTraverser::visitUnary(Visit visit, TIntermUnary *node) ...@@ -2185,9 +2187,9 @@ bool OutputSPIRVTraverser::visitUnary(Visit visit, TIntermUnary *node)
// Get the int and uint type ids. // Get the int and uint type ids.
SpirvType intType; SpirvType intType;
intType.type = EbtInt; intType.type = EbtInt;
const spirv::IdRef intTypeId = mBuilder.getSpirvTypeData(intType, "").id; const spirv::IdRef intTypeId = mBuilder.getSpirvTypeData(intType, nullptr).id;
intType.type = EbtUInt; intType.type = EbtUInt;
const spirv::IdRef uintTypeId = mBuilder.getSpirvTypeData(intType, "").id; const spirv::IdRef uintTypeId = mBuilder.getSpirvTypeData(intType, nullptr).id;
// Generate the instruction. // Generate the instruction.
const spirv::IdRef resultId = mBuilder.getNewId({}); const spirv::IdRef resultId = mBuilder.getNewId({});
...@@ -2470,7 +2472,7 @@ bool OutputSPIRVTraverser::visitUnary(Visit visit, TIntermUnary *node) ...@@ -2470,7 +2472,7 @@ bool OutputSPIRVTraverser::visitUnary(Visit visit, TIntermUnary *node)
SpirvType columnType = mBuilder.getSpirvType(operandType, EbsUnspecified); SpirvType columnType = mBuilder.getSpirvType(operandType, EbsUnspecified);
columnType.secondarySize = 1; columnType.secondarySize = 1;
const spirv::IdRef columnTypeId = mBuilder.getSpirvTypeData(columnType, "").id; const spirv::IdRef columnTypeId = mBuilder.getSpirvTypeData(columnType, nullptr).id;
// Extract and apply the operator to each column. // Extract and apply the operator to each column.
for (int columnIndex = 0; columnIndex < operandType.getCols(); ++columnIndex) for (int columnIndex = 0; columnIndex < operandType.getCols(); ++columnIndex)
...@@ -2663,7 +2665,7 @@ bool OutputSPIRVTraverser::visitFunctionDefinition(Visit visit, TIntermFunctionD ...@@ -2663,7 +2665,7 @@ bool OutputSPIRVTraverser::visitFunctionDefinition(Visit visit, TIntermFunctionD
mSymbolIdMap[paramVariable] = paramId; mSymbolIdMap[paramVariable] = paramId;
} }
mBuilder.startNewFunction(ids.functionId, mBuilder.hashFunctionName(function).data()); mBuilder.startNewFunction(ids.functionId, function);
return true; return true;
} }
...@@ -2948,7 +2950,7 @@ bool OutputSPIRVTraverser::visitDeclaration(Visit visit, TIntermDeclaration *nod ...@@ -2948,7 +2950,7 @@ bool OutputSPIRVTraverser::visitDeclaration(Visit visit, TIntermDeclaration *nod
{ {
SpirvType elementType = mBuilder.getSpirvType(type, EbsUnspecified); SpirvType elementType = mBuilder.getSpirvType(type, EbsUnspecified);
elementType.arraySizes = {}; elementType.arraySizes = {};
nonArrayTypeId = mBuilder.getSpirvTypeData(elementType, "").id; nonArrayTypeId = mBuilder.getSpirvTypeData(elementType, nullptr).id;
} }
if (isShaderInOut) if (isShaderInOut)
......
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