Fold the depth_range_offsets into the writer options.

Only the GLSL writer used the depth_range_offsets option. They have been
moved into the GLSL options structure itself. The SPIRV backend uses
hard coded values for the transform.

Change-Id: Ibe27d267220f7bfb676bf42a829fcbb14d31bbeb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/191960
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/api/options/BUILD.bazel b/src/tint/api/options/BUILD.bazel
index 91919c2..5d312a2 100644
--- a/src/tint/api/options/BUILD.bazel
+++ b/src/tint/api/options/BUILD.bazel
@@ -42,7 +42,6 @@
     "options.cc",
   ],
   hdrs = [
-    "depth_range_offsets.h",
     "pixel_local.h",
     "texture_builtins_from_uniform.h",
   ],
diff --git a/src/tint/api/options/BUILD.cmake b/src/tint/api/options/BUILD.cmake
index facd62e..1789ace 100644
--- a/src/tint/api/options/BUILD.cmake
+++ b/src/tint/api/options/BUILD.cmake
@@ -39,7 +39,6 @@
 # Kind:      lib
 ################################################################################
 tint_add_target(tint_api_options lib
-  api/options/depth_range_offsets.h
   api/options/options.cc
   api/options/pixel_local.h
   api/options/texture_builtins_from_uniform.h
diff --git a/src/tint/api/options/BUILD.gn b/src/tint/api/options/BUILD.gn
index e2dd30a..378e54b 100644
--- a/src/tint/api/options/BUILD.gn
+++ b/src/tint/api/options/BUILD.gn
@@ -44,7 +44,6 @@
 
 libtint_source_set("options") {
   sources = [
-    "depth_range_offsets.h",
     "options.cc",
     "pixel_local.h",
     "texture_builtins_from_uniform.h",
diff --git a/src/tint/api/options/depth_range_offsets.h b/src/tint/api/options/depth_range_offsets.h
deleted file mode 100644
index b762378..0000000
--- a/src/tint/api/options/depth_range_offsets.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2024 The Dawn & Tint Authors
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice, this
-//    list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-//    this list of conditions and the following disclaimer in the documentation
-//    and/or other materials provided with the distribution.
-//
-// 3. Neither the name of the copyright holder nor the names of its
-//    contributors may be used to endorse or promote products derived from
-//    this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef SRC_TINT_API_OPTIONS_DEPTH_RANGE_OFFSETS_H_
-#define SRC_TINT_API_OPTIONS_DEPTH_RANGE_OFFSETS_H_
-
-#include <unordered_map>
-
-#include "src/tint/api/common/binding_point.h"
-#include "src/tint/utils/reflection/reflection.h"
-
-namespace tint {
-
-/// Options used to specify the offsets of the min_depth and max_depth push constants.
-struct DepthRangeOffsets {
-    /// A map of old binding point to new binding point
-    uint32_t min = 0;
-    uint32_t max = 0;
-
-    /// Reflect the fields of this class so that it can be used by tint::ForeachField()
-    TINT_REFLECT(DepthRangeOffsets, min, max);
-};
-
-}  // namespace tint
-
-#endif  // SRC_TINT_API_OPTIONS_DEPTH_RANGE_OFFSETS_H_
diff --git a/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
index 536ff67..57453a2 100644
--- a/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
@@ -215,7 +215,11 @@
     // ClampFragDepth must come before CanonicalizeEntryPointIO, or the assignments to FragDepth are
     // lost
     manager.Add<ast::transform::ClampFragDepth>();
-    data.Add<ast::transform::ClampFragDepth::Config>(options.depth_range_offsets);
+    std::optional<ast::transform::ClampFragDepth::RangeOffsets> range_offsets;
+    if (options.depth_range_offsets.has_value()) {
+        range_offsets = {options.depth_range_offsets->min, options.depth_range_offsets->max};
+    }
+    data.Add<ast::transform::ClampFragDepth::Config>(range_offsets);
 
     // CanonicalizeEntryPointIO must come after Robustness
     manager.Add<ast::transform::CanonicalizeEntryPointIO>();
diff --git a/src/tint/lang/glsl/writer/common/options.h b/src/tint/lang/glsl/writer/common/options.h
index c9963ea..c2b4bc3 100644
--- a/src/tint/lang/glsl/writer/common/options.h
+++ b/src/tint/lang/glsl/writer/common/options.h
@@ -32,7 +32,6 @@
 #include <string>
 #include <unordered_map>
 
-#include "src/tint/api/options/depth_range_offsets.h"
 #include "src/tint/api/options/texture_builtins_from_uniform.h"
 #include "src/tint/lang/glsl/writer/common/version.h"
 #include "src/tint/lang/wgsl/ast/transform/transform.h"
@@ -206,6 +205,16 @@
 
 /// Configuration options used for generating GLSL.
 struct Options {
+    struct RangeOffsets {
+        /// The offset of the min_depth push constant
+        uint32_t min = 0;
+        /// The offset of the max_depth push constant
+        uint32_t max = 0;
+
+        /// Reflect the fields of this class so that it can be used by tint::ForeachField()
+        TINT_REFLECT(RangeOffsets, min, max);
+    };
+
     /// Constructor
     Options();
 
@@ -234,7 +243,7 @@
     std::optional<int32_t> first_instance_offset;
 
     /// Offsets of the minDepth and maxDepth push constants.
-    std::optional<DepthRangeOffsets> depth_range_offsets;
+    std::optional<RangeOffsets> depth_range_offsets;
 
     /// Options used to map WGSL textureNumLevels/textureNumSamples builtins to internal uniform
     /// buffer values. If not specified, emits corresponding GLSL builtins
diff --git a/src/tint/lang/spirv/writer/ast_printer/BUILD.bazel b/src/tint/lang/spirv/writer/ast_printer/BUILD.bazel
index e04cdbe..7b21783 100644
--- a/src/tint/lang/spirv/writer/ast_printer/BUILD.bazel
+++ b/src/tint/lang/spirv/writer/ast_printer/BUILD.bazel
@@ -49,7 +49,6 @@
   ],
   deps = [
     "//src/tint/api/common",
-    "//src/tint/api/options",
     "//src/tint/lang/core",
     "//src/tint/lang/core/common",
     "//src/tint/lang/core/constant",
diff --git a/src/tint/lang/spirv/writer/ast_printer/BUILD.cmake b/src/tint/lang/spirv/writer/ast_printer/BUILD.cmake
index 63b7b79..5f4995e 100644
--- a/src/tint/lang/spirv/writer/ast_printer/BUILD.cmake
+++ b/src/tint/lang/spirv/writer/ast_printer/BUILD.cmake
@@ -50,7 +50,6 @@
 
 tint_target_add_dependencies(tint_lang_spirv_writer_ast_printer lib
   tint_api_common
-  tint_api_options
   tint_lang_core
   tint_lang_core_common
   tint_lang_core_constant
diff --git a/src/tint/lang/spirv/writer/ast_printer/BUILD.gn b/src/tint/lang/spirv/writer/ast_printer/BUILD.gn
index abd94d6..e9fc887 100644
--- a/src/tint/lang/spirv/writer/ast_printer/BUILD.gn
+++ b/src/tint/lang/spirv/writer/ast_printer/BUILD.gn
@@ -52,7 +52,6 @@
     ]
     deps = [
       "${tint_src_dir}/api/common",
-      "${tint_src_dir}/api/options",
       "${tint_src_dir}/lang/core",
       "${tint_src_dir}/lang/core/common",
       "${tint_src_dir}/lang/core/constant",
diff --git a/src/tint/lang/spirv/writer/ast_printer/ast_printer.cc b/src/tint/lang/spirv/writer/ast_printer/ast_printer.cc
index 6493419..f14a025 100644
--- a/src/tint/lang/spirv/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/spirv/writer/ast_printer/ast_printer.cc
@@ -29,7 +29,6 @@
 
 #include <unordered_map>
 
-#include "src/tint/api/options/depth_range_offsets.h"
 #include "src/tint/lang/spirv/writer/ast_raise/for_loop_to_loop.h"
 #include "src/tint/lang/spirv/writer/ast_raise/merge_return.h"
 #include "src/tint/lang/spirv/writer/ast_raise/var_for_dynamic_index.h"
@@ -70,7 +69,8 @@
 
     if (options.clamp_frag_depth) {
         manager.Add<ast::transform::ClampFragDepth>();
-        data.Add<ast::transform::ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+        data.Add<ast::transform::ClampFragDepth::Config>(
+            ast::transform::ClampFragDepth::RangeOffsets{0, 4});
     }
 
     manager.Add<ast::transform::DisableUniformityAnalysis>();
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.bazel b/src/tint/lang/wgsl/ast/transform/BUILD.bazel
index d9d9fb6..62bf03b 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.bazel
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.bazel
@@ -118,7 +118,6 @@
   ],
   deps = [
     "//src/tint/api/common",
-    "//src/tint/api/options",
     "//src/tint/lang/core",
     "//src/tint/lang/core/common",
     "//src/tint/lang/core/constant",
@@ -194,7 +193,6 @@
   ],
   deps = [
     "//src/tint/api/common",
-    "//src/tint/api/options",
     "//src/tint/lang/core",
     "//src/tint/lang/core/common",
     "//src/tint/lang/core/constant",
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.cmake b/src/tint/lang/wgsl/ast/transform/BUILD.cmake
index b5f91ea..440f54e 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.cmake
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.cmake
@@ -117,7 +117,6 @@
 
 tint_target_add_dependencies(tint_lang_wgsl_ast_transform lib
   tint_api_common
-  tint_api_options
   tint_lang_core
   tint_lang_core_common
   tint_lang_core_constant
@@ -195,7 +194,6 @@
 
 tint_target_add_dependencies(tint_lang_wgsl_ast_transform_test test
   tint_api_common
-  tint_api_options
   tint_lang_core
   tint_lang_core_common
   tint_lang_core_constant
@@ -282,7 +280,6 @@
 
 tint_target_add_dependencies(tint_lang_wgsl_ast_transform_fuzz fuzz
   tint_api_common
-  tint_api_options
   tint_lang_core
   tint_lang_core_common
   tint_lang_core_constant
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.gn b/src/tint/lang/wgsl/ast/transform/BUILD.gn
index b014cde..92c7ac8 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.gn
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.gn
@@ -121,7 +121,6 @@
   ]
   deps = [
     "${tint_src_dir}/api/common",
-    "${tint_src_dir}/api/options",
     "${tint_src_dir}/lang/core",
     "${tint_src_dir}/lang/core/common",
     "${tint_src_dir}/lang/core/constant",
@@ -196,7 +195,6 @@
       deps = [
         "${tint_src_dir}:gmock_and_gtest",
         "${tint_src_dir}/api/common",
-        "${tint_src_dir}/api/options",
         "${tint_src_dir}/lang/core",
         "${tint_src_dir}/lang/core/common",
         "${tint_src_dir}/lang/core/constant",
@@ -271,7 +269,6 @@
     ]
     deps = [
       "${tint_src_dir}/api/common",
-      "${tint_src_dir}/api/options",
       "${tint_src_dir}/lang/core",
       "${tint_src_dir}/lang/core/common",
       "${tint_src_dir}/lang/core/constant",
diff --git a/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.cc b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.cc
index 44c1118..1fad428 100644
--- a/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.cc
+++ b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.cc
@@ -222,7 +222,7 @@
 }
 
 ClampFragDepth::Config::Config() = default;
-ClampFragDepth::Config::Config(std::optional<tint::DepthRangeOffsets> off) : offsets(off) {}
+ClampFragDepth::Config::Config(std::optional<RangeOffsets> off) : offsets(off) {}
 
 ClampFragDepth::Config::~Config() = default;
 
diff --git a/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h
index 39a73f8..73ba6ff 100644
--- a/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h
+++ b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h
@@ -28,7 +28,6 @@
 #ifndef SRC_TINT_LANG_WGSL_AST_TRANSFORM_CLAMP_FRAG_DEPTH_H_
 #define SRC_TINT_LANG_WGSL_AST_TRANSFORM_CLAMP_FRAG_DEPTH_H_
 
-#include "src/tint/api/options/depth_range_offsets.h"
 #include "src/tint/lang/wgsl/ast/transform/transform.h"
 #include "src/tint/utils/reflection/reflection.h"
 
@@ -66,6 +65,16 @@
 /// ```
 class ClampFragDepth final : public Castable<ClampFragDepth, ast::transform::Transform> {
   public:
+    struct RangeOffsets {
+        /// The offset of the min_depth push constant
+        uint32_t min = 0;
+        /// The offset of the max_depth push constant
+        uint32_t max = 0;
+
+        /// Reflection for this struct
+        TINT_REFLECT(RangeOffsets, min, max);
+    };
+
     /// Constructor
     ClampFragDepth();
     /// Destructor
@@ -78,13 +87,13 @@
 
         /// Constructor
         /// @param off Offsets of the min_depth and max_depth push constants
-        explicit Config(std::optional<tint::DepthRangeOffsets> off);
+        explicit Config(std::optional<RangeOffsets> off);
 
         /// Destructor
         ~Config() override;
 
         /// Offsets of the min_depth and max_depth push constants
-        std::optional<tint::DepthRangeOffsets> offsets;
+        std::optional<RangeOffsets> offsets;
 
         /// Reflection for this struct
         TINT_REFLECT(Config, offsets);
diff --git a/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_test.cc b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_test.cc
index 027c19d..52c8eb3 100644
--- a/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_test.cc
+++ b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_test.cc
@@ -71,7 +71,7 @@
     )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{0, 4});
 
     EXPECT_TRUE(ShouldRun<ClampFragDepth>(src, config));
 }
@@ -119,7 +119,7 @@
 )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{4, 8});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{4, 8});
 
     auto got = Run<ClampFragDepth>(src, config);
     EXPECT_EQ(expect, str(got));
@@ -133,7 +133,7 @@
     )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{0, 4});
 
     EXPECT_TRUE(ShouldRun<ClampFragDepth>(src, config));
 }
@@ -151,7 +151,7 @@
     )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{0, 4});
 
     EXPECT_TRUE(ShouldRun<ClampFragDepth>(src, config));
 }
@@ -186,7 +186,7 @@
 )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{0, 4});
     auto got = Run<ClampFragDepth>(src, config);
     EXPECT_EQ(expect, str(got));
 }
@@ -227,7 +227,7 @@
 )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{0, 4});
     auto got = Run<ClampFragDepth>(src, config);
     EXPECT_EQ(expect, str(got));
 }
@@ -270,7 +270,7 @@
 )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{0, 4});
     auto got = Run<ClampFragDepth>(src, config);
     EXPECT_EQ(expect, str(got));
 }
@@ -318,7 +318,7 @@
 )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{0, 4});
     auto got = Run<ClampFragDepth>(src, config);
     EXPECT_EQ(expect, str(got));
 }
@@ -396,7 +396,7 @@
 )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{0, 4});
     auto got = Run<ClampFragDepth>(src, config);
     EXPECT_EQ(expect, str(got));
 }
@@ -456,7 +456,7 @@
 )";
 
     DataMap config;
-    config.Add<ClampFragDepth::Config>(tint::DepthRangeOffsets{0, 4});
+    config.Add<ClampFragDepth::Config>(ClampFragDepth::RangeOffsets{0, 4});
     auto got = Run<ClampFragDepth>(src, config);
     EXPECT_EQ(expect, str(got));
 }