Remove @block attribute

Since this was the only attribute allowed on structures, we can also
remove the parsing code for them. However, we still need to have
attributes on the struct AST node, since the AddSpirvBlockAttribute
transform adds one.

Fixed: tint:1324
Change-Id: I7966237765b1d8a58c59908b59e1f1152a8a0439
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/83740
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price 2022-03-21 16:09:17 +00:00
parent 3b00139439
commit 8bcecf365d
61 changed files with 403 additions and 1045 deletions

View File

@ -1,5 +1,11 @@
# Tint changes during Origin Trial # Tint changes during Origin Trial
## Changes for M102
### Breaking changes
* The `@block` attribute has been removed. [tint:1324](crbug.com/tint/1324)
## Changes for M101 ## Changes for M101
### New Features ### New Features

View File

@ -298,8 +298,6 @@ libtint_source_set("libtint_core_all_src") {
"ast/stride_attribute.h", "ast/stride_attribute.h",
"ast/struct.cc", "ast/struct.cc",
"ast/struct.h", "ast/struct.h",
"ast/struct_block_attribute.cc",
"ast/struct_block_attribute.h",
"ast/struct_member.cc", "ast/struct_member.cc",
"ast/struct_member.h", "ast/struct_member.h",
"ast/struct_member_align_attribute.cc", "ast/struct_member_align_attribute.cc",

View File

@ -182,8 +182,6 @@ set(TINT_LIB_SRCS
ast/storage_texture.h ast/storage_texture.h
ast/stride_attribute.cc ast/stride_attribute.cc
ast/stride_attribute.h ast/stride_attribute.h
ast/struct_block_attribute.cc
ast/struct_block_attribute.h
ast/struct_member_align_attribute.cc ast/struct_member_align_attribute.cc
ast/struct_member_align_attribute.h ast/struct_member_align_attribute.h
ast/struct_member_offset_attribute.cc ast/struct_member_offset_attribute.cc
@ -909,7 +907,6 @@ if(TINT_BUILD_TESTS)
reader/wgsl/parser_impl_struct_body_decl_test.cc reader/wgsl/parser_impl_struct_body_decl_test.cc
reader/wgsl/parser_impl_struct_decl_test.cc reader/wgsl/parser_impl_struct_decl_test.cc
reader/wgsl/parser_impl_struct_attribute_decl_test.cc reader/wgsl/parser_impl_struct_attribute_decl_test.cc
reader/wgsl/parser_impl_struct_attribute_test.cc
reader/wgsl/parser_impl_struct_member_attribute_decl_test.cc reader/wgsl/parser_impl_struct_member_attribute_decl_test.cc
reader/wgsl/parser_impl_struct_member_attribute_test.cc reader/wgsl/parser_impl_struct_member_attribute_test.cc
reader/wgsl/parser_impl_struct_member_test.cc reader/wgsl/parser_impl_struct_member_test.cc

View File

@ -26,14 +26,13 @@ TEST(ModuleCloneTest, Clone) {
#if TINT_BUILD_WGSL_READER && TINT_BUILD_WGSL_WRITER #if TINT_BUILD_WGSL_READER && TINT_BUILD_WGSL_WRITER
// Shader that exercises the bulk of the AST nodes and types. // Shader that exercises the bulk of the AST nodes and types.
// See also fuzzers/tint_ast_clone_fuzzer.cc for further coverage of cloning. // See also fuzzers/tint_ast_clone_fuzzer.cc for further coverage of cloning.
Source::File file("test.wgsl", R"([[block]] Source::File file("test.wgsl", R"(struct S0 {
struct S0 {
@size(4) @size(4)
m0 : u32; m0 : u32;
m1 : array<u32>; m1 : array<u32>;
}; };
[[block]] struct S1 { struct S1 {
@size(4) @size(4)
m0 : u32; m0 : u32;
m1 : array<u32, 6>; m1 : array<u32, 6>;

View File

@ -16,7 +16,6 @@
#include <string> #include <string>
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
TINT_INSTANTIATE_TYPEINFO(tint::ast::Struct); TINT_INSTANTIATE_TYPEINFO(tint::ast::Struct);

View File

@ -1,43 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include <string>
#include "src/tint/program_builder.h"
TINT_INSTANTIATE_TYPEINFO(tint::ast::StructBlockAttribute);
namespace tint {
namespace ast {
StructBlockAttribute::StructBlockAttribute(ProgramID pid, const Source& src)
: Base(pid, src) {}
StructBlockAttribute::~StructBlockAttribute() = default;
std::string StructBlockAttribute::Name() const {
return "block";
}
const StructBlockAttribute* StructBlockAttribute::Clone(
CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto src = ctx->Clone(source);
return ctx->dst->create<StructBlockAttribute>(src);
}
} // namespace ast
} // namespace tint

View File

@ -1,49 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_TINT_AST_STRUCT_BLOCK_ATTRIBUTE_H_
#define SRC_TINT_AST_STRUCT_BLOCK_ATTRIBUTE_H_
#include <string>
#include <vector>
#include "src/tint/ast/attribute.h"
namespace tint {
namespace ast {
/// The struct block attribute
class StructBlockAttribute final
: public Castable<StructBlockAttribute, Attribute> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param src the source of this node
StructBlockAttribute(ProgramID pid, const Source& src);
~StructBlockAttribute() override;
/// @returns the WGSL name for the attribute
std::string Name() const override;
/// Clones this node and all transitive child nodes using the `CloneContext`
/// `ctx`.
/// @param ctx the clone context
/// @return the newly cloned node
const StructBlockAttribute* Clone(CloneContext* ctx) const override;
};
} // namespace ast
} // namespace tint
#endif // SRC_TINT_AST_STRUCT_BLOCK_ATTRIBUTE_H_

View File

@ -22,17 +22,19 @@
#include "src/tint/ast/matrix.h" #include "src/tint/ast/matrix.h"
#include "src/tint/ast/pointer.h" #include "src/tint/ast/pointer.h"
#include "src/tint/ast/sampler.h" #include "src/tint/ast/sampler.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/test_helper.h" #include "src/tint/ast/test_helper.h"
#include "src/tint/ast/texture.h" #include "src/tint/ast/texture.h"
#include "src/tint/ast/u32.h" #include "src/tint/ast/u32.h"
#include "src/tint/ast/vector.h" #include "src/tint/ast/vector.h"
#include "src/tint/transform/add_spirv_block_attribute.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using AstStructTest = TestHelper; using AstStructTest = TestHelper;
using SpirvBlockAttribute =
transform::AddSpirvBlockAttribute::SpirvBlockAttribute;
TEST_F(AstStructTest, Creation) { TEST_F(AstStructTest, Creation) {
auto name = Sym("s"); auto name = Sym("s");
@ -50,14 +52,14 @@ TEST_F(AstStructTest, Creation) {
TEST_F(AstStructTest, Creation_WithAttributes) { TEST_F(AstStructTest, Creation_WithAttributes) {
auto name = Sym("s"); auto name = Sym("s");
AttributeList attrs; AttributeList attrs;
attrs.push_back(create<StructBlockAttribute>()); attrs.push_back(ASTNodes().Create<SpirvBlockAttribute>(ID()));
auto* s = auto* s =
create<Struct>(name, StructMemberList{Member("a", ty.i32())}, attrs); create<Struct>(name, StructMemberList{Member("a", ty.i32())}, attrs);
EXPECT_EQ(s->name, name); EXPECT_EQ(s->name, name);
EXPECT_EQ(s->members.size(), 1u); EXPECT_EQ(s->members.size(), 1u);
ASSERT_EQ(s->attributes.size(), 1u); ASSERT_EQ(s->attributes.size(), 1u);
EXPECT_TRUE(s->attributes[0]->Is<StructBlockAttribute>()); EXPECT_TRUE(s->attributes[0]->Is<SpirvBlockAttribute>());
EXPECT_EQ(s->source.range.begin.line, 0u); EXPECT_EQ(s->source.range.begin.line, 0u);
EXPECT_EQ(s->source.range.begin.column, 0u); EXPECT_EQ(s->source.range.begin.column, 0u);
EXPECT_EQ(s->source.range.end.line, 0u); EXPECT_EQ(s->source.range.end.line, 0u);
@ -69,11 +71,11 @@ TEST_F(AstStructTest, CreationWithSourceAndAttributes) {
auto* s = create<Struct>( auto* s = create<Struct>(
Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}}, Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}},
name, StructMemberList{Member("a", ty.i32())}, name, StructMemberList{Member("a", ty.i32())},
AttributeList{create<StructBlockAttribute>()}); AttributeList{ASTNodes().Create<SpirvBlockAttribute>(ID())});
EXPECT_EQ(s->name, name); EXPECT_EQ(s->name, name);
EXPECT_EQ(s->members.size(), 1u); EXPECT_EQ(s->members.size(), 1u);
ASSERT_EQ(s->attributes.size(), 1u); ASSERT_EQ(s->attributes.size(), 1u);
EXPECT_TRUE(s->attributes[0]->Is<StructBlockAttribute>()); EXPECT_TRUE(s->attributes[0]->Is<SpirvBlockAttribute>());
EXPECT_EQ(s->source.range.begin.line, 27u); EXPECT_EQ(s->source.range.begin.line, 27u);
EXPECT_EQ(s->source.range.begin.column, 4u); EXPECT_EQ(s->source.range.begin.column, 4u);
EXPECT_EQ(s->source.range.end.line, 27u); EXPECT_EQ(s->source.range.end.line, 27u);
@ -119,9 +121,9 @@ TEST_F(AstStructTest, Assert_DifferentProgramID_Attribute) {
{ {
ProgramBuilder b1; ProgramBuilder b1;
ProgramBuilder b2; ProgramBuilder b2;
b1.create<Struct>(b1.Sym("S"), b1.create<Struct>(
StructMemberList{b1.Member("a", b1.ty.i32())}, b1.Sym("S"), StructMemberList{b1.Member("a", b1.ty.i32())},
AttributeList{b2.create<StructBlockAttribute>()}); AttributeList{b2.ASTNodes().Create<SpirvBlockAttribute>(b2.ID())});
}, },
"internal compiler error"); "internal compiler error");
} }

View File

@ -17,7 +17,6 @@
#include "src/tint/ast/disable_validation_attribute.h" #include "src/tint/ast/disable_validation_attribute.h"
#include "src/tint/ast/id_attribute.h" #include "src/tint/ast/id_attribute.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/workgroup_attribute.h" #include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/inspector/test_inspector_builder.h" #include "src/tint/inspector/test_inspector_builder.h"
#include "src/tint/inspector/test_inspector_runner.h" #include "src/tint/inspector/test_inspector_runner.h"
@ -764,7 +763,7 @@ TEST_F(InspectorGetEntryPointTest, InputSampleMaskStructReferenced) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back( members.push_back(
Member("inner_position", ty.u32(), {Builtin(ast::Builtin::kSampleMask)})); Member("inner_position", ty.u32(), {Builtin(ast::Builtin::kSampleMask)}));
Structure("in_struct", members, {}); Structure("in_struct", members);
auto* in_var = Param("in_var", ty.type_name("in_struct"), {}); auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
Func("ep_func", {in_var}, ty.void_(), {Return()}, Func("ep_func", {in_var}, ty.void_(), {Return()},
@ -797,7 +796,7 @@ TEST_F(InspectorGetEntryPointTest, OutputSampleMaskStructReferenced) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(Member("inner_sample_mask", ty.u32(), members.push_back(Member("inner_sample_mask", ty.u32(),
{Builtin(ast::Builtin::kSampleMask)})); {Builtin(ast::Builtin::kSampleMask)}));
Structure("out_struct", members, {}); Structure("out_struct", members);
Func("ep_func", {}, ty.type_name("out_struct"), Func("ep_func", {}, ty.type_name("out_struct"),
{Decl(Var("out_var", ty.type_name("out_struct"))), Return("out_var")}, {Decl(Var("out_var", ty.type_name("out_struct"))), Return("out_var")},
@ -829,7 +828,7 @@ TEST_F(InspectorGetEntryPointTest, InputPositionStructReferenced) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(Member("inner_position", ty.vec4<f32>(), members.push_back(Member("inner_position", ty.vec4<f32>(),
{Builtin(ast::Builtin::kPosition)})); {Builtin(ast::Builtin::kPosition)}));
Structure("in_struct", members, {}); Structure("in_struct", members);
auto* in_var = Param("in_var", ty.type_name("in_struct"), {}); auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
Func("ep_func", {in_var}, ty.void_(), {Return()}, Func("ep_func", {in_var}, ty.void_(), {Return()},
@ -861,7 +860,7 @@ TEST_F(InspectorGetEntryPointTest, FrontFacingStructReferenced) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(Member("inner_position", ty.bool_(), members.push_back(Member("inner_position", ty.bool_(),
{Builtin(ast::Builtin::kFrontFacing)})); {Builtin(ast::Builtin::kFrontFacing)}));
Structure("in_struct", members, {}); Structure("in_struct", members);
auto* in_var = Param("in_var", ty.type_name("in_struct"), {}); auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
Func("ep_func", {in_var}, ty.void_(), {Return()}, Func("ep_func", {in_var}, ty.void_(), {Return()},
@ -893,7 +892,7 @@ TEST_F(InspectorGetEntryPointTest, SampleIndexStructReferenced) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(Member("inner_position", ty.u32(), members.push_back(Member("inner_position", ty.u32(),
{Builtin(ast::Builtin::kSampleIndex)})); {Builtin(ast::Builtin::kSampleIndex)}));
Structure("in_struct", members, {}); Structure("in_struct", members);
auto* in_var = Param("in_var", ty.type_name("in_struct"), {}); auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
Func("ep_func", {in_var}, ty.void_(), {Return()}, Func("ep_func", {in_var}, ty.void_(), {Return()},
@ -925,7 +924,7 @@ TEST_F(InspectorGetEntryPointTest, NumWorkgroupsStructReferenced) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(Member("inner_position", ty.vec3<u32>(), members.push_back(Member("inner_position", ty.vec3<u32>(),
{Builtin(ast::Builtin::kNumWorkgroups)})); {Builtin(ast::Builtin::kNumWorkgroups)}));
Structure("in_struct", members, {}); Structure("in_struct", members);
auto* in_var = Param("in_var", ty.type_name("in_struct"), {}); auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
Func("ep_func", {in_var}, ty.void_(), {Return()}, Func("ep_func", {in_var}, ty.void_(), {Return()},
@ -942,7 +941,7 @@ TEST_F(InspectorGetEntryPointTest, NumWorkgroupsStructReferenced) {
TEST_F(InspectorGetEntryPointTest, ImplicitInterpolate) { TEST_F(InspectorGetEntryPointTest, ImplicitInterpolate) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(Member("struct_inner", ty.f32(), {Location(0)})); members.push_back(Member("struct_inner", ty.f32(), {Location(0)}));
Structure("in_struct", members, {}); Structure("in_struct", members);
auto* in_var = Param("in_var", ty.type_name("in_struct"), {}); auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
Func("ep_func", {in_var}, ty.void_(), {Return()}, Func("ep_func", {in_var}, ty.void_(), {Return()},
@ -966,7 +965,7 @@ TEST_P(InspectorGetEntryPointInterpolateTest, Test) {
members.push_back( members.push_back(
Member("struct_inner", ty.f32(), Member("struct_inner", ty.f32(),
{Interpolate(params.in_type, params.in_sampling), Location(0)})); {Interpolate(params.in_type, params.in_sampling), Location(0)}));
Structure("in_struct", members, {}); Structure("in_struct", members);
auto* in_var = Param("in_var", ty.type_name("in_struct"), {}); auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
Func("ep_func", {in_var}, ty.void_(), {Return()}, Func("ep_func", {in_var}, ty.void_(), {Return()},
@ -1548,8 +1547,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
auto* foo_struct_type = Structure( auto* foo_struct_type = Structure(
"foo_type", "foo_type",
{Member("0i32", ty.i32()), {Member("0i32", ty.i32()),
Member("b", ty.array(ty.u32(), 4, /*stride*/ 16), {MemberAlign(16)})}, Member("b", ty.array(ty.u32(), 4, /*stride*/ 16), {MemberAlign(16)})});
{create<ast::StructBlockAttribute>()});
AddUniformBuffer("foo_ub", ty.Of(foo_struct_type), 0, 0); AddUniformBuffer("foo_ub", ty.Of(foo_struct_type), 0, 0);
@ -2948,8 +2946,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, CompoundTypes) {
// This struct should occupy 68 bytes. 4 from the i32 field, and another 64 // This struct should occupy 68 bytes. 4 from the i32 field, and another 64
// from the 4-element array with 16-byte stride. // from the 4-element array with 16-byte stride.
auto* wg_struct_type = MakeStructType( auto* wg_struct_type = MakeStructType(
"WgStruct", {ty.i32(), ty.array(ty.i32(), 4, /*stride=*/16)}, "WgStruct", {ty.i32(), ty.array(ty.i32(), 4, /*stride=*/16)});
/*is_block=*/false);
AddWorkgroupStorage("wg_struct_var", ty.Of(wg_struct_type)); AddWorkgroupStorage("wg_struct_var", ty.Of(wg_struct_type));
MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var", MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var",
{{0, ty.i32()}}); {{0, ty.i32()}});
@ -2992,8 +2989,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, StructAlignment) {
const auto* wg_struct_type = MakeStructTypeFromMembers( const auto* wg_struct_type = MakeStructTypeFromMembers(
"WgStruct", "WgStruct",
{MakeStructMember(0, ty.f32(), {MakeStructMember(0, ty.f32(),
{create<ast::StructMemberAlignAttribute>(1024)})}, {create<ast::StructMemberAlignAttribute>(1024)})});
/*is_block=*/false);
AddWorkgroupStorage("wg_struct_var", ty.Of(wg_struct_type)); AddWorkgroupStorage("wg_struct_var", ty.Of(wg_struct_type));
MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var", MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var",

View File

@ -91,24 +91,18 @@ std::string InspectorBuilder::StructMemberName(size_t idx,
const ast::Struct* InspectorBuilder::MakeStructType( const ast::Struct* InspectorBuilder::MakeStructType(
const std::string& name, const std::string& name,
std::vector<const ast::Type*> member_types, std::vector<const ast::Type*> member_types) {
bool is_block) {
ast::StructMemberList members; ast::StructMemberList members;
for (auto* type : member_types) { for (auto* type : member_types) {
members.push_back(MakeStructMember(members.size(), type, {})); members.push_back(MakeStructMember(members.size(), type, {}));
} }
return MakeStructTypeFromMembers(name, std::move(members), is_block); return MakeStructTypeFromMembers(name, std::move(members));
} }
const ast::Struct* InspectorBuilder::MakeStructTypeFromMembers( const ast::Struct* InspectorBuilder::MakeStructTypeFromMembers(
const std::string& name, const std::string& name,
ast::StructMemberList members, ast::StructMemberList members) {
bool is_block) { return Structure(name, std::move(members));
ast::AttributeList attrs;
if (is_block) {
attrs.push_back(create<ast::StructBlockAttribute>());
}
return Structure(name, std::move(members), attrs);
} }
const ast::StructMember* InspectorBuilder::MakeStructMember( const ast::StructMember* InspectorBuilder::MakeStructMember(
@ -121,13 +115,13 @@ const ast::StructMember* InspectorBuilder::MakeStructMember(
const ast::Struct* InspectorBuilder::MakeUniformBufferType( const ast::Struct* InspectorBuilder::MakeUniformBufferType(
const std::string& name, const std::string& name,
std::vector<const ast::Type*> member_types) { std::vector<const ast::Type*> member_types) {
return MakeStructType(name, member_types, true); return MakeStructType(name, member_types);
} }
std::function<const ast::TypeName*()> InspectorBuilder::MakeStorageBufferTypes( std::function<const ast::TypeName*()> InspectorBuilder::MakeStorageBufferTypes(
const std::string& name, const std::string& name,
std::vector<const ast::Type*> member_types) { std::vector<const ast::Type*> member_types) {
MakeStructType(name, member_types, true); MakeStructType(name, member_types);
return [this, name] { return ty.type_name(name); }; return [this, name] { return ty.type_name(name); };
} }

View File

@ -24,7 +24,6 @@
#include "src/tint/ast/disable_validation_attribute.h" #include "src/tint/ast/disable_validation_attribute.h"
#include "src/tint/ast/id_attribute.h" #include "src/tint/ast/id_attribute.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/workgroup_attribute.h" #include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"
#include "src/tint/sem/depth_texture_type.h" #include "src/tint/sem/depth_texture_type.h"
@ -153,20 +152,16 @@ class InspectorBuilder : public ProgramBuilder {
/// Generates a struct type /// Generates a struct type
/// @param name name for the type /// @param name name for the type
/// @param member_types a vector of member types /// @param member_types a vector of member types
/// @param is_block whether or not to decorate as a Block
/// @returns a struct type /// @returns a struct type
const ast::Struct* MakeStructType(const std::string& name, const ast::Struct* MakeStructType(const std::string& name,
std::vector<const ast::Type*> member_types, std::vector<const ast::Type*> member_types);
bool is_block);
/// Generates a struct type from a list of member nodes. /// Generates a struct type from a list of member nodes.
/// @param name name for the struct type /// @param name name for the struct type
/// @param members a vector of members /// @param members a vector of members
/// @param is_block whether or not to decorate as a Block
/// @returns a struct type /// @returns a struct type
const ast::Struct* MakeStructTypeFromMembers(const std::string& name, const ast::Struct* MakeStructTypeFromMembers(const std::string& name,
ast::StructMemberList members, ast::StructMemberList members);
bool is_block);
/// Generates a struct member with a specified index and type. /// Generates a struct member with a specified index and type.
/// @param index index of the field within the struct /// @param index index of the field within the struct

View File

@ -62,7 +62,6 @@
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/storage_texture.h" #include "src/tint/ast/storage_texture.h"
#include "src/tint/ast/stride_attribute.h" #include "src/tint/ast/stride_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/struct_member_align_attribute.h" #include "src/tint/ast/struct_member_align_attribute.h"
#include "src/tint/ast/struct_member_offset_attribute.h" #include "src/tint/ast/struct_member_offset_attribute.h"
#include "src/tint/ast/struct_member_size_attribute.h" #include "src/tint/ast/struct_member_size_attribute.h"
@ -1901,12 +1900,6 @@ class ProgramBuilder {
return create<ast::StructMemberAlignAttribute>(source_, val); return create<ast::StructMemberAlignAttribute>(source_, val);
} }
/// Creates a ast::StructBlockAttribute
/// @returns the struct block attribute pointer
const ast::StructBlockAttribute* StructBlock() {
return create<ast::StructBlockAttribute>();
}
/// Creates the ast::GroupAttribute /// Creates the ast::GroupAttribute
/// @param value group attribute index /// @param value group attribute index
/// @returns the group attribute pointer /// @returns the group attribute pointer
@ -2074,16 +2067,14 @@ class ProgramBuilder {
/// @param source the source information /// @param source the source information
/// @param name the struct name /// @param name the struct name
/// @param members the struct members /// @param members the struct members
/// @param attributes the optional struct attributes
/// @returns the struct type /// @returns the struct type
template <typename NAME> template <typename NAME>
const ast::Struct* Structure(const Source& source, const ast::Struct* Structure(const Source& source,
NAME&& name, NAME&& name,
ast::StructMemberList members, ast::StructMemberList members) {
ast::AttributeList attributes = {}) {
auto sym = Sym(std::forward<NAME>(name)); auto sym = Sym(std::forward<NAME>(name));
auto* type = create<ast::Struct>(source, sym, std::move(members), auto* type = create<ast::Struct>(source, sym, std::move(members),
std::move(attributes)); ast::AttributeList{});
AST().AddTypeDecl(type); AST().AddTypeDecl(type);
return type; return type;
} }
@ -2091,15 +2082,12 @@ class ProgramBuilder {
/// Creates a ast::Struct registering it with the AST().TypeDecls(). /// Creates a ast::Struct registering it with the AST().TypeDecls().
/// @param name the struct name /// @param name the struct name
/// @param members the struct members /// @param members the struct members
/// @param attributes the optional struct attributes
/// @returns the struct type /// @returns the struct type
template <typename NAME> template <typename NAME>
const ast::Struct* Structure(NAME&& name, const ast::Struct* Structure(NAME&& name, ast::StructMemberList members) {
ast::StructMemberList members,
ast::AttributeList attributes = {}) {
auto sym = Sym(std::forward<NAME>(name)); auto sym = Sym(std::forward<NAME>(name));
auto* type = auto* type =
create<ast::Struct>(sym, std::move(members), std::move(attributes)); create<ast::Struct>(sym, std::move(members), ast::AttributeList{});
AST().AddTypeDecl(type); AST().AddTypeDecl(type);
return type; return type;
} }

View File

@ -29,7 +29,6 @@
#include "src/tint/ast/loop_statement.h" #include "src/tint/ast/loop_statement.h"
#include "src/tint/ast/return_statement.h" #include "src/tint/ast/return_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/switch_statement.h" #include "src/tint/ast/switch_statement.h"
#include "src/tint/ast/type_name.h" #include "src/tint/ast/type_name.h"
#include "src/tint/ast/unary_op_expression.h" #include "src/tint/ast/unary_op_expression.h"
@ -111,7 +110,6 @@ ast::Builtin ident_to_builtin(std::string_view str) {
} }
const char kBindingAttribute[] = "binding"; const char kBindingAttribute[] = "binding";
const char kBlockAttribute[] = "block";
const char kBuiltinAttribute[] = "builtin"; const char kBuiltinAttribute[] = "builtin";
const char kGroupAttribute[] = "group"; const char kGroupAttribute[] = "group";
const char kIdAttribute[] = "id"; const char kIdAttribute[] = "id";
@ -126,8 +124,7 @@ const char kWorkgroupSizeAttribute[] = "workgroup_size";
bool is_attribute(Token t) { bool is_attribute(Token t) {
return t == kAlignAttribute || t == kBindingAttribute || return t == kAlignAttribute || t == kBindingAttribute ||
t == kBlockAttribute || t == kBuiltinAttribute || t == kBuiltinAttribute || t == kGroupAttribute || t == kIdAttribute ||
t == kGroupAttribute || t == kIdAttribute ||
t == kInterpolateAttribute || t == kLocationAttribute || t == kInterpolateAttribute || t == kLocationAttribute ||
t == kSizeAttribute || t == kStageAttribute || t == kStrideAttribute || t == kSizeAttribute || t == kStageAttribute || t == kStrideAttribute ||
t == kWorkgroupSizeAttribute; t == kWorkgroupSizeAttribute;
@ -394,7 +391,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
return true; return true;
} }
auto str = struct_decl(attrs.value); auto str = struct_decl();
if (str.errored) if (str.errored)
return Failure::kErrored; return Failure::kErrored;
@ -1189,8 +1186,8 @@ Expect<ast::StorageClass> ParserImpl::expect_storage_class(
} }
// struct_decl // struct_decl
// : struct_attribute_decl* STRUCT IDENT struct_body_decl // : STRUCT IDENT struct_body_decl
Maybe<const ast::Struct*> ParserImpl::struct_decl(ast::AttributeList& attrs) { Maybe<const ast::Struct*> ParserImpl::struct_decl() {
auto t = peek(); auto t = peek();
auto source = t.source(); auto source = t.source();
@ -1207,7 +1204,7 @@ Maybe<const ast::Struct*> ParserImpl::struct_decl(ast::AttributeList& attrs) {
auto sym = builder_.Symbols().Register(name.value); auto sym = builder_.Symbols().Register(name.value);
return create<ast::Struct>(source, sym, std::move(body.value), return create<ast::Struct>(source, sym, std::move(body.value),
std::move(attrs)); ast::AttributeList{});
} }
// struct_body_decl // struct_body_decl
@ -3052,11 +3049,6 @@ Maybe<const ast::Attribute*> ParserImpl::attribute() {
}); });
} }
if (t == kBlockAttribute) {
deprecated(t.source(), "[[block]] attributes have been removed from WGSL");
return create<ast::StructBlockAttribute>(t.source());
}
if (t == kStrideAttribute) { if (t == kStrideAttribute) {
const char* use = "stride attribute"; const char* use = "stride attribute";
return expect_paren_block(use, [&]() -> Result { return expect_paren_block(use, [&]() -> Result {

View File

@ -428,11 +428,9 @@ class ParserImpl {
/// @param use a description of what was being parsed if an error was raised. /// @param use a description of what was being parsed if an error was raised.
/// @returns the storage class or StorageClass::kNone if none matched /// @returns the storage class or StorageClass::kNone if none matched
Expect<ast::StorageClass> expect_storage_class(std::string_view use); Expect<ast::StorageClass> expect_storage_class(std::string_view use);
/// Parses a `struct_decl` grammar element with the initial /// Parses a `struct_decl` grammar element.
/// `struct_attribute_decl*` provided as `attrs`.
/// @returns the struct type or nullptr on error /// @returns the struct type or nullptr on error
/// @param attrs the list of attributes for the struct declaration. Maybe<const ast::Struct*> struct_decl();
Maybe<const ast::Struct*> struct_decl(ast::AttributeList& attrs);
/// Parses a `struct_body_decl` grammar element, erroring on parse failure. /// Parses a `struct_body_decl` grammar element, erroring on parse failure.
/// @returns the struct members /// @returns the struct members
Expect<ast::StructMemberList> expect_struct_body_decl(); Expect<ast::StructMemberList> expect_struct_body_decl();

View File

@ -725,42 +725,6 @@ var x : texture_storage_2d<1>;
)"); )");
} }
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when [[block]] is removed.
TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStructAttrMissingStruct) {
EXPECT(
"[[block]];",
R"(test.wgsl:1:1 warning: use of deprecated language feature: [[attribute]] style attributes have been replaced with @attribute style
[[block]];
^^
test.wgsl:1:3 warning: use of deprecated language feature: [[block]] attributes have been removed from WGSL
[[block]];
^^^^^
test.wgsl:1:10 error: expected declaration after attributes
[[block]];
^
)");
}
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when [[block]] is removed.
TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStructAttrMissingEnd) {
EXPECT(
"[[block struct {};",
R"(test.wgsl:1:1 warning: use of deprecated language feature: [[attribute]] style attributes have been replaced with @attribute style
[[block struct {};
^^
test.wgsl:1:3 warning: use of deprecated language feature: [[block]] attributes have been removed from WGSL
[[block struct {};
^^^^^
test.wgsl:1:9 error: expected ']]' for attribute list
[[block struct {};
^^^^^^
)");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructDeclMissingIdentifier) { TEST_F(ParserImplErrorTest, GlobalDeclStructDeclMissingIdentifier) {
EXPECT("struct {};", EXPECT("struct {};",
R"(test.wgsl:1:8 error: expected identifier for struct declaration R"(test.wgsl:1:8 error: expected identifier for struct declaration

View File

@ -193,24 +193,6 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
ASSERT_EQ(stride->As<ast::StrideAttribute>()->stride, 4u); ASSERT_EQ(stride->As<ast::StrideAttribute>()->stride, 4u);
} }
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when @block is removed.
TEST_F(ParserImplTest, GlobalDecl_Struct_WithAttribute) {
auto p = parser("[[block]] struct A { data: f32; }");
p->expect_global_decl();
ASSERT_FALSE(p->has_error()) << p->error();
auto program = p->program();
ASSERT_EQ(program.AST().TypeDecls().size(), 1u);
auto* t = program.AST().TypeDecls()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<ast::Struct>());
auto* str = t->As<ast::Struct>();
EXPECT_EQ(str->name, program.Symbols().Get("A"));
EXPECT_EQ(str->members.size(), 1u);
}
TEST_F(ParserImplTest, GlobalDecl_Struct_Invalid) { TEST_F(ParserImplTest, GlobalDecl_Struct_Invalid) {
auto p = parser("A {}"); auto p = parser("A {}");
p->expect_global_decl(); p->expect_global_decl();

View File

@ -1,62 +0,0 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
namespace tint {
namespace reader {
namespace wgsl {
namespace {
struct AttributeData {
const char* input;
bool is_block;
};
inline std::ostream& operator<<(std::ostream& out, AttributeData data) {
out << std::string(data.input);
return out;
}
class AttributeTest : public ParserImplTestWithParam<AttributeData> {};
TEST_P(AttributeTest, Parses) {
auto params = GetParam();
auto p = parser(params.input);
auto attr = p->attribute();
ASSERT_FALSE(p->has_error());
EXPECT_TRUE(attr.matched);
EXPECT_FALSE(attr.errored);
ASSERT_NE(attr.value, nullptr);
auto* struct_attr = attr.value->As<ast::Attribute>();
ASSERT_NE(struct_attr, nullptr);
EXPECT_EQ(struct_attr->Is<ast::StructBlockAttribute>(), params.is_block);
}
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
AttributeTest,
testing::Values(AttributeData{"block", true}));
TEST_F(ParserImplTest, Attribute_NoMatch) {
auto p = parser("not-a-stage");
auto attr = p->attribute();
EXPECT_FALSE(attr.matched);
EXPECT_FALSE(attr.errored);
ASSERT_EQ(attr.value, nullptr);
}
} // namespace
} // namespace wgsl
} // namespace reader
} // namespace tint

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/reader/wgsl/parser_impl_test_helper.h" #include "src/tint/reader/wgsl/parser_impl_test_helper.h"
#include "src/tint/utils/string.h" #include "src/tint/utils/string.h"
@ -27,12 +26,7 @@ struct S {
a : i32; a : i32;
b : f32; b : f32;
})"); })");
auto attrs = p->attribute_list(); auto s = p->struct_decl();
EXPECT_FALSE(attrs.errored);
EXPECT_FALSE(attrs.matched);
ASSERT_EQ(attrs.value.size(), 0u);
auto s = p->struct_decl(attrs.value);
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
EXPECT_FALSE(s.errored); EXPECT_FALSE(s.errored);
EXPECT_TRUE(s.matched); EXPECT_TRUE(s.matched);
@ -65,12 +59,8 @@ struct $struct {
src = utils::ReplaceAll(src, "$member_b", member_b_ident); src = utils::ReplaceAll(src, "$member_b", member_b_ident);
auto p = parser(src); auto p = parser(src);
auto attrs = p->attribute_list();
EXPECT_FALSE(attrs.errored);
EXPECT_FALSE(attrs.matched);
ASSERT_EQ(attrs.value.size(), 0u);
auto s = p->struct_decl(attrs.value); auto s = p->struct_decl();
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
EXPECT_FALSE(s.errored); EXPECT_FALSE(s.errored);
EXPECT_TRUE(s.matched); EXPECT_TRUE(s.matched);
@ -83,64 +73,10 @@ struct $struct {
p->builder().Symbols().Register(member_b_ident)); p->builder().Symbols().Register(member_b_ident));
} }
TEST_F(ParserImplTest, StructDecl_ParsesWithAttribute) {
auto p = parser(R"(
[[block]] struct B {
a : f32;
b : f32;
})");
auto attrs = p->attribute_list();
EXPECT_FALSE(attrs.errored);
EXPECT_TRUE(attrs.matched);
ASSERT_EQ(attrs.value.size(), 1u);
auto s = p->struct_decl(attrs.value);
EXPECT_FALSE(p->has_error());
EXPECT_FALSE(s.errored);
EXPECT_TRUE(s.matched);
ASSERT_NE(s.value, nullptr);
ASSERT_EQ(s->name, p->builder().Symbols().Register("B"));
ASSERT_EQ(s->members.size(), 2u);
EXPECT_EQ(s->members[0]->symbol, p->builder().Symbols().Register("a"));
EXPECT_EQ(s->members[1]->symbol, p->builder().Symbols().Register("b"));
ASSERT_EQ(s->attributes.size(), 1u);
EXPECT_TRUE(s->attributes[0]->Is<ast::StructBlockAttribute>());
}
TEST_F(ParserImplTest, StructDecl_ParsesWithMultipleAttribute) {
auto p = parser(R"(
[[block]]
[[block]] struct S {
a : f32;
b : f32;
})");
auto attrs = p->attribute_list();
EXPECT_FALSE(attrs.errored);
EXPECT_TRUE(attrs.matched);
ASSERT_EQ(attrs.value.size(), 2u);
auto s = p->struct_decl(attrs.value);
EXPECT_FALSE(p->has_error());
EXPECT_FALSE(s.errored);
EXPECT_TRUE(s.matched);
ASSERT_NE(s.value, nullptr);
ASSERT_EQ(s->name, p->builder().Symbols().Register("S"));
ASSERT_EQ(s->members.size(), 2u);
EXPECT_EQ(s->members[0]->symbol, p->builder().Symbols().Register("a"));
EXPECT_EQ(s->members[1]->symbol, p->builder().Symbols().Register("b"));
ASSERT_EQ(s->attributes.size(), 2u);
EXPECT_TRUE(s->attributes[0]->Is<ast::StructBlockAttribute>());
EXPECT_TRUE(s->attributes[1]->Is<ast::StructBlockAttribute>());
}
TEST_F(ParserImplTest, StructDecl_EmptyMembers) { TEST_F(ParserImplTest, StructDecl_EmptyMembers) {
auto p = parser("struct S {}"); auto p = parser("struct S {}");
auto attrs = p->attribute_list();
EXPECT_FALSE(attrs.errored);
EXPECT_FALSE(attrs.matched);
ASSERT_EQ(attrs.value.size(), 0u);
auto s = p->struct_decl(attrs.value); auto s = p->struct_decl();
EXPECT_FALSE(p->has_error()); EXPECT_FALSE(p->has_error());
EXPECT_FALSE(s.errored); EXPECT_FALSE(s.errored);
EXPECT_TRUE(s.matched); EXPECT_TRUE(s.matched);
@ -150,12 +86,8 @@ TEST_F(ParserImplTest, StructDecl_EmptyMembers) {
TEST_F(ParserImplTest, StructDecl_MissingIdent) { TEST_F(ParserImplTest, StructDecl_MissingIdent) {
auto p = parser("struct {}"); auto p = parser("struct {}");
auto attrs = p->attribute_list();
EXPECT_FALSE(attrs.errored);
EXPECT_FALSE(attrs.matched);
ASSERT_EQ(attrs.value.size(), 0u);
auto s = p->struct_decl(attrs.value); auto s = p->struct_decl();
EXPECT_TRUE(s.errored); EXPECT_TRUE(s.errored);
EXPECT_FALSE(s.matched); EXPECT_FALSE(s.matched);
EXPECT_EQ(s.value, nullptr); EXPECT_EQ(s.value, nullptr);
@ -166,12 +98,8 @@ TEST_F(ParserImplTest, StructDecl_MissingIdent) {
TEST_F(ParserImplTest, StructDecl_MissingBracketLeft) { TEST_F(ParserImplTest, StructDecl_MissingBracketLeft) {
auto p = parser("struct S }"); auto p = parser("struct S }");
auto attrs = p->attribute_list();
EXPECT_FALSE(attrs.errored);
EXPECT_FALSE(attrs.matched);
ASSERT_EQ(attrs.value.size(), 0u);
auto s = p->struct_decl(attrs.value); auto s = p->struct_decl();
EXPECT_TRUE(s.errored); EXPECT_TRUE(s.errored);
EXPECT_FALSE(s.matched); EXPECT_FALSE(s.matched);
EXPECT_EQ(s.value, nullptr); EXPECT_EQ(s.value, nullptr);
@ -180,42 +108,6 @@ TEST_F(ParserImplTest, StructDecl_MissingBracketLeft) {
EXPECT_EQ(p->error(), "1:10: expected '{' for struct declaration"); EXPECT_EQ(p->error(), "1:10: expected '{' for struct declaration");
} }
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when @block is removed.
TEST_F(ParserImplTest, StructDecl_InvalidAttributeDecl) {
auto p = parser("[[block struct S { a : i32; }");
auto attrs = p->attribute_list();
EXPECT_TRUE(attrs.errored);
EXPECT_FALSE(attrs.matched);
auto s = p->struct_decl(attrs.value);
EXPECT_FALSE(s.errored);
EXPECT_TRUE(s.matched);
EXPECT_NE(s.value, nullptr);
EXPECT_TRUE(p->has_error());
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: [[attribute]] style attributes have been replaced with @attribute style
1:3: use of deprecated language feature: [[block]] attributes have been removed from WGSL
1:9: expected ']]' for attribute list)");
}
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when [[block]] is removed.
TEST_F(ParserImplTest, StructDecl_MissingStruct) {
auto p = parser("[[block]] S {}");
auto attrs = p->attribute_list();
EXPECT_FALSE(attrs.errored);
EXPECT_TRUE(attrs.matched);
ASSERT_EQ(attrs.value.size(), 1u);
auto s = p->struct_decl(attrs.value);
EXPECT_FALSE(s.errored);
EXPECT_FALSE(s.matched);
EXPECT_EQ(s.value, nullptr);
EXPECT_FALSE(p->has_error());
}
} // namespace } // namespace
} // namespace wgsl } // namespace wgsl
} // namespace reader } // namespace reader

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/reader/wgsl/parser_impl_test_helper.h" #include "src/tint/reader/wgsl/parser_impl_test_helper.h"
namespace tint { namespace tint {
@ -83,10 +82,6 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessAttrFail) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(mem); members.push_back(mem);
auto* block_attr = create<ast::StructBlockAttribute>();
ast::AttributeList attrs;
attrs.push_back(block_attr);
auto decl = p->expect_variable_ident_decl("test"); auto decl = p->expect_variable_ident_decl("test");
ASSERT_TRUE(p->has_error()); ASSERT_TRUE(p->has_error());
ASSERT_TRUE(decl.errored); ASSERT_TRUE(decl.errored);

View File

@ -15,7 +15,6 @@
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/storage_texture_type.h" #include "src/tint/sem/storage_texture_type.h"
@ -26,11 +25,10 @@ namespace {
using ResolverAssignmentValidationTest = ResolverTest; using ResolverAssignmentValidationTest = ResolverTest;
TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) { TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) {
// [[block]] struct S { m : i32 }; // struct S { m : i32 };
// @group(0) @binding(0) // @group(0) @binding(0)
// var<storage,read> a : S; // var<storage,read> a : S;
auto* s = Structure("S", {Member("m", ty.i32())}, auto* s = Structure("S", {Member("m", ty.i32())});
{create<ast::StructBlockAttribute>()});
Global(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kRead, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -250,12 +248,11 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
} }
TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) { TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) {
// [[block]] struct S { a : atomic<i32>; }; // struct S { a : atomic<i32>; };
// @group(0) @binding(0) var<storage, read_write> v : S; // @group(0) @binding(0) var<storage, read_write> v : S;
// v.a = v.a; // v.a = v.a;
auto* s = Structure("S", {Member("a", ty.atomic(ty.i32()))}, auto* s = Structure("S", {Member("a", ty.atomic(ty.i32()))});
{create<ast::StructBlockAttribute>()});
Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
@ -272,12 +269,11 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) {
} }
TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) { TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) {
// [[block]] struct S { a : array<f32>; }; // struct S { a : array<f32>; };
// @group(0) @binding(0) var<storage, read_write> v : S; // @group(0) @binding(0) var<storage, read_write> v : S;
// v.a = v.a; // v.a = v.a;
auto* s = Structure("S", {Member("a", ty.array(ty.f32()))}, auto* s = Structure("S", {Member("a", ty.array(ty.f32()))});
{create<ast::StructBlockAttribute>()});
Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
@ -295,7 +291,6 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) {
TEST_F(ResolverAssignmentValidationTest, TEST_F(ResolverAssignmentValidationTest,
AssignToPhony_NonConstructibleStruct_Fail) { AssignToPhony_NonConstructibleStruct_Fail) {
// [[block]]
// struct S { // struct S {
// arr: array<i32>; // arr: array<i32>;
// }; // };
@ -303,7 +298,7 @@ TEST_F(ResolverAssignmentValidationTest,
// fn f() { // fn f() {
// _ = s; // _ = s;
// } // }
auto* s = Structure("S", {Member("arr", ty.array<i32>())}, {StructBlock()}); auto* s = Structure("S", {Member("arr", ty.array<i32>())});
Global("s", ty.Of(s), ast::StorageClass::kStorage, GroupAndBinding(0, 0)); Global("s", ty.Of(s), ast::StorageClass::kStorage, GroupAndBinding(0, 0));
WrapInFunction(Assign(Phony(), Expr(Source{{12, 34}}, "s"))); WrapInFunction(Assign(Phony(), Expr(Source{{12, 34}}, "s")));
@ -316,7 +311,6 @@ TEST_F(ResolverAssignmentValidationTest,
} }
TEST_F(ResolverAssignmentValidationTest, AssignToPhony_DynamicArray_Fail) { TEST_F(ResolverAssignmentValidationTest, AssignToPhony_DynamicArray_Fail) {
// [[block]]
// struct S { // struct S {
// arr: array<i32>; // arr: array<i32>;
// }; // };
@ -324,7 +318,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_DynamicArray_Fail) {
// fn f() { // fn f() {
// _ = s.arr; // _ = s.arr;
// } // }
auto* s = Structure("S", {Member("arr", ty.array<i32>())}, {StructBlock()}); auto* s = Structure("S", {Member("arr", ty.array<i32>())});
Global("s", ty.Of(s), ast::StorageClass::kStorage, GroupAndBinding(0, 0)); Global("s", ty.Of(s), ast::StorageClass::kStorage, GroupAndBinding(0, 0));
WrapInFunction(Assign(Phony(), MemberAccessor(Source{{12, 34}}, "s", "arr"))); WrapInFunction(Assign(Phony(), MemberAccessor(Source{{12, 34}}, "s", "arr")));
@ -338,12 +332,10 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_DynamicArray_Fail) {
} }
TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) { TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
// [[block]]
// struct S { // struct S {
// i: i32; // i: i32;
// arr: array<i32>; // arr: array<i32>;
// }; // };
// [[block]]
// struct U { // struct U {
// i: i32; // i: i32;
// }; // };
@ -367,13 +359,11 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
// _ = wg; // _ = wg;
// _ = wg[3]; // _ = wg[3];
// } // }
auto* S = Structure("S", auto* S = Structure("S", {
{ Member("i", ty.i32()),
Member("i", ty.i32()), Member("arr", ty.array<i32>()),
Member("arr", ty.array<i32>()), });
}, auto* U = Structure("U", {Member("i", ty.i32())});
{StructBlock()});
auto* U = Structure("U", {Member("i", ty.i32())}, {StructBlock()});
Global("tex", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Global("tex", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
GroupAndBinding(0, 0)); GroupAndBinding(0, 0));
Global("smp", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(0, 1)); Global("smp", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(0, 1));

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/atomic_type.h" #include "src/tint/sem/atomic_type.h"
@ -50,8 +49,8 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) {
} }
TEST_F(ResolverAtomicTest, GlobalStorageStruct) { TEST_F(ResolverAtomicTest, GlobalStorageStruct) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}, auto* s =
{create<ast::StructBlockAttribute>()}); Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
auto* g = Global("g", ty.Of(s), ast::StorageClass::kStorage, auto* g = Global("g", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{

View File

@ -34,8 +34,8 @@ TEST_F(ResolverAtomicValidationTest, StorageClass_WorkGroup) {
} }
TEST_F(ResolverAtomicValidationTest, StorageClass_Storage) { TEST_F(ResolverAtomicValidationTest, StorageClass_Storage) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}, auto* s =
{StructBlock()}); Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
Global("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GroupAndBinding(0, 0)); GroupAndBinding(0, 0));
@ -211,8 +211,8 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Complex) {
} }
TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) { TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}, auto* s =
{StructBlock()}); Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kRead, GroupAndBinding(0, 0)); ast::Access::kRead, GroupAndBinding(0, 0));
@ -225,8 +225,8 @@ TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) {
} }
TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Struct) { TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Struct) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}, auto* s =
{StructBlock()}); Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kRead, GroupAndBinding(0, 0)); ast::Access::kRead, GroupAndBinding(0, 0));
@ -245,8 +245,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStruct) {
auto* Inner = auto* Inner =
Structure("Inner", {Member("m", ty.atomic(Source{{12, 34}}, ty.i32()))}); Structure("Inner", {Member("m", ty.atomic(Source{{12, 34}}, ty.i32()))});
auto* Outer = auto* Outer = Structure("Outer", {Member("m", ty.Of(Inner))});
Structure("Outer", {Member("m", ty.Of(Inner))}, {StructBlock()});
Global(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage,
ast::Access::kRead, GroupAndBinding(0, 0)); ast::Access::kRead, GroupAndBinding(0, 0));
@ -265,8 +264,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStructOfArray) {
auto* Inner = auto* Inner =
Structure("Inner", {Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))}); Structure("Inner", {Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))});
auto* Outer = auto* Outer = Structure("Outer", {Member("m", ty.Of(Inner))});
Structure("Outer", {Member("m", ty.Of(Inner))}, {StructBlock()});
Global(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage,
ast::Access::kRead, GroupAndBinding(0, 0)); ast::Access::kRead, GroupAndBinding(0, 0));
@ -308,7 +306,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Complex) {
auto* s3 = Structure("S3", {Member("x", ty.Of(s4))}); auto* s3 = Structure("S3", {Member("x", ty.Of(s4))});
auto* s2 = Structure("S2", {Member("x", ty.Of(s3))}); auto* s2 = Structure("S2", {Member("x", ty.Of(s3))});
auto* s1 = Structure("S1", {Member("x", ty.Of(s2))}); auto* s1 = Structure("S1", {Member("x", ty.Of(s2))});
auto* s0 = Structure("S0", {Member("x", ty.Of(s1))}, {StructBlock()}); auto* s0 = Structure("S0", {Member("x", ty.Of(s1))});
Global(Source{{56, 78}}, "g", ty.Of(s0), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(s0), ast::StorageClass::kStorage,
ast::Access::kRead, GroupAndBinding(0, 0)); ast::Access::kRead, GroupAndBinding(0, 0));

View File

@ -15,6 +15,7 @@
#include "src/tint/ast/disable_validation_attribute.h" #include "src/tint/ast/disable_validation_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/transform/add_spirv_block_attribute.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
@ -63,7 +64,6 @@ enum class AttributeKind {
kSize, kSize,
kStage, kStage,
kStride, kStride,
kStructBlock,
kWorkgroup, kWorkgroup,
kBindingAndGroup, kBindingAndGroup,
@ -115,8 +115,6 @@ static ast::AttributeList createAttributes(const Source& source,
return {builder.Stage(source, ast::PipelineStage::kCompute)}; return {builder.Stage(source, ast::PipelineStage::kCompute)};
case AttributeKind::kStride: case AttributeKind::kStride:
return {builder.create<ast::StrideAttribute>(source, 4u)}; return {builder.create<ast::StrideAttribute>(source, 4u)};
case AttributeKind::kStructBlock:
return {builder.create<ast::StructBlockAttribute>(source)};
case AttributeKind::kWorkgroup: case AttributeKind::kWorkgroup:
return {builder.create<ast::WorkgroupAttribute>(source, builder.Expr(1))}; return {builder.create<ast::WorkgroupAttribute>(source, builder.Expr(1))};
case AttributeKind::kBindingAndGroup: case AttributeKind::kBindingAndGroup:
@ -160,7 +158,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
@ -195,7 +192,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
} // namespace FunctionInputAndOutputTests } // namespace FunctionInputAndOutputTests
@ -244,7 +240,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
@ -283,7 +278,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
@ -333,7 +327,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
@ -381,7 +374,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
@ -431,7 +423,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
@ -477,7 +468,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
@ -537,13 +527,15 @@ TEST_F(EntryPointReturnTypeAttributeTest, DuplicateInternalAttribute) {
namespace StructAndStructMemberTests { namespace StructAndStructMemberTests {
using StructAttributeTest = TestWithParams; using StructAttributeTest = TestWithParams;
using SpirvBlockAttribute =
transform::AddSpirvBlockAttribute::SpirvBlockAttribute;
TEST_P(StructAttributeTest, IsValid) { TEST_P(StructAttributeTest, IsValid) {
auto& params = GetParam(); auto& params = GetParam();
Structure("mystruct", {Member("a", ty.f32())}, auto* str = create<ast::Struct>(
createAttributes(Source{{12, 34}}, *this, params.kind)); Sym("mystruct"), ast::StructMemberList{Member("a", ty.f32())},
createAttributes(Source{{12, 34}}, *this, params.kind));
WrapInFunction(); AST().AddGlobalDeclaration(str);
if (params.should_pass) { if (params.should_pass) {
EXPECT_TRUE(r()->Resolve()) << r()->error(); EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -568,25 +560,9 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, true},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
TEST_F(StructAttributeTest, DuplicateAttribute) {
Structure("mystruct",
{
Member("a", ty.i32()),
},
{
create<ast::StructBlockAttribute>(Source{{12, 34}}),
create<ast::StructBlockAttribute>(Source{{56, 78}}),
});
WrapInFunction();
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
R"(56:78 error: duplicate block attribute
12:34 note: first attribute declared here)");
}
using StructMemberAttributeTest = TestWithParams; using StructMemberAttributeTest = TestWithParams;
TEST_P(StructMemberAttributeTest, IsValid) { TEST_P(StructMemberAttributeTest, IsValid) {
auto& params = GetParam(); auto& params = GetParam();
@ -625,7 +601,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, true}, TestParams{AttributeKind::kSize, true},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
TEST_F(StructMemberAttributeTest, DuplicateAttribute) { TEST_F(StructMemberAttributeTest, DuplicateAttribute) {
@ -678,11 +653,9 @@ TEST_P(ArrayAttributeTest, IsValid) {
auto* arr = ty.array(ty.f32(), nullptr, auto* arr = ty.array(ty.f32(), nullptr,
createAttributes(Source{{12, 34}}, *this, params.kind)); createAttributes(Source{{12, 34}}, *this, params.kind));
Structure("mystruct", Structure("mystruct", {
{ Member("a", arr),
Member("a", arr), });
},
{create<ast::StructBlockAttribute>()});
WrapInFunction(); WrapInFunction();
@ -709,7 +682,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, true}, TestParams{AttributeKind::kStride, true},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
@ -753,7 +725,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, true})); TestParams{AttributeKind::kBindingAndGroup, true}));
@ -818,7 +789,6 @@ INSTANTIATE_TEST_SUITE_P(
TestParams{AttributeKind::kSize, false}, TestParams{AttributeKind::kSize, false},
TestParams{AttributeKind::kStage, false}, TestParams{AttributeKind::kStage, false},
TestParams{AttributeKind::kStride, false}, TestParams{AttributeKind::kStride, false},
TestParams{AttributeKind::kStructBlock, false},
TestParams{AttributeKind::kWorkgroup, false}, TestParams{AttributeKind::kWorkgroup, false},
TestParams{AttributeKind::kBindingAndGroup, false})); TestParams{AttributeKind::kBindingAndGroup, false}));
@ -968,8 +938,7 @@ namespace {
using ResourceAttributeTest = ResolverTest; using ResourceAttributeTest = ResolverTest;
TEST_F(ResourceAttributeTest, UniformBufferMissingBinding) { TEST_F(ResourceAttributeTest, UniformBufferMissingBinding) {
auto* s = Structure("S", {Member("x", ty.i32())}, auto* s = Structure("S", {Member("x", ty.i32())});
{create<ast::StructBlockAttribute>()});
Global(Source{{12, 34}}, "G", ty.Of(s), ast::StorageClass::kUniform); Global(Source{{12, 34}}, "G", ty.Of(s), ast::StorageClass::kUniform);
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
@ -979,8 +948,7 @@ TEST_F(ResourceAttributeTest, UniformBufferMissingBinding) {
} }
TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) { TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) {
auto* s = Structure("S", {Member("x", ty.i32())}, auto* s = Structure("S", {Member("x", ty.i32())});
{create<ast::StructBlockAttribute>()});
Global(Source{{12, 34}}, "G", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{12, 34}}, "G", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kRead); ast::Access::kRead);
@ -1344,8 +1312,7 @@ TEST_F(InterpolateTest, VertexOutput_Integer_MissingFlatInterpolation) {
{ {
Member("pos", ty.vec4<f32>(), {Builtin(ast::Builtin::kPosition)}), Member("pos", ty.vec4<f32>(), {Builtin(ast::Builtin::kPosition)}),
Member(Source{{12, 34}}, "u", ty.u32(), {Location(0)}), Member(Source{{12, 34}}, "u", ty.u32(), {Location(0)}),
}, });
{});
Func("main", {}, ty.Of(s), {Return(Construct(ty.Of(s)))}, Func("main", {}, ty.Of(s), {Return(Construct(ty.Of(s)))},
ast::AttributeList{Stage(ast::PipelineStage::kVertex)}); ast::AttributeList{Stage(ast::PipelineStage::kVertex)});

View File

@ -25,7 +25,6 @@
#include "src/tint/ast/loop_statement.h" #include "src/tint/ast/loop_statement.h"
#include "src/tint/ast/return_statement.h" #include "src/tint/ast/return_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/switch_statement.h" #include "src/tint/ast/switch_statement.h"
#include "src/tint/ast/unary_op_expression.h" #include "src/tint/ast/unary_op_expression.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
@ -633,8 +632,7 @@ using ResolverBuiltinDataTest = ResolverTest;
TEST_F(ResolverBuiltinDataTest, ArrayLength_Vector) { TEST_F(ResolverBuiltinDataTest, ArrayLength_Vector) {
auto* ary = ty.array<i32>(); auto* ary = ty.array<i32>();
auto* str = auto* str = Structure("S", {Member("x", ary)});
Structure("S", {Member("x", ary)}, {create<ast::StructBlockAttribute>()});
Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),

View File

@ -379,8 +379,7 @@ class DependencyScanner {
ast::IdAttribute, ast::InternalAttribute, ast::InterpolateAttribute, ast::IdAttribute, ast::InternalAttribute, ast::InterpolateAttribute,
ast::InvariantAttribute, ast::LocationAttribute, ast::InvariantAttribute, ast::LocationAttribute,
ast::StageAttribute, ast::StrideAttribute, ast::StageAttribute, ast::StrideAttribute,
ast::StructBlockAttribute, ast::StructMemberAlignAttribute, ast::StructMemberAlignAttribute, ast::StructMemberOffsetAttribute,
ast::StructMemberOffsetAttribute,
ast::StructMemberSizeAttribute>()) { ast::StructMemberSizeAttribute>()) {
return; return;
} }

View File

@ -16,7 +16,6 @@
#include "src/tint/ast/location_attribute.h" #include "src/tint/ast/location_attribute.h"
#include "src/tint/ast/return_statement.h" #include "src/tint/ast/return_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
@ -540,16 +539,13 @@ TEST_F(LocationAttributeTests, BadType_Input_Struct_NestedStruct) {
} }
TEST_F(LocationAttributeTests, BadType_Input_Struct_RuntimeArray) { TEST_F(LocationAttributeTests, BadType_Input_Struct_RuntimeArray) {
// [[block]]
// struct Input { // struct Input {
// @location(0) a : array<f32>; // @location(0) a : array<f32>;
// }; // };
// @stage(fragment) // @stage(fragment)
// fn main(param : Input) {} // fn main(param : Input) {}
auto* input = Structure( auto* input = Structure("Input", {Member(Source{{13, 43}}, "a",
"Input", ty.array<float>(), {Location(0)})});
{Member(Source{{13, 43}}, "a", ty.array<float>(), {Location(0)})},
{create<ast::StructBlockAttribute>()});
auto* param = Param("param", ty.Of(input)); auto* param = Param("param", ty.Of(input));
Func(Source{{12, 34}}, "main", {param}, ty.void_(), {}, Func(Source{{12, 34}}, "main", {param}, ty.void_(), {},
{Stage(ast::PipelineStage::kFragment)}); {Stage(ast::PipelineStage::kFragment)});
@ -563,14 +559,13 @@ TEST_F(LocationAttributeTests, BadType_Input_Struct_RuntimeArray) {
} }
TEST_F(LocationAttributeTests, BadMemberType_Input) { TEST_F(LocationAttributeTests, BadMemberType_Input) {
// [[block]]
// struct S { @location(0) m: array<i32>; }; // struct S { @location(0) m: array<i32>; };
// @stage(fragment) // @stage(fragment)
// fn frag_main( a: S) {} // fn frag_main( a: S) {}
auto* m = Member(Source{{34, 56}}, "m", ty.array<i32>(), auto* m = Member(Source{{34, 56}}, "m", ty.array<i32>(),
ast::AttributeList{Location(Source{{12, 34}}, 0u)}); ast::AttributeList{Location(Source{{12, 34}}, 0u)});
auto* s = Structure("S", {m}, ast::AttributeList{StructBlock()}); auto* s = Structure("S", {m});
auto* p = Param("a", ty.Of(s)); auto* p = Param("a", ty.Of(s));
Func("frag_main", {p}, ty.void_(), {}, Func("frag_main", {p}, ty.void_(), {},
@ -682,7 +677,6 @@ TEST_F(LocationAttributeTests, ReturnType_Struct_NestedStruct) {
} }
TEST_F(LocationAttributeTests, ReturnType_Struct_RuntimeArray) { TEST_F(LocationAttributeTests, ReturnType_Struct_RuntimeArray) {
// [[block]]
// struct Output { // struct Output {
// @location(0) a : array<f32>; // @location(0) a : array<f32>;
// }; // };
@ -690,10 +684,9 @@ TEST_F(LocationAttributeTests, ReturnType_Struct_RuntimeArray) {
// fn main() -> Output { // fn main() -> Output {
// return Output(); // return Output();
// } // }
auto* output = Structure("Output", auto* output =
{Member(Source{{13, 43}}, "a", ty.array<float>(), Structure("Output", {Member(Source{{13, 43}}, "a", ty.array<float>(),
{Location(Source{{12, 34}}, 0)})}, {Location(Source{{12, 34}}, 0)})});
{create<ast::StructBlockAttribute>()});
Func(Source{{12, 34}}, "main", {}, ty.Of(output), Func(Source{{12, 34}}, "main", {}, ty.Of(output),
{Return(Construct(ty.Of(output)))}, {Return(Construct(ty.Of(output)))},
{Stage(ast::PipelineStage::kFragment)}); {Stage(ast::PipelineStage::kFragment)});

View File

@ -15,7 +15,6 @@
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
@ -26,8 +25,7 @@ namespace {
using ResolverHostShareableValidationTest = ResolverTest; using ResolverHostShareableValidationTest = ResolverTest;
TEST_F(ResolverHostShareableValidationTest, BoolMember) { TEST_F(ResolverHostShareableValidationTest, BoolMember) {
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.bool_())}, auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.bool_())});
{create<ast::StructBlockAttribute>()});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kRead, ast::Access::kRead,
@ -46,8 +44,7 @@ TEST_F(ResolverHostShareableValidationTest, BoolMember) {
} }
TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) { TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) {
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.vec3<bool>())}, auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.vec3<bool>())});
{create<ast::StructBlockAttribute>()});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kRead, ast::Access::kRead,
@ -67,8 +64,7 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) {
TEST_F(ResolverHostShareableValidationTest, Aliases) { TEST_F(ResolverHostShareableValidationTest, Aliases) {
auto* a1 = Alias("a1", ty.bool_()); auto* a1 = Alias("a1", ty.bool_());
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.Of(a1))}, auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.Of(a1))});
{create<ast::StructBlockAttribute>()});
auto* a2 = Alias("a2", ty.Of(s)); auto* a2 = Alias("a2", ty.Of(s));
Global(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage,
ast::Access::kRead, ast::Access::kRead,
@ -91,8 +87,7 @@ TEST_F(ResolverHostShareableValidationTest, NestedStructures) {
auto* i2 = Structure("I2", {Member(Source{{3, 4}}, "y", ty.Of(i1))}); auto* i2 = Structure("I2", {Member(Source{{3, 4}}, "y", ty.Of(i1))});
auto* i3 = Structure("I3", {Member(Source{{5, 6}}, "z", ty.Of(i2))}); auto* i3 = Structure("I3", {Member(Source{{5, 6}}, "z", ty.Of(i2))});
auto* s = Structure("S", {Member(Source{{7, 8}}, "m", ty.Of(i3))}, auto* s = Structure("S", {Member(Source{{7, 8}}, "m", ty.Of(i3))});
{create<ast::StructBlockAttribute>()});
Global(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kRead, ast::Access::kRead,
@ -132,8 +127,7 @@ TEST_F(ResolverHostShareableValidationTest, NoError) {
Member(Source{{6, 1}}, "z3", ty.Of(a2)), Member(Source{{6, 1}}, "z3", ty.Of(a2)),
}); });
auto* s = Structure("S", {Member(Source{{7, 8}}, "m", ty.Of(i3))}, auto* s = Structure("S", {Member(Source{{7, 8}}, "m", ty.Of(i3))});
{create<ast::StructBlockAttribute>()});
Global(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kRead, ast::Access::kRead,

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
@ -154,7 +153,7 @@ TEST_F(ResolverInferredTypeTest, InferArray_Pass) {
TEST_F(ResolverInferredTypeTest, InferStruct_Pass) { TEST_F(ResolverInferredTypeTest, InferStruct_Pass) {
auto* member = Member("x", ty.i32()); auto* member = Member("x", ty.i32());
auto* str = Structure("S", {member}, {create<ast::StructBlockAttribute>()}); auto* str = Structure("S", {member});
auto* expected_type = create<sem::Struct>( auto* expected_type = create<sem::Struct>(
str, str->name, str, str->name,

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/reference_type.h" #include "src/tint/sem/reference_type.h"
@ -61,8 +60,7 @@ TEST_F(ResolverPtrRefTest, AddressOfThenDeref) {
TEST_F(ResolverPtrRefTest, DefaultPtrStorageClass) { TEST_F(ResolverPtrRefTest, DefaultPtrStorageClass) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class // https://gpuweb.github.io/gpuweb/wgsl/#storage-class
auto* buf = Structure("S", {Member("m", ty.i32())}, auto* buf = Structure("S", {Member("m", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* function = Var("f", ty.i32()); auto* function = Var("f", ty.i32());
auto* private_ = Global("p", ty.i32(), ast::StorageClass::kPrivate); auto* private_ = Global("p", ty.i32(), ast::StorageClass::kPrivate);
auto* workgroup = Global("w", ty.i32(), ast::StorageClass::kWorkgroup); auto* workgroup = Global("w", ty.i32(), ast::StorageClass::kWorkgroup);

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
#include "src/tint/ast/bitcast_expression.h" #include "src/tint/ast/bitcast_expression.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/reference_type.h" #include "src/tint/sem/reference_type.h"
@ -139,7 +138,7 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) {
// struct Inner { // struct Inner {
// arr: array<i32, 4>; // arr: array<i32, 4>;
// } // }
// [[block]] struct S { // struct S {
// inner: Inner; // inner: Inner;
// } // }
// @group(0) @binding(0) var<storage, read_write> s : S; // @group(0) @binding(0) var<storage, read_write> s : S;
@ -147,8 +146,7 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) {
// let p : pointer<storage, i32> = &s.inner.arr[2]; // let p : pointer<storage, i32> = &s.inner.arr[2];
// } // }
auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())}); auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())});
auto* buf = Structure("S", {Member("inner", ty.Of(inner))}, auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
{create<ast::StructBlockAttribute>()});
auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage, auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{

View File

@ -30,7 +30,6 @@
#include "src/tint/ast/loop_statement.h" #include "src/tint/ast/loop_statement.h"
#include "src/tint/ast/return_statement.h" #include "src/tint/ast/return_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/switch_statement.h" #include "src/tint/ast/switch_statement.h"
#include "src/tint/ast/unary_op_expression.h" #include "src/tint/ast/unary_op_expression.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
@ -783,8 +782,7 @@ TEST_F(ResolverTest, Function_Parameters) {
} }
TEST_F(ResolverTest, Function_RegisterInputOutputVariables) { TEST_F(ResolverTest, Function_RegisterInputOutputVariables) {
auto* s = Structure("S", {Member("m", ty.u32())}, auto* s = Structure("S", {Member("m", ty.u32())});
{create<ast::StructBlockAttribute>()});
auto* sb_var = Global("sb_var", ty.Of(s), ast::StorageClass::kStorage, auto* sb_var = Global("sb_var", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
@ -817,8 +815,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) {
} }
TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) { TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) {
auto* s = Structure("S", {Member("m", ty.u32())}, auto* s = Structure("S", {Member("m", ty.u32())});
{create<ast::StructBlockAttribute>()});
auto* sb_var = Global("sb_var", ty.Of(s), ast::StorageClass::kStorage, auto* sb_var = Global("sb_var", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
@ -1800,10 +1797,9 @@ TEST_F(ResolverTest, StorageClass_DoesNotSetOnConst) {
} }
TEST_F(ResolverTest, Access_SetForStorageBuffer) { TEST_F(ResolverTest, Access_SetForStorageBuffer) {
// [[block]] struct S { x : i32 }; // struct S { x : i32 };
// var<storage> g : S; // var<storage> g : S;
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}, auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* var = auto* var =
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{

View File

@ -2133,7 +2133,7 @@ bool Resolver::ValidateStructure(const sem::Struct* str) {
} }
for (auto* attr : str->Declaration()->attributes) { for (auto* attr : str->Declaration()->attributes) {
if (!(attr->IsAnyOf<ast::StructBlockAttribute, ast::InternalAttribute>())) { if (!(attr->IsAnyOf<ast::InternalAttribute>())) {
AddError("attribute is not valid for struct declarations", attr->source); AddError("attribute is not valid for struct declarations", attr->source);
return false; return false;
} }

View File

@ -26,7 +26,6 @@ using ResolverStorageClassLayoutValidationTest = ResolverTest;
// Detect unaligned member for storage buffers // Detect unaligned member for storage buffers
TEST_F(ResolverStorageClassLayoutValidationTest, TEST_F(ResolverStorageClassLayoutValidationTest,
StorageBuffer_UnalignedMember) { StorageBuffer_UnalignedMember) {
// [[block]]
// struct S { // struct S {
// @size(5) a : f32; // @size(5) a : f32;
// @align(1) b : f32; // @align(1) b : f32;
@ -36,8 +35,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
Structure(Source{{12, 34}}, "S", Structure(Source{{12, 34}}, "S",
{Member("a", ty.f32(), {MemberSize(5)}), {Member("a", ty.f32(), {MemberSize(5)}),
Member(Source{{34, 56}}, "b", ty.f32(), {MemberAlign(1)})}, Member(Source{{34, 56}}, "b", ty.f32(), {MemberAlign(1)})});
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage, Global(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage,
GroupAndBinding(0, 0)); GroupAndBinding(0, 0));
@ -57,7 +55,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
TEST_F(ResolverStorageClassLayoutValidationTest, TEST_F(ResolverStorageClassLayoutValidationTest,
StorageBuffer_UnalignedMember_SuggestedFix) { StorageBuffer_UnalignedMember_SuggestedFix) {
// [[block]]
// struct S { // struct S {
// @size(5) a : f32; // @size(5) a : f32;
// @align(4) b : f32; // @align(4) b : f32;
@ -67,8 +64,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
Structure(Source{{12, 34}}, "S", Structure(Source{{12, 34}}, "S",
{Member("a", ty.f32(), {MemberSize(5)}), {Member("a", ty.f32(), {MemberSize(5)}),
Member(Source{{34, 56}}, "b", ty.f32(), {MemberAlign(4)})}, Member(Source{{34, 56}}, "b", ty.f32(), {MemberAlign(4)})});
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage, Global(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage,
GroupAndBinding(0, 0)); GroupAndBinding(0, 0));
@ -83,7 +79,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
// scalar : i32; // scalar : i32;
// }; // };
// //
// [[block]]
// struct Outer { // struct Outer {
// scalar : f32; // scalar : f32;
// inner : Inner; // inner : Inner;
@ -98,8 +93,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
{ {
Member("scalar", ty.f32()), Member("scalar", ty.f32()),
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
}, });
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), Global(Source{{78, 90}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -126,7 +120,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
// scalar : i32; // scalar : i32;
// }; // };
// //
// [[block]]
// struct Outer { // struct Outer {
// scalar : f32; // scalar : f32;
// @align(16) inner : Inner; // @align(16) inner : Inner;
@ -142,8 +135,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
Member("scalar", ty.f32()), Member("scalar", ty.f32()),
Member(Source{{56, 78}}, "inner", ty.type_name("Inner"), Member(Source{{56, 78}}, "inner", ty.type_name("Inner"),
{MemberAlign(16)}), {MemberAlign(16)}),
}, });
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), Global(Source{{78, 90}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -156,7 +148,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
UniformBuffer_UnalignedMember_Array) { UniformBuffer_UnalignedMember_Array) {
// type Inner = @stride(16) array<f32, 10>; // type Inner = @stride(16) array<f32, 10>;
// //
// [[block]]
// struct Outer { // struct Outer {
// scalar : f32; // scalar : f32;
// inner : Inner; // inner : Inner;
@ -170,8 +161,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
{ {
Member("scalar", ty.f32()), Member("scalar", ty.f32()),
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
}, });
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), Global(Source{{78, 90}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -192,7 +182,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
UniformBuffer_UnalignedMember_Array_SuggestedFix) { UniformBuffer_UnalignedMember_Array_SuggestedFix) {
// type Inner = @stride(16) array<f32, 10>; // type Inner = @stride(16) array<f32, 10>;
// //
// [[block]]
// struct Outer { // struct Outer {
// scalar : f32; // scalar : f32;
// @align(16) inner : Inner; // @align(16) inner : Inner;
@ -207,8 +196,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
Member("scalar", ty.f32()), Member("scalar", ty.f32()),
Member(Source{{34, 56}}, "inner", ty.type_name("Inner"), Member(Source{{34, 56}}, "inner", ty.type_name("Inner"),
{MemberAlign(16)}), {MemberAlign(16)}),
}, });
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), Global(Source{{78, 90}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -224,7 +212,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
// @align(1) @size(5) scalar : i32; // @align(1) @size(5) scalar : i32;
// }; // };
// //
// [[block]]
// struct Outer { // struct Outer {
// inner : Inner; // inner : Inner;
// scalar : i32; // scalar : i32;
@ -240,8 +227,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
{ {
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
Member(Source{{78, 90}}, "scalar", ty.i32()), Member(Source{{78, 90}}, "scalar", ty.i32()),
}, });
{StructBlock()});
Global(Source{{22, 24}}, "a", ty.type_name("Outer"), Global(Source{{22, 24}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -273,7 +259,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
// @align(1) @size(5) scalar : i32; // @align(1) @size(5) scalar : i32;
// }; // };
// //
// [[block]]
// struct Outer { // struct Outer {
// inner : Inner; // inner : Inner;
// scalar : i32; // scalar : i32;
@ -294,8 +279,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
{ {
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
Member(Source{{78, 90}}, "scalar", ty.i32()), Member(Source{{78, 90}}, "scalar", ty.i32()),
}, });
{StructBlock()});
Global(Source{{22, 24}}, "a", ty.type_name("Outer"), Global(Source{{22, 24}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -326,7 +310,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
// @align(1) @size(5) scalar : i32; // @align(1) @size(5) scalar : i32;
// }; // };
// //
// [[block]]
// struct Outer { // struct Outer {
// @align(16) inner : Inner; // @align(16) inner : Inner;
// scalar : i32; // scalar : i32;
@ -342,8 +325,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
{ {
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
Member(Source{{78, 90}}, "scalar", ty.i32(), {MemberAlign(16)}), Member(Source{{78, 90}}, "scalar", ty.i32(), {MemberAlign(16)}),
}, });
{StructBlock()});
Global(Source{{22, 34}}, "a", ty.type_name("Outer"), Global(Source{{22, 34}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -355,7 +337,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
// size is 12. 's' should be at offset 12, which is okay here. // size is 12. 's' should be at offset 12, which is okay here.
TEST_F(ResolverStorageClassLayoutValidationTest, TEST_F(ResolverStorageClassLayoutValidationTest,
UniformBuffer_Vec3MemberOffset_NoFail) { UniformBuffer_Vec3MemberOffset_NoFail) {
// [[block]]
// struct ScalarPackedAtEndOfVec3 { // struct ScalarPackedAtEndOfVec3 {
// v : vec3<f32>; // v : vec3<f32>;
// s : f32; // s : f32;
@ -363,12 +344,10 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
// @group(0) @binding(0) // @group(0) @binding(0)
// var<uniform> a : ScalarPackedAtEndOfVec3; // var<uniform> a : ScalarPackedAtEndOfVec3;
Structure("ScalarPackedAtEndOfVec3", Structure("ScalarPackedAtEndOfVec3", {
{ Member("v", ty.vec3(ty.f32())),
Member("v", ty.vec3(ty.f32())), Member("s", ty.f32()),
Member("s", ty.f32()), });
},
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"), Global(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -381,7 +360,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
UniformBuffer_InvalidArrayStride_Scalar) { UniformBuffer_InvalidArrayStride_Scalar) {
// type Inner = array<f32, 10>; // type Inner = array<f32, 10>;
// //
// [[block]]
// struct Outer { // struct Outer {
// inner : Inner; // inner : Inner;
// scalar : i32; // scalar : i32;
@ -396,8 +374,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
{ {
Member("inner", ty.type_name(Source{{34, 56}}, "Inner")), Member("inner", ty.type_name(Source{{34, 56}}, "Inner")),
Member("scalar", ty.i32()), Member("scalar", ty.i32()),
}, });
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), Global(Source{{78, 90}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -418,7 +395,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
UniformBuffer_InvalidArrayStride_Vector) { UniformBuffer_InvalidArrayStride_Vector) {
// type Inner = array<vec2<f32>, 10>; // type Inner = array<vec2<f32>, 10>;
// //
// [[block]]
// struct Outer { // struct Outer {
// inner : Inner; // inner : Inner;
// scalar : i32; // scalar : i32;
@ -433,8 +409,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
{ {
Member("inner", ty.type_name(Source{{34, 56}}, "Inner")), Member("inner", ty.type_name(Source{{34, 56}}, "Inner")),
Member("scalar", ty.i32()), Member("scalar", ty.i32()),
}, });
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), Global(Source{{78, 90}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -460,7 +435,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
// } // }
// type Inner = array<ArrayElem, 10>; // type Inner = array<ArrayElem, 10>;
// //
// [[block]]
// struct Outer { // struct Outer {
// inner : Inner; // inner : Inner;
// scalar : i32; // scalar : i32;
@ -479,8 +453,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
{ {
Member("inner", ty.type_name(Source{{34, 56}}, "Inner")), Member("inner", ty.type_name(Source{{34, 56}}, "Inner")),
Member("scalar", ty.i32()), Member("scalar", ty.i32()),
}, });
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), Global(Source{{78, 90}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -523,8 +496,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
Source{{12, 34}}, "Outer", Source{{12, 34}}, "Outer",
{ {
Member("inner", ty.array(Source{{34, 56}}, ty.array(ty.f32(), 4), 4)), Member("inner", ty.array(Source{{34, 56}}, ty.array(ty.f32(), 4), 4)),
}, });
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), Global(Source{{78, 90}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));
@ -544,7 +516,6 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
UniformBuffer_InvalidArrayStride_SuggestedFix) { UniformBuffer_InvalidArrayStride_SuggestedFix) {
// type Inner = @stride(16) array<f32, 10>; // type Inner = @stride(16) array<f32, 10>;
// //
// [[block]]
// struct Outer { // struct Outer {
// inner : Inner; // inner : Inner;
// scalar : i32; // scalar : i32;
@ -559,8 +530,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
{ {
Member("inner", ty.type_name(Source{{34, 56}}, "Inner")), Member("inner", ty.type_name(Source{{34, 56}}, "Inner")),
Member("scalar", ty.i32()), Member("scalar", ty.i32()),
}, });
{StructBlock()});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), Global(Source{{78, 90}}, "a", ty.type_name("Outer"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ast::StorageClass::kUniform, GroupAndBinding(0, 0));

View File

@ -15,7 +15,6 @@
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
@ -57,7 +56,7 @@ TEST_F(ResolverStorageClassValidationTest, Private_RuntimeArray) {
} }
TEST_F(ResolverStorageClassValidationTest, Private_RuntimeArrayInStruct) { TEST_F(ResolverStorageClassValidationTest, Private_RuntimeArrayInStruct) {
auto* s = Structure("S", {Member("m", ty.array(ty.i32()))}, {StructBlock()}); auto* s = Structure("S", {Member("m", ty.array(ty.i32()))});
Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kPrivate); Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
@ -80,7 +79,7 @@ TEST_F(ResolverStorageClassValidationTest, Workgroup_RuntimeArray) {
} }
TEST_F(ResolverStorageClassValidationTest, Workgroup_RuntimeArrayInStruct) { TEST_F(ResolverStorageClassValidationTest, Workgroup_RuntimeArrayInStruct) {
auto* s = Structure("S", {Member("m", ty.array(ty.i32()))}, {StructBlock()}); auto* s = Structure("S", {Member("m", ty.array(ty.i32()))});
Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kWorkgroup); Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kWorkgroup);
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
@ -192,10 +191,9 @@ TEST_F(ResolverStorageClassValidationTest, NotStorage_AccessMode) {
} }
TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Basic) { TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Basic) {
// [[block]] struct S { x : i32 }; // struct S { x : i32 };
// var<storage, read> g : S; // var<storage, read> g : S;
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}, auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
{create<ast::StructBlockAttribute>()});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kRead, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -207,11 +205,10 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Basic) {
} }
TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) { TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) {
// [[block]] struct S { x : i32 }; // struct S { x : i32 };
// type a1 = S; // type a1 = S;
// var<storage, read> g : a1; // var<storage, read> g : a1;
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}, auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* a1 = Alias("a1", ty.Of(s)); auto* a1 = Alias("a1", ty.Of(s));
auto* a2 = Alias("a2", ty.Of(a1)); auto* a2 = Alias("a2", ty.Of(a1));
Global(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, Global(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage,
@ -225,11 +222,10 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) {
} }
TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) { TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) {
// [[block]] struct S { m: array<f32>; }; // struct S { m: array<f32>; };
// @group(0) @binding(0) var<uniform, > svar : S; // @group(0) @binding(0) var<uniform, > svar : S;
auto* s = Structure(Source{{12, 34}}, "S", {Member("m", ty.array<i32>())}, auto* s = Structure(Source{{12, 34}}, "S", {Member("m", ty.array<i32>())});
{create<ast::StructBlockAttribute>()});
Global(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform, Global(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
@ -336,10 +332,9 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBoolAlias) {
} }
TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Basic) { TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Basic) {
// [[block]] struct S { x : i32 }; // struct S { x : i32 };
// var<uniform> g : S; // var<uniform> g : S;
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}, auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
{create<ast::StructBlockAttribute>()});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform, Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),
@ -350,11 +345,10 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Basic) {
} }
TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Aliases) { TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Aliases) {
// [[block]] struct S { x : i32 }; // struct S { x : i32 };
// type a1 = S; // type a1 = S;
// var<uniform> g : a1; // var<uniform> g : a1;
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}, auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* a1 = Alias("a1", ty.Of(s)); auto* a1 = Alias("a1", ty.Of(s));
Global(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform, Global(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{

View File

@ -15,7 +15,6 @@
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
@ -129,11 +128,9 @@ TEST_F(ResolverStructLayoutTest, ExplicitStrideArrayStaticSize) {
} }
TEST_F(ResolverStructLayoutTest, ImplicitStrideArrayRuntimeSized) { TEST_F(ResolverStructLayoutTest, ImplicitStrideArrayRuntimeSized) {
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("c", ty.array<f32>()),
Member("c", ty.array<f32>()), });
},
ast::AttributeList{create<ast::StructBlockAttribute>()});
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -149,11 +146,9 @@ TEST_F(ResolverStructLayoutTest, ImplicitStrideArrayRuntimeSized) {
} }
TEST_F(ResolverStructLayoutTest, ExplicitStrideArrayRuntimeSized) { TEST_F(ResolverStructLayoutTest, ExplicitStrideArrayRuntimeSized) {
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("c", ty.array<f32>(/*stride*/ 32)),
Member("c", ty.array<f32>(/*stride*/ 32)), });
},
ast::AttributeList{create<ast::StructBlockAttribute>()});
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();

View File

@ -15,7 +15,6 @@
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/struct.h" #include "src/tint/sem/struct.h"
@ -168,8 +167,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalArray) {
} }
TEST_F(ResolverStorageClassUseTest, StructMultipleStorageClassUses) { TEST_F(ResolverStorageClassUseTest, StructMultipleStorageClassUses) {
auto* s = Structure("S", {Member("a", ty.f32())}, auto* s = Structure("S", {Member("a", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("x", ty.Of(s), ast::StorageClass::kUniform, Global("x", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),

View File

@ -15,7 +15,6 @@
#include "src/tint/ast/id_attribute.h" #include "src/tint/ast/id_attribute.h"
#include "src/tint/ast/return_statement.h" #include "src/tint/ast/return_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/multisampled_texture_type.h" #include "src/tint/sem/multisampled_texture_type.h"
@ -481,18 +480,15 @@ TEST_F(ResolverTypeValidationTest, Struct_MemberOffset_TooBig) {
} }
TEST_F(ResolverTypeValidationTest, RuntimeArrayIsLast_Pass) { TEST_F(ResolverTypeValidationTest, RuntimeArrayIsLast_Pass) {
// [[block]]
// struct Foo { // struct Foo {
// vf: f32; // vf: f32;
// rt: array<f32>; // rt: array<f32>;
// }; // };
Structure("Foo", Structure("Foo", {
{ Member("vf", ty.f32()),
Member("vf", ty.f32()), Member("rt", ty.array<f32>()),
Member("rt", ty.array<f32>()), });
},
{create<ast::StructBlockAttribute>()});
WrapInFunction(); WrapInFunction();
@ -547,18 +543,15 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayInStructInStruct) {
} }
TEST_F(ResolverTypeValidationTest, RuntimeArrayIsNotLast_Fail) { TEST_F(ResolverTypeValidationTest, RuntimeArrayIsNotLast_Fail) {
// [[block]]
// struct Foo { // struct Foo {
// rt: array<f32>; // rt: array<f32>;
// vf: f32; // vf: f32;
// }; // };
Structure("Foo", Structure("Foo", {
{ Member(Source{{12, 34}}, "rt", ty.array<f32>()),
Member(Source{{12, 34}}, "rt", ty.array<f32>()), Member("vf", ty.f32()),
Member("vf", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
WrapInFunction(); WrapInFunction();
@ -639,7 +632,6 @@ TEST_F(ResolverTypeValidationTest, PtrToRuntimeArrayAsParameter_Fail) {
} }
TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsNotLast_Fail) { TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsNotLast_Fail) {
// [[block]]
// type RTArr = array<u32>; // type RTArr = array<u32>;
// struct s { // struct s {
// b: RTArr; // b: RTArr;
@ -647,12 +639,10 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsNotLast_Fail) {
//} //}
auto* alias = Alias("RTArr", ty.array<u32>()); auto* alias = Alias("RTArr", ty.array<u32>());
Structure("s", Structure("s", {
{ Member(Source{{12, 34}}, "b", ty.Of(alias)),
Member(Source{{12, 34}}, "b", ty.Of(alias)), Member("a", ty.u32()),
Member("a", ty.u32()), });
},
{create<ast::StructBlockAttribute>()});
WrapInFunction(); WrapInFunction();
@ -663,7 +653,6 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsNotLast_Fail) {
} }
TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) { TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) {
// [[block]]
// type RTArr = array<u32>; // type RTArr = array<u32>;
// struct s { // struct s {
// a: u32; // a: u32;
@ -671,12 +660,10 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) {
//} //}
auto* alias = Alias("RTArr", ty.array<u32>()); auto* alias = Alias("RTArr", ty.array<u32>());
Structure("s", Structure("s", {
{ Member("a", ty.u32()),
Member("a", ty.u32()), Member("b", ty.Of(alias)),
Member("b", ty.Of(alias)), });
},
{create<ast::StructBlockAttribute>()});
WrapInFunction(); WrapInFunction();

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
#include "src/tint/sem/reference_type.h" #include "src/tint/sem/reference_type.h"
@ -216,8 +215,7 @@ TEST_F(ResolverVarLetTest, LetDecl) {
TEST_F(ResolverVarLetTest, DefaultVarStorageClass) { TEST_F(ResolverVarLetTest, DefaultVarStorageClass) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class // https://gpuweb.github.io/gpuweb/wgsl/#storage-class
auto* buf = Structure("S", {Member("m", ty.i32())}, auto* buf = Structure("S", {Member("m", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* function = Var("f", ty.i32()); auto* function = Var("f", ty.i32());
auto* private_ = Global("p", ty.i32(), ast::StorageClass::kPrivate); auto* private_ = Global("p", ty.i32(), ast::StorageClass::kPrivate);
auto* workgroup = Global("w", ty.i32(), ast::StorageClass::kWorkgroup); auto* workgroup = Global("w", ty.i32(), ast::StorageClass::kWorkgroup);
@ -264,8 +262,7 @@ TEST_F(ResolverVarLetTest, DefaultVarStorageClass) {
TEST_F(ResolverVarLetTest, ExplicitVarStorageClass) { TEST_F(ResolverVarLetTest, ExplicitVarStorageClass) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class // https://gpuweb.github.io/gpuweb/wgsl/#storage-class
auto* buf = Structure("S", {Member("m", ty.i32())}, auto* buf = Structure("S", {Member("m", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* storage = Global("sb", ty.Of(buf), ast::StorageClass::kStorage, auto* storage = Global("sb", ty.Of(buf), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
@ -285,7 +282,7 @@ TEST_F(ResolverVarLetTest, LetInheritsAccessFromOriginatingVariable) {
// struct Inner { // struct Inner {
// arr: array<i32, 4>; // arr: array<i32, 4>;
// } // }
// [[block]] struct S { // struct S {
// inner: Inner; // inner: Inner;
// } // }
// @group(0) @binding(0) var<storage, read_write> s : S; // @group(0) @binding(0) var<storage, read_write> s : S;
@ -293,8 +290,7 @@ TEST_F(ResolverVarLetTest, LetInheritsAccessFromOriginatingVariable) {
// let p = &s.inner.arr[2]; // let p = &s.inner.arr[2];
// } // }
auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())}); auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())});
auto* buf = Structure("S", {Member("inner", ty.Of(inner))}, auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
{create<ast::StructBlockAttribute>()});
auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage, auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver.h"
#include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/resolver/resolver_test_helper.h"
@ -220,7 +219,7 @@ TEST_F(ResolverVarLetValidationTest, InferredPtrStorageAccessMismatch) {
// struct Inner { // struct Inner {
// arr: array<i32, 4>; // arr: array<i32, 4>;
// } // }
// [[block]] struct S { // struct S {
// inner: Inner; // inner: Inner;
// } // }
// @group(0) @binding(0) var<storage> s : S; // @group(0) @binding(0) var<storage> s : S;
@ -228,8 +227,7 @@ TEST_F(ResolverVarLetValidationTest, InferredPtrStorageAccessMismatch) {
// let p : pointer<storage, i32, read_write> = &s.inner.arr[2]; // let p : pointer<storage, i32, read_write> = &s.inner.arr[2];
// } // }
auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())}); auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())});
auto* buf = Structure("S", {Member("inner", ty.Of(inner))}, auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
{create<ast::StructBlockAttribute>()});
auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage, auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),
@ -262,8 +260,7 @@ TEST_F(ResolverVarLetValidationTest, NonConstructibleType_Atomic) {
} }
TEST_F(ResolverVarLetValidationTest, NonConstructibleType_RuntimeArray) { TEST_F(ResolverVarLetValidationTest, NonConstructibleType_RuntimeArray) {
auto* s = Structure("S", {Member(Source{{56, 78}}, "m", ty.array(ty.i32()))}, auto* s = Structure("S", {Member(Source{{56, 78}}, "m", ty.array(ty.i32()))});
{StructBlock()});
auto* v = Var(Source{{12, 34}}, "v", ty.Of(s)); auto* v = Var(Source{{12, 34}}, "v", ty.Of(s));
WrapInFunction(v); WrapInFunction(v);

View File

@ -34,7 +34,7 @@ TEST_F(LocalizeStructArrayAssignmentTest, EmptyModule) {
TEST_F(LocalizeStructArrayAssignmentTest, StructArray) { TEST_F(LocalizeStructArrayAssignmentTest, StructArray) {
auto* src = R"( auto* src = R"(
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
}; };
@ -57,7 +57,6 @@ fn main() {
)"; )";
auto* expect = R"( auto* expect = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
} }
@ -109,7 +108,7 @@ struct InnerS {
v : i32; v : i32;
}; };
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
}; };
)"; )";
@ -137,7 +136,6 @@ struct InnerS {
v : i32; v : i32;
} }
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
} }
@ -150,7 +148,7 @@ struct Uniforms {
TEST_F(LocalizeStructArrayAssignmentTest, StructStructArray) { TEST_F(LocalizeStructArrayAssignmentTest, StructStructArray) {
auto* src = R"( auto* src = R"(
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
}; };
@ -177,7 +175,6 @@ fn main() {
)"; )";
auto* expect = R"( auto* expect = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
} }
@ -237,7 +234,7 @@ struct InnerS {
v : i32; v : i32;
}; };
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
}; };
)"; )";
@ -269,7 +266,6 @@ struct InnerS {
v : i32; v : i32;
} }
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
} }
@ -282,7 +278,7 @@ struct Uniforms {
TEST_F(LocalizeStructArrayAssignmentTest, StructArrayArray) { TEST_F(LocalizeStructArrayAssignmentTest, StructArrayArray) {
auto* src = R"( auto* src = R"(
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
j : u32; j : u32;
}; };
@ -306,7 +302,6 @@ fn main() {
)"; )";
auto* expect = R"( auto* expect = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
j : u32; j : u32;
@ -342,7 +337,7 @@ fn main() {
TEST_F(LocalizeStructArrayAssignmentTest, StructArrayStruct) { TEST_F(LocalizeStructArrayAssignmentTest, StructArrayStruct) {
auto* src = R"( auto* src = R"(
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
}; };
@ -369,7 +364,6 @@ fn main() {
)"; )";
auto* expect = R"( auto* expect = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
} }
@ -408,7 +402,7 @@ fn main() {
TEST_F(LocalizeStructArrayAssignmentTest, StructArrayStructArray) { TEST_F(LocalizeStructArrayAssignmentTest, StructArrayStructArray) {
auto* src = R"( auto* src = R"(
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
j : u32; j : u32;
}; };
@ -436,7 +430,6 @@ fn main() {
)"; )";
auto* expect = R"( auto* expect = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
j : u32; j : u32;
@ -479,7 +472,7 @@ fn main() {
TEST_F(LocalizeStructArrayAssignmentTest, IndexingWithSideEffectFunc) { TEST_F(LocalizeStructArrayAssignmentTest, IndexingWithSideEffectFunc) {
auto* src = R"( auto* src = R"(
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
j : u32; j : u32;
}; };
@ -513,7 +506,6 @@ fn main() {
)"; )";
auto* expect = R"( auto* expect = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
j : u32; j : u32;
@ -573,7 +565,7 @@ fn main() {
@group(1) @binding(4) var<uniform> uniforms : Uniforms; @group(1) @binding(4) var<uniform> uniforms : Uniforms;
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
j : u32; j : u32;
}; };
@ -615,7 +607,6 @@ fn main() {
@group(1) @binding(4) var<uniform> uniforms : Uniforms; @group(1) @binding(4) var<uniform> uniforms : Uniforms;
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
j : u32; j : u32;
@ -648,7 +639,7 @@ struct InnerS {
TEST_F(LocalizeStructArrayAssignmentTest, ViaPointerArg) { TEST_F(LocalizeStructArrayAssignmentTest, ViaPointerArg) {
auto* src = R"( auto* src = R"(
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
}; };
struct InnerS { struct InnerS {
@ -672,7 +663,6 @@ fn main() {
)"; )";
auto* expect = R"( auto* expect = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
} }
@ -731,7 +721,7 @@ struct OuterS {
@group(1) @binding(4) var<uniform> uniforms : Uniforms; @group(1) @binding(4) var<uniform> uniforms : Uniforms;
@block struct Uniforms { struct Uniforms {
i : u32; i : u32;
}; };
)"; )";
@ -763,7 +753,6 @@ struct OuterS {
@group(1) @binding(4) var<uniform> uniforms : Uniforms; @group(1) @binding(4) var<uniform> uniforms : Uniforms;
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
} }
@ -776,7 +765,6 @@ struct Uniforms {
TEST_F(LocalizeStructArrayAssignmentTest, ViaPointerVar) { TEST_F(LocalizeStructArrayAssignmentTest, ViaPointerVar) {
auto* src = R"( auto* src = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
}; };
@ -805,7 +793,6 @@ fn main() {
)"; )";
auto* expect = R"( auto* expect = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
} }
@ -845,12 +832,10 @@ fn main() {
TEST_F(LocalizeStructArrayAssignmentTest, VectorAssignment) { TEST_F(LocalizeStructArrayAssignmentTest, VectorAssignment) {
auto* src = R"( auto* src = R"(
@block
struct Uniforms { struct Uniforms {
i : u32; i : u32;
} }
@block
struct OuterS { struct OuterS {
a1 : array<u32, 8>; a1 : array<u32, 8>;
} }

View File

@ -108,7 +108,7 @@ TEST_F(CreateASTTypeForTest, ArrayNonImplicitStride) {
TEST_F(CreateASTTypeForTest, Struct) { TEST_F(CreateASTTypeForTest, Struct) {
auto* str = create([](ProgramBuilder& b) { auto* str = create([](ProgramBuilder& b) {
auto* decl = b.Structure("S", {}, {}); auto* decl = b.Structure("S", {});
return b.create<sem::Struct>(decl, decl->name, sem::StructMemberList{}, return b.create<sem::Struct>(decl, decl->name, sem::StructMemberList{},
4u /* align */, 4u /* size */, 4u /* align */, 4u /* size */,
4u /* size_no_padding */); 4u /* size_no_padding */);

View File

@ -14,7 +14,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/ast/workgroup_attribute.h" #include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/writer/glsl/test_helper.h" #include "src/tint/writer/glsl/test_helper.h"
@ -329,8 +328,7 @@ tint_symbol_2 vert_main2() {
#endif #endif
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())}, auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
{create<ast::StructBlockAttribute>()});
auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),
@ -385,8 +383,7 @@ void frag_main() {
TEST_F(GlslGeneratorImplTest_Function, TEST_F(GlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_UniformStruct) { Emit_Attribute_EntryPoint_With_UniformStruct) {
auto* s = Structure("Uniforms", {Member("coord", ty.vec4<f32>())}, auto* s = Structure("Uniforms", {Member("coord", ty.vec4<f32>())});
{create<ast::StructBlockAttribute>()});
Global("uniforms", ty.Of(s), ast::StorageClass::kUniform, Global("uniforms", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
@ -429,12 +426,10 @@ void frag_main() {
TEST_F(GlslGeneratorImplTest_Function, TEST_F(GlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_RW_StorageBuffer_Read) { Emit_Attribute_EntryPoint_With_RW_StorageBuffer_Read) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, Global("coord", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
@ -484,12 +479,10 @@ void main() {
TEST_F(GlslGeneratorImplTest_Function, TEST_F(GlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_RO_StorageBuffer_Read) { Emit_Attribute_EntryPoint_With_RO_StorageBuffer_Read) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -539,12 +532,10 @@ void main() {
TEST_F(GlslGeneratorImplTest_Function, TEST_F(GlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_WO_StorageBuffer_Store) { Emit_Attribute_EntryPoint_With_WO_StorageBuffer_Store) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{ ast::AttributeList{
@ -590,12 +581,10 @@ void main() {
TEST_F(GlslGeneratorImplTest_Function, TEST_F(GlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_StorageBuffer_Store) { Emit_Attribute_EntryPoint_With_StorageBuffer_Store) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, Global("coord", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
@ -642,8 +631,7 @@ void main() {
TEST_F(GlslGeneratorImplTest_Function, TEST_F(GlslGeneratorImplTest_Function,
Emit_Attribute_Called_By_EntryPoint_With_Uniform) { Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
auto* s = Structure("S", {Member("x", ty.f32())}, auto* s = Structure("S", {Member("x", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kUniform, Global("coord", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),
@ -694,8 +682,7 @@ void frag_main() {
TEST_F(GlslGeneratorImplTest_Function, TEST_F(GlslGeneratorImplTest_Function,
Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) { Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) {
auto* s = Structure("S", {Member("x", ty.f32())}, auto* s = Structure("S", {Member("x", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, Global("coord", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
@ -912,7 +899,7 @@ float[5] my_func() {
// https://crbug.com/tint/297 // https://crbug.com/tint/297
TEST_F(GlslGeneratorImplTest_Function, TEST_F(GlslGeneratorImplTest_Function,
Emit_Multiple_EntryPoint_With_Same_ModuleVar) { Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
// [[block]] struct Data { // struct Data {
// d : f32; // d : f32;
// }; // };
// @binding(0) @group(0) var<storage> data : Data; // @binding(0) @group(0) var<storage> data : Data;
@ -929,8 +916,7 @@ TEST_F(GlslGeneratorImplTest_Function,
// return; // return;
// } // }
auto* s = Structure("Data", {Member("d", ty.f32())}, auto* s = Structure("Data", {Member("d", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{

View File

@ -14,7 +14,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/writer/glsl/test_helper.h" #include "src/tint/writer/glsl/test_helper.h"
namespace tint { namespace tint {
@ -95,8 +94,7 @@ class GlslGeneratorImplTest_MemberAccessorBase : public BASE {
void SetupStorageBuffer(ast::StructMemberList members) { void SetupStorageBuffer(ast::StructMemberList members) {
ProgramBuilder& b = *this; ProgramBuilder& b = *this;
auto* s = auto* s = b.Structure("Data", members);
b.Structure("Data", members, {b.create<ast::StructBlockAttribute>()});
b.Global("data", b.ty.Of(s), ast::StorageClass::kStorage, b.Global("data", b.ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,

View File

@ -14,7 +14,6 @@
#include "src/tint/ast/call_statement.h" #include "src/tint/ast/call_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/writer/glsl/test_helper.h" #include "src/tint/writer/glsl/test_helper.h"
@ -26,8 +25,7 @@ namespace {
using GlslSanitizerTest = TestHelper; using GlslSanitizerTest = TestHelper;
TEST_F(GlslSanitizerTest, Call_ArrayLength) { TEST_F(GlslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -67,12 +65,10 @@ void main() {
} }
TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
auto* s = Structure("my_struct", auto* s = Structure("my_struct", {
{ Member(0, "z", ty.f32()),
Member(0, "z", ty.f32()), Member(4, "a", ty.array<f32>(4)),
Member(4, "a", ty.array<f32>(4)), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -114,8 +110,7 @@ void main() {
} }
TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) { TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),

View File

@ -15,7 +15,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/call_statement.h" #include "src/tint/ast/call_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/sem/depth_texture_type.h" #include "src/tint/sem/depth_texture_type.h"
#include "src/tint/sem/multisampled_texture_type.h" #include "src/tint/sem/multisampled_texture_type.h"
#include "src/tint/sem/sampled_texture_type.h" #include "src/tint/sem/sampled_texture_type.h"
@ -189,12 +188,10 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
} }
TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) { TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("a", ty.i32(), {MemberOffset(0)}),
Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(8)}),
Member("b", ty.f32(), {MemberOffset(8)}), });
},
{create<ast::StructBlockAttribute>()});
Global("g", ty.Of(s), ast::StorageClass::kPrivate); Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -14,7 +14,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/ast/workgroup_attribute.h" #include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/writer/hlsl/test_helper.h" #include "src/tint/writer/hlsl/test_helper.h"
@ -337,8 +336,7 @@ tint_symbol_1 vert_main2() {
} }
TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())}, auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
{create<ast::StructBlockAttribute>()});
auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),
@ -386,8 +384,7 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, TEST_F(HlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_UniformStruct) { Emit_Attribute_EntryPoint_With_UniformStruct) {
auto* s = Structure("Uniforms", {Member("coord", ty.vec4<f32>())}, auto* s = Structure("Uniforms", {Member("coord", ty.vec4<f32>())});
{create<ast::StructBlockAttribute>()});
Global("uniforms", ty.Of(s), ast::StorageClass::kUniform, Global("uniforms", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
@ -423,12 +420,10 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, TEST_F(HlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_RW_StorageBuffer_Read) { Emit_Attribute_EntryPoint_With_RW_StorageBuffer_Read) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, Global("coord", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
@ -464,12 +459,10 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, TEST_F(HlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_RO_StorageBuffer_Read) { Emit_Attribute_EntryPoint_With_RO_StorageBuffer_Read) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -504,12 +497,10 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, TEST_F(HlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_WO_StorageBuffer_Store) { Emit_Attribute_EntryPoint_With_WO_StorageBuffer_Store) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{ ast::AttributeList{
@ -541,12 +532,10 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, TEST_F(HlslGeneratorImplTest_Function,
Emit_Attribute_EntryPoint_With_StorageBuffer_Store) { Emit_Attribute_EntryPoint_With_StorageBuffer_Store) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, Global("coord", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
@ -579,8 +568,7 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, TEST_F(HlslGeneratorImplTest_Function,
Emit_Attribute_Called_By_EntryPoint_With_Uniform) { Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
auto* s = Structure("S", {Member("x", ty.f32())}, auto* s = Structure("S", {Member("x", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kUniform, Global("coord", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),
@ -624,8 +612,7 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, TEST_F(HlslGeneratorImplTest_Function,
Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) { Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) {
auto* s = Structure("S", {Member("x", ty.f32())}, auto* s = Structure("S", {Member("x", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, Global("coord", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
@ -856,7 +843,7 @@ TEST_F(HlslGeneratorImplTest_Function,
// https://crbug.com/tint/297 // https://crbug.com/tint/297
TEST_F(HlslGeneratorImplTest_Function, TEST_F(HlslGeneratorImplTest_Function,
Emit_Multiple_EntryPoint_With_Same_ModuleVar) { Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
// [[block]] struct Data { // struct Data {
// d : f32; // d : f32;
// }; // };
// @binding(0) @group(0) var<storage> data : Data; // @binding(0) @group(0) var<storage> data : Data;
@ -873,8 +860,7 @@ TEST_F(HlslGeneratorImplTest_Function,
// return; // return;
// } // }
auto* s = Structure("Data", {Member("d", ty.f32())}, auto* s = Structure("Data", {Member("d", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{

View File

@ -14,7 +14,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/writer/hlsl/test_helper.h" #include "src/tint/writer/hlsl/test_helper.h"
namespace tint { namespace tint {
@ -95,8 +94,7 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE {
void SetupStorageBuffer(ast::StructMemberList members) { void SetupStorageBuffer(ast::StructMemberList members) {
ProgramBuilder& b = *this; ProgramBuilder& b = *this;
auto* s = auto* s = b.Structure("Data", members);
b.Structure("Data", members, {b.create<ast::StructBlockAttribute>()});
b.Global("data", b.ty.Of(s), ast::StorageClass::kStorage, b.Global("data", b.ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,

View File

@ -14,7 +14,6 @@
#include "src/tint/ast/call_statement.h" #include "src/tint/ast/call_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/writer/hlsl/test_helper.h" #include "src/tint/writer/hlsl/test_helper.h"
@ -26,8 +25,7 @@ namespace {
using HlslSanitizerTest = TestHelper; using HlslSanitizerTest = TestHelper;
TEST_F(HlslSanitizerTest, Call_ArrayLength) { TEST_F(HlslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -62,12 +60,10 @@ void a_func() {
} }
TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
auto* s = Structure("my_struct", auto* s = Structure("my_struct", {
{ Member(0, "z", ty.f32()),
Member(0, "z", ty.f32()), Member(4, "a", ty.array<f32>(4)),
Member(4, "a", ty.array<f32>(4)), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -103,8 +99,7 @@ void a_func() {
} }
TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) { TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -145,8 +140,7 @@ void a_func() {
} }
TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),

View File

@ -15,7 +15,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/call_statement.h" #include "src/tint/ast/call_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/sem/depth_texture_type.h" #include "src/tint/sem/depth_texture_type.h"
#include "src/tint/sem/multisampled_texture_type.h" #include "src/tint/sem/multisampled_texture_type.h"
#include "src/tint/sem/sampled_texture_type.h" #include "src/tint/sem/sampled_texture_type.h"
@ -154,12 +153,10 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) {
} }
TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) { TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) {
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),
@ -207,12 +204,10 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
} }
TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) { TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("a", ty.i32(), {MemberOffset(0)}),
Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(8)}),
Member("b", ty.f32(), {MemberOffset(8)}), });
},
{create<ast::StructBlockAttribute>()});
Global("g", ty.Of(s), ast::StorageClass::kPrivate); Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/writer/msl/test_helper.h" #include "src/tint/writer/msl/test_helper.h"
@ -329,12 +328,10 @@ vertex tint_symbol_1 vert_main2() {
TEST_F(MslGeneratorImplTest, TEST_F(MslGeneratorImplTest,
Emit_FunctionAttribute_EntryPoint_With_RW_StorageBuffer) { Emit_FunctionAttribute_EntryPoint_With_RW_StorageBuffer) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, Global("coord", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
@ -376,12 +373,10 @@ fragment void frag_main(device Data* tint_symbol [[buffer(0)]]) {
TEST_F(MslGeneratorImplTest, TEST_F(MslGeneratorImplTest,
Emit_FunctionAttribute_EntryPoint_With_RO_StorageBuffer) { Emit_FunctionAttribute_EntryPoint_With_RO_StorageBuffer) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -421,8 +416,7 @@ fragment void frag_main(const device Data* tint_symbol [[buffer(0)]]) {
} }
TEST_F(MslGeneratorImplTest, Emit_Attribute_Called_By_EntryPoint_With_Uniform) { TEST_F(MslGeneratorImplTest, Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())}, auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
{create<ast::StructBlockAttribute>()});
auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),
@ -474,12 +468,10 @@ fragment void frag_main(const constant UBO* tint_symbol_1 [[buffer(0)]]) {
TEST_F(MslGeneratorImplTest, TEST_F(MslGeneratorImplTest,
Emit_FunctionAttribute_Called_By_EntryPoint_With_RW_StorageBuffer) { Emit_FunctionAttribute_Called_By_EntryPoint_With_RW_StorageBuffer) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, Global("coord", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
@ -532,12 +524,10 @@ fragment void frag_main(device Data* tint_symbol_1 [[buffer(0)]]) {
TEST_F(MslGeneratorImplTest, TEST_F(MslGeneratorImplTest,
Emit_FunctionAttribute_Called_By_EntryPoint_With_RO_StorageBuffer) { Emit_FunctionAttribute_Called_By_EntryPoint_With_RO_StorageBuffer) {
auto* s = Structure("Data", auto* s = Structure("Data", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -644,7 +634,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayReturn) {
// https://crbug.com/tint/297 // https://crbug.com/tint/297
TEST_F(MslGeneratorImplTest, TEST_F(MslGeneratorImplTest,
Emit_Function_Multiple_EntryPoint_With_Same_ModuleVar) { Emit_Function_Multiple_EntryPoint_With_Same_ModuleVar) {
// [[block]] struct Data { // struct Data {
// d : f32; // d : f32;
// }; // };
// @binding(0) @group(0) var<storage> data : Data; // @binding(0) @group(0) var<storage> data : Data;
@ -659,8 +649,7 @@ TEST_F(MslGeneratorImplTest,
// return; // return;
// } // }
auto* s = Structure("Data", {Member("d", ty.f32())}, auto* s = Structure("Data", {Member("d", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{

View File

@ -15,7 +15,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/call_statement.h" #include "src/tint/ast/call_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/writer/msl/test_helper.h" #include "src/tint/writer/msl/test_helper.h"
@ -29,8 +28,7 @@ using ::testing::HasSubstr;
using MslSanitizerTest = TestHelper; using MslSanitizerTest = TestHelper;
TEST_F(MslSanitizerTest, Call_ArrayLength) { TEST_F(MslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -72,12 +70,10 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) {
} }
TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
auto* s = Structure("my_struct", auto* s = Structure("my_struct", {
{ Member(0, "z", ty.f32()),
Member(0, "z", ty.f32()), Member(4, "a", ty.array<f32>(4)),
Member(4, "a", ty.array<f32>(4)), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -121,8 +117,7 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) {
} }
TEST_F(MslSanitizerTest, Call_ArrayLength_ViaLets) { TEST_F(MslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -170,8 +165,7 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) {
} }
TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -227,8 +221,7 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(29)]]) {
TEST_F(MslSanitizerTest, TEST_F(MslSanitizerTest,
Call_ArrayLength_ArrayLengthFromUniformMissingBinding) { Call_ArrayLength_ArrayLengthFromUniformMissingBinding) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),

View File

@ -16,7 +16,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/sem/depth_multisampled_texture_type.h" #include "src/tint/sem/depth_multisampled_texture_type.h"
#include "src/tint/sem/depth_texture_type.h" #include "src/tint/sem/depth_texture_type.h"
#include "src/tint/sem/multisampled_texture_type.h" #include "src/tint/sem/multisampled_texture_type.h"
@ -121,8 +120,7 @@ TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) {
} }
TEST_F(MslGeneratorImplTest, EmitType_ArrayWithStride) { TEST_F(MslGeneratorImplTest, EmitType_ArrayWithStride) {
auto* s = Structure("s", {Member("arr", ty.array<f32, 4>(64))}, auto* s = Structure("s", {Member("arr", ty.array<f32, 4>(64))});
{create<ast::StructBlockAttribute>()});
auto* ubo = Global("ubo", ty.Of(s), ast::StorageClass::kUniform, auto* ubo = Global("ubo", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0),
@ -231,37 +229,35 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) {
} }
TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) { TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) {
auto* s = auto* s = Structure(
Structure("S", "S", {
{ Member("a", ty.i32(), {MemberSize(32)}),
Member("a", ty.i32(), {MemberSize(32)}), Member("b", ty.f32(), {MemberAlign(128), MemberSize(128)}),
Member("b", ty.f32(), {MemberAlign(128), MemberSize(128)}), Member("c", ty.vec2<f32>()),
Member("c", ty.vec2<f32>()), Member("d", ty.u32()),
Member("d", ty.u32()), Member("e", ty.vec3<f32>()),
Member("e", ty.vec3<f32>()), Member("f", ty.u32()),
Member("f", ty.u32()), Member("g", ty.vec4<f32>()),
Member("g", ty.vec4<f32>()), Member("h", ty.u32()),
Member("h", ty.u32()), Member("i", ty.mat2x2<f32>()),
Member("i", ty.mat2x2<f32>()), Member("j", ty.u32()),
Member("j", ty.u32()), Member("k", ty.mat2x3<f32>()),
Member("k", ty.mat2x3<f32>()), Member("l", ty.u32()),
Member("l", ty.u32()), Member("m", ty.mat2x4<f32>()),
Member("m", ty.mat2x4<f32>()), Member("n", ty.u32()),
Member("n", ty.u32()), Member("o", ty.mat3x2<f32>()),
Member("o", ty.mat3x2<f32>()), Member("p", ty.u32()),
Member("p", ty.u32()), Member("q", ty.mat3x3<f32>()),
Member("q", ty.mat3x3<f32>()), Member("r", ty.u32()),
Member("r", ty.u32()), Member("s", ty.mat3x4<f32>()),
Member("s", ty.mat3x4<f32>()), Member("t", ty.u32()),
Member("t", ty.u32()), Member("u", ty.mat4x2<f32>()),
Member("u", ty.mat4x2<f32>()), Member("v", ty.u32()),
Member("v", ty.u32()), Member("w", ty.mat4x3<f32>()),
Member("w", ty.mat4x3<f32>()), Member("x", ty.u32()),
Member("x", ty.u32()), Member("y", ty.mat4x4<f32>()),
Member("y", ty.mat4x4<f32>()), Member("z", ty.f32()),
Member("z", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -363,15 +359,13 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) {
Member("b", ty.f32()), Member("b", ty.f32()),
}); });
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.Of(inner_x)),
Member("b", ty.Of(inner_x)), Member("c", ty.f32()),
Member("c", ty.f32()), Member("d", ty.Of(inner_y)),
Member("d", ty.Of(inner_y)), Member("e", ty.f32()),
Member("e", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -456,16 +450,14 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) {
// array_z: size(4), align(4) // array_z: size(4), align(4)
auto* array_z = ty.array<f32>(); auto* array_z = ty.array<f32>();
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", array_x),
Member("b", array_x), Member("c", ty.f32()),
Member("c", ty.f32()), Member("d", array_y),
Member("d", array_y), Member("e", ty.f32()),
Member("e", ty.f32()), Member("f", array_z),
Member("f", array_z), });
},
ast::AttributeList{create<ast::StructBlockAttribute>()});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -544,13 +536,11 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) {
// array: size(64), align(16) // array: size(64), align(16)
auto* array = ty.array(ty.vec3<f32>(), 4); auto* array = ty.array(ty.vec3<f32>(), 4);
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", array),
Member("b", array), Member("c", ty.i32()),
Member("c", ty.i32()), });
},
ast::AttributeList{create<ast::StructBlockAttribute>()});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -612,8 +602,7 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) {
Member("tint_pad_28", ty.u32()), Member("tint_pad_28", ty.u32()),
Member("tint_pad_4", ty.mat4x4<f32>()), Member("tint_pad_4", ty.mat4x4<f32>()),
Member("tint_pad_21", ty.f32()), Member("tint_pad_21", ty.f32()),
}, });
{create<ast::StructBlockAttribute>()});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -671,12 +660,10 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) {
} }
TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) { TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) {
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32()),
Member("b", ty.f32()), });
},
{create<ast::StructBlockAttribute>()});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{

View File

@ -14,7 +14,6 @@
#include "src/tint/ast/call_statement.h" #include "src/tint/ast/call_statement.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/sem/depth_texture_type.h" #include "src/tint/sem/depth_texture_type.h"
#include "src/tint/utils/string.h" #include "src/tint/utils/string.h"
#include "src/tint/writer/spirv/spv_dump.h" #include "src/tint/writer/spirv/spv_dump.h"
@ -1482,8 +1481,7 @@ OpFunctionEnd
} }
TEST_F(BuiltinBuilderTest, Call_ArrayLength) { TEST_F(BuiltinBuilderTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -1527,12 +1525,10 @@ OpReturn
} }
TEST_F(BuiltinBuilderTest, Call_ArrayLength_OtherMembersInStruct) { TEST_F(BuiltinBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
auto* s = Structure("my_struct", auto* s = Structure("my_struct", {
{ Member("z", ty.f32()),
Member("z", ty.f32()), Member(4, "a", ty.array<f32>(4)),
Member(4, "a", ty.array<f32>(4)), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -1576,8 +1572,7 @@ OpReturn
} }
TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets) { TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -1626,7 +1621,7 @@ OpReturn
} }
TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) { TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) {
// [[block]] struct my_struct { // struct my_struct {
// a : @stride(4) array<f32>; // a : @stride(4) array<f32>;
// }; // };
// @binding(1) @group(2) var<storage, read> b : my_struct; // @binding(1) @group(2) var<storage, read> b : my_struct;
@ -1637,8 +1632,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) {
// let p3 = &((*p).a); // let p3 = &((*p).a);
// arrayLength(&*p3); // arrayLength(&*p3);
// } // }
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))}, auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -1689,7 +1683,7 @@ OpReturn
} }
TEST_F(BuiltinBuilderTest, Call_AtomicLoad) { TEST_F(BuiltinBuilderTest, Call_AtomicLoad) {
// [[block]] struct S { // struct S {
// u : atomic<u32>; // u : atomic<u32>;
// i : atomic<i32>; // i : atomic<i32>;
// } // }
@ -1700,12 +1694,10 @@ TEST_F(BuiltinBuilderTest, Call_AtomicLoad) {
// let u : u32 = atomicLoad(&b.u); // let u : u32 = atomicLoad(&b.u);
// let i : i32 = atomicLoad(&b.i); // let i : i32 = atomicLoad(&b.i);
// } // }
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("u", ty.atomic<u32>()),
Member("u", ty.atomic<u32>()), Member("i", ty.atomic<i32>()),
Member("i", ty.atomic<i32>()), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -1755,7 +1747,7 @@ OpReturn
} }
TEST_F(BuiltinBuilderTest, Call_AtomicStore) { TEST_F(BuiltinBuilderTest, Call_AtomicStore) {
// [[block]] struct S { // struct S {
// u : atomic<u32>; // u : atomic<u32>;
// i : atomic<i32>; // i : atomic<i32>;
// } // }
@ -1768,12 +1760,10 @@ TEST_F(BuiltinBuilderTest, Call_AtomicStore) {
// atomicStore(&b.u, u); // atomicStore(&b.u, u);
// atomicStore(&b.i, i); // atomicStore(&b.i, i);
// } // }
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("u", ty.atomic<u32>()),
Member("u", ty.atomic<u32>()), Member("i", ty.atomic<i32>()),
Member("i", ty.atomic<i32>()), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -1835,7 +1825,7 @@ OpReturn
using Builtin_Builtin_AtomicRMW_i32 = BuiltinBuilderTestWithParam<BuiltinData>; using Builtin_Builtin_AtomicRMW_i32 = BuiltinBuilderTestWithParam<BuiltinData>;
TEST_P(Builtin_Builtin_AtomicRMW_i32, Test) { TEST_P(Builtin_Builtin_AtomicRMW_i32, Test) {
// [[block]] struct S { // struct S {
// v : atomic<i32>; // v : atomic<i32>;
// } // }
// //
@ -1845,11 +1835,9 @@ TEST_P(Builtin_Builtin_AtomicRMW_i32, Test) {
// var v = 10; // var v = 10;
// let x : i32 = atomicOP(&b.v, v); // let x : i32 = atomicOP(&b.v, v);
// } // }
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("v", ty.atomic<i32>()),
Member("v", ty.atomic<i32>()), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -1912,7 +1900,7 @@ INSTANTIATE_TEST_SUITE_P(
using Builtin_Builtin_AtomicRMW_u32 = BuiltinBuilderTestWithParam<BuiltinData>; using Builtin_Builtin_AtomicRMW_u32 = BuiltinBuilderTestWithParam<BuiltinData>;
TEST_P(Builtin_Builtin_AtomicRMW_u32, Test) { TEST_P(Builtin_Builtin_AtomicRMW_u32, Test) {
// [[block]] struct S { // struct S {
// v : atomic<u32>; // v : atomic<u32>;
// } // }
// //
@ -1922,11 +1910,9 @@ TEST_P(Builtin_Builtin_AtomicRMW_u32, Test) {
// var v = 10u; // var v = 10u;
// let x : u32 = atomicOP(&b.v, v); // let x : u32 = atomicOP(&b.v, v);
// } // }
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("v", ty.atomic<u32>()),
Member("v", ty.atomic<u32>()), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -1987,7 +1973,7 @@ INSTANTIATE_TEST_SUITE_P(
BuiltinData{"atomicXor", "OpAtomicXor"})); BuiltinData{"atomicXor", "OpAtomicXor"}));
TEST_F(BuiltinBuilderTest, Call_AtomicExchange) { TEST_F(BuiltinBuilderTest, Call_AtomicExchange) {
// [[block]] struct S { // struct S {
// u : atomic<u32>; // u : atomic<u32>;
// i : atomic<i32>; // i : atomic<i32>;
// } // }
@ -2000,12 +1986,10 @@ TEST_F(BuiltinBuilderTest, Call_AtomicExchange) {
// let r : u32 = atomicExchange(&b.u, u); // let r : u32 = atomicExchange(&b.u, u);
// let s : i32 = atomicExchange(&b.i, i); // let s : i32 = atomicExchange(&b.i, i);
// } // }
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("u", ty.atomic<u32>()),
Member("u", ty.atomic<u32>()), Member("i", ty.atomic<i32>()),
Member("i", ty.atomic<i32>()), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),
@ -2069,7 +2053,7 @@ OpReturn
} }
TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) { TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) {
// [[block]] struct S { // struct S {
// u : atomic<u32>; // u : atomic<u32>;
// i : atomic<i32>; // i : atomic<i32>;
// } // }
@ -2080,12 +2064,10 @@ TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) {
// let u : vec2<u32> = atomicCompareExchangeWeak(&b.u, 10u); // let u : vec2<u32> = atomicCompareExchangeWeak(&b.u, 10u);
// let i : vec2<i32> = atomicCompareExchangeWeak(&b.i, 10); // let i : vec2<i32> = atomicCompareExchangeWeak(&b.i, 10);
// } // }
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("u", ty.atomic<u32>()),
Member("u", ty.atomic<u32>()), Member("i", ty.atomic<i32>()),
Member("i", ty.atomic<i32>()), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1),

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/writer/spirv/spv_dump.h" #include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h" #include "src/tint/writer/spirv/test_helper.h"
@ -186,7 +185,7 @@ TEST_F(BuilderTest, FunctionType_DeDuplicate) {
// https://crbug.com/tint/297 // https://crbug.com/tint/297
TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
// [[block]] struct Data { // struct Data {
// d : f32; // d : f32;
// }; // };
// @binding(0) @group(0) var<storage> data : Data; // @binding(0) @group(0) var<storage> data : Data;
@ -201,8 +200,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
// return; // return;
// } // }
auto* s = Structure("Data", {Member("d", ty.f32())}, auto* s = Structure("Data", {Member("d", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{

View File

@ -14,7 +14,6 @@
#include "src/tint/ast/id_attribute.h" #include "src/tint/ast/id_attribute.h"
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/writer/spirv/spv_dump.h" #include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h" #include "src/tint/writer/spirv/test_helper.h"
@ -377,12 +376,10 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) {
// }; // };
// var b<storage, read> : A // var b<storage, read> : A
auto* A = Structure("A", auto* A = Structure("A", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.i32()),
Member("b", ty.i32()), });
},
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -423,8 +420,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) {
// type B = A; // type B = A;
// var b<storage, read> : B // var b<storage, read> : B
auto* A = Structure("A", {Member("a", ty.i32())}, auto* A = Structure("A", {Member("a", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* B = Alias("B", ty.Of(A)); auto* B = Alias("B", ty.Of(A));
Global("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -463,8 +459,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) {
// type B = A; // type B = A;
// var<storage, read> b : B // var<storage, read> b : B
auto* A = Structure("A", {Member("a", ty.i32())}, auto* A = Structure("A", {Member("a", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* B = Alias("B", ty.Of(A)); auto* B = Alias("B", ty.Of(A));
Global("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -503,8 +498,7 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) {
// var<storage, read> b : A // var<storage, read> b : A
// var<storage, read_write> c : A // var<storage, read_write> c : A
auto* A = Structure("A", {Member("a", ty.i32())}, auto* A = Structure("A", {Member("a", ty.i32())});
{create<ast::StructBlockAttribute>()});
Global("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, Global("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0),
@ -629,12 +623,10 @@ TEST_F(BuilderTest, GlobalVar_WorkgroupWithZeroInit) {
auto* type_array = ty.array<f32, 16>(); auto* type_array = ty.array<f32, 16>();
auto* var_array = Global("b", type_array, ast::StorageClass::kWorkgroup); auto* var_array = Global("b", type_array, ast::StorageClass::kWorkgroup);
auto* type_struct = Structure("C", auto* type_struct = Structure("C", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.i32()),
Member("b", ty.i32()), });
},
{create<ast::StructBlockAttribute>()});
auto* var_struct = auto* var_struct =
Global("c", ty.Of(type_struct), ast::StorageClass::kWorkgroup); Global("c", ty.Of(type_struct), ast::StorageClass::kWorkgroup);

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/sem/depth_texture_type.h" #include "src/tint/sem/depth_texture_type.h"
#include "src/tint/sem/multisampled_texture_type.h" #include "src/tint/sem/multisampled_texture_type.h"
#include "src/tint/sem/sampled_texture_type.h" #include "src/tint/sem/sampled_texture_type.h"
@ -28,8 +27,7 @@ using BuilderTest_Type = TestHelper;
TEST_F(BuilderTest_Type, GenerateRuntimeArray) { TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
auto* ary = ty.array(ty.i32()); auto* ary = ty.array(ty.i32());
auto* str = auto* str = Structure("S", {Member("x", ary)});
Structure("S", {Member("x", ary)}, {create<ast::StructBlockAttribute>()});
Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),
@ -49,8 +47,7 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
auto* ary = ty.array(ty.i32()); auto* ary = ty.array(ty.i32());
auto* str = auto* str = Structure("S", {Member("x", ary)});
Structure("S", {Member("x", ary)}, {create<ast::StructBlockAttribute>()});
Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0),

View File

@ -41,7 +41,6 @@
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/storage_texture.h" #include "src/tint/ast/storage_texture.h"
#include "src/tint/ast/stride_attribute.h" #include "src/tint/ast/stride_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/struct_member_align_attribute.h" #include "src/tint/ast/struct_member_align_attribute.h"
#include "src/tint/ast/struct_member_offset_attribute.h" #include "src/tint/ast/struct_member_offset_attribute.h"
#include "src/tint/ast/struct_member_size_attribute.h" #include "src/tint/ast/struct_member_size_attribute.h"
@ -713,10 +712,6 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out,
out << ")"; out << ")";
return true; return true;
}, },
[&](const ast::StructBlockAttribute*) { //
out << "block";
return true;
},
[&](const ast::StageAttribute* stage) { [&](const ast::StageAttribute* stage) {
out << "stage(" << stage->stage << ")"; out << "stage(" << stage->stage << ")";
return true; return true;

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
#include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/stage_attribute.h"
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/ast/workgroup_attribute.h" #include "src/tint/ast/workgroup_attribute.h"
#include "src/tint/writer/wgsl/test_helper.h" #include "src/tint/writer/wgsl/test_helper.h"
@ -153,7 +152,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_EntryPoint_ReturnValue) {
// https://crbug.com/tint/297 // https://crbug.com/tint/297
TEST_F(WgslGeneratorImplTest, TEST_F(WgslGeneratorImplTest,
Emit_Function_Multiple_EntryPoint_With_Same_ModuleVar) { Emit_Function_Multiple_EntryPoint_With_Same_ModuleVar) {
// [[block]] struct Data { // struct Data {
// d : f32; // d : f32;
// }; // };
// @binding(0) @group(0) var<storage> data : Data; // @binding(0) @group(0) var<storage> data : Data;
@ -168,8 +167,7 @@ TEST_F(WgslGeneratorImplTest,
// return; // return;
// } // }
auto* s = Structure("Data", {Member("d", ty.f32())}, auto* s = Structure("Data", {Member("d", ty.f32())});
{create<ast::StructBlockAttribute>()});
Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
@ -210,8 +208,7 @@ TEST_F(WgslGeneratorImplTest,
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error(); ASSERT_TRUE(gen.Generate()) << gen.error();
EXPECT_EQ(gen.result(), R"(@block EXPECT_EQ(gen.result(), R"(struct Data {
struct Data {
d : f32; d : f32;
} }

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/sem/depth_texture_type.h" #include "src/tint/sem/depth_texture_type.h"
#include "src/tint/sem/multisampled_texture_type.h" #include "src/tint/sem/multisampled_texture_type.h"
#include "src/tint/sem/sampled_texture_type.h" #include "src/tint/sem/sampled_texture_type.h"
@ -230,18 +229,15 @@ TEST_F(WgslGeneratorImplTest, EmitType_StructSizeDecl) {
} }
TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithAttribute) { TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithAttribute) {
auto* s = Structure("S", auto* s = Structure("S", {
{ Member("a", ty.i32()),
Member("a", ty.i32()), Member("b", ty.f32(), {MemberAlign(8)}),
Member("b", ty.f32(), {MemberAlign(8)}), });
},
{create<ast::StructBlockAttribute>()});
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStructType(s)) << gen.error(); ASSERT_TRUE(gen.EmitStructType(s)) << gen.error();
EXPECT_EQ(gen.result(), R"(@block EXPECT_EQ(gen.result(), R"(struct S {
struct S {
a : i32; a : i32;
@align(8) @align(8)
b : f32; b : f32;
@ -250,21 +246,15 @@ struct S {
} }
TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithEntryPointAttributes) { TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithEntryPointAttributes) {
ast::AttributeList attrs;
attrs.push_back(create<ast::StructBlockAttribute>());
auto* s = Structure( auto* s = Structure(
"S", "S", ast::StructMemberList{
ast::StructMemberList{ Member("a", ty.u32(), {Builtin(ast::Builtin::kVertexIndex)}),
Member("a", ty.u32(), {Builtin(ast::Builtin::kVertexIndex)}), Member("b", ty.f32(), {Location(2u)})});
Member("b", ty.f32(), {Location(2u)})},
attrs);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStructType(s)) << gen.error(); ASSERT_TRUE(gen.EmitStructType(s)) << gen.error();
EXPECT_EQ(gen.result(), R"(@block EXPECT_EQ(gen.result(), R"(struct S {
struct S {
@builtin(vertex_index) @builtin(vertex_index)
a : u32; a : u32;
@location(2) @location(2)

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/tint/ast/struct_block_attribute.h"
#include "src/tint/writer/wgsl/test_helper.h" #include "src/tint/writer/wgsl/test_helper.h"
namespace tint { namespace tint {
@ -43,8 +42,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) {
} }
TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) {
auto* s = Structure("S", {Member("a", ty.i32())}, auto* s = Structure("S", {Member("a", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* v = auto* v =
Global("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Global("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
@ -60,8 +58,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) {
} }
TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Write) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Write) {
auto* s = Structure("S", {Member("a", ty.i32())}, auto* s = Structure("S", {Member("a", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* v = auto* v =
Global("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, Global("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{ ast::AttributeList{
@ -77,8 +74,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Write) {
} }
TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) {
auto* s = Structure("S", {Member("a", ty.i32())}, auto* s = Structure("S", {Member("a", ty.i32())});
{create<ast::StructBlockAttribute>()});
auto* v = Global("a", ty.Of(s), ast::StorageClass::kStorage, auto* v = Global("a", ty.Of(s), ast::StorageClass::kStorage,
ast::Access::kReadWrite, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{

View File

@ -510,7 +510,6 @@ tint_unittests_source_set("tint_unittests_wgsl_reader_src") {
"../../src/tint/reader/wgsl/parser_impl_storage_class_test.cc", "../../src/tint/reader/wgsl/parser_impl_storage_class_test.cc",
"../../src/tint/reader/wgsl/parser_impl_storage_texture_type_test.cc", "../../src/tint/reader/wgsl/parser_impl_storage_texture_type_test.cc",
"../../src/tint/reader/wgsl/parser_impl_struct_attribute_decl_test.cc", "../../src/tint/reader/wgsl/parser_impl_struct_attribute_decl_test.cc",
"../../src/tint/reader/wgsl/parser_impl_struct_attribute_test.cc",
"../../src/tint/reader/wgsl/parser_impl_struct_body_decl_test.cc", "../../src/tint/reader/wgsl/parser_impl_struct_body_decl_test.cc",
"../../src/tint/reader/wgsl/parser_impl_struct_decl_test.cc", "../../src/tint/reader/wgsl/parser_impl_struct_decl_test.cc",
"../../src/tint/reader/wgsl/parser_impl_struct_member_attribute_decl_test.cc", "../../src/tint/reader/wgsl/parser_impl_struct_member_attribute_decl_test.cc",