mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 14:08:04 +00:00
Add create<T>() method to Module for types
Migrate all uses to use this and the new `unique_type<T>()` and `types()` methods. Remove the `type_mgr()` accessor. `TypeManager` is now an implementation detail of the module, allowing us to unify the allocation of types and nodes (if we so wish). Fixes: tint:337 Bug: tint:307 Change-Id: I233fa9dc73d60515dd721f02ea7ba089ef7d374f Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33667 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
0fb5168fc7
commit
7e4ffa0064
@@ -237,7 +237,7 @@ bool BoundArrayAccessorsTransform::ProcessAccessExpression(
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
auto* u32 = mod_->type_mgr().Get(std::make_unique<ast::type::U32Type>());
|
||||
auto* u32 = mod_->create<ast::type::U32Type>();
|
||||
|
||||
ast::ExpressionList cast_expr;
|
||||
cast_expr.push_back(expr->idx_expr());
|
||||
|
||||
@@ -222,7 +222,7 @@ void VertexPullingTransform::AddVertexStorageBuffers() {
|
||||
ary_decos.push_back(create<ast::StrideDecoration>(4u, Source{}));
|
||||
internal_array->set_decorations(std::move(ary_decos));
|
||||
|
||||
auto* internal_array_type = mod_->type_mgr().Get(std::move(internal_array));
|
||||
auto* internal_array_type = mod_->unique_type(std::move(internal_array));
|
||||
|
||||
// Creating the struct type
|
||||
ast::StructMemberList members;
|
||||
@@ -235,10 +235,8 @@ void VertexPullingTransform::AddVertexStorageBuffers() {
|
||||
ast::StructDecorationList decos;
|
||||
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
||||
|
||||
auto* struct_type =
|
||||
mod_->type_mgr().Get(std::make_unique<ast::type::StructType>(
|
||||
kStructName,
|
||||
create<ast::Struct>(std::move(decos), std::move(members))));
|
||||
auto* struct_type = mod_->create<ast::type::StructType>(
|
||||
kStructName, create<ast::Struct>(std::move(decos), std::move(members)));
|
||||
|
||||
for (uint32_t i = 0; i < vertex_state_->vertex_buffers.size(); ++i) {
|
||||
// The decorated variable with struct type
|
||||
@@ -411,21 +409,20 @@ ast::Expression* VertexPullingTransform::AccessVec(uint32_t buffer,
|
||||
}
|
||||
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
mod_->type_mgr().Get(
|
||||
std::make_unique<ast::type::VectorType>(base_type, count)),
|
||||
mod_->create<ast::type::VectorType>(base_type, count),
|
||||
std::move(expr_list));
|
||||
}
|
||||
|
||||
ast::type::Type* VertexPullingTransform::GetU32Type() {
|
||||
return mod_->type_mgr().Get(std::make_unique<ast::type::U32Type>());
|
||||
return mod_->create<ast::type::U32Type>();
|
||||
}
|
||||
|
||||
ast::type::Type* VertexPullingTransform::GetI32Type() {
|
||||
return mod_->type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
||||
return mod_->create<ast::type::I32Type>();
|
||||
}
|
||||
|
||||
ast::type::Type* VertexPullingTransform::GetF32Type() {
|
||||
return mod_->type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
||||
return mod_->create<ast::type::F32Type>();
|
||||
}
|
||||
|
||||
VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor() = default;
|
||||
|
||||
@@ -46,10 +46,9 @@ class VertexPullingTransformHelper {
|
||||
|
||||
// Create basic module with an entry point and vertex function
|
||||
void InitBasicModule() {
|
||||
auto* func = create<ast::Function>(
|
||||
"main", ast::VariableList{},
|
||||
mod_->type_mgr().Get(std::make_unique<ast::type::VoidType>()),
|
||||
create<ast::BlockStatement>());
|
||||
auto* func = create<ast::Function>("main", ast::VariableList{},
|
||||
mod_->create<ast::type::VoidType>(),
|
||||
create<ast::BlockStatement>());
|
||||
func->add_decoration(
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex, Source{}));
|
||||
mod()->AddFunction(func);
|
||||
@@ -125,10 +124,9 @@ TEST_F(VertexPullingTransformTest, Error_InvalidEntryPoint) {
|
||||
}
|
||||
|
||||
TEST_F(VertexPullingTransformTest, Error_EntryPointWrongStage) {
|
||||
auto* func = create<ast::Function>(
|
||||
"main", ast::VariableList{},
|
||||
mod()->type_mgr().Get(std::make_unique<ast::type::VoidType>()),
|
||||
create<ast::BlockStatement>());
|
||||
auto* func = create<ast::Function>("main", ast::VariableList{},
|
||||
mod()->create<ast::type::VoidType>(),
|
||||
create<ast::BlockStatement>());
|
||||
func->add_decoration(
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}));
|
||||
mod()->AddFunction(func);
|
||||
|
||||
Reference in New Issue
Block a user