diff --git a/include/tint/tint.h b/include/tint/tint.h index 4f61086bcd..ff1991e76b 100644 --- a/include/tint/tint.h +++ b/include/tint/tint.h @@ -26,7 +26,6 @@ #include "src/sem/type_manager.h" #include "src/transform/binding_remapper.h" #include "src/transform/bound_array_accessors.h" -#include "src/transform/emit_vertex_point_size.h" #include "src/transform/first_index_offset.h" #include "src/transform/manager.h" #include "src/transform/renamer.h" diff --git a/samples/main.cc b/samples/main.cc index 5346d7274f..98797bd207 100644 --- a/samples/main.cc +++ b/samples/main.cc @@ -82,7 +82,6 @@ const char kUsage[] = R"(Usage: tint [options] --transform -- Runs transforms, name list is comma separated Available transforms: bound_array_accessors - emit_vertex_point_size first_index_offset renamer --parse-only -- Stop after parsing the input @@ -663,8 +662,6 @@ int main(int argc, const char** argv) { if (name == "bound_array_accessors") { transform_manager.Add(); - } else if (name == "emit_vertex_point_size") { - transform_manager.Add(); } else if (name == "first_index_offset") { transform_inputs.Add(0, 0); @@ -689,6 +686,7 @@ int main(int argc, const char** argv) { case Format::kSpirv: case Format::kSpvAsm: transform_manager.Add(); + transform_inputs.Add(true); break; #endif // TINT_BUILD_SPV_WRITER #if TINT_BUILD_MSL_WRITER diff --git a/src/BUILD.gn b/src/BUILD.gn index fc6835f4d2..1c69ee82d7 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -509,8 +509,6 @@ libtint_source_set("libtint_core_all_src") { "transform/canonicalize_entry_point_io.h", "transform/decompose_storage_access.cc", "transform/decompose_storage_access.h", - "transform/emit_vertex_point_size.cc", - "transform/emit_vertex_point_size.h", "transform/external_texture_transform.cc", "transform/external_texture_transform.h", "transform/first_index_offset.cc", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70b691df6f..7024c3282f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -269,8 +269,6 @@ set(TINT_LIB_SRCS transform/canonicalize_entry_point_io.h transform/decompose_storage_access.cc transform/decompose_storage_access.h - transform/emit_vertex_point_size.cc - transform/emit_vertex_point_size.h transform/external_texture_transform.cc transform/external_texture_transform.h transform/first_index_offset.cc @@ -796,7 +794,6 @@ if(${TINT_BUILD_TESTS}) transform/calculate_array_length_test.cc transform/canonicalize_entry_point_io_test.cc transform/decompose_storage_access_test.cc - transform/emit_vertex_point_size_test.cc transform/external_texture_transform_test.cc transform/first_index_offset_test.cc transform/renamer_test.cc diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc deleted file mode 100644 index 9854149be8..0000000000 --- a/src/transform/emit_vertex_point_size.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/transform/emit_vertex_point_size.h" - -#include - -#include "src/ast/assignment_statement.h" -#include "src/program_builder.h" - -namespace tint { -namespace transform { - -EmitVertexPointSize::EmitVertexPointSize() = default; -EmitVertexPointSize::~EmitVertexPointSize() = default; - -Output EmitVertexPointSize::Run(const Program* in, const DataMap&) { - if (!in->AST().Functions().HasStage(ast::PipelineStage::kVertex)) { - // If the module doesn't have any vertex stages, then there's nothing to do. - return Output(Program(in->Clone())); - } - - ProgramBuilder out; - - CloneContext ctx(&out, in); - - Symbol pointsize = out.Symbols().New("tint_pointsize"); - - // Declare the pointsize builtin output variable. - out.Global(pointsize, out.ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::DecorationList{ - out.Builtin(ast::Builtin::kPointSize), - }); - - // Add the pointsize assignment statement to the front of all vertex stages. - ctx.ReplaceAll([&](ast::Function* func) -> ast::Function* { - if (func->pipeline_stage() != ast::PipelineStage::kVertex) { - return nullptr; // Just clone func - } - - return CloneWithStatementsAtStart(&ctx, func, - { - out.Assign(pointsize, 1.0f), - }); - }); - ctx.Clone(); - - return Output(Program(std::move(out))); -} - -} // namespace transform -} // namespace tint diff --git a/src/transform/emit_vertex_point_size.h b/src/transform/emit_vertex_point_size.h deleted file mode 100644 index 40bcc19856..0000000000 --- a/src/transform/emit_vertex_point_size.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef SRC_TRANSFORM_EMIT_VERTEX_POINT_SIZE_H_ -#define SRC_TRANSFORM_EMIT_VERTEX_POINT_SIZE_H_ - -#include "src/transform/transform.h" - -namespace tint { -namespace transform { - -/// DEPRECATED: This should now be performed using the SPIR-V sanitizer. -/// EmitVertexPointSize is a Transform that adds a PointSize builtin global -/// output variable to the program which is assigned 1.0 as the new first -/// statement for all vertex stage entry points. -/// If the program does not contain a vertex pipeline stage entry point then -/// then this transform is a no-op. -class EmitVertexPointSize : public Transform { - public: - /// Constructor - EmitVertexPointSize(); - /// Destructor - ~EmitVertexPointSize() override; - - /// Runs the transform on `program`, returning the transformation result. - /// @param program the source program to transform - /// @param data optional extra transform-specific input data - /// @returns the transformation result - Output Run(const Program* program, const DataMap& data = {}) override; -}; - -} // namespace transform -} // namespace tint - -#endif // SRC_TRANSFORM_EMIT_VERTEX_POINT_SIZE_H_ diff --git a/src/transform/emit_vertex_point_size_test.cc b/src/transform/emit_vertex_point_size_test.cc deleted file mode 100644 index f420115a3e..0000000000 --- a/src/transform/emit_vertex_point_size_test.cc +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/transform/emit_vertex_point_size.h" - -#include "src/transform/test_helper.h" - -namespace tint { -namespace transform { -namespace { - -using EmitVertexPointSizeTest = TransformTest; - -TEST_F(EmitVertexPointSizeTest, VertexStageBasic) { - auto* src = R"( -fn non_entry_a() { -} - -[[stage(vertex)]] -fn entry() -> [[builtin(position)]] vec4 { - var builtin_assignments_should_happen_before_this : f32; - return vec4(); -} - -fn non_entry_b() { -} -)"; - - auto* expect = R"( -[[builtin(pointsize)]] var tint_pointsize : f32; - -fn non_entry_a() { -} - -[[stage(vertex)]] -fn entry() -> [[builtin(position)]] vec4 { - tint_pointsize = 1.0; - var builtin_assignments_should_happen_before_this : f32; - return vec4(); -} - -fn non_entry_b() { -} -)"; - - auto got = Run(src); - - EXPECT_EQ(expect, str(got)); -} - -TEST_F(EmitVertexPointSizeTest, NonVertexStage) { - auto* src = R"( -[[stage(fragment)]] -fn fragment_entry() { -} - -[[stage(compute)]] -fn compute_entry() { -} -)"; - - auto* expect = R"( -[[stage(fragment)]] -fn fragment_entry() { -} - -[[stage(compute)]] -fn compute_entry() { -} -)"; - - auto got = Run(src); - - EXPECT_EQ(expect, str(got)); -} - -TEST_F(EmitVertexPointSizeTest, AttemptSymbolCollision) { - auto* src = R"( -[[stage(vertex)]] -fn entry() -> [[builtin(position)]] vec4 { - var tint_pointsize : f32; - return vec4(); -} -)"; - - auto* expect = R"( -[[builtin(pointsize)]] var tint_pointsize_1 : f32; - -[[stage(vertex)]] -fn entry() -> [[builtin(position)]] vec4 { - tint_pointsize_1 = 1.0; - var tint_pointsize : f32; - return vec4(); -} -)"; - - auto got = Run(src); - - EXPECT_EQ(expect, str(got)); -} - -} // namespace -} // namespace transform -} // namespace tint diff --git a/test/BUILD.gn b/test/BUILD.gn index ca6b446428..4f6bf1175e 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -295,7 +295,6 @@ tint_unittests_source_set("tint_unittests_core_src") { "../src/transform/calculate_array_length_test.cc", "../src/transform/canonicalize_entry_point_io_test.cc", "../src/transform/decompose_storage_access_test.cc", - "../src/transform/emit_vertex_point_size_test.cc", "../src/transform/external_texture_transform_test.cc", "../src/transform/first_index_offset_test.cc", "../src/transform/renamer_test.cc",