Commit 683064b7 by Shahbaz Youssefi Committed by Angle LUCI CQ

Vulkan: Fix missing operand list in OpExecutionMode parser & builder

Bug: angleproject:4889 Change-Id: Ie864031caeddfcf5202044b0f9c197b3883ceaf7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2934782Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 16b10a54
{
"src/common/spirv/gen_spirv_builder_and_parser.py":
"5ddd90060971e4cb7f8867e488e3d73a",
"e8d99c4791b23c8613a3a6830904bd19",
"src/common/spirv/spirv_instruction_builder_autogen.cpp":
"ec0ed8f398906dc49c35100fe1ac7a4a",
"450a8ccffc5a5586dbbfd0c8c8c3673d",
"src/common/spirv/spirv_instruction_builder_autogen.h":
"e704ce45c18d87996e8a920bb92e505a",
"c46c849dbea811cc8d16c51de1883deb",
"src/common/spirv/spirv_instruction_parser_autogen.cpp":
"55d28bb4b003dbecf31e162ff996fc4f",
"ec8ace46aa3fb858eb01cfede3c1e6df",
"src/common/spirv/spirv_instruction_parser_autogen.h":
"d1e45755f704b7bd587be379e5eabd67",
"66b41c497bef1ea01b906c3f4875b6ff",
"third_party/vulkan-deps/spirv-headers/src/include/spirv/1.0/spirv.core.grammar.json":
"a8c4239344b2fc10bfc4ace7ddee1867"
}
\ No newline at end of file
......@@ -289,16 +289,21 @@ class Writer:
# First, a number of special-cases for optional lists
if quantifier == '*':
suffix = 'List'
# For IdRefs, change 'Xyz 1', +\n'Xyz 2', +\n...' to xyzList
if kind == 'IdRef':
if name.find(' ') != -1:
name = name[0:name.find(' ')]
return make_camel_case(name) + 'List'
# Otherwise, it's a pair in the form of 'Xyz, Abc, ...', which is changed to
# xyzAbcPairList
# Otherwise, if it's a pair in the form of 'Xyz, Abc, ...', change it to xyzAbcPairList
elif kind.startswith('Pair'):
suffix = 'PairList'
# Otherwise, it's just a list, so change `xyz abc` to `xyzAbcList
name = remove_chars(name, " ,.")
return make_camel_case(name) + 'PairList'
return make_camel_case(name) + suffix
# Otherwise, remove invalid characters and make the first letter lower case.
name = remove_chars(name, " .,+\n~")
......@@ -497,6 +502,19 @@ class Writer:
self.process_operand(decoration_operands, cpp_operands_in, cpp_operands_out,
cpp_in_parse_lines, cpp_out_push_back_lines)
elif operand['kind'] == 'ExecutionMode':
# Special handling of OpExecutionMode instruction with an ExecutionMode operand.
# That operand always comes last, and implies a number of LiteralIntegers to follow.
assert (len(cpp_in_parse_lines) == len(operands))
execution_mode_operands = {
'name': 'operands',
'kind': 'LiteralInteger',
'quantifier': '*'
}
self.process_operand(execution_mode_operands, cpp_operands_in, cpp_operands_out,
cpp_in_parse_lines, cpp_out_push_back_lines)
elif operand['kind'] == 'ImageOperands':
# Special handling of OpImage* instructions with an ImageOperands operand. That
# operand always comes last, and implies a number of IdRefs to follow with different
......
......@@ -240,12 +240,19 @@ void WriteEntryPoint(Blob *blob,
}
(*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEntryPoint);
}
void WriteExecutionMode(Blob *blob, IdRef entryPoint, spv::ExecutionMode mode)
void WriteExecutionMode(Blob *blob,
IdRef entryPoint,
spv::ExecutionMode mode,
const LiteralIntegerList &operandsList)
{
const size_t startSize = blob->size();
blob->push_back(0);
blob->push_back(entryPoint);
blob->push_back(mode);
for (const auto &operand : operandsList)
{
blob->push_back(operand);
}
(*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpExecutionMode);
}
void WriteCapability(Blob *blob, spv::Capability capability)
......@@ -713,13 +720,13 @@ void WriteInBoundsPtrAccessChain(Blob *blob,
void WriteDecorate(Blob *blob,
IdRef target,
spv::Decoration decoration,
const LiteralIntegerList &valuesPairList)
const LiteralIntegerList &valuesList)
{
const size_t startSize = blob->size();
blob->push_back(0);
blob->push_back(target);
blob->push_back(decoration);
for (const auto &operand : valuesPairList)
for (const auto &operand : valuesList)
{
blob->push_back(operand);
}
......@@ -729,14 +736,14 @@ void WriteMemberDecorate(Blob *blob,
IdRef structureType,
LiteralInteger member,
spv::Decoration decoration,
const LiteralIntegerList &valuesPairList)
const LiteralIntegerList &valuesList)
{
const size_t startSize = blob->size();
blob->push_back(0);
blob->push_back(structureType);
blob->push_back(member);
blob->push_back(decoration);
for (const auto &operand : valuesPairList)
for (const auto &operand : valuesList)
{
blob->push_back(operand);
}
......@@ -809,7 +816,7 @@ void WriteVectorShuffle(Blob *blob,
IdResult idResult,
IdRef vector1,
IdRef vector2,
const LiteralIntegerList &componentsPairList)
const LiteralIntegerList &componentsList)
{
const size_t startSize = blob->size();
blob->push_back(0);
......@@ -817,7 +824,7 @@ void WriteVectorShuffle(Blob *blob,
blob->push_back(idResult);
blob->push_back(vector1);
blob->push_back(vector2);
for (const auto &operand : componentsPairList)
for (const auto &operand : componentsList)
{
blob->push_back(operand);
}
......@@ -842,14 +849,14 @@ void WriteCompositeExtract(Blob *blob,
IdResultType idResultType,
IdResult idResult,
IdRef composite,
const LiteralIntegerList &indexesPairList)
const LiteralIntegerList &indexesList)
{
const size_t startSize = blob->size();
blob->push_back(0);
blob->push_back(idResultType);
blob->push_back(idResult);
blob->push_back(composite);
for (const auto &operand : indexesPairList)
for (const auto &operand : indexesList)
{
blob->push_back(operand);
}
......@@ -860,7 +867,7 @@ void WriteCompositeInsert(Blob *blob,
IdResult idResult,
IdRef object,
IdRef composite,
const LiteralIntegerList &indexesPairList)
const LiteralIntegerList &indexesList)
{
const size_t startSize = blob->size();
blob->push_back(0);
......@@ -868,7 +875,7 @@ void WriteCompositeInsert(Blob *blob,
blob->push_back(idResult);
blob->push_back(object);
blob->push_back(composite);
for (const auto &operand : indexesPairList)
for (const auto &operand : indexesList)
{
blob->push_back(operand);
}
......@@ -2741,14 +2748,14 @@ void WriteBranchConditional(Blob *blob,
IdRef condition,
IdRef trueLabel,
IdRef falseLabel,
const LiteralIntegerList &branchweightsPairList)
const LiteralIntegerList &branchweightsList)
{
const size_t startSize = blob->size();
blob->push_back(0);
blob->push_back(condition);
blob->push_back(trueLabel);
blob->push_back(falseLabel);
for (const auto &operand : branchweightsPairList)
for (const auto &operand : branchweightsList)
{
blob->push_back(operand);
}
......
......@@ -50,7 +50,10 @@ void WriteEntryPoint(Blob *blob,
IdRef entryPoint,
LiteralString name,
const IdRefList &interfaceList);
void WriteExecutionMode(Blob *blob, IdRef entryPoint, spv::ExecutionMode mode);
void WriteExecutionMode(Blob *blob,
IdRef entryPoint,
spv::ExecutionMode mode,
const LiteralIntegerList &operandsList);
void WriteCapability(Blob *blob, spv::Capability capability);
void WriteTypeVoid(Blob *blob, IdResult idResult);
void WriteTypeBool(Blob *blob, IdResult idResult);
......@@ -165,12 +168,12 @@ void WriteInBoundsPtrAccessChain(Blob *blob,
void WriteDecorate(Blob *blob,
IdRef target,
spv::Decoration decoration,
const LiteralIntegerList &valuesPairList);
const LiteralIntegerList &valuesList);
void WriteMemberDecorate(Blob *blob,
IdRef structureType,
LiteralInteger member,
spv::Decoration decoration,
const LiteralIntegerList &valuesPairList);
const LiteralIntegerList &valuesList);
void WriteDecorationGroup(Blob *blob, IdResult idResult);
void WriteGroupDecorate(Blob *blob, IdRef decorationGroup, const IdRefList &targetsList);
void WriteGroupMemberDecorate(Blob *blob,
......@@ -192,7 +195,7 @@ void WriteVectorShuffle(Blob *blob,
IdResult idResult,
IdRef vector1,
IdRef vector2,
const LiteralIntegerList &componentsPairList);
const LiteralIntegerList &componentsList);
void WriteCompositeConstruct(Blob *blob,
IdResultType idResultType,
IdResult idResult,
......@@ -201,13 +204,13 @@ void WriteCompositeExtract(Blob *blob,
IdResultType idResultType,
IdResult idResult,
IdRef composite,
const LiteralIntegerList &indexesPairList);
const LiteralIntegerList &indexesList);
void WriteCompositeInsert(Blob *blob,
IdResultType idResultType,
IdResult idResult,
IdRef object,
IdRef composite,
const LiteralIntegerList &indexesPairList);
const LiteralIntegerList &indexesList);
void WriteCopyObject(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand);
void WriteTranspose(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef matrix);
void WriteSampledImage(Blob *blob,
......@@ -789,7 +792,7 @@ void WriteBranchConditional(Blob *blob,
IdRef condition,
IdRef trueLabel,
IdRef falseLabel,
const LiteralIntegerList &branchweightsPairList);
const LiteralIntegerList &branchweightsList);
void WriteSwitch(Blob *blob,
IdRef selector,
IdRef default_,
......
......@@ -218,7 +218,10 @@ void ParseEntryPoint(const uint32_t *_instruction,
}
}
}
void ParseExecutionMode(const uint32_t *_instruction, IdRef *entryPoint, spv::ExecutionMode *mode)
void ParseExecutionMode(const uint32_t *_instruction,
IdRef *entryPoint,
spv::ExecutionMode *mode,
LiteralIntegerList *operandsList)
{
spv::Op _op;
uint32_t _length;
......@@ -227,6 +230,13 @@ void ParseExecutionMode(const uint32_t *_instruction, IdRef *entryPoint, spv::Ex
uint32_t _o = 1;
*entryPoint = IdRef(_instruction[_o++]);
*mode = spv::ExecutionMode(_instruction[_o++]);
if (operandsList)
{
while (_o < _length)
{
operandsList->emplace_back(_instruction[_o++]);
}
}
}
void ParseCapability(const uint32_t *_instruction, spv::Capability *capability)
{
......@@ -811,7 +821,7 @@ void ParseInBoundsPtrAccessChain(const uint32_t *_instruction,
void ParseDecorate(const uint32_t *_instruction,
IdRef *target,
spv::Decoration *decoration,
LiteralIntegerList *valuesPairList)
LiteralIntegerList *valuesList)
{
spv::Op _op;
uint32_t _length;
......@@ -820,11 +830,11 @@ void ParseDecorate(const uint32_t *_instruction,
uint32_t _o = 1;
*target = IdRef(_instruction[_o++]);
*decoration = spv::Decoration(_instruction[_o++]);
if (valuesPairList)
if (valuesList)
{
while (_o < _length)
{
valuesPairList->emplace_back(_instruction[_o++]);
valuesList->emplace_back(_instruction[_o++]);
}
}
}
......@@ -832,7 +842,7 @@ void ParseMemberDecorate(const uint32_t *_instruction,
IdRef *structureType,
LiteralInteger *member,
spv::Decoration *decoration,
LiteralIntegerList *valuesPairList)
LiteralIntegerList *valuesList)
{
spv::Op _op;
uint32_t _length;
......@@ -842,11 +852,11 @@ void ParseMemberDecorate(const uint32_t *_instruction,
*structureType = IdRef(_instruction[_o++]);
*member = LiteralInteger(_instruction[_o++]);
*decoration = spv::Decoration(_instruction[_o++]);
if (valuesPairList)
if (valuesList)
{
while (_o < _length)
{
valuesPairList->emplace_back(_instruction[_o++]);
valuesList->emplace_back(_instruction[_o++]);
}
}
}
......@@ -936,7 +946,7 @@ void ParseVectorShuffle(const uint32_t *_instruction,
IdResult *idResult,
IdRef *vector1,
IdRef *vector2,
LiteralIntegerList *componentsPairList)
LiteralIntegerList *componentsList)
{
spv::Op _op;
uint32_t _length;
......@@ -947,11 +957,11 @@ void ParseVectorShuffle(const uint32_t *_instruction,
*idResult = IdResult(_instruction[_o++]);
*vector1 = IdRef(_instruction[_o++]);
*vector2 = IdRef(_instruction[_o++]);
if (componentsPairList)
if (componentsList)
{
while (_o < _length)
{
componentsPairList->emplace_back(_instruction[_o++]);
componentsList->emplace_back(_instruction[_o++]);
}
}
}
......@@ -979,7 +989,7 @@ void ParseCompositeExtract(const uint32_t *_instruction,
IdResultType *idResultType,
IdResult *idResult,
IdRef *composite,
LiteralIntegerList *indexesPairList)
LiteralIntegerList *indexesList)
{
spv::Op _op;
uint32_t _length;
......@@ -989,11 +999,11 @@ void ParseCompositeExtract(const uint32_t *_instruction,
*idResultType = IdResultType(_instruction[_o++]);
*idResult = IdResult(_instruction[_o++]);
*composite = IdRef(_instruction[_o++]);
if (indexesPairList)
if (indexesList)
{
while (_o < _length)
{
indexesPairList->emplace_back(_instruction[_o++]);
indexesList->emplace_back(_instruction[_o++]);
}
}
}
......@@ -1002,7 +1012,7 @@ void ParseCompositeInsert(const uint32_t *_instruction,
IdResult *idResult,
IdRef *object,
IdRef *composite,
LiteralIntegerList *indexesPairList)
LiteralIntegerList *indexesList)
{
spv::Op _op;
uint32_t _length;
......@@ -1013,11 +1023,11 @@ void ParseCompositeInsert(const uint32_t *_instruction,
*idResult = IdResult(_instruction[_o++]);
*object = IdRef(_instruction[_o++]);
*composite = IdRef(_instruction[_o++]);
if (indexesPairList)
if (indexesList)
{
while (_o < _length)
{
indexesPairList->emplace_back(_instruction[_o++]);
indexesList->emplace_back(_instruction[_o++]);
}
}
}
......@@ -3282,7 +3292,7 @@ void ParseBranchConditional(const uint32_t *_instruction,
IdRef *condition,
IdRef *trueLabel,
IdRef *falseLabel,
LiteralIntegerList *branchweightsPairList)
LiteralIntegerList *branchweightsList)
{
spv::Op _op;
uint32_t _length;
......@@ -3292,11 +3302,11 @@ void ParseBranchConditional(const uint32_t *_instruction,
*condition = IdRef(_instruction[_o++]);
*trueLabel = IdRef(_instruction[_o++]);
*falseLabel = IdRef(_instruction[_o++]);
if (branchweightsPairList)
if (branchweightsList)
{
while (_o < _length)
{
branchweightsPairList->emplace_back(_instruction[_o++]);
branchweightsList->emplace_back(_instruction[_o++]);
}
}
}
......
......@@ -54,7 +54,10 @@ void ParseEntryPoint(const uint32_t *_instruction,
IdRef *entryPoint,
LiteralString *name,
IdRefList *interfaceList);
void ParseExecutionMode(const uint32_t *_instruction, IdRef *entryPoint, spv::ExecutionMode *mode);
void ParseExecutionMode(const uint32_t *_instruction,
IdRef *entryPoint,
spv::ExecutionMode *mode,
LiteralIntegerList *operandsList);
void ParseCapability(const uint32_t *_instruction, spv::Capability *capability);
void ParseTypeVoid(const uint32_t *_instruction, IdResult *idResult);
void ParseTypeBool(const uint32_t *_instruction, IdResult *idResult);
......@@ -197,12 +200,12 @@ void ParseInBoundsPtrAccessChain(const uint32_t *_instruction,
void ParseDecorate(const uint32_t *_instruction,
IdRef *target,
spv::Decoration *decoration,
LiteralIntegerList *valuesPairList);
LiteralIntegerList *valuesList);
void ParseMemberDecorate(const uint32_t *_instruction,
IdRef *structureType,
LiteralInteger *member,
spv::Decoration *decoration,
LiteralIntegerList *valuesPairList);
LiteralIntegerList *valuesList);
void ParseDecorationGroup(const uint32_t *_instruction, IdResult *idResult);
void ParseGroupDecorate(const uint32_t *_instruction,
IdRef *decorationGroup,
......@@ -226,7 +229,7 @@ void ParseVectorShuffle(const uint32_t *_instruction,
IdResult *idResult,
IdRef *vector1,
IdRef *vector2,
LiteralIntegerList *componentsPairList);
LiteralIntegerList *componentsList);
void ParseCompositeConstruct(const uint32_t *_instruction,
IdResultType *idResultType,
IdResult *idResult,
......@@ -235,13 +238,13 @@ void ParseCompositeExtract(const uint32_t *_instruction,
IdResultType *idResultType,
IdResult *idResult,
IdRef *composite,
LiteralIntegerList *indexesPairList);
LiteralIntegerList *indexesList);
void ParseCompositeInsert(const uint32_t *_instruction,
IdResultType *idResultType,
IdResult *idResult,
IdRef *object,
IdRef *composite,
LiteralIntegerList *indexesPairList);
LiteralIntegerList *indexesList);
void ParseCopyObject(const uint32_t *_instruction,
IdResultType *idResultType,
IdResult *idResult,
......@@ -918,7 +921,7 @@ void ParseBranchConditional(const uint32_t *_instruction,
IdRef *condition,
IdRef *trueLabel,
IdRef *falseLabel,
LiteralIntegerList *branchweightsPairList);
LiteralIntegerList *branchweightsList);
void ParseSwitch(const uint32_t *_instruction,
IdRef *selector,
IdRef *default_,
......
......@@ -1249,7 +1249,7 @@ spirv::Blob SPIRVBuilder::getSpirv()
// - OpExecutionMode instructions
for (spv::ExecutionMode executionMode : mExecutionModes)
{
spirv::WriteExecutionMode(&result, mEntryPointId, executionMode);
spirv::WriteExecutionMode(&result, mEntryPointId, executionMode, {});
}
result.insert(result.end(), mSpirvExecutionModes.begin(), mSpirvExecutionModes.end());
......
......@@ -2543,7 +2543,7 @@ void SpirvTransformFeedbackCodeGenerator::addExecutionMode(spirv::IdRef entryPoi
if (mHasTransformFeedbackOutput)
{
spirv::WriteExecutionMode(blobOut, entryPointId, spv::ExecutionModeXfb);
spirv::WriteExecutionMode(blobOut, entryPointId, spv::ExecutionModeXfb, {});
}
}
......@@ -3596,7 +3596,7 @@ TransformationState SpirvTransformer::transformExecutionMode(const uint32_t *ins
{
spirv::IdRef entryPoint;
spv::ExecutionMode mode;
spirv::ParseExecutionMode(instruction, &entryPoint, &mode);
spirv::ParseExecutionMode(instruction, &entryPoint, &mode, nullptr);
if (mode == spv::ExecutionModeEarlyFragmentTests &&
mOptions.removeEarlyFragmentTestsOptimization)
......
......@@ -655,10 +655,12 @@ void InsertPreamble(uint32_t colorAttachmentCount,
spirv::WriteEntryPoint(blobOut, spv::ExecutionModelFragment, spirv::IdRef(kIdMain), "main",
entryPointIds);
spirv::WriteExecutionMode(blobOut, spirv::IdRef(kIdMain), spv::ExecutionModeOriginUpperLeft);
spirv::WriteExecutionMode(blobOut, spirv::IdRef(kIdMain), spv::ExecutionModeOriginUpperLeft,
{});
if (unresolveDepth)
{
spirv::WriteExecutionMode(blobOut, spirv::IdRef(kIdMain), spv::ExecutionModeDepthReplacing);
spirv::WriteExecutionMode(blobOut, spirv::IdRef(kIdMain), spv::ExecutionModeDepthReplacing,
{});
}
spirv::WriteSource(blobOut, spv::SourceLanguageGLSL, spirv::LiteralInteger(450), nullptr,
nullptr);
......
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