HLSL: Fix #1064: Don't include empty structures on OpEntryPoint
authorJohn Kessenich <cepheus@frii.com>
Tue, 19 Sep 2017 17:09:59 +0000 (11:09 -0600)
committerJohn Kessenich <cepheus@frii.com>
Tue, 19 Sep 2017 17:23:58 +0000 (11:23 -0600)
SPIRV/GlslangToSpv.cpp
Test/baseResults/hlsl.emptystructreturn.frag.out
Test/baseResults/hlsl.emptystructreturn.vert.out

index 40f7508e4766009b1e815ff1afe1c46865f7e410..9dec286cd07f8b691499f165fae0db2db39cdaf5 100755 (executable)
@@ -1081,8 +1081,10 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
     // Include all "static use" and "linkage only" interface variables on the OpEntryPoint instruction
     if (builder.isPointer(id)) {
         spv::StorageClass sc = builder.getStorageClass(id);
-        if (sc == spv::StorageClassInput || sc == spv::StorageClassOutput)
-            iOSet.insert(id);
+        if (sc == spv::StorageClassInput || sc == spv::StorageClassOutput) {
+            if (!symbol->getType().isStruct() || symbol->getType().getStruct()->size() > 0)
+                iOSet.insert(id);
+        }
     }
 
     // Only process non-linkage-only nodes for generating actual static uses
index 5440045db53bc40199f77878ab0f7e45c3f67a4d..5913180497f8ae9c34c9064e174c5993f143d708 100644 (file)
@@ -56,7 +56,7 @@ gl_FragCoord origin is upper left
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 20 23
+                              EntryPoint Fragment 4  "main"
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
index c8cea5d1f2d019bfb652d52bb73a662769a6b9ee..f93bb63d2382f582511d100d4e41fcc6cc11e820 100644 (file)
@@ -54,7 +54,7 @@ Shader version: 500
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Vertex 4  "main" 20 23
+                              EntryPoint Vertex 4  "main"
                               Source HLSL 500
                               Name 4  "main"
                               Name 6  "vs_in"