spirvbin_t(int verbose = 0); // construct
// remap an existing binary in memory
- void remap(std::vector<std::uint32_t>& spv, std::uint32_t opts = Options::DO_EVERYTHING);
+ void remap(std::vector<std::uint32_t>& spv, std::uint32_t opts = DO_EVERYTHING);
// Type for error/log handler functions
typedef std::function<void(const std::string&)> errorfn_t;
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
// so short circuit the access-chain stuff with a swizzle.\r
std::vector<unsigned> swizzle;\r
swizzle.push_back(node->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst());\r
- builder.accessChainPushSwizzle(swizzle, node->getLeft()->getVectorSize());\r
+ builder.accessChainPushSwizzle(swizzle);\r
} else {\r
// normal case for indexing array or structure or block\r
builder.accessChainPush(builder.makeIntConstant(index), convertGlslangToSpvType(node->getType()));\r
std::vector<unsigned> swizzle;\r
for (int i = 0; i < (int)swizzleSequence.size(); ++i)\r
swizzle.push_back(swizzleSequence[i]->getAsConstantUnion()->getConstArray()[0].getIConst());\r
- builder.accessChainPushSwizzle(swizzle, node->getLeft()->getVectorSize());\r
+ builder.accessChainPushSwizzle(swizzle);\r
}\r
return false;\r
default:\r
\r
void spirvbin_t::stripDebug()\r
{\r
- if ((options & Options::STRIP) == 0)\r
+ if ((options & STRIP) == 0)\r
return;\r
\r
// build local Id and name maps\r
process(\r
[&](spv::Op opCode, unsigned start) {\r
// remember opcodes we want to strip later\r
- if ((options & Options::STRIP) && isStripOp(opCode))\r
+ if ((options & STRIP) && isStripOp(opCode))\r
stripInst(start);\r
\r
if (opCode == spv::Op::OpName) {\r
\r
#include <string>\r
#include <vector>\r
+#include <stdlib.h>\r
\r
namespace spv {\r
\r
spirvbin_t(int verbose = 0) : entryPoint(spv::NoResult), largestNewId(0), verbose(verbose) { }\r
\r
// remap on an existing binary in memory\r
- void remap(std::vector<std::uint32_t>& spv, std::uint32_t opts = Options::DO_EVERYTHING);\r
+ void remap(std::vector<std::uint32_t>& spv, std::uint32_t opts = DO_EVERYTHING);\r
\r
// Type for error/log handler functions\r
typedef std::function<void(const std::string&)> errorfn_t;\r
typedef std::unordered_map<spv::Id, spv::Id> idmap_t;\r
typedef std::unordered_set<spv::Id> idset_t;\r
\r
- void remap(std::uint32_t opts = Options::DO_EVERYTHING);\r
+ void remap(std::uint32_t opts = DO_EVERYTHING);\r
\r
// Map of names to IDs\r
typedef std::unordered_map<std::string, spv::Id> namemap_t;\r
type = groupedTypes[OpTypeSampler][t];\r
if (type->getIdOperand(0) == sampledType &&\r
type->getImmediateOperand(1) == (unsigned int)dim &&\r
- type->getImmediateOperand(2) == content &&\r
+ type->getImmediateOperand(2) == (unsigned int)content &&\r
type->getImmediateOperand(3) == (arrayed ? 1u : 0u) &&\r
type->getImmediateOperand(4) == ( shadow ? 1u : 0u) &&\r
type->getImmediateOperand(5) == ( ms ? 1u : 0u))\r
}\r
\r
// Comments in header\r
-void Builder::accessChainPushSwizzle(std::vector<unsigned>& swizzle, int width)\r
+void Builder::accessChainPushSwizzle(std::vector<unsigned>& swizzle)\r
{\r
// if needed, propagate the swizzle for the current access chain\r
if (accessChain.swizzle.size()) {\r
Id makeMatrixType(Id component, int cols, int rows);\r
Id makeArrayType(Id element, unsigned size);\r
Id makeFunctionType(Id returnType, std::vector<Id>& paramTypes);\r
- enum samplerContent : unsigned {\r
+ enum samplerContent {\r
samplerContentTexture,\r
samplerContentImage,\r
samplerContentTextureFilter\r
}\r
\r
// push new swizzle onto the end of any existing swizzle, merging into a single swizzle\r
- void accessChainPushSwizzle(std::vector<unsigned>& swizzle, int width);\r
+ void accessChainPushSwizzle(std::vector<unsigned>& swizzle);\r
\r
// push a variable component selection onto the access chain; supporting only one, so unsided\r
void accessChainPushComponent(Id component) { accessChain.component = component; }\r
usage(argv[0]);\r
\r
verbosity = 0;\r
- options = spv::spirvbin_t::Options::NONE;\r
+ options = spv::spirvbin_t::NONE;\r
\r
// Parse command line.\r
// boost::program_options would be quite a bit nicer, but we don't want to\r
inputFile.push_back(argv[a]);\r
} else if (arg == "--do-everything") {\r
++a;\r
- options = options | spv::spirvbin_t::Options::DO_EVERYTHING;\r
+ options = options | spv::spirvbin_t::DO_EVERYTHING;\r
} else if (arg == "--strip-all" || arg == "-s") {\r
++a;\r
- options = options | spv::spirvbin_t::Options::STRIP;\r
+ options = options | spv::spirvbin_t::STRIP;\r
} else if (arg == "--strip") {\r
++a;\r
if (strncmp(argv[a], "all", 3) == 0) {\r
- options = options | spv::spirvbin_t::Options::STRIP;\r
+ options = options | spv::spirvbin_t::STRIP;\r
++a;\r
}\r
} else if (arg == "--dce") {\r
++a;\r
for (const char* c = argv[a]; *c; ++c) {\r
if (strncmp(c, "all", 3) == 0) {\r
- options = (options | spv::spirvbin_t::Options::DCE_ALL);\r
+ options = (options | spv::spirvbin_t::DCE_ALL);\r
c += 3;\r
} else if (strncmp(c, "*", 1) == 0) {\r
- options = (options | spv::spirvbin_t::Options::DCE_ALL);\r
+ options = (options | spv::spirvbin_t::DCE_ALL);\r
c += 1;\r
} else if (strncmp(c, "funcs", 5) == 0) {\r
- options = (options | spv::spirvbin_t::Options::DCE_FUNCS);\r
+ options = (options | spv::spirvbin_t::DCE_FUNCS);\r
c += 5;\r
} else if (strncmp(c, "types", 5) == 0) {\r
- options = (options | spv::spirvbin_t::Options::DCE_TYPES);\r
+ options = (options | spv::spirvbin_t::DCE_TYPES);\r
c += 5;\r
}\r
}\r
++a;\r
for (const char* c = argv[a]; *c; ++c) {\r
if (strncmp(c, "all", 3) == 0) {\r
- options = (options | spv::spirvbin_t::Options::MAP_ALL);\r
+ options = (options | spv::spirvbin_t::MAP_ALL);\r
c += 3;\r
} else if (strncmp(c, "*", 1) == 0) {\r
- options = (options | spv::spirvbin_t::Options::MAP_ALL);\r
+ options = (options | spv::spirvbin_t::MAP_ALL);\r
c += 1;\r
} else if (strncmp(c, "types", 5) == 0) {\r
- options = (options | spv::spirvbin_t::Options::MAP_TYPES);\r
+ options = (options | spv::spirvbin_t::MAP_TYPES);\r
c += 5;\r
} else if (strncmp(c, "names", 5) == 0) {\r
- options = (options | spv::spirvbin_t::Options::MAP_NAMES);\r
+ options = (options | spv::spirvbin_t::MAP_NAMES);\r
c += 5;\r
} else if (strncmp(c, "funcs", 5) == 0) {\r
- options = (options | spv::spirvbin_t::Options::MAP_FUNCS);\r
+ options = (options | spv::spirvbin_t::MAP_FUNCS);\r
c += 5;\r
}\r
}\r
++a;\r
for (const char* c = argv[a]; *c; ++c) {\r
if (strncmp(c, "all", 3) == 0) {\r
- options = (options | spv::spirvbin_t::Options::OPT_ALL);\r
+ options = (options | spv::spirvbin_t::OPT_ALL);\r
c += 3;\r
} else if (strncmp(c, "*", 1) == 0) {\r
- options = (options | spv::spirvbin_t::Options::OPT_ALL);\r
+ options = (options | spv::spirvbin_t::OPT_ALL);\r
c += 1;\r
} else if (strncmp(c, "loadstore", 9) == 0) {\r
- options = (options | spv::spirvbin_t::Options::OPT_LOADSTORE);\r
+ options = (options | spv::spirvbin_t::OPT_LOADSTORE);\r
c += 9;\r
}\r
}\r