From 16c1196ea6bae60be684f6c37f97348666ceaf2f Mon Sep 17 00:00:00 2001 From: Ethan Nicholas Date: Fri, 16 Mar 2018 12:20:54 -0400 Subject: [PATCH] fix SkSL SPIR-V geometry shaders' entry point declaration Bug: skia: Change-Id: I5cd5a35fe1a554b127548a7809c106de70df0be7 Reviewed-on: https://skia-review.googlesource.com/114785 Reviewed-by: Greg Daniel Commit-Queue: Ethan Nicholas --- src/sksl/SkSLCompiler.h | 1 + src/sksl/SkSLSPIRVCodeGenerator.cpp | 13 ++++++++----- src/sksl/ir/SkSLSwizzle.h | 2 +- src/sksl/sksl_geom.inc | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sksl/SkSLCompiler.h b/src/sksl/SkSLCompiler.h index eb2fc45b51..384562fe3e 100644 --- a/src/sksl/SkSLCompiler.h +++ b/src/sksl/SkSLCompiler.h @@ -24,6 +24,7 @@ #define SK_OUTCOLOR_BUILTIN 10004 #define SK_TRANSFORMEDCOORDS2D_BUILTIN 10005 #define SK_TEXTURESAMPLERS_BUILTIN 10006 +#define SK_OUT_BUILTIN 10007 #define SK_FRAGCOORD_BUILTIN 15 #define SK_VERTEXID_BUILTIN 5 #define SK_INSTANCEID_BUILTIN 6 diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp index 02bd336b55..6e008471ea 100644 --- a/src/sksl/SkSLSPIRVCodeGenerator.cpp +++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp @@ -2436,7 +2436,7 @@ void SPIRVCodeGenerator::writeLayout(const Layout& layout, SpvId target) { fCapabilities |= (((uint64_t) 1) << SpvCapabilityInputAttachment); } if (layout.fBuiltin >= 0 && layout.fBuiltin != SK_FRAGCOLOR_BUILTIN && - layout.fBuiltin != SK_IN_BUILTIN) { + layout.fBuiltin != SK_IN_BUILTIN && layout.fBuiltin != SK_OUT_BUILTIN) { this->writeInstruction(SpvOpDecorate, target, SpvDecorationBuiltIn, layout.fBuiltin, fDecorationBuffer); } @@ -2949,8 +2949,9 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream& intf.fSizes.emplace_back(new IntLiteral(fContext, -1, skInSize)); } SpvId id = this->writeInterfaceBlock(intf); - if ((intf.fVariable.fModifiers.fFlags & Modifiers::kIn_Flag) || - (intf.fVariable.fModifiers.fFlags & Modifiers::kOut_Flag)) { + if (((intf.fVariable.fModifiers.fFlags & Modifiers::kIn_Flag) || + (intf.fVariable.fModifiers.fFlags & Modifiers::kOut_Flag)) && + intf.fVariable.fModifiers.fLayout.fBuiltin == -1) { interfaceVars.insert(id); } } @@ -2976,8 +2977,10 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream& for (auto entry : fVariableMap) { const Variable* var = entry.first; if (var->fStorage == Variable::kGlobal_Storage && - ((var->fModifiers.fFlags & Modifiers::kIn_Flag) || - (var->fModifiers.fFlags & Modifiers::kOut_Flag))) { + ((var->fModifiers.fFlags & Modifiers::kIn_Flag) || + (var->fModifiers.fFlags & Modifiers::kOut_Flag)) && + var->fModifiers.fLayout.fBuiltin != SK_IN_BUILTIN && + var->fModifiers.fLayout.fBuiltin != SK_OUT_BUILTIN) { interfaceVars.insert(entry.second); } } diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h index 5512c852b3..d07f16efc2 100644 --- a/src/sksl/ir/SkSLSwizzle.h +++ b/src/sksl/ir/SkSLSwizzle.h @@ -79,7 +79,7 @@ static const Type& get_type(const Context& context, Expression& value, size_t co } /** - * Represents a vector swizzle operation such as 'float21, 2, 3).zyx'. + * Represents a vector swizzle operation such as 'float2(1, 2, 3).zyx'. */ struct Swizzle : public Expression { Swizzle(const Context& context, std::unique_ptr base, std::vector components) diff --git a/src/sksl/sksl_geom.inc b/src/sksl/sksl_geom.inc index 1ce5265c19..dcd85f1aed 100644 --- a/src/sksl/sksl_geom.inc +++ b/src/sksl/sksl_geom.inc @@ -8,7 +8,7 @@ layout(builtin=10002) in sk_PerVertex { layout(builtin=3) float sk_ClipDistance[1]; } sk_in[]; -out sk_PerVertex { +layout(builtin=10007) out sk_PerVertex { layout(builtin=0) float4 sk_Position; layout(builtin=1) float sk_PointSize; layout(builtin=3) float sk_ClipDistance[1];