Update SPIRV-Tools to 2020.1 / SPIRV-Cross to 65aa0c3 (#2121)

This commit is contained in:
Ben Doherty
2020-03-10 15:32:41 -07:00
committed by GitHub
parent a2818037b3
commit a2c6c34739
1747 changed files with 265212 additions and 44504 deletions
+42 -10
View File
@@ -14,9 +14,8 @@
#include "source/val/function.h"
#include <cassert>
#include <algorithm>
#include <cassert>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
@@ -86,6 +85,12 @@ spv_result_t Function::RegisterLoopMerge(uint32_t merge_id,
continue_construct.set_corresponding_constructs({&loop_construct});
loop_construct.set_corresponding_constructs({&continue_construct});
merge_block_header_[&merge_block] = current_block_;
if (continue_target_headers_.find(&continue_target_block) ==
continue_target_headers_.end()) {
continue_target_headers_[&continue_target_block] = {current_block_};
} else {
continue_target_headers_[&continue_target_block].push_back(current_block_);
}
return SPV_SUCCESS;
}
@@ -93,7 +98,7 @@ spv_result_t Function::RegisterLoopMerge(uint32_t merge_id,
spv_result_t Function::RegisterSelectionMerge(uint32_t merge_id) {
RegisterBlock(merge_id, false);
BasicBlock& merge_block = blocks_.at(merge_id);
current_block_->set_type(kBlockTypeHeader);
current_block_->set_type(kBlockTypeSelection);
merge_block.set_type(kBlockTypeMerge);
merge_block_header_[&merge_block] = current_block_;
@@ -311,13 +316,10 @@ int Function::GetBlockDepth(BasicBlock* bb) {
if (!bb_dom || bb == bb_dom) {
// This block has no dominator, so it's at depth 0.
block_depth_[bb] = 0;
} else if (bb->is_type(kBlockTypeMerge)) {
// If this is a merge block, its depth is equal to the block before
// branching.
BasicBlock* header = merge_block_header_[bb];
assert(header);
block_depth_[bb] = GetBlockDepth(header);
} else if (bb->is_type(kBlockTypeContinue)) {
// This rule must precede the rule for merge blocks in order to set up
// depths correctly. If a block is both a merge and continue then the merge
// is nested within the continue's loop (or the graph is incorrect).
// The depth of the continue block entry point is 1 + loop header depth.
Construct* continue_construct =
entry_block_to_construct_[std::make_pair(bb, ConstructType::kContinue)];
@@ -335,7 +337,13 @@ int Function::GetBlockDepth(BasicBlock* bb) {
} else {
block_depth_[bb] = 1 + GetBlockDepth(loop_header);
}
} else if (bb_dom->is_type(kBlockTypeHeader) ||
} else if (bb->is_type(kBlockTypeMerge)) {
// If this is a merge block, its depth is equal to the block before
// branching.
BasicBlock* header = merge_block_header_[bb];
assert(header);
block_depth_[bb] = GetBlockDepth(header);
} else if (bb_dom->is_type(kBlockTypeSelection) ||
bb_dom->is_type(kBlockTypeLoop)) {
// The dominator of the given block is a header block. So, the nesting
// depth of this block is: 1 + nesting depth of the header.
@@ -383,5 +391,29 @@ bool Function::IsCompatibleWithExecutionModel(SpvExecutionModel model,
return return_value;
}
bool Function::CheckLimitations(const ValidationState_t& _,
const Function* entry_point,
std::string* reason) const {
bool return_value = true;
std::stringstream ss_reason;
for (const auto& is_compatible : limitations_) {
std::string message;
if (!is_compatible(_, entry_point, &message)) {
if (!reason) return false;
return_value = false;
if (!message.empty()) {
ss_reason << message << "\n";
}
}
}
if (!return_value && reason) {
*reason = ss_reason.str();
}
return return_value;
}
} // namespace val
} // namespace spvtools