Move ClampFragDepth transform to WGSL transforms.
This transform will be needed by the GLSL backend.
Change-Id: I6971d5e22c7b12581e4bed0608834a18943ad355
Bug: dawn:2185
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/171460
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
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 5e5055f..346f46d 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/lang/spirv/writer/ast_raise/clamp_frag_depth.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"
@@ -41,6 +40,7 @@
#include "src/tint/lang/wgsl/ast/transform/binding_remapper.h"
#include "src/tint/lang/wgsl/ast/transform/builtin_polyfill.h"
#include "src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.h"
+#include "src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h"
#include "src/tint/lang/wgsl/ast/transform/demote_to_helper.h"
#include "src/tint/lang/wgsl/ast/transform/direct_variable_access.h"
#include "src/tint/lang/wgsl/ast/transform/disable_uniformity_analysis.h"
@@ -65,7 +65,7 @@
ast::transform::DataMap data;
if (options.clamp_frag_depth) {
- manager.Add<ClampFragDepth>();
+ manager.Add<ast::transform::ClampFragDepth>();
}
manager.Add<ast::transform::DisableUniformityAnalysis>();
diff --git a/src/tint/lang/spirv/writer/ast_raise/BUILD.bazel b/src/tint/lang/spirv/writer/ast_raise/BUILD.bazel
index e13d946..275f6e5 100644
--- a/src/tint/lang/spirv/writer/ast_raise/BUILD.bazel
+++ b/src/tint/lang/spirv/writer/ast_raise/BUILD.bazel
@@ -39,7 +39,6 @@
cc_library(
name = "ast_raise",
srcs = [
- "clamp_frag_depth.cc",
"for_loop_to_loop.cc",
"merge_return.cc",
"var_for_dynamic_index.cc",
@@ -47,7 +46,6 @@
"while_to_loop.cc",
],
hdrs = [
- "clamp_frag_depth.h",
"for_loop_to_loop.h",
"merge_return.h",
"var_for_dynamic_index.h",
@@ -88,7 +86,6 @@
name = "test",
alwayslink = True,
srcs = [
- "clamp_frag_depth_test.cc",
"for_loop_to_loop_test.cc",
"merge_return_test.cc",
"var_for_dynamic_index_test.cc",
diff --git a/src/tint/lang/spirv/writer/ast_raise/BUILD.cmake b/src/tint/lang/spirv/writer/ast_raise/BUILD.cmake
index 9cd1d16..409ca99 100644
--- a/src/tint/lang/spirv/writer/ast_raise/BUILD.cmake
+++ b/src/tint/lang/spirv/writer/ast_raise/BUILD.cmake
@@ -41,8 +41,6 @@
# Condition: TINT_BUILD_SPV_WRITER
################################################################################
tint_add_target(tint_lang_spirv_writer_ast_raise lib
- lang/spirv/writer/ast_raise/clamp_frag_depth.cc
- lang/spirv/writer/ast_raise/clamp_frag_depth.h
lang/spirv/writer/ast_raise/for_loop_to_loop.cc
lang/spirv/writer/ast_raise/for_loop_to_loop.h
lang/spirv/writer/ast_raise/merge_return.cc
@@ -91,7 +89,6 @@
# Condition: TINT_BUILD_SPV_WRITER AND TINT_BUILD_WGSL_READER AND TINT_BUILD_WGSL_WRITER
################################################################################
tint_add_target(tint_lang_spirv_writer_ast_raise_test test
- lang/spirv/writer/ast_raise/clamp_frag_depth_test.cc
lang/spirv/writer/ast_raise/for_loop_to_loop_test.cc
lang/spirv/writer/ast_raise/merge_return_test.cc
lang/spirv/writer/ast_raise/var_for_dynamic_index_test.cc
diff --git a/src/tint/lang/spirv/writer/ast_raise/BUILD.gn b/src/tint/lang/spirv/writer/ast_raise/BUILD.gn
index b18ddb5..f24dbdd 100644
--- a/src/tint/lang/spirv/writer/ast_raise/BUILD.gn
+++ b/src/tint/lang/spirv/writer/ast_raise/BUILD.gn
@@ -44,8 +44,6 @@
if (tint_build_spv_writer) {
libtint_source_set("ast_raise") {
sources = [
- "clamp_frag_depth.cc",
- "clamp_frag_depth.h",
"for_loop_to_loop.cc",
"for_loop_to_loop.h",
"merge_return.cc",
@@ -91,7 +89,6 @@
tint_build_wgsl_writer) {
tint_unittests_source_set("unittests") {
sources = [
- "clamp_frag_depth_test.cc",
"for_loop_to_loop_test.cc",
"merge_return_test.cc",
"var_for_dynamic_index_test.cc",
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.bazel b/src/tint/lang/wgsl/ast/transform/BUILD.bazel
index cb9c9b1..4b1340a 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.bazel
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.bazel
@@ -45,6 +45,7 @@
"binding_remapper.cc",
"builtin_polyfill.cc",
"canonicalize_entry_point_io.cc",
+ "clamp_frag_depth.cc",
"data.cc",
"demote_to_helper.cc",
"direct_variable_access.cc",
@@ -79,6 +80,7 @@
"binding_remapper.h",
"builtin_polyfill.h",
"canonicalize_entry_point_io.h",
+ "clamp_frag_depth.h",
"data.h",
"demote_to_helper.h",
"direct_variable_access.h",
@@ -146,6 +148,7 @@
"binding_remapper_test.cc",
"builtin_polyfill_test.cc",
"canonicalize_entry_point_io_test.cc",
+ "clamp_frag_depth_test.cc",
"demote_to_helper_test.cc",
"direct_variable_access_test.cc",
"disable_uniformity_analysis_test.cc",
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.cmake b/src/tint/lang/wgsl/ast/transform/BUILD.cmake
index c432f09..11ddfaa 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.cmake
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.cmake
@@ -51,6 +51,8 @@
lang/wgsl/ast/transform/builtin_polyfill.h
lang/wgsl/ast/transform/canonicalize_entry_point_io.cc
lang/wgsl/ast/transform/canonicalize_entry_point_io.h
+ lang/wgsl/ast/transform/clamp_frag_depth.cc
+ lang/wgsl/ast/transform/clamp_frag_depth.h
lang/wgsl/ast/transform/data.cc
lang/wgsl/ast/transform/data.h
lang/wgsl/ast/transform/demote_to_helper.cc
@@ -146,6 +148,7 @@
lang/wgsl/ast/transform/binding_remapper_test.cc
lang/wgsl/ast/transform/builtin_polyfill_test.cc
lang/wgsl/ast/transform/canonicalize_entry_point_io_test.cc
+ lang/wgsl/ast/transform/clamp_frag_depth_test.cc
lang/wgsl/ast/transform/demote_to_helper_test.cc
lang/wgsl/ast/transform/direct_variable_access_test.cc
lang/wgsl/ast/transform/disable_uniformity_analysis_test.cc
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.gn b/src/tint/lang/wgsl/ast/transform/BUILD.gn
index 1214968..4632240 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.gn
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.gn
@@ -56,6 +56,8 @@
"builtin_polyfill.h",
"canonicalize_entry_point_io.cc",
"canonicalize_entry_point_io.h",
+ "clamp_frag_depth.cc",
+ "clamp_frag_depth.h",
"data.cc",
"data.h",
"demote_to_helper.cc",
@@ -147,6 +149,7 @@
"binding_remapper_test.cc",
"builtin_polyfill_test.cc",
"canonicalize_entry_point_io_test.cc",
+ "clamp_frag_depth_test.cc",
"demote_to_helper_test.cc",
"direct_variable_access_test.cc",
"disable_uniformity_analysis_test.cc",
diff --git a/src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth.cc b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.cc
similarity index 97%
rename from src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth.cc
rename to src/tint/lang/wgsl/ast/transform/clamp_frag_depth.cc
index 6683f18..c87fa15 100644
--- a/src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth.cc
+++ b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.cc
@@ -25,7 +25,7 @@
// 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.
-#include "src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth.h"
+#include "src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h"
#include <utility>
@@ -44,9 +44,9 @@
#include "src/tint/utils/containers/vector.h"
#include "src/tint/utils/macros/scoped_assignment.h"
-TINT_INSTANTIATE_TYPEINFO(tint::spirv::writer::ClampFragDepth);
+TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::ClampFragDepth);
-namespace tint::spirv::writer {
+namespace tint::ast::transform {
/// PIMPL state for the transform
struct ClampFragDepth::State {
@@ -242,4 +242,4 @@
return State{src}.Run();
}
-} // namespace tint::spirv::writer
+} // namespace tint::ast::transform
diff --git a/src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth.h b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h
similarity index 91%
rename from src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth.h
rename to src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h
index 521ba2e..5bcd3ea 100644
--- a/src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth.h
+++ b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h
@@ -25,12 +25,12 @@
// 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_LANG_SPIRV_WRITER_AST_RAISE_CLAMP_FRAG_DEPTH_H_
-#define SRC_TINT_LANG_SPIRV_WRITER_AST_RAISE_CLAMP_FRAG_DEPTH_H_
+#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/lang/wgsl/ast/transform/transform.h"
-namespace tint::spirv::writer {
+namespace tint::ast::transform {
/// Add clamping of the `@builtin(frag_depth)` output of fragment shaders using two push constants
/// provided by the outside environment. For example the following code:
@@ -78,6 +78,6 @@
struct State;
};
-} // namespace tint::spirv::writer
+} // namespace tint::ast::transform
-#endif // SRC_TINT_LANG_SPIRV_WRITER_AST_RAISE_CLAMP_FRAG_DEPTH_H_
+#endif // SRC_TINT_LANG_WGSL_AST_TRANSFORM_CLAMP_FRAG_DEPTH_H_
diff --git a/src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth_test.cc b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_test.cc
similarity index 98%
rename from src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth_test.cc
rename to src/tint/lang/wgsl/ast/transform/clamp_frag_depth_test.cc
index 9a71665..cc09c6f 100644
--- a/src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth_test.cc
+++ b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_test.cc
@@ -25,11 +25,11 @@
// 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.
-#include "src/tint/lang/spirv/writer/ast_raise/clamp_frag_depth.h"
+#include "src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h"
#include "src/tint/lang/wgsl/ast/transform/helper_test.h"
-namespace tint::spirv::writer {
+namespace tint::ast::transform {
namespace {
using ClampFragDepthTest = ast::transform::TransformTest;
@@ -391,4 +391,4 @@
}
} // namespace
-} // namespace tint::spirv::writer
+} // namespace tint::ast::transform