Detect non-2D textures in MetalCodeGenerator and fail cleanly

We were letting this get further, then asserting.

Bug: skia:10797
Change-Id: Iff6fe43aa32450b5a517c94773031d593f1f62a2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321794
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLMetalCodeGenerator.cpp b/src/sksl/SkSLMetalCodeGenerator.cpp
index 97e277b..6f44c0a 100644
--- a/src/sksl/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/SkSLMetalCodeGenerator.cpp
@@ -958,8 +958,14 @@
                         if (var.fVar->fModifiers.fLayout.fBinding < 0) {
                             fErrors.error(decls.fOffset,
                                           "Metal samplers must have 'layout(binding=...)'");
+                            return;
                         }
-                        this->write(", texture2d<float> "); // FIXME - support other texture types
+                        if (var.fVar->type().dimensions() != SpvDim2D) {
+                            // TODO: Support other texture types (skbug.com/10797)
+                            fErrors.error(decls.fOffset, "Unsupported texture dimensions");
+                            return;
+                        }
+                        this->write(", texture2d<float> ");
                         this->writeName(var.fVar->fName);
                         this->write("[[texture(");
                         this->write(to_string(var.fVar->fModifiers.fLayout.fBinding));