mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 15:16:16 +00:00
ast: Replace NamedType with TypeDecl
TypeDecls (alias, structure) are not a types - they declare types. ast::TypeName is what's used for a ast::Type. Previously we were trying to automatically convert these to TypeNames in the builder, but having these inherit from ast::Type was extremely error prone. reader/spirv was actually constructing ast::Structs and using them as types, which is invalid. Change-Id: I05773ad6d488626606019015b84217a5a55a8e8a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53802 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
@@ -332,7 +332,7 @@ void InsertGlobal(CloneContext& ctx,
|
||||
}
|
||||
|
||||
/// @returns the unwrapped, user-declared constructed type of ty.
|
||||
const ast::NamedType* ConstructedTypeOf(const sem::Type* ty) {
|
||||
const ast::TypeDecl* ConstructedTypeOf(const sem::Type* ty) {
|
||||
while (true) {
|
||||
if (auto* ref = ty->As<sem::Reference>()) {
|
||||
ty = ref->StoreType();
|
||||
@@ -414,7 +414,7 @@ struct DecomposeStorageAccess::State {
|
||||
/// @param var_user the variable user
|
||||
/// @return the name of the function that performs the load
|
||||
Symbol LoadFunc(CloneContext& ctx,
|
||||
const ast::NamedType* insert_after,
|
||||
const ast::TypeDecl* insert_after,
|
||||
const sem::Type* buf_ty,
|
||||
const sem::Type* el_ty,
|
||||
const sem::VariableUser* var_user) {
|
||||
@@ -490,7 +490,7 @@ struct DecomposeStorageAccess::State {
|
||||
/// @param var_user the variable user
|
||||
/// @return the name of the function that performs the store
|
||||
Symbol StoreFunc(CloneContext& ctx,
|
||||
const ast::NamedType* insert_after,
|
||||
const ast::TypeDecl* insert_after,
|
||||
const sem::Type* buf_ty,
|
||||
const sem::Type* el_ty,
|
||||
const sem::VariableUser* var_user) {
|
||||
|
||||
@@ -133,14 +133,14 @@ Output FirstIndexOffset::Run(const Program* in, const DataMap& data) {
|
||||
instance_index_offset = offset;
|
||||
offset += 4;
|
||||
}
|
||||
auto* struct_type =
|
||||
auto* struct_ =
|
||||
ctx.dst->Structure(ctx.dst->Sym(), std::move(members),
|
||||
{ctx.dst->create<ast::StructBlockDecoration>()});
|
||||
|
||||
// Create a global to hold the uniform buffer
|
||||
Symbol buffer_name = ctx.dst->Sym();
|
||||
ctx.dst->Global(buffer_name, struct_type, ast::StorageClass::kUniform,
|
||||
nullptr,
|
||||
ctx.dst->Global(buffer_name, ctx.dst->ty.Of(struct_),
|
||||
ast::StorageClass::kUniform, nullptr,
|
||||
ast::DecorationList{
|
||||
ctx.dst->create<ast::BindingDecoration>(ub_binding),
|
||||
ctx.dst->create<ast::GroupDecoration>(ub_group),
|
||||
|
||||
@@ -69,7 +69,7 @@ Output SingleEntryPoint::Run(const Program* in, const DataMap& data) {
|
||||
// Clone any module-scope variables, types, and functions that are statically
|
||||
// referenced by the target entry point.
|
||||
for (auto* decl : in->AST().GlobalDeclarations()) {
|
||||
if (auto* ty = decl->As<ast::NamedType>()) {
|
||||
if (auto* ty = decl->As<ast::TypeDecl>()) {
|
||||
// TODO(jrprice): Strip unused types.
|
||||
out.AST().AddConstructedType(ctx.Clone(ty));
|
||||
} else if (auto* var = decl->As<ast::Variable>()) {
|
||||
|
||||
@@ -216,8 +216,8 @@ struct State {
|
||||
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
|
||||
// The decorated variable with struct type
|
||||
ctx.dst->Global(
|
||||
GetVertexBufferName(i), struct_type, ast::StorageClass::kStorage,
|
||||
ast::Access::kRead,
|
||||
GetVertexBufferName(i), ctx.dst->ty.Of(struct_type),
|
||||
ast::StorageClass::kStorage, ast::Access::kRead,
|
||||
ast::DecorationList{
|
||||
ctx.dst->create<ast::BindingDecoration>(i),
|
||||
ctx.dst->create<ast::GroupDecoration>(cfg.pulling_group),
|
||||
@@ -485,7 +485,8 @@ struct State {
|
||||
auto* new_struct = ctx.dst->Structure(ctx.dst->Sym(), new_members);
|
||||
|
||||
// Create a new function parameter with this struct.
|
||||
auto* new_param = ctx.dst->Param(ctx.dst->Sym(), new_struct);
|
||||
auto* new_param =
|
||||
ctx.dst->Param(ctx.dst->Sym(), ctx.dst->ty.Of(new_struct));
|
||||
new_function_parameters.push_back(new_param);
|
||||
|
||||
// Copy values from the new parameter to the function-scope variable.
|
||||
|
||||
Reference in New Issue
Block a user