Remove legacy EmitVertexPointSize transform
This has been moved into the Spirv sanitizer, and Dawn is now using this path. Change-Id: Iffcbbc1c84e6bad0ebc51ded82d998bb307e2d6d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50564 Auto-Submit: James Price <jrprice@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
fe7f7b33fb
commit
77daee15bd
|
@ -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"
|
||||
|
|
|
@ -82,7 +82,6 @@ const char kUsage[] = R"(Usage: tint [options] <input-file>
|
|||
--transform <name list> -- 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<tint::transform::BoundArrayAccessors>();
|
||||
} else if (name == "emit_vertex_point_size") {
|
||||
transform_manager.Add<tint::transform::EmitVertexPointSize>();
|
||||
} else if (name == "first_index_offset") {
|
||||
transform_inputs.Add<tint::transform::FirstIndexOffset::BindingPoint>(0,
|
||||
0);
|
||||
|
@ -689,6 +686,7 @@ int main(int argc, const char** argv) {
|
|||
case Format::kSpirv:
|
||||
case Format::kSpvAsm:
|
||||
transform_manager.Add<tint::transform::Spirv>();
|
||||
transform_inputs.Add<tint::transform::Spirv::Config>(true);
|
||||
break;
|
||||
#endif // TINT_BUILD_SPV_WRITER
|
||||
#if TINT_BUILD_MSL_WRITER
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <utility>
|
||||
|
||||
#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
|
|
@ -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_
|
|
@ -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<f32> {
|
||||
var builtin_assignments_should_happen_before_this : f32;
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
fn non_entry_b() {
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[builtin(pointsize)]] var<out> tint_pointsize : f32;
|
||||
|
||||
fn non_entry_a() {
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry() -> [[builtin(position)]] vec4<f32> {
|
||||
tint_pointsize = 1.0;
|
||||
var builtin_assignments_should_happen_before_this : f32;
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
fn non_entry_b() {
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<EmitVertexPointSize>(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<EmitVertexPointSize>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(EmitVertexPointSizeTest, AttemptSymbolCollision) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn entry() -> [[builtin(position)]] vec4<f32> {
|
||||
var tint_pointsize : f32;
|
||||
return vec4<f32>();
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[builtin(pointsize)]] var<out> tint_pointsize_1 : f32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry() -> [[builtin(position)]] vec4<f32> {
|
||||
tint_pointsize_1 = 1.0;
|
||||
var tint_pointsize : f32;
|
||||
return vec4<f32>();
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<EmitVertexPointSize>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace transform
|
||||
} // namespace tint
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue