From 236eb0d32580b79554f5edd7215c4c244eaa133a Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Thu, 13 Dec 2018 12:06:12 -0700 Subject: [PATCH] GLSL/SPV: XFB: No streams on types, but support them on built-in blocks. From internal Khronos discussions, work, and testing. --- SPIRV/GlslangToSpv.cpp | 4 ---- Test/baseResults/spv.150.geom.out | 3 --- Test/baseResults/spv.420.geom.out | 1 - glslang/MachineIndependent/ParseHelper.cpp | 14 ++++++++++++-- 4 files changed, 12 insertions(+), 10 deletions(-) mode change 100644 => 100755 glslang/MachineIndependent/ParseHelper.cpp diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index ef3e9de77..cdf7154cc 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -3279,10 +3279,6 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type, // Decorate the structure builder.addDecoration(spvType, TranslateLayoutDecoration(type, qualifier.layoutMatrix)); builder.addDecoration(spvType, TranslateBlockDecoration(type, glslangIntermediate->usingStorageBuffer())); - if (type.getQualifier().hasStream() && glslangIntermediate->isMultiStream()) { - builder.addCapability(spv::CapabilityGeometryStreams); - builder.addDecoration(spvType, spv::DecorationStream, type.getQualifier().layoutStream); - } } // Turn the expression forming the array size into an id. diff --git a/Test/baseResults/spv.150.geom.out b/Test/baseResults/spv.150.geom.out index f75979383..19bd72530 100644 --- a/Test/baseResults/spv.150.geom.out +++ b/Test/baseResults/spv.150.geom.out @@ -38,14 +38,12 @@ spv.150.geom MemberName 68(toFragment) 0 "color" Name 70 "toF" Decorate 8(fromVertex) Block - Decorate 8(fromVertex) Stream 3 Decorate 10 Stream 3 Decorate 13(fromVertex) Block MemberDecorate 27(gl_PerVertex) 0 BuiltIn Position MemberDecorate 27(gl_PerVertex) 1 BuiltIn PointSize MemberDecorate 27(gl_PerVertex) 2 BuiltIn ClipDistance Decorate 27(gl_PerVertex) Block - Decorate 27(gl_PerVertex) Stream 0 Decorate 29 Stream 0 MemberDecorate 30(gl_PerVertex) 0 BuiltIn Position MemberDecorate 30(gl_PerVertex) 1 BuiltIn PointSize @@ -57,7 +55,6 @@ spv.150.geom Decorate 51(gl_Layer) Stream 0 Decorate 51(gl_Layer) BuiltIn Layer Decorate 68(toFragment) Block - Decorate 68(toFragment) Stream 3 Decorate 70(toF) Stream 3 2: TypeVoid 3: TypeFunction 2 diff --git a/Test/baseResults/spv.420.geom.out b/Test/baseResults/spv.420.geom.out index a8e80e7bb..fa91dd81d 100644 --- a/Test/baseResults/spv.420.geom.out +++ b/Test/baseResults/spv.420.geom.out @@ -36,7 +36,6 @@ spv.420.geom Decorate 9(gl_PerVertex) Block MemberDecorate 21(gl_PerVertex) 0 BuiltIn PointSize Decorate 21(gl_PerVertex) Block - Decorate 21(gl_PerVertex) Stream 0 Decorate 23 Stream 0 Decorate 28(gl_ViewportIndex) Stream 0 Decorate 28(gl_ViewportIndex) BuiltIn ViewportIndex diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp old mode 100644 new mode 100755 index b32315b37..d719e175c --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -4059,6 +4059,8 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT if (currentBlockQualifier.storage == EvqVaryingOut && globalOutputDefaults.hasXfbBuffer()) { if (!currentBlockQualifier.hasXfbBuffer()) currentBlockQualifier.layoutXfbBuffer = globalOutputDefaults.layoutXfbBuffer; + if (!currentBlockQualifier.hasStream()) + currentBlockQualifier.layoutStream = globalOutputDefaults.layoutStream; fixXfbOffsets(currentBlockQualifier, newTypeList); } @@ -4141,6 +4143,9 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT if (newType.getQualifier().hasXfbBuffer() && newType.getQualifier().layoutXfbBuffer != currentBlockQualifier.layoutXfbBuffer) error(memberLoc, "member cannot contradict block (or what block inherited from global)", "xfb_buffer", ""); + if (newType.getQualifier().hasStream() && + newType.getQualifier().layoutStream != currentBlockQualifier.layoutStream) + error(memberLoc, "member cannot contradict block (or what block inherited from global)", "xfb_stream", ""); oldType.getQualifier().centroid = newType.getQualifier().centroid; oldType.getQualifier().sample = newType.getQualifier().sample; oldType.getQualifier().invariant = newType.getQualifier().invariant; @@ -4152,8 +4157,8 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT oldType.getQualifier().layoutXfbBuffer = newType.getQualifier().layoutXfbBuffer; oldType.getQualifier().layoutXfbStride = newType.getQualifier().layoutXfbStride; if (oldType.getQualifier().layoutXfbOffset != TQualifier::layoutXfbBufferEnd) { - // if any member as an xfb_offset, then the block's xfb_buffer inherents current xfb_buffer, - // and for xfb processing, the member needs it as well, along with xfb_stride + // If any member has an xfb_offset, then the block's xfb_buffer inherents current xfb_buffer, + // and for xfb processing, the member needs it as well, along with xfb_stride. type.getQualifier().layoutXfbBuffer = currentBlockQualifier.layoutXfbBuffer; oldType.getQualifier().layoutXfbBuffer = currentBlockQualifier.layoutXfbBuffer; } @@ -4178,6 +4183,11 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT } } + if (spvVersion.vulkan > 0) { + // ...then streams apply to built-in blocks, instead of them being only on stream 0 + type.getQualifier().layoutStream = currentBlockQualifier.layoutStream; + } + if (numOriginalMembersFound < newTypeList.size()) error(loc, "block redeclaration has extra members", blockName.c_str(), ""); if (type.isArray() != (arraySizes != nullptr) ||