From 5f77d864f31ecbb419240bcc910f80176b1a57f0 Mon Sep 17 00:00:00 2001 From: John Kessenich <cepheus@frii.com> Date: Tue, 19 Sep 2017 11:09:59 -0600 Subject: [PATCH] HLSL: Fix #1064: Don't include empty structures on OpEntryPoint --- SPIRV/GlslangToSpv.cpp | 6 ++++-- Test/baseResults/hlsl.emptystructreturn.frag.out | 2 +- Test/baseResults/hlsl.emptystructreturn.vert.out | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 40f7508e4..9dec286cd 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -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 diff --git a/Test/baseResults/hlsl.emptystructreturn.frag.out b/Test/baseResults/hlsl.emptystructreturn.frag.out index 5440045db..591318049 100644 --- a/Test/baseResults/hlsl.emptystructreturn.frag.out +++ b/Test/baseResults/hlsl.emptystructreturn.frag.out @@ -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" diff --git a/Test/baseResults/hlsl.emptystructreturn.vert.out b/Test/baseResults/hlsl.emptystructreturn.vert.out index c8cea5d1f..f93bb63d2 100644 --- a/Test/baseResults/hlsl.emptystructreturn.vert.out +++ b/Test/baseResults/hlsl.emptystructreturn.vert.out @@ -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" -- GitLab