remapper: do not eliminate interface variables in dce by default
authorGregF <greg@LunarG.com>
Fri, 3 Jun 2016 15:53:47 +0000 (09:53 -0600)
committerGregF <greg@LunarG.com>
Fri, 3 Jun 2016 15:57:57 +0000 (09:57 -0600)
this is done by counting op_entrypoint as a use/def

SPIRV/SPVRemapper.cpp

index 35dda17b7b8f2f62d76acb568bac968efcc47e6b..1bbd58924f96f70333d42b6c73e7e9017f8bf6a3 100755 (executable)
@@ -926,8 +926,17 @@ namespace spv {
         // Count function variable use
         process(
             [&](spv::Op opCode, unsigned start) {
-                if (opCode == spv::OpVariable) { ++varUseCount[asId(start+2)]; return true; }
-                return false;
+                if (opCode == spv::OpVariable) {
+                    ++varUseCount[asId(start+2)];
+                    return true;
+                } else if (opCode == spv::OpEntryPoint) {
+                    const int wordCount = asWordCount(start);
+                    for (int i = 4; i < wordCount; i++) {
+                        ++varUseCount[asId(start+i)];
+                    }
+                    return true;
+                } else
+                    return false;
             },
 
             [&](spv::Id& id) { if (varUseCount[id]) ++varUseCount[id]; }