diff --git a/README-spirv-remap.txt b/README-spirv-remap.txt index a67771c5..8e3259f8 100644 --- a/README-spirv-remap.txt +++ b/README-spirv-remap.txt @@ -72,7 +72,7 @@ public: spirvbin_t(int verbose = 0); // construct // remap an existing binary in memory - void remap(std::vector& spv, std::uint32_t opts = Options::DO_EVERYTHING); + void remap(std::vector& spv, std::uint32_t opts = DO_EVERYTHING); // Type for error/log handler functions typedef std::function errorfn_t; @@ -119,7 +119,7 @@ normal build process. REMAPPING AND OPTIMIZATION OPTIONS -------------------------------------------------------------------------------- API: - These are bits defined under spv::spirvbin_t::Options::, and can be + These are bits defined under spv::spirvbin_t::, and can be bitwise or-ed together as desired. MAP_TYPES = canonicalize type IDs diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 1cc3e6f8..65358ebf 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -573,7 +573,7 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T // so short circuit the access-chain stuff with a swizzle. std::vector swizzle; swizzle.push_back(node->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst()); - builder.accessChainPushSwizzle(swizzle, node->getLeft()->getVectorSize()); + builder.accessChainPushSwizzle(swizzle); } else { // normal case for indexing array or structure or block builder.accessChainPush(builder.makeIntConstant(index), convertGlslangToSpvType(node->getType())); @@ -615,7 +615,7 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T std::vector swizzle; for (int i = 0; i < (int)swizzleSequence.size(); ++i) swizzle.push_back(swizzleSequence[i]->getAsConstantUnion()->getConstArray()[0].getIConst()); - builder.accessChainPushSwizzle(swizzle, node->getLeft()->getVectorSize()); + builder.accessChainPushSwizzle(swizzle); } return false; default: diff --git a/SPIRV/SPVRemapper.cpp b/SPIRV/SPVRemapper.cpp index d2768071..a8b71f95 100644 --- a/SPIRV/SPVRemapper.cpp +++ b/SPIRV/SPVRemapper.cpp @@ -299,7 +299,7 @@ namespace spv { void spirvbin_t::stripDebug() { - if ((options & Options::STRIP) == 0) + if ((options & STRIP) == 0) return; // build local Id and name maps @@ -337,7 +337,7 @@ namespace spv { process( [&](spv::Op opCode, unsigned start) { // remember opcodes we want to strip later - if ((options & Options::STRIP) && isStripOp(opCode)) + if ((options & STRIP) && isStripOp(opCode)) stripInst(start); if (opCode == spv::Op::OpName) { diff --git a/SPIRV/SPVRemapper.h b/SPIRV/SPVRemapper.h index edaa7dfd..71ca7191 100644 --- a/SPIRV/SPVRemapper.h +++ b/SPIRV/SPVRemapper.h @@ -38,6 +38,7 @@ #include #include +#include namespace spv { @@ -112,7 +113,7 @@ public: spirvbin_t(int verbose = 0) : entryPoint(spv::NoResult), largestNewId(0), verbose(verbose) { } // remap on an existing binary in memory - void remap(std::vector& spv, std::uint32_t opts = Options::DO_EVERYTHING); + void remap(std::vector& spv, std::uint32_t opts = DO_EVERYTHING); // Type for error/log handler functions typedef std::function errorfn_t; @@ -131,7 +132,7 @@ private: typedef std::unordered_map idmap_t; typedef std::unordered_set idset_t; - void remap(std::uint32_t opts = Options::DO_EVERYTHING); + void remap(std::uint32_t opts = DO_EVERYTHING); // Map of names to IDs typedef std::unordered_map namemap_t; diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index b94c0ff9..fe10b2d2 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -301,7 +301,7 @@ Id Builder::makeSampler(Id sampledType, Dim dim, samplerContent content, bool ar type = groupedTypes[OpTypeSampler][t]; if (type->getIdOperand(0) == sampledType && type->getImmediateOperand(1) == (unsigned int)dim && - type->getImmediateOperand(2) == content && + type->getImmediateOperand(2) == (unsigned int)content && type->getImmediateOperand(3) == (arrayed ? 1u : 0u) && type->getImmediateOperand(4) == ( shadow ? 1u : 0u) && type->getImmediateOperand(5) == ( ms ? 1u : 0u)) @@ -1842,7 +1842,7 @@ void Builder::clearAccessChain() } // Comments in header -void Builder::accessChainPushSwizzle(std::vector& swizzle, int width) +void Builder::accessChainPushSwizzle(std::vector& swizzle) { // if needed, propagate the swizzle for the current access chain if (accessChain.swizzle.size()) { diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h index c46c361a..b500c1fe 100644 --- a/SPIRV/SpvBuilder.h +++ b/SPIRV/SpvBuilder.h @@ -101,7 +101,7 @@ public: Id makeMatrixType(Id component, int cols, int rows); Id makeArrayType(Id element, unsigned size); Id makeFunctionType(Id returnType, std::vector& paramTypes); - enum samplerContent : unsigned { + enum samplerContent { samplerContentTexture, samplerContentImage, samplerContentTextureFilter @@ -470,7 +470,7 @@ public: } // push new swizzle onto the end of any existing swizzle, merging into a single swizzle - void accessChainPushSwizzle(std::vector& swizzle, int width); + void accessChainPushSwizzle(std::vector& swizzle); // push a variable component selection onto the access chain; supporting only one, so unsided void accessChainPushComponent(Id component) { accessChain.component = component; } diff --git a/StandAlone/spirv-remap.cpp b/StandAlone/spirv-remap.cpp index 444403b3..b3359a62 100644 --- a/StandAlone/spirv-remap.cpp +++ b/StandAlone/spirv-remap.cpp @@ -181,7 +181,7 @@ namespace { usage(argv[0]); verbosity = 0; - options = spv::spirvbin_t::Options::NONE; + options = spv::spirvbin_t::NONE; // Parse command line. // boost::program_options would be quite a bit nicer, but we don't want to @@ -228,14 +228,14 @@ namespace { inputFile.push_back(argv[a]); } else if (arg == "--do-everything") { ++a; - options = options | spv::spirvbin_t::Options::DO_EVERYTHING; + options = options | spv::spirvbin_t::DO_EVERYTHING; } else if (arg == "--strip-all" || arg == "-s") { ++a; - options = options | spv::spirvbin_t::Options::STRIP; + options = options | spv::spirvbin_t::STRIP; } else if (arg == "--strip") { ++a; if (strncmp(argv[a], "all", 3) == 0) { - options = options | spv::spirvbin_t::Options::STRIP; + options = options | spv::spirvbin_t::STRIP; ++a; } } else if (arg == "--dce") { @@ -243,16 +243,16 @@ namespace { ++a; for (const char* c = argv[a]; *c; ++c) { if (strncmp(c, "all", 3) == 0) { - options = (options | spv::spirvbin_t::Options::DCE_ALL); + options = (options | spv::spirvbin_t::DCE_ALL); c += 3; } else if (strncmp(c, "*", 1) == 0) { - options = (options | spv::spirvbin_t::Options::DCE_ALL); + options = (options | spv::spirvbin_t::DCE_ALL); c += 1; } else if (strncmp(c, "funcs", 5) == 0) { - options = (options | spv::spirvbin_t::Options::DCE_FUNCS); + options = (options | spv::spirvbin_t::DCE_FUNCS); c += 5; } else if (strncmp(c, "types", 5) == 0) { - options = (options | spv::spirvbin_t::Options::DCE_TYPES); + options = (options | spv::spirvbin_t::DCE_TYPES); c += 5; } } @@ -262,19 +262,19 @@ namespace { ++a; for (const char* c = argv[a]; *c; ++c) { if (strncmp(c, "all", 3) == 0) { - options = (options | spv::spirvbin_t::Options::MAP_ALL); + options = (options | spv::spirvbin_t::MAP_ALL); c += 3; } else if (strncmp(c, "*", 1) == 0) { - options = (options | spv::spirvbin_t::Options::MAP_ALL); + options = (options | spv::spirvbin_t::MAP_ALL); c += 1; } else if (strncmp(c, "types", 5) == 0) { - options = (options | spv::spirvbin_t::Options::MAP_TYPES); + options = (options | spv::spirvbin_t::MAP_TYPES); c += 5; } else if (strncmp(c, "names", 5) == 0) { - options = (options | spv::spirvbin_t::Options::MAP_NAMES); + options = (options | spv::spirvbin_t::MAP_NAMES); c += 5; } else if (strncmp(c, "funcs", 5) == 0) { - options = (options | spv::spirvbin_t::Options::MAP_FUNCS); + options = (options | spv::spirvbin_t::MAP_FUNCS); c += 5; } } @@ -283,13 +283,13 @@ namespace { ++a; for (const char* c = argv[a]; *c; ++c) { if (strncmp(c, "all", 3) == 0) { - options = (options | spv::spirvbin_t::Options::OPT_ALL); + options = (options | spv::spirvbin_t::OPT_ALL); c += 3; } else if (strncmp(c, "*", 1) == 0) { - options = (options | spv::spirvbin_t::Options::OPT_ALL); + options = (options | spv::spirvbin_t::OPT_ALL); c += 1; } else if (strncmp(c, "loadstore", 9) == 0) { - options = (options | spv::spirvbin_t::Options::OPT_LOADSTORE); + options = (options | spv::spirvbin_t::OPT_LOADSTORE); c += 9; } }