From a5a5ea0e2dfce9c755a88af1074ebe68a44d2ed9 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Wed, 1 Aug 2018 14:58:12 -0400 Subject: [PATCH] Remove using std:: statements. (#1756) Many of the files have using std:: statements in them, but then the use of will be inconsistently std:: or scattered through the file. This CL removes all of the using statements and updates the code to have the required std:: prefix. --- source/cfa.h | 61 +- source/opt/cfg.cpp | 5 +- source/opt/local_single_store_elim_pass.cpp | 4 +- source/opt/mem_pass.cpp | 4 +- source/val/basic_block.cpp | 5 +- source/val/function.cpp | 38 +- source/val/instruction.cpp | 4 +- source/val/validate.cpp | 22 +- source/val/validate_cfg.cpp | 67 +- source/val/validate_decorations.cpp | 11 +- source/val/validate_id.cpp | 30 +- source/val/validation_state.cpp | 4 +- test/binary_to_text_test.cpp | 10 +- test/operand_capabilities_test.cpp | 14 +- test/operand_test.cpp | 7 +- test/text_to_binary.annotation_test.cpp | 41 +- test/text_to_binary.control_flow_test.cpp | 11 +- test/text_to_binary.mode_setting_test.cpp | 17 +- .../text_to_binary.subgroup_dispatch_test.cpp | 1 - test/val/val_arithmetics_test.cpp | 2 - test/val/val_capability_test.cpp | 963 +++++++++--------- test/val/val_cfg_test.cpp | 325 +++--- test/val/val_data_test.cpp | 191 ++-- test/val/val_decoration_test.cpp | 184 ++-- test/val/val_extensions_test.cpp | 54 +- test/val/val_id_test.cpp | 575 ++++++----- test/val/val_layout_test.cpp | 120 +-- test/val/val_limits_test.cpp | 9 +- test/val/val_ssa_test.cpp | 210 ++-- test/val/val_state_test.cpp | 2 - test/val/val_type_unique_test.cpp | 40 +- test/val/val_validation_state_test.cpp | 14 +- test/val/val_version_test.cpp | 295 +++--- test/val/val_webgpu_test.cpp | 3 +- 34 files changed, 1647 insertions(+), 1696 deletions(-) diff --git a/source/cfa.h b/source/cfa.h index 89adf1bc1..9e7081b95 100644 --- a/source/cfa.h +++ b/source/cfa.h @@ -25,14 +25,6 @@ #include #include -using std::find; -using std::function; -using std::get; -using std::pair; -using std::unordered_map; -using std::unordered_set; -using std::vector; - namespace spvtools { // Control Flow Analysis of control flow graphs of basic block nodes |BB|. @@ -111,8 +103,8 @@ class CFA { /// block /// without predecessors (such as the root node) is its own immediate /// dominator. - static vector> CalculateDominators( - const vector& postorder, get_blocks_func predecessor_func); + static std::vector> CalculateDominators( + const std::vector& postorder, get_blocks_func predecessor_func); // Computes a minimal set of root nodes required to traverse, in the forward // direction, the CFG represented by the given vector of blocks, and successor @@ -133,7 +125,8 @@ class CFA { }; template -bool CFA::FindInWorkList(const vector& work_list, uint32_t id) { +bool CFA::FindInWorkList(const std::vector& work_list, + uint32_t id) { for (const auto b : work_list) { if (b.block->id() == id) return true; } @@ -141,19 +134,19 @@ bool CFA::FindInWorkList(const vector& work_list, uint32_t id) { } template -void CFA::DepthFirstTraversal(const BB* entry, - get_blocks_func successor_func, - function preorder, - function postorder, - function backedge) { - unordered_set processed; +void CFA::DepthFirstTraversal( + const BB* entry, get_blocks_func successor_func, + std::function preorder, + std::function postorder, + std::function backedge) { + std::unordered_set processed; /// NOTE: work_list is the sequence of nodes from the root node to the node /// being processed in the traversal - vector work_list; + std::vector work_list; work_list.reserve(10); - work_list.push_back({entry, begin(*successor_func(entry))}); + work_list.push_back({entry, std::begin(*successor_func(entry))}); preorder(entry); processed.insert(entry->id()); @@ -171,7 +164,7 @@ void CFA::DepthFirstTraversal(const BB* entry, if (processed.count(child->id()) == 0) { preorder(child); work_list.emplace_back( - block_info{child, begin(*successor_func(child))}); + block_info{child, std::begin(*successor_func(child))}); processed.insert(child->id()); } } @@ -179,15 +172,15 @@ void CFA::DepthFirstTraversal(const BB* entry, } template -vector> CFA::CalculateDominators( - const vector& postorder, get_blocks_func predecessor_func) { +std::vector> CFA::CalculateDominators( + const std::vector& postorder, get_blocks_func predecessor_func) { struct block_detail { size_t dominator; ///< The index of blocks's dominator in post order array size_t postorder_index; ///< The index of the block in the post order array }; const size_t undefined_dom = postorder.size(); - unordered_map idoms; + std::unordered_map idoms; for (size_t i = 0; i < postorder.size(); i++) { idoms[postorder[i]] = {undefined_dom, i}; } @@ -197,14 +190,14 @@ vector> CFA::CalculateDominators( while (changed) { changed = false; for (auto b = postorder.rbegin() + 1; b != postorder.rend(); ++b) { - const vector& predecessors = *predecessor_func(*b); + const std::vector& predecessors = *predecessor_func(*b); // Find the first processed/reachable predecessor that is reachable // in the forward traversal. - auto res = find_if(begin(predecessors), end(predecessors), - [&idoms, undefined_dom](BB* pred) { - return idoms.count(pred) && - idoms[pred].dominator != undefined_dom; - }); + auto res = std::find_if(std::begin(predecessors), std::end(predecessors), + [&idoms, undefined_dom](BB* pred) { + return idoms.count(pred) && + idoms[pred].dominator != undefined_dom; + }); if (res == end(predecessors)) continue; const BB* idom = *res; size_t idom_idx = idoms[idom].postorder_index; @@ -237,19 +230,19 @@ vector> CFA::CalculateDominators( } } - vector> out; + std::vector> out; for (auto idom : idoms) { // NOTE: performing a const cast for convenient usage with // UpdateImmediateDominators - out.push_back({const_cast(get<0>(idom)), - const_cast(postorder[get<1>(idom).dominator])}); + out.push_back({const_cast(std::get<0>(idom)), + const_cast(postorder[std::get<1>(idom).dominator])}); } // Sort by postorder index to generate a deterministic ordering of edges. std::sort( out.begin(), out.end(), - [&idoms](const pair& lhs, - const pair& rhs) { + [&idoms](const std::pair& lhs, + const std::pair& rhs) { assert(lhs.first); assert(lhs.second); assert(rhs.first); diff --git a/source/opt/cfg.cpp b/source/opt/cfg.cpp index 8625358cc..fa3e50f33 100644 --- a/source/opt/cfg.cpp +++ b/source/opt/cfg.cpp @@ -143,8 +143,9 @@ void CFG::ComputeStructuredSuccessors(Function* func) { } } -void CFG::ComputePostOrderTraversal(BasicBlock* bb, vector* order, - unordered_set* seen) { +void CFG::ComputePostOrderTraversal(BasicBlock* bb, + std::vector* order, + std::unordered_set* seen) { seen->insert(bb); static_cast(bb)->ForEachSuccessorLabel( [&order, &seen, this](const uint32_t sbid) { diff --git a/source/opt/local_single_store_elim_pass.cpp b/source/opt/local_single_store_elim_pass.cpp index 225356e5d..66c1505e3 100644 --- a/source/opt/local_single_store_elim_pass.cpp +++ b/source/opt/local_single_store_elim_pass.cpp @@ -116,7 +116,7 @@ void LocalSingleStoreElimPass::InitExtensionWhiteList() { }); } bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) { - vector users; + std::vector users; FindUses(var_inst, &users); Instruction* store_inst = FindSingleStoreAndCheckUses(var_inst, users); @@ -129,7 +129,7 @@ bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) { } Instruction* LocalSingleStoreElimPass::FindSingleStoreAndCheckUses( - Instruction* var_inst, const vector& users) const { + Instruction* var_inst, const std::vector& users) const { // Make sure there is exactly 1 store. Instruction* store_inst = nullptr; diff --git a/source/opt/mem_pass.cpp b/source/opt/mem_pass.cpp index 9292c3586..41c29d64f 100644 --- a/source/opt/mem_pass.cpp +++ b/source/opt/mem_pass.cpp @@ -178,7 +178,7 @@ void MemPass::AddStores(uint32_t ptr_id, std::queue* insts) { } void MemPass::DCEInst(Instruction* inst, - const function& call_back) { + const std::function& call_back) { std::queue deadInsts; deadInsts.push(inst); while (!deadInsts.empty()) { @@ -310,7 +310,7 @@ bool MemPass::IsTargetVar(uint32_t varId) { // [ ... ] // %30 = OpPhi %int %int_42 %13 %50 %14 %50 %15 void MemPass::RemovePhiOperands( - Instruction* phi, const unordered_set& reachable_blocks) { + Instruction* phi, const std::unordered_set& reachable_blocks) { std::vector keep_operands; uint32_t type_id = 0; // The id of an undefined value we've generated. diff --git a/source/val/basic_block.cpp b/source/val/basic_block.cpp index d70a3f006..ce1a3b513 100644 --- a/source/val/basic_block.cpp +++ b/source/val/basic_block.cpp @@ -18,8 +18,6 @@ #include #include -using std::vector; - namespace spvtools { namespace val { @@ -55,7 +53,8 @@ BasicBlock* BasicBlock::immediate_post_dominator() { return immediate_post_dominator_; } -void BasicBlock::RegisterSuccessors(const vector& next_blocks) { +void BasicBlock::RegisterSuccessors( + const std::vector& next_blocks) { for (auto& block : next_blocks) { block->predecessors_.push_back(this); successors_.push_back(block); diff --git a/source/val/function.cpp b/source/val/function.cpp index 9f02a489e..d1599b716 100644 --- a/source/val/function.cpp +++ b/source/val/function.cpp @@ -27,13 +27,6 @@ #include "val/construct.h" #include "validate.h" -using std::ignore; -using std::list; -using std::make_pair; -using std::pair; -using std::tie; -using std::vector; - namespace spvtools { namespace val { @@ -140,12 +133,12 @@ spv_result_t Function::RegisterBlock(uint32_t block_id, bool is_definition) { return SPV_SUCCESS; } -void Function::RegisterBlockEnd(vector next_list, +void Function::RegisterBlockEnd(std::vector next_list, SpvOp branch_instruction) { assert( current_block_ && "RegisterBlockEnd can only be called when parsing a binary in a block"); - vector next_blocks; + std::vector next_blocks; next_blocks.reserve(next_list.size()); std::unordered_map::iterator inserted_block; @@ -196,16 +189,18 @@ size_t Function::undefined_block_count() const { return undefined_blocks_.size(); } -const vector& Function::ordered_blocks() const { +const std::vector& Function::ordered_blocks() const { return ordered_blocks_; } -vector& Function::ordered_blocks() { return ordered_blocks_; } +std::vector& Function::ordered_blocks() { return ordered_blocks_; } const BasicBlock* Function::current_block() const { return current_block_; } BasicBlock* Function::current_block() { return current_block_; } -const list& Function::constructs() const { return cfg_constructs_; } -list& Function::constructs() { return cfg_constructs_; } +const std::list& Function::constructs() const { + return cfg_constructs_; +} +std::list& Function::constructs() { return cfg_constructs_; } const BasicBlock* Function::first_block() const { if (ordered_blocks_.empty()) return nullptr; @@ -219,30 +214,31 @@ BasicBlock* Function::first_block() { bool Function::IsBlockType(uint32_t merge_block_id, BlockType type) const { bool ret = false; const BasicBlock* block; - tie(block, ignore) = GetBlock(merge_block_id); + std::tie(block, std::ignore) = GetBlock(merge_block_id); if (block) { ret = block->is_type(type); } return ret; } -pair Function::GetBlock(uint32_t block_id) const { +std::pair Function::GetBlock(uint32_t block_id) const { const auto b = blocks_.find(block_id); if (b != end(blocks_)) { const BasicBlock* block = &(b->second); bool defined = - undefined_blocks_.find(block->id()) == end(undefined_blocks_); - return make_pair(block, defined); + undefined_blocks_.find(block->id()) == std::end(undefined_blocks_); + return std::make_pair(block, defined); } else { - return make_pair(nullptr, false); + return std::make_pair(nullptr, false); } } -pair Function::GetBlock(uint32_t block_id) { +std::pair Function::GetBlock(uint32_t block_id) { const BasicBlock* out; bool defined; - tie(out, defined) = const_cast(this)->GetBlock(block_id); - return make_pair(const_cast(out), defined); + std::tie(out, defined) = + const_cast(this)->GetBlock(block_id); + return std::make_pair(const_cast(out), defined); } Function::GetBlocksFunction Function::AugmentedCFGSuccessorsFunction() const { diff --git a/source/val/instruction.cpp b/source/val/instruction.cpp index 1e2bb76ad..692ba1a22 100644 --- a/source/val/instruction.cpp +++ b/source/val/instruction.cpp @@ -16,8 +16,6 @@ #include -using std::make_pair; - namespace spvtools { namespace val { @@ -47,7 +45,7 @@ Instruction::Instruction(const spv_parsed_instruction_t* inst, uses_() {} void Instruction::RegisterUse(const Instruction* inst, uint32_t index) { - uses_.push_back(make_pair(inst, index)); + uses_.push_back(std::make_pair(inst, index)); } } // namespace val diff --git a/source/val/validate.cpp b/source/val/validate.cpp index 74627a220..7c586c36f 100644 --- a/source/val/validate.cpp +++ b/source/val/validate.cpp @@ -42,14 +42,6 @@ #include "source/val/validation_state.h" #include "spirv-tools/libspirv.h" -using std::function; -using std::ostream_iterator; -using std::string; -using std::stringstream; -using std::transform; -using std::vector; -using std::placeholders::_1; - namespace spvtools { namespace val { namespace { @@ -165,7 +157,7 @@ spv_result_t ProcessInstruction(void* user_data, } void printDot(const ValidationState_t& _, const BasicBlock& other) { - string block_string; + std::string block_string; if (other.successors()->empty()) { block_string += "end "; } else { @@ -199,7 +191,7 @@ void PrintBlocks(ValidationState_t& _, Function func) { UNUSED(void PrintDotGraph(ValidationState_t& _, Function func)) { if (func.first_block()) { - string func_name(_.getIdOrName(func.id())); + std::string func_name(_.getIdOrName(func.id())); printf("digraph %s {\n", func_name.c_str()); PrintBlocks(_, func); printf("}\n"); @@ -261,11 +253,13 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( // module. Use the information from the ProcessInstruction pass to make the // checks. if (vstate->unresolved_forward_id_count() > 0) { - stringstream ss; - vector ids = vstate->UnresolvedForwardIds(); + std::stringstream ss; + std::vector ids = vstate->UnresolvedForwardIds(); - transform(begin(ids), end(ids), ostream_iterator(ss, " "), - bind(&ValidationState_t::getIdName, std::ref(*vstate), _1)); + transform(std::begin(ids), std::end(ids), + std::ostream_iterator(ss, " "), + bind(&ValidationState_t::getIdName, std::ref(*vstate), + std::placeholders::_1)); auto id_str = ss.str(); return vstate->diag(SPV_ERROR_INVALID_ID, nullptr) diff --git a/source/val/validate_cfg.cpp b/source/val/validate_cfg.cpp index 9ed450469..e369d06eb 100644 --- a/source/val/validate_cfg.cpp +++ b/source/val/validate_cfg.cpp @@ -33,22 +33,6 @@ #include "source/val/function.h" #include "source/val/validation_state.h" -using std::find; -using std::function; -using std::get; -using std::ignore; -using std::make_pair; -using std::make_tuple; -using std::numeric_limits; -using std::pair; -using std::string; -using std::tie; -using std::transform; -using std::tuple; -using std::unordered_map; -using std::unordered_set; -using std::vector; - namespace spvtools { namespace val { @@ -86,13 +70,14 @@ spv_result_t MergeBlockAssert(ValidationState_t& _, uint32_t merge_block) { /// Update the continue construct's exit blocks once the backedge blocks are /// identified in the CFG. void UpdateContinueConstructExitBlocks( - Function& function, const vector>& back_edges) { + Function& function, + const std::vector>& back_edges) { auto& constructs = function.constructs(); // TODO(umar): Think of a faster way to do this for (auto& edge : back_edges) { uint32_t back_edge_block_id; uint32_t loop_header_block_id; - tie(back_edge_block_id, loop_header_block_id) = edge; + std::tie(back_edge_block_id, loop_header_block_id) = edge; auto is_this_header = [=](Construct& c) { return c.type() == ConstructType::kLoop && c.entry_block()->id() == loop_header_block_id; @@ -105,15 +90,17 @@ void UpdateContinueConstructExitBlocks( assert(continue_construct->type() == ConstructType::kContinue); BasicBlock* back_edge_block; - tie(back_edge_block, ignore) = function.GetBlock(back_edge_block_id); + std::tie(back_edge_block, std::ignore) = + function.GetBlock(back_edge_block_id); continue_construct->set_exit(back_edge_block); } } } } -tuple ConstructNames(ConstructType type) { - string construct_name, header_name, exit_name; +std::tuple ConstructNames( + ConstructType type) { + std::string construct_name, header_name, exit_name; switch (type) { case ConstructType::kSelection: @@ -140,16 +127,16 @@ tuple ConstructNames(ConstructType type) { assert(1 == 0 && "Not defined type"); } - return make_tuple(construct_name, header_name, exit_name); + return std::make_tuple(construct_name, header_name, exit_name); } /// Constructs an error message for construct validation errors -string ConstructErrorString(const Construct& construct, - const string& header_string, - const string& exit_string, - const string& dominate_text) { - string construct_name, header_name, exit_name; - tie(construct_name, header_name, exit_name) = +std::string ConstructErrorString(const Construct& construct, + const std::string& header_string, + const std::string& exit_string, + const std::string& dominate_text) { + std::string construct_name, header_name, exit_name; + std::tie(construct_name, header_name, exit_name) = ConstructNames(construct.type()); // TODO(umar): Add header block for continue constructs to error message @@ -319,7 +306,7 @@ spv_result_t StructuredSwitchChecks(const ValidationState_t& _, spv_result_t StructuredControlFlowChecks( const ValidationState_t& _, Function* function, - const vector>& back_edges) { + const std::vector>& back_edges) { /// Check all backedges target only loop headers and have exactly one /// back-edge branching to it @@ -328,7 +315,7 @@ spv_result_t StructuredControlFlowChecks( for (auto back_edge : back_edges) { uint32_t back_edge_block; uint32_t header_block; - tie(back_edge_block, header_block) = back_edge; + std::tie(back_edge_block, header_block) = back_edge; if (!function->IsBlockType(header_block, kBlockTypeLoop)) { return _.diag(SPV_ERROR_INVALID_CFG, _.FindDef(back_edge_block)) << "Back-edges (" << _.getIdName(back_edge_block) << " -> " @@ -358,8 +345,8 @@ spv_result_t StructuredControlFlowChecks( auto merge = construct.exit_block(); if (header->reachable() && !merge) { - string construct_name, header_name, exit_name; - tie(construct_name, header_name, exit_name) = + std::string construct_name, header_name, exit_name; + std::tie(construct_name, header_name, exit_name) = ConstructNames(construct.type()); return _.diag(SPV_ERROR_INTERNAL, _.FindDef(header->id())) << "Construct " + construct_name + " with " + header_name + " " + @@ -403,8 +390,8 @@ spv_result_t StructuredControlFlowChecks( if (block == header) continue; for (auto pred : *block->predecessors()) { if (pred->reachable() && !construct_blocks.count(pred)) { - string construct_name, header_name, exit_name; - tie(construct_name, header_name, exit_name) = + std::string construct_name, header_name, exit_name; + std::tie(construct_name, header_name, exit_name) = ConstructNames(construct.type()); return _.diag(SPV_ERROR_INVALID_CFG, _.FindDef(pred->id())) << "block " << pred->id() << " branches to the " @@ -431,7 +418,7 @@ spv_result_t PerformCfgChecks(ValidationState_t& _) { for (auto& function : _.functions()) { // Check all referenced blocks are defined within a function if (function.undefined_block_count() != 0) { - string undef_blocks("{"); + std::string undef_blocks("{"); bool first = true; for (auto undefined_block : function.undefined_blocks()) { undef_blocks += _.getIdName(undefined_block); @@ -452,9 +439,9 @@ spv_result_t PerformCfgChecks(ValidationState_t& _) { // We want to analyze all the blocks in the function, even in degenerate // control flow cases including unreachable blocks. So use the augmented // CFG to ensure we cover all the blocks. - vector postorder; - vector postdom_postorder; - vector> back_edges; + std::vector postorder; + std::vector postdom_postorder; + std::vector> back_edges; auto ignore_block = [](const BasicBlock*) {}; auto ignore_edge = [](const BasicBlock*, const BasicBlock*) {}; if (!function.ordered_blocks().empty()) { @@ -575,7 +562,7 @@ spv_result_t CfgPass(ValidationState_t& _, const Instruction* inst) { } break; case SpvOpSwitch: { - vector cases; + std::vector cases; for (size_t i = 1; i < inst->operands().size(); i += 2) { uint32_t target = inst->GetOperandAs(i); CFG_ASSERT(FirstBlockAssert, target); @@ -596,7 +583,7 @@ spv_result_t CfgPass(ValidationState_t& _, const Instruction* inst) { case SpvOpKill: case SpvOpReturnValue: case SpvOpUnreachable: - _.current_function().RegisterBlockEnd(vector(), opcode); + _.current_function().RegisterBlockEnd(std::vector(), opcode); if (opcode == SpvOpKill) { _.current_function().RegisterExecutionModelLimitation( SpvExecutionModelFragment, diff --git a/source/val/validate_decorations.cpp b/source/val/validate_decorations.cpp index a539ea775..2f0d007d9 100644 --- a/source/val/validate_decorations.cpp +++ b/source/val/validate_decorations.cpp @@ -30,8 +30,6 @@ namespace spvtools { namespace val { namespace { -using std::make_pair; - // Distinguish between row and column major matrix layouts. enum MatrixLayout { kRowMajor, kColumnMajor }; @@ -200,7 +198,8 @@ uint32_t getBaseAlignment(uint32_t member_id, bool roundUp, for (uint32_t memberIdx = 0, numMembers = uint32_t(members.size()); memberIdx < numMembers; ++memberIdx) { const auto id = members[memberIdx]; - const auto& constraint = constraints[make_pair(member_id, memberIdx)]; + const auto& constraint = + constraints[std::make_pair(member_id, memberIdx)]; baseAlignment = std::max( baseAlignment, getBaseAlignment(id, roundUp, constraint, constraints, vstate)); @@ -284,7 +283,7 @@ uint32_t getSize(uint32_t member_id, bool roundUp, // This check depends on the fact that all members have offsets. This // has been checked earlier in the flow. assert(offset != 0xffffffff); - const auto& constraint = constraints[make_pair(lastMember, lastIdx)]; + const auto& constraint = constraints[std::make_pair(lastMember, lastIdx)]; return offset + getSize(lastMember, roundUp, constraint, constraints, vstate); } @@ -390,7 +389,7 @@ spv_result_t checkLayout(uint32_t struct_id, const char* storage_class_str, const auto offset = member_offset.offset; auto id = members[member_offset.member]; const LayoutConstraints& constraint = - constraints[make_pair(struct_id, uint32_t(memberIdx))]; + constraints[std::make_pair(struct_id, uint32_t(memberIdx))]; const auto alignment = getBaseAlignment(id, blockRules, constraint, constraints, vstate); const auto inst = vstate.FindDef(id); @@ -718,7 +717,7 @@ void ComputeMemberConstraintsForStruct(MemberConstraints* constraints, for (uint32_t memberIdx = 0, numMembers = uint32_t(members.size()); memberIdx < numMembers; memberIdx++) { LayoutConstraints& constraint = - (*constraints)[make_pair(struct_id, memberIdx)]; + (*constraints)[std::make_pair(struct_id, memberIdx)]; constraint = inherited; for (auto& decoration : vstate.id_decorations(struct_id)) { if (decoration.struct_member_index() == (int)memberIdx) { diff --git a/source/val/validate_id.cpp b/source/val/validate_id.cpp index 6cc1a5c86..d00cef552 100644 --- a/source/val/validate_id.cpp +++ b/source/val/validate_id.cpp @@ -34,13 +34,6 @@ #include "source/val/validation_state.h" #include "spirv-tools/libspirv.h" -using std::function; -using std::ignore; -using std::make_pair; -using std::pair; -using std::unordered_set; -using std::vector; - namespace spvtools { namespace val { namespace { @@ -50,8 +43,9 @@ class idUsage { idUsage(spv_const_context context, const spv_instruction_t* pInsts, const uint64_t instCountArg, const SpvMemoryModel memoryModelArg, const SpvAddressingModel addressingModelArg, - const ValidationState_t& module, const vector& entry_points, - spv_position positionArg, const MessageConsumer& consumer) + const ValidationState_t& module, + const std::vector& entry_points, spv_position positionArg, + const MessageConsumer& consumer) : targetEnv(context->target_env), opcodeTable(context->opcode_table), operandTable(context->operand_table), @@ -82,7 +76,7 @@ class idUsage { spv_position position; const MessageConsumer& consumer_; const ValidationState_t& module_; - vector entry_points_; + std::vector entry_points_; // Returns true if the two instructions represent structs that, as far as the // validator can tell, have the exact same data layout. @@ -101,8 +95,8 @@ class idUsage { bool HaveSameLayoutDecorations(const Instruction* type1, const Instruction* type2); bool HasConflictingMemberOffsets( - const vector& type1_decorations, - const vector& type2_decorations) const; + const std::vector& type1_decorations, + const std::vector& type2_decorations) const; }; #define DIAG(inst) \ @@ -367,8 +361,8 @@ bool idUsage::isValid(const spv_instruction_t*, // constant-defining instruction (either OpConstant or // OpSpecConstant). typeWords are the words of the constant's-type-defining // OpTypeInt. -bool aboveZero(const vector& constWords, - const vector& typeWords) { +bool aboveZero(const std::vector& constWords, + const std::vector& typeWords) { const uint32_t width = typeWords[2]; const bool is_signed = typeWords[3] > 0; const uint32_t loWord = constWords[3]; @@ -807,7 +801,7 @@ bool idUsage::isValid(const spv_instruction_t* inst, // True if instruction defines a type that can have a null value, as defined by // the SPIR-V spec. Tracks composite-type components through module to check // nullability transitively. -bool IsTypeNullable(const vector& instruction, +bool IsTypeNullable(const std::vector& instruction, const ValidationState_t& module) { uint16_t opcode; uint16_t word_count; @@ -2009,8 +2003,8 @@ bool idUsage::HaveSameLayoutDecorations(const Instruction* type1, } bool idUsage::HasConflictingMemberOffsets( - const vector& type1_decorations, - const vector& type2_decorations) const { + const std::vector& type1_decorations, + const std::vector& type2_decorations) const { { // We are interested in conflicting decoration. If a decoration is in one // list but not the other, then we will assume the code is correct. We are @@ -2071,7 +2065,7 @@ spv_result_t UpdateIdUse(ValidationState_t& _) { /// NOTE: This function does NOT check module scoped functions which are /// checked during the initial binary parse in the IdPass below spv_result_t CheckIdDefinitionDominateUse(const ValidationState_t& _) { - unordered_set phi_instructions; + std::unordered_set phi_instructions; for (const auto& definition : _.all_definitions()) { // Check only those definitions defined in a function if (const Function* func = definition.second->function()) { diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp index 4b17732e3..8db20fe99 100644 --- a/source/val/validation_state.cpp +++ b/source/val/validation_state.cpp @@ -242,7 +242,7 @@ std::string ValidationState_t::getIdName(uint32_t id) const { std::string ValidationState_t::getIdOrName(uint32_t id) const { std::stringstream out; - if (operand_names_.find(id) != end(operand_names_)) { + if (operand_names_.find(id) != std::end(operand_names_)) { out << operand_names_.at(id); } else { out << id; @@ -261,7 +261,7 @@ std::vector ValidationState_t::UnresolvedForwardIds() const { } bool ValidationState_t::IsDefinedId(uint32_t id) const { - return all_definitions_.find(id) != end(all_definitions_); + return all_definitions_.find(id) != std::end(all_definitions_); } const Instruction* ValidationState_t::FindDef(uint32_t id) const { diff --git a/test/binary_to_text_test.cpp b/test/binary_to_text_test.cpp index 93e46a419..291b0e186 100644 --- a/test/binary_to_text_test.cpp +++ b/test/binary_to_text_test.cpp @@ -27,8 +27,6 @@ namespace { using spvtest::AutoText; using spvtest::ScopedContext; using spvtest::TextToBinaryTest; -using std::get; -using std::tuple; using ::testing::Combine; using ::testing::Eq; using ::testing::HasSubstr; @@ -227,13 +225,13 @@ OpExecutionMode %1 LocalSizeHint 100 200 300 } using RoundTripInstructionsTest = spvtest::TextToBinaryTestBase< - ::testing::TestWithParam>>; + ::testing::TestWithParam>>; TEST_P(RoundTripInstructionsTest, Sample) { - EXPECT_THAT(EncodeAndDecodeSuccessfully(get<1>(GetParam()), + EXPECT_THAT(EncodeAndDecodeSuccessfully(std::get<1>(GetParam()), SPV_BINARY_TO_TEXT_OPTION_NONE, - get<0>(GetParam())), - Eq(get<1>(GetParam()))); + std::get<0>(GetParam())), + Eq(std::get<1>(GetParam()))); } // clang-format off diff --git a/test/operand_capabilities_test.cpp b/test/operand_capabilities_test.cpp index 49934cfb7..baf4f9522 100644 --- a/test/operand_capabilities_test.cpp +++ b/test/operand_capabilities_test.cpp @@ -25,8 +25,6 @@ namespace spvtools { namespace { using spvtest::ElementsIn; -using std::get; -using std::tuple; using ::testing::Combine; using ::testing::Eq; using ::testing::TestWithParam; @@ -42,23 +40,23 @@ struct EnumCapabilityCase { // Test fixture for testing EnumCapabilityCases. using EnumCapabilityTest = - TestWithParam>; + TestWithParam>; TEST_P(EnumCapabilityTest, Sample) { - const auto env = get<0>(GetParam()); + const auto env = std::get<0>(GetParam()); const auto context = spvContextCreate(env); const AssemblyGrammar grammar(context); spv_operand_desc entry; ASSERT_EQ(SPV_SUCCESS, - grammar.lookupOperand(get<1>(GetParam()).type, - get<1>(GetParam()).value, &entry)); + grammar.lookupOperand(std::get<1>(GetParam()).type, + std::get<1>(GetParam()).value, &entry)); const auto cap_set = grammar.filterCapsAgainstTargetEnv( entry->capabilities, entry->numCapabilities); EXPECT_THAT(ElementsIn(cap_set), - Eq(ElementsIn(get<1>(GetParam()).expected_capabilities))) - << " capability value " << get<1>(GetParam()).value; + Eq(ElementsIn(std::get<1>(GetParam()).expected_capabilities))) + << " capability value " << std::get<1>(GetParam()).value; spvContextDestroy(context); } diff --git a/test/operand_test.cpp b/test/operand_test.cpp index 2e29bdc17..be927d663 100644 --- a/test/operand_test.cpp +++ b/test/operand_test.cpp @@ -18,7 +18,6 @@ namespace spvtools { namespace { using GetTargetTest = ::testing::TestWithParam; -using std::vector; using ::testing::ValuesIn; TEST_P(GetTargetTest, Default) { @@ -33,9 +32,9 @@ TEST_P(GetTargetTest, InvalidPointerTable) { } INSTANTIATE_TEST_CASE_P(OperandTableGet, GetTargetTest, - ValuesIn(vector{SPV_ENV_UNIVERSAL_1_0, - SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_VULKAN_1_0}), ); + ValuesIn(std::vector{ + SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, + SPV_ENV_VULKAN_1_0}), ); TEST(OperandString, AllAreDefinedExceptVariable) { // None has no string, so don't test it. diff --git a/test/text_to_binary.annotation_test.cpp b/test/text_to_binary.annotation_test.cpp index 94e2db1e1..27df121f5 100644 --- a/test/text_to_binary.annotation_test.cpp +++ b/test/text_to_binary.annotation_test.cpp @@ -30,8 +30,6 @@ using spvtest::EnumCase; using spvtest::MakeInstruction; using spvtest::MakeVector; using spvtest::TextToBinaryTest; -using std::get; -using std::tuple; using ::testing::Combine; using ::testing::Eq; using ::testing::Values; @@ -39,23 +37,25 @@ using ::testing::ValuesIn; // Test OpDecorate -using OpDecorateSimpleTest = spvtest::TextToBinaryTestBase< - ::testing::TestWithParam>>>; +using OpDecorateSimpleTest = + spvtest::TextToBinaryTestBase<::testing::TestWithParam< + std::tuple>>>; TEST_P(OpDecorateSimpleTest, AnySimpleDecoration) { // This string should assemble, but should not validate. std::stringstream input; - input << "OpDecorate %1 " << get<1>(GetParam()).name(); - for (auto operand : get<1>(GetParam()).operands()) input << " " << operand; + input << "OpDecorate %1 " << std::get<1>(GetParam()).name(); + for (auto operand : std::get<1>(GetParam()).operands()) + input << " " << operand; input << std::endl; - EXPECT_THAT(CompiledInstructions(input.str(), get<0>(GetParam())), + EXPECT_THAT(CompiledInstructions(input.str(), std::get<0>(GetParam())), Eq(MakeInstruction(SpvOpDecorate, - {1, uint32_t(get<1>(GetParam()).value())}, - get<1>(GetParam()).operands()))); + {1, uint32_t(std::get<1>(GetParam()).value())}, + std::get<1>(GetParam()).operands()))); // Also check disassembly. EXPECT_THAT( EncodeAndDecodeSuccessfully(input.str(), SPV_BINARY_TO_TEXT_OPTION_NONE, - get<0>(GetParam())), + std::get<0>(GetParam())), Eq(input.str())); } @@ -398,23 +398,26 @@ TEST_F(TextToBinaryTest, GroupMemberDecorateInvalidSecondTargetMemberNumber) { // Test OpMemberDecorate -using OpMemberDecorateSimpleTest = spvtest::TextToBinaryTestBase< - ::testing::TestWithParam>>>; +using OpMemberDecorateSimpleTest = + spvtest::TextToBinaryTestBase<::testing::TestWithParam< + std::tuple>>>; TEST_P(OpMemberDecorateSimpleTest, AnySimpleDecoration) { // This string should assemble, but should not validate. std::stringstream input; - input << "OpMemberDecorate %1 42 " << get<1>(GetParam()).name(); - for (auto operand : get<1>(GetParam()).operands()) input << " " << operand; + input << "OpMemberDecorate %1 42 " << std::get<1>(GetParam()).name(); + for (auto operand : std::get<1>(GetParam()).operands()) + input << " " << operand; input << std::endl; - EXPECT_THAT(CompiledInstructions(input.str(), get<0>(GetParam())), - Eq(MakeInstruction(SpvOpMemberDecorate, - {1, 42, uint32_t(get<1>(GetParam()).value())}, - get<1>(GetParam()).operands()))); + EXPECT_THAT( + CompiledInstructions(input.str(), std::get<0>(GetParam())), + Eq(MakeInstruction(SpvOpMemberDecorate, + {1, 42, uint32_t(std::get<1>(GetParam()).value())}, + std::get<1>(GetParam()).operands()))); // Also check disassembly. EXPECT_THAT( EncodeAndDecodeSuccessfully(input.str(), SPV_BINARY_TO_TEXT_OPTION_NONE, - get<0>(GetParam())), + std::get<0>(GetParam())), Eq(input.str())); } diff --git a/test/text_to_binary.control_flow_test.cpp b/test/text_to_binary.control_flow_test.cpp index c94f961a7..df8386750 100644 --- a/test/text_to_binary.control_flow_test.cpp +++ b/test/text_to_binary.control_flow_test.cpp @@ -31,9 +31,6 @@ using spvtest::Concatenate; using spvtest::EnumCase; using spvtest::MakeInstruction; using spvtest::TextToBinaryTest; -using std::get; -using std::ostringstream; -using std::tuple; using ::testing::Combine; using ::testing::Eq; using ::testing::TestWithParam; @@ -80,14 +77,14 @@ TEST_F(OpSelectionMergeTest, WrongSelectionControl) { // Test OpLoopMerge using OpLoopMergeTest = spvtest::TextToBinaryTestBase< - TestWithParam>>>; + TestWithParam>>>; TEST_P(OpLoopMergeTest, AnySingleLoopControlMask) { - const auto ctrl = get<1>(GetParam()); - ostringstream input; + const auto ctrl = std::get<1>(GetParam()); + std::ostringstream input; input << "OpLoopMerge %merge %continue " << ctrl.name(); for (auto num : ctrl.operands()) input << " " << num; - EXPECT_THAT(CompiledInstructions(input.str(), get<0>(GetParam())), + EXPECT_THAT(CompiledInstructions(input.str(), std::get<0>(GetParam())), Eq(MakeInstruction(SpvOpLoopMerge, {1, 2, ctrl.value()}, ctrl.operands()))); } diff --git a/test/text_to_binary.mode_setting_test.cpp b/test/text_to_binary.mode_setting_test.cpp index 309682be5..ad4629b99 100644 --- a/test/text_to_binary.mode_setting_test.cpp +++ b/test/text_to_binary.mode_setting_test.cpp @@ -26,8 +26,6 @@ namespace { using spvtest::EnumCase; using spvtest::MakeInstruction; using spvtest::MakeVector; -using std::get; -using std::tuple; using ::testing::Combine; using ::testing::Eq; using ::testing::TestWithParam; @@ -135,17 +133,18 @@ TEST_F(OpEntryPointTest, WrongModel) { // Test OpExecutionMode using OpExecutionModeTest = spvtest::TextToBinaryTestBase< - TestWithParam>>>; + TestWithParam>>>; TEST_P(OpExecutionModeTest, AnyExecutionMode) { // This string should assemble, but should not validate. std::stringstream input; - input << "OpExecutionMode %1 " << get<1>(GetParam()).name(); - for (auto operand : get<1>(GetParam()).operands()) input << " " << operand; - EXPECT_THAT( - CompiledInstructions(input.str(), get<0>(GetParam())), - Eq(MakeInstruction(SpvOpExecutionMode, {1, get<1>(GetParam()).value()}, - get<1>(GetParam()).operands()))); + input << "OpExecutionMode %1 " << std::get<1>(GetParam()).name(); + for (auto operand : std::get<1>(GetParam()).operands()) + input << " " << operand; + EXPECT_THAT(CompiledInstructions(input.str(), std::get<0>(GetParam())), + Eq(MakeInstruction(SpvOpExecutionMode, + {1, std::get<1>(GetParam()).value()}, + std::get<1>(GetParam()).operands()))); } #define CASE(NAME) SpvExecutionMode##NAME, #NAME diff --git a/test/text_to_binary.subgroup_dispatch_test.cpp b/test/text_to_binary.subgroup_dispatch_test.cpp index fed43477f..10aa77cf9 100644 --- a/test/text_to_binary.subgroup_dispatch_test.cpp +++ b/test/text_to_binary.subgroup_dispatch_test.cpp @@ -24,7 +24,6 @@ namespace spvtools { namespace { using ::spvtest::MakeInstruction; -using std::vector; using ::testing::Eq; using OpGetKernelLocalSizeForSubgroupCountTest = spvtest::TextToBinaryTest; diff --git a/test/val/val_arithmetics_test.cpp b/test/val/val_arithmetics_test.cpp index 4e5deafc8..73174e29d 100644 --- a/test/val/val_arithmetics_test.cpp +++ b/test/val/val_arithmetics_test.cpp @@ -27,8 +27,6 @@ namespace { using ::testing::HasSubstr; using ::testing::Not; -using std::string; - using ValidateArithmetics = spvtest::ValidateBase; std::string GenerateCode(const std::string& main_body) { diff --git a/test/val/val_capability_test.cpp b/test/val/val_capability_test.cpp index eb5f962a6..b1d6dc312 100644 --- a/test/val/val_capability_test.cpp +++ b/test/val/val_capability_test.cpp @@ -32,23 +32,16 @@ namespace val { namespace { using spvtest::ScopedContext; -using std::get; -using std::make_pair; -using std::ostringstream; -using std::pair; -using std::string; -using std::tuple; -using std::vector; using testing::Combine; using testing::HasSubstr; using testing::Values; using testing::ValuesIn; -// Parameter for validation test fixtures. The first string is a capability -// name that will begin the assembly under test, the second the remainder -// assembly, and the vector at the end determines whether the test expects -// success or failure. See below for details and convenience methods to access -// each one. +// Parameter for validation test fixtures. The first std::string is a +// capability name that will begin the assembly under test, the second the +// remainder assembly, and the std::vector at the end determines whether the +// test expects success or failure. See below for details and convenience +// methods to access each one. // // The assembly to test is composed from a variable top line and a fixed // remainder. The top line will be an OpCapability instruction, while the @@ -66,27 +59,32 @@ using testing::ValuesIn; // // So how does the test parameter capture which capabilities should cause // success and which shouldn't? The answer is in the last element: it's a -// vector of capabilities that make the remainder assembly succeed. So if the -// first-line capability exists in that vector, success is expected; otherwise, -// failure is expected in the tests. +// std::vector of capabilities that make the remainder assembly succeed. So if +// the first-line capability exists in that std::vector, success is expected; +// otherwise, failure is expected in the tests. // // We will use testing::Combine() to vary the first line: when we combine // AllCapabilities() with a single remainder assembly, we generate enough test // cases to try the assembly with every possible capability that could be // declared. However, Combine() only produces tuples -- it cannot produce, say, // a struct. Therefore, this type must be a tuple. -using CapTestParameter = tuple>>; +using CapTestParameter = + std::tuple>>; -const string& Capability(const CapTestParameter& p) { return get<0>(p); } -const string& Remainder(const CapTestParameter& p) { return get<1>(p).first; } -const vector& MustSucceed(const CapTestParameter& p) { - return get<1>(p).second; +const std::string& Capability(const CapTestParameter& p) { + return std::get<0>(p); +} +const std::string& Remainder(const CapTestParameter& p) { + return std::get<1>(p).first; +} +const std::vector& MustSucceed(const CapTestParameter& p) { + return std::get<1>(p).second; } // Creates assembly to test from p. -string MakeAssembly(const CapTestParameter& p) { - ostringstream ss; - const string& capability = Capability(p); +std::string MakeAssembly(const CapTestParameter& p) { + std::ostringstream ss; + const std::string& capability = Capability(p); if (!capability.empty()) { ss << "OpCapability " << capability << "\n"; } @@ -131,8 +129,8 @@ TEST_F(ValidateCapability, Default) { } // clang-format off -const vector& AllCapabilities() { - static const auto r = new vector{ +const std::vector& AllCapabilities() { + static const auto r = new std::vector{ "", "Matrix", "Shader", @@ -215,8 +213,8 @@ const vector& AllCapabilities() { return *r; } -const vector& AllSpirV10Capabilities() { - static const auto r = new vector{ +const std::vector& AllSpirV10Capabilities() { + static const auto r = new std::vector{ "", "Matrix", "Shader", @@ -277,8 +275,8 @@ const vector& AllSpirV10Capabilities() { return *r; } -const vector& AllVulkan10Capabilities() { - static const auto r = new vector{ +const std::vector& AllVulkan10Capabilities() { + static const auto r = new std::vector{ "", "Matrix", "Shader", @@ -318,8 +316,8 @@ const vector& AllVulkan10Capabilities() { return *r; } -const vector& AllVulkan11Capabilities() { - static const auto r = new vector{ +const std::vector& AllVulkan11Capabilities() { + static const auto r = new std::vector{ "", "Matrix", "Shader", @@ -378,8 +376,8 @@ const vector& AllVulkan11Capabilities() { return *r; } -const vector& MatrixDependencies() { - static const auto r = new vector{ +const std::vector& MatrixDependencies() { + static const auto r = new std::vector{ "Matrix", "Shader", "Geometry", @@ -420,8 +418,8 @@ const vector& MatrixDependencies() { return *r; } -const vector& ShaderDependencies() { - static const auto r = new vector{ +const std::vector& ShaderDependencies() { + static const auto r = new std::vector{ "Shader", "Geometry", "Tessellation", @@ -461,15 +459,15 @@ const vector& ShaderDependencies() { return *r; } -const vector& TessellationDependencies() { - static const auto r = new vector{ +const std::vector& TessellationDependencies() { + static const auto r = new std::vector{ "Tessellation", "TessellationPointSize"}; return *r; } -const vector& GeometryDependencies() { - static const auto r = new vector{ +const std::vector& GeometryDependencies() { + static const auto r = new std::vector{ "Geometry", "GeometryPointSize", "GeometryStreams", @@ -477,8 +475,8 @@ const vector& GeometryDependencies() { return *r; } -const vector& GeometryTessellationDependencies() { - static const auto r = new vector{ +const std::vector& GeometryTessellationDependencies() { + static const auto r = new std::vector{ "Tessellation", "TessellationPointSize", "Geometry", @@ -490,8 +488,8 @@ const vector& GeometryTessellationDependencies() { // Returns the names of capabilities that directly depend on Kernel, // plus itself. -const vector& KernelDependencies() { - static const auto r = new vector{ +const std::vector& KernelDependencies() { + static const auto r = new std::vector{ "Kernel", "Vector16", "Float16Buffer", @@ -507,8 +505,8 @@ const vector& KernelDependencies() { return *r; } -const vector& KernelAndGroupNonUniformDependencies() { - static const auto r = new vector{ +const std::vector& KernelAndGroupNonUniformDependencies() { + static const auto r = new std::vector{ "Kernel", "Vector16", "Float16Buffer", @@ -532,29 +530,29 @@ const vector& KernelAndGroupNonUniformDependencies() { return *r; } -const vector& AddressesDependencies() { - static const auto r = new vector{ +const std::vector& AddressesDependencies() { + static const auto r = new std::vector{ "Addresses", "GenericPointer"}; return *r; } -const vector& Sampled1DDependencies() { - static const auto r = new vector{ +const std::vector& Sampled1DDependencies() { + static const auto r = new std::vector{ "Sampled1D", "Image1D"}; return *r; } -const vector& SampledRectDependencies() { - static const auto r = new vector{ +const std::vector& SampledRectDependencies() { + static const auto r = new std::vector{ "SampledRect", "ImageRect"}; return *r; } -const vector& SampledBufferDependencies() { - static const auto r = new vector{ +const std::vector& SampledBufferDependencies() { + static const auto r = new std::vector{ "SampledBuffer", "ImageBuffer"}; return *r; @@ -587,289 +585,289 @@ INSTANTIATE_TEST_CASE_P(ExecutionModel, ValidateCapability, Combine( ValuesIn(AllCapabilities()), Values( -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint Vertex %func \"shader\"" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint TessellationControl %func \"shader\"" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint TessellationEvaluation %func \"shader\"" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint Geometry %func \"shader\"" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint Fragment %func \"shader\"" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint GLCompute %func \"shader\"" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kGLSL450MemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Kernel %func \"shader\"" + - string(kVoidFVoid), KernelDependencies()) + std::string(kVoidFVoid), KernelDependencies()) )),); INSTANTIATE_TEST_CASE_P(AddressingAndMemoryModel, ValidateCapability, Combine( ValuesIn(AllCapabilities()), Values( -make_pair(" OpCapability Shader" +std::make_pair(" OpCapability Shader" " OpMemoryModel Logical Simple" " OpEntryPoint Vertex %func \"shader\"" + - string(kVoidFVoid), AllCapabilities()), -make_pair(" OpCapability Shader" + std::string(kVoidFVoid), AllCapabilities()), +std::make_pair(" OpCapability Shader" " OpMemoryModel Logical GLSL450" " OpEntryPoint Vertex %func \"shader\"" + - string(kVoidFVoid), AllCapabilities()), -make_pair(" OpCapability Kernel" + std::string(kVoidFVoid), AllCapabilities()), +std::make_pair(" OpCapability Kernel" " OpMemoryModel Logical OpenCL" " OpEntryPoint Kernel %func \"compute\"" + - string(kVoidFVoid), AllCapabilities()), -make_pair(" OpCapability Shader" + std::string(kVoidFVoid), AllCapabilities()), +std::make_pair(" OpCapability Shader" " OpMemoryModel Physical32 Simple" " OpEntryPoint Vertex %func \"shader\"" + - string(kVoidFVoid), AddressesDependencies()), -make_pair(" OpCapability Shader" + std::string(kVoidFVoid), AddressesDependencies()), +std::make_pair(" OpCapability Shader" " OpMemoryModel Physical32 GLSL450" " OpEntryPoint Vertex %func \"shader\"" + - string(kVoidFVoid), AddressesDependencies()), -make_pair(" OpCapability Kernel" + std::string(kVoidFVoid), AddressesDependencies()), +std::make_pair(" OpCapability Kernel" " OpMemoryModel Physical32 OpenCL" " OpEntryPoint Kernel %func \"compute\"" + - string(kVoidFVoid), AddressesDependencies()), -make_pair(" OpCapability Shader" + std::string(kVoidFVoid), AddressesDependencies()), +std::make_pair(" OpCapability Shader" " OpMemoryModel Physical64 Simple" " OpEntryPoint Vertex %func \"shader\"" + - string(kVoidFVoid), AddressesDependencies()), -make_pair(" OpCapability Shader" + std::string(kVoidFVoid), AddressesDependencies()), +std::make_pair(" OpCapability Shader" " OpMemoryModel Physical64 GLSL450" " OpEntryPoint Vertex %func \"shader\"" + - string(kVoidFVoid), AddressesDependencies()), -make_pair(" OpCapability Kernel" + std::string(kVoidFVoid), AddressesDependencies()), +std::make_pair(" OpCapability Kernel" " OpMemoryModel Physical64 OpenCL" " OpEntryPoint Kernel %func \"compute\"" + - string(kVoidFVoid), AddressesDependencies()) + std::string(kVoidFVoid), AddressesDependencies()) )),); INSTANTIATE_TEST_CASE_P(ExecutionMode, ValidateCapability, Combine( ValuesIn(AllCapabilities()), Values( -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func Invocations 42" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func SpacingEqual" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func SpacingFractionalEven" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func SpacingFractionalOdd" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func VertexOrderCw" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func VertexOrderCcw" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Vertex %func \"shader\" " "OpExecutionMode %func PixelCenterInteger" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Vertex %func \"shader\" " "OpExecutionMode %func OriginUpperLeft" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Vertex %func \"shader\" " "OpExecutionMode %func OriginLowerLeft" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Vertex %func \"shader\" " "OpExecutionMode %func EarlyFragmentTests" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func PointMode" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Vertex %func \"shader\" " "OpExecutionMode %func Xfb" + - string(kVoidFVoid), vector{"TransformFeedback"}), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), std::vector{"TransformFeedback"}), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Vertex %func \"shader\" " "OpExecutionMode %func DepthReplacing" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Vertex %func \"shader\" " "OpExecutionMode %func DepthGreater" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Vertex %func \"shader\" " "OpExecutionMode %func DepthLess" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Vertex %func \"shader\" " "OpExecutionMode %func DepthUnchanged" + - string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), ShaderDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"shader\" " "OpExecutionMode %func LocalSize 42 42 42" + - string(kVoidFVoid), AllCapabilities()), -make_pair(string(kGLSL450MemoryModel) + + std::string(kVoidFVoid), AllCapabilities()), +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Kernel %func \"shader\" " "OpExecutionMode %func LocalSizeHint 42 42 42" + - string(kVoidFVoid), KernelDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), KernelDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func InputPoints" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func InputLines" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func InputLinesAdjacency" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func Triangles" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func Triangles" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func InputTrianglesAdjacency" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func Quads" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func Isolines" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func OutputVertices 42" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint TessellationControl %func \"shader\" " "OpExecutionMode %func OutputVertices 42" + - string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), TessellationDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func OutputPoints" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func OutputLineStrip" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Geometry %func \"shader\" " "OpExecutionMode %func OutputTriangleStrip" + - string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kGLSL450MemoryModel) + + std::string(kVoidFVoid), GeometryDependencies()), +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Kernel %func \"shader\" " "OpExecutionMode %func VecTypeHint 2" + - string(kVoidFVoid), KernelDependencies()), -make_pair(string(kGLSL450MemoryModel) + + std::string(kVoidFVoid), KernelDependencies()), +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Kernel %func \"shader\" " "OpExecutionMode %func ContractionOff" + - string(kVoidFVoid), KernelDependencies()))),); + std::string(kVoidFVoid), KernelDependencies()))),); // clang-format on INSTANTIATE_TEST_CASE_P( ExecutionModeV11, ValidateCapabilityV11, Combine(ValuesIn(AllCapabilities()), - Values(make_pair(string(kOpenCLMemoryModel) + - "OpEntryPoint Kernel %func \"shader\" " - "OpExecutionMode %func SubgroupSize 1" + - string(kVoidFVoid), - vector{"SubgroupDispatch"}), - make_pair( - string(kOpenCLMemoryModel) + + Values(std::make_pair(std::string(kOpenCLMemoryModel) + + "OpEntryPoint Kernel %func \"shader\" " + "OpExecutionMode %func SubgroupSize 1" + + std::string(kVoidFVoid), + std::vector{"SubgroupDispatch"}), + std::make_pair( + std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"shader\" " "OpExecutionMode %func SubgroupsPerWorkgroup 65535" + - string(kVoidFVoid), - vector{"SubgroupDispatch"}))), ); + std::string(kVoidFVoid), + std::vector{"SubgroupDispatch"}))), ); // clang-format off INSTANTIATE_TEST_CASE_P(StorageClass, ValidateCapability, Combine( ValuesIn(AllCapabilities()), Values( -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer UniformConstant %intt\n" - " %var = OpVariable %ptrt UniformConstant\n" + string(kVoidFVoid), + " %var = OpVariable %ptrt UniformConstant\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint Kernel %func \"compute\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer Input %intt" - " %var = OpVariable %ptrt Input\n" + string(kVoidFVoid), + " %var = OpVariable %ptrt Input\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint Vertex %func \"shader\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer Uniform %intt\n" - " %var = OpVariable %ptrt Uniform\n" + string(kVoidFVoid), + " %var = OpVariable %ptrt Uniform\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint Vertex %func \"shader\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer Output %intt\n" - " %var = OpVariable %ptrt Output\n" + string(kVoidFVoid), + " %var = OpVariable %ptrt Output\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer Workgroup %intt\n" - " %var = OpVariable %ptrt Workgroup\n" + string(kVoidFVoid), + " %var = OpVariable %ptrt Workgroup\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer CrossWorkgroup %intt\n" - " %var = OpVariable %ptrt CrossWorkgroup\n" + string(kVoidFVoid), + " %var = OpVariable %ptrt CrossWorkgroup\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint Kernel %func \"compute\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer Private %intt\n" - " %var = OpVariable %ptrt Private\n" + string(kVoidFVoid), + " %var = OpVariable %ptrt Private\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + " OpEntryPoint Kernel %func \"compute\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer PushConstant %intt\n" - " %var = OpVariable %ptrt PushConstant\n" + string(kVoidFVoid), + " %var = OpVariable %ptrt PushConstant\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer AtomicCounter %intt\n" - " %var = OpVariable %ptrt AtomicCounter\n" + string(kVoidFVoid), - vector{"AtomicStorage"}), -make_pair(string(kGLSL450MemoryModel) + + " %var = OpVariable %ptrt AtomicCounter\n" + std::string(kVoidFVoid), + std::vector{"AtomicStorage"}), +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" + " %intt = OpTypeInt 32 0\n" " %ptrt = OpTypePointer Image %intt\n" - " %var = OpVariable %ptrt Image\n" + string(kVoidFVoid), + " %var = OpVariable %ptrt Image\n" + std::string(kVoidFVoid), AllCapabilities()) )),); @@ -877,48 +875,48 @@ INSTANTIATE_TEST_CASE_P(Dim, ValidateCapability, Combine( ValuesIn(AllCapabilities()), Values( -make_pair(" OpCapability ImageBasic" + - string(kOpenCLMemoryModel) + - string(" OpEntryPoint Kernel %func \"compute\"") + +std::make_pair(" OpCapability ImageBasic" + + std::string(kOpenCLMemoryModel) + + std::string(" OpEntryPoint Kernel %func \"compute\"") + " %voidt = OpTypeVoid" - " %imgt = OpTypeImage %voidt 1D 0 0 0 0 Unknown" + string(kVoidFVoid2), + " %imgt = OpTypeImage %voidt 1D 0 0 0 0 Unknown" + std::string(kVoidFVoid2), Sampled1DDependencies()), -make_pair(" OpCapability ImageBasic" + - string(kOpenCLMemoryModel) + - string(" OpEntryPoint Kernel %func \"compute\"") + +std::make_pair(" OpCapability ImageBasic" + + std::string(kOpenCLMemoryModel) + + std::string(" OpEntryPoint Kernel %func \"compute\"") + " %voidt = OpTypeVoid" - " %imgt = OpTypeImage %voidt 2D 0 0 0 0 Unknown" + string(kVoidFVoid2), + " %imgt = OpTypeImage %voidt 2D 0 0 0 0 Unknown" + std::string(kVoidFVoid2), AllCapabilities()), -make_pair(" OpCapability ImageBasic" + - string(kOpenCLMemoryModel) + - string(" OpEntryPoint Kernel %func \"compute\"") + +std::make_pair(" OpCapability ImageBasic" + + std::string(kOpenCLMemoryModel) + + std::string(" OpEntryPoint Kernel %func \"compute\"") + " %voidt = OpTypeVoid" - " %imgt = OpTypeImage %voidt 3D 0 0 0 0 Unknown" + string(kVoidFVoid2), + " %imgt = OpTypeImage %voidt 3D 0 0 0 0 Unknown" + std::string(kVoidFVoid2), AllCapabilities()), -make_pair(" OpCapability ImageBasic" + - string(kOpenCLMemoryModel) + - string(" OpEntryPoint Kernel %func \"compute\"") + +std::make_pair(" OpCapability ImageBasic" + + std::string(kOpenCLMemoryModel) + + std::string(" OpEntryPoint Kernel %func \"compute\"") + " %voidt = OpTypeVoid" - " %imgt = OpTypeImage %voidt Cube 0 0 0 0 Unknown" + string(kVoidFVoid2), + " %imgt = OpTypeImage %voidt Cube 0 0 0 0 Unknown" + std::string(kVoidFVoid2), ShaderDependencies()), -make_pair(" OpCapability ImageBasic" + - string(kOpenCLMemoryModel) + - string(" OpEntryPoint Kernel %func \"compute\"") + +std::make_pair(" OpCapability ImageBasic" + + std::string(kOpenCLMemoryModel) + + std::string(" OpEntryPoint Kernel %func \"compute\"") + " %voidt = OpTypeVoid" - " %imgt = OpTypeImage %voidt Rect 0 0 0 0 Unknown" + string(kVoidFVoid2), + " %imgt = OpTypeImage %voidt Rect 0 0 0 0 Unknown" + std::string(kVoidFVoid2), SampledRectDependencies()), -make_pair(" OpCapability ImageBasic" + - string(kOpenCLMemoryModel) + - string(" OpEntryPoint Kernel %func \"compute\"") + +std::make_pair(" OpCapability ImageBasic" + + std::string(kOpenCLMemoryModel) + + std::string(" OpEntryPoint Kernel %func \"compute\"") + " %voidt = OpTypeVoid" - " %imgt = OpTypeImage %voidt Buffer 0 0 0 0 Unknown" + string(kVoidFVoid2), + " %imgt = OpTypeImage %voidt Buffer 0 0 0 0 Unknown" + std::string(kVoidFVoid2), SampledBufferDependencies()), -make_pair(" OpCapability ImageBasic" + - string(kOpenCLMemoryModel) + - string(" OpEntryPoint Kernel %func \"compute\"") + +std::make_pair(" OpCapability ImageBasic" + + std::string(kOpenCLMemoryModel) + + std::string(" OpEntryPoint Kernel %func \"compute\"") + " %voidt = OpTypeVoid" - " %imgt = OpTypeImage %voidt SubpassData 0 0 0 2 Unknown" + string(kVoidFVoid2), - vector{"InputAttachment"}) + " %imgt = OpTypeImage %voidt SubpassData 0 0 0 2 Unknown" + std::string(kVoidFVoid2), + std::vector{"InputAttachment"}) )),); // NOTE: All Sampler Address Modes require kernel capabilities but the @@ -927,36 +925,36 @@ INSTANTIATE_TEST_CASE_P(SamplerAddressingMode, ValidateCapability, Combine( ValuesIn(AllCapabilities()), Values( -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" " %samplert = OpTypeSampler" " %sampler = OpConstantSampler %samplert None 1 Nearest" + - string(kVoidFVoid), - vector{"LiteralSampler"}), -make_pair(string(kGLSL450MemoryModel) + + std::string(kVoidFVoid), + std::vector{"LiteralSampler"}), +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" " %samplert = OpTypeSampler" " %sampler = OpConstantSampler %samplert ClampToEdge 1 Nearest" + - string(kVoidFVoid), - vector{"LiteralSampler"}), -make_pair(string(kGLSL450MemoryModel) + + std::string(kVoidFVoid), + std::vector{"LiteralSampler"}), +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" " %samplert = OpTypeSampler" " %sampler = OpConstantSampler %samplert Clamp 1 Nearest" + - string(kVoidFVoid), - vector{"LiteralSampler"}), -make_pair(string(kGLSL450MemoryModel) + + std::string(kVoidFVoid), + std::vector{"LiteralSampler"}), +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" " %samplert = OpTypeSampler" " %sampler = OpConstantSampler %samplert Repeat 1 Nearest" + - string(kVoidFVoid), - vector{"LiteralSampler"}), -make_pair(string(kGLSL450MemoryModel) + + std::string(kVoidFVoid), + std::vector{"LiteralSampler"}), +std::make_pair(std::string(kGLSL450MemoryModel) + " OpEntryPoint Vertex %func \"shader\"" " %samplert = OpTypeSampler" " %sampler = OpConstantSampler %samplert RepeatMirrored 1 Nearest" + - string(kVoidFVoid), - vector{"LiteralSampler"}) + std::string(kVoidFVoid), + std::vector{"LiteralSampler"}) )),); // TODO(umar): Sampler Filter Mode @@ -974,471 +972,474 @@ INSTANTIATE_TEST_CASE_P(Decoration, ValidateCapability, Combine( ValuesIn(AllCapabilities()), Values( -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt RelaxedPrecision\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Block\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt BufferBlock\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt RowMajor\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), MatrixDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt ColMajor\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), MatrixDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt ArrayStride 1\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt MatrixStride 1\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), MatrixDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt GLSLShared\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt GLSLPacked\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" "OpDecorate %intt CPacked\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt NoPerspective\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Flat\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Patch\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Centroid\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Sample\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), - vector{"SampleRateShading"}), -make_pair(string(kOpenCLMemoryModel) + + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), + std::vector{"SampleRateShading"}), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Invariant\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Restrict\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Aliased\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Volatile\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" "OpDecorate %intt Constant\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Coherent\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt NonWritable\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt NonReadable\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Uniform\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" "OpDecorate %intt SaturatedConversion\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Stream 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), - vector{"GeometryStreams"}), -make_pair(string(kOpenCLMemoryModel) + + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), + std::vector{"GeometryStreams"}), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Location 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Component 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Index 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Binding 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt DescriptorSet 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt Offset 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt XfbBuffer 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), - vector{"TransformFeedback"}), -make_pair(string(kOpenCLMemoryModel) + + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), + std::vector{"TransformFeedback"}), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt XfbStride 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), - vector{"TransformFeedback"}), -make_pair(string(kGLSL450MemoryModel) + + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), + std::vector{"TransformFeedback"}), +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" "OpDecorate %intt FuncParamAttr Zext\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" "OpDecorate %intt FPFastMathMode Fast\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt LinkageAttributes \"other\" Import\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), - vector{"Linkage"}), -make_pair(string(kOpenCLMemoryModel) + + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), + std::vector{"Linkage"}), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt NoContraction\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" "OpDecorate %intt InputAttachmentIndex 0\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), - vector{"InputAttachment"}), -make_pair(string(kGLSL450MemoryModel) + + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), + std::vector{"InputAttachment"}), +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" "OpDecorate %intt Alignment 4\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()) )),); // clang-format on INSTANTIATE_TEST_CASE_P( DecorationSpecId, ValidateCapability, - Combine(ValuesIn(AllSpirV10Capabilities()), - Values(make_pair(string(kOpenCLMemoryModel) + - "OpEntryPoint Vertex %func \"shader\" \n" + - "OpDecorate %1 SpecId 1\n" - "%intt = OpTypeInt 32 0\n" - "%1 = OpSpecConstant %intt 0\n" + - string(kVoidFVoid), - ShaderDependencies()))), ); + Combine( + ValuesIn(AllSpirV10Capabilities()), + Values(std::make_pair(std::string(kOpenCLMemoryModel) + + "OpEntryPoint Vertex %func \"shader\" \n" + + "OpDecorate %1 SpecId 1\n" + "%intt = OpTypeInt 32 0\n" + "%1 = OpSpecConstant %intt 0\n" + + std::string(kVoidFVoid), + ShaderDependencies()))), ); INSTANTIATE_TEST_CASE_P( DecorationV11, ValidateCapabilityV11, Combine(ValuesIn(AllCapabilities()), - Values(make_pair(string(kOpenCLMemoryModel) + - "OpEntryPoint Kernel %func \"compute\" \n" - "OpDecorate %p MaxByteOffset 0 " - "%i32 = OpTypeInt 32 0 " - "%pi32 = OpTypePointer Workgroup %i32 " - "%p = OpVariable %pi32 Workgroup " + - string(kVoidFVoid), - AddressesDependencies()), + Values(std::make_pair(std::string(kOpenCLMemoryModel) + + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %p MaxByteOffset 0 " + "%i32 = OpTypeInt 32 0 " + "%pi32 = OpTypePointer Workgroup %i32 " + "%p = OpVariable %pi32 Workgroup " + + std::string(kVoidFVoid), + AddressesDependencies()), // Trying to test OpDecorate here, but if this fails due to // incorrect OpMemoryModel validation, that must also be // fixed. - make_pair(string("OpMemoryModel Logical OpenCL " - "OpEntryPoint Kernel %func \"compute\" \n" - "OpDecorate %1 SpecId 1 " - "%intt = OpTypeInt 32 0 " - "%1 = OpSpecConstant %intt 0") + - string(kVoidFVoid), - KernelDependencies()), - make_pair(string("OpMemoryModel Logical Simple " - "OpEntryPoint Vertex %func \"shader\" \n" - "OpDecorate %1 SpecId 1 " - "%intt = OpTypeInt 32 0 " - "%1 = OpSpecConstant %intt 0") + - string(kVoidFVoid), - ShaderDependencies()))), ); + std::make_pair( + std::string("OpMemoryModel Logical OpenCL " + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %1 SpecId 1 " + "%intt = OpTypeInt 32 0 " + "%1 = OpSpecConstant %intt 0") + + std::string(kVoidFVoid), + KernelDependencies()), + std::make_pair( + std::string("OpMemoryModel Logical Simple " + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %1 SpecId 1 " + "%intt = OpTypeInt 32 0 " + "%1 = OpSpecConstant %intt 0") + + std::string(kVoidFVoid), + ShaderDependencies()))), ); // clang-format off INSTANTIATE_TEST_CASE_P(BuiltIn, ValidateCapability, Combine( ValuesIn(AllCapabilities()), Values( -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn Position\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), // Just mentioning PointSize, ClipDistance, or CullDistance as a BuiltIn does // not trigger the requirement for the associated capability. // See https://github.com/KhronosGroup/SPIRV-Tools/issues/365 -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn PointSize\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn ClipDistance\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn CullDistance\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn VertexId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn InstanceId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn PrimitiveId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), GeometryTessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn InvocationId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), GeometryTessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn Layer\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), GeometryDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn ViewportIndex\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), - vector{"MultiViewport"}), -make_pair(string(kOpenCLMemoryModel) + + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), + std::vector{"MultiViewport"}), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn TessLevelOuter\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn TessLevelInner\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn TessCoord\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn PatchVertices\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), TessellationDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn FragCoord\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn PointCoord\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn FrontFacing\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn SampleId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), - vector{"SampleRateShading"}), -make_pair(string(kOpenCLMemoryModel) + + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), + std::vector{"SampleRateShading"}), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn SamplePosition\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), - vector{"SampleRateShading"}), -make_pair(string(kOpenCLMemoryModel) + + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), + std::vector{"SampleRateShading"}), +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn SampleMask\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn FragDepth\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn HelperInvocation\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn VertexIndex\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn InstanceIndex\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn NumWorkgroups\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn WorkgroupSize\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn WorkgroupId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn LocalInvocationId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn GlobalInvocationId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn LocalInvocationIndex\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllCapabilities()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn WorkDim\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn GlobalSize\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn EnqueuedWorkgroupSize\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn GlobalOffset\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn GlobalLinearId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn SubgroupSize\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelAndGroupNonUniformDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn SubgroupMaxSize\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn NumSubgroups\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelAndGroupNonUniformDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn NumEnqueuedSubgroups\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn SubgroupId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelAndGroupNonUniformDependencies()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn SubgroupLocalInvocationId\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), KernelAndGroupNonUniformDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn VertexIndex\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()), -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "OpDecorate %intt BuiltIn InstanceIndex\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), ShaderDependencies()) )),); @@ -1451,31 +1452,31 @@ INSTANTIATE_TEST_CASE_P(BuiltIn, ValidateCapabilityVulkan10, // All capabilities to try. ValuesIn(AllSpirV10Capabilities()), Values( -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" "OpMemberDecorate %block 0 BuiltIn PointSize\n" "%f32 = OpTypeFloat 32\n" "%block = OpTypeStruct %f32\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), // Capabilities which should succeed. AllVulkan10Capabilities()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" "OpMemberDecorate %block 0 BuiltIn ClipDistance\n" "%f32 = OpTypeFloat 32\n" "%intt = OpTypeInt 32 0\n" "%intt_4 = OpConstant %intt 4\n" "%f32arr4 = OpTypeArray %f32 %intt_4\n" - "%block = OpTypeStruct %f32arr4\n" + string(kVoidFVoid), + "%block = OpTypeStruct %f32arr4\n" + std::string(kVoidFVoid), AllVulkan10Capabilities()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" "OpMemberDecorate %block 0 BuiltIn CullDistance\n" "%f32 = OpTypeFloat 32\n" "%intt = OpTypeInt 32 0\n" "%intt_4 = OpConstant %intt 4\n" "%f32arr4 = OpTypeArray %f32 %intt_4\n" - "%block = OpTypeStruct %f32arr4\n" + string(kVoidFVoid), + "%block = OpTypeStruct %f32arr4\n" + std::string(kVoidFVoid), AllVulkan10Capabilities()) )),); @@ -1484,20 +1485,20 @@ INSTANTIATE_TEST_CASE_P(BuiltIn, ValidateCapabilityOpenGL40, // OpenGL 4.0 is based on SPIR-V 1.0 ValuesIn(AllSpirV10Capabilities()), Values( -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn PointSize\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllSpirV10Capabilities()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn ClipDistance\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllSpirV10Capabilities()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn CullDistance\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllSpirV10Capabilities()) )),); @@ -1506,15 +1507,15 @@ INSTANTIATE_TEST_CASE_P(Capabilities, ValidateCapabilityVulkan11, // All capabilities to try. ValuesIn(AllCapabilities()), Values( -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn PointSize\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllVulkan11Capabilities()), -make_pair(string(kGLSL450MemoryModel) + +std::make_pair(std::string(kGLSL450MemoryModel) + "OpEntryPoint Vertex %func \"shader\" \n" + "OpDecorate %intt BuiltIn CullDistance\n" - "%intt = OpTypeInt 32 0\n" + string(kVoidFVoid), + "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid), AllVulkan11Capabilities()) )),); @@ -1532,11 +1533,11 @@ INSTANTIATE_TEST_CASE_P(MatrixOp, ValidateCapability, Combine( ValuesIn(AllCapabilities()), Values( -make_pair(string(kOpenCLMemoryModel) + +std::make_pair(std::string(kOpenCLMemoryModel) + "OpEntryPoint Kernel %func \"compute\" \n" + "%f32 = OpTypeFloat 32\n" "%vec3 = OpTypeVector %f32 3\n" - "%mat33 = OpTypeMatrix %vec3 3\n" + string(kVoidFVoid), + "%mat33 = OpTypeMatrix %vec3 3\n" + std::string(kVoidFVoid), MatrixDependencies()))),); // clang-format on @@ -1548,7 +1549,7 @@ make_pair(string(kOpenCLMemoryModel) + // the image-operands part. The assembly defines constants %fzero and %izero // that can be used for operands where IDs are required. The assembly is valid, // apart from not declaring any capabilities required by the operands. -string ImageOperandsTemplate(const string& operands) { +string ImageOperandsTemplate(const std::string& operands) { ostringstream ss; // clang-format off ss << R"( @@ -1582,13 +1583,13 @@ INSTANTIATE_TEST_CASE_P( TwoImageOperandsMask, ValidateCapability, Combine( ValuesIn(AllCapabilities()), - Values(make_pair(ImageOperandsTemplate("Bias|Lod %fzero %fzero"), + Values(std::make_pair(ImageOperandsTemplate("Bias|Lod %fzero %fzero"), ShaderDependencies()), - make_pair(ImageOperandsTemplate("Lod|Offset %fzero %izero"), - vector{"ImageGatherExtended"}), - make_pair(ImageOperandsTemplate("Sample|MinLod %izero %fzero"), - vector{"MinLod"}), - make_pair(ImageOperandsTemplate("Lod|Sample %fzero %izero"), + std::make_pair(ImageOperandsTemplate("Lod|Offset %fzero %izero"), + std::vector{"ImageGatherExtended"}), + std::make_pair(ImageOperandsTemplate("Sample|MinLod %izero %fzero"), + std::vector{"MinLod"}), + std::make_pair(ImageOperandsTemplate("Lod|Sample %fzero %izero"), AllCapabilities()))), ); #endif @@ -1629,7 +1630,7 @@ bool Exists(const std::string& capability, spv_target_env env) { } TEST_P(ValidateCapability, Capability) { - const string capability = Capability(GetParam()); + const std::string capability = Capability(GetParam()); spv_target_env env = SPV_ENV_UNIVERSAL_1_0; if (!capability.empty()) { if (Exists(capability, SPV_ENV_UNIVERSAL_1_0)) @@ -1641,7 +1642,7 @@ TEST_P(ValidateCapability, Capability) { else env = SPV_ENV_UNIVERSAL_1_3; } - const string test_code = MakeAssembly(GetParam()); + const std::string test_code = MakeAssembly(GetParam()); CompileSuccessfully(test_code, env); ASSERT_EQ(ExpectedResult(GetParam()), ValidateInstructions(env)) << "target env: " << spvTargetEnvDescription(env) << "\ntest code:\n" @@ -1649,9 +1650,9 @@ TEST_P(ValidateCapability, Capability) { } TEST_P(ValidateCapabilityV11, Capability) { - const string capability = Capability(GetParam()); + const std::string capability = Capability(GetParam()); if (Exists(capability, SPV_ENV_UNIVERSAL_1_1)) { - const string test_code = MakeAssembly(GetParam()); + const std::string test_code = MakeAssembly(GetParam()); CompileSuccessfully(test_code, SPV_ENV_UNIVERSAL_1_1); ASSERT_EQ(ExpectedResult(GetParam()), ValidateInstructions(SPV_ENV_UNIVERSAL_1_1)) @@ -1660,9 +1661,9 @@ TEST_P(ValidateCapabilityV11, Capability) { } TEST_P(ValidateCapabilityVulkan10, Capability) { - const string capability = Capability(GetParam()); + const std::string capability = Capability(GetParam()); if (Exists(capability, SPV_ENV_VULKAN_1_0)) { - const string test_code = MakeAssembly(GetParam()); + const std::string test_code = MakeAssembly(GetParam()); CompileSuccessfully(test_code, SPV_ENV_VULKAN_1_0); ASSERT_EQ(ExpectedResult(GetParam()), ValidateInstructions(SPV_ENV_VULKAN_1_0)) @@ -1671,9 +1672,9 @@ TEST_P(ValidateCapabilityVulkan10, Capability) { } TEST_P(ValidateCapabilityVulkan11, Capability) { - const string capability = Capability(GetParam()); + const std::string capability = Capability(GetParam()); if (Exists(capability, SPV_ENV_VULKAN_1_1)) { - const string test_code = MakeAssembly(GetParam()); + const std::string test_code = MakeAssembly(GetParam()); CompileSuccessfully(test_code, SPV_ENV_VULKAN_1_1); ASSERT_EQ(ExpectedResult(GetParam()), ValidateInstructions(SPV_ENV_VULKAN_1_1)) @@ -1682,9 +1683,9 @@ TEST_P(ValidateCapabilityVulkan11, Capability) { } TEST_P(ValidateCapabilityOpenGL40, Capability) { - const string capability = Capability(GetParam()); + const std::string capability = Capability(GetParam()); if (Exists(capability, SPV_ENV_OPENGL_4_0)) { - const string test_code = MakeAssembly(GetParam()); + const std::string test_code = MakeAssembly(GetParam()); CompileSuccessfully(test_code, SPV_ENV_OPENGL_4_0); ASSERT_EQ(ExpectedResult(GetParam()), ValidateInstructions(SPV_ENV_OPENGL_4_0)) @@ -1796,7 +1797,7 @@ OpEntryPoint Vertex %func "shader" OpMemberDecorate %block 0 BuiltIn PointSize %f32 = OpTypeFloat 32 %block = OpTypeStruct %f32 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); @@ -1810,7 +1811,7 @@ OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %func "shader" OpDecorate %intt BuiltIn PointSize %intt = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0); EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY, @@ -1846,7 +1847,7 @@ OpCapability ImageBasic OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_1_2); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_1_2)); @@ -1860,7 +1861,7 @@ OpCapability Linkage OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_1_2); EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY, @@ -1898,7 +1899,7 @@ OpCapability ImageBasic OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_1_2); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_1_2)); @@ -1912,7 +1913,7 @@ OpCapability Linkage OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_1_2); EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY, @@ -1962,7 +1963,7 @@ OpCapability ImageBasic OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_0); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_2_0)); @@ -1976,7 +1977,7 @@ OpCapability Linkage OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_0); EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY, @@ -2012,7 +2013,7 @@ OpCapability ImageBasic OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_0); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_0)); @@ -2026,7 +2027,7 @@ OpCapability Linkage OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_0); EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY, @@ -2075,7 +2076,7 @@ OpCapability ImageBasic OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_2); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_2_2)); @@ -2089,7 +2090,7 @@ OpCapability Linkage OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_2); EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY, @@ -2127,7 +2128,7 @@ OpCapability ImageBasic OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_2); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_2)); @@ -2141,7 +2142,7 @@ OpCapability Linkage OpCapability Sampled1D OpMemoryModel Physical64 OpenCL %u32 = OpTypeInt 32 0 -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_2); EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY, @@ -2162,7 +2163,7 @@ TEST_F(ValidateCapability, DecorationFromExtensionMissingEnabledByCapability) { OpCapability Shader OpMemoryModel Logical Simple OpDecorate %void ViewportRelativeNV -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_0); EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY, @@ -2178,7 +2179,7 @@ TEST_F(ValidateCapability, CapabilityEnabledByMissingExtension) { OpCapability Shader OpCapability ShaderViewportMaskNV OpMemoryModel Logical Simple -)" + string(kVoidFVoid); +)" + std::string(kVoidFVoid); CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_0); EXPECT_EQ(SPV_ERROR_MISSING_EXTENSION, diff --git a/test/val/val_cfg_test.cpp b/test/val/val_cfg_test.cpp index 625a7bc94..9f48a0c1b 100644 --- a/test/val/val_cfg_test.cpp +++ b/test/val/val_cfg_test.cpp @@ -34,46 +34,39 @@ namespace spvtools { namespace val { namespace { -using std::array; -using std::make_pair; -using std::pair; -using std::string; -using std::stringstream; -using std::vector; - using ::testing::HasSubstr; using ::testing::MatchesRegex; using ValidateCFG = spvtest::ValidateBase; using spvtest::ScopedContext; -string nameOps() { return ""; } +std::string nameOps() { return ""; } template -string nameOps(pair head, Args... names) { +std::string nameOps(std::pair head, Args... names) { return "OpName %" + head.first + " \"" + head.second + "\"\n" + nameOps(names...); } template -string nameOps(string head, Args... names) { +std::string nameOps(std::string head, Args... names) { return "OpName %" + head + " \"" + head + "\"\n" + nameOps(names...); } /// This class allows the easy creation of complex control flow without writing /// SPIR-V. This class is used in the test cases below. class Block { - string label_; - string body_; + std::string label_; + std::string body_; SpvOp type_; - vector successors_; + std::vector successors_; public: /// Creates a Block with a given label /// /// @param[in]: label the label id of the block /// @param[in]: type the branch instruciton that ends the block - explicit Block(string label, SpvOp type = SpvOpBranch) + explicit Block(std::string label, SpvOp type = SpvOpBranch) : label_(label), body_(), type_(type), successors_() {} /// Sets the instructions which will appear in the body of the block @@ -88,8 +81,8 @@ class Block { } /// Converts the block into a SPIR-V string - operator string() { - stringstream out; + operator std::string() { + std::stringstream out; out << std::setw(8) << "%" + label_ + " = OpLabel \n"; if (!body_.empty()) { out << body_; @@ -104,7 +97,7 @@ class Block { break; case SpvOpSwitch: { out << "OpSwitch %one %" + successors_.front().label_; - stringstream ss; + std::stringstream ss; for (size_t i = 1; i < successors_.size(); i++) { ss << " " << i << " %" << successors_[i].label_; } @@ -129,12 +122,12 @@ class Block { return out.str(); } - friend Block& operator>>(Block& curr, vector successors); + friend Block& operator>>(Block& curr, std::vector successors); friend Block& operator>>(Block& lhs, Block& successor); }; /// Assigns the successors for the Block on the lhs -Block& operator>>(Block& lhs, vector successors) { +Block& operator>>(Block& lhs, std::vector successors) { if (lhs.type_ == SpvOpBranchConditional) { assert(successors.size() == 2); } else if (lhs.type_ == SpvOpSwitch) { @@ -192,7 +185,7 @@ TEST_P(ValidateCFG, LoopReachableFromEntryButNeverLeadingToReturn) { // // For more motivation, see // https://github.com/KhronosGroup/SPIRV-Tools/issues/279 - string str = R"( + std::string str = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -230,7 +223,7 @@ TEST_P(ValidateCFG, LoopUnreachableFromEntryButLeadingToReturn) { // https://github.com/KhronosGroup/SPIRV-Tools/issues/279 // Before that fix, we'd have an infinite loop when calculating // post-dominators. - string str = R"( + std::string str = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -277,13 +270,14 @@ TEST_P(ValidateCFG, Simple) { loop.SetBody("OpLoopMerge %merge %cont None\n"); } - string str = - header(GetParam()) + - nameOps("loop", "entry", "cont", "merge", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("loop", "entry", "cont", "merge", + std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; - str += loop >> vector({cont, merge}); + str += loop >> std::vector({cont, merge}); str += cont >> loop; str += merge; str += "OpFunctionEnd\n"; @@ -299,8 +293,9 @@ TEST_P(ValidateCFG, Variable) { entry.SetBody("%var = OpVariable %ptrt Function\n"); - string str = header(GetParam()) + nameOps(make_pair("func", "Main")) + - types_consts() + " %func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps(std::make_pair("func", "Main")) + types_consts() + + " %func = OpFunction %voidt None %funct\n"; str += entry >> cont; str += cont >> exit; str += exit; @@ -318,8 +313,9 @@ TEST_P(ValidateCFG, VariableNotInFirstBlockBad) { // This operation should only be performed in the entry block cont.SetBody("%var = OpVariable %ptrt Function\n"); - string str = header(GetParam()) + nameOps(make_pair("func", "Main")) + - types_consts() + " %func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps(std::make_pair("func", "Main")) + types_consts() + + " %func = OpFunction %voidt None %funct\n"; str += entry >> cont; str += cont >> exit; @@ -343,13 +339,14 @@ TEST_P(ValidateCFG, BlockSelfLoopIsOk) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) loop.SetBody("OpLoopMerge %merge %loop None\n"); - string str = header(GetParam()) + - nameOps("loop", "merge", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("loop", "merge", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; // loop branches to itself, but does not trigger an error. - str += loop >> vector({merge, loop}); + str += loop >> std::vector({merge, loop}); str += merge; str += "OpFunctionEnd\n"; @@ -367,13 +364,14 @@ TEST_P(ValidateCFG, BlockAppearsBeforeDominatorBad) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) branch.SetBody("OpSelectionMerge %merge None\n"); - string str = header(GetParam()) + - nameOps("cont", "branch", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("cont", "branch", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> branch; str += cont >> merge; // cont appears before its dominator - str += branch >> vector({cont, merge}); + str += branch >> std::vector({cont, merge}); str += merge; str += "OpFunctionEnd\n"; @@ -398,13 +396,13 @@ TEST_P(ValidateCFG, MergeBlockTargetedByMultipleHeaderBlocksBad) { // cannot share the same merge if (is_shader) selection.SetBody("OpSelectionMerge %merge None\n"); - string str = header(GetParam()) + - nameOps("merge", make_pair("func", "Main")) + types_consts() + - "%func = OpFunction %voidt None %funct\n"; + std::string str = + header(GetParam()) + nameOps("merge", std::make_pair("func", "Main")) + + types_consts() + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; str += loop >> selection; - str += selection >> vector({loop, merge}); + str += selection >> std::vector({loop, merge}); str += merge; str += "OpFunctionEnd\n"; @@ -433,13 +431,13 @@ TEST_P(ValidateCFG, MergeBlockTargetedByMultipleHeaderBlocksSelectionBad) { // cannot share the same merge if (is_shader) loop.SetBody(" OpLoopMerge %merge %loop None\n"); - string str = header(GetParam()) + - nameOps("merge", make_pair("func", "Main")) + types_consts() + - "%func = OpFunction %voidt None %funct\n"; + std::string str = + header(GetParam()) + nameOps("merge", std::make_pair("func", "Main")) + + types_consts() + "%func = OpFunction %voidt None %funct\n"; str += entry >> selection; - str += selection >> vector({merge, loop}); - str += loop >> vector({loop, merge}); + str += selection >> std::vector({merge, loop}); + str += loop >> std::vector({loop, merge}); str += merge; str += "OpFunctionEnd\n"; @@ -459,9 +457,10 @@ TEST_P(ValidateCFG, BranchTargetFirstBlockBadSinceEntryBlock) { Block entry("entry"); Block bad("bad"); Block end("end", SpvOpReturn); - string str = header(GetParam()) + - nameOps("entry", "bad", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("entry", "bad", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> bad; str += bad >> entry; // Cannot target entry block @@ -481,9 +480,10 @@ TEST_P(ValidateCFG, BranchTargetFirstBlockBadSinceValue) { Block bad("bad"); Block end("end", SpvOpReturn); Block badvalue("func"); // This referenes the function name. - string str = header(GetParam()) + - nameOps("entry", "bad", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("entry", "bad", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> bad; str += @@ -509,12 +509,13 @@ TEST_P(ValidateCFG, BranchConditionalTrueTargetFirstBlockBad) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); bad.SetBody(" OpLoopMerge %entry %exit None\n"); - string str = header(GetParam()) + - nameOps("entry", "bad", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("entry", "bad", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> bad; - str += bad >> vector({entry, exit}); // cannot target entry block + str += bad >> std::vector({entry, exit}); // cannot target entry block str += exit; str += "OpFunctionEnd\n"; @@ -536,12 +537,13 @@ TEST_P(ValidateCFG, BranchConditionalFalseTargetFirstBlockBad) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); bad.SetBody("OpLoopMerge %merge %cont None\n"); - string str = header(GetParam()) + - nameOps("entry", "bad", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("entry", "bad", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> bad; - str += bad >> vector({t, entry}); + str += bad >> std::vector({t, entry}); str += merge >> end; str += end; str += "OpFunctionEnd\n"; @@ -567,12 +569,13 @@ TEST_P(ValidateCFG, SwitchTargetFirstBlockBad) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); bad.SetBody("OpSelectionMerge %merge None\n"); - string str = header(GetParam()) + - nameOps("entry", "bad", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("entry", "bad", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> bad; - str += bad >> vector({def, block1, block2, block3, entry}); + str += bad >> std::vector({def, block1, block2, block3, entry}); str += def >> merge; str += block1 >> merge; str += block2 >> merge; @@ -601,12 +604,12 @@ TEST_P(ValidateCFG, BranchToBlockInOtherFunctionBad) { Block middle2("middle2"); Block end2("end2", SpvOpReturn); - string str = header(GetParam()) + - nameOps("middle2", make_pair("func", "Main")) + types_consts() + - "%func = OpFunction %voidt None %funct\n"; + std::string str = + header(GetParam()) + nameOps("middle2", std::make_pair("func", "Main")) + + types_consts() + "%func = OpFunction %voidt None %funct\n"; str += entry >> middle; - str += middle >> vector({end, middle2}); + str += middle >> std::vector({end, middle2}); str += end; str += "OpFunctionEnd\n"; @@ -636,12 +639,13 @@ TEST_P(ValidateCFG, HeaderDoesntDominatesMergeBad) { if (is_shader) head.AppendBody("OpSelectionMerge %merge None\n"); - string str = header(GetParam()) + - nameOps("head", "merge", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("head", "merge", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> merge; - str += head >> vector({merge, f}); + str += head >> std::vector({merge, f}); str += f >> merge; str += merge; str += "OpFunctionEnd\n"; @@ -670,11 +674,12 @@ TEST_P(ValidateCFG, HeaderDoesntStrictlyDominateMergeBad) { if (is_shader) head.AppendBody("OpSelectionMerge %head None\n"); - string str = header(GetParam()) + - nameOps("head", "exit", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("head", "exit", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; - str += head >> vector({exit, exit}); + str += head >> std::vector({exit, exit}); str += exit; str += "OpFunctionEnd\n"; @@ -702,12 +707,13 @@ TEST_P(ValidateCFG, UnreachableMerge) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) branch.AppendBody("OpSelectionMerge %merge None\n"); - string str = header(GetParam()) + - nameOps("branch", "merge", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("branch", "merge", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> branch; - str += branch >> vector({t, f}); + str += branch >> std::vector({t, f}); str += t; str += f; str += merge; @@ -728,12 +734,13 @@ TEST_P(ValidateCFG, UnreachableMergeDefinedByOpUnreachable) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) branch.AppendBody("OpSelectionMerge %merge None\n"); - string str = header(GetParam()) + - nameOps("branch", "merge", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("branch", "merge", std::make_pair("func", "Main")) + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> branch; - str += branch >> vector({t, f}); + str += branch >> std::vector({t, f}); str += t; str += f; str += merge; @@ -748,9 +755,10 @@ TEST_P(ValidateCFG, UnreachableBlock) { Block unreachable("unreachable"); Block exit("exit", SpvOpReturn); - string str = header(GetParam()) + - nameOps("unreachable", "exit", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = + header(GetParam()) + + nameOps("unreachable", "exit", std::make_pair("func", "Main")) + + types_consts() + "%func = OpFunction %voidt None %funct\n"; str += entry >> exit; str += unreachable >> exit; @@ -772,12 +780,14 @@ TEST_P(ValidateCFG, UnreachableBranch) { unreachable.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) unreachable.AppendBody("OpSelectionMerge %merge None\n"); - string str = header(GetParam()) + - nameOps("unreachable", "exit", make_pair("func", "Main")) + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = + header(GetParam()) + + nameOps("unreachable", "exit", std::make_pair("func", "Main")) + + types_consts() + "%func = OpFunction %voidt None %funct\n"; str += entry >> exit; - str += unreachable >> vector({unreachablechildt, unreachablechildf}); + str += + unreachable >> std::vector({unreachablechildt, unreachablechildf}); str += unreachablechildt >> merge; str += unreachablechildf >> merge; str += merge >> exit; @@ -789,8 +799,8 @@ TEST_P(ValidateCFG, UnreachableBranch) { } TEST_P(ValidateCFG, EmptyFunction) { - string str = header(GetParam()) + string(types_consts()) + - R"(%func = OpFunction %voidt None %funct + std::string str = header(GetParam()) + std::string(types_consts()) + + R"(%func = OpFunction %voidt None %funct %l = OpLabel OpReturn OpFunctionEnd)"; @@ -808,11 +818,11 @@ TEST_P(ValidateCFG, SingleBlockLoop) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) loop.AppendBody("OpLoopMerge %exit %loop None\n"); - string str = header(GetParam()) + string(types_consts()) + - "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + std::string(types_consts()) + + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; - str += loop >> vector({loop, exit}); + str += loop >> std::vector({loop, exit}); str += exit; str += "OpFunctionEnd"; @@ -837,13 +847,14 @@ TEST_P(ValidateCFG, NestedLoops) { loop2.SetBody("OpLoopMerge %loop2_merge %loop2 None\n"); } - string str = header(GetParam()) + nameOps("loop2", "loop2_merge") + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + nameOps("loop2", "loop2_merge") + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop1; str += loop1 >> loop1_cont_break_block; - str += loop1_cont_break_block >> vector({loop1_merge, loop2}); - str += loop2 >> vector({loop2, loop2_merge}); + str += loop1_cont_break_block >> std::vector({loop1_merge, loop2}); + str += loop2 >> std::vector({loop2, loop2_merge}); str += loop2_merge >> loop1; str += loop1_merge >> exit; str += exit; @@ -857,8 +868,8 @@ TEST_P(ValidateCFG, NestedSelection) { bool is_shader = GetParam() == SpvCapabilityShader; Block entry("entry"); const int N = 256; - vector if_blocks; - vector merge_blocks; + std::vector if_blocks; + std::vector merge_blocks; Block inner("inner"); entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); @@ -869,21 +880,22 @@ TEST_P(ValidateCFG, NestedSelection) { merge_blocks.emplace_back("if_merge0", SpvOpReturn); for (int i = 1; i < N; i++) { - stringstream ss; + std::stringstream ss; ss << i; if_blocks.emplace_back("if" + ss.str(), SpvOpBranchConditional); if (is_shader) if_blocks[i].SetBody("OpSelectionMerge %if_merge" + ss.str() + " None\n"); merge_blocks.emplace_back("if_merge" + ss.str(), SpvOpBranch); } - string str = header(GetParam()) + string(types_consts()) + - "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + std::string(types_consts()) + + "%func = OpFunction %voidt None %funct\n"; str += entry >> if_blocks[0]; for (int i = 0; i < N - 1; i++) { - str += if_blocks[i] >> vector({if_blocks[i + 1], merge_blocks[i]}); + str += + if_blocks[i] >> std::vector({if_blocks[i + 1], merge_blocks[i]}); } - str += if_blocks.back() >> vector({inner, merge_blocks.back()}); + str += if_blocks.back() >> std::vector({inner, merge_blocks.back()}); str += inner >> merge_blocks.back(); for (int i = N - 1; i > 0; i--) { str += merge_blocks[i] >> merge_blocks[i - 1]; @@ -910,14 +922,15 @@ TEST_P(ValidateCFG, BackEdgeBlockDoesntPostDominateContinueTargetBad) { loop2.SetBody("OpLoopMerge %loop2_merge %loop2 None\n"); } - string str = header(GetParam()) + - nameOps("loop1", "loop2", "be_block", "loop2_merge") + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("loop1", "loop2", "be_block", "loop2_merge") + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop1; - str += loop1 >> vector({loop2, exit}); - str += loop2 >> vector({loop2, loop2_merge}); - str += loop2_merge >> vector({be_block, exit}); + str += loop1 >> std::vector({loop2, exit}); + str += loop2 >> std::vector({loop2, loop2_merge}); + str += loop2_merge >> std::vector({be_block, exit}); str += be_block >> loop1; str += exit; str += "OpFunctionEnd"; @@ -946,11 +959,12 @@ TEST_P(ValidateCFG, BranchingToNonLoopHeaderBlockBad) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) split.SetBody("OpSelectionMerge %exit None\n"); - string str = header(GetParam()) + nameOps("split", "f") + types_consts() + - "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + nameOps("split", "f") + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> split; - str += split >> vector({t, f}); + str += split >> std::vector({t, f}); str += t >> exit; str += f >> split; str += exit; @@ -978,11 +992,11 @@ TEST_P(ValidateCFG, BranchingToSameNonLoopHeaderBlockBad) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) split.SetBody("OpSelectionMerge %exit None\n"); - string str = header(GetParam()) + nameOps("split") + types_consts() + - "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + nameOps("split") + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> split; - str += split >> vector({split, exit}); + str += split >> std::vector({split, exit}); str += exit; str += "OpFunctionEnd"; @@ -1010,11 +1024,12 @@ TEST_P(ValidateCFG, MultipleBackEdgeBlocksToLoopHeaderBad) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) loop.SetBody("OpLoopMerge %merge %back0 None\n"); - string str = header(GetParam()) + nameOps("loop", "back0", "back1") + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + nameOps("loop", "back0", "back1") + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; - str += loop >> vector({back0, back1}); + str += loop >> std::vector({back0, back1}); str += back0 >> loop; str += back1 >> loop; str += merge; @@ -1046,12 +1061,13 @@ TEST_P(ValidateCFG, ContinueTargetMustBePostDominatedByBackEdge) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) loop.SetBody("OpLoopMerge %merge %cheader None\n"); - string str = header(GetParam()) + nameOps("cheader", "be_block") + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + nameOps("cheader", "be_block") + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; - str += loop >> vector({cheader, merge}); - str += cheader >> vector({exit, be_block}); + str += loop >> std::vector({cheader, merge}); + str += cheader >> std::vector({exit, be_block}); str += exit; // Branches out of a continue construct str += be_block >> loop; str += merge; @@ -1080,12 +1096,13 @@ TEST_P(ValidateCFG, BranchOutOfConstructToMergeBad) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) loop.SetBody("OpLoopMerge %merge %loop None\n"); - string str = header(GetParam()) + nameOps("cont", "loop") + types_consts() + - "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + nameOps("cont", "loop") + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; - str += loop >> vector({cont, merge}); - str += cont >> vector({loop, merge}); + str += loop >> std::vector({cont, merge}); + str += cont >> std::vector({loop, merge}); str += merge; str += "OpFunctionEnd"; @@ -1114,12 +1131,13 @@ TEST_P(ValidateCFG, BranchOutOfConstructBad) { entry.SetBody("%cond = OpSLessThan %boolt %one %two\n"); if (is_shader) loop.SetBody("OpLoopMerge %merge %loop None\n"); - string str = header(GetParam()) + nameOps("cont", "loop") + types_consts() + - "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + nameOps("cont", "loop") + + types_consts() + + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; - str += loop >> vector({cont, merge}); - str += cont >> vector({loop, exit}); + str += loop >> std::vector({cont, merge}); + str += cont >> std::vector({loop, exit}); str += merge >> exit; str += exit; str += "OpFunctionEnd"; @@ -1145,7 +1163,7 @@ TEST_F(ValidateCFG, OpSwitchToUnreachableBlock) { Block def("default", SpvOpUnreachable); Block phi("phi", SpvOpReturn); - string str = R"( + std::string str = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" %id @@ -1171,7 +1189,7 @@ OpDecorate %id BuiltIn GlobalInvocationId "%x = OpCompositeExtract %u32 %idval 0\n" "%selector = OpUMod %u32 %x %three\n" "OpSelectionMerge %phi None\n"); - str += entry >> vector({def, case0, case1, case2}); + str += entry >> std::vector({def, case0, case1, case2}); str += case1 >> phi; str += def; str += phi; @@ -1184,7 +1202,7 @@ OpDecorate %id BuiltIn GlobalInvocationId } TEST_F(ValidateCFG, LoopWithZeroBackEdgesBad) { - string str = R"( + std::string str = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %main "main" @@ -1209,7 +1227,7 @@ TEST_F(ValidateCFG, LoopWithZeroBackEdgesBad) { } TEST_F(ValidateCFG, LoopWithBackEdgeFromUnreachableContinueConstructGood) { - string str = R"( + std::string str = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %main "main" @@ -1262,11 +1280,12 @@ TEST_P(ValidateCFG, inner_head.SetBody("OpSelectionMerge %inner_merge None\n"); } - string str = header(GetParam()) + nameOps("entry", "inner_merge", "exit") + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = header(GetParam()) + + nameOps("entry", "inner_merge", "exit") + types_consts() + + "%func = OpFunction %voidt None %funct\n"; - str += entry >> vector({inner_head, exit}); - str += inner_head >> vector({inner_true, inner_false}); + str += entry >> std::vector({inner_head, exit}); + str += inner_head >> std::vector({inner_true, inner_false}); str += inner_true; str += inner_false; str += inner_merge >> exit; @@ -1298,16 +1317,16 @@ TEST_P(ValidateCFG, ContinueTargetCanBeMergeBlockForNestedStructureGood) { if_head.SetBody("OpSelectionMerge %if_merge None\n"); } - string str = + std::string str = header(GetParam()) + nameOps("entry", "loop", "if_head", "if_true", "if_merge", "merge") + types_consts() + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; str += loop >> if_head; - str += if_head >> vector({if_true, if_merge}); + str += if_head >> std::vector({if_true, if_merge}); str += if_true >> if_merge; - str += if_merge >> vector({loop, merge}); + str += if_merge >> std::vector({loop, merge}); str += merge; str += "OpFunctionEnd"; @@ -1329,12 +1348,13 @@ TEST_P(ValidateCFG, SingleLatchBlockMultipleBranchesToLoopHeader) { loop.SetBody("OpLoopMerge %merge %latch None\n"); } - string str = header(GetParam()) + nameOps("entry", "loop", "latch", "merge") + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = + header(GetParam()) + nameOps("entry", "loop", "latch", "merge") + + types_consts() + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; - str += loop >> vector({latch, merge}); - str += latch >> vector({loop, loop}); // This is the key + str += loop >> std::vector({latch, merge}); + str += latch >> std::vector({loop, loop}); // This is the key str += merge; str += "OpFunctionEnd"; @@ -1361,8 +1381,9 @@ TEST_P(ValidateCFG, SingleLatchBlockHeaderContinueTargetIsItselfGood) { loop.SetBody("OpLoopMerge %merge %loop None\n"); } - string str = header(GetParam()) + nameOps("entry", "loop", "latch", "merge") + - types_consts() + "%func = OpFunction %voidt None %funct\n"; + std::string str = + header(GetParam()) + nameOps("entry", "loop", "latch", "merge") + + types_consts() + "%func = OpFunction %voidt None %funct\n"; str += entry >> loop; str += loop >> latch; diff --git a/test/val/val_data_test.cpp b/test/val/val_data_test.cpp index 3a1735fda..916f98276 100644 --- a/test/val/val_data_test.cpp +++ b/test/val/val_data_test.cpp @@ -29,87 +29,83 @@ namespace { using ::testing::HasSubstr; using ::testing::MatchesRegex; -using std::pair; -using std::string; -using std::stringstream; +using ValidateData = spvtest::ValidateBase>; -using ValidateData = spvtest::ValidateBase>; - -string HeaderWith(std::string cap) { +std::string HeaderWith(std::string cap) { return std::string("OpCapability Shader OpCapability Linkage OpCapability ") + cap + " OpMemoryModel Logical GLSL450 "; } -string header = R"( +std::string header = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 )"; -string header_with_addresses = R"( +std::string header_with_addresses = R"( OpCapability Addresses OpCapability Kernel OpCapability GenericPointer OpCapability Linkage OpMemoryModel Physical32 OpenCL )"; -string header_with_vec16_cap = R"( +std::string header_with_vec16_cap = R"( OpCapability Shader OpCapability Vector16 OpCapability Linkage OpMemoryModel Logical GLSL450 )"; -string header_with_int8 = R"( +std::string header_with_int8 = R"( OpCapability Shader OpCapability Linkage OpCapability Int8 OpMemoryModel Logical GLSL450 )"; -string header_with_int16 = R"( +std::string header_with_int16 = R"( OpCapability Shader OpCapability Linkage OpCapability Int16 OpMemoryModel Logical GLSL450 )"; -string header_with_int64 = R"( +std::string header_with_int64 = R"( OpCapability Shader OpCapability Linkage OpCapability Int64 OpMemoryModel Logical GLSL450 )"; -string header_with_float16 = R"( +std::string header_with_float16 = R"( OpCapability Shader OpCapability Linkage OpCapability Float16 OpMemoryModel Logical GLSL450 )"; -string header_with_float16_buffer = R"( +std::string header_with_float16_buffer = R"( OpCapability Shader OpCapability Linkage OpCapability Float16Buffer OpMemoryModel Logical GLSL450 )"; -string header_with_float64 = R"( +std::string header_with_float64 = R"( OpCapability Shader OpCapability Linkage OpCapability Float64 OpMemoryModel Logical GLSL450 )"; -string invalid_comp_error = "Illegal number of components"; -string missing_cap_error = "requires the Vector16 capability"; -string missing_int8_cap_error = "requires the Int8 capability"; -string missing_int16_cap_error = +std::string invalid_comp_error = "Illegal number of components"; +std::string missing_cap_error = "requires the Vector16 capability"; +std::string missing_int8_cap_error = "requires the Int8 capability"; +std::string missing_int16_cap_error = "requires the Int16 capability," " or an extension that explicitly enables 16-bit integers."; -string missing_int64_cap_error = "requires the Int64 capability"; -string missing_float16_cap_error = +std::string missing_int64_cap_error = "requires the Int64 capability"; +std::string missing_float16_cap_error = "requires the Float16 or Float16Buffer capability," " or an extension that explicitly enables 16-bit floating point."; -string missing_float64_cap_error = "requires the Float64 capability"; -string invalid_num_bits_error = "Invalid number of bits"; +std::string missing_float64_cap_error = "requires the Float64 capability"; +std::string invalid_num_bits_error = "Invalid number of bits"; TEST_F(ValidateData, vec0) { - string str = header + R"( + std::string str = header + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 0 )"; @@ -119,7 +115,7 @@ TEST_F(ValidateData, vec0) { } TEST_F(ValidateData, vec1) { - string str = header + R"( + std::string str = header + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 1 )"; @@ -129,7 +125,7 @@ TEST_F(ValidateData, vec1) { } TEST_F(ValidateData, vec2) { - string str = header + R"( + std::string str = header + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 2 )"; @@ -138,7 +134,7 @@ TEST_F(ValidateData, vec2) { } TEST_F(ValidateData, vec3) { - string str = header + R"( + std::string str = header + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 3 )"; @@ -147,7 +143,7 @@ TEST_F(ValidateData, vec3) { } TEST_F(ValidateData, vec4) { - string str = header + R"( + std::string str = header + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 )"; @@ -156,7 +152,7 @@ TEST_F(ValidateData, vec4) { } TEST_F(ValidateData, vec5) { - string str = header + R"( + std::string str = header + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 5 )"; @@ -166,7 +162,7 @@ TEST_F(ValidateData, vec5) { } TEST_F(ValidateData, vec8) { - string str = header + R"( + std::string str = header + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 8 )"; @@ -176,7 +172,7 @@ TEST_F(ValidateData, vec8) { } TEST_F(ValidateData, vec8_with_capability) { - string str = header_with_vec16_cap + R"( + std::string str = header_with_vec16_cap + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 8 )"; @@ -185,7 +181,7 @@ TEST_F(ValidateData, vec8_with_capability) { } TEST_F(ValidateData, vec16) { - string str = header + R"( + std::string str = header + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 8 )"; @@ -195,7 +191,7 @@ TEST_F(ValidateData, vec16) { } TEST_F(ValidateData, vec16_with_capability) { - string str = header_with_vec16_cap + R"( + std::string str = header_with_vec16_cap + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 16 )"; @@ -204,7 +200,7 @@ TEST_F(ValidateData, vec16_with_capability) { } TEST_F(ValidateData, vec15) { - string str = header + R"( + std::string str = header + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 15 )"; @@ -214,62 +210,62 @@ TEST_F(ValidateData, vec15) { } TEST_F(ValidateData, int8_good) { - string str = header_with_int8 + "%2 = OpTypeInt 8 0"; + std::string str = header_with_int8 + "%2 = OpTypeInt 8 0"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateData, int8_bad) { - string str = header + "%2 = OpTypeInt 8 1"; + std::string str = header + "%2 = OpTypeInt 8 1"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr(missing_int8_cap_error)); } TEST_F(ValidateData, int8_with_storage_buffer_8bit_access_good) { - string str = HeaderWith( - "StorageBuffer8BitAccess " - "OpExtension \"SPV_KHR_8bit_storage\"") + - " %2 = OpTypeInt 8 0"; + std::string str = HeaderWith( + "StorageBuffer8BitAccess " + "OpExtension \"SPV_KHR_8bit_storage\"") + + " %2 = OpTypeInt 8 0"; CompileSuccessfully(str.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()) << getDiagnosticString(); } TEST_F(ValidateData, int8_with_uniform_and_storage_buffer_8bit_access_good) { - string str = HeaderWith( - "UniformAndStorageBuffer8BitAccess " - "OpExtension \"SPV_KHR_8bit_storage\"") + - " %2 = OpTypeInt 8 0"; + std::string str = HeaderWith( + "UniformAndStorageBuffer8BitAccess " + "OpExtension \"SPV_KHR_8bit_storage\"") + + " %2 = OpTypeInt 8 0"; CompileSuccessfully(str.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()) << getDiagnosticString(); } TEST_F(ValidateData, int8_with_storage_push_constant_8_good) { - string str = HeaderWith( - "StoragePushConstant8 " - "OpExtension \"SPV_KHR_8bit_storage\"") + - " %2 = OpTypeInt 8 0"; + std::string str = HeaderWith( + "StoragePushConstant8 " + "OpExtension \"SPV_KHR_8bit_storage\"") + + " %2 = OpTypeInt 8 0"; CompileSuccessfully(str.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()) << getDiagnosticString(); } TEST_F(ValidateData, int16_good) { - string str = header_with_int16 + "%2 = OpTypeInt 16 1"; + std::string str = header_with_int16 + "%2 = OpTypeInt 16 1"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateData, storage_uniform_buffer_block_16_good) { - string str = HeaderWith( - "StorageUniformBufferBlock16 " - "OpExtension \"SPV_KHR_16bit_storage\"") + - "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16"; + std::string str = HeaderWith( + "StorageUniformBufferBlock16 " + "OpExtension \"SPV_KHR_16bit_storage\"") + + "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateData, storage_uniform_16_good) { - string str = + std::string str = HeaderWith("StorageUniform16 OpExtension \"SPV_KHR_16bit_storage\"") + "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16"; CompileSuccessfully(str.c_str()); @@ -277,38 +273,38 @@ TEST_F(ValidateData, storage_uniform_16_good) { } TEST_F(ValidateData, storage_push_constant_16_good) { - string str = HeaderWith( - "StoragePushConstant16 " - "OpExtension \"SPV_KHR_16bit_storage\"") + - "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16"; + std::string str = HeaderWith( + "StoragePushConstant16 " + "OpExtension \"SPV_KHR_16bit_storage\"") + + "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateData, storage_input_output_16_good) { - string str = HeaderWith( - "StorageInputOutput16 " - "OpExtension \"SPV_KHR_16bit_storage\"") + - "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16"; + std::string str = HeaderWith( + "StorageInputOutput16 " + "OpExtension \"SPV_KHR_16bit_storage\"") + + "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateData, int16_bad) { - string str = header + "%2 = OpTypeInt 16 1"; + std::string str = header + "%2 = OpTypeInt 16 1"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr(missing_int16_cap_error)); } TEST_F(ValidateData, int64_good) { - string str = header_with_int64 + "%2 = OpTypeInt 64 1"; + std::string str = header_with_int64 + "%2 = OpTypeInt 64 1"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateData, int64_bad) { - string str = header + "%2 = OpTypeInt 64 1"; + std::string str = header + "%2 = OpTypeInt 64 1"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr(missing_int64_cap_error)); @@ -316,39 +312,39 @@ TEST_F(ValidateData, int64_bad) { // Number of bits in an integer may be only one of: {8,16,32,64} TEST_F(ValidateData, int_invalid_num_bits) { - string str = header + "%2 = OpTypeInt 48 1"; + std::string str = header + "%2 = OpTypeInt 48 1"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr(invalid_num_bits_error)); } TEST_F(ValidateData, float16_good) { - string str = header_with_float16 + "%2 = OpTypeFloat 16"; + std::string str = header_with_float16 + "%2 = OpTypeFloat 16"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateData, float16_buffer_good) { - string str = header_with_float16_buffer + "%2 = OpTypeFloat 16"; + std::string str = header_with_float16_buffer + "%2 = OpTypeFloat 16"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateData, float16_bad) { - string str = header + "%2 = OpTypeFloat 16"; + std::string str = header + "%2 = OpTypeFloat 16"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr(missing_float16_cap_error)); } TEST_F(ValidateData, float64_good) { - string str = header_with_float64 + "%2 = OpTypeFloat 64"; + std::string str = header_with_float64 + "%2 = OpTypeFloat 64"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateData, float64_bad) { - string str = header + "%2 = OpTypeFloat 64"; + std::string str = header + "%2 = OpTypeFloat 64"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr(missing_float64_cap_error)); @@ -356,14 +352,14 @@ TEST_F(ValidateData, float64_bad) { // Number of bits in a float may be only one of: {16,32,64} TEST_F(ValidateData, float_invalid_num_bits) { - string str = header + "%2 = OpTypeFloat 48"; + std::string str = header + "%2 = OpTypeFloat 48"; CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr(invalid_num_bits_error)); } TEST_F(ValidateData, matrix_data_type_float) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %vec3 = OpTypeVector %f32 3 %mat33 = OpTypeMatrix %vec3 3 @@ -373,7 +369,7 @@ TEST_F(ValidateData, matrix_data_type_float) { } TEST_F(ValidateData, ids_should_be_validated_before_data) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %mat33 = OpTypeMatrix %vec3 3 )"; @@ -383,7 +379,7 @@ TEST_F(ValidateData, ids_should_be_validated_before_data) { } TEST_F(ValidateData, matrix_bad_column_type) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %mat33 = OpTypeMatrix %f32 3 )"; @@ -394,7 +390,7 @@ TEST_F(ValidateData, matrix_bad_column_type) { } TEST_F(ValidateData, matrix_data_type_int) { - string str = header + R"( + std::string str = header + R"( %int32 = OpTypeInt 32 1 %vec3 = OpTypeVector %int32 3 %mat33 = OpTypeMatrix %vec3 3 @@ -406,7 +402,7 @@ TEST_F(ValidateData, matrix_data_type_int) { } TEST_F(ValidateData, matrix_data_type_bool) { - string str = header + R"( + std::string str = header + R"( %boolt = OpTypeBool %vec3 = OpTypeVector %boolt 3 %mat33 = OpTypeMatrix %vec3 3 @@ -418,7 +414,7 @@ TEST_F(ValidateData, matrix_data_type_bool) { } TEST_F(ValidateData, matrix_with_0_columns) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %vec3 = OpTypeVector %f32 3 %mat33 = OpTypeMatrix %vec3 0 @@ -431,7 +427,7 @@ TEST_F(ValidateData, matrix_with_0_columns) { } TEST_F(ValidateData, matrix_with_1_column) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %vec3 = OpTypeVector %f32 3 %mat33 = OpTypeMatrix %vec3 1 @@ -444,7 +440,7 @@ TEST_F(ValidateData, matrix_with_1_column) { } TEST_F(ValidateData, matrix_with_2_columns) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %vec3 = OpTypeVector %f32 3 %mat33 = OpTypeMatrix %vec3 2 @@ -454,7 +450,7 @@ TEST_F(ValidateData, matrix_with_2_columns) { } TEST_F(ValidateData, matrix_with_3_columns) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %vec3 = OpTypeVector %f32 3 %mat33 = OpTypeMatrix %vec3 3 @@ -464,7 +460,7 @@ TEST_F(ValidateData, matrix_with_3_columns) { } TEST_F(ValidateData, matrix_with_4_columns) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %vec3 = OpTypeVector %f32 3 %mat33 = OpTypeMatrix %vec3 4 @@ -474,7 +470,7 @@ TEST_F(ValidateData, matrix_with_4_columns) { } TEST_F(ValidateData, matrix_with_5_column) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %vec3 = OpTypeVector %f32 3 %mat33 = OpTypeMatrix %vec3 5 @@ -487,7 +483,7 @@ TEST_F(ValidateData, matrix_with_5_column) { } TEST_F(ValidateData, specialize_int) { - string str = header + R"( + std::string str = header + R"( %i32 = OpTypeInt 32 1 %len = OpSpecConstant %i32 2)"; CompileSuccessfully(str.c_str()); @@ -495,7 +491,7 @@ TEST_F(ValidateData, specialize_int) { } TEST_F(ValidateData, specialize_float) { - string str = header + R"( + std::string str = header + R"( %f32 = OpTypeFloat 32 %len = OpSpecConstant %f32 2)"; CompileSuccessfully(str.c_str()); @@ -503,7 +499,7 @@ TEST_F(ValidateData, specialize_float) { } TEST_F(ValidateData, specialize_boolean) { - string str = header + R"( + std::string str = header + R"( %2 = OpTypeBool %3 = OpSpecConstantTrue %2 %4 = OpSpecConstantFalse %2)"; @@ -512,7 +508,7 @@ TEST_F(ValidateData, specialize_boolean) { } TEST_F(ValidateData, specialize_boolean_to_int) { - string str = header + R"( + std::string str = header + R"( %2 = OpTypeInt 32 1 %3 = OpSpecConstantTrue %2 %4 = OpSpecConstantFalse %2)"; @@ -523,7 +519,7 @@ TEST_F(ValidateData, specialize_boolean_to_int) { } TEST_F(ValidateData, missing_forward_pointer_decl) { - string str = header_with_addresses + R"( + std::string str = header_with_addresses + R"( %uintt = OpTypeInt 32 0 %3 = OpTypeStruct %fwd_ptrt %uintt )"; @@ -534,7 +530,7 @@ TEST_F(ValidateData, missing_forward_pointer_decl) { } TEST_F(ValidateData, forward_pointer_missing_definition) { - string str = header_with_addresses + R"( + std::string str = header_with_addresses + R"( OpTypeForwardPointer %_ptr_Generic_struct_A Generic %uintt = OpTypeInt 32 0 %struct_B = OpTypeStruct %uintt %_ptr_Generic_struct_A @@ -546,7 +542,7 @@ OpTypeForwardPointer %_ptr_Generic_struct_A Generic } TEST_F(ValidateData, forward_ref_bad_type) { - string str = header_with_addresses + R"( + std::string str = header_with_addresses + R"( OpTypeForwardPointer %_ptr_Generic_struct_A Generic %uintt = OpTypeInt 32 0 %struct_B = OpTypeStruct %uintt %_ptr_Generic_struct_A @@ -560,7 +556,7 @@ OpTypeForwardPointer %_ptr_Generic_struct_A Generic } TEST_F(ValidateData, forward_ref_points_to_non_struct) { - string str = header_with_addresses + R"( + std::string str = header_with_addresses + R"( OpTypeForwardPointer %_ptr_Generic_struct_A Generic %uintt = OpTypeInt 32 0 %struct_B = OpTypeStruct %uintt %_ptr_Generic_struct_A @@ -575,7 +571,7 @@ OpTypeForwardPointer %_ptr_Generic_struct_A Generic } TEST_F(ValidateData, struct_forward_pointer_good) { - string str = header_with_addresses + R"( + std::string str = header_with_addresses + R"( OpTypeForwardPointer %_ptr_Generic_struct_A Generic %uintt = OpTypeInt 32 0 %struct_B = OpTypeStruct %uintt %_ptr_Generic_struct_A @@ -591,15 +587,14 @@ TEST_F(ValidateData, ext_16bit_storage_caps_allow_free_fp_rounding_mode) { for (const char* cap : {"StorageUniform16", "StorageUniformBufferBlock16", "StoragePushConstant16", "StorageInputOutput16"}) { for (const char* mode : {"RTE", "RTZ", "RTP", "RTN"}) { - string str = string(R"( + std::string str = std::string(R"( OpCapability Shader OpCapability Linkage OpCapability )") + - cap + R"( + cap + R"( OpExtension "SPV_KHR_16bit_storage" OpMemoryModel Logical GLSL450 - OpDecorate %2 FPRoundingMode )" + - mode + R"( + OpDecorate %2 FPRoundingMode )" + mode + R"( %1 = OpTypeFloat 32 %2 = OpConstant %1 1.25 )"; @@ -612,11 +607,11 @@ TEST_F(ValidateData, ext_16bit_storage_caps_allow_free_fp_rounding_mode) { TEST_F(ValidateData, vulkan_disallow_free_fp_rounding_mode) { for (const char* mode : {"RTE", "RTZ"}) { for (const auto env : {SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1}) { - string str = string(R"( + std::string str = std::string(R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpDecorate %2 FPRoundingMode )") + - mode + R"( + mode + R"( %1 = OpTypeFloat 32 %2 = OpConstant %1 1.25 )"; diff --git a/test/val/val_decoration_test.cpp b/test/val/val_decoration_test.cpp index 87130e8c0..d2905ae97 100644 --- a/test/val/val_decoration_test.cpp +++ b/test/val/val_decoration_test.cpp @@ -23,15 +23,13 @@ namespace spvtools { namespace val { namespace { -using std::string; -using std::vector; using ::testing::Eq; using ::testing::HasSubstr; using ValidateDecorations = spvtest::ValidateBase; TEST_F(ValidateDecorations, ValidateOpDecorateRegistration) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -45,13 +43,14 @@ TEST_F(ValidateDecorations, ValidateOpDecorateRegistration) { CompileSuccessfully(spirv); EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); // Must have 2 decorations. - EXPECT_THAT(vstate_->id_decorations(id), - Eq(vector{Decoration(SpvDecorationArrayStride, {4}), - Decoration(SpvDecorationUniform)})); + EXPECT_THAT( + vstate_->id_decorations(id), + Eq(std::vector{Decoration(SpvDecorationArrayStride, {4}), + Decoration(SpvDecorationUniform)})); } TEST_F(ValidateDecorations, ValidateOpMemberDecorateRegistration) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -72,18 +71,19 @@ TEST_F(ValidateDecorations, ValidateOpMemberDecorateRegistration) { const uint32_t arr_id = 1; EXPECT_THAT( vstate_->id_decorations(arr_id), - Eq(vector{Decoration(SpvDecorationArrayStride, {4})})); + Eq(std::vector{Decoration(SpvDecorationArrayStride, {4})})); // The struct must have 3 decorations. const uint32_t struct_id = 2; - EXPECT_THAT(vstate_->id_decorations(struct_id), - Eq(vector{Decoration(SpvDecorationNonReadable, {}, 2), - Decoration(SpvDecorationOffset, {2}, 2), - Decoration(SpvDecorationBufferBlock)})); + EXPECT_THAT( + vstate_->id_decorations(struct_id), + Eq(std::vector{Decoration(SpvDecorationNonReadable, {}, 2), + Decoration(SpvDecorationOffset, {2}, 2), + Decoration(SpvDecorationBufferBlock)})); } TEST_F(ValidateDecorations, ValidateGroupDecorateRegistration) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -109,7 +109,7 @@ TEST_F(ValidateDecorations, ValidateGroupDecorateRegistration) { EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); // Decoration group has 3 decorations. - auto expected_decorations = vector{ + auto expected_decorations = std::vector{ Decoration(SpvDecorationDescriptorSet, {0}), Decoration(SpvDecorationNonWritable), Decoration(SpvDecorationRestrict)}; @@ -122,7 +122,7 @@ TEST_F(ValidateDecorations, ValidateGroupDecorateRegistration) { } TEST_F(ValidateDecorations, ValidateGroupMemberDecorateRegistration) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -139,7 +139,7 @@ TEST_F(ValidateDecorations, ValidateGroupMemberDecorateRegistration) { EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); // Decoration group has 1 decoration. auto expected_decorations = - vector{Decoration(SpvDecorationOffset, {3}, 3)}; + std::vector{Decoration(SpvDecorationOffset, {3}, 3)}; // Decoration group is applied to id 2, 3, and 4. EXPECT_THAT(vstate_->id_decorations(2), Eq(expected_decorations)); @@ -148,7 +148,7 @@ TEST_F(ValidateDecorations, ValidateGroupMemberDecorateRegistration) { } TEST_F(ValidateDecorations, LinkageImportUsedForInitializedVariableBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -165,7 +165,7 @@ TEST_F(ValidateDecorations, LinkageImportUsedForInitializedVariableBad) { "cannot be marked with the Import Linkage Type.")); } TEST_F(ValidateDecorations, LinkageExportUsedForInitializedVariableGood) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -180,7 +180,7 @@ TEST_F(ValidateDecorations, LinkageExportUsedForInitializedVariableGood) { } TEST_F(ValidateDecorations, StructAllMembersHaveBuiltInDecorationsGood) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -197,7 +197,7 @@ TEST_F(ValidateDecorations, StructAllMembersHaveBuiltInDecorationsGood) { } TEST_F(ValidateDecorations, MixedBuiltInDecorationsBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -219,7 +219,7 @@ TEST_F(ValidateDecorations, MixedBuiltInDecorationsBad) { } TEST_F(ValidateDecorations, StructContainsBuiltInStructBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -242,7 +242,7 @@ TEST_F(ValidateDecorations, StructContainsBuiltInStructBad) { } TEST_F(ValidateDecorations, StructContainsNonBuiltInStructGood) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -255,7 +255,7 @@ TEST_F(ValidateDecorations, StructContainsNonBuiltInStructGood) { } TEST_F(ValidateDecorations, MultipleBuiltInObjectsConsumedByOpEntryPointBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Geometry OpMemoryModel Logical GLSL450 @@ -287,7 +287,7 @@ TEST_F(ValidateDecorations, MultipleBuiltInObjectsConsumedByOpEntryPointBad) { TEST_F(ValidateDecorations, OneBuiltInObjectPerStorageClassConsumedByOpEntryPointGood) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Geometry OpMemoryModel Logical GLSL450 @@ -314,7 +314,7 @@ TEST_F(ValidateDecorations, } TEST_F(ValidateDecorations, NoBuiltInObjectsConsumedByOpEntryPointGood) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Geometry OpMemoryModel Logical GLSL450 @@ -339,7 +339,7 @@ TEST_F(ValidateDecorations, NoBuiltInObjectsConsumedByOpEntryPointGood) { } TEST_F(ValidateDecorations, EntryPointFunctionHasLinkageAttributeBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -362,7 +362,7 @@ TEST_F(ValidateDecorations, EntryPointFunctionHasLinkageAttributeBad) { } TEST_F(ValidateDecorations, FunctionDeclarationWithoutImportLinkageBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -380,7 +380,7 @@ TEST_F(ValidateDecorations, FunctionDeclarationWithoutImportLinkageBad) { } TEST_F(ValidateDecorations, FunctionDeclarationWithImportLinkageGood) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -395,7 +395,7 @@ TEST_F(ValidateDecorations, FunctionDeclarationWithImportLinkageGood) { } TEST_F(ValidateDecorations, FunctionDeclarationWithExportLinkageBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -414,7 +414,7 @@ TEST_F(ValidateDecorations, FunctionDeclarationWithExportLinkageBad) { } TEST_F(ValidateDecorations, FunctionDefinitionWithImportLinkageBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -434,7 +434,7 @@ TEST_F(ValidateDecorations, FunctionDefinitionWithImportLinkageBad) { } TEST_F(ValidateDecorations, FunctionDefinitionWithoutImportLinkageGood) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -727,7 +727,7 @@ TEST_F(ValidateDecorations, ArrayOfArraysOfDescriptorSetsIsDisallowed) { } TEST_F(ValidateDecorations, BlockMissingOffsetBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -754,7 +754,7 @@ TEST_F(ValidateDecorations, BlockMissingOffsetBad) { } TEST_F(ValidateDecorations, BufferBlockMissingOffsetBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -781,7 +781,7 @@ TEST_F(ValidateDecorations, BufferBlockMissingOffsetBad) { } TEST_F(ValidateDecorations, BlockNestedStructMissingOffsetBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -816,7 +816,7 @@ TEST_F(ValidateDecorations, BlockNestedStructMissingOffsetBad) { } TEST_F(ValidateDecorations, BufferBlockNestedStructMissingOffsetBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -851,7 +851,7 @@ TEST_F(ValidateDecorations, BufferBlockNestedStructMissingOffsetBad) { } TEST_F(ValidateDecorations, BlockGLSLSharedBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -880,7 +880,7 @@ TEST_F(ValidateDecorations, BlockGLSLSharedBad) { } TEST_F(ValidateDecorations, BufferBlockGLSLSharedBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -909,7 +909,7 @@ TEST_F(ValidateDecorations, BufferBlockGLSLSharedBad) { } TEST_F(ValidateDecorations, BlockNestedStructGLSLSharedBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -944,7 +944,7 @@ TEST_F(ValidateDecorations, BlockNestedStructGLSLSharedBad) { } TEST_F(ValidateDecorations, BufferBlockNestedStructGLSLSharedBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -979,7 +979,7 @@ TEST_F(ValidateDecorations, BufferBlockNestedStructGLSLSharedBad) { } TEST_F(ValidateDecorations, BlockGLSLPackedBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1008,7 +1008,7 @@ TEST_F(ValidateDecorations, BlockGLSLPackedBad) { } TEST_F(ValidateDecorations, BufferBlockGLSLPackedBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1037,7 +1037,7 @@ TEST_F(ValidateDecorations, BufferBlockGLSLPackedBad) { } TEST_F(ValidateDecorations, BlockNestedStructGLSLPackedBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1072,7 +1072,7 @@ TEST_F(ValidateDecorations, BlockNestedStructGLSLPackedBad) { } TEST_F(ValidateDecorations, BufferBlockNestedStructGLSLPackedBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1107,7 +1107,7 @@ TEST_F(ValidateDecorations, BufferBlockNestedStructGLSLPackedBad) { } TEST_F(ValidateDecorations, BlockMissingArrayStrideBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1139,7 +1139,7 @@ TEST_F(ValidateDecorations, BlockMissingArrayStrideBad) { } TEST_F(ValidateDecorations, BufferBlockMissingArrayStrideBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1171,7 +1171,7 @@ TEST_F(ValidateDecorations, BufferBlockMissingArrayStrideBad) { } TEST_F(ValidateDecorations, BlockNestedStructMissingArrayStrideBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1208,7 +1208,7 @@ TEST_F(ValidateDecorations, BlockNestedStructMissingArrayStrideBad) { } TEST_F(ValidateDecorations, BufferBlockNestedStructMissingArrayStrideBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1245,7 +1245,7 @@ TEST_F(ValidateDecorations, BufferBlockNestedStructMissingArrayStrideBad) { } TEST_F(ValidateDecorations, BlockMissingMatrixStrideBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1276,7 +1276,7 @@ TEST_F(ValidateDecorations, BlockMissingMatrixStrideBad) { } TEST_F(ValidateDecorations, BufferBlockMissingMatrixStrideBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1307,7 +1307,7 @@ TEST_F(ValidateDecorations, BufferBlockMissingMatrixStrideBad) { } TEST_F(ValidateDecorations, BlockMissingMatrixStrideArrayBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1341,7 +1341,7 @@ TEST_F(ValidateDecorations, BlockMissingMatrixStrideArrayBad) { } TEST_F(ValidateDecorations, BufferBlockMissingMatrixStrideArrayBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1375,7 +1375,7 @@ TEST_F(ValidateDecorations, BufferBlockMissingMatrixStrideArrayBad) { } TEST_F(ValidateDecorations, BlockNestedStructMissingMatrixStrideBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1411,7 +1411,7 @@ TEST_F(ValidateDecorations, BlockNestedStructMissingMatrixStrideBad) { } TEST_F(ValidateDecorations, BufferBlockNestedStructMissingMatrixStrideBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1447,7 +1447,7 @@ TEST_F(ValidateDecorations, BufferBlockNestedStructMissingMatrixStrideBad) { } TEST_F(ValidateDecorations, BlockStandardUniformBufferLayout) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -1509,7 +1509,7 @@ TEST_F(ValidateDecorations, BlockStandardUniformBufferLayout) { TEST_F(ValidateDecorations, BlockLayoutPermitsTightVec3ScalarPackingGood) { // See https://github.com/KhronosGroup/SPIRV-Tools/issues/1666 - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1539,7 +1539,7 @@ TEST_F(ValidateDecorations, BlockLayoutPermitsTightVec3ScalarPackingGood) { TEST_F(ValidateDecorations, BlockLayoutForbidsTightScalarVec3PackingBad) { // See https://github.com/KhronosGroup/SPIRV-Tools/issues/1666 - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1574,7 +1574,7 @@ TEST_F(ValidateDecorations, BlockLayoutForbidsTightScalarVec3PackingBad) { TEST_F(ValidateDecorations, BlockLayoutPermitsTightScalarVec3PackingWithRelaxedLayoutGood) { // Same as previous test, but with explicit option to relax block layout. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1608,7 +1608,7 @@ TEST_F(ValidateDecorations, BlockLayoutPermitsTightScalarVec3PackingBadOffsetWithRelaxedLayoutBad) { // Same as previous test, but with the vector not aligned to its scalar // element. Use offset 5 instead of a multiple of 4. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1647,7 +1647,7 @@ TEST_F(ValidateDecorations, BlockLayoutPermitsTightScalarVec3PackingWithVulkan1_1Good) { // Same as previous test, but with Vulkan 1.1. Vulkan 1.1 included // VK_KHR_relaxed_block_layout in core. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1677,7 +1677,7 @@ TEST_F(ValidateDecorations, } TEST_F(ValidateDecorations, BufferBlock16bitStandardStorageBufferLayout) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability StorageUniform16 OpExtension "SPV_KHR_16bit_storage" @@ -1720,7 +1720,7 @@ TEST_F(ValidateDecorations, BufferBlock16bitStandardStorageBufferLayout) { TEST_F(ValidateDecorations, BlockArrayBaseAlignmentGood) { // For uniform buffer, Array base alignment is 16, and ArrayStride // must be a multiple of 16. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1752,7 +1752,7 @@ TEST_F(ValidateDecorations, BlockArrayBaseAlignmentGood) { TEST_F(ValidateDecorations, BlockArrayBadAlignmentBad) { // For uniform buffer, Array base alignment is 16. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1791,7 +1791,7 @@ TEST_F(ValidateDecorations, BlockArrayBadAlignmentWithRelaxedLayoutStillBad) { // For uniform buffer, Array base alignment is 16, and ArrayStride // must be a multiple of 16. This case uses relaxed block layout. Relaxed // layout only relaxes rules for vector alignment, not array alignment. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1831,7 +1831,7 @@ TEST_F(ValidateDecorations, BlockArrayBadAlignmentWithRelaxedLayoutStillBad) { TEST_F(ValidateDecorations, BlockArrayBadAlignmentWithVulkan1_1StillBad) { // Same as previous test, but with Vulkan 1.1, which includes // VK_KHR_relaxed_block_layout in core. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1874,7 +1874,7 @@ TEST_F(ValidateDecorations, PushConstantArrayBaseAlignmentGood) { // layout(push_constant) uniform S { vec2 v; float arr[2]; } u; // void main() { } - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1906,7 +1906,7 @@ TEST_F(ValidateDecorations, PushConstantArrayBaseAlignmentGood) { TEST_F(ValidateDecorations, PushConstantArrayBadAlignmentBad) { // Like the previous test, but with offset 7 instead of 8. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1944,7 +1944,7 @@ TEST_F(ValidateDecorations, PushConstantArrayBadAlignmentBad) { TEST_F(ValidateDecorations, PushConstantLayoutPermitsTightVec3ScalarPackingGood) { // See https://github.com/KhronosGroup/SPIRV-Tools/issues/1666 - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -1973,7 +1973,7 @@ TEST_F(ValidateDecorations, TEST_F(ValidateDecorations, PushConstantLayoutForbidsTightScalarVec3PackingBad) { // See https://github.com/KhronosGroup/SPIRV-Tools/issues/1666 - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" @@ -2007,7 +2007,7 @@ TEST_F(ValidateDecorations, TEST_F(ValidateDecorations, StorageBufferStorageClassArrayBaseAlignmentGood) { // Spot check buffer rules when using StorageBuffer storage class with Block // decoration. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" OpMemoryModel Logical GLSL450 @@ -2042,7 +2042,7 @@ TEST_F(ValidateDecorations, StorageBufferStorageClassArrayBaseAlignmentGood) { TEST_F(ValidateDecorations, StorageBufferStorageClassArrayBadAlignmentBad) { // Like the previous test, but with offset 7. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" OpMemoryModel Logical GLSL450 @@ -2081,7 +2081,7 @@ TEST_F(ValidateDecorations, StorageBufferStorageClassArrayBadAlignmentBad) { } TEST_F(ValidateDecorations, BufferBlockStandardStorageBufferLayout) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2144,7 +2144,7 @@ TEST_F(ValidateDecorations, BufferBlockStandardStorageBufferLayout) { TEST_F(ValidateDecorations, StorageBufferLayoutPermitsTightVec3ScalarPackingGood) { // See https://github.com/KhronosGroup/SPIRV-Tools/issues/1666 - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" OpMemoryModel Logical GLSL450 @@ -2176,7 +2176,7 @@ TEST_F(ValidateDecorations, TEST_F(ValidateDecorations, StorageBufferLayoutForbidsTightScalarVec3PackingBad) { // See https://github.com/KhronosGroup/SPIRV-Tools/issues/1666 - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" OpMemoryModel Logical GLSL450 @@ -2212,7 +2212,7 @@ TEST_F(ValidateDecorations, TEST_F(ValidateDecorations, BlockStandardUniformBufferLayoutIncorrectOffset0Bad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2279,7 +2279,7 @@ TEST_F(ValidateDecorations, TEST_F(ValidateDecorations, BlockStandardUniformBufferLayoutIncorrectOffset1Bad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2345,7 +2345,7 @@ TEST_F(ValidateDecorations, } TEST_F(ValidateDecorations, BlockUniformBufferLayoutIncorrectArrayStrideBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2413,7 +2413,7 @@ TEST_F(ValidateDecorations, BlockUniformBufferLayoutIncorrectArrayStrideBad) { TEST_F(ValidateDecorations, BufferBlockStandardStorageBufferLayoutImproperStraddleBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2448,7 +2448,7 @@ TEST_F(ValidateDecorations, TEST_F(ValidateDecorations, BlockUniformBufferLayoutOffsetInsideArrayPaddingBad) { // In this case the 2nd member fits entirely within the padding. - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2488,7 +2488,7 @@ TEST_F(ValidateDecorations, TEST_F(ValidateDecorations, BlockUniformBufferLayoutOffsetInsideStructPaddingBad) { // In this case the 2nd member fits entirely within the padding. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %1 "main" @@ -2520,7 +2520,7 @@ TEST_F(ValidateDecorations, } TEST_F(ValidateDecorations, BlockLayoutOffsetOutOfOrderBadUniversal1_0) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2555,7 +2555,7 @@ TEST_F(ValidateDecorations, BlockLayoutOffsetOutOfOrderBadUniversal1_0) { } TEST_F(ValidateDecorations, BlockLayoutOffsetOutOfOrderBadOpenGL4_5) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2590,7 +2590,7 @@ TEST_F(ValidateDecorations, BlockLayoutOffsetOutOfOrderBadOpenGL4_5) { } TEST_F(ValidateDecorations, BlockLayoutOffsetOutOfOrderGoodVulkan1_1) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2620,7 +2620,7 @@ TEST_F(ValidateDecorations, BlockLayoutOffsetOutOfOrderGoodVulkan1_1) { } TEST_F(ValidateDecorations, BlockLayoutOffsetOverlapBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2657,7 +2657,7 @@ TEST_F(ValidateDecorations, BlockLayoutOffsetOverlapBad) { } TEST_F(ValidateDecorations, BufferBlockEmptyStruct) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2700,7 +2700,7 @@ TEST_F(ValidateDecorations, RowMajorMatrixTightPackingGood) { // d -> 60 ; d fits at bytes 12-15 after offset of c. Tight (vec3;float) // packing - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %1 "main" @@ -2739,7 +2739,7 @@ TEST_F(ValidateDecorations, ArrayArrayRowMajorMatrixTightPackingGood) { // Like the previous case, but we have an array of arrays of matrices. // The RowMajor decoration goes on the struct member (surprisingly). - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %1 "main" @@ -2783,7 +2783,7 @@ TEST_F(ValidateDecorations, ArrayArrayRowMajorMatrixTightPackingGood) { TEST_F(ValidateDecorations, ArrayArrayRowMajorMatrixNextMemberOverlapsBad) { // Like the previous case, but the offset of member 2 overlaps the matrix. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %1 "main" @@ -2840,7 +2840,7 @@ TEST_F(ValidateDecorations, StorageBufferArraySizeCalculationPackGood) { // } B; // void main() {} - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %1 "main" @@ -2874,7 +2874,7 @@ TEST_F(ValidateDecorations, StorageBufferArraySizeCalculationPackGood) { TEST_F(ValidateDecorations, StorageBufferArraySizeCalculationPackBad) { // Like previous but, the offset of the second member is too small. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %1 "main" @@ -2914,7 +2914,7 @@ TEST_F(ValidateDecorations, UniformBufferArraySizeCalculationPackGood) { // Like the corresponding buffer block case, but the array padding must // count for the last element as well, and so the offset of the second // member must be at least 64. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %1 "main" @@ -2948,7 +2948,7 @@ TEST_F(ValidateDecorations, UniformBufferArraySizeCalculationPackGood) { TEST_F(ValidateDecorations, UniformBufferArraySizeCalculationPackBad) { // Like previous but, the offset of the second member is too small. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %1 "main" @@ -2988,7 +2988,7 @@ TEST_F(ValidateDecorations, UniformBufferArraySizeCalculationPackBad) { TEST_F(ValidateDecorations, LayoutNotCheckedWhenSkipBlockLayout) { // Checks that block layout is not verified in skipping block layout mode. // Even for obviously wrong layout. - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" diff --git a/test/val/val_extensions_test.cpp b/test/val/val_extensions_test.cpp index 9fdb2f68c..328e22ac4 100644 --- a/test/val/val_extensions_test.cpp +++ b/test/val/val_extensions_test.cpp @@ -33,14 +33,12 @@ using ::testing::Not; using ::testing::Values; using ::testing::ValuesIn; -using std::string; - -using ValidateKnownExtensions = spvtest::ValidateBase; -using ValidateUnknownExtensions = spvtest::ValidateBase; +using ValidateKnownExtensions = spvtest::ValidateBase; +using ValidateUnknownExtensions = spvtest::ValidateBase; using ValidateExtensionCapabilities = spvtest::ValidateBase; // Returns expected error string if |extension| is not recognized. -string GetErrorString(const std::string& extension) { +std::string GetErrorString(const std::string& extension) { return "Found unrecognized extension " + extension; } @@ -71,7 +69,7 @@ INSTANTIATE_TEST_CASE_P(FailSilently, ValidateUnknownExtensions, TEST_P(ValidateKnownExtensions, ExpectSuccess) { const std::string extension = GetParam(); - const string str = + const std::string str = "OpCapability Shader\nOpCapability Linkage\nOpExtension \"" + extension + "\"\nOpMemoryModel Logical GLSL450"; CompileSuccessfully(str.c_str()); @@ -81,7 +79,7 @@ TEST_P(ValidateKnownExtensions, ExpectSuccess) { TEST_P(ValidateUnknownExtensions, FailSilently) { const std::string extension = GetParam(); - const string str = + const std::string str = "OpCapability Shader\nOpCapability Linkage\nOpExtension \"" + extension + "\"\nOpMemoryModel Logical GLSL450"; CompileSuccessfully(str.c_str()); @@ -90,7 +88,7 @@ TEST_P(ValidateUnknownExtensions, FailSilently) { } TEST_F(ValidateExtensionCapabilities, DeclCapabilitySuccess) { - const string str = + const std::string str = "OpCapability Shader\nOpCapability Linkage\nOpCapability DeviceGroup\n" "OpExtension \"SPV_KHR_device_group\"" "\nOpMemoryModel Logical GLSL450"; @@ -99,7 +97,7 @@ TEST_F(ValidateExtensionCapabilities, DeclCapabilitySuccess) { } TEST_F(ValidateExtensionCapabilities, DeclCapabilityFailure) { - const string str = + const std::string str = "OpCapability Shader\nOpCapability Linkage\nOpCapability DeviceGroup\n" "\nOpMemoryModel Logical GLSL450"; CompileSuccessfully(str.c_str()); @@ -110,16 +108,16 @@ TEST_F(ValidateExtensionCapabilities, DeclCapabilityFailure) { EXPECT_THAT(getDiagnosticString(), HasSubstr("SPV_KHR_device_group")); } -using ValidateAMDShaderBallotCapabilities = spvtest::ValidateBase; +using ValidateAMDShaderBallotCapabilities = spvtest::ValidateBase; // Returns a vector of strings for the prefix of a SPIR-V assembly shader // that can use the group instructions introduced by SPV_AMD_shader_ballot. -std::vector ShaderPartsForAMDShaderBallot() { - return std::vector{R"( +std::vector ShaderPartsForAMDShaderBallot() { + return std::vector{R"( OpCapability Shader OpCapability Linkage )", - R"( + R"( OpMemoryModel Logical GLSL450 %float = OpTypeFloat 32 %uint = OpTypeInt 32 0 @@ -139,8 +137,8 @@ std::vector ShaderPartsForAMDShaderBallot() { // Returns a list of SPIR-V assembly strings, where each uses only types // and IDs that can fit with a shader made from parts from the result // of ShaderPartsForAMDShaderBallot. -std::vector AMDShaderBallotGroupInstructions() { - return std::vector{ +std::vector AMDShaderBallotGroupInstructions() { + return std::vector{ "%iadd_reduce = OpGroupIAddNonUniformAMD %uint %scope Reduce %uint_const", "%iadd_iscan = OpGroupIAddNonUniformAMD %uint %scope InclusiveScan " "%uint_const", @@ -197,8 +195,9 @@ TEST_P(ValidateAMDShaderBallotCapabilities, ExpectSuccess) { // Succeed because the module specifies the SPV_AMD_shader_ballot extension. auto parts = ShaderPartsForAMDShaderBallot(); - const string assembly = parts[0] + "OpExtension \"SPV_AMD_shader_ballot\"\n" + - parts[1] + GetParam() + "\nOpReturn OpFunctionEnd"; + const std::string assembly = + parts[0] + "OpExtension \"SPV_AMD_shader_ballot\"\n" + parts[1] + + GetParam() + "\nOpReturn OpFunctionEnd"; CompileSuccessfully(assembly.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()) << getDiagnosticString(); @@ -212,7 +211,7 @@ TEST_P(ValidateAMDShaderBallotCapabilities, ExpectFailure) { // extension. auto parts = ShaderPartsForAMDShaderBallot(); - const string assembly = + const std::string assembly = parts[0] + parts[1] + GetParam() + "\nOpReturn OpFunctionEnd"; CompileSuccessfully(assembly.c_str()); @@ -222,9 +221,10 @@ TEST_P(ValidateAMDShaderBallotCapabilities, ExpectFailure) { // Find just the opcode name, skipping over the "Op" part. auto prefix_with_opcode = GetParam().substr(GetParam().find("Group")); auto opcode = prefix_with_opcode.substr(0, prefix_with_opcode.find(' ')); - EXPECT_THAT(getDiagnosticString(), - HasSubstr(string("Opcode " + opcode + - " requires one of these capabilities: Groups"))); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr(std::string("Opcode " + opcode + + " requires one of these capabilities: Groups"))); } INSTANTIATE_TEST_CASE_P(ExpectFailure, ValidateAMDShaderBallotCapabilities, @@ -244,10 +244,10 @@ using ValidateExtIntoCore = spvtest::ValidateBase; // functionalities that introduced in extensions but became core SPIR-V later. TEST_P(ValidateExtIntoCore, DoNotAskForExtensionInLaterVersion) { - const string code = string(R"( + const std::string code = std::string(R"( OpCapability Shader OpCapability )") + - GetParam().cap + R"( + GetParam().cap + R"( OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %main "main" %builtin OpDecorate %builtin BuiltIn )" + GetParam().builtin + R"( @@ -267,14 +267,14 @@ TEST_P(ValidateExtIntoCore, DoNotAskForExtensionInLaterVersion) { ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(GetParam().env)); } else { ASSERT_NE(SPV_SUCCESS, ValidateInstructions(GetParam().env)); - const string message = getDiagnosticString(); + const std::string message = getDiagnosticString(); if (spvIsVulkanEnv(GetParam().env)) { - EXPECT_THAT(message, HasSubstr(string(GetParam().cap) + + EXPECT_THAT(message, HasSubstr(std::string(GetParam().cap) + " is not allowed by Vulkan")); - EXPECT_THAT(message, HasSubstr(string("or requires extension"))); + EXPECT_THAT(message, HasSubstr(std::string("or requires extension"))); } else { EXPECT_THAT(message, - HasSubstr(string("requires one of these extensions: ") + + HasSubstr(std::string("requires one of these extensions: ") + GetParam().ext)); } } diff --git a/test/val/val_id_test.cpp b/test/val/val_id_test.cpp index 9e60d4367..09f1239e4 100644 --- a/test/val/val_id_test.cpp +++ b/test/val/val_id_test.cpp @@ -31,15 +31,12 @@ namespace val { namespace { using spvtest::ScopedContext; -using std::ostringstream; -using std::string; -using std::vector; using ::testing::HasSubstr; using ::testing::ValuesIn; using ValidateIdWithMessage = spvtest::ValidateBase; -string kOpCapabilitySetup = R"( +std::string kOpCapabilitySetup = R"( OpCapability Shader OpCapability Linkage OpCapability Addresses @@ -53,11 +50,11 @@ string kOpCapabilitySetup = R"( OpCapability Float64 )"; -string kGLSL450MemoryModel = kOpCapabilitySetup + R"( +std::string kGLSL450MemoryModel = kOpCapabilitySetup + R"( OpMemoryModel Logical GLSL450 )"; -string kOpenCLMemoryModel32 = R"( +std::string kOpenCLMemoryModel32 = R"( OpCapability Addresses OpCapability Linkage OpCapability Kernel @@ -65,7 +62,7 @@ string kOpenCLMemoryModel32 = R"( OpMemoryModel Physical32 OpenCL )"; -string kOpenCLMemoryModel64 = R"( +std::string kOpenCLMemoryModel64 = R"( OpCapability Addresses OpCapability Linkage OpCapability Kernel @@ -74,7 +71,7 @@ string kOpenCLMemoryModel64 = R"( OpMemoryModel Physical64 OpenCL )"; -string sampledImageSetup = R"( +std::string sampledImageSetup = R"( %void = OpTypeVoid %typeFuncVoid = OpTypeFunction %void %float = OpTypeFloat 32 @@ -99,7 +96,7 @@ string sampledImageSetup = R"( %sampler_inst = OpLoad %sampler_type %s )"; -string BranchConditionalSetup = R"( +std::string BranchConditionalSetup = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -129,7 +126,7 @@ string BranchConditionalSetup = R"( %lmain = OpLabel )"; -string BranchConditionalTail = R"( +std::string BranchConditionalTail = R"( %target_t = OpLabel OpNop OpBranch %end @@ -146,7 +143,7 @@ string BranchConditionalTail = R"( // TODO: OpUndef TEST_F(ValidateIdWithMessage, OpName) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpName %2 "name" %1 = OpTypeInt 32 0 %2 = OpTypePointer UniformConstant %1 @@ -156,7 +153,7 @@ TEST_F(ValidateIdWithMessage, OpName) { } TEST_F(ValidateIdWithMessage, OpMemberNameGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberName %2 0 "foo" %1 = OpTypeInt 32 0 %2 = OpTypeStruct %1)"; @@ -164,7 +161,7 @@ TEST_F(ValidateIdWithMessage, OpMemberNameGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpMemberNameTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberName %1 0 "foo" %1 = OpTypeInt 32 0)"; CompileSuccessfully(spirv.c_str()); @@ -174,7 +171,7 @@ TEST_F(ValidateIdWithMessage, OpMemberNameTypeBad) { HasSubstr("OpMemberName Type '1[foo]' is not a struct type.")); } TEST_F(ValidateIdWithMessage, OpMemberNameMemberBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberName %1 1 "foo" %2 = OpTypeInt 32 0 %1 = OpTypeStruct %2)"; @@ -187,7 +184,7 @@ TEST_F(ValidateIdWithMessage, OpMemberNameMemberBad) { } TEST_F(ValidateIdWithMessage, OpLineGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpString "/path/to/source.file" OpLine %1 0 0 %2 = OpTypeInt 32 0 @@ -198,7 +195,7 @@ TEST_F(ValidateIdWithMessage, OpLineGood) { } TEST_F(ValidateIdWithMessage, OpLineFileBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 OpLine %1 0 0 )"; @@ -209,7 +206,7 @@ TEST_F(ValidateIdWithMessage, OpLineFileBad) { } TEST_F(ValidateIdWithMessage, OpDecorateGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpDecorate %2 GLSLShared %1 = OpTypeInt 64 0 %2 = OpTypeStruct %1 %1)"; @@ -217,7 +214,7 @@ TEST_F(ValidateIdWithMessage, OpDecorateGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpDecorateBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpDecorate %1 GLSLShared)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); @@ -226,7 +223,7 @@ OpDecorate %1 GLSLShared)"; } TEST_F(ValidateIdWithMessage, OpMemberDecorateGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberDecorate %2 0 Uniform %1 = OpTypeInt 32 0 %2 = OpTypeStruct %1 %1)"; @@ -234,7 +231,7 @@ TEST_F(ValidateIdWithMessage, OpMemberDecorateGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpMemberDecorateBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberDecorate %1 0 Uniform %1 = OpTypeInt 32 0)"; CompileSuccessfully(spirv.c_str()); @@ -245,7 +242,7 @@ TEST_F(ValidateIdWithMessage, OpMemberDecorateBad) { "OpMemberDecorate Structure type '1' is not a struct type.")); } TEST_F(ValidateIdWithMessage, OpMemberDecorateMemberBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberDecorate %1 3 Uniform %int = OpTypeInt 32 0 %1 = OpTypeStruct %int %int)"; @@ -258,7 +255,7 @@ TEST_F(ValidateIdWithMessage, OpMemberDecorateMemberBad) { } TEST_F(ValidateIdWithMessage, OpGroupDecorateGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpDecorationGroup OpDecorate %1 Uniform OpDecorate %1 GLSLShared @@ -270,7 +267,7 @@ TEST_F(ValidateIdWithMessage, OpGroupDecorateGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpDecorationGroupBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpDecorationGroup OpDecorate %1 Uniform OpDecorate %1 GLSLShared @@ -284,7 +281,7 @@ TEST_F(ValidateIdWithMessage, OpDecorationGroupBad) { "OpDecorate, and OpGroupMemberDecorate")); } TEST_F(ValidateIdWithMessage, OpGroupDecorateDecorationGroupBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage %1 = OpExtInstImport "GLSL.std.450" @@ -299,7 +296,7 @@ TEST_F(ValidateIdWithMessage, OpGroupDecorateDecorationGroupBad) { "decoration group.")); } TEST_F(ValidateIdWithMessage, OpGroupDecorateTargetBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpDecorationGroup OpDecorate %1 Uniform OpDecorate %1 GLSLShared @@ -311,7 +308,7 @@ TEST_F(ValidateIdWithMessage, OpGroupDecorateTargetBad) { HasSubstr("forward referenced IDs have not been defined")); } TEST_F(ValidateIdWithMessage, OpGroupMemberDecorateDecorationGroupBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage %1 = OpExtInstImport "GLSL.std.450" @@ -325,7 +322,7 @@ TEST_F(ValidateIdWithMessage, OpGroupMemberDecorateDecorationGroupBad) { "not a decoration group.")); } TEST_F(ValidateIdWithMessage, OpGroupMemberDecorateIdNotStructBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpDecorationGroup OpGroupMemberDecorate %1 %2 0 %2 = OpTypeInt 32 0)"; @@ -336,7 +333,7 @@ TEST_F(ValidateIdWithMessage, OpGroupMemberDecorateIdNotStructBad) { "a struct type.")); } TEST_F(ValidateIdWithMessage, OpGroupMemberDecorateIndexOutOfBoundBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpDecorate %1 Offset 0 %1 = OpDecorationGroup OpGroupMemberDecorate %1 %struct 3 @@ -354,7 +351,7 @@ TEST_F(ValidateIdWithMessage, OpGroupMemberDecorateIndexOutOfBoundBad) { // TODO: OpExtInst TEST_F(ValidateIdWithMessage, OpEntryPointGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpEntryPoint GLCompute %3 "" %1 = OpTypeVoid %2 = OpTypeFunction %1 @@ -367,7 +364,7 @@ TEST_F(ValidateIdWithMessage, OpEntryPointGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpEntryPointFunctionBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpEntryPoint GLCompute %1 "" %1 = OpTypeVoid)"; CompileSuccessfully(spirv.c_str()); @@ -377,7 +374,7 @@ TEST_F(ValidateIdWithMessage, OpEntryPointFunctionBad) { HasSubstr("OpEntryPoint Entry Point '1' is not a function.")); } TEST_F(ValidateIdWithMessage, OpEntryPointParameterCountBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpEntryPoint GLCompute %3 "" %1 = OpTypeVoid %2 = OpTypeFunction %1 %1 @@ -392,7 +389,7 @@ TEST_F(ValidateIdWithMessage, OpEntryPointParameterCountBad) { "count is not zero")); } TEST_F(ValidateIdWithMessage, OpEntryPointReturnTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpEntryPoint GLCompute %3 "" %1 = OpTypeInt 32 0 %ret = OpConstant %1 0 @@ -409,7 +406,7 @@ TEST_F(ValidateIdWithMessage, OpEntryPointReturnTypeBad) { } TEST_F(ValidateIdWithMessage, OpEntryPointInterfaceIsNotVariableTypeBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Geometry OpMemoryModel Logical GLSL450 @@ -433,7 +430,7 @@ TEST_F(ValidateIdWithMessage, OpEntryPointInterfaceIsNotVariableTypeBad) { } TEST_F(ValidateIdWithMessage, OpEntryPointInterfaceStorageClassBad) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Geometry OpMemoryModel Logical GLSL450 @@ -459,7 +456,7 @@ TEST_F(ValidateIdWithMessage, OpEntryPointInterfaceStorageClassBad) { } TEST_F(ValidateIdWithMessage, OpExecutionModeGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpEntryPoint GLCompute %3 "" OpExecutionMode %3 LocalSize 1 1 1 %1 = OpTypeVoid @@ -473,7 +470,7 @@ TEST_F(ValidateIdWithMessage, OpExecutionModeGood) { } TEST_F(ValidateIdWithMessage, OpExecutionModeEntryPointMissing) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpExecutionMode %3 LocalSize 1 1 1 %1 = OpTypeVoid %2 = OpTypeFunction %1 @@ -489,7 +486,7 @@ TEST_F(ValidateIdWithMessage, OpExecutionModeEntryPointMissing) { } TEST_F(ValidateIdWithMessage, OpExecutionModeEntryPointBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpEntryPoint GLCompute %3 "" %a OpExecutionMode %a LocalSize 1 1 1 %void = OpTypeVoid @@ -508,7 +505,7 @@ TEST_F(ValidateIdWithMessage, OpExecutionModeEntryPointBad) { } TEST_F(ValidateIdWithMessage, OpTypeVectorFloat) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4)"; CompileSuccessfully(spirv.c_str()); @@ -516,7 +513,7 @@ TEST_F(ValidateIdWithMessage, OpTypeVectorFloat) { } TEST_F(ValidateIdWithMessage, OpTypeVectorInt) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeVector %1 4)"; CompileSuccessfully(spirv.c_str()); @@ -524,7 +521,7 @@ TEST_F(ValidateIdWithMessage, OpTypeVectorInt) { } TEST_F(ValidateIdWithMessage, OpTypeVectorUInt) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 64 0 %2 = OpTypeVector %1 4)"; CompileSuccessfully(spirv.c_str()); @@ -532,7 +529,7 @@ TEST_F(ValidateIdWithMessage, OpTypeVectorUInt) { } TEST_F(ValidateIdWithMessage, OpTypeVectorBool) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeBool %2 = OpTypeVector %1 4)"; CompileSuccessfully(spirv.c_str()); @@ -540,7 +537,7 @@ TEST_F(ValidateIdWithMessage, OpTypeVectorBool) { } TEST_F(ValidateIdWithMessage, OpTypeVectorComponentTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypePointer UniformConstant %1 %3 = OpTypeVector %2 4)"; @@ -552,7 +549,7 @@ TEST_F(ValidateIdWithMessage, OpTypeVectorComponentTypeBad) { } TEST_F(ValidateIdWithMessage, OpTypeMatrixGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 2 %3 = OpTypeMatrix %2 3)"; @@ -560,7 +557,7 @@ TEST_F(ValidateIdWithMessage, OpTypeMatrixGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpTypeMatrixColumnTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeMatrix %1 3)"; CompileSuccessfully(spirv.c_str()); @@ -571,14 +568,14 @@ TEST_F(ValidateIdWithMessage, OpTypeMatrixColumnTypeBad) { TEST_F(ValidateIdWithMessage, OpTypeSamplerGood) { // In Rev31, OpTypeSampler takes no arguments. - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %s = OpTypeSampler)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpTypeArrayGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 1 %3 = OpTypeArray %1 %2)"; @@ -587,7 +584,7 @@ TEST_F(ValidateIdWithMessage, OpTypeArrayGood) { } TEST_F(ValidateIdWithMessage, OpTypeArrayElementTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 1 %3 = OpTypeArray %2 %2)"; @@ -601,8 +598,9 @@ TEST_F(ValidateIdWithMessage, OpTypeArrayElementTypeBad) { enum Signed { kSigned, kUnsigned }; // Creates an assembly snippet declaring OpTypeArray with the given length. -string MakeArrayLength(const string& len, Signed isSigned, int width) { - ostringstream ss; +std::string MakeArrayLength(const std::string& len, Signed isSigned, + int width) { + std::ostringstream ss; ss << R"( OpCapability Shader OpCapability Linkage @@ -658,7 +656,7 @@ TEST_P(OpTypeArrayLengthTest, LengthPositive) { Val(CompileSuccessfully(MakeArrayLength("55", kSigned, width)))); EXPECT_EQ(SPV_SUCCESS, Val(CompileSuccessfully(MakeArrayLength("55", kUnsigned, width)))); - const string fpad(width / 4 - 1, 'F'); + const std::string fpad(width / 4 - 1, 'F'); EXPECT_EQ( SPV_SUCCESS, Val(CompileSuccessfully(MakeArrayLength("0x7" + fpad, kSigned, width)))); @@ -692,7 +690,7 @@ TEST_P(OpTypeArrayLengthTest, LengthNegative) { SPV_ERROR_INVALID_ID, Val(CompileSuccessfully(MakeArrayLength("-123", kSigned, width)), "OpTypeArray Length '2' default value must be at least 1.")); - const string neg_max = "0x8" + string(width / 4 - 1, '0'); + const std::string neg_max = "0x8" + std::string(width / 4 - 1, '0'); EXPECT_EQ( SPV_ERROR_INVALID_ID, Val(CompileSuccessfully(MakeArrayLength(neg_max, kSigned, width)), @@ -705,10 +703,10 @@ TEST_P(OpTypeArrayLengthTest, LengthNegative) { // here since the purpose of these tests is to check the validity of // OpTypeArray, not OpTypeInt. INSTANTIATE_TEST_CASE_P(Widths, OpTypeArrayLengthTest, - ValuesIn(vector{16, 32, 64})); + ValuesIn(std::vector{16, 32, 64})); TEST_F(ValidateIdWithMessage, OpTypeArrayLengthNull) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %i32 = OpTypeInt 32 0 %len = OpConstantNull %i32 %ary = OpTypeArray %i32 %len)"; @@ -721,7 +719,7 @@ TEST_F(ValidateIdWithMessage, OpTypeArrayLengthNull) { } TEST_F(ValidateIdWithMessage, OpTypeArrayLengthSpecConst) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %i32 = OpTypeInt 32 0 %len = OpSpecConstant %i32 2 %ary = OpTypeArray %i32 %len)"; @@ -730,7 +728,7 @@ TEST_F(ValidateIdWithMessage, OpTypeArrayLengthSpecConst) { } TEST_F(ValidateIdWithMessage, OpTypeArrayLengthSpecConstOp) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %i32 = OpTypeInt 32 0 %c1 = OpConstant %i32 1 %c2 = OpConstant %i32 2 @@ -741,14 +739,14 @@ TEST_F(ValidateIdWithMessage, OpTypeArrayLengthSpecConstOp) { } TEST_F(ValidateIdWithMessage, OpTypeRuntimeArrayGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeRuntimeArray %1)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpTypeRuntimeArrayBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 0 %3 = OpTypeRuntimeArray %2)"; @@ -762,7 +760,7 @@ TEST_F(ValidateIdWithMessage, OpTypeRuntimeArrayBad) { // Unifrom Storage Class TEST_F(ValidateIdWithMessage, OpTypeStructGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeFloat 64 %3 = OpTypePointer Input %1 @@ -771,7 +769,7 @@ TEST_F(ValidateIdWithMessage, OpTypeStructGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpTypeStructMemberTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeFloat 64 %3 = OpConstant %2 0.0 @@ -783,14 +781,14 @@ TEST_F(ValidateIdWithMessage, OpTypeStructMemberTypeBad) { } TEST_F(ValidateIdWithMessage, OpTypePointerGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypePointer Input %1)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpTypePointerBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 0 %3 = OpTypePointer Input %2)"; @@ -801,14 +799,14 @@ TEST_F(ValidateIdWithMessage, OpTypePointerBad) { } TEST_F(ValidateIdWithMessage, OpTypeFunctionGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeFunction %1)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpTypeFunctionReturnTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 0 %3 = OpTypeFunction %2)"; @@ -818,7 +816,7 @@ TEST_F(ValidateIdWithMessage, OpTypeFunctionReturnTypeBad) { HasSubstr("OpTypeFunction Return Type '2' is not a type.")); } TEST_F(ValidateIdWithMessage, OpTypeFunctionParameterBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpConstant %2 0 @@ -831,7 +829,7 @@ TEST_F(ValidateIdWithMessage, OpTypeFunctionParameterBad) { } TEST_F(ValidateIdWithMessage, OpTypePipeGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 16 %3 = OpTypePipe ReadOnly)"; @@ -840,14 +838,14 @@ TEST_F(ValidateIdWithMessage, OpTypePipeGood) { } TEST_F(ValidateIdWithMessage, OpConstantTrueGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeBool %2 = OpConstantTrue %1)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantTrueBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpConstantTrue %1)"; CompileSuccessfully(spirv.c_str()); @@ -858,14 +856,14 @@ TEST_F(ValidateIdWithMessage, OpConstantTrueBad) { } TEST_F(ValidateIdWithMessage, OpConstantFalseGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeBool %2 = OpConstantTrue %1)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantFalseBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpConstantFalse %1)"; CompileSuccessfully(spirv.c_str()); @@ -876,14 +874,14 @@ TEST_F(ValidateIdWithMessage, OpConstantFalseBad) { } TEST_F(ValidateIdWithMessage, OpConstantGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 1)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpConstant !1 !0)"; // The expected failure code is implementation dependent (currently @@ -894,7 +892,7 @@ TEST_F(ValidateIdWithMessage, OpConstantBad) { } TEST_F(ValidateIdWithMessage, OpConstantCompositeVectorGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpConstant %1 3.14 @@ -903,7 +901,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeVectorGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantCompositeVectorWithUndefGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpConstant %1 3.14 @@ -913,7 +911,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeVectorWithUndefGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantCompositeVectorResultTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpConstant %1 3.14 @@ -926,7 +924,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeVectorResultTypeBad) { "OpConstantComposite Result Type '1' is not a composite type.")); } TEST_F(ValidateIdWithMessage, OpConstantCompositeVectorConstituentTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %4 = OpTypeInt 32 0 @@ -942,7 +940,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeVectorConstituentTypeBad) { } TEST_F(ValidateIdWithMessage, OpConstantCompositeVectorConstituentUndefTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %4 = OpTypeInt 32 0 @@ -957,7 +955,7 @@ TEST_F(ValidateIdWithMessage, "Result Type '2's vector element type.")); } TEST_F(ValidateIdWithMessage, OpConstantCompositeMatrixGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpTypeMatrix %2 4 @@ -972,7 +970,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeMatrixGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantCompositeMatrixUndefGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpTypeMatrix %2 4 @@ -987,7 +985,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeMatrixUndefGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantCompositeMatrixConstituentTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %11 = OpTypeVector %1 3 @@ -1008,7 +1006,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeMatrixConstituentTypeBad) { } TEST_F(ValidateIdWithMessage, OpConstantCompositeMatrixConstituentUndefTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %11 = OpTypeVector %1 3 @@ -1028,7 +1026,7 @@ TEST_F(ValidateIdWithMessage, "vector component count.")); } TEST_F(ValidateIdWithMessage, OpConstantCompositeMatrixColumnTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeFloat 32 %3 = OpTypeVector %1 2 @@ -1045,7 +1043,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeMatrixColumnTypeBad) { HasSubstr("Columns in a matrix must be of type vector.")); } TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 4 %3 = OpTypeArray %1 %2 @@ -1054,7 +1052,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayWithUndefGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 4 %9 = OpUndef %1 @@ -1064,7 +1062,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayWithUndefGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayConstConstituentBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 4 %3 = OpTypeArray %1 %2 @@ -1076,7 +1074,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayConstConstituentBad) { "constant or undef.")); } TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayConstituentTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 4 %3 = OpTypeArray %1 %2 @@ -1090,7 +1088,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayConstituentTypeBad) { "not match Result Type '3's array element type.")); } TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayConstituentUndefTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 4 %3 = OpTypeArray %1 %2 @@ -1104,7 +1102,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeArrayConstituentUndefTypeBad) { "not match Result Type '3's array element type.")); } TEST_F(ValidateIdWithMessage, OpConstantCompositeStructGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeInt 64 0 %3 = OpTypeStruct %1 %1 %2 @@ -1115,7 +1113,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeStructGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantCompositeStructUndefGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeInt 64 0 %3 = OpTypeStruct %1 %1 %2 @@ -1126,7 +1124,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeStructUndefGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantCompositeStructMemberTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeInt 64 0 %3 = OpTypeStruct %1 %1 %2 @@ -1141,7 +1139,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeStructMemberTypeBad) { } TEST_F(ValidateIdWithMessage, OpConstantCompositeStructMemberUndefTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeInt 64 0 %3 = OpTypeStruct %1 %1 %2 @@ -1156,7 +1154,7 @@ TEST_F(ValidateIdWithMessage, OpConstantCompositeStructMemberUndefTypeBad) { } TEST_F(ValidateIdWithMessage, OpConstantSamplerGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %float = OpTypeFloat 32 %samplerType = OpTypeSampler %3 = OpConstantSampler %samplerType ClampToEdge 0 Nearest)"; @@ -1164,7 +1162,7 @@ TEST_F(ValidateIdWithMessage, OpConstantSamplerGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpConstantSamplerResultTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpConstantSampler %1 Clamp 0 Nearest)"; CompileSuccessfully(spirv.c_str()); @@ -1176,7 +1174,7 @@ TEST_F(ValidateIdWithMessage, OpConstantSamplerResultTypeBad) { } TEST_F(ValidateIdWithMessage, OpConstantNullGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeBool %2 = OpConstantNull %1 %3 = OpTypeInt 32 0 @@ -1212,7 +1210,7 @@ TEST_F(ValidateIdWithMessage, OpConstantNullGood) { } TEST_F(ValidateIdWithMessage, OpConstantNullBasicBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpConstantNull %1)"; CompileSuccessfully(spirv.c_str()); @@ -1224,7 +1222,7 @@ TEST_F(ValidateIdWithMessage, OpConstantNullBasicBad) { } TEST_F(ValidateIdWithMessage, OpConstantNullArrayBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %2 = OpTypeInt 32 0 %3 = OpTypeSampler %4 = OpConstant %2 4 @@ -1239,7 +1237,7 @@ TEST_F(ValidateIdWithMessage, OpConstantNullArrayBad) { } TEST_F(ValidateIdWithMessage, OpConstantNullStructBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %2 = OpTypeSampler %3 = OpTypeStruct %2 %2 %4 = OpConstantNull %3)"; @@ -1252,7 +1250,7 @@ TEST_F(ValidateIdWithMessage, OpConstantNullStructBad) { } TEST_F(ValidateIdWithMessage, OpConstantNullRuntimeArrayBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %bool = OpTypeBool %array = OpTypeRuntimeArray %bool %null = OpConstantNull %array)"; @@ -1265,14 +1263,14 @@ TEST_F(ValidateIdWithMessage, OpConstantNullRuntimeArrayBad) { } TEST_F(ValidateIdWithMessage, OpSpecConstantTrueGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeBool %2 = OpSpecConstantTrue %1)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpSpecConstantTrueBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpSpecConstantTrue %1)"; CompileSuccessfully(spirv.c_str()); @@ -1282,14 +1280,14 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantTrueBad) { } TEST_F(ValidateIdWithMessage, OpSpecConstantFalseGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeBool %2 = OpSpecConstantFalse %1)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpSpecConstantFalseBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpSpecConstantFalse %1)"; CompileSuccessfully(spirv.c_str()); @@ -1299,14 +1297,14 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantFalseBad) { } TEST_F(ValidateIdWithMessage, OpSpecConstantGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpSpecConstant %1 42)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpSpecConstantBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpSpecConstant !1 !4)"; // The expected failure code is implementation dependent (currently @@ -1320,7 +1318,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantBad) { // Valid: SpecConstantComposite specializes to a vector. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpSpecConstant %1 3.14 @@ -1332,7 +1330,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorGood) { // Valid: Vector of floats and Undefs. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorWithUndefGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpSpecConstant %1 3.14 @@ -1345,7 +1343,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorWithUndefGood) { // Invalid: result type is float. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorResultTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpSpecConstant %1 3.14 @@ -1357,7 +1355,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorResultTypeBad) { // Invalid: Vector contains a mix of Int and Float. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorConstituentTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %4 = OpTypeInt 32 0 @@ -1375,7 +1373,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorConstituentTypeBad) { // Invalid: Constituent is not a constant TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorConstituentNotConstantBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpTypeInt 32 0 @@ -1391,7 +1389,7 @@ TEST_F(ValidateIdWithMessage, // Invalid: Vector contains a mix of Undef-int and Float. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorConstituentUndefTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %4 = OpTypeInt 32 0 @@ -1408,7 +1406,7 @@ TEST_F(ValidateIdWithMessage, // Invalid: Vector expects 3 components, but 4 specified. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorNumComponentsBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 3 %3 = OpConstant %1 3.14 @@ -1424,7 +1422,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeVectorNumComponentsBad) { // Valid: 4x4 matrix of floats TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpTypeMatrix %2 4 @@ -1441,7 +1439,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixGood) { // Valid: Matrix in which one column is Undef TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixUndefGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpTypeMatrix %2 4 @@ -1458,7 +1456,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixUndefGood) { // Invalid: Matrix in which the sizes of column vectors are not equal. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixConstituentTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpTypeVector %1 3 @@ -1480,7 +1478,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixConstituentTypeBad) { // Invalid: Matrix type expects 4 columns but only 3 specified. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixNumColsBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpTypeMatrix %2 4 @@ -1501,7 +1499,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixNumColsBad) { // Invalid: Composite contains a non-const/undef component TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixConstituentNotConstBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpConstant %1 0.0 %3 = OpTypeVector %1 4 @@ -1517,7 +1515,7 @@ TEST_F(ValidateIdWithMessage, // Invalid: Composite contains a column that is *not* a vector (it's an array) TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixColTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeInt 32 0 %3 = OpSpecConstant %2 4 @@ -1539,7 +1537,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixColTypeBad) { // Invalid: Matrix with an Undef column of the wrong size. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixConstituentUndefTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeFloat 32 %2 = OpTypeVector %1 4 %3 = OpTypeVector %1 3 @@ -1561,7 +1559,7 @@ TEST_F(ValidateIdWithMessage, // Invalid: Matrix in which some columns are Int and some are Float. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixColumnTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeFloat 32 %3 = OpTypeVector %1 2 @@ -1582,7 +1580,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeMatrixColumnTypeBad) { // Valid: Array of integers TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpSpecConstant %1 4 %5 = OpConstant %1 5 @@ -1596,7 +1594,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayGood) { // Invalid: Expecting an array of 4 components, but 3 specified. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayNumComponentsBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpSpecConstant %1 4 %3 = OpTypeArray %1 %2 @@ -1610,7 +1608,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayNumComponentsBad) { // Valid: Array of Integers and Undef-int TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayWithUndefGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpSpecConstant %1 4 %9 = OpUndef %1 @@ -1622,7 +1620,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayWithUndefGood) { // Invalid: Array uses a type as operand. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayConstConstituentBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 4 %3 = OpTypeArray %1 %2 @@ -1636,7 +1634,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayConstConstituentBad) { // Invalid: Array has a mix of Int and Float components. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayConstituentTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpConstant %1 4 %3 = OpTypeArray %1 %2 @@ -1654,7 +1652,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayConstituentTypeBad) { // Invalid: Array has a mix of Int and Undef-float. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeArrayConstituentUndefTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpSpecConstant %1 4 %3 = OpTypeArray %1 %2 @@ -1671,7 +1669,7 @@ TEST_F(ValidateIdWithMessage, // Valid: Struct of {Int32,Int32,Int64}. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeInt 64 0 %3 = OpTypeStruct %1 %1 %2 @@ -1685,7 +1683,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructGood) { // Invalid: missing one int32 struct member. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructMissingComponentBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %3 = OpTypeStruct %1 %1 %1 %4 = OpConstant %1 42 @@ -1701,7 +1699,7 @@ TEST_F(ValidateIdWithMessage, // Valid: Struct uses Undef-int64. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructUndefGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeInt 64 0 %3 = OpTypeStruct %1 %1 %2 @@ -1714,7 +1712,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructUndefGood) { // Invalid: Composite contains non-const/undef component. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructNonConstBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeInt 64 0 %3 = OpTypeStruct %1 %1 %2 @@ -1731,7 +1729,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructNonConstBad) { // Invalid: Struct component type does not match expected specialization type. // Second component was expected to be Int32, but got Int64. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructMemberTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeInt 64 0 %3 = OpTypeStruct %1 %1 %2 @@ -1748,7 +1746,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructMemberTypeBad) { // Invalid: Undef-int64 used when Int32 was expected. TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructMemberUndefTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeInt 64 0 %3 = OpTypeStruct %1 %1 %2 @@ -1766,7 +1764,7 @@ TEST_F(ValidateIdWithMessage, OpSpecConstantCompositeStructMemberUndefTypeBad) { // TODO: OpSpecConstantOp TEST_F(ValidateIdWithMessage, OpVariableGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypePointer Input %1 %3 = OpVariable %2 Input)"; @@ -1774,7 +1772,7 @@ TEST_F(ValidateIdWithMessage, OpVariableGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpVariableInitializerConstantGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypePointer Input %1 %3 = OpConstant %1 42 @@ -1783,7 +1781,7 @@ TEST_F(ValidateIdWithMessage, OpVariableInitializerConstantGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpVariableInitializerGlobalVariableGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypePointer Uniform %1 %3 = OpVariable %2 Uniform @@ -1794,7 +1792,7 @@ TEST_F(ValidateIdWithMessage, OpVariableInitializerGlobalVariableGood) { } // TODO: Positive test OpVariable with OpConstantNull of OpTypePointer TEST_F(ValidateIdWithMessage, OpVariableResultTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpVariable %1 Input)"; CompileSuccessfully(spirv.c_str()); @@ -1804,7 +1802,7 @@ TEST_F(ValidateIdWithMessage, OpVariableResultTypeBad) { HasSubstr("OpVariable Result Type '1' is not a pointer type.")); } TEST_F(ValidateIdWithMessage, OpVariableInitializerIsTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypePointer Input %1 %3 = OpVariable %2 Input %2)"; @@ -1816,7 +1814,7 @@ TEST_F(ValidateIdWithMessage, OpVariableInitializerIsTypeBad) { } TEST_F(ValidateIdWithMessage, OpVariableInitializerIsFunctionVarBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %int = OpTypeInt 32 0 %ptrint = OpTypePointer Function %int %ptrptrint = OpTypePointer Function %ptrint @@ -1837,7 +1835,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpVariableInitializerIsModuleVarGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %int = OpTypeInt 32 0 %ptrint = OpTypePointer Uniform %int %mvar = OpVariable %ptrint Uniform @@ -1855,7 +1853,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpLoadGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2029,7 +2027,7 @@ TEST_F(ValidateIdWithMessage, OpLoadVarPtrOpFunctionCallGood) { } TEST_F(ValidateIdWithMessage, OpLoadResultTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2049,7 +2047,7 @@ TEST_F(ValidateIdWithMessage, OpLoadResultTypeBad) { } TEST_F(ValidateIdWithMessage, OpLoadPointerBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2069,7 +2067,7 @@ TEST_F(ValidateIdWithMessage, OpLoadPointerBad) { // Disabled as bitcasting type to object is now not valid. TEST_F(ValidateIdWithMessage, DISABLED_OpLoadLogicalPointerBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFloat 32 @@ -2094,7 +2092,7 @@ TEST_F(ValidateIdWithMessage, DISABLED_OpLoadLogicalPointerBad) { } TEST_F(ValidateIdWithMessage, OpStoreGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer Uniform %2 @@ -2110,7 +2108,7 @@ TEST_F(ValidateIdWithMessage, OpStoreGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpStorePointerBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2130,7 +2128,7 @@ TEST_F(ValidateIdWithMessage, OpStorePointerBad) { // Disabled as bitcasting type to object is now not valid. TEST_F(ValidateIdWithMessage, DISABLED_OpStoreLogicalPointerBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFloat 32 @@ -2189,7 +2187,7 @@ TEST_F(ValidateIdWithMessage, OpStoreVarPtrGood) { } TEST_F(ValidateIdWithMessage, OpStoreObjectGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer Uniform %2 @@ -2207,7 +2205,7 @@ TEST_F(ValidateIdWithMessage, OpStoreObjectGood) { HasSubstr("OpStore Object '7's type is void.")); } TEST_F(ValidateIdWithMessage, OpStoreTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %9 = OpTypeFloat 32 @@ -2234,7 +2232,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeBad) { // relaxes the rules for them as well. Also need test to check for layout // decorations specific to those types. TEST_F(ValidateIdWithMessage, OpStoreTypeBadStruct) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberDecorate %1 0 Offset 0 OpMemberDecorate %1 1 Offset 4 OpMemberDecorate %2 0 Offset 0 @@ -2263,7 +2261,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeBadStruct) { // Same code as the last test. The difference is that we relax the rule. // Because the structs %3 and %5 are defined the same way. TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedStruct) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberDecorate %1 0 Offset 0 OpMemberDecorate %1 1 Offset 4 OpMemberDecorate %2 0 Offset 0 @@ -2290,7 +2288,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedStruct) { // Same code as the last test excect for an extra decoration on one of the // members. With the relaxed rules, the code is still valid. TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedStructWithExtraDecoration) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberDecorate %1 0 Offset 0 OpMemberDecorate %1 1 Offset 4 OpMemberDecorate %1 0 RelaxedPrecision @@ -2318,7 +2316,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedStructWithExtraDecoration) { // This test check that we recursively traverse the struct to check if they are // interchangable. TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedNestedStruct) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberDecorate %1 0 Offset 0 OpMemberDecorate %1 1 Offset 4 OpMemberDecorate %2 0 Offset 0 @@ -2354,7 +2352,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedNestedStruct) { // This test check that the even with the relaxed rules an error is identified // if the members of the struct are in a different order. TEST_F(ValidateIdWithMessage, OpStoreTypeBadRelaxedStruct1) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberDecorate %1 0 Offset 0 OpMemberDecorate %1 1 Offset 4 OpMemberDecorate %2 0 Offset 0 @@ -2394,7 +2392,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeBadRelaxedStruct1) { // This test check that the even with the relaxed rules an error is identified // if the members of the struct are at different offsets. TEST_F(ValidateIdWithMessage, OpStoreTypeBadRelaxedStruct2) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpMemberDecorate %1 0 Offset 4 OpMemberDecorate %1 1 Offset 0 OpMemberDecorate %2 0 Offset 0 @@ -2432,7 +2430,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeBadRelaxedStruct2) { } TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedLogicalPointerReturnPointer) { - const string spirv = R"( + const std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -2451,7 +2449,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedLogicalPointerReturnPointer) { } TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedLogicalPointerAllocPointer) { - const string spirv = R"( + const std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -2474,7 +2472,7 @@ TEST_F(ValidateIdWithMessage, OpStoreTypeRelaxedLogicalPointerAllocPointer) { } TEST_F(ValidateIdWithMessage, OpStoreVoid) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer Uniform %2 @@ -2493,7 +2491,7 @@ TEST_F(ValidateIdWithMessage, OpStoreVoid) { } TEST_F(ValidateIdWithMessage, OpStoreLabel) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer Uniform %2 @@ -2513,7 +2511,7 @@ TEST_F(ValidateIdWithMessage, OpStoreLabel) { // TODO: enable when this bug is fixed: // https://cvs.khronos.org/bugzilla/show_bug.cgi?id=15404 TEST_F(ValidateIdWithMessage, DISABLED_OpStoreFunction) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 %4 = OpTypeFunction %2 @@ -2529,7 +2527,7 @@ TEST_F(ValidateIdWithMessage, DISABLED_OpStoreFunction) { } TEST_F(ValidateIdWithMessage, OpStoreBuiltin) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -2567,7 +2565,7 @@ TEST_F(ValidateIdWithMessage, OpStoreBuiltin) { } TEST_F(ValidateIdWithMessage, OpCopyMemoryGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2586,7 +2584,7 @@ TEST_F(ValidateIdWithMessage, OpCopyMemoryGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpCopyMemoryBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2611,7 +2609,7 @@ TEST_F(ValidateIdWithMessage, OpCopyMemoryBad) { // TODO: OpCopyMemorySized TEST_F(ValidateIdWithMessage, OpCopyMemorySizedGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2629,7 +2627,7 @@ TEST_F(ValidateIdWithMessage, OpCopyMemorySizedGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpCopyMemorySizedTargetBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2648,7 +2646,7 @@ TEST_F(ValidateIdWithMessage, OpCopyMemorySizedTargetBad) { HasSubstr("OpCopyMemorySized Target '9' is not a pointer.")); } TEST_F(ValidateIdWithMessage, OpCopyMemorySizedSourceBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2667,7 +2665,7 @@ TEST_F(ValidateIdWithMessage, OpCopyMemorySizedSourceBad) { HasSubstr("OpCopyMemorySized Source '6' is not a pointer.")); } TEST_F(ValidateIdWithMessage, OpCopyMemorySizedSizeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2688,7 +2686,7 @@ TEST_F(ValidateIdWithMessage, OpCopyMemorySizedSizeBad) { "an integer type.")); } TEST_F(ValidateIdWithMessage, OpCopyMemorySizedSizeTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypePointer UniformConstant %2 @@ -2780,10 +2778,10 @@ bool AccessChainRequiresElemId(const std::string& instr) { TEST_P(AccessChainInstructionTest, AccessChainGood) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + - "%float_entry = " + instr + - R"( %_ptr_Private_float %my_matrix )" + elem + - R"(%int_0 %int_1 + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + + "%float_entry = " + instr + + R"( %_ptr_Private_float %my_matrix )" + elem + + R"(%int_0 %int_1 OpReturn OpFunctionEnd )"; @@ -2795,9 +2793,10 @@ TEST_P(AccessChainInstructionTest, AccessChainGood) { TEST_P(AccessChainInstructionTest, AccessChainResultTypeBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %float_entry = )" + - instr + R"( %float %my_matrix )" + elem + R"(%int_0 %int_1 + instr + R"( %float %my_matrix )" + elem + + R"(%int_0 %int_1 OpReturn OpFunctionEnd )"; @@ -2814,10 +2813,10 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainBaseTypeVoidBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %float_entry = )" + - instr + " %_ptr_Private_float %void " + elem + - R"(%int_0 %int_1 + instr + " %_ptr_Private_float %void " + elem + + R"(%int_0 %int_1 OpReturn OpFunctionEnd )"; @@ -2833,11 +2832,11 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainBaseTypeNonPtrVariableBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + - instr + - R"( %_ptr_Private_float %_ptr_Private_float )" + elem + - R"(%int_0 %int_1 + instr + + R"( %_ptr_Private_float %_ptr_Private_float )" + elem + + R"(%int_0 %int_1 OpReturn OpFunctionEnd )"; @@ -2854,11 +2853,11 @@ TEST_P(AccessChainInstructionTest, AccessChainResultAndBaseStorageClassDoesntMatchBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + - instr + - R"( %_ptr_Function_float %my_matrix )" + elem + - R"(%int_0 %int_1 + instr + + R"( %_ptr_Function_float %my_matrix )" + elem + + R"(%int_0 %int_1 OpReturn OpFunctionEnd )"; @@ -2876,10 +2875,10 @@ TEST_P(AccessChainInstructionTest, AccessChainBasePtrNotPointingToCompositeBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( -%entry = )" + - instr + - R"( %_ptr_Private_float %my_float_var )" + elem + R"(%int_0 + std::string spirv = + kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( +%entry = )" + instr + + R"( %_ptr_Private_float %my_float_var )" + elem + R"(%int_0 OpReturn OpFunctionEnd )"; @@ -2896,10 +2895,10 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainNoIndexesGood) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + - instr + - R"( %_ptr_Private_float %my_float_var )" + elem + R"( + instr + + R"( %_ptr_Private_float %my_float_var )" + elem + R"( OpReturn OpFunctionEnd )"; @@ -2912,10 +2911,10 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainNoIndexesBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + - instr + - R"( %_ptr_Private_mat4x3 %my_float_var )" + elem + R"( + instr + + R"( %_ptr_Private_mat4x3 %my_float_var )" + elem + R"( OpReturn OpFunctionEnd )"; @@ -3063,7 +3062,7 @@ TEST_P(AccessChainInstructionTest, CustomizedAccessChainTooManyIndexesBad) { TEST_P(AccessChainInstructionTest, AccessChainUndefinedIndexBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + instr + R"( %_ptr_Private_float %my_matrix )" + elem + R"(%float %int_1 @@ -3082,10 +3081,10 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainStructIndexNotConstantBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %f = )" + - instr + R"( %_ptr_Uniform_float %blockName_var )" + elem + - R"(%int_0 %spec_int %int_2 + instr + R"( %_ptr_Uniform_float %blockName_var )" + elem + + R"(%int_0 %spec_int %int_2 OpReturn OpFunctionEnd )"; @@ -3102,11 +3101,11 @@ TEST_P(AccessChainInstructionTest, AccessChainStructResultTypeDoesntMatchIndexedTypeBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + - instr + - R"( %_ptr_Uniform_float %blockName_var )" + elem + - R"(%int_0 %int_1 %int_2 + instr + + R"( %_ptr_Uniform_float %blockName_var )" + elem + + R"(%int_0 %int_1 %int_2 OpReturn OpFunctionEnd )"; @@ -3123,11 +3122,11 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainStructTooManyIndexesBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + - instr + - R"( %_ptr_Uniform_float %blockName_var )" + elem + - R"(%int_0 %int_2 %int_2 + instr + + R"( %_ptr_Uniform_float %blockName_var )" + elem + + R"(%int_0 %int_2 %int_2 OpReturn OpFunctionEnd )"; @@ -3143,11 +3142,11 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainStructIndexOutOfBoundBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + - instr + - R"( %_ptr_Uniform_float %blockName_var )" + elem + - R"(%int_3 %int_2 %int_2 + instr + + R"( %_ptr_Uniform_float %blockName_var )" + elem + + R"(%int_3 %int_2 %int_2 OpReturn OpFunctionEnd )"; @@ -3170,7 +3169,7 @@ TEST_P(AccessChainInstructionTest, AccessChainIndexIntoAllTypesGood) { // 0 will select the element at the index 0 of the vector. (which is a float). const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - ostringstream spirv; + std::ostringstream spirv; spirv << kGLSL450MemoryModel << kDeeplyNestedStructureSetup << std::endl; spirv << "%ss = " << instr << " %_ptr_Uniform_struct_s %blockName_var " << elem << "%int_0" << std::endl; @@ -3194,11 +3193,11 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainIndexIntoRuntimeArrayGood) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %runtime_arr_entry = )" + - instr + - R"( %_ptr_Uniform_float %blockName_var )" + elem + - R"(%int_2 %int_0 + instr + + R"( %_ptr_Uniform_float %blockName_var )" + elem + + R"(%int_2 %int_0 OpReturn OpFunctionEnd )"; @@ -3210,11 +3209,11 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainIndexIntoRuntimeArrayBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %runtime_arr_entry = )" + - instr + - R"( %_ptr_Uniform_float %blockName_var )" + elem + - R"(%int_2 %int_0 %int_1 + instr + + R"( %_ptr_Uniform_float %blockName_var )" + elem + + R"(%int_2 %int_0 %int_1 OpReturn OpFunctionEnd )"; @@ -3231,11 +3230,11 @@ OpFunctionEnd TEST_P(AccessChainInstructionTest, AccessChainMatrixMoreArgsThanNeededBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + - instr + - R"( %_ptr_Private_float %my_matrix )" + elem + - R"(%int_0 %int_1 %int_0 + instr + + R"( %_ptr_Private_float %my_matrix )" + elem + + R"(%int_0 %int_1 %int_0 OpReturn OpFunctionEnd )"; @@ -3252,11 +3251,11 @@ TEST_P(AccessChainInstructionTest, AccessChainResultTypeDoesntMatchIndexedTypeBad) { const std::string instr = GetParam(); const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : ""; - string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( + std::string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"( %entry = )" + - instr + - R"( %_ptr_Private_mat4x3 %my_matrix )" + elem + - R"(%int_0 %int_1 + instr + + R"( %_ptr_Private_mat4x3 %my_matrix )" + elem + + R"(%int_0 %int_1 OpReturn OpFunctionEnd )"; @@ -3280,7 +3279,7 @@ INSTANTIATE_TEST_CASE_P( // TODO: OpGenericPtrMemSemantics TEST_F(ValidateIdWithMessage, OpFunctionGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %1 %2 %2 @@ -3292,7 +3291,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpFunctionResultTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpConstant %2 42 @@ -3308,7 +3307,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionResultTypeBad) { "Function Type '2's return type.")); } TEST_F(ValidateIdWithMessage, OpReturnValueTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeInt 32 0 %2 = OpTypeFloat 32 %3 = OpConstant %2 0 @@ -3324,7 +3323,7 @@ TEST_F(ValidateIdWithMessage, OpReturnValueTypeBad) { "OpFunction's return type.")); } TEST_F(ValidateIdWithMessage, OpFunctionFunctionTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %4 = OpFunction %1 None %2 @@ -3339,7 +3338,7 @@ OpFunctionEnd)"; } TEST_F(ValidateIdWithMessage, OpFunctionParameterGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %1 %2 @@ -3352,7 +3351,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionParameterGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpFunctionParameterMultipleGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %1 %2 %2 @@ -3366,7 +3365,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionParameterMultipleGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpFunctionParameterResultTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %1 %2 @@ -3384,7 +3383,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionParameterResultTypeBad) { } TEST_F(ValidateIdWithMessage, OpFunctionCallGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %2 %2 @@ -3406,7 +3405,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpFunctionCallResultTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %2 %2 @@ -3432,7 +3431,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallResultTypeBad) { "match Function '2's return type.")); } TEST_F(ValidateIdWithMessage, OpFunctionCallFunctionBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %2 %2 @@ -3450,7 +3449,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallFunctionBad) { HasSubstr("OpFunctionCall Function '5' is not a function.")); } TEST_F(ValidateIdWithMessage, OpFunctionCallArgumentTypeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %2 %2 @@ -3482,7 +3481,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallArgumentTypeBad) { // Valid: OpSampledImage result is used in the same block by // OpImageSampleImplictLod TEST_F(ValidateIdWithMessage, OpSampledImageGood) { - string spirv = kGLSL450MemoryModel + sampledImageSetup + R"( + std::string spirv = kGLSL450MemoryModel + sampledImageSetup + R"( %smpld_img = OpSampledImage %sampled_image_type %image_inst %sampler_inst %si_lod = OpImageSampleImplicitLod %v4float %smpld_img %const_vec_1_1 OpReturn @@ -3494,7 +3493,7 @@ TEST_F(ValidateIdWithMessage, OpSampledImageGood) { // Invalid: OpSampledImage result is defined in one block and used in a // different block. TEST_F(ValidateIdWithMessage, OpSampledImageUsedInDifferentBlockBad) { - string spirv = kGLSL450MemoryModel + sampledImageSetup + R"( + std::string spirv = kGLSL450MemoryModel + sampledImageSetup + R"( %smpld_img = OpSampledImage %sampled_image_type %image_inst %sampler_inst OpBranch %label_2 %label_2 = OpLabel @@ -3520,7 +3519,7 @@ OpFunctionEnd)"; // // Disabled since OpSelect catches this now. TEST_F(ValidateIdWithMessage, DISABLED_OpSampledImageUsedInOpSelectBad) { - string spirv = kGLSL450MemoryModel + sampledImageSetup + R"( + std::string spirv = kGLSL450MemoryModel + sampledImageSetup + R"( %smpld_img = OpSampledImage %sampled_image_type %image_inst %sampler_inst %select_img = OpSelect %sampled_image_type %spec_true %smpld_img %smpld_img OpReturn @@ -3536,7 +3535,7 @@ OpFunctionEnd)"; // Valid: Get a float in a matrix using CompositeExtract. // Valid: Insert float into a matrix using CompositeInsert. TEST_F(ValidateIdWithMessage, CompositeExtractInsertGood) { - ostringstream spirv; + std::ostringstream spirv; spirv << kGLSL450MemoryModel << kDeeplyNestedStructureSetup << std::endl; spirv << "%matrix = OpLoad %mat4x3 %my_matrix" << std::endl; spirv << "%float_entry = OpCompositeExtract %float %matrix 0 1" << std::endl; @@ -3619,7 +3618,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallArgumentCountBar) { // TODO: OpVectorInsertDynamic TEST_F(ValidateIdWithMessage, OpVectorShuffleIntGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %int = OpTypeInt 32 0 %ivec3 = OpTypeVector %int 3 %ivec4 = OpTypeVector %int 4 @@ -3642,7 +3641,7 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleIntGood) { } TEST_F(ValidateIdWithMessage, OpVectorShuffleFloatGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %float = OpTypeFloat 32 %vec2 = OpTypeVector %float 2 %vec3 = OpTypeVector %float 3 @@ -3668,7 +3667,7 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleFloatGood) { } TEST_F(ValidateIdWithMessage, OpVectorShuffleScalarResultType) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %float = OpTypeFloat 32 %vec2 = OpTypeVector %float 2 %ptr_vec2 = OpTypePointer Function %vec2 @@ -3691,7 +3690,7 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleScalarResultType) { } TEST_F(ValidateIdWithMessage, OpVectorShuffleComponentCount) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %int = OpTypeInt 32 0 %ivec3 = OpTypeVector %int 3 %ptr_ivec3 = OpTypePointer Function %ivec3 @@ -3716,7 +3715,7 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleComponentCount) { } TEST_F(ValidateIdWithMessage, OpVectorShuffleVector1Type) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %int = OpTypeInt 32 0 %ivec2 = OpTypeVector %int 2 %ptr_int = OpTypePointer Function %int @@ -3737,7 +3736,7 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleVector1Type) { } TEST_F(ValidateIdWithMessage, OpVectorShuffleVector2Type) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %int = OpTypeInt 32 0 %ivec2 = OpTypeVector %int 2 %ptr_ivec2 = OpTypePointer Function %ivec2 @@ -3759,7 +3758,7 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleVector2Type) { } TEST_F(ValidateIdWithMessage, OpVectorShuffleVector1ComponentType) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %int = OpTypeInt 32 0 %ivec3 = OpTypeVector %int 3 %ptr_ivec3 = OpTypePointer Function %ivec3 @@ -3792,7 +3791,7 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleVector1ComponentType) { } TEST_F(ValidateIdWithMessage, OpVectorShuffleVector2ComponentType) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %int = OpTypeInt 32 0 %ivec3 = OpTypeVector %int 3 %ptr_ivec3 = OpTypePointer Function %ivec3 @@ -3825,7 +3824,7 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleVector2ComponentType) { } TEST_F(ValidateIdWithMessage, OpVectorShuffleLiterals) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %float = OpTypeFloat 32 %vec2 = OpTypeVector %float 2 %vec3 = OpTypeVector %float 3 @@ -3940,7 +3939,7 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleLiterals) { // TODO: OpBranch TEST_F(ValidateIdWithMessage, OpPhiNotAType) { - string spirv = kOpenCLMemoryModel32 + R"( + std::string spirv = kOpenCLMemoryModel32 + R"( %2 = OpTypeBool %3 = OpConstantTrue %2 %4 = OpTypeVoid @@ -3961,7 +3960,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpPhiSamePredecessor) { - string spirv = kOpenCLMemoryModel32 + R"( + std::string spirv = kOpenCLMemoryModel32 + R"( %2 = OpTypeBool %3 = OpConstantTrue %2 %4 = OpTypeVoid @@ -3980,7 +3979,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpPhiOddArgumentNumber) { - string spirv = kOpenCLMemoryModel32 + R"( + std::string spirv = kOpenCLMemoryModel32 + R"( %2 = OpTypeBool %3 = OpConstantTrue %2 %4 = OpTypeVoid @@ -4002,7 +4001,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpPhiTooFewPredecessors) { - string spirv = kOpenCLMemoryModel32 + R"( + std::string spirv = kOpenCLMemoryModel32 + R"( %2 = OpTypeBool %3 = OpConstantTrue %2 %4 = OpTypeVoid @@ -4024,7 +4023,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpPhiTooManyPredecessors) { - string spirv = kOpenCLMemoryModel32 + R"( + std::string spirv = kOpenCLMemoryModel32 + R"( %2 = OpTypeBool %3 = OpConstantTrue %2 %4 = OpTypeVoid @@ -4048,7 +4047,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpPhiMismatchedTypes) { - string spirv = kOpenCLMemoryModel32 + R"( + std::string spirv = kOpenCLMemoryModel32 + R"( %2 = OpTypeBool %3 = OpConstantTrue %2 %4 = OpTypeVoid @@ -4074,7 +4073,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpPhiPredecessorNotABlock) { - string spirv = kOpenCLMemoryModel32 + R"( + std::string spirv = kOpenCLMemoryModel32 + R"( %2 = OpTypeBool %3 = OpConstantTrue %2 %4 = OpTypeVoid @@ -4100,7 +4099,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpPhiNotAPredecessor) { - string spirv = kOpenCLMemoryModel32 + R"( + std::string spirv = kOpenCLMemoryModel32 + R"( %2 = OpTypeBool %3 = OpConstantTrue %2 %4 = OpTypeVoid @@ -4126,7 +4125,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, OpBranchConditionalGood) { - string spirv = BranchConditionalSetup + R"( + std::string spirv = BranchConditionalSetup + R"( %branch_cond = OpINotEqual %bool %i0 %i1 OpSelectionMerge %end None OpBranchConditional %branch_cond %target_t %target_f @@ -4137,7 +4136,7 @@ TEST_F(ValidateIdWithMessage, OpBranchConditionalGood) { } TEST_F(ValidateIdWithMessage, OpBranchConditionalWithWeightsGood) { - string spirv = BranchConditionalSetup + R"( + std::string spirv = BranchConditionalSetup + R"( %branch_cond = OpINotEqual %bool %i0 %i1 OpSelectionMerge %end None OpBranchConditional %branch_cond %target_t %target_f 1 1 @@ -4148,7 +4147,7 @@ TEST_F(ValidateIdWithMessage, OpBranchConditionalWithWeightsGood) { } TEST_F(ValidateIdWithMessage, OpBranchConditional_CondIsScalarInt) { - string spirv = BranchConditionalSetup + R"( + std::string spirv = BranchConditionalSetup + R"( OpSelectionMerge %end None OpBranchConditional %i0 %target_t %target_f )" + BranchConditionalTail; @@ -4162,7 +4161,7 @@ TEST_F(ValidateIdWithMessage, OpBranchConditional_CondIsScalarInt) { } TEST_F(ValidateIdWithMessage, OpBranchConditional_TrueTargetIsNotLabel) { - string spirv = BranchConditionalSetup + R"( + std::string spirv = BranchConditionalSetup + R"( OpSelectionMerge %end None OpBranchConditional %i0 %i0 %target_f )" + BranchConditionalTail; @@ -4181,7 +4180,7 @@ TEST_F(ValidateIdWithMessage, OpBranchConditional_TrueTargetIsNotLabel) { } TEST_F(ValidateIdWithMessage, OpBranchConditional_FalseTargetIsNotLabel) { - string spirv = BranchConditionalSetup + R"( + std::string spirv = BranchConditionalSetup + R"( OpSelectionMerge %end None OpBranchConditional %i0 %target_t %i0 )" + BranchConditionalTail; @@ -4200,7 +4199,7 @@ TEST_F(ValidateIdWithMessage, OpBranchConditional_FalseTargetIsNotLabel) { } TEST_F(ValidateIdWithMessage, OpBranchConditional_NotEnoughWeights) { - string spirv = BranchConditionalSetup + R"( + std::string spirv = BranchConditionalSetup + R"( %branch_cond = OpINotEqual %bool %i0 %i1 OpSelectionMerge %end None OpBranchConditional %branch_cond %target_t %target_f 1 @@ -4214,7 +4213,7 @@ TEST_F(ValidateIdWithMessage, OpBranchConditional_NotEnoughWeights) { } TEST_F(ValidateIdWithMessage, OpBranchConditional_TooManyWeights) { - string spirv = BranchConditionalSetup + R"( + std::string spirv = BranchConditionalSetup + R"( %branch_cond = OpINotEqual %bool %i0 %i1 OpSelectionMerge %end None OpBranchConditional %branch_cond %target_t %target_f 1 2 3 @@ -4230,7 +4229,7 @@ TEST_F(ValidateIdWithMessage, OpBranchConditional_TooManyWeights) { // TODO: OpSwitch TEST_F(ValidateIdWithMessage, OpReturnValueConstantGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %2 @@ -4244,7 +4243,7 @@ TEST_F(ValidateIdWithMessage, OpReturnValueConstantGood) { } TEST_F(ValidateIdWithMessage, OpReturnValueVariableGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 ;10 %3 = OpTypeFunction %2 @@ -4261,7 +4260,7 @@ TEST_F(ValidateIdWithMessage, OpReturnValueVariableGood) { } TEST_F(ValidateIdWithMessage, OpReturnValueExpressionGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %2 @@ -4276,7 +4275,7 @@ TEST_F(ValidateIdWithMessage, OpReturnValueExpressionGood) { } TEST_F(ValidateIdWithMessage, OpReturnValueIsType) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %2 @@ -4292,7 +4291,7 @@ TEST_F(ValidateIdWithMessage, OpReturnValueIsType) { } TEST_F(ValidateIdWithMessage, OpReturnValueIsLabel) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %2 @@ -4308,7 +4307,7 @@ TEST_F(ValidateIdWithMessage, OpReturnValueIsLabel) { } TEST_F(ValidateIdWithMessage, OpReturnValueIsVoid) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %1 @@ -4326,7 +4325,7 @@ TEST_F(ValidateIdWithMessage, OpReturnValueIsVoid) { TEST_F(ValidateIdWithMessage, OpReturnValueIsVariableInPhysical) { // It's valid to return a pointer in a physical addressing model. - string spirv = kOpCapabilitySetup + R"( + std::string spirv = kOpCapabilitySetup + R"( OpMemoryModel Physical32 OpenCL %1 = OpTypeVoid %2 = OpTypeInt 32 0 @@ -4343,7 +4342,7 @@ TEST_F(ValidateIdWithMessage, OpReturnValueIsVariableInPhysical) { TEST_F(ValidateIdWithMessage, OpReturnValueIsVariableInLogical) { // It's invalid to return a pointer in a physical addressing model. - string spirv = kOpCapabilitySetup + R"( + std::string spirv = kOpCapabilitySetup + R"( OpMemoryModel Logical GLSL450 %1 = OpTypeVoid %2 = OpTypeInt 32 0 @@ -4393,7 +4392,7 @@ TEST_F(ValidateIdWithMessage, DISABLED_OpReturnValueVarPtrBad) { // TODO: enable when this bug is fixed: // https://cvs.khronos.org/bugzilla/show_bug.cgi?id=15404 TEST_F(ValidateIdWithMessage, DISABLED_OpReturnValueIsFunction) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeInt 32 0 %3 = OpTypeFunction %2 @@ -4406,7 +4405,7 @@ TEST_F(ValidateIdWithMessage, DISABLED_OpReturnValueIsFunction) { } TEST_F(ValidateIdWithMessage, UndefinedTypeId) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %s = OpTypeStruct %i32 )"; CompileSuccessfully(spirv.c_str()); @@ -4417,7 +4416,7 @@ TEST_F(ValidateIdWithMessage, UndefinedTypeId) { } TEST_F(ValidateIdWithMessage, UndefinedIdScope) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %u32 = OpTypeInt 32 0 %memsem = OpConstant %u32 0 %void = OpTypeVoid @@ -4434,7 +4433,7 @@ TEST_F(ValidateIdWithMessage, UndefinedIdScope) { } TEST_F(ValidateIdWithMessage, UndefinedIdMemSem) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %u32 = OpTypeInt 32 0 %scope = OpConstant %u32 0 %void = OpTypeVoid @@ -4452,7 +4451,7 @@ TEST_F(ValidateIdWithMessage, UndefinedIdMemSem) { TEST_F(ValidateIdWithMessage, KernelOpEntryPointAndOpInBoundsPtrAccessChainGood) { - string spirv = kOpenCLMemoryModel32 + R"( + std::string spirv = kOpenCLMemoryModel32 + R"( OpEntryPoint Kernel %2 "simple_kernel" OpSource OpenCL_C 200000 OpDecorate %3 BuiltIn GlobalInvocationId @@ -4484,7 +4483,7 @@ TEST_F(ValidateIdWithMessage, } TEST_F(ValidateIdWithMessage, OpPtrAccessChainGood) { - string spirv = kOpenCLMemoryModel64 + R"( + std::string spirv = kOpenCLMemoryModel64 + R"( OpEntryPoint Kernel %2 "another_kernel" OpSource OpenCL_C 200000 OpDecorate %3 BuiltIn GlobalInvocationId @@ -4519,7 +4518,7 @@ TEST_F(ValidateIdWithMessage, OpPtrAccessChainGood) { } TEST_F(ValidateIdWithMessage, OpLoadBitcastPointerGood) { - string spirv = kOpenCLMemoryModel64 + R"( + std::string spirv = kOpenCLMemoryModel64 + R"( %2 = OpTypeVoid %3 = OpTypeInt 32 0 %4 = OpTypeFloat 32 @@ -4537,7 +4536,7 @@ TEST_F(ValidateIdWithMessage, OpLoadBitcastPointerGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpLoadBitcastNonPointerBad) { - string spirv = kOpenCLMemoryModel64 + R"( + std::string spirv = kOpenCLMemoryModel64 + R"( %2 = OpTypeVoid %3 = OpTypeInt 32 0 %4 = OpTypeFloat 32 @@ -4558,7 +4557,7 @@ TEST_F(ValidateIdWithMessage, OpLoadBitcastNonPointerBad) { HasSubstr("OpLoad type for pointer '11' is not a pointer type.")); } TEST_F(ValidateIdWithMessage, OpStoreBitcastPointerGood) { - string spirv = kOpenCLMemoryModel64 + R"( + std::string spirv = kOpenCLMemoryModel64 + R"( %2 = OpTypeVoid %3 = OpTypeInt 32 0 %4 = OpTypeFloat 32 @@ -4577,7 +4576,7 @@ TEST_F(ValidateIdWithMessage, OpStoreBitcastPointerGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateIdWithMessage, OpStoreBitcastNonPointerBad) { - string spirv = kOpenCLMemoryModel64 + R"( + std::string spirv = kOpenCLMemoryModel64 + R"( %2 = OpTypeVoid %3 = OpTypeInt 32 0 %4 = OpTypeFloat 32 @@ -4601,7 +4600,7 @@ TEST_F(ValidateIdWithMessage, OpStoreBitcastNonPointerBad) { // Result resulting from an instruction within a function may not be used // outside that function. TEST_F(ValidateIdWithMessage, ResultIdUsedOutsideOfFunctionBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %1 = OpTypeVoid %2 = OpTypeFunction %1 %3 = OpTypeInt 32 0 @@ -4626,7 +4625,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, SpecIdTargetNotSpecializationConstant) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpDecorate %1 SpecId 200 %void = OpTypeVoid %2 = OpTypeFunction %void @@ -4646,7 +4645,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, SpecIdTargetOpSpecConstantOpBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpDecorate %1 SpecId 200 %void = OpTypeVoid %2 = OpTypeFunction %void @@ -4668,7 +4667,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, SpecIdTargetOpSpecConstantCompositeBad) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpDecorate %1 SpecId 200 %void = OpTypeVoid %2 = OpTypeFunction %void @@ -4689,7 +4688,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, SpecIdTargetGood) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( OpDecorate %3 SpecId 200 OpDecorate %4 SpecId 201 OpDecorate %5 SpecId 202 @@ -4710,7 +4709,7 @@ OpFunctionEnd } TEST_F(ValidateIdWithMessage, CorrectErrorForShuffle) { - string spirv = kGLSL450MemoryModel + R"( + std::string spirv = kGLSL450MemoryModel + R"( %uint = OpTypeInt 32 0 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 diff --git a/test/val/val_layout_test.cpp b/test/val/val_layout_test.cpp index b7ddbb58e..95876b8d3 100644 --- a/test/val/val_layout_test.cpp +++ b/test/val/val_layout_test.cpp @@ -28,23 +28,13 @@ namespace spvtools { namespace val { namespace { -using std::function; -using std::ostream; -using std::ostream_iterator; -using std::pair; -using std::string; -using std::stringstream; -using std::tie; -using std::tuple; -using std::vector; - using ::testing::Eq; using ::testing::HasSubstr; using ::testing::StrEq; -using pred_type = function; -using ValidateLayout = - spvtest::ValidateBase>>; +using pred_type = std::function; +using ValidateLayout = spvtest::ValidateBase< + std::tuple>>; // returns true if order is equal to VAL template @@ -72,9 +62,9 @@ spv_result_t InvalidSet(int order) { } // SPIRV source used to test the logical layout -const vector& getInstructions() { +const std::vector& getInstructions() { // clang-format off - static const vector instructions = { + static const std::vector instructions = { "OpCapability Shader", "OpExtension \"TestExtension\"", "%inst = OpExtInstImport \"GLSL.std.450\"", @@ -135,38 +125,38 @@ INSTANTIATE_TEST_CASE_P(InstructionsOrder, // validation error. Therefore, "Lines to compile" for some instructions // are not "All" in the below. // - // | Instruction | Line(s) valid | Lines to compile - ::testing::Values(make_tuple(string("OpCapability") , Equals<0> , Range<0, 2>()) - , make_tuple(string("OpExtension") , Equals<1> , All) - , make_tuple(string("OpExtInstImport") , Equals<2> , All) - , make_tuple(string("OpMemoryModel") , Equals<3> , Range<1, kRangeEnd>()) - , make_tuple(string("OpEntryPoint") , Equals<4> , All) - , make_tuple(string("OpExecutionMode ") , Range<5, 6>() , All) - , make_tuple(string("OpExecutionModeId") , Range<5, 6>() , All) - , make_tuple(string("OpSource ") , Range<7, 11>() , Range<8, kRangeEnd>()) - , make_tuple(string("OpSourceContinued ") , Range<7, 11>() , All) - , make_tuple(string("OpSourceExtension ") , Range<7, 11>() , All) - , make_tuple(string("%str2 = OpString ") , Range<7, 11>() , All) - , make_tuple(string("OpName ") , Range<12, 13>() , All) - , make_tuple(string("OpMemberName ") , Range<12, 13>() , All) - , make_tuple(string("OpDecorate ") , Range<14, 17>() , All) - , make_tuple(string("OpMemberDecorate ") , Range<14, 17>() , All) - , make_tuple(string("OpGroupDecorate ") , Range<14, 17>() , Range<17, kRangeEnd>()) - , make_tuple(string("OpDecorationGroup") , Range<14, 17>() , Range<0, 16>()) - , make_tuple(string("OpTypeBool") , Range<18, 31>() , All) - , make_tuple(string("OpTypeVoid") , Range<18, 31>() , Range<0, 26>()) - , make_tuple(string("OpTypeFloat") , Range<18, 31>() , Range<0,21>()) - , make_tuple(string("OpTypeInt") , Range<18, 31>() , Range<0, 21>()) - , make_tuple(string("OpTypeVector %floatt 4") , Range<18, 31>() , Range<20, 24>()) - , make_tuple(string("OpTypeMatrix %vec4 4") , Range<18, 31>() , Range<23, kRangeEnd>()) - , make_tuple(string("OpTypeStruct") , Range<18, 31>() , Range<25, kRangeEnd>()) - , make_tuple(string("%vfunct = OpTypeFunction"), Range<18, 31>() , Range<21, 31>()) - , make_tuple(string("OpConstant") , Range<18, 31>() , Range<21, kRangeEnd>()) - , make_tuple(string("OpLine ") , Range<18, kRangeEnd>() , Range<8, kRangeEnd>()) - , make_tuple(string("OpNoLine") , Range<18, kRangeEnd>() , All) - , make_tuple(string("%fLabel = OpLabel") , Equals<39> , All) - , make_tuple(string("OpNop") , Equals<40> , Range<40,kRangeEnd>()) - , make_tuple(string("OpReturn ; %func2 return") , Equals<41> , All) + // | Instruction | Line(s) valid | Lines to compile + ::testing::Values(std::make_tuple(std::string("OpCapability") , Equals<0> , Range<0, 2>()) + , std::make_tuple(std::string("OpExtension") , Equals<1> , All) + , std::make_tuple(std::string("OpExtInstImport") , Equals<2> , All) + , std::make_tuple(std::string("OpMemoryModel") , Equals<3> , Range<1, kRangeEnd>()) + , std::make_tuple(std::string("OpEntryPoint") , Equals<4> , All) + , std::make_tuple(std::string("OpExecutionMode ") , Range<5, 6>() , All) + , std::make_tuple(std::string("OpExecutionModeId") , Range<5, 6>() , All) + , std::make_tuple(std::string("OpSource ") , Range<7, 11>() , Range<8, kRangeEnd>()) + , std::make_tuple(std::string("OpSourceContinued ") , Range<7, 11>() , All) + , std::make_tuple(std::string("OpSourceExtension ") , Range<7, 11>() , All) + , std::make_tuple(std::string("%str2 = OpString ") , Range<7, 11>() , All) + , std::make_tuple(std::string("OpName ") , Range<12, 13>() , All) + , std::make_tuple(std::string("OpMemberName ") , Range<12, 13>() , All) + , std::make_tuple(std::string("OpDecorate ") , Range<14, 17>() , All) + , std::make_tuple(std::string("OpMemberDecorate ") , Range<14, 17>() , All) + , std::make_tuple(std::string("OpGroupDecorate ") , Range<14, 17>() , Range<17, kRangeEnd>()) + , std::make_tuple(std::string("OpDecorationGroup") , Range<14, 17>() , Range<0, 16>()) + , std::make_tuple(std::string("OpTypeBool") , Range<18, 31>() , All) + , std::make_tuple(std::string("OpTypeVoid") , Range<18, 31>() , Range<0, 26>()) + , std::make_tuple(std::string("OpTypeFloat") , Range<18, 31>() , Range<0,21>()) + , std::make_tuple(std::string("OpTypeInt") , Range<18, 31>() , Range<0, 21>()) + , std::make_tuple(std::string("OpTypeVector %floatt 4") , Range<18, 31>() , Range<20, 24>()) + , std::make_tuple(std::string("OpTypeMatrix %vec4 4") , Range<18, 31>() , Range<23, kRangeEnd>()) + , std::make_tuple(std::string("OpTypeStruct") , Range<18, 31>() , Range<25, kRangeEnd>()) + , std::make_tuple(std::string("%vfunct = OpTypeFunction"), Range<18, 31>() , Range<21, 31>()) + , std::make_tuple(std::string("OpConstant") , Range<18, 31>() , Range<21, kRangeEnd>()) + , std::make_tuple(std::string("OpLine ") , Range<18, kRangeEnd>() , Range<8, kRangeEnd>()) + , std::make_tuple(std::string("OpNoLine") , Range<18, kRangeEnd>() , All) + , std::make_tuple(std::string("%fLabel = OpLabel") , Equals<39> , All) + , std::make_tuple(std::string("OpNop") , Equals<40> , Range<40,kRangeEnd>()) + , std::make_tuple(std::string("OpReturn ; %func2 return") , Equals<41> , All) )),); // clang-format on @@ -174,15 +164,16 @@ INSTANTIATE_TEST_CASE_P(InstructionsOrder, // instructions vector and reinserts it in the location specified by order. // NOTE: This will not work correctly if there are two instances of substr in // instructions -vector GenerateCode(string substr, int order) { - vector code(getInstructions().size()); - vector inst(1); - partition_copy(begin(getInstructions()), end(getInstructions()), begin(code), - begin(inst), [=](const string& str) { - return string::npos == str.find(substr); +std::vector GenerateCode(std::string substr, int order) { + std::vector code(getInstructions().size()); + std::vector inst(1); + partition_copy(std::begin(getInstructions()), std::end(getInstructions()), + std::begin(code), std::begin(inst), + [=](const std::string& str) { + return std::string::npos == str.find(substr); }); - code.insert(begin(code) + order, inst.front()); + code.insert(std::begin(code) + order, inst.front()); return code; } @@ -191,21 +182,22 @@ vector GenerateCode(string substr, int order) { // the SPIRV source formed by combining the vector "instructions". TEST_P(ValidateLayout, Layout) { int order; - string instruction; + std::string instruction; pred_type pred; pred_type test_pred; // Predicate to determine if the test should be build - tuple testCase; + std::tuple testCase; - tie(order, testCase) = GetParam(); - tie(instruction, pred, test_pred) = testCase; + std::tie(order, testCase) = GetParam(); + std::tie(instruction, pred, test_pred) = testCase; // Skip test which break the code generation if (test_pred(order)) return; - vector code = GenerateCode(instruction, order); + std::vector code = GenerateCode(instruction, order); - stringstream ss; - copy(begin(code), end(code), ostream_iterator(ss, "\n")); + std::stringstream ss; + std::copy(std::begin(code), std::end(code), + std::ostream_iterator(ss, "\n")); const auto env = SPV_ENV_UNIVERSAL_1_3; // printf("code: \n%s\n", ss.str().c_str()); @@ -222,7 +214,7 @@ TEST_P(ValidateLayout, Layout) { } TEST_F(ValidateLayout, MemoryModelMissingBeforeEntryPoint) { - string str = R"( + std::string str = R"( OpCapability Matrix OpExtension "TestExtension" %inst = OpExtInstImport "GLSL.std.450" @@ -346,7 +338,7 @@ TEST_F(ValidateLayout, FuncParameterNotImmediatlyAfterFuncBad) { } TEST_F(ValidateLayout, OpUndefCanAppearInTypeDeclarationSection) { - string str = R"( + std::string str = R"( OpCapability Kernel OpCapability Linkage OpMemoryModel Logical OpenCL @@ -365,7 +357,7 @@ TEST_F(ValidateLayout, OpUndefCanAppearInTypeDeclarationSection) { } TEST_F(ValidateLayout, OpUndefCanAppearInBlock) { - string str = R"( + std::string str = R"( OpCapability Kernel OpCapability Linkage OpMemoryModel Logical OpenCL diff --git a/test/val/val_limits_test.cpp b/test/val/val_limits_test.cpp index b5829621a..40fb1dcea 100644 --- a/test/val/val_limits_test.cpp +++ b/test/val/val_limits_test.cpp @@ -26,20 +26,19 @@ namespace spvtools { namespace val { namespace { -using std::string; using ::testing::HasSubstr; using ::testing::MatchesRegex; using ValidateLimits = spvtest::ValidateBase; -string header = R"( +std::string header = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 )"; TEST_F(ValidateLimits, IdLargerThanBoundBad) { - string str = header + R"( + std::string str = header + R"( ; %i32 has ID 1 %i32 = OpTypeInt 32 1 %c = OpConstant %i32 100 @@ -57,7 +56,7 @@ TEST_F(ValidateLimits, IdLargerThanBoundBad) { } TEST_F(ValidateLimits, IdEqualToBoundBad) { - string str = header + R"( + std::string str = header + R"( ; %i32 has ID 1 %i32 = OpTypeInt 32 1 %c = OpConstant %i32 100 @@ -694,7 +693,7 @@ TEST_F(ValidateLimits, CustomizedControlFlowDepthBad) { // continue target is the loop iteself. It also exercises the case where a loop // is unreachable. TEST_F(ValidateLimits, ControlFlowNoEntryToLoopGood) { - string str = header + R"( + std::string str = header + R"( OpName %entry "entry" OpName %loop "loop" OpName %exit "exit" diff --git a/test/val/val_ssa_test.cpp b/test/val/val_ssa_test.cpp index bc32ea6c5..b82bd2208 100644 --- a/test/val/val_ssa_test.cpp +++ b/test/val/val_ssa_test.cpp @@ -29,11 +29,7 @@ namespace { using ::testing::HasSubstr; using ::testing::MatchesRegex; -using std::pair; -using std::string; -using std::stringstream; - -using ValidateSSA = spvtest::ValidateBase>; +using ValidateSSA = spvtest::ValidateBase>; TEST_F(ValidateSSA, Default) { char str[] = R"( @@ -550,14 +546,14 @@ TEST_F(ValidateSSA, ForwardBranchConditionalMissingTargetBad) { // Since Int8 requires the Kernel capability, the signedness of int types may // not be "1". -const string kHeader = R"( +const std::string kHeader = R"( OpCapability Int8 OpCapability DeviceEnqueue OpCapability Linkage OpMemoryModel Logical OpenCL )"; -const string kBasicTypes = R"( +const std::string kBasicTypes = R"( %voidt = OpTypeVoid %boolt = OpTypeBool %int8t = OpTypeInt 8 0 @@ -570,7 +566,7 @@ const string kBasicTypes = R"( %false = OpConstantFalse %boolt )"; -const string kKernelTypesAndConstants = R"( +const std::string kKernelTypesAndConstants = R"( %queuet = OpTypeQueue %three = OpConstant %uintt 3 @@ -595,14 +591,14 @@ const string kKernelTypesAndConstants = R"( %kfunct = OpTypeFunction %voidt %intptrt )"; -const string kKernelSetup = R"( +const std::string kKernelSetup = R"( %dqueue = OpGetDefaultQueue %queuet %ndval = OpBuildNDRange %ndt %gl %local %offset %revent = OpUndef %eventt )"; -const string kKernelDefinition = R"( +const std::string kKernelDefinition = R"( %kfunc = OpFunction %voidt None %kfunct %iparam = OpFunctionParameter %intptrt %kfuncl = OpLabel @@ -612,8 +608,8 @@ const string kKernelDefinition = R"( )"; TEST_F(ValidateSSA, EnqueueKernelGood) { - string str = kHeader + kBasicTypes + kKernelTypesAndConstants + - kKernelDefinition + R"( + std::string str = kHeader + kBasicTypes + kKernelTypesAndConstants + + kKernelDefinition + R"( %main = OpFunction %voidt None %vfunct %mainl = OpLabel )" + kKernelSetup + R"( @@ -628,11 +624,11 @@ TEST_F(ValidateSSA, EnqueueKernelGood) { } TEST_F(ValidateSSA, ForwardEnqueueKernelGood) { - string str = kHeader + kBasicTypes + kKernelTypesAndConstants + R"( + std::string str = kHeader + kBasicTypes + kKernelTypesAndConstants + R"( %main = OpFunction %voidt None %vfunct %mainl = OpLabel )" + - kKernelSetup + R"( + kKernelSetup + R"( %err = OpEnqueueKernel %uintt %dqueue %flags %ndval %nevent %event %revent %kfunc %firstp %psize %palign %lsize @@ -644,8 +640,8 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelGood) { } TEST_F(ValidateSSA, EnqueueMissingFunctionBad) { - string str = kHeader + "OpName %kfunc \"kfunc\"" + kBasicTypes + - kKernelTypesAndConstants + R"( + std::string str = kHeader + "OpName %kfunc \"kfunc\"" + kBasicTypes + + kKernelTypesAndConstants + R"( %main = OpFunction %voidt None %vfunct %mainl = OpLabel )" + kKernelSetup + R"( @@ -660,25 +656,25 @@ TEST_F(ValidateSSA, EnqueueMissingFunctionBad) { EXPECT_THAT(getDiagnosticString(), HasSubstr("kfunc")); } -string forwardKernelNonDominantParameterBaseCode(string name = string()) { - string op_name; +std::string forwardKernelNonDominantParameterBaseCode( + std::string name = std::string()) { + std::string op_name; if (name.empty()) { op_name = ""; } else { op_name = "\nOpName %" + name + " \"" + name + "\"\n"; } - string out = kHeader + op_name + kBasicTypes + kKernelTypesAndConstants + - kKernelDefinition + - R"( + std::string out = kHeader + op_name + kBasicTypes + kKernelTypesAndConstants + + kKernelDefinition + + R"( %main = OpFunction %voidt None %vfunct %mainl = OpLabel - )" + - kKernelSetup; + )" + kKernelSetup; return out; } TEST_F(ValidateSSA, ForwardEnqueueKernelMissingParameter1Bad) { - string str = forwardKernelNonDominantParameterBaseCode("missing") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("missing") + R"( %err = OpEnqueueKernel %missing %dqueue %flags %ndval %nevent %event %revent %kfunc %firstp %psize %palign %lsize @@ -691,7 +687,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelMissingParameter1Bad) { } TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter2Bad) { - string str = forwardKernelNonDominantParameterBaseCode("dqueue2") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("dqueue2") + R"( %err = OpEnqueueKernel %uintt %dqueue2 %flags %ndval %nevent %event %revent %kfunc %firstp %psize %palign %lsize @@ -705,7 +701,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter2Bad) { } TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter3Bad) { - string str = forwardKernelNonDominantParameterBaseCode("ndval2") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("ndval2") + R"( %err = OpEnqueueKernel %uintt %dqueue %flags %ndval2 %nevent %event %revent %kfunc %firstp %psize %palign %lsize @@ -719,7 +715,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter3Bad) { } TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter4Bad) { - string str = forwardKernelNonDominantParameterBaseCode("nevent2") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("nevent2") + R"( %err = OpEnqueueKernel %uintt %dqueue %flags %ndval %nevent2 %event %revent %kfunc %firstp %psize %palign %lsize @@ -733,7 +729,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter4Bad) { } TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter5Bad) { - string str = forwardKernelNonDominantParameterBaseCode("event2") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("event2") + R"( %err = OpEnqueueKernel %uintt %dqueue %flags %ndval %nevent %event2 %revent %kfunc %firstp %psize %palign %lsize @@ -747,7 +743,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter5Bad) { } TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter6Bad) { - string str = forwardKernelNonDominantParameterBaseCode("revent2") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("revent2") + R"( %err = OpEnqueueKernel %uintt %dqueue %flags %ndval %nevent %event %revent2 %kfunc %firstp %psize %palign %lsize @@ -761,7 +757,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter6Bad) { } TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter8Bad) { - string str = forwardKernelNonDominantParameterBaseCode("firstp2") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("firstp2") + R"( %err = OpEnqueueKernel %uintt %dqueue %flags %ndval %nevent %event %revent %kfunc %firstp2 %psize %palign %lsize @@ -775,7 +771,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter8Bad) { } TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter9Bad) { - string str = forwardKernelNonDominantParameterBaseCode("psize2") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("psize2") + R"( %err = OpEnqueueKernel %uintt %dqueue %flags %ndval %nevent %event %revent %kfunc %firstp %psize2 %palign %lsize @@ -789,7 +785,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter9Bad) { } TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter10Bad) { - string str = forwardKernelNonDominantParameterBaseCode("palign2") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("palign2") + R"( %err = OpEnqueueKernel %uintt %dqueue %flags %ndval %nevent %event %revent %kfunc %firstp %psize %palign2 %lsize @@ -803,7 +799,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter10Bad) { } TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter11Bad) { - string str = forwardKernelNonDominantParameterBaseCode("lsize2") + R"( + std::string str = forwardKernelNonDominantParameterBaseCode("lsize2") + R"( %err = OpEnqueueKernel %uintt %dqueue %flags %ndval %nevent %event %revent %kfunc %firstp %psize %palign %lsize2 @@ -819,7 +815,7 @@ TEST_F(ValidateSSA, ForwardEnqueueKernelNonDominantParameter11Bad) { static const bool kWithNDrange = true; static const bool kNoNDrange = false; -pair cases[] = { +std::pair cases[] = { {"OpGetKernelNDrangeSubGroupCount", kWithNDrange}, {"OpGetKernelNDrangeMaxSubGroupSize", kWithNDrange}, {"OpGetKernelWorkGroupSize", kNoNDrange}, @@ -827,17 +823,17 @@ pair cases[] = { INSTANTIATE_TEST_CASE_P(KernelArgs, ValidateSSA, ::testing::ValuesIn(cases), ); -static const string return_instructions = R"( +static const std::string return_instructions = R"( OpReturn OpFunctionEnd )"; TEST_P(ValidateSSA, GetKernelGood) { - string instruction = GetParam().first; + std::string instruction = GetParam().first; bool with_ndrange = GetParam().second; - string ndrange_param = with_ndrange ? " %ndval " : " "; + std::string ndrange_param = with_ndrange ? " %ndval " : " "; - stringstream ss; + std::stringstream ss; // clang-format off ss << forwardKernelNonDominantParameterBaseCode() + " %numsg = " << instruction + " %uintt" + ndrange_param + "%kfunc %firstp %psize %palign" @@ -849,12 +845,12 @@ TEST_P(ValidateSSA, GetKernelGood) { } TEST_P(ValidateSSA, ForwardGetKernelGood) { - string instruction = GetParam().first; + std::string instruction = GetParam().first; bool with_ndrange = GetParam().second; - string ndrange_param = with_ndrange ? " %ndval " : " "; + std::string ndrange_param = with_ndrange ? " %ndval " : " "; // clang-format off - string str = kHeader + kBasicTypes + kKernelTypesAndConstants + + std::string str = kHeader + kBasicTypes + kKernelTypesAndConstants + R"( %main = OpFunction %voidt None %vfunct %mainl = OpLabel @@ -869,11 +865,11 @@ TEST_P(ValidateSSA, ForwardGetKernelGood) { } TEST_P(ValidateSSA, ForwardGetKernelMissingDefinitionBad) { - string instruction = GetParam().first; + std::string instruction = GetParam().first; bool with_ndrange = GetParam().second; - string ndrange_param = with_ndrange ? " %ndval " : " "; + std::string ndrange_param = with_ndrange ? " %ndval " : " "; - stringstream ss; + std::stringstream ss; // clang-format off ss << forwardKernelNonDominantParameterBaseCode("missing") + " %numsg = " << instruction + " %uintt" + ndrange_param + "%missing %firstp %psize %palign" @@ -886,11 +882,11 @@ TEST_P(ValidateSSA, ForwardGetKernelMissingDefinitionBad) { } TEST_P(ValidateSSA, ForwardGetKernelNDrangeSubGroupCountMissingParameter1Bad) { - string instruction = GetParam().first; + std::string instruction = GetParam().first; bool with_ndrange = GetParam().second; - string ndrange_param = with_ndrange ? " %ndval " : " "; + std::string ndrange_param = with_ndrange ? " %ndval " : " "; - stringstream ss; + std::stringstream ss; // clang-format off ss << forwardKernelNonDominantParameterBaseCode("missing") + " %numsg = " << instruction + " %missing" + ndrange_param + "%kfunc %firstp %psize %palign" @@ -904,11 +900,11 @@ TEST_P(ValidateSSA, ForwardGetKernelNDrangeSubGroupCountMissingParameter1Bad) { TEST_P(ValidateSSA, ForwardGetKernelNDrangeSubGroupCountNonDominantParameter2Bad) { - string instruction = GetParam().first; + std::string instruction = GetParam().first; bool with_ndrange = GetParam().second; - string ndrange_param = with_ndrange ? " %ndval2 " : " "; + std::string ndrange_param = with_ndrange ? " %ndval2 " : " "; - stringstream ss; + std::stringstream ss; // clang-format off ss << forwardKernelNonDominantParameterBaseCode("ndval2") + " %numsg = " << instruction + " %uintt" + ndrange_param + "%kfunc %firstp %psize %palign" @@ -925,11 +921,11 @@ TEST_P(ValidateSSA, TEST_P(ValidateSSA, ForwardGetKernelNDrangeSubGroupCountNonDominantParameter4Bad) { - string instruction = GetParam().first; + std::string instruction = GetParam().first; bool with_ndrange = GetParam().second; - string ndrange_param = with_ndrange ? " %ndval " : " "; + std::string ndrange_param = with_ndrange ? " %ndval " : " "; - stringstream ss; + std::stringstream ss; // clang-format off ss << forwardKernelNonDominantParameterBaseCode("firstp2") + " %numsg = " << instruction + " %uintt" + ndrange_param + "%kfunc %firstp2 %psize %palign" @@ -944,11 +940,11 @@ TEST_P(ValidateSSA, TEST_P(ValidateSSA, ForwardGetKernelNDrangeSubGroupCountNonDominantParameter5Bad) { - string instruction = GetParam().first; + std::string instruction = GetParam().first; bool with_ndrange = GetParam().second; - string ndrange_param = with_ndrange ? " %ndval " : " "; + std::string ndrange_param = with_ndrange ? " %ndval " : " "; - stringstream ss; + std::stringstream ss; // clang-format off ss << forwardKernelNonDominantParameterBaseCode("psize2") + " %numsg = " << instruction + " %uintt" + ndrange_param + "%kfunc %firstp %psize2 %palign" @@ -963,11 +959,11 @@ TEST_P(ValidateSSA, TEST_P(ValidateSSA, ForwardGetKernelNDrangeSubGroupCountNonDominantParameter6Bad) { - string instruction = GetParam().first; + std::string instruction = GetParam().first; bool with_ndrange = GetParam().second; - string ndrange_param = with_ndrange ? " %ndval " : " "; + std::string ndrange_param = with_ndrange ? " %ndval " : " "; - stringstream ss; + std::stringstream ss; // clang-format off ss << forwardKernelNonDominantParameterBaseCode("palign2") + " %numsg = " << instruction + " %uintt" + ndrange_param + "%kfunc %firstp %psize %palign2" @@ -983,8 +979,8 @@ TEST_P(ValidateSSA, } TEST_F(ValidateSSA, PhiGood) { - string str = kHeader + kBasicTypes + - R"( + std::string str = kHeader + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %preheader = OpLabel %init = OpCopyObject %uintt %zero @@ -1006,8 +1002,8 @@ TEST_F(ValidateSSA, PhiGood) { } TEST_F(ValidateSSA, PhiMissingTypeBad) { - string str = kHeader + "OpName %missing \"missing\"" + kBasicTypes + - R"( + std::string str = kHeader + "OpName %missing \"missing\"" + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %preheader = OpLabel %init = OpCopyObject %uintt %zero @@ -1030,8 +1026,8 @@ TEST_F(ValidateSSA, PhiMissingTypeBad) { } TEST_F(ValidateSSA, PhiMissingIdBad) { - string str = kHeader + "OpName %missing \"missing\"" + kBasicTypes + - R"( + std::string str = kHeader + "OpName %missing \"missing\"" + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %preheader = OpLabel %init = OpCopyObject %uintt %zero @@ -1054,8 +1050,8 @@ TEST_F(ValidateSSA, PhiMissingIdBad) { } TEST_F(ValidateSSA, PhiMissingLabelBad) { - string str = kHeader + "OpName %missing \"missing\"" + kBasicTypes + - R"( + std::string str = kHeader + "OpName %missing \"missing\"" + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %preheader = OpLabel %init = OpCopyObject %uintt %zero @@ -1078,8 +1074,8 @@ TEST_F(ValidateSSA, PhiMissingLabelBad) { } TEST_F(ValidateSSA, IdDominatesItsUseGood) { - string str = kHeader + kBasicTypes + - R"( + std::string str = kHeader + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel %cond = OpSLessThan %boolt %one %ten @@ -1102,12 +1098,12 @@ TEST_F(ValidateSSA, IdDominatesItsUseGood) { } TEST_F(ValidateSSA, IdDoesNotDominateItsUseBad) { - string str = kHeader + - "OpName %eleven \"eleven\"\n" - "OpName %true_block \"true_block\"\n" - "OpName %false_block \"false_block\"" + - kBasicTypes + - R"( + std::string str = kHeader + + "OpName %eleven \"eleven\"\n" + "OpName %true_block \"true_block\"\n" + "OpName %false_block \"false_block\"" + + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel %cond = OpSLessThan %boolt %one %ten @@ -1134,8 +1130,8 @@ TEST_F(ValidateSSA, IdDoesNotDominateItsUseBad) { } TEST_F(ValidateSSA, PhiUseDoesntDominateDefinitionGood) { - string str = kHeader + kBasicTypes + - R"( + std::string str = kHeader + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel %var_one = OpVariable %intptrt Function %one @@ -1162,8 +1158,8 @@ TEST_F(ValidateSSA, PhiUseDoesntDominateDefinitionGood) { TEST_F(ValidateSSA, PhiUseDoesntDominateUseOfPhiOperandUsedBeforeDefinitionBad) { - string str = kHeader + "OpName %inew \"inew\"" + kBasicTypes + - R"( + std::string str = kHeader + "OpName %inew \"inew\"" + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel %var_one = OpVariable %intptrt Function %one @@ -1193,10 +1189,10 @@ TEST_F(ValidateSSA, } TEST_F(ValidateSSA, PhiUseMayComeFromNonDominatingBlockGood) { - string str = kHeader + "OpName %if_true \"if_true\"\n" + - "OpName %exit \"exit\"\n" + "OpName %copy \"copy\"\n" + - kBasicTypes + - R"( + std::string str = kHeader + "OpName %if_true \"if_true\"\n" + + "OpName %exit \"exit\"\n" + "OpName %copy \"copy\"\n" + + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel OpBranchConditional %false %if_true %exit @@ -1223,9 +1219,9 @@ TEST_F(ValidateSSA, PhiUsesItsOwnDefinitionGood) { // // Non-phi instructions can't use their own definitions, as // already checked in test DominateUsageSameInstructionBad. - string str = kHeader + "OpName %loop \"loop\"\n" + - "OpName %value \"value\"\n" + kBasicTypes + - R"( + std::string str = kHeader + "OpName %loop \"loop\"\n" + + "OpName %value \"value\"\n" + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel OpBranch %loop @@ -1242,11 +1238,12 @@ TEST_F(ValidateSSA, PhiUsesItsOwnDefinitionGood) { } TEST_F(ValidateSSA, PhiVariableDefNotDominatedByParentBlockBad) { - string str = kHeader + "OpName %if_true \"if_true\"\n" + - "OpName %if_false \"if_false\"\n" + "OpName %exit \"exit\"\n" + - "OpName %value \"phi\"\n" + "OpName %true_copy \"true_copy\"\n" + - "OpName %false_copy \"false_copy\"\n" + kBasicTypes + - R"( + std::string str = kHeader + "OpName %if_true \"if_true\"\n" + + "OpName %if_false \"if_false\"\n" + + "OpName %exit \"exit\"\n" + "OpName %value \"phi\"\n" + + "OpName %true_copy \"true_copy\"\n" + + "OpName %false_copy \"false_copy\"\n" + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel OpBranchConditional %false %if_true %if_false @@ -1277,8 +1274,8 @@ TEST_F(ValidateSSA, PhiVariableDefNotDominatedByParentBlockBad) { } TEST_F(ValidateSSA, PhiVariableDefDominatesButNotDefinedInParentBlock) { - string str = kHeader + "OpName %if_true \"if_true\"\n" + kBasicTypes + - R"( + std::string str = kHeader + "OpName %if_true \"if_true\"\n" + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel OpBranchConditional %false %if_true %if_false @@ -1307,8 +1304,8 @@ TEST_F(ValidateSSA, PhiVariableDefDominatesButNotDefinedInParentBlock) { TEST_F(ValidateSSA, DominanceCheckIgnoresUsesInUnreachableBlocksDefInBlockGood) { - string str = kHeader + kBasicTypes + - R"( + std::string str = kHeader + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel %def = OpCopyObject %boolt %false @@ -1325,8 +1322,9 @@ TEST_F(ValidateSSA, } TEST_F(ValidateSSA, PhiVariableUnreachableDefNotInParentBlock) { - string str = kHeader + "OpName %unreachable \"unreachable\"\n" + kBasicTypes + - R"( + std::string str = kHeader + "OpName %unreachable \"unreachable\"\n" + + kBasicTypes + + R"( %func = OpFunction %voidt None %vfunct %entry = OpLabel OpBranch %if_false @@ -1355,8 +1353,8 @@ TEST_F(ValidateSSA, PhiVariableUnreachableDefNotInParentBlock) { TEST_F(ValidateSSA, DominanceCheckIgnoresUsesInUnreachableBlocksDefIsParamGood) { - string str = kHeader + kBasicTypes + - R"( + std::string str = kHeader + kBasicTypes + + R"( %void_fn_int = OpTypeFunction %voidt %uintt %func = OpFunction %voidt None %void_fn_int %int_param = OpFunctionParameter %uintt @@ -1374,11 +1372,11 @@ TEST_F(ValidateSSA, } TEST_F(ValidateSSA, UseFunctionParameterFromOtherFunctionBad) { - string str = kHeader + - "OpName %first \"first\"\n" - "OpName %func \"func\"\n" + - "OpName %func2 \"func2\"\n" + kBasicTypes + - R"( + std::string str = kHeader + + "OpName %first \"first\"\n" + "OpName %func \"func\"\n" + + "OpName %func2 \"func2\"\n" + kBasicTypes + + R"( %viifunct = OpTypeFunction %voidt %uintt %uintt %func = OpFunction %voidt None %viifunct %first = OpFunctionParameter %uintt @@ -1406,7 +1404,7 @@ TEST_F(ValidateSSA, TypeForwardPointerForwardReference) { // See https://github.com/KhronosGroup/SPIRV-Tools/issues/429 // // ForwardPointers can references instructions that have not been defined - string str = R"( + std::string str = R"( OpCapability Kernel OpCapability Addresses OpCapability Linkage @@ -1422,7 +1420,7 @@ TEST_F(ValidateSSA, TypeForwardPointerForwardReference) { } TEST_F(ValidateSSA, TypeStructForwardReference) { - string str = R"( + std::string str = R"( OpCapability Kernel OpCapability Addresses OpCapability Linkage diff --git a/test/val/val_state_test.cpp b/test/val/val_state_test.cpp index b74d5e394..a344f4daa 100644 --- a/test/val/val_state_test.cpp +++ b/test/val/val_state_test.cpp @@ -32,8 +32,6 @@ namespace spvtools { namespace val { namespace { -using std::vector; - // This is all we need for these tests. static uint32_t kFakeBinary[] = {0}; diff --git a/test/val/val_type_unique_test.cpp b/test/val/val_type_unique_test.cpp index 0db854139..7215c1d6b 100644 --- a/test/val/val_type_unique_test.cpp +++ b/test/val/val_type_unique_test.cpp @@ -27,14 +27,12 @@ namespace { using ::testing::HasSubstr; using ::testing::Not; -using std::string; - using ValidateTypeUnique = spvtest::ValidateBase; const spv_result_t kDuplicateTypeError = SPV_ERROR_INVALID_DATA; -const string& GetHeader() { - static const string header = R"( +const std::string& GetHeader() { + static const std::string header = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -66,8 +64,8 @@ OpMemoryModel Logical GLSL450 return header; } -const string& GetBody() { - static const string body = R"( +const std::string& GetBody() { + static const std::string body = R"( %main = OpFunction %voidt None %vfunct %mainl = OpLabel %a = OpIAdd %uintt %const3 %val3 @@ -92,19 +90,19 @@ OpFunctionEnd // Returns expected error string if |opcode| produces a duplicate type // declaration. -string GetErrorString(SpvOp opcode) { +std::string GetErrorString(SpvOp opcode) { return "Duplicate non-aggregate type declarations are not allowed. Opcode: " + std::string(spvOpcodeString(opcode)); } TEST_F(ValidateTypeUnique, success) { - string str = GetHeader() + GetBody(); + std::string str = GetHeader() + GetBody(); CompileSuccessfully(str.c_str()); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateTypeUnique, duplicate_void) { - string str = GetHeader() + R"( + std::string str = GetHeader() + R"( %boolt2 = OpTypeVoid )" + GetBody(); CompileSuccessfully(str.c_str()); @@ -113,7 +111,7 @@ TEST_F(ValidateTypeUnique, duplicate_void) { } TEST_F(ValidateTypeUnique, duplicate_bool) { - string str = GetHeader() + R"( + std::string str = GetHeader() + R"( %boolt2 = OpTypeBool )" + GetBody(); CompileSuccessfully(str.c_str()); @@ -122,7 +120,7 @@ TEST_F(ValidateTypeUnique, duplicate_bool) { } TEST_F(ValidateTypeUnique, duplicate_int) { - string str = GetHeader() + R"( + std::string str = GetHeader() + R"( %uintt2 = OpTypeInt 32 0 )" + GetBody(); CompileSuccessfully(str.c_str()); @@ -131,7 +129,7 @@ TEST_F(ValidateTypeUnique, duplicate_int) { } TEST_F(ValidateTypeUnique, duplicate_float) { - string str = GetHeader() + R"( + std::string str = GetHeader() + R"( %floatt2 = OpTypeFloat 32 )" + GetBody(); CompileSuccessfully(str.c_str()); @@ -140,7 +138,7 @@ TEST_F(ValidateTypeUnique, duplicate_float) { } TEST_F(ValidateTypeUnique, duplicate_vec3) { - string str = GetHeader() + R"( + std::string str = GetHeader() + R"( %vec3t2 = OpTypeVector %floatt 3 )" + GetBody(); CompileSuccessfully(str.c_str()); @@ -150,7 +148,7 @@ TEST_F(ValidateTypeUnique, duplicate_vec3) { } TEST_F(ValidateTypeUnique, duplicate_mat33) { - string str = GetHeader() + R"( + std::string str = GetHeader() + R"( %mat33t2 = OpTypeMatrix %vec3t 3 )" + GetBody(); CompileSuccessfully(str.c_str()); @@ -160,7 +158,7 @@ TEST_F(ValidateTypeUnique, duplicate_mat33) { } TEST_F(ValidateTypeUnique, duplicate_vfunc) { - string str = GetHeader() + R"( + std::string str = GetHeader() + R"( %vfunct2 = OpTypeFunction %voidt )" + GetBody(); CompileSuccessfully(str.c_str()); @@ -170,7 +168,7 @@ TEST_F(ValidateTypeUnique, duplicate_vfunc) { } TEST_F(ValidateTypeUnique, duplicate_pipe_storage) { - string str = R"( + std::string str = R"( OpCapability Addresses OpCapability Kernel OpCapability Linkage @@ -187,7 +185,7 @@ OpMemoryModel Physical32 OpenCL } TEST_F(ValidateTypeUnique, duplicate_named_barrier) { - string str = R"( + std::string str = R"( OpCapability Addresses OpCapability Kernel OpCapability Linkage @@ -203,7 +201,7 @@ OpMemoryModel Physical32 OpenCL } TEST_F(ValidateTypeUnique, duplicate_forward_pointer) { - string str = R"( + std::string str = R"( OpCapability Addresses OpCapability Kernel OpCapability GenericPointer @@ -221,7 +219,7 @@ OpTypeForwardPointer %ptr2 Generic } TEST_F(ValidateTypeUnique, duplicate_void_with_extension) { - string str = R"( + std::string str = R"( OpCapability Addresses OpCapability Kernel OpCapability Linkage @@ -238,7 +236,7 @@ OpMemoryModel Physical32 OpenCL } TEST_F(ValidateTypeUnique, DuplicatePointerTypesNoExtension) { - string str = R"( + std::string str = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450 @@ -251,7 +249,7 @@ OpMemoryModel Logical GLSL450 } TEST_F(ValidateTypeUnique, DuplicatePointerTypesWithExtension) { - string str = R"( + std::string str = R"( OpCapability Shader OpCapability Linkage OpExtension "SPV_KHR_variable_pointers" diff --git a/test/val/val_validation_state_test.cpp b/test/val/val_validation_state_test.cpp index 8a2206718..79cc06e17 100644 --- a/test/val/val_validation_state_test.cpp +++ b/test/val/val_validation_state_test.cpp @@ -25,7 +25,6 @@ namespace spvtools { namespace val { namespace { -using std::string; using ::testing::HasSubstr; using ValidationStateTest = spvtest::ValidateBase; @@ -45,7 +44,7 @@ const char kVoidFVoid[] = // Tests that the instruction count in ValidationState is correct. TEST_F(ValidationStateTest, CheckNumInstructions) { - string spirv = string(header) + "%int = OpTypeInt 32 0"; + std::string spirv = std::string(header) + "%int = OpTypeInt 32 0"; CompileSuccessfully(spirv); EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); EXPECT_EQ(size_t(4), vstate_->ordered_instructions().size()); @@ -53,7 +52,7 @@ TEST_F(ValidationStateTest, CheckNumInstructions) { // Tests that the number of global variables in ValidationState is correct. TEST_F(ValidationStateTest, CheckNumGlobalVars) { - string spirv = string(header) + R"( + std::string spirv = std::string(header) + R"( %int = OpTypeInt 32 0 %_ptr_int = OpTypePointer Input %int %var_1 = OpVariable %_ptr_int Input @@ -66,7 +65,7 @@ TEST_F(ValidationStateTest, CheckNumGlobalVars) { // Tests that the number of local variables in ValidationState is correct. TEST_F(ValidationStateTest, CheckNumLocalVars) { - string spirv = string(header) + R"( + std::string spirv = std::string(header) + R"( %int = OpTypeInt 32 0 %_ptr_int = OpTypePointer Function %int %voidt = OpTypeVoid @@ -86,7 +85,7 @@ TEST_F(ValidationStateTest, CheckNumLocalVars) { // Tests that the "id bound" in ValidationState is correct. TEST_F(ValidationStateTest, CheckIdBound) { - string spirv = string(header) + R"( + std::string spirv = std::string(header) + R"( %int = OpTypeInt 32 0 %voidt = OpTypeVoid )"; @@ -97,8 +96,9 @@ TEST_F(ValidationStateTest, CheckIdBound) { // Tests that the entry_points in ValidationState is correct. TEST_F(ValidationStateTest, CheckEntryPoints) { - string spirv = string(header) + " OpEntryPoint Vertex %func \"shader\"" + - string(kVoidFVoid); + std::string spirv = std::string(header) + + " OpEntryPoint Vertex %func \"shader\"" + + std::string(kVoidFVoid); CompileSuccessfully(spirv); EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState()); EXPECT_EQ(size_t(1), vstate_->entry_points().size()); diff --git a/test/val/val_version_test.cpp b/test/val/val_version_test.cpp index 9c90e3045..58f47897e 100644 --- a/test/val/val_version_test.cpp +++ b/test/val/val_version_test.cpp @@ -20,7 +20,6 @@ namespace val { namespace { using ::testing::HasSubstr; -using std::make_tuple; using ValidateVersion = spvtest::ValidateBase< std::tuple>; @@ -93,180 +92,180 @@ TEST_P(ValidateVersion, version) { INSTANTIATE_TEST_CASE_P(Universal, ValidateVersion, ::testing::Values( // Binary version, Target environment - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_0, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_3, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_5, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_WEBGPU_0, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_0, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_WEBGPU_0, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_WEBGPU_0, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_WEBGPU_0, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_WEBGPU_0, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_WEBGPU_0, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), - make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_WEBGPU_0, vulkan_spirv, true) + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_WEBGPU_0, vulkan_spirv, true) ) ); INSTANTIATE_TEST_CASE_P(Vulkan, ValidateVersion, ::testing::Values( // Binary version, Target environment - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_0, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_3, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_0, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_5, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), - make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) ) ); INSTANTIATE_TEST_CASE_P(OpenCL, ValidateVersion, ::testing::Values( // Binary version, Target environment - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_0, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_1, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_1_2, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_0, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_1, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_1_2, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_1_2, opencl_spirv, true) + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_1_2, opencl_spirv, true) ) ); INSTANTIATE_TEST_CASE_P(OpenCLEmbedded, ValidateVersion, ::testing::Values( // Binary version, Target environment - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_0, SPV_ENV_OPENCL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_1, SPV_ENV_OPENCL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_2_0, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_2_1, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, false), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), - make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_1_2, opencl_spirv, false) + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_UNIVERSAL_1_0, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_2_0, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_2_1, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_EMBEDDED_2_0, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_EMBEDDED_2_1, opencl_spirv, false), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_EMBEDDED_2_2, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_EMBEDDED_2_2, SPV_ENV_OPENCL_1_2, opencl_spirv, false) ) ); // clang-format on diff --git a/test/val/val_webgpu_test.cpp b/test/val/val_webgpu_test.cpp index 27594e899..a45c94015 100644 --- a/test/val/val_webgpu_test.cpp +++ b/test/val/val_webgpu_test.cpp @@ -22,13 +22,12 @@ namespace spvtools { namespace val { namespace { -using std::string; using testing::HasSubstr; using ValidateWebGPU = spvtest::ValidateBase; TEST_F(ValidateWebGPU, OpUndefIsDisallowed) { - string spirv = R"( + std::string spirv = R"( OpCapability Shader OpCapability Linkage OpMemoryModel Logical GLSL450