glslang portability: Resolve OSX errors, some other OS warnings.
authorJohn Kessenich <cepheus@frii.com>
Wed, 10 Jun 2015 22:05:48 +0000 (22:05 +0000)
committerJohn Kessenich <cepheus@frii.com>
Wed, 10 Jun 2015 22:05:48 +0000 (22:05 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31468 e7fa87d3-cd2b-0410-9028-fcbf551c1848

README-spirv-remap.txt
SPIRV/GlslangToSpv.cpp
SPIRV/SPVRemapper.cpp
SPIRV/SPVRemapper.h
SPIRV/SpvBuilder.cpp
SPIRV/SpvBuilder.h
StandAlone/spirv-remap.cpp

index a67771c..8e3259f 100644 (file)
@@ -72,7 +72,7 @@ public:
    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;
@@ -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
index 1cc3e6f..65358eb 100644 (file)
@@ -573,7 +573,7 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
                 // 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
@@ -615,7 +615,7 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
             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
index d276807..a8b71f9 100644 (file)
@@ -299,7 +299,7 @@ namespace spv {
 \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
@@ -337,7 +337,7 @@ namespace spv {
         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
index edaa7df..71ca719 100644 (file)
@@ -38,6 +38,7 @@
 \r
 #include <string>\r
 #include <vector>\r
+#include <stdlib.h>\r
 \r
 namespace spv {\r
 \r
@@ -112,7 +113,7 @@ public:
    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
@@ -131,7 +132,7 @@ private:
    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
index b94c0ff..fe10b2d 100644 (file)
@@ -301,7 +301,7 @@ Id Builder::makeSampler(Id sampledType, Dim dim, samplerContent content, bool ar
         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
@@ -1842,7 +1842,7 @@ void Builder::clearAccessChain()
 }\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
index c46c361..b500c1f 100644 (file)
@@ -101,7 +101,7 @@ public:
     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
@@ -470,7 +470,7 @@ public:
     }\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
index 444403b..b3359a6 100644 (file)
@@ -181,7 +181,7 @@ namespace {
             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
@@ -228,14 +228,14 @@ namespace {
                     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
@@ -243,16 +243,16 @@ namespace {
                 ++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
@@ -262,19 +262,19 @@ namespace {
                 ++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
@@ -283,13 +283,13 @@ namespace {
                 ++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