Detect unsupported types for MemoryLayout and report errors.

Previously, MemoryLayout would ABORT if it encountered any types that
we can't layout in memory (e.g. opaque types like samplers). Instead of
an abort, this case is now detected cleanly and an error is reported
identifying the offending type.

This should unwedge the fuzzer, which appears to be very
enthusiatically generating interface blocks with nonsense types inside.

(Note that code generators which don't actually try to compute a memory
layout--that is, GLSL--will still accept these types. This should still
be caught and reported as an error, since it's still illegal in GLSL,
but that's for a future CL.)

Change-Id: I88a9649bcd8c75dadc8cca679f3c5e94570742bc
Bug: skia:10956, oss-fuzz:27525
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335196
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/SkSLMemoryLayout.h b/src/sksl/SkSLMemoryLayout.h
index a75e453..f6e3ba6 100644
--- a/src/sksl/SkSLMemoryLayout.h
+++ b/src/sksl/SkSLMemoryLayout.h
@@ -48,6 +48,7 @@
         // See OpenGL Spec 7.6.2.2 Standard Uniform Block Layout
         switch (type.typeKind()) {
             case Type::TypeKind::kScalar:
+            case Type::TypeKind::kEnum:
                 return this->size(type);
             case Type::TypeKind::kVector:
                 return vector_alignment(this->size(type.componentType()), type.columns());
@@ -108,6 +109,8 @@
                 // FIXME need to take precision into account, once we figure out how we want to
                 // handle it...
                 return 4;
+            case Type::TypeKind::kEnum:
+                return 4;
             case Type::TypeKind::kVector:
                 if (fStd == kMetal_Standard && type.columns() == 3) {
                     return 4 * this->size(type.componentType());
@@ -136,6 +139,24 @@
         }
     }
 
+    /**
+     * Not all types are compatible with memory layout.
+     */
+    size_t layoutIsSupported(const Type& type) const {
+        switch (type.typeKind()) {
+            case Type::TypeKind::kScalar:
+            case Type::TypeKind::kEnum:
+            case Type::TypeKind::kVector:
+            case Type::TypeKind::kMatrix:
+            case Type::TypeKind::kArray:
+            case Type::TypeKind::kStruct:
+                return true;
+
+            default:
+                return false;
+        }
+    }
+
     const Standard fStd;
 };