Replace spirv::writer::binding::BindingInfo with tint::BindingPoint

Replaced `tint::spirv::writer::binding::BindingInfo` with
`tint::BindingPoint`.

Change-Id: I5acb8522f19249caac134f701285f16dc7e7d214
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/255916
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/dawn/native/vulkan/ShaderModuleVk.cpp b/src/dawn/native/vulkan/ShaderModuleVk.cpp
index cb13755..9011ffa 100644
--- a/src/dawn/native/vulkan/ShaderModuleVk.cpp
+++ b/src/dawn/native/vulkan/ShaderModuleVk.cpp
@@ -168,19 +168,13 @@
                 [&](const BufferBindingInfo& bindingInfo) {
                     switch (bindingInfo.type) {
                         case wgpu::BufferBindingType::Uniform:
-                            bindings.uniform.emplace(
-                                srcBindingPoint,
-                                tint::spirv::writer::binding::Uniform{dstBindingPoint.group,
-                                                                      dstBindingPoint.binding});
+                            bindings.uniform.emplace(srcBindingPoint, dstBindingPoint);
                             break;
                         case kInternalStorageBufferBinding:
                         case wgpu::BufferBindingType::Storage:
                         case wgpu::BufferBindingType::ReadOnlyStorage:
                         case kInternalReadOnlyStorageBufferBinding:
-                            bindings.storage.emplace(
-                                srcBindingPoint,
-                                tint::spirv::writer::binding::Storage{dstBindingPoint.group,
-                                                                      dstBindingPoint.binding});
+                            bindings.storage.emplace(srcBindingPoint, dstBindingPoint);
                             break;
                         case wgpu::BufferBindingType::BindingNotUsed:
                         case wgpu::BufferBindingType::Undefined:
@@ -189,9 +183,7 @@
                     }
                 },
                 [&](const SamplerBindingInfo& bindingInfo) {
-                    bindings.sampler.emplace(srcBindingPoint,
-                                             tint::spirv::writer::binding::Sampler{
-                                                 dstBindingPoint.group, dstBindingPoint.binding});
+                    bindings.sampler.emplace(srcBindingPoint, dstBindingPoint);
                 },
                 [&](const TextureBindingInfo& bindingInfo) {
                     if (auto samplerIndex = bgl->GetStaticSamplerIndexForTexture(
@@ -199,14 +191,10 @@
                         dstBindingPoint.binding = static_cast<uint32_t>(samplerIndex.value());
                         statically_paired_texture_binding_points.insert(srcBindingPoint);
                     }
-                    bindings.texture.emplace(srcBindingPoint,
-                                             tint::spirv::writer::binding::Texture{
-                                                 dstBindingPoint.group, dstBindingPoint.binding});
+                    bindings.texture.emplace(srcBindingPoint, dstBindingPoint);
                 },
                 [&](const StorageTextureBindingInfo& bindingInfo) {
-                    bindings.storage_texture.emplace(
-                        srcBindingPoint, tint::spirv::writer::binding::StorageTexture{
-                                             dstBindingPoint.group, dstBindingPoint.binding});
+                    bindings.storage_texture.emplace(srcBindingPoint, dstBindingPoint);
                 },
                 [&](const ExternalTextureBindingInfo& bindingInfo) {
                     const auto& bindingMap = bgl->GetExternalTextureBindingExpansionMap();
@@ -214,24 +202,22 @@
                     DAWN_ASSERT(expansion != bindingMap.end());
 
                     const auto& bindingExpansion = expansion->second;
-                    tint::spirv::writer::binding::BindingInfo plane0{
+                    tint::BindingPoint plane0{
                         static_cast<uint32_t>(group),
                         static_cast<uint32_t>(bgl->GetBindingIndex(bindingExpansion.plane0))};
-                    tint::spirv::writer::binding::BindingInfo plane1{
+                    tint::BindingPoint plane1{
                         static_cast<uint32_t>(group),
                         static_cast<uint32_t>(bgl->GetBindingIndex(bindingExpansion.plane1))};
-                    tint::spirv::writer::binding::BindingInfo metadata{
+                    tint::BindingPoint metadata{
                         static_cast<uint32_t>(group),
                         static_cast<uint32_t>(bgl->GetBindingIndex(bindingExpansion.params))};
 
                     bindings.external_texture.emplace(
                         srcBindingPoint,
-                        tint::spirv::writer::binding::ExternalTexture{metadata, plane0, plane1});
+                        tint::spirv::writer::ExternalTexture{metadata, plane0, plane1});
                 },
                 [&](const InputAttachmentBindingInfo& bindingInfo) {
-                    bindings.input_attachment.emplace(
-                        srcBindingPoint, tint::spirv::writer::binding::InputAttachment{
-                                             dstBindingPoint.group, dstBindingPoint.binding});
+                    bindings.input_attachment.emplace(srcBindingPoint, dstBindingPoint);
                 });
         }
     }
diff --git a/src/tint/lang/spirv/writer/common/option_helper.cc b/src/tint/lang/spirv/writer/common/option_helper.cc
index 59b26c2..025813e 100644
--- a/src/tint/lang/spirv/writer/common/option_helper.cc
+++ b/src/tint/lang/spirv/writer/common/option_helper.cc
@@ -37,8 +37,8 @@
 Result<SuccessType> ValidateBindingOptions(const Options& options) {
     diag::List diagnostics;
 
-    tint::Hashmap<tint::BindingPoint, binding::BindingInfo, 8> seen_wgsl_bindings{};
-    tint::Hashmap<binding::BindingInfo, tint::BindingPoint, 8> seen_spirv_bindings{};
+    tint::Hashmap<tint::BindingPoint, tint::BindingPoint, 8> seen_wgsl_bindings{};
+    tint::Hashmap<tint::BindingPoint, tint::BindingPoint, 8> seen_spirv_bindings{};
 
     // Both wgsl_seen and spirv_seen check to see if the pair of [src, dst] are unique. If we have
     // multiple entries that map the same [src, dst] pair, that's fine. We treat it as valid as it's
@@ -46,7 +46,7 @@
     // match, then we report an error about a duplicate binding point.
 
     auto wgsl_seen = [&diagnostics, &seen_wgsl_bindings](const tint::BindingPoint& src,
-                                                         const binding::BindingInfo& dst) -> bool {
+                                                         const tint::BindingPoint& dst) -> bool {
         if (auto binding = seen_wgsl_bindings.Get(src)) {
             if (*binding != dst) {
                 diagnostics.AddError(Source{}) << "found duplicate WGSL binding point: " << src;
@@ -61,7 +61,7 @@
         options.statically_paired_texture_binding_points;
     auto spirv_seen = [&diagnostics, &seen_spirv_bindings,
                        &statically_paired_texture_binding_points](
-                          const binding::BindingInfo& src, const tint::BindingPoint& dst) -> bool {
+                          const tint::BindingPoint& src, const tint::BindingPoint& dst) -> bool {
         if (auto binding = seen_spirv_bindings.Get(src)) {
             if (*binding != dst && !statically_paired_texture_binding_points.count(*binding) &&
                 !statically_paired_texture_binding_points.count(dst)) {
@@ -193,16 +193,14 @@
     auto create_remappings = [&remapper_data](const auto& hsh) {
         for (const auto& it : hsh) {
             const BindingPoint& src_binding_point = it.first;
-            const binding::BindingInfo& dst_binding_point = it.second;
+            const auto& dst_binding_point = it.second;
 
             // Bindings which go to the same slot in SPIR-V do not need to be re-bound.
-            if (src_binding_point.group == dst_binding_point.group &&
-                src_binding_point.binding == dst_binding_point.binding) {
+            if (src_binding_point == dst_binding_point) {
                 continue;
             }
 
-            remapper_data.emplace(src_binding_point,
-                                  BindingPoint{dst_binding_point.group, dst_binding_point.binding});
+            remapper_data.emplace(src_binding_point, dst_binding_point);
         }
     };
 
@@ -216,26 +214,20 @@
     // External textures are re-bound to their plane0 location
     for (const auto& it : options.bindings.external_texture) {
         const BindingPoint& src_binding_point = it.first;
-        const binding::BindingInfo& plane0 = it.second.plane0;
-        const binding::BindingInfo& plane1 = it.second.plane1;
-        const binding::BindingInfo& metadata = it.second.metadata;
-
-        const BindingPoint plane0_binding_point{plane0.group, plane0.binding};
-        const BindingPoint plane1_binding_point{plane1.group, plane1.binding};
-        const BindingPoint metadata_binding_point{metadata.group, metadata.binding};
+        const auto& plane0 = it.second.plane0;
+        const auto& plane1 = it.second.plane1;
+        const auto& metadata = it.second.metadata;
 
         // Use the re-bound spir-v plane0 value for the lookup key.
-        multiplanar_map.emplace(plane0_binding_point,
-                                tint::transform::multiplanar::BindingPoints{
-                                    plane1_binding_point, metadata_binding_point});
+        multiplanar_map.emplace(plane0,
+                                tint::transform::multiplanar::BindingPoints{plane1, metadata});
 
         // Bindings which go to the same slot in SPIR-V do not need to be re-bound.
-        if (src_binding_point.group == plane0.group &&
-            src_binding_point.binding == plane0.binding) {
+        if (src_binding_point == plane0) {
             continue;
         }
 
-        remapper_data.emplace(src_binding_point, BindingPoint{plane0.group, plane0.binding});
+        remapper_data.emplace(src_binding_point, plane0);
     }
 }
 
diff --git a/src/tint/lang/spirv/writer/common/options.h b/src/tint/lang/spirv/writer/common/options.h
index 8b4bc8b..f302164 100644
--- a/src/tint/lang/spirv/writer/common/options.h
+++ b/src/tint/lang/spirv/writer/common/options.h
@@ -37,86 +37,39 @@
 #include "src/tint/utils/reflection.h"
 
 namespace tint::spirv::writer {
-namespace binding {
-
-/// Generic binding point
-struct BindingInfo {
-    /// The group
-    uint32_t group = 0;
-    /// The binding
-    uint32_t binding = 0;
-
-    /// Equality operator
-    /// @param rhs the BindingInfo to compare against
-    /// @returns true if this BindingInfo is equal to `rhs`
-    inline bool operator==(const BindingInfo& rhs) const {
-        return group == rhs.group && binding == rhs.binding;
-    }
-    /// Inequality operator
-    /// @param rhs the BindingInfo to compare against
-    /// @returns true if this BindingInfo is not equal to `rhs`
-    inline bool operator!=(const BindingInfo& rhs) const { return !(*this == rhs); }
-
-    /// @returns the hash code of the BindingInfo
-    tint::HashCode HashCode() const { return Hash(group, binding); }
-
-    /// Reflect the fields of this class so that it can be used by tint::ForeachField()
-    TINT_REFLECT(BindingInfo, group, binding);
-};
-
-using Uniform = BindingInfo;
-using Storage = BindingInfo;
-using Texture = BindingInfo;
-using StorageTexture = BindingInfo;
-using Sampler = BindingInfo;
-using InputAttachment = BindingInfo;
 
 /// An external texture
 struct ExternalTexture {
     /// Metadata
-    BindingInfo metadata{};
+    BindingPoint metadata{};
     /// Plane0 binding data
-    BindingInfo plane0{};
+    BindingPoint plane0{};
     /// Plane1 binding data
-    BindingInfo plane1{};
+    BindingPoint plane1{};
 
     /// Reflect the fields of this class so that it can be used by tint::ForeachField()
     TINT_REFLECT(ExternalTexture, metadata, plane0, plane1);
 };
 
-}  // namespace binding
-
-// Maps the WGSL binding point to the SPIR-V group,binding for uniforms
-using UniformBindings = std::unordered_map<BindingPoint, binding::Uniform>;
-// Maps the WGSL binding point to the SPIR-V group,binding for storage
-using StorageBindings = std::unordered_map<BindingPoint, binding::Storage>;
-// Maps the WGSL binding point to the SPIR-V group,binding for textures
-using TextureBindings = std::unordered_map<BindingPoint, binding::Texture>;
-// Maps the WGSL binding point to the SPIR-V group,binding for storage textures
-using StorageTextureBindings = std::unordered_map<BindingPoint, binding::StorageTexture>;
-// Maps the WGSL binding point to the SPIR-V group,binding for samplers
-using SamplerBindings = std::unordered_map<BindingPoint, binding::Sampler>;
-// Maps the WGSL binding point to the plane0, plane1, and metadata information for external textures
-using ExternalTextureBindings = std::unordered_map<BindingPoint, binding::ExternalTexture>;
-// Maps the WGSL binding point to the SPIR-V group,binding for input attachments
-using InputAttachmentBindings = std::unordered_map<BindingPoint, binding::InputAttachment>;
+using BindingMap = std::unordered_map<BindingPoint, BindingPoint>;
+using ExternalTextureBindings = std::unordered_map<BindingPoint, ExternalTexture>;
 
 /// Binding information
 struct Bindings {
     /// Uniform bindings
-    UniformBindings uniform{};
+    BindingMap uniform{};
     /// Storage bindings
-    StorageBindings storage{};
+    BindingMap storage{};
     /// Texture bindings
-    TextureBindings texture{};
+    BindingMap texture{};
     /// Storage texture bindings
-    StorageTextureBindings storage_texture{};
+    BindingMap storage_texture{};
     /// Sampler bindings
-    SamplerBindings sampler{};
+    BindingMap sampler{};
     /// External bindings
     ExternalTextureBindings external_texture{};
     /// Input attachment bindings
-    InputAttachmentBindings input_attachment{};
+    BindingMap input_attachment{};
 
     /// Reflect the fields of this class so that it can be used by tint::ForeachField()
     TINT_REFLECT(Bindings,
diff --git a/src/tint/lang/spirv/writer/common/options_test.cc b/src/tint/lang/spirv/writer/common/options_test.cc
index 70c136a..bfcdbbe 100644
--- a/src/tint/lang/spirv/writer/common/options_test.cc
+++ b/src/tint/lang/spirv/writer/common/options_test.cc
@@ -33,8 +33,7 @@
 namespace {
 
 TEST(TintCheckAllFieldsReflected, SpirvWriterCommonOptionsTest) {
-    TINT_ASSERT_ALL_FIELDS_REFLECTED(binding::BindingInfo);
-    TINT_ASSERT_ALL_FIELDS_REFLECTED(binding::ExternalTexture);
+    TINT_ASSERT_ALL_FIELDS_REFLECTED(ExternalTexture);
     TINT_ASSERT_ALL_FIELDS_REFLECTED(Bindings);
     TINT_ASSERT_ALL_FIELDS_REFLECTED(Options);
 }
diff --git a/src/tint/lang/spirv/writer/helpers/generate_bindings.cc b/src/tint/lang/spirv/writer/helpers/generate_bindings.cc
index f49af9a..a6c581c 100644
--- a/src/tint/lang/spirv/writer/helpers/generate_bindings.cc
+++ b/src/tint/lang/spirv/writer/helpers/generate_bindings.cc
@@ -72,22 +72,21 @@
                 continue;
             }
 
-            binding::BindingInfo info{bp->group, bp->binding};
             switch (ptr->AddressSpace()) {
                 case core::AddressSpace::kHandle:
                     Switch(
                         ptr->UnwrapPtr(),  //
-                        [&](const core::type::Sampler*) { bindings.sampler.emplace(*bp, info); },
+                        [&](const core::type::Sampler*) { bindings.sampler.emplace(*bp, *bp); },
                         [&](const core::type::StorageTexture*) {
-                            bindings.storage_texture.emplace(*bp, info);
+                            bindings.storage_texture.emplace(*bp, *bp);
                         },
-                        [&](const core::type::Texture*) { bindings.texture.emplace(*bp, info); });
+                        [&](const core::type::Texture*) { bindings.texture.emplace(*bp, *bp); });
                     break;
                 case core::AddressSpace::kStorage:
-                    bindings.storage.emplace(*bp, info);
+                    bindings.storage.emplace(*bp, *bp);
                     break;
                 case core::AddressSpace::kUniform:
-                    bindings.uniform.emplace(*bp, info);
+                    bindings.uniform.emplace(*bp, *bp);
                     break;
 
                 case core::AddressSpace::kUndefined:
@@ -107,11 +106,11 @@
         uint32_t g = bp.group;
         uint32_t& next_num = group_to_next_binding_number.GetOrAddZero(g);
 
-        binding::BindingInfo plane0{bp.group, bp.binding};
-        binding::BindingInfo plane1{g, next_num++};
-        binding::BindingInfo metadata{g, next_num++};
+        tint::BindingPoint plane0{bp.group, bp.binding};
+        tint::BindingPoint plane1{g, next_num++};
+        tint::BindingPoint metadata{g, next_num++};
 
-        bindings.external_texture.emplace(bp, binding::ExternalTexture{metadata, plane0, plane1});
+        bindings.external_texture.emplace(bp, ExternalTexture{metadata, plane0, plane1});
     }
 
     return bindings;