mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 14:08:04 +00:00
[wgsl-reader] Add parsing of named structs.
This CL adds the parsing of structs with names. The parsing of type aliased structs remains to allow for migration to the new system. The named struct format is always emitted. Bug: tint:175 Change-Id: Ic0579dedbd2dd0edc7dfd30bc2ec02972091e718 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30341 Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
c9a3e47396
commit
7156d3e314
@@ -26,7 +26,6 @@
|
||||
#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"
|
||||
@@ -239,14 +238,13 @@ void VertexPullingTransform::AddVertexStorageBuffers() {
|
||||
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, alias));
|
||||
std::make_unique<ast::Variable>(GetVertexBufferName(i),
|
||||
ast::StorageClass::kStorageBuffer,
|
||||
struct_type));
|
||||
|
||||
// Add decorations
|
||||
ast::VariableDecorationList decorations;
|
||||
@@ -256,7 +254,7 @@ void VertexPullingTransform::AddVertexStorageBuffers() {
|
||||
|
||||
mod_->AddGlobalVariable(std::move(var));
|
||||
}
|
||||
mod_->AddAliasType(alias->AsAlias());
|
||||
mod_->AddConstructedType(struct_type);
|
||||
}
|
||||
|
||||
void VertexPullingTransform::AddVertexPullingPreamble(
|
||||
|
||||
@@ -136,8 +136,7 @@ TEST_F(VertexPullingTransformTest, OneAttribute) {
|
||||
EXPECT_TRUE(transform()->Run());
|
||||
|
||||
EXPECT_EQ(R"(Module{
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
TintVertexData Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
@@ -161,7 +160,7 @@ TEST_F(VertexPullingTransformTest, OneAttribute) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
__struct_TintVertexData
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -222,8 +221,7 @@ TEST_F(VertexPullingTransformTest, OneInstancedAttribute) {
|
||||
EXPECT_TRUE(transform()->Run());
|
||||
|
||||
EXPECT_EQ(R"(Module{
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
TintVertexData Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
@@ -247,7 +245,7 @@ TEST_F(VertexPullingTransformTest, OneInstancedAttribute) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
__struct_TintVertexData
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -308,8 +306,7 @@ TEST_F(VertexPullingTransformTest, OneAttributeDifferentOutputSet) {
|
||||
EXPECT_TRUE(transform()->Run());
|
||||
|
||||
EXPECT_EQ(R"(Module{
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
TintVertexData Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
@@ -333,7 +330,7 @@ TEST_F(VertexPullingTransformTest, OneAttributeDifferentOutputSet) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
__struct_TintVertexData
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -424,8 +421,7 @@ TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) {
|
||||
EXPECT_TRUE(transform()->Run());
|
||||
|
||||
EXPECT_EQ(R"(Module{
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
TintVertexData Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
@@ -462,7 +458,7 @@ TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
__struct_TintVertexData
|
||||
}
|
||||
DecoratedVariable{
|
||||
Decorations{
|
||||
@@ -471,7 +467,7 @@ TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_1
|
||||
storage_buffer
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
__struct_TintVertexData
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -565,8 +561,7 @@ TEST_F(VertexPullingTransformTest, TwoAttributesSameBuffer) {
|
||||
EXPECT_TRUE(transform()->Run());
|
||||
|
||||
EXPECT_EQ(R"(Module{
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
TintVertexData Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
@@ -595,7 +590,7 @@ TEST_F(VertexPullingTransformTest, TwoAttributesSameBuffer) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
__struct_TintVertexData
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
@@ -751,8 +746,7 @@ TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
|
||||
EXPECT_TRUE(transform()->Run());
|
||||
|
||||
EXPECT_EQ(R"(Module{
|
||||
TintVertexData -> __struct_TintVertexData
|
||||
Struct{
|
||||
TintVertexData Struct{
|
||||
[[block]]
|
||||
StructMember{[[ offset 0 ]] _tint_vertex_data: __array__u32_stride_4}
|
||||
}
|
||||
@@ -786,7 +780,7 @@ TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_0
|
||||
storage_buffer
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
__struct_TintVertexData
|
||||
}
|
||||
DecoratedVariable{
|
||||
Decorations{
|
||||
@@ -795,7 +789,7 @@ TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_1
|
||||
storage_buffer
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
__struct_TintVertexData
|
||||
}
|
||||
DecoratedVariable{
|
||||
Decorations{
|
||||
@@ -804,7 +798,7 @@ TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
|
||||
}
|
||||
_tint_pulling_vertex_buffer_2
|
||||
storage_buffer
|
||||
__alias_TintVertexData__struct_TintVertexData
|
||||
__struct_TintVertexData
|
||||
}
|
||||
Function main -> __void
|
||||
StageDecoration{vertex}
|
||||
|
||||
Reference in New Issue
Block a user