Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Headers.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJeff Bolz <jbolz@nvidia.com>2019-05-17 00:15:54 +0300
committerJeff Bolz <jbolz@nvidia.com>2019-05-17 00:15:54 +0300
commit9f50e659a8215b2a6dd5d23a02b85828581a9133 (patch)
treea931e8cb053cb55ec6f15e35503e297495b34744 /tools
parent4b0985f29277a81f5ce88feb0502cc44d6d5e7c3 (diff)
Update HasResultAndType code generation to skip duplicate enum values. There weren't any until SPIR-V 1.4 release, now there are two.
Diffstat (limited to 'tools')
-rw-r--r--tools/buildHeaders/header.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/buildHeaders/header.cpp b/tools/buildHeaders/header.cpp
index f579eaf..e1e05d0 100644
--- a/tools/buildHeaders/header.cpp
+++ b/tools/buildHeaders/header.cpp
@@ -42,6 +42,7 @@
#include <cctype>
#include <vector>
#include <utility>
+#include <set>
#include "jsoncpp/dist/json/json.h"
@@ -503,6 +504,8 @@ namespace {
{
const Json::Value& enums = spvRoot["spv"]["enum"];
+ std::set<unsigned> seenValues;
+
for (auto opClass = enums.begin(); opClass != enums.end(); ++opClass) {
const auto opName = (*opClass)["Name"].asString();
if (opName != "Op") {
@@ -516,6 +519,14 @@ namespace {
out << " default: /* unknown opcode */ break;" << std::endl;
for (auto& inst : spv::InstructionDesc) {
+
+ // Filter out duplicate enum values, which would break the switch statement.
+ // These are probably just extension enums promoted to core.
+ if (seenValues.find(inst.value) != seenValues.end()) {
+ continue;
+ }
+ seenValues.insert(inst.value);
+
std::string name = inst.name;
out << " case " << fmtEnumUse("Op", name) << ": *hasResult = " << (inst.hasResult() ? "true" : "false") << "; *hasResultType = " << (inst.hasType() ? "true" : "false") << "; break;" << std::endl;
}