From: John Kessenich Date: Fri, 4 Mar 2016 05:29:11 +0000 (-0700) Subject: SPV: Use heuristic to avoid geometry multi-streams when possible. X-Git-Tag: upstream/0.1~255 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f2d8a5c53fda69a7e19defbda7964f380da54ad1;p=platform%2Fupstream%2Fglslang.git SPV: Use heuristic to avoid geometry multi-streams when possible. --- diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 212d45b..5eb097b 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -1803,7 +1803,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty // Decorate the structure addDecoration(spvType, TranslateLayoutDecoration(type, qualifier.layoutMatrix)); addDecoration(spvType, TranslateBlockDecoration(type)); - if (type.getQualifier().hasStream()) { + if (type.getQualifier().hasStream() && glslangIntermediate->isMultiStream()) { builder.addCapability(spv::CapabilityGeometryStreams); builder.addDecoration(spvType, spv::DecorationStream, type.getQualifier().layoutStream); } @@ -3599,7 +3599,7 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol } addDecoration(id, TranslateInvariantDecoration(symbol->getType().getQualifier())); - if (symbol->getQualifier().hasStream()) { + if (symbol->getQualifier().hasStream() && glslangIntermediate->isMultiStream()) { builder.addCapability(spv::CapabilityGeometryStreams); builder.addDecoration(id, spv::DecorationStream, symbol->getQualifier().layoutStream); } diff --git a/Test/baseResults/spv.330.geom.out b/Test/baseResults/spv.330.geom.out index 55ee35c..3077769 100755 --- a/Test/baseResults/spv.330.geom.out +++ b/Test/baseResults/spv.330.geom.out @@ -9,7 +9,6 @@ Linked geometry stage: Capability Geometry Capability ClipDistance - Capability GeometryStreams 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Geometry 4 "main" 13 20 @@ -31,8 +30,6 @@ Linked geometry stage: MemberDecorate 11(gl_PerVertex) 0 BuiltIn Position MemberDecorate 11(gl_PerVertex) 1 BuiltIn ClipDistance Decorate 11(gl_PerVertex) Block - Decorate 11(gl_PerVertex) Stream 0 - Decorate 13 Stream 0 MemberDecorate 16(gl_PerVertex) 0 BuiltIn Position MemberDecorate 16(gl_PerVertex) 1 BuiltIn ClipDistance Decorate 16(gl_PerVertex) Block diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index b97c96c..03370b8 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -1524,6 +1524,11 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan } break; + case EOpEmitStreamVertex: + case EOpEndStreamPrimitive: + intermediate.setMultiStream(); + break; + default: break; } @@ -4050,6 +4055,8 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi if (id == "stream") { requireProfile(loc, ~EEsProfile, "selecting output stream"); publicType.qualifier.layoutStream = value; + if (value > 0) + intermediate.setMultiStream(); return; } break; diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h index 60bf68e..9926747 100644 --- a/glslang/MachineIndependent/localintermediate.h +++ b/glslang/MachineIndependent/localintermediate.h @@ -128,7 +128,8 @@ public: numMains(0), numErrors(0), numPushConstants(0), recursive(false), invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet), inputPrimitive(ElgNone), outputPrimitive(ElgNone), pixelCenterInteger(false), originUpperLeft(false), - vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false), depthLayout(EldNone), depthReplacing(false), blendEquations(0), xfbMode(false) + vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false), depthLayout(EldNone), depthReplacing(false), blendEquations(0), + multiStream(false), xfbMode(false) { localSize[0] = 1; localSize[1] = 1; @@ -271,6 +272,8 @@ public: void setXfbMode() { xfbMode = true; } bool getXfbMode() const { return xfbMode; } + void setMultiStream() { multiStream = true; } + bool isMultiStream() const { return multiStream; } bool setOutputPrimitive(TLayoutGeometry p) { if (outputPrimitive != ElgNone) @@ -361,6 +364,7 @@ protected: bool depthReplacing; int blendEquations; // an 'or'ing of masks of shifts of TBlendEquationShift bool xfbMode; + bool multiStream; typedef std::list TGraph; TGraph callGraph;