fixed SPIR-V compilation error with unmodified variables
authorEthan Nicholas <ethannicholas@google.com>
Fri, 31 Mar 2017 18:53:17 +0000 (14:53 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Fri, 31 Mar 2017 20:33:14 +0000 (20:33 +0000)
Change-Id: I22981a60c21a2e16d41d69c53e099f221a202a58
Reviewed-on: https://skia-review.googlesource.com/11000
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

src/sksl/SkSLParser.cpp
src/sksl/SkSLSPIRVCodeGenerator.cpp
tests/SkSLGLSLTest.cpp

index 1004de85b148d36d9c18e4560c7aa2bdb8522908..cdbf25e0d58475aeda974a41002ce047c03ed647 100644 (file)
@@ -498,7 +498,7 @@ std::unique_ptr<ASTVarDeclarations> Parser::varDeclarationEnd(Modifiers mods,
 
 /* modifiers type IDENTIFIER (LBRACKET INT_LITERAL RBRACKET)? */
 std::unique_ptr<ASTParameter> Parser::parameter() {
-    Modifiers modifiers = this->modifiersWithDefaults(Modifiers::kIn_Flag);
+    Modifiers modifiers = this->modifiersWithDefaults(0);
     std::unique_ptr<ASTType> type = this->type();
     if (!type) {
         return nullptr;
index 2b8feb93b980b08c434a22da614da473ad4ca439..d713d6fddd6969265b4386d86ca8e2766aac5847 100644 (file)
@@ -1642,8 +1642,13 @@ SpvStorageClass_ get_storage_class(const Modifiers& modifiers) {
 
 SpvStorageClass_ get_storage_class(const Expression& expr) {
     switch (expr.fKind) {
-        case Expression::kVariableReference_Kind:
-            return get_storage_class(((VariableReference&) expr).fVariable.fModifiers);
+        case Expression::kVariableReference_Kind: {
+            const Variable& var = ((VariableReference&) expr).fVariable;
+            if (var.fStorage != Variable::kGlobal_Storage) {
+                return SpvStorageClassFunction;
+            }
+            return get_storage_class(var.fModifiers);
+        }
         case Expression::kFieldAccess_Kind:
             return get_storage_class(*((FieldAccess&) expr).fBase);
         case Expression::kIndex_Kind:
index efae33604b05fc3bda4243a8121ee78519695fb4..51a1f6325d1f04ddb2c59f790db3687d5f0341d3 100644 (file)
@@ -93,7 +93,7 @@ DEF_TEST(SkSLFunctions, r) {
          *SkSL::ShaderCapsFactory::Default(),
          "#version 400\n"
          "out vec4 sk_FragColor;\n"
-         "float foo(in float v[2]) {\n"
+         "float foo(float v[2]) {\n"
          "    return v[0] * v[1];\n"
          "}\n"
          "void bar(inout float x) {\n"