mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 03:30:06 +00:00
[val] Fixup id name output (#2158)
This CL changes the id/name output from the validator to always use a consistent id[%name] style. This removes the need for getIdOrName. The name lookup is changed to use the NameMapper so the output is consistent with what the disassembler will produce. Fixes #2137
This commit is contained in:
parent
0c172a6b74
commit
d835d664bd
@ -116,18 +116,18 @@ void printDot(const ValidationState_t& _, const BasicBlock& other) {
|
||||
block_string += "end ";
|
||||
} else {
|
||||
for (auto block : *other.successors()) {
|
||||
block_string += _.getIdOrName(block->id()) + " ";
|
||||
block_string += _.getIdName(block->id()) + " ";
|
||||
}
|
||||
}
|
||||
printf("%10s -> {%s\b}\n", _.getIdOrName(other.id()).c_str(),
|
||||
printf("%10s -> {%s\b}\n", _.getIdName(other.id()).c_str(),
|
||||
block_string.c_str());
|
||||
}
|
||||
|
||||
void PrintBlocks(ValidationState_t& _, Function func) {
|
||||
assert(func.first_block());
|
||||
|
||||
printf("%10s -> %s\n", _.getIdOrName(func.id()).c_str(),
|
||||
_.getIdOrName(func.first_block()->id()).c_str());
|
||||
printf("%10s -> %s\n", _.getIdName(func.id()).c_str(),
|
||||
_.getIdName(func.first_block()->id()).c_str());
|
||||
for (const auto& block : func.ordered_blocks()) {
|
||||
printDot(_, *block);
|
||||
}
|
||||
@ -145,7 +145,7 @@ void PrintBlocks(ValidationState_t& _, Function func) {
|
||||
|
||||
UNUSED(void PrintDotGraph(ValidationState_t& _, Function func)) {
|
||||
if (func.first_block()) {
|
||||
std::string func_name(_.getIdOrName(func.id()));
|
||||
std::string func_name(_.getIdName(func.id()));
|
||||
printf("digraph %s {\n", func_name.c_str());
|
||||
PrintBlocks(_, func);
|
||||
printf("}\n");
|
||||
|
@ -208,6 +208,10 @@ ValidationState_t::ValidationState_t(const spv_const_context ctx,
|
||||
/* diagnostic = */ nullptr);
|
||||
preallocateStorage();
|
||||
}
|
||||
|
||||
friendly_mapper_ = spvtools::MakeUnique<spvtools::FriendlyNameMapper>(
|
||||
context_, words_, num_words_);
|
||||
name_mapper_ = friendly_mapper_->GetNameMapper();
|
||||
}
|
||||
|
||||
void ValidationState_t::preallocateStorage() {
|
||||
@ -239,21 +243,10 @@ void ValidationState_t::AssignNameToId(uint32_t id, std::string name) {
|
||||
}
|
||||
|
||||
std::string ValidationState_t::getIdName(uint32_t id) const {
|
||||
std::stringstream out;
|
||||
out << id;
|
||||
if (operand_names_.find(id) != end(operand_names_)) {
|
||||
out << "[" << operand_names_.at(id) << "]";
|
||||
}
|
||||
return out.str();
|
||||
}
|
||||
const std::string id_name = name_mapper_(id);
|
||||
|
||||
std::string ValidationState_t::getIdOrName(uint32_t id) const {
|
||||
std::stringstream out;
|
||||
if (operand_names_.find(id) != std::end(operand_names_)) {
|
||||
out << operand_names_.at(id);
|
||||
} else {
|
||||
out << id;
|
||||
}
|
||||
out << id << "[%" << id_name << "]";
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "source/disassemble.h"
|
||||
#include "source/enum_set.h"
|
||||
#include "source/latest_version_spirv_header.h"
|
||||
#include "source/name_mapper.h"
|
||||
#include "source/spirv_definition.h"
|
||||
#include "source/spirv_validator_options.h"
|
||||
#include "source/val/decoration.h"
|
||||
@ -154,9 +155,6 @@ class ValidationState_t {
|
||||
/// Mutator function for ID bound.
|
||||
void setIdBound(uint32_t bound);
|
||||
|
||||
/// Like getIdName but does not display the id if the \p id has a name
|
||||
std::string getIdOrName(uint32_t id) const;
|
||||
|
||||
/// Returns the number of ID which have been forward referenced but not
|
||||
/// defined
|
||||
size_t unresolved_forward_id_count() const;
|
||||
@ -661,6 +659,10 @@ class ValidationState_t {
|
||||
std::unordered_map<uint32_t, std::vector<uint32_t>> function_to_entry_points_;
|
||||
const std::vector<uint32_t> empty_ids_;
|
||||
|
||||
/// Maps ids to friendly names.
|
||||
std::unique_ptr<spvtools::FriendlyNameMapper> friendly_mapper_;
|
||||
spvtools::NameMapper name_mapper_;
|
||||
|
||||
/// Variables used to reduce the number of diagnostic messages.
|
||||
uint32_t num_of_warnings_;
|
||||
uint32_t max_num_of_warnings_;
|
||||
|
@ -58,7 +58,8 @@ TEST(CppInterface, SuccessfulRoundTrip) {
|
||||
EXPECT_EQ(0u, position.line);
|
||||
EXPECT_EQ(0u, position.column);
|
||||
EXPECT_EQ(1u, position.index);
|
||||
EXPECT_STREQ("ID 1 has not been defined\n %2 = OpSizeOf %1 %3\n", message);
|
||||
EXPECT_STREQ("ID 1[%1] has not been defined\n %2 = OpSizeOf %1 %3\n",
|
||||
message);
|
||||
});
|
||||
EXPECT_FALSE(t.Validate(binary));
|
||||
|
||||
|
@ -53,7 +53,8 @@ OpFunctionEnd
|
||||
|
||||
CompileSuccessfully(module);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("ID 1 has not been defined"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("ID 1[%bool] has not been defined"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateAdjacency, OpLoopMergeEndsModuleFail) {
|
||||
|
@ -606,7 +606,8 @@ TEST_F(ValidateArithmetics, DotNotVectorTypeOperand1) {
|
||||
|
||||
CompileSuccessfully(GenerateCode(body).c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 6 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 6[%float] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateArithmetics, DotNotVectorTypeOperand2) {
|
||||
|
@ -380,7 +380,8 @@ TEST_F(ValidateAtomics, AtomicLoadWrongPointerType) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(body));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 27 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 27[%_ptr_Workgroup_float] cannot be a type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateAtomics, AtomicLoadWrongPointerDataType) {
|
||||
@ -623,7 +624,9 @@ TEST_F(ValidateAtomics, AtomicExchangeWrongPointerType) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(body));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 33 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 33[%_ptr_Workgroup_v4float] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateAtomics, AtomicExchangeWrongPointerDataType) {
|
||||
@ -736,7 +739,9 @@ TEST_F(ValidateAtomics, AtomicCompareExchangeWrongPointerType) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(body));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 33 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 33[%_ptr_Workgroup_v4float] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateAtomics, AtomicCompareExchangeWrongPointerDataType) {
|
||||
|
@ -875,7 +875,8 @@ OpMemoryBarrier %u32 %u32_0
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(body));
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 5 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 5[%uint] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateBarriers,
|
||||
|
@ -378,8 +378,8 @@ TEST_P(ValidateCFG, BlockAppearsBeforeDominatorBad) {
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("Block .\\[cont\\] appears in the binary "
|
||||
"before its dominator .\\[branch\\]\n"
|
||||
MatchesRegex("Block .\\[%cont\\] appears in the binary "
|
||||
"before its dominator .\\[%branch\\]\n"
|
||||
" %branch = OpLabel\n"));
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ TEST_P(ValidateCFG, MergeBlockTargetedByMultipleHeaderBlocksBad) {
|
||||
if (is_shader) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("Block .\\[merge\\] is already a merge block "
|
||||
MatchesRegex("Block .\\[%merge\\] is already a merge block "
|
||||
"for another header\n"
|
||||
" %Main = OpFunction %void None %9\n"));
|
||||
} else {
|
||||
@ -445,7 +445,7 @@ TEST_P(ValidateCFG, MergeBlockTargetedByMultipleHeaderBlocksSelectionBad) {
|
||||
if (is_shader) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("Block .\\[merge\\] is already a merge block "
|
||||
MatchesRegex("Block .\\[%merge\\] is already a merge block "
|
||||
"for another header\n"
|
||||
" %Main = OpFunction %void None %9\n"));
|
||||
} else {
|
||||
@ -470,8 +470,8 @@ TEST_P(ValidateCFG, BranchTargetFirstBlockBadSinceEntryBlock) {
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("First block .\\[entry\\] of function .\\[Main\\] "
|
||||
"is targeted by block .\\[bad\\]\n"
|
||||
MatchesRegex("First block .\\[%entry\\] of function "
|
||||
".\\[%Main\\] is targeted by block .\\[%bad\\]\n"
|
||||
" %Main = OpFunction %void None %10\n"));
|
||||
}
|
||||
|
||||
@ -494,10 +494,11 @@ TEST_P(ValidateCFG, BranchTargetFirstBlockBadSinceValue) {
|
||||
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("Block\\(s\\) \\{..\\} are referenced but not "
|
||||
"defined in function .\\[Main\\]\n"
|
||||
" %Main = OpFunction %void None %10\n"))
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex("Block\\(s\\) \\{11\\[%11\\]\\} are referenced but not "
|
||||
"defined in function .\\[%Main\\]\n %Main = OpFunction "
|
||||
"%void None %10\n"))
|
||||
<< str;
|
||||
}
|
||||
|
||||
@ -522,8 +523,8 @@ TEST_P(ValidateCFG, BranchConditionalTrueTargetFirstBlockBad) {
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("First block .\\[entry\\] of function .\\[Main\\] "
|
||||
"is targeted by block .\\[bad\\]\n"
|
||||
MatchesRegex("First block .\\[%entry\\] of function .\\[%Main\\] "
|
||||
"is targeted by block .\\[%bad\\]\n"
|
||||
" %Main = OpFunction %void None %10\n"));
|
||||
}
|
||||
|
||||
@ -551,8 +552,8 @@ TEST_P(ValidateCFG, BranchConditionalFalseTargetFirstBlockBad) {
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("First block .\\[entry\\] of function .\\[Main\\] "
|
||||
"is targeted by block .\\[bad\\]\n"
|
||||
MatchesRegex("First block .\\[%entry\\] of function .\\[%Main\\] "
|
||||
"is targeted by block .\\[%bad\\]\n"
|
||||
" %Main = OpFunction %void None %10\n"));
|
||||
}
|
||||
|
||||
@ -587,8 +588,8 @@ TEST_P(ValidateCFG, SwitchTargetFirstBlockBad) {
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("First block .\\[entry\\] of function .\\[Main\\] "
|
||||
"is targeted by block .\\[bad\\]\n"
|
||||
MatchesRegex("First block .\\[%entry\\] of function .\\[%Main\\] "
|
||||
"is targeted by block .\\[%bad\\]\n"
|
||||
" %Main = OpFunction %void None %10\n"));
|
||||
}
|
||||
|
||||
@ -623,8 +624,8 @@ TEST_P(ValidateCFG, BranchToBlockInOtherFunctionBad) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex("Block\\(s\\) \\{.\\[middle2\\]\\} are referenced but not "
|
||||
"defined in function .\\[Main\\]\n"
|
||||
MatchesRegex("Block\\(s\\) \\{.\\[%middle2\\]\\} are referenced but not "
|
||||
"defined in function .\\[%Main\\]\n"
|
||||
" %Main = OpFunction %void None %9\n"));
|
||||
}
|
||||
|
||||
@ -656,8 +657,8 @@ TEST_P(ValidateCFG, HeaderDoesntDominatesMergeBad) {
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex("The selection construct with the selection header "
|
||||
".\\[head\\] does not dominate the merge block "
|
||||
".\\[merge\\]\n %merge = OpLabel\n"));
|
||||
".\\[%head\\] does not dominate the merge block "
|
||||
".\\[%merge\\]\n %merge = OpLabel\n"));
|
||||
} else {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
@ -689,8 +690,8 @@ TEST_P(ValidateCFG, HeaderDoesntStrictlyDominateMergeBad) {
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex("The selection construct with the selection header "
|
||||
".\\[head\\] does not strictly dominate the merge block "
|
||||
".\\[head\\]\n %head = OpLabel\n"));
|
||||
".\\[%head\\] does not strictly dominate the merge block "
|
||||
".\\[%head\\]\n %head = OpLabel\n"));
|
||||
} else {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()) << str;
|
||||
}
|
||||
@ -940,8 +941,8 @@ TEST_P(ValidateCFG, BackEdgeBlockDoesntPostDominateContinueTargetBad) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("The continue construct with the continue target "
|
||||
".\\[loop2_merge\\] is not post dominated by the "
|
||||
"back-edge block .\\[be_block\\]\n"
|
||||
".\\[%loop2_merge\\] is not post dominated by the "
|
||||
"back-edge block .\\[%be_block\\]\n"
|
||||
" %be_block = OpLabel\n"));
|
||||
} else {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
@ -975,7 +976,7 @@ TEST_P(ValidateCFG, BranchingToNonLoopHeaderBlockBad) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex("Back-edges \\(.\\[f\\] -> .\\[split\\]\\) can only "
|
||||
MatchesRegex("Back-edges \\(.\\[%f\\] -> .\\[%split\\]\\) can only "
|
||||
"be formed between a block and a loop header.\n"
|
||||
" %f = OpLabel\n"));
|
||||
} else {
|
||||
@ -1003,11 +1004,11 @@ TEST_P(ValidateCFG, BranchingToSameNonLoopHeaderBlockBad) {
|
||||
CompileSuccessfully(str);
|
||||
if (is_shader) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex(
|
||||
"Back-edges \\(.\\[split\\] -> .\\[split\\]\\) can only be "
|
||||
"formed between a block and a loop header.\n"
|
||||
" %split = OpLabel\n"));
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex(
|
||||
"Back-edges \\(.\\[%split\\] -> .\\[%split\\]\\) can only be "
|
||||
"formed between a block and a loop header.\n %split = OpLabel\n"));
|
||||
} else {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
@ -1038,11 +1039,11 @@ TEST_P(ValidateCFG, MultipleBackEdgeBlocksToLoopHeaderBad) {
|
||||
CompileSuccessfully(str);
|
||||
if (is_shader) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex(
|
||||
"Loop header .\\[loop\\] is targeted by 2 back-edge blocks "
|
||||
"but the standard requires exactly one\n"
|
||||
" %loop = OpLabel\n"))
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex(
|
||||
"Loop header .\\[%loop\\] is targeted by 2 back-edge blocks but "
|
||||
"the standard requires exactly one\n %loop = OpLabel\n"))
|
||||
<< str;
|
||||
} else {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
@ -1078,8 +1079,8 @@ TEST_P(ValidateCFG, ContinueTargetMustBePostDominatedByBackEdge) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("The continue construct with the continue target "
|
||||
".\\[cheader\\] is not post dominated by the "
|
||||
"back-edge block .\\[be_block\\]\n"
|
||||
".\\[%cheader\\] is not post dominated by the "
|
||||
"back-edge block .\\[%be_block\\]\n"
|
||||
" %be_block = OpLabel\n"));
|
||||
} else {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
@ -1111,8 +1112,8 @@ TEST_P(ValidateCFG, BranchOutOfConstructToMergeBad) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("The continue construct with the continue target "
|
||||
".\\[loop\\] is not post dominated by the "
|
||||
"back-edge block .\\[cont\\]\n"
|
||||
".\\[%loop\\] is not post dominated by the "
|
||||
"back-edge block .\\[%cont\\]\n"
|
||||
" %cont = OpLabel\n"))
|
||||
<< str;
|
||||
} else {
|
||||
@ -1147,8 +1148,8 @@ TEST_P(ValidateCFG, BranchOutOfConstructBad) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("The continue construct with the continue target "
|
||||
".\\[loop\\] is not post dominated by the "
|
||||
"back-edge block .\\[cont\\]\n"
|
||||
".\\[%loop\\] is not post dominated by the "
|
||||
"back-edge block .\\[%cont\\]\n"
|
||||
" %cont = OpLabel\n"));
|
||||
} else {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
@ -1222,7 +1223,7 @@ TEST_F(ValidateCFG, LoopWithZeroBackEdgesBad) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex("Loop header .\\[loop\\] is targeted by "
|
||||
MatchesRegex("Loop header .\\[%loop\\] is targeted by "
|
||||
"0 back-edge blocks but the standard requires exactly "
|
||||
"one\n %loop = OpLabel\n"));
|
||||
}
|
||||
@ -1567,8 +1568,8 @@ OpFunctionEnd
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"Case construct that targets 10 has branches to multiple other case "
|
||||
"construct targets 12 and 11\n %10 = OpLabel"));
|
||||
"Case construct that targets 10[%10] has branches to multiple other "
|
||||
"case construct targets 12[%12] and 11[%11]\n %10 = OpLabel"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateCFG, MultipleFallThroughToDefault) {
|
||||
@ -1602,7 +1603,7 @@ OpFunctionEnd
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Multiple case constructs have branches to the case construct "
|
||||
"that targets 10\n %10 = OpLabel"));
|
||||
"that targets 10[%10]\n %10 = OpLabel"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateCFG, MultipleFallThroughToNonDefault) {
|
||||
@ -1636,7 +1637,7 @@ OpFunctionEnd
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Multiple case constructs have branches to the case construct "
|
||||
"that targets 12\n %12 = OpLabel"));
|
||||
"that targets 12[%12]\n %12 = OpLabel"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateCFG, DuplicateTargetWithFallThrough) {
|
||||
@ -1697,8 +1698,8 @@ OpFunctionEnd
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Case construct that targets 12 has branches to the case "
|
||||
"construct that targets 11, but does not immediately "
|
||||
HasSubstr("Case construct that targets 12[%12] has branches to the case "
|
||||
"construct that targets 11[%11], but does not immediately "
|
||||
"precede it in the OpSwitch's target list\n"
|
||||
" OpSwitch %uint_0 %10 0 %11 1 %12"));
|
||||
}
|
||||
@ -1733,8 +1734,8 @@ OpFunctionEnd
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Case construct that targets 12 has branches to the case "
|
||||
"construct that targets 11, but does not immediately "
|
||||
HasSubstr("Case construct that targets 12[%12] has branches to the case "
|
||||
"construct that targets 11[%11], but does not immediately "
|
||||
"precede it in the OpSwitch's target list\n"
|
||||
" OpSwitch %uint_0 %10 0 %11 1 %12"));
|
||||
}
|
||||
@ -1771,8 +1772,8 @@ OpFunctionEnd
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Case construct that targets 12 has branches to the case "
|
||||
"construct that targets 11, but does not immediately "
|
||||
HasSubstr("Case construct that targets 12[%12] has branches to the case "
|
||||
"construct that targets 11[%11], but does not immediately "
|
||||
"precede it in the OpSwitch's target list\n"
|
||||
" OpSwitch %uint_0 %10 0 %11 1 %12 2 %13"));
|
||||
}
|
||||
@ -1839,9 +1840,10 @@ OpFunctionEnd
|
||||
CompileSuccessfully(text);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Case construct that targets 8 has invalid branch to "
|
||||
"block 10 (not another case construct, corresponding "
|
||||
"merge, outer loop merge or outer loop continue"));
|
||||
HasSubstr("Case construct that targets 8[%8] has invalid branch "
|
||||
"to block 10[%10] (not another case construct, "
|
||||
"corresponding merge, outer loop merge or outer loop "
|
||||
"continue)"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateCFG, GoodCaseExitsToOuterConstructs) {
|
||||
|
@ -321,7 +321,8 @@ TEST_F(ValidateComposites, CompositeConstructVectorWrongConsituent1) {
|
||||
|
||||
CompileSuccessfully(GenerateShaderCode(body).c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 5 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 5[%float] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateComposites, CompositeConstructVectorWrongConsituent2) {
|
||||
@ -537,7 +538,8 @@ TEST_F(ValidateComposites, CopyObjectResultTypeNotType) {
|
||||
|
||||
CompileSuccessfully(GenerateShaderCode(body).c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("ID 19 is not a type id"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("ID 19[%float_0] is not a type id"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateComposites, CopyObjectWrongOperandType) {
|
||||
@ -658,7 +660,8 @@ TEST_F(ValidateComposites, CompositeExtractNotObject) {
|
||||
|
||||
CompileSuccessfully(GenerateShaderCode(body));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 11 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 11[%v4float] cannot "
|
||||
"be a type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateComposites, CompositeExtractNotComposite) {
|
||||
|
@ -973,7 +973,8 @@ TEST_F(ValidateConversion, PtrCastToGenericWrongInputType) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(body).c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 4 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 4[%float] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateConversion, PtrCastToGenericWrongInputStorageClass) {
|
||||
@ -1208,7 +1209,8 @@ TEST_F(ValidateConversion, BitcastInputHasNoType) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(body).c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 4 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 4[%float] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateConversion, BitcastWrongResultType) {
|
||||
@ -1296,7 +1298,8 @@ OpFunctionEnd
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 1 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 1[%uint] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -386,7 +386,8 @@ TEST_F(ValidateData, ids_should_be_validated_before_data) {
|
||||
)";
|
||||
CompileSuccessfully(str.c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("ID 3 has not been defined"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("ID 3[%3] has not been defined"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateData, matrix_bad_column_type) {
|
||||
@ -684,8 +685,9 @@ TEST_F(ValidateData, void_array) {
|
||||
|
||||
CompileSuccessfully(str.c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("OpTypeArray Element Type <id> '1' is a void type."));
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("OpTypeArray Element Type <id> '1[%void]' is a void type."));
|
||||
}
|
||||
|
||||
TEST_F(ValidateData, void_runtime_array) {
|
||||
@ -698,7 +700,8 @@ TEST_F(ValidateData, void_runtime_array) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("OpTypeRuntimeArray Element Type <id> '1' is a void type."));
|
||||
HasSubstr(
|
||||
"OpTypeRuntimeArray Element Type <id> '1[%void]' is a void type."));
|
||||
}
|
||||
} // namespace
|
||||
} // namespace val
|
||||
|
@ -105,8 +105,8 @@ TEST_F(ValidateDecorations, ValidateOpMemberDecorateOutOfBound) {
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Index 1 provided in OpMemberDecorate for struct <id> "
|
||||
"2 is out of bounds. The structure has 1 members. "
|
||||
"Largest valid index is 0."));
|
||||
"2[%_struct_2] is out of bounds. The structure has 1 "
|
||||
"members. Largest valid index is 0."));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, ValidateGroupDecorateRegistration) {
|
||||
@ -300,10 +300,11 @@ TEST_F(ValidateDecorations, StructContainsBuiltInStructBad) {
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateAndRetrieveValidationState());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Structure <id> 1 contains members with BuiltIn "
|
||||
"decoration. Therefore this structure may not be "
|
||||
"contained as a member of another structure type. "
|
||||
"Structure <id> 4 contains structure <id> 1."));
|
||||
HasSubstr("Structure <id> 1[%_struct_1] contains members with "
|
||||
"BuiltIn decoration. Therefore this structure may not "
|
||||
"be contained as a member of another structure type. "
|
||||
"Structure <id> 4[%_struct_4] contains structure <id> "
|
||||
"1[%_struct_1]."));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, StructContainsNonBuiltInStructGood) {
|
||||
@ -3322,8 +3323,8 @@ OpDecorate %1 Coherent
|
||||
CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Coherent decoration targeting 1 is banned when using "
|
||||
"the Vulkan memory model."));
|
||||
HasSubstr("Coherent decoration targeting 1[%1] is "
|
||||
"banned when using the Vulkan memory model."));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, VulkanMemoryModelNoCoherentMember) {
|
||||
@ -3340,10 +3341,10 @@ OpMemberDecorate %1 0 Coherent
|
||||
|
||||
CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Coherent decoration targeting 1 (member index 0) is "
|
||||
"banned when using "
|
||||
"the Vulkan memory model."));
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Coherent decoration targeting 1[%_struct_1] (member index 0) "
|
||||
"is banned when using the Vulkan memory model."));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, VulkanMemoryModelNoVolatile) {
|
||||
@ -3363,8 +3364,8 @@ OpDecorate %1 Volatile
|
||||
CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Volatile decoration targeting 1 is banned when using "
|
||||
"the Vulkan memory model."));
|
||||
HasSubstr("Volatile decoration targeting 1[%1] is banned when "
|
||||
"using the Vulkan memory model."));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, VulkanMemoryModelNoVolatileMember) {
|
||||
@ -3382,9 +3383,9 @@ OpMemberDecorate %1 1 Volatile
|
||||
CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Volatile decoration targeting 1 (member index 1) is "
|
||||
"banned when using "
|
||||
"the Vulkan memory model."));
|
||||
HasSubstr("Volatile decoration targeting 1[%_struct_1] (member "
|
||||
"index 1) is banned when using the Vulkan memory "
|
||||
"model."));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, FPRoundingModeGood) {
|
||||
@ -3696,9 +3697,9 @@ OpGroupDecorate %1 %1
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("OpGroupDecorate may not target OpDecorationGroup <id> '1'"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("OpGroupDecorate may not target OpDecorationGroup <id> "
|
||||
"'1[%1]'"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, GroupDecorateTargetsDecorationGroup2) {
|
||||
@ -3713,9 +3714,9 @@ OpGroupDecorate %1 %2 %1
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("OpGroupDecorate may not target OpDecorationGroup <id> '1'"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("OpGroupDecorate may not target OpDecorationGroup <id> "
|
||||
"'1[%1]'"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, RecurseThroughRuntimeArray) {
|
||||
|
@ -120,7 +120,8 @@ TEST_F(ValidateDerivatives, OpDPdxWrongResultType) {
|
||||
|
||||
CompileSuccessfully(GenerateShaderCode(body).c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 10 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 10[%v4float] cannot "
|
||||
"be a type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDerivatives, OpDPdxWrongPType) {
|
||||
|
@ -4134,7 +4134,8 @@ TEST_P(ValidateOpenCLStdVStoreHalfLike, PNotPointer) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(ss.str()));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 89 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 89[%_ptr_Workgroup_half] cannot be a type"));
|
||||
}
|
||||
|
||||
TEST_P(ValidateOpenCLStdVStoreHalfLike, ConstPointer) {
|
||||
@ -4305,7 +4306,8 @@ TEST_P(ValidateOpenCLStdVLoadHalfLike, PNotPointer) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(ss.str()));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 89 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 89[%_ptr_Workgroup_half] cannot be a type"));
|
||||
}
|
||||
|
||||
TEST_P(ValidateOpenCLStdVLoadHalfLike, OffsetWrongStorageType) {
|
||||
@ -4476,7 +4478,9 @@ TEST_F(ValidateExtInst, VLoadNPNotPointer) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(ss.str()));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 120 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 120[%_ptr_UniformConstant_float] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateExtInst, VLoadNWrongStorageClass) {
|
||||
@ -4587,7 +4591,9 @@ TEST_F(ValidateExtInst, VLoadHalfPNotPointer) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(ss.str()));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 114 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 114[%_ptr_UniformConstant_half] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateExtInst, VLoadHalfWrongStorageClass) {
|
||||
@ -4739,7 +4745,8 @@ TEST_F(ValidateExtInst, VStoreNPNotPointer) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(ss.str()));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 124 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 124[%_ptr_Generic_float] cannot be a type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateExtInst, VStoreNPNotGeneric) {
|
||||
@ -5052,7 +5059,9 @@ TEST_F(ValidateExtInst, OpenCLStdPrintfFormatNotPointer) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(body));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 134 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 134[%_ptr_UniformConstant_uchar] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateExtInst, OpenCLStdPrintfFormatNotUniformConstStorageClass) {
|
||||
@ -5143,7 +5152,9 @@ TEST_F(ValidateExtInst, OpenCLStdPrefetchPtrNotPointer) {
|
||||
|
||||
CompileSuccessfully(GenerateKernelCode(body));
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 99 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Operand 99[%_ptr_CrossWorkgroup_uint] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateExtInst, OpenCLStdPrefetchPtrNotCrossWorkgroup) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -672,7 +672,8 @@ TEST_F(ValidateImage, ImageTexelPointerImageNotResultTypePointer) {
|
||||
|
||||
CompileSuccessfully(GenerateShaderCode(body).c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 136 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 136[%136] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateImage, ImageTexelPointerImageNotImage) {
|
||||
|
@ -353,7 +353,7 @@ TEST_F(ValidateLimits, OpTypeFunctionBad) {
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("OpTypeFunction may not take more than 255 arguments. "
|
||||
"OpTypeFunction <id> '2' has 256 arguments."));
|
||||
"OpTypeFunction <id> '2[%2]' has 256 arguments."));
|
||||
}
|
||||
|
||||
// Valid: OpTypeFunction with 100 arguments (Custom limit: 100)
|
||||
@ -389,7 +389,7 @@ TEST_F(ValidateLimits, CustomizedOpTypeFunctionBad) {
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("OpTypeFunction may not take more than 100 arguments. "
|
||||
"OpTypeFunction <id> '2' has 101 arguments."));
|
||||
"OpTypeFunction <id> '2[%2]' has 101 arguments."));
|
||||
}
|
||||
|
||||
// Valid: module has 65,535 global variables.
|
||||
|
@ -442,9 +442,8 @@ OpFunctionEnd
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"OpVariable, <id> '5', has a disallowed initializer & storage class "
|
||||
"combination.\n"
|
||||
"From WebGPU execution environment spec:\n"
|
||||
"OpVariable, <id> '5[%5]', has a disallowed initializer & storage "
|
||||
"class combination.\nFrom WebGPU execution environment spec:\n"
|
||||
"Variable declarations that include initializers must have one of "
|
||||
"the following storage classes: Output, Private, or Function\n"
|
||||
" %5 = OpVariable %_ptr_Uniform_float Uniform %float_1\n"));
|
||||
@ -535,9 +534,8 @@ OpFunctionEnd
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"OpVariable, <id> '5', has a disallowed initializer & storage class "
|
||||
"combination.\n"
|
||||
"From Vulkan spec, Appendix A:\n"
|
||||
"OpVariable, <id> '5[%5]', has a disallowed initializer & storage "
|
||||
"class combination.\nFrom Vulkan spec, Appendix A:\n"
|
||||
"Variable declarations that include initializers must have one of "
|
||||
"the following storage classes: Output, Private, or Function\n "
|
||||
"%5 = OpVariable %_ptr_Input_float Input %float_1\n"));
|
||||
@ -620,8 +618,9 @@ TEST_F(ValidateMemory, ArrayLenResultNotIntType) {
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"The Result Type of OpArrayLength <id> '10' must be OpTypeInt with "
|
||||
"width 32 and signedness 0.\n %10 = OpArrayLength %float %9 0\n"));
|
||||
"The Result Type of OpArrayLength <id> '10[%10]' must be OpTypeInt "
|
||||
"with width 32 and signedness 0.\n %10 = OpArrayLength %float %9 "
|
||||
"0\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMemory, ArrayLenResultNot32bits) {
|
||||
@ -652,8 +651,9 @@ TEST_F(ValidateMemory, ArrayLenResultNot32bits) {
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"The Result Type of OpArrayLength <id> '11' must be OpTypeInt with "
|
||||
"width 32 and signedness 0.\n %11 = OpArrayLength %ushort %10 0\n"));
|
||||
"The Result Type of OpArrayLength <id> '11[%11]' must be OpTypeInt "
|
||||
"with width 32 and signedness 0.\n %11 = OpArrayLength %ushort %10 "
|
||||
"0\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMemory, ArrayLenResultSigned) {
|
||||
@ -683,8 +683,9 @@ TEST_F(ValidateMemory, ArrayLenResultSigned) {
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"The Result Type of OpArrayLength <id> '11' must be OpTypeInt with "
|
||||
"width 32 and signedness 0.\n %11 = OpArrayLength %int %10 0\n"));
|
||||
"The Result Type of OpArrayLength <id> '11[%11]' must be OpTypeInt "
|
||||
"with width 32 and signedness 0.\n %11 = OpArrayLength %int %10 "
|
||||
"0\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMemory, ArrayLenInputNotStruct) {
|
||||
@ -712,8 +713,8 @@ TEST_F(ValidateMemory, ArrayLenInputNotStruct) {
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("The Struture's type in OpArrayLength <id> '11' must "
|
||||
"be a pointer to an OpTypeStruct."));
|
||||
HasSubstr("The Struture's type in OpArrayLength <id> '11[%11]' "
|
||||
"must be a pointer to an OpTypeStruct."));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMemory, ArrayLenInputLastMemberNoRTA) {
|
||||
@ -742,8 +743,9 @@ TEST_F(ValidateMemory, ArrayLenInputLastMemberNoRTA) {
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("The Struture's last member in OpArrayLength <id> '11' must be "
|
||||
"an OpTypeRuntimeArray.\n %11 = OpArrayLength %uint %10 0\n"));
|
||||
HasSubstr("The Struture's last member in OpArrayLength <id> '11[%11]' "
|
||||
"must be an OpTypeRuntimeArray.\n %11 = OpArrayLength %uint "
|
||||
"%10 0\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMemory, ArrayLenInputLastMemberNoRTA2) {
|
||||
@ -772,8 +774,9 @@ TEST_F(ValidateMemory, ArrayLenInputLastMemberNoRTA2) {
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("The Struture's last member in OpArrayLength <id> '11' must be "
|
||||
"an OpTypeRuntimeArray.\n %11 = OpArrayLength %uint %10 1\n"));
|
||||
HasSubstr("The Struture's last member in OpArrayLength <id> '11[%11]' "
|
||||
"must be an OpTypeRuntimeArray.\n %11 = OpArrayLength %uint "
|
||||
"%10 1\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMemory, ArrayLenIndexNotLastMember) {
|
||||
@ -803,8 +806,8 @@ TEST_F(ValidateMemory, ArrayLenIndexNotLastMember) {
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"The array member in OpArrayLength <id> '11' must be an the last "
|
||||
"member of the struct.\n %11 = OpArrayLength %uint %10 0\n"));
|
||||
"The array member in OpArrayLength <id> '11[%11]' must be an the "
|
||||
"last member of the struct.\n %11 = OpArrayLength %uint %10 0\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMemory, ArrayLenIndexNotPointerToStruct) {
|
||||
@ -835,8 +838,8 @@ TEST_F(ValidateMemory, ArrayLenIndexNotPointerToStruct) {
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"The Struture's type in OpArrayLength <id> '12' must be a pointer to "
|
||||
"an OpTypeStruct.\n %12 = OpArrayLength %uint %11 0\n"));
|
||||
"The Struture's type in OpArrayLength <id> '12[%12]' must be a "
|
||||
"pointer to an OpTypeStruct.\n %12 = OpArrayLength %uint %11 0\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMemory, ArrayLenPointerIsAType) {
|
||||
@ -859,7 +862,8 @@ TEST_F(ValidateMemory, ArrayLenPointerIsAType) {
|
||||
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 4 cannot be a type"));
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("Operand 4[%float] cannot be a "
|
||||
"type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMemory, PushConstantNotStructGood) {
|
||||
@ -905,8 +909,8 @@ TEST_F(ValidateMemory, VulkanPushConstantNotStructBad) {
|
||||
CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_1));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("PushConstant OpVariable <id> '6' has illegal type.\n"
|
||||
"From Vulkan spec, section 14.5.1:\n"
|
||||
HasSubstr("PushConstant OpVariable <id> '6[%6]' has illegal "
|
||||
"type.\nFrom Vulkan spec, section 14.5.1:\n"
|
||||
"Such variables must be typed as OpTypeStruct, "
|
||||
"or an array of this type"));
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ TEST_F(ValidateSSA, DominateUsageWithinBlockBad) {
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("ID .\\[bad\\] has not been defined\n"
|
||||
MatchesRegex("ID .\\[%bad\\] has not been defined\n"
|
||||
" %8 = OpIAdd %uint %uint_1 %bad\n"));
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ TEST_F(ValidateSSA, DominateUsageSameInstructionBad) {
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("ID .\\[sum\\] has not been defined\n"
|
||||
MatchesRegex("ID .\\[%sum\\] has not been defined\n"
|
||||
" %sum = OpIAdd %uint %uint_1 %sum\n"));
|
||||
}
|
||||
|
||||
@ -202,7 +202,9 @@ TEST_F(ValidateSSA, ForwardMemberNameMissingTargetBad) {
|
||||
)";
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("size"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("The following forward referenced IDs have not been "
|
||||
"defined:\n2[%2]"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateSSA, ForwardDecorateGood) {
|
||||
@ -1124,8 +1126,8 @@ TEST_F(ValidateSSA, IdDoesNotDominateItsUseBad) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex("ID .\\[eleven\\] defined in block .\\[true_block\\] does "
|
||||
"not dominate its use in block .\\[false_block\\]\n"
|
||||
MatchesRegex("ID .\\[%eleven\\] defined in block .\\[%true_block\\] "
|
||||
"does not dominate its use in block .\\[%false_block\\]\n"
|
||||
" %false_block = OpLabel\n"));
|
||||
}
|
||||
|
||||
@ -1185,7 +1187,7 @@ TEST_F(ValidateSSA,
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
MatchesRegex("ID .\\[inew\\] has not been defined\n"
|
||||
MatchesRegex("ID .\\[%inew\\] has not been defined\n"
|
||||
" %19 = OpIAdd %uint %inew %uint_1\n"));
|
||||
}
|
||||
|
||||
@ -1268,8 +1270,8 @@ TEST_F(ValidateSSA, PhiVariableDefNotDominatedByParentBlockBad) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex("In OpPhi instruction .\\[phi\\], ID .\\[true_copy\\] "
|
||||
"definition does not dominate its parent .\\[if_false\\]\n"
|
||||
MatchesRegex("In OpPhi instruction .\\[%phi\\], ID .\\[%true_copy\\] "
|
||||
"definition does not dominate its parent .\\[%if_false\\]\n"
|
||||
" %phi = OpPhi %bool %true_copy %if_false %false_copy "
|
||||
"%if_true\n"));
|
||||
}
|
||||
@ -1396,8 +1398,8 @@ TEST_F(ValidateSSA, UseFunctionParameterFromOtherFunctionBad) {
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
MatchesRegex("ID .\\[first\\] used in function .\\[func2\\] is used "
|
||||
"outside of it's defining function .\\[func\\]\n"
|
||||
MatchesRegex("ID .\\[%first\\] used in function .\\[%func2\\] is used "
|
||||
"outside of it's defining function .\\[%func\\]\n"
|
||||
" %func = OpFunction %void None %14\n"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user