[tint][ir] Support `texel_buffer` in the binary IR schema.

Change-Id: Ic7535829ab8a9715f4a56bb50ae474080b0afa2c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/252415
Commit-Queue: Diego Rodrigues <diejorarr@gmail.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/core/ir/binary/decode.cc b/src/tint/lang/core/ir/binary/decode.cc
index e3e25e8..b5e4722 100644
--- a/src/tint/lang/core/ir/binary/decode.cc
+++ b/src/tint/lang/core/ir/binary/decode.cc
@@ -691,6 +691,8 @@
                 return CreateTypeArray(type_in.array());
             case pb::Type::KindCase::kBindingArray:
                 return CreateTypeBindingArray(type_in.binding_array());
+            case pb::Type::KindCase::kTexelBuffer:
+                return CreateTypeTexelBuffer(type_in.texel_buffer());
             case pb::Type::KindCase::kDepthTexture:
                 return CreateTypeDepthTexture(type_in.depth_texture());
             case pb::Type::KindCase::kSampledTexture:
@@ -931,6 +933,12 @@
         return mod_out_.Types().storage_texture(dimension, texel_format, access);
     }
 
+    const type::TexelBuffer* CreateTypeTexelBuffer(const pb::TypeTexelBuffer& buffer_in) {
+        auto texel_format = TexelFormat(buffer_in.texel_format());
+        auto access = AccessControl(buffer_in.access());
+        return mod_out_.Types().texel_buffer(texel_format, access);
+    }
+
     const type::ExternalTexture* CreateTypeExternalTexture(const pb::TypeExternalTexture&) {
         return mod_out_.Types().external_texture();
     }
diff --git a/src/tint/lang/core/ir/binary/encode.cc b/src/tint/lang/core/ir/binary/encode.cc
index d44fb96..4a9113d 100644
--- a/src/tint/lang/core/ir/binary/encode.cc
+++ b/src/tint/lang/core/ir/binary/encode.cc
@@ -410,6 +410,9 @@
                 [&](const core::type::StorageTexture* t) {
                     TypeStorageTexture(*type_out.mutable_storage_texture(), t);
                 },
+                [&](const core::type::TexelBuffer* t) {
+                    TypeTexelBuffer(*type_out.mutable_texel_buffer(), t);
+                },
                 [&](const core::type::ExternalTexture* t) {
                     TypeExternalTexture(*type_out.mutable_external_texture(), t);
                 },
@@ -552,6 +555,12 @@
         texture_out.set_access(AccessControl(texture_in->Access()));
     }
 
+    void TypeTexelBuffer(pb::TypeTexelBuffer& buffer_out,
+                         const core::type::TexelBuffer* buffer_in) {
+        buffer_out.set_texel_format(TexelFormat(buffer_in->TexelFormat()));
+        buffer_out.set_access(AccessControl(buffer_in->Access()));
+    }
+
     void TypeExternalTexture(pb::TypeExternalTexture&, const core::type::ExternalTexture*) {}
     void TypeInputAttachment(pb::TypeInputAttachment& input_attachment_out,
                              const core::type::InputAttachment* input_attachment_in) {
diff --git a/src/tint/lang/core/ir/binary/roundtrip_test.cc b/src/tint/lang/core/ir/binary/roundtrip_test.cc
index 3663a6d..8bc2134 100644
--- a/src/tint/lang/core/ir/binary/roundtrip_test.cc
+++ b/src/tint/lang/core/ir/binary/roundtrip_test.cc
@@ -333,6 +333,12 @@
     RUN_TEST();
 }
 
+TEST_F(IRBinaryRoundtripTest, texel_buffer) {
+    auto* buf = ty.texel_buffer(core::TexelFormat::kRgba32Float, core::Access::kReadWrite);
+    b.Append(b.ir.root_block, [&] { b.Var(ty.ptr(handle, buf, read)); });
+    RUN_TEST();
+}
+
 TEST_F(IRBinaryRoundtripTest, external_texture) {
     auto* tex = ty.external_texture();
     b.Append(b.ir.root_block, [&] { b.Var(ty.ptr(handle, tex, read)); });
diff --git a/src/tint/utils/protos/ir/ir.proto b/src/tint/utils/protos/ir/ir.proto
index 32fe84b..27abc8d 100644
--- a/src/tint/utils/protos/ir/ir.proto
+++ b/src/tint/utils/protos/ir/ir.proto
@@ -63,6 +63,7 @@
         TypeSubgroupMatrix subgroup_matrix_result = 18;
         TypeBuiltinStruct builtin_struct = 19;
         TypeBindingArray binding_array = 20;
+        TypeTexelBuffer texel_buffer = 21;
     }
 }
 
@@ -184,6 +185,11 @@
     ModfResultVec4F32 = 17;
 }
 
+message TypeTexelBuffer {
+    TexelFormat texel_format = 1;
+    AccessControl access = 2;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // Values
 ////////////////////////////////////////////////////////////////////////////////