Remove using std::<foo> statements. (#1756)

Many of the files have using std::<foo> statements in them, but then the
use of <foo> will be inconsistently std::<foo> or <foo> scattered
through the file. This CL removes all of the using statements and
updates the code to have the required std:: prefix.
This commit is contained in:
dan sinclair 2018-08-01 14:58:12 -04:00 committed by GitHub
parent ebd6c75a71
commit a5a5ea0e2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 1647 additions and 1696 deletions

View File

@ -25,14 +25,6 @@
#include <utility>
#include <vector>
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<pair<BB*, BB*>> CalculateDominators(
const vector<cbb_ptr>& postorder, get_blocks_func predecessor_func);
static std::vector<std::pair<BB*, BB*>> CalculateDominators(
const std::vector<cbb_ptr>& 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 <class BB>
bool CFA<BB>::FindInWorkList(const vector<block_info>& work_list, uint32_t id) {
bool CFA<BB>::FindInWorkList(const std::vector<block_info>& work_list,
uint32_t id) {
for (const auto b : work_list) {
if (b.block->id() == id) return true;
}
@ -141,19 +134,19 @@ bool CFA<BB>::FindInWorkList(const vector<block_info>& work_list, uint32_t id) {
}
template <class BB>
void CFA<BB>::DepthFirstTraversal(const BB* entry,
get_blocks_func successor_func,
function<void(cbb_ptr)> preorder,
function<void(cbb_ptr)> postorder,
function<void(cbb_ptr, cbb_ptr)> backedge) {
unordered_set<uint32_t> processed;
void CFA<BB>::DepthFirstTraversal(
const BB* entry, get_blocks_func successor_func,
std::function<void(cbb_ptr)> preorder,
std::function<void(cbb_ptr)> postorder,
std::function<void(cbb_ptr, cbb_ptr)> backedge) {
std::unordered_set<uint32_t> processed;
/// NOTE: work_list is the sequence of nodes from the root node to the node
/// being processed in the traversal
vector<block_info> work_list;
std::vector<block_info> 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<BB>::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<BB>::DepthFirstTraversal(const BB* entry,
}
template <class BB>
vector<pair<BB*, BB*>> CFA<BB>::CalculateDominators(
const vector<cbb_ptr>& postorder, get_blocks_func predecessor_func) {
std::vector<std::pair<BB*, BB*>> CFA<BB>::CalculateDominators(
const std::vector<cbb_ptr>& 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<cbb_ptr, block_detail> idoms;
std::unordered_map<cbb_ptr, block_detail> idoms;
for (size_t i = 0; i < postorder.size(); i++) {
idoms[postorder[i]] = {undefined_dom, i};
}
@ -197,14 +190,14 @@ vector<pair<BB*, BB*>> CFA<BB>::CalculateDominators(
while (changed) {
changed = false;
for (auto b = postorder.rbegin() + 1; b != postorder.rend(); ++b) {
const vector<BB*>& predecessors = *predecessor_func(*b);
const std::vector<BB*>& 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<pair<BB*, BB*>> CFA<BB>::CalculateDominators(
}
}
vector<pair<bb_ptr, bb_ptr>> out;
std::vector<std::pair<bb_ptr, bb_ptr>> out;
for (auto idom : idoms) {
// NOTE: performing a const cast for convenient usage with
// UpdateImmediateDominators
out.push_back({const_cast<BB*>(get<0>(idom)),
const_cast<BB*>(postorder[get<1>(idom).dominator])});
out.push_back({const_cast<BB*>(std::get<0>(idom)),
const_cast<BB*>(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<bb_ptr, bb_ptr>& lhs,
const pair<bb_ptr, bb_ptr>& rhs) {
[&idoms](const std::pair<bb_ptr, bb_ptr>& lhs,
const std::pair<bb_ptr, bb_ptr>& rhs) {
assert(lhs.first);
assert(lhs.second);
assert(rhs.first);

View File

@ -143,8 +143,9 @@ void CFG::ComputeStructuredSuccessors(Function* func) {
}
}
void CFG::ComputePostOrderTraversal(BasicBlock* bb, vector<BasicBlock*>* order,
unordered_set<BasicBlock*>* seen) {
void CFG::ComputePostOrderTraversal(BasicBlock* bb,
std::vector<BasicBlock*>* order,
std::unordered_set<BasicBlock*>* seen) {
seen->insert(bb);
static_cast<const BasicBlock*>(bb)->ForEachSuccessorLabel(
[&order, &seen, this](const uint32_t sbid) {

View File

@ -116,7 +116,7 @@ void LocalSingleStoreElimPass::InitExtensionWhiteList() {
});
}
bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) {
vector<Instruction*> users;
std::vector<Instruction*> 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<Instruction*>& users) const {
Instruction* var_inst, const std::vector<Instruction*>& users) const {
// Make sure there is exactly 1 store.
Instruction* store_inst = nullptr;

View File

@ -178,7 +178,7 @@ void MemPass::AddStores(uint32_t ptr_id, std::queue<Instruction*>* insts) {
}
void MemPass::DCEInst(Instruction* inst,
const function<void(Instruction*)>& call_back) {
const std::function<void(Instruction*)>& call_back) {
std::queue<Instruction*> 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<BasicBlock*>& reachable_blocks) {
Instruction* phi, const std::unordered_set<BasicBlock*>& reachable_blocks) {
std::vector<Operand> keep_operands;
uint32_t type_id = 0;
// The id of an undefined value we've generated.

View File

@ -18,8 +18,6 @@
#include <utility>
#include <vector>
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<BasicBlock*>& next_blocks) {
void BasicBlock::RegisterSuccessors(
const std::vector<BasicBlock*>& next_blocks) {
for (auto& block : next_blocks) {
block->predecessors_.push_back(this);
successors_.push_back(block);

View File

@ -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<uint32_t> next_list,
void Function::RegisterBlockEnd(std::vector<uint32_t> next_list,
SpvOp branch_instruction) {
assert(
current_block_ &&
"RegisterBlockEnd can only be called when parsing a binary in a block");
vector<BasicBlock*> next_blocks;
std::vector<BasicBlock*> next_blocks;
next_blocks.reserve(next_list.size());
std::unordered_map<uint32_t, BasicBlock>::iterator inserted_block;
@ -196,16 +189,18 @@ size_t Function::undefined_block_count() const {
return undefined_blocks_.size();
}
const vector<BasicBlock*>& Function::ordered_blocks() const {
const std::vector<BasicBlock*>& Function::ordered_blocks() const {
return ordered_blocks_;
}
vector<BasicBlock*>& Function::ordered_blocks() { return ordered_blocks_; }
std::vector<BasicBlock*>& Function::ordered_blocks() { return ordered_blocks_; }
const BasicBlock* Function::current_block() const { return current_block_; }
BasicBlock* Function::current_block() { return current_block_; }
const list<Construct>& Function::constructs() const { return cfg_constructs_; }
list<Construct>& Function::constructs() { return cfg_constructs_; }
const std::list<Construct>& Function::constructs() const {
return cfg_constructs_;
}
std::list<Construct>& 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<const BasicBlock*, bool> Function::GetBlock(uint32_t block_id) const {
std::pair<const BasicBlock*, bool> 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<BasicBlock*, bool> Function::GetBlock(uint32_t block_id) {
std::pair<BasicBlock*, bool> Function::GetBlock(uint32_t block_id) {
const BasicBlock* out;
bool defined;
tie(out, defined) = const_cast<const Function*>(this)->GetBlock(block_id);
return make_pair(const_cast<BasicBlock*>(out), defined);
std::tie(out, defined) =
const_cast<const Function*>(this)->GetBlock(block_id);
return std::make_pair(const_cast<BasicBlock*>(out), defined);
}
Function::GetBlocksFunction Function::AugmentedCFGSuccessorsFunction() const {

View File

@ -16,8 +16,6 @@
#include <utility>
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

View File

@ -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<uint32_t> ids = vstate->UnresolvedForwardIds();
std::stringstream ss;
std::vector<uint32_t> ids = vstate->UnresolvedForwardIds();
transform(begin(ids), end(ids), ostream_iterator<string>(ss, " "),
bind(&ValidationState_t::getIdName, std::ref(*vstate), _1));
transform(std::begin(ids), std::end(ids),
std::ostream_iterator<std::string>(ss, " "),
bind(&ValidationState_t::getIdName, std::ref(*vstate),
std::placeholders::_1));
auto id_str = ss.str();
return vstate->diag(SPV_ERROR_INVALID_ID, nullptr)

View File

@ -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<pair<uint32_t, uint32_t>>& back_edges) {
Function& function,
const std::vector<std::pair<uint32_t, uint32_t>>& 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<string, string, string> ConstructNames(ConstructType type) {
string construct_name, header_name, exit_name;
std::tuple<std::string, std::string, std::string> ConstructNames(
ConstructType type) {
std::string construct_name, header_name, exit_name;
switch (type) {
case ConstructType::kSelection:
@ -140,16 +127,16 @@ tuple<string, string, string> 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<pair<uint32_t, uint32_t>>& back_edges) {
const std::vector<std::pair<uint32_t, uint32_t>>& 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 <ID> " << 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<const BasicBlock*> postorder;
vector<const BasicBlock*> postdom_postorder;
vector<pair<uint32_t, uint32_t>> back_edges;
std::vector<const BasicBlock*> postorder;
std::vector<const BasicBlock*> postdom_postorder;
std::vector<std::pair<uint32_t, uint32_t>> 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<uint32_t> cases;
std::vector<uint32_t> cases;
for (size_t i = 1; i < inst->operands().size(); i += 2) {
uint32_t target = inst->GetOperandAs<uint32_t>(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<uint32_t>(), opcode);
_.current_function().RegisterBlockEnd(std::vector<uint32_t>(), opcode);
if (opcode == SpvOpKill) {
_.current_function().RegisterExecutionModelLimitation(
SpvExecutionModelFragment,

View File

@ -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) {

View File

@ -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<uint32_t>& entry_points,
spv_position positionArg, const MessageConsumer& consumer)
const ValidationState_t& module,
const std::vector<uint32_t>& 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<uint32_t> entry_points_;
std::vector<uint32_t> 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<Decoration>& type1_decorations,
const vector<Decoration>& type2_decorations) const;
const std::vector<Decoration>& type1_decorations,
const std::vector<Decoration>& type2_decorations) const;
};
#define DIAG(inst) \
@ -367,8 +361,8 @@ bool idUsage::isValid<SpvOpTypeSampler>(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<uint32_t>& constWords,
const vector<uint32_t>& typeWords) {
bool aboveZero(const std::vector<uint32_t>& constWords,
const std::vector<uint32_t>& 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<SpvOpConstantSampler>(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<uint32_t>& instruction,
bool IsTypeNullable(const std::vector<uint32_t>& 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<Decoration>& type1_decorations,
const vector<Decoration>& type2_decorations) const {
const std::vector<Decoration>& type1_decorations,
const std::vector<Decoration>& 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<const Instruction*> phi_instructions;
std::unordered_set<const Instruction*> phi_instructions;
for (const auto& definition : _.all_definitions()) {
// Check only those definitions defined in a function
if (const Function* func = definition.second->function()) {

View File

@ -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<uint32_t> 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 {

View File

@ -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<tuple<spv_target_env, std::string>>>;
::testing::TestWithParam<std::tuple<spv_target_env, std::string>>>;
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

View File

@ -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<tuple<spv_target_env, EnumCapabilityCase>>;
TestWithParam<std::tuple<spv_target_env, EnumCapabilityCase>>;
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);
}

View File

@ -18,7 +18,6 @@ namespace spvtools {
namespace {
using GetTargetTest = ::testing::TestWithParam<spv_target_env>;
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_target_env>{SPV_ENV_UNIVERSAL_1_0,
SPV_ENV_UNIVERSAL_1_1,
SPV_ENV_VULKAN_1_0}), );
ValuesIn(std::vector<spv_target_env>{
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.

View File

@ -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<tuple<spv_target_env, EnumCase<SpvDecoration>>>>;
using OpDecorateSimpleTest =
spvtest::TextToBinaryTestBase<::testing::TestWithParam<
std::tuple<spv_target_env, EnumCase<SpvDecoration>>>>;
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<tuple<spv_target_env, EnumCase<SpvDecoration>>>>;
using OpMemberDecorateSimpleTest =
spvtest::TextToBinaryTestBase<::testing::TestWithParam<
std::tuple<spv_target_env, EnumCase<SpvDecoration>>>>;
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()));
}

View File

@ -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<tuple<spv_target_env, EnumCase<int>>>>;
TestWithParam<std::tuple<spv_target_env, EnumCase<int>>>>;
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())));
}

View File

@ -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<tuple<spv_target_env, EnumCase<SpvExecutionMode>>>>;
TestWithParam<std::tuple<spv_target_env, EnumCase<SpvExecutionMode>>>>;
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

View File

@ -24,7 +24,6 @@ namespace spvtools {
namespace {
using ::spvtest::MakeInstruction;
using std::vector;
using ::testing::Eq;
using OpGetKernelLocalSizeForSubgroupCountTest = spvtest::TextToBinaryTest;

View File

@ -27,8 +27,6 @@ namespace {
using ::testing::HasSubstr;
using ::testing::Not;
using std::string;
using ValidateArithmetics = spvtest::ValidateBase<bool>;
std::string GenerateCode(const std::string& main_body) {

File diff suppressed because it is too large Load Diff

View File

@ -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<SpvCapability>;
using spvtest::ScopedContext;
string nameOps() { return ""; }
std::string nameOps() { return ""; }
template <typename... Args>
string nameOps(pair<string, string> head, Args... names) {
std::string nameOps(std::pair<std::string, std::string> head, Args... names) {
return "OpName %" + head.first + " \"" + head.second + "\"\n" +
nameOps(names...);
}
template <typename... Args>
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<Block> successors_;
std::vector<Block> 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<Block> successors);
friend Block& operator>>(Block& curr, std::vector<Block> successors);
friend Block& operator>>(Block& lhs, Block& successor);
};
/// Assigns the successors for the Block on the lhs
Block& operator>>(Block& lhs, vector<Block> successors) {
Block& operator>>(Block& lhs, std::vector<Block> 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<Block>({cont, merge});
str += loop >> std::vector<Block>({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<Block>({merge, loop});
str += loop >> std::vector<Block>({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<Block>({cont, merge});
str += branch >> std::vector<Block>({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<Block>({loop, merge});
str += selection >> std::vector<Block>({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<Block>({merge, loop});
str += loop >> vector<Block>({loop, merge});
str += selection >> std::vector<Block>({merge, loop});
str += loop >> std::vector<Block>({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<Block>({entry, exit}); // cannot target entry block
str += bad >> std::vector<Block>({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<Block>({t, entry});
str += bad >> std::vector<Block>({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<Block>({def, block1, block2, block3, entry});
str += bad >> std::vector<Block>({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<Block>({end, middle2});
str += middle >> std::vector<Block>({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<Block>({merge, f});
str += head >> std::vector<Block>({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<Block>({exit, exit});
str += head >> std::vector<Block>({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<Block>({t, f});
str += branch >> std::vector<Block>({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<Block>({t, f});
str += branch >> std::vector<Block>({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<Block>({unreachablechildt, unreachablechildf});
str +=
unreachable >> std::vector<Block>({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<Block>({loop, exit});
str += loop >> std::vector<Block>({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<Block>({loop1_merge, loop2});
str += loop2 >> vector<Block>({loop2, loop2_merge});
str += loop1_cont_break_block >> std::vector<Block>({loop1_merge, loop2});
str += loop2 >> std::vector<Block>({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<Block> if_blocks;
vector<Block> merge_blocks;
std::vector<Block> if_blocks;
std::vector<Block> 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<Block>({if_blocks[i + 1], merge_blocks[i]});
str +=
if_blocks[i] >> std::vector<Block>({if_blocks[i + 1], merge_blocks[i]});
}
str += if_blocks.back() >> vector<Block>({inner, merge_blocks.back()});
str += if_blocks.back() >> std::vector<Block>({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<Block>({loop2, exit});
str += loop2 >> vector<Block>({loop2, loop2_merge});
str += loop2_merge >> vector<Block>({be_block, exit});
str += loop1 >> std::vector<Block>({loop2, exit});
str += loop2 >> std::vector<Block>({loop2, loop2_merge});
str += loop2_merge >> std::vector<Block>({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<Block>({t, f});
str += split >> std::vector<Block>({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<Block>({split, exit});
str += split >> std::vector<Block>({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<Block>({back0, back1});
str += loop >> std::vector<Block>({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<Block>({cheader, merge});
str += cheader >> vector<Block>({exit, be_block});
str += loop >> std::vector<Block>({cheader, merge});
str += cheader >> std::vector<Block>({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<Block>({cont, merge});
str += cont >> vector<Block>({loop, merge});
str += loop >> std::vector<Block>({cont, merge});
str += cont >> std::vector<Block>({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<Block>({cont, merge});
str += cont >> vector<Block>({loop, exit});
str += loop >> std::vector<Block>({cont, merge});
str += cont >> std::vector<Block>({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<Block>({def, case0, case1, case2});
str += entry >> std::vector<Block>({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<Block>({inner_head, exit});
str += inner_head >> vector<Block>({inner_true, inner_false});
str += entry >> std::vector<Block>({inner_head, exit});
str += inner_head >> std::vector<Block>({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<Block>({if_true, if_merge});
str += if_head >> std::vector<Block>({if_true, if_merge});
str += if_true >> if_merge;
str += if_merge >> vector<Block>({loop, merge});
str += if_merge >> std::vector<Block>({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<Block>({latch, merge});
str += latch >> vector<Block>({loop, loop}); // This is the key
str += loop >> std::vector<Block>({latch, merge});
str += latch >> std::vector<Block>({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;

View File

@ -29,87 +29,83 @@ namespace {
using ::testing::HasSubstr;
using ::testing::MatchesRegex;
using std::pair;
using std::string;
using std::stringstream;
using ValidateData = spvtest::ValidateBase<std::pair<std::string, bool>>;
using ValidateData = spvtest::ValidateBase<pair<string, bool>>;
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
)";

View File

@ -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<bool>;
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>{Decoration(SpvDecorationArrayStride, {4}),
Decoration(SpvDecorationUniform)}));
EXPECT_THAT(
vstate_->id_decorations(id),
Eq(std::vector<Decoration>{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>{Decoration(SpvDecorationArrayStride, {4})}));
Eq(std::vector<Decoration>{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>{Decoration(SpvDecorationNonReadable, {}, 2),
Decoration(SpvDecorationOffset, {2}, 2),
Decoration(SpvDecorationBufferBlock)}));
EXPECT_THAT(
vstate_->id_decorations(struct_id),
Eq(std::vector<Decoration>{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<Decoration>{
auto expected_decorations = std::vector<Decoration>{
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>{Decoration(SpvDecorationOffset, {3}, 3)};
std::vector<Decoration>{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"

View File

@ -33,14 +33,12 @@ using ::testing::Not;
using ::testing::Values;
using ::testing::ValuesIn;
using std::string;
using ValidateKnownExtensions = spvtest::ValidateBase<string>;
using ValidateUnknownExtensions = spvtest::ValidateBase<string>;
using ValidateKnownExtensions = spvtest::ValidateBase<std::string>;
using ValidateUnknownExtensions = spvtest::ValidateBase<std::string>;
using ValidateExtensionCapabilities = spvtest::ValidateBase<bool>;
// 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<string>;
using ValidateAMDShaderBallotCapabilities = spvtest::ValidateBase<std::string>;
// 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<string> ShaderPartsForAMDShaderBallot() {
return std::vector<string>{R"(
std::vector<std::string> ShaderPartsForAMDShaderBallot() {
return std::vector<std::string>{R"(
OpCapability Shader
OpCapability Linkage
)",
R"(
R"(
OpMemoryModel Logical GLSL450
%float = OpTypeFloat 32
%uint = OpTypeInt 32 0
@ -139,8 +137,8 @@ std::vector<string> 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<string> AMDShaderBallotGroupInstructions() {
return std::vector<string>{
std::vector<std::string> AMDShaderBallotGroupInstructions() {
return std::vector<std::string>{
"%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<ExtIntoCoreCase>;
// 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));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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<spv_result_t(int)>;
using ValidateLayout =
spvtest::ValidateBase<tuple<int, tuple<string, pred_type, pred_type>>>;
using pred_type = std::function<spv_result_t(int)>;
using ValidateLayout = spvtest::ValidateBase<
std::tuple<int, std::tuple<std::string, pred_type, pred_type>>>;
// returns true if order is equal to VAL
template <int VAL, spv_result_t RET = SPV_ERROR_INVALID_LAYOUT>
@ -72,9 +62,9 @@ spv_result_t InvalidSet(int order) {
}
// SPIRV source used to test the logical layout
const vector<string>& getInstructions() {
const std::vector<std::string>& getInstructions() {
// clang-format off
static const vector<string> instructions = {
static const std::vector<std::string> 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<string> GenerateCode(string substr, int order) {
vector<string> code(getInstructions().size());
vector<string> inst(1);
partition_copy(begin(getInstructions()), end(getInstructions()), begin(code),
begin(inst), [=](const string& str) {
return string::npos == str.find(substr);
std::vector<std::string> GenerateCode(std::string substr, int order) {
std::vector<std::string> code(getInstructions().size());
std::vector<std::string> 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<string> 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<string, pred_type, pred_type> testCase;
std::tuple<std::string, pred_type, pred_type> 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<string> code = GenerateCode(instruction, order);
std::vector<std::string> code = GenerateCode(instruction, order);
stringstream ss;
copy(begin(code), end(code), ostream_iterator<string>(ss, "\n"));
std::stringstream ss;
std::copy(std::begin(code), std::end(code),
std::ostream_iterator<std::string>(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

View File

@ -26,20 +26,19 @@ namespace spvtools {
namespace val {
namespace {
using std::string;
using ::testing::HasSubstr;
using ::testing::MatchesRegex;
using ValidateLimits = spvtest::ValidateBase<bool>;
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"

View File

@ -29,11 +29,7 @@ namespace {
using ::testing::HasSubstr;
using ::testing::MatchesRegex;
using std::pair;
using std::string;
using std::stringstream;
using ValidateSSA = spvtest::ValidateBase<pair<string, bool>>;
using ValidateSSA = spvtest::ValidateBase<std::pair<std::string, bool>>;
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<string, bool> cases[] = {
std::pair<std::string, bool> cases[] = {
{"OpGetKernelNDrangeSubGroupCount", kWithNDrange},
{"OpGetKernelNDrangeMaxSubGroupSize", kWithNDrange},
{"OpGetKernelWorkGroupSize", kNoNDrange},
@ -827,17 +823,17 @@ pair<string, bool> 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

View File

@ -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};

View File

@ -27,14 +27,12 @@ namespace {
using ::testing::HasSubstr;
using ::testing::Not;
using std::string;
using ValidateTypeUnique = spvtest::ValidateBase<bool>;
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"

View File

@ -25,7 +25,6 @@ namespace spvtools {
namespace val {
namespace {
using std::string;
using ::testing::HasSubstr;
using ValidationStateTest = spvtest::ValidateBase<bool>;
@ -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());

View File

@ -20,7 +20,6 @@ namespace val {
namespace {
using ::testing::HasSubstr;
using std::make_tuple;
using ValidateVersion = spvtest::ValidateBase<
std::tuple<spv_target_env, spv_target_env, std::string, bool>>;
@ -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

View File

@ -22,13 +22,12 @@ namespace spvtools {
namespace val {
namespace {
using std::string;
using testing::HasSubstr;
using ValidateWebGPU = spvtest::ValidateBase<bool>;
TEST_F(ValidateWebGPU, OpUndefIsDisallowed) {
string spirv = R"(
std::string spirv = R"(
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450