[tint][wgsl] Add 'chromium_internal_graphite' extension

Bug: dawn:2101
Change-Id: Ifa57e3ee7fd0f4b0c6c7bca8e04fb6986a37df74
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/176041
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/lang/wgsl/extension.cc b/src/tint/lang/wgsl/extension.cc
index 3069ccf..1240173 100644
--- a/src/tint/lang/wgsl/extension.cc
+++ b/src/tint/lang/wgsl/extension.cc
@@ -60,6 +60,9 @@
     if (str == "chromium_internal_dual_source_blending") {
         return Extension::kChromiumInternalDualSourceBlending;
     }
+    if (str == "chromium_internal_graphite") {
+        return Extension::kChromiumInternalGraphite;
+    }
     if (str == "chromium_internal_relaxed_uniform_layout") {
         return Extension::kChromiumInternalRelaxedUniformLayout;
     }
@@ -85,6 +88,8 @@
             return "chromium_experimental_subgroups";
         case Extension::kChromiumInternalDualSourceBlending:
             return "chromium_internal_dual_source_blending";
+        case Extension::kChromiumInternalGraphite:
+            return "chromium_internal_graphite";
         case Extension::kChromiumInternalRelaxedUniformLayout:
             return "chromium_internal_relaxed_uniform_layout";
         case Extension::kF16:
diff --git a/src/tint/lang/wgsl/extension.h b/src/tint/lang/wgsl/extension.h
index 7de7e82..3eccedf 100644
--- a/src/tint/lang/wgsl/extension.h
+++ b/src/tint/lang/wgsl/extension.h
@@ -52,6 +52,7 @@
     kChromiumExperimentalPushConstant,
     kChromiumExperimentalSubgroups,
     kChromiumInternalDualSourceBlending,
+    kChromiumInternalGraphite,
     kChromiumInternalRelaxedUniformLayout,
     kF16,
 };
@@ -74,10 +75,15 @@
 Extension ParseExtension(std::string_view str);
 
 constexpr std::string_view kExtensionStrings[] = {
-    "chromium_disable_uniformity_analysis",     "chromium_experimental_framebuffer_fetch",
-    "chromium_experimental_pixel_local",        "chromium_experimental_push_constant",
-    "chromium_experimental_subgroups",          "chromium_internal_dual_source_blending",
-    "chromium_internal_relaxed_uniform_layout", "f16",
+    "chromium_disable_uniformity_analysis",
+    "chromium_experimental_framebuffer_fetch",
+    "chromium_experimental_pixel_local",
+    "chromium_experimental_push_constant",
+    "chromium_experimental_subgroups",
+    "chromium_internal_dual_source_blending",
+    "chromium_internal_graphite",
+    "chromium_internal_relaxed_uniform_layout",
+    "f16",
 };
 
 /// All extensions
@@ -88,6 +94,7 @@
     Extension::kChromiumExperimentalPushConstant,
     Extension::kChromiumExperimentalSubgroups,
     Extension::kChromiumInternalDualSourceBlending,
+    Extension::kChromiumInternalGraphite,
     Extension::kChromiumInternalRelaxedUniformLayout,
     Extension::kF16,
 };
diff --git a/src/tint/lang/wgsl/extension_bench.cc b/src/tint/lang/wgsl/extension_bench.cc
index 70c0d73..c2128d3 100644
--- a/src/tint/lang/wgsl/extension_bench.cc
+++ b/src/tint/lang/wgsl/extension_bench.cc
@@ -87,20 +87,27 @@
         "chromium_internakk_ualsourc_blendHng",
         "chromium_inRRrnal_dujl_sourceblgnding",
         "chromiuminternal_duab_source_blendin",
-        "chromium_internal_relaxed_uniform_lajout",
-        "chromium_internal_relxed_uniform_layout",
-        "chroium_inqernal_rlaxed_uniform_layout",
+        "chromiumjinternal_graphite",
+        "chromium_inernal_graphite",
+        "cromiu_internaq_graphite",
+        "chromium_internal_graphite",
+        "chromium_intenalNNgraphite",
+        "chromiuminternal_gvaphite",
+        "chromium_internal_grphitQQ",
+        "chromirm_intenal_rfflaxed_unifrm_layout",
+        "chromium_internal_jelaxed_uniform_layout",
+        "chromium_interna_relNNxed_uwwiform_lay82t",
         "chromium_internal_relaxed_uniform_layout",
-        "chromium_internNNl_relaxed_uniform_layou",
-        "chromium_internal_relaxvvd_unifom_laout",
-        "chromium_internalrelaxed_uniQQorm_layout",
-        "ff",
-        "fj6",
-        "wNN2",
+        "chromium_internal_relaxed_uniform_layut",
+        "chromium_internal_relaxed_rrniform_layout",
+        "chromium_internal_relaxedGuniform_layout",
+        "FF16",
+        "",
+        "rr1",
         "f16",
-        "f6",
-        "rr16",
-        "fG6",
+        "1",
+        "DJ1",
+        "",
     };
     for (auto _ : state) {
         for (auto* str : kStrings) {
diff --git a/src/tint/lang/wgsl/extension_test.cc b/src/tint/lang/wgsl/extension_test.cc
index 8bcbd0c..11a75b0 100644
--- a/src/tint/lang/wgsl/extension_test.cc
+++ b/src/tint/lang/wgsl/extension_test.cc
@@ -63,6 +63,7 @@
     {"chromium_experimental_push_constant", Extension::kChromiumExperimentalPushConstant},
     {"chromium_experimental_subgroups", Extension::kChromiumExperimentalSubgroups},
     {"chromium_internal_dual_source_blending", Extension::kChromiumInternalDualSourceBlending},
+    {"chromium_internal_graphite", Extension::kChromiumInternalGraphite},
     {"chromium_internal_relaxed_uniform_layout", Extension::kChromiumInternalRelaxedUniformLayout},
     {"f16", Extension::kF16},
 };
@@ -86,12 +87,15 @@
     {"chromium_internal_dual_soErce_blending", Extension::kUndefined},
     {"chromiuPP_internal_dual_sourceblenTTing", Extension::kUndefined},
     {"chromim_internadd_dual_sxxurce_blending", Extension::kUndefined},
-    {"chromium_interna44_relaxed_uniform_layout", Extension::kUndefined},
-    {"chromium_internal_relaxed_uniformSSlayouVV", Extension::kUndefined},
-    {"chromiumRnteRnal_re22axed_uniform_layout", Extension::kUndefined},
-    {"96", Extension::kUndefined},
-    {"f1", Extension::kUndefined},
-    {"VOR6", Extension::kUndefined},
+    {"chromi44m_internal_graphite", Extension::kUndefined},
+    {"chromSSuVV_internal_graphite", Extension::kUndefined},
+    {"cRromium_nternR22_graphite", Extension::kUndefined},
+    {"chromium_int9rnal_relaxed_Fnifor_layout", Extension::kUndefined},
+    {"chrmium_internal_relaxed_uniform_layout", Extension::kUndefined},
+    {"VRhHomium_internal_relaxd_uniform_OOayout", Extension::kUndefined},
+    {"y1", Extension::kUndefined},
+    {"l77rrn6", Extension::kUndefined},
+    {"4016", Extension::kUndefined},
 };
 
 using ExtensionParseTest = testing::TestWithParam<Case>;
diff --git a/src/tint/lang/wgsl/reader/parser/enable_directive_test.cc b/src/tint/lang/wgsl/reader/parser/enable_directive_test.cc
index 6f689b3..adb1d1c 100644
--- a/src/tint/lang/wgsl/reader/parser/enable_directive_test.cc
+++ b/src/tint/lang/wgsl/reader/parser/enable_directive_test.cc
@@ -205,7 +205,7 @@
     // Error when unknown extension found
     EXPECT_TRUE(p->has_error());
     EXPECT_EQ(p->error(), R"(1:8: expected extension
-Possible values: 'chromium_disable_uniformity_analysis', 'chromium_experimental_framebuffer_fetch', 'chromium_experimental_pixel_local', 'chromium_experimental_push_constant', 'chromium_experimental_subgroups', 'chromium_internal_dual_source_blending', 'chromium_internal_relaxed_uniform_layout', 'f16')");
+Possible values: 'chromium_disable_uniformity_analysis', 'chromium_experimental_framebuffer_fetch', 'chromium_experimental_pixel_local', 'chromium_experimental_push_constant', 'chromium_experimental_subgroups', 'chromium_internal_dual_source_blending', 'chromium_internal_graphite', 'chromium_internal_relaxed_uniform_layout', 'f16')");
     auto program = p->program();
     auto& ast = program.AST();
     EXPECT_EQ(ast.Enables().Length(), 0u);
diff --git a/src/tint/lang/wgsl/wgsl.def b/src/tint/lang/wgsl/wgsl.def
index c99f413..b851cdb 100644
--- a/src/tint/lang/wgsl/wgsl.def
+++ b/src/tint/lang/wgsl/wgsl.def
@@ -76,6 +76,8 @@
   chromium_experimental_push_constant
   // A Chromium-specific extension that adds basic subgroup functionality.
   chromium_experimental_subgroups
+  // A Chromium-specific extension that enables features for graphite
+  chromium_internal_graphite
   // A Chromium-specific extension that relaxes memory layout requirements for uniform storage.
   chromium_internal_relaxed_uniform_layout
   // A Chromium-specific extension that enables dual source blending.