mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
Remove internal usage of Context.
This CL removes all internal usage of the Context object. It is still accepted as a parameter until we update Dawn, but all usage is removed. The namer has been removed from the SPIR-V backend with this change and the emitted names reverted to their non-modified version. Change-Id: Ie6c550fab1807b558182cd7188ab6450a627f154 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34740 Commit-Queue: dan sinclair <dsinclair@chromium.org> Auto-Submit: dan sinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
573d8939f4
commit
685cb02ea8
@@ -49,9 +49,12 @@
|
||||
namespace tint {
|
||||
namespace transform {
|
||||
|
||||
BoundArrayAccessorsTransform::BoundArrayAccessorsTransform(Context* ctx,
|
||||
BoundArrayAccessorsTransform::BoundArrayAccessorsTransform(ast::Module* mod)
|
||||
: Transformer(mod) {}
|
||||
|
||||
BoundArrayAccessorsTransform::BoundArrayAccessorsTransform(Context*,
|
||||
ast::Module* mod)
|
||||
: Transformer(ctx, mod) {}
|
||||
: BoundArrayAccessorsTransform(mod) {}
|
||||
|
||||
BoundArrayAccessorsTransform::~BoundArrayAccessorsTransform() = default;
|
||||
|
||||
|
||||
@@ -35,9 +35,13 @@ namespace transform {
|
||||
class BoundArrayAccessorsTransform : public Transformer {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param mod the module transform
|
||||
explicit BoundArrayAccessorsTransform(ast::Module* mod);
|
||||
/// Constructor
|
||||
/// DEPRECATED
|
||||
/// @param ctx the Tint context object
|
||||
/// @param mod the module transform
|
||||
explicit BoundArrayAccessorsTransform(Context* ctx, ast::Module* mod);
|
||||
BoundArrayAccessorsTransform(Context* ctx, ast::Module* mod);
|
||||
~BoundArrayAccessorsTransform() override;
|
||||
|
||||
/// Users of Tint should register the transform with transform manager and
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "src/ast/uint_literal.h"
|
||||
#include "src/ast/variable.h"
|
||||
#include "src/ast/variable_decl_statement.h"
|
||||
#include "src/context.h"
|
||||
#include "src/transform/manager.h"
|
||||
#include "src/type_determiner.h"
|
||||
|
||||
@@ -50,12 +49,10 @@ namespace {
|
||||
|
||||
class BoundArrayAccessorsTest : public testing::Test {
|
||||
public:
|
||||
BoundArrayAccessorsTest() : td_(&ctx_, &mod_) {
|
||||
auto transform =
|
||||
std::make_unique<BoundArrayAccessorsTransform>(&ctx_, &mod_);
|
||||
BoundArrayAccessorsTest() : td_(&mod_) {
|
||||
auto transform = std::make_unique<BoundArrayAccessorsTransform>(&mod_);
|
||||
transform_ = transform.get();
|
||||
manager_ = std::make_unique<Manager>(&ctx_, &mod_);
|
||||
manager_->append(std::move(transform));
|
||||
manager_.append(std::move(transform));
|
||||
}
|
||||
|
||||
ast::BlockStatement* SetupFunctionAndBody() {
|
||||
@@ -74,7 +71,7 @@ class BoundArrayAccessorsTest : public testing::Test {
|
||||
|
||||
TypeDeterminer* td() { return &td_; }
|
||||
|
||||
Manager* manager() { return manager_.get(); }
|
||||
bool Run() { return manager_.Run(&mod_); }
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
@@ -86,11 +83,10 @@ class BoundArrayAccessorsTest : public testing::Test {
|
||||
}
|
||||
|
||||
private:
|
||||
Context ctx_;
|
||||
ast::Module mod_;
|
||||
TypeDeterminer td_;
|
||||
ast::type::Void void_type_;
|
||||
std::unique_ptr<Manager> manager_;
|
||||
Manager manager_;
|
||||
BoundArrayAccessorsTransform* transform_;
|
||||
ast::BlockStatement* body_ = nullptr;
|
||||
};
|
||||
@@ -128,7 +124,7 @@ TEST_F(BoundArrayAccessorsTest, Ptrs_Clamp) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::CallExpression>());
|
||||
|
||||
@@ -191,7 +187,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::CallExpression>());
|
||||
|
||||
@@ -268,7 +264,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
||||
@@ -316,7 +312,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::CallExpression>());
|
||||
|
||||
@@ -369,7 +365,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Negative) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
||||
@@ -408,7 +404,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_OutOfBounds) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
||||
@@ -447,7 +443,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
||||
@@ -495,7 +491,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::CallExpression>());
|
||||
|
||||
@@ -547,7 +543,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Negative) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
||||
@@ -586,7 +582,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_OutOfBounds) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
|
||||
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
||||
@@ -628,7 +624,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
|
||||
ASSERT_TRUE(ptr->array()->Is<ast::ArrayAccessorExpression>());
|
||||
@@ -692,7 +688,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
|
||||
ASSERT_TRUE(ptr->array()->Is<ast::ArrayAccessorExpression>());
|
||||
@@ -771,7 +767,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
|
||||
ASSERT_TRUE(ptr->array()->Is<ast::ArrayAccessorExpression>());
|
||||
@@ -839,7 +835,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
|
||||
ASSERT_TRUE(ptr->array()->Is<ast::ArrayAccessorExpression>());
|
||||
@@ -893,7 +889,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
|
||||
ASSERT_TRUE(ptr->array()->Is<ast::ArrayAccessorExpression>());
|
||||
@@ -948,7 +944,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
|
||||
ASSERT_TRUE(ptr->array()->Is<ast::ArrayAccessorExpression>());
|
||||
@@ -1003,7 +999,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) {
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ASSERT_TRUE(manager()->Run());
|
||||
ASSERT_TRUE(Run());
|
||||
ASSERT_TRUE(ptr->Is<ast::ArrayAccessorExpression>());
|
||||
|
||||
ASSERT_TRUE(ptr->array()->Is<ast::ArrayAccessorExpression>());
|
||||
|
||||
@@ -19,12 +19,19 @@
|
||||
namespace tint {
|
||||
namespace transform {
|
||||
|
||||
Manager::Manager(Context* context, ast::Module* module)
|
||||
: context_(context), module_(module) {}
|
||||
Manager::Manager() = default;
|
||||
|
||||
Manager::Manager(Context*, ast::Module* module) : module_(module) {}
|
||||
|
||||
Manager::~Manager() = default;
|
||||
|
||||
bool Manager::Run() {
|
||||
return Run(module_);
|
||||
}
|
||||
|
||||
bool Manager::Run(ast::Module* module) {
|
||||
error_ = "";
|
||||
|
||||
for (auto& transform : transforms_) {
|
||||
if (!transform->Run()) {
|
||||
error_ = transform->error();
|
||||
@@ -32,10 +39,10 @@ bool Manager::Run() {
|
||||
}
|
||||
}
|
||||
|
||||
if (context_ != nullptr && module_ != nullptr) {
|
||||
if (module != nullptr) {
|
||||
// The transformed have potentially inserted nodes into the AST, so the type
|
||||
// determinater needs to be run.
|
||||
TypeDeterminer td(context_, module_);
|
||||
TypeDeterminer td(module);
|
||||
if (!td.Determine()) {
|
||||
error_ = td.error();
|
||||
return false;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "src/context.h"
|
||||
#include "src/transform/transformer.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -31,6 +32,9 @@ namespace transform {
|
||||
class Manager {
|
||||
public:
|
||||
/// Constructor
|
||||
Manager();
|
||||
/// Constructor
|
||||
/// DEPRECATED
|
||||
/// @param context the tint context
|
||||
/// @param module the module to transform
|
||||
Manager(Context* context, ast::Module* module);
|
||||
@@ -43,6 +47,11 @@ class Manager {
|
||||
}
|
||||
|
||||
/// Runs the transforms
|
||||
/// @param module the module to run the transforms on
|
||||
/// @returns true on success; false otherwise
|
||||
bool Run(ast::Module* module);
|
||||
/// Runs the transforms
|
||||
/// DEPRECATED
|
||||
/// @returns true on success; false otherwise
|
||||
bool Run();
|
||||
|
||||
@@ -50,9 +59,8 @@ class Manager {
|
||||
std::string error() const { return error_; }
|
||||
|
||||
private:
|
||||
Context* context_;
|
||||
ast::Module* module_;
|
||||
std::vector<std::unique_ptr<Transformer>> transforms_;
|
||||
ast::Module* module_ = nullptr;
|
||||
|
||||
std::string error_;
|
||||
};
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
namespace tint {
|
||||
namespace transform {
|
||||
|
||||
Transformer::Transformer(Context* ctx, ast::Module* mod)
|
||||
: ctx_(ctx), mod_(mod) {}
|
||||
Transformer::Transformer(ast::Module* mod) : mod_(mod) {}
|
||||
|
||||
Transformer::~Transformer() = default;
|
||||
|
||||
|
||||
@@ -29,9 +29,8 @@ namespace transform {
|
||||
class Transformer {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param ctx the Tint context
|
||||
/// @param mod the module to transform
|
||||
Transformer(Context* ctx, ast::Module* mod);
|
||||
explicit Transformer(ast::Module* mod);
|
||||
virtual ~Transformer();
|
||||
|
||||
/// Users of Tint should register the transform with transform manager and
|
||||
@@ -53,8 +52,6 @@ class Transformer {
|
||||
return mod_->create<T>(std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// The context
|
||||
Context* ctx_ = nullptr;
|
||||
/// The module
|
||||
ast::Module* mod_ = nullptr;
|
||||
/// Any error messages, or blank if no error
|
||||
|
||||
@@ -52,8 +52,11 @@ static const char kDefaultInstanceIndexName[] = "_tint_pulling_instance_index";
|
||||
|
||||
} // namespace
|
||||
|
||||
VertexPullingTransform::VertexPullingTransform(Context* ctx, ast::Module* mod)
|
||||
: Transformer(ctx, mod) {}
|
||||
VertexPullingTransform::VertexPullingTransform(ast::Module* mod)
|
||||
: Transformer(mod) {}
|
||||
|
||||
VertexPullingTransform::VertexPullingTransform(Context*, ast::Module* mod)
|
||||
: VertexPullingTransform(mod) {}
|
||||
|
||||
VertexPullingTransform::~VertexPullingTransform() = default;
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "src/ast/module.h"
|
||||
#include "src/ast/statement.h"
|
||||
#include "src/ast/variable.h"
|
||||
#include "src/context.h"
|
||||
#include "src/transform/transformer.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -147,6 +146,10 @@ struct VertexStateDescriptor {
|
||||
class VertexPullingTransform : public Transformer {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param mod the module to convert to vertex pulling
|
||||
explicit VertexPullingTransform(ast::Module* mod);
|
||||
/// Constructor
|
||||
/// DEPRECATED
|
||||
/// @param ctx the tint context
|
||||
/// @param mod the module to convert to vertex pulling
|
||||
VertexPullingTransform(Context* ctx, ast::Module* mod);
|
||||
|
||||
Reference in New Issue
Block a user