Update resolver to allow runtime sized binding array

Add logic into the resolve to support a `binding_array` with a runtime
size.

Bug: 439626909
Change-Id: I8d2630ef639ad0454e6ad5e6a9da5be6281a262e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/257897
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/wgsl/resolver/binding_array_test.cc b/src/tint/lang/wgsl/resolver/binding_array_test.cc
index ae2149e..252f6a1 100644
--- a/src/tint/lang/wgsl/resolver/binding_array_test.cc
+++ b/src/tint/lang/wgsl/resolver/binding_array_test.cc
@@ -207,15 +207,14 @@
     GlobalVar("a", Binding(0_a), Group(0_a), ty("binding_array", 4_u));
 
     EXPECT_FALSE(r()->Resolve());
-    EXPECT_EQ(r()->error(), R"(error: 'binding_array' requires 2 template arguments)");
+    EXPECT_EQ(r()->error(), R"(error: cannot use value of type 'u32' as type)");
 }
 
-TEST_F(ResolverBindingArrayTest, InvalidNoTemplateCount) {
+TEST_F(ResolverBindingArrayTest, RuntimeBindingArray) {
     GlobalVar("a", Binding(0_a), Group(0_a),
               ty("binding_array", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32())));
 
-    EXPECT_FALSE(r()->Resolve());
-    EXPECT_EQ(r()->error(), R"(error: 'binding_array' requires 2 template arguments)");
+    EXPECT_TRUE(r()->Resolve()) << r()->error();
 }
 
 TEST_F(ResolverBindingArrayTest, InvalidCountZero) {
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index f76d25a..0b25077 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -2894,7 +2894,7 @@
 }
 
 const core::type::BindingArray* Resolver::BindingArray(const ast::Identifier* ident) {
-    auto* tmpl_ident = TemplatedIdentifier(ident, 2);
+    auto* tmpl_ident = TemplatedIdentifier(ident, 1, 2);
     if (DAWN_UNLIKELY(!tmpl_ident)) {
         return nullptr;
     }
@@ -2904,7 +2904,9 @@
         return nullptr;
     }
 
-    const core::type::ArrayCount* el_count = ArrayCount(tmpl_ident->arguments[1]);
+    const core::type::ArrayCount* el_count = tmpl_ident->arguments.Length() > 1
+                                                 ? ArrayCount(tmpl_ident->arguments[1])
+                                                 : b.create<core::type::RuntimeArrayCount>();
     if (!el_count) {
         return nullptr;
     }
diff --git a/src/tint/lang/wgsl/resolver/validator.cc b/src/tint/lang/wgsl/resolver/validator.cc
index a61e79e..5944311 100644
--- a/src/tint/lang/wgsl/resolver/validator.cc
+++ b/src/tint/lang/wgsl/resolver/validator.cc
@@ -471,7 +471,7 @@
                          << "language feature, which is not allowed in the current environment";
         return false;
     }
-    if (!t->Count()->Is<core::type::ConstantArrayCount>()) {
+    if (!t->Count()->IsAnyOf<core::type::ConstantArrayCount, core::type::RuntimeArrayCount>()) {
         AddError(source) << "binding_array count must be a constant expression";
         return false;
     }