mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 05:57:51 +00:00
[ast] Require StructType to have a name
This CL moves the StructType name into the constructor of the struct type instead of receiving through an accessor. The |set_name| accessor is removed as it should not be needed anymore. All call sites have been updated. The vertex pulling transform was fixed to correctly register an alias for the structure being created so it will be emitted. Bug: tint:175 Change-Id: I8802931d9bdbc6c2f12982eea9032931939d195c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30280 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
53380f9ed7
commit
481ecff293
@@ -26,6 +26,7 @@
|
||||
#include "src/ast/struct_decoration.h"
|
||||
#include "src/ast/struct_member.h"
|
||||
#include "src/ast/struct_member_offset_decoration.h"
|
||||
#include "src/ast/type/alias_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/f32_type.h"
|
||||
#include "src/ast/type/i32_type.h"
|
||||
@@ -42,6 +43,7 @@ namespace {
|
||||
|
||||
static const char kVertexBufferNamePrefix[] = "_tint_pulling_vertex_buffer_";
|
||||
static const char kStructBufferName[] = "_tint_vertex_data";
|
||||
static const char kStructName[] = "TintVertexData";
|
||||
static const char kPullingPosVarName[] = "_tint_pulling_pos";
|
||||
static const char kDefaultVertexIndexName[] = "_tint_pulling_vertex_index";
|
||||
static const char kDefaultInstanceIndexName[] = "_tint_pulling_instance_index";
|
||||
@@ -235,14 +237,16 @@ void VertexPullingTransform::AddVertexStorageBuffers() {
|
||||
|
||||
auto* struct_type =
|
||||
ctx_->type_mgr().Get(std::make_unique<ast::type::StructType>(
|
||||
kStructName,
|
||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members))));
|
||||
auto* alias = ctx_->type_mgr().Get(
|
||||
std::make_unique<ast::type::AliasType>(kStructName, struct_type));
|
||||
|
||||
for (uint32_t i = 0; i < vertex_state_->vertex_buffers.size(); ++i) {
|
||||
// The decorated variable with struct type
|
||||
auto var = std::make_unique<ast::DecoratedVariable>(
|
||||
std::make_unique<ast::Variable>(GetVertexBufferName(i),
|
||||
ast::StorageClass::kStorageBuffer,
|
||||
struct_type));
|
||||
std::make_unique<ast::Variable>(
|
||||
GetVertexBufferName(i), ast::StorageClass::kStorageBuffer, alias));
|
||||
|
||||
// Add decorations
|
||||
ast::VariableDecorationList decorations;
|
||||
@@ -252,6 +256,7 @@ void VertexPullingTransform::AddVertexStorageBuffers() {
|
||||
|
||||
mod_->AddGlobalVariable(std::move(var));
|
||||
}
|
||||
mod_->AddAliasType(alias->AsAlias());
|
||||
}
|
||||
|
||||
void VertexPullingTransform::AddVertexPullingPreamble(
|
||||
|
||||
@@ -156,7 +156,12 @@ TEST_F(VertexPullingTransformTest, OneAttribute) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__struct_
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
}
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -237,7 +242,12 @@ TEST_F(VertexPullingTransformTest, OneInstancedAttribute) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__struct_
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
}
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -318,7 +328,12 @@ TEST_F(VertexPullingTransformTest, OneAttributeDifferentOutputSet) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__struct_
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
}
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -442,7 +457,7 @@ TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__struct_
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
}
|
||||
DecoratedVariable{
|
||||
Decorations{
|
||||
@@ -451,7 +466,12 @@ TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_1
|
||||
storage_buffer
|
||||
__struct_
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
}
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -570,7 +590,12 @@ TEST_F(VertexPullingTransformTest, TwoAttributesSameBuffer) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__struct_
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
}
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -756,7 +781,7 @@ TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__struct_
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
}
|
||||
DecoratedVariable{
|
||||
Decorations{
|
||||
@@ -765,7 +790,7 @@ TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_1
|
||||
storage_buffer
|
||||
__struct_
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
}
|
||||
DecoratedVariable{
|
||||
Decorations{
|
||||
@@ -774,7 +799,12 @@ TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_2
|
||||
storage_buffer
|
||||
__struct_
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
}
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
|
||||
Reference in New Issue
Block a user