mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 07:06:11 +00:00
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:
@@ -17,7 +17,6 @@
|
||||
#include "src/tint/ast/disable_validation_attribute.h"
|
||||
#include "src/tint/ast/id_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/inspector/test_inspector_builder.h"
|
||||
#include "src/tint/inspector/test_inspector_runner.h"
|
||||
@@ -764,7 +763,7 @@ TEST_F(InspectorGetEntryPointTest, InputSampleMaskStructReferenced) {
|
||||
ast::StructMemberList members;
|
||||
members.push_back(
|
||||
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"), {});
|
||||
|
||||
Func("ep_func", {in_var}, ty.void_(), {Return()},
|
||||
@@ -797,7 +796,7 @@ TEST_F(InspectorGetEntryPointTest, OutputSampleMaskStructReferenced) {
|
||||
ast::StructMemberList members;
|
||||
members.push_back(Member("inner_sample_mask", ty.u32(),
|
||||
{Builtin(ast::Builtin::kSampleMask)}));
|
||||
Structure("out_struct", members, {});
|
||||
Structure("out_struct", members);
|
||||
|
||||
Func("ep_func", {}, ty.type_name("out_struct"),
|
||||
{Decl(Var("out_var", ty.type_name("out_struct"))), Return("out_var")},
|
||||
@@ -829,7 +828,7 @@ TEST_F(InspectorGetEntryPointTest, InputPositionStructReferenced) {
|
||||
ast::StructMemberList members;
|
||||
members.push_back(Member("inner_position", ty.vec4<f32>(),
|
||||
{Builtin(ast::Builtin::kPosition)}));
|
||||
Structure("in_struct", members, {});
|
||||
Structure("in_struct", members);
|
||||
auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
|
||||
|
||||
Func("ep_func", {in_var}, ty.void_(), {Return()},
|
||||
@@ -861,7 +860,7 @@ TEST_F(InspectorGetEntryPointTest, FrontFacingStructReferenced) {
|
||||
ast::StructMemberList members;
|
||||
members.push_back(Member("inner_position", ty.bool_(),
|
||||
{Builtin(ast::Builtin::kFrontFacing)}));
|
||||
Structure("in_struct", members, {});
|
||||
Structure("in_struct", members);
|
||||
auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
|
||||
|
||||
Func("ep_func", {in_var}, ty.void_(), {Return()},
|
||||
@@ -893,7 +892,7 @@ TEST_F(InspectorGetEntryPointTest, SampleIndexStructReferenced) {
|
||||
ast::StructMemberList members;
|
||||
members.push_back(Member("inner_position", ty.u32(),
|
||||
{Builtin(ast::Builtin::kSampleIndex)}));
|
||||
Structure("in_struct", members, {});
|
||||
Structure("in_struct", members);
|
||||
auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
|
||||
|
||||
Func("ep_func", {in_var}, ty.void_(), {Return()},
|
||||
@@ -925,7 +924,7 @@ TEST_F(InspectorGetEntryPointTest, NumWorkgroupsStructReferenced) {
|
||||
ast::StructMemberList members;
|
||||
members.push_back(Member("inner_position", ty.vec3<u32>(),
|
||||
{Builtin(ast::Builtin::kNumWorkgroups)}));
|
||||
Structure("in_struct", members, {});
|
||||
Structure("in_struct", members);
|
||||
auto* in_var = Param("in_var", ty.type_name("in_struct"), {});
|
||||
|
||||
Func("ep_func", {in_var}, ty.void_(), {Return()},
|
||||
@@ -942,7 +941,7 @@ TEST_F(InspectorGetEntryPointTest, NumWorkgroupsStructReferenced) {
|
||||
TEST_F(InspectorGetEntryPointTest, ImplicitInterpolate) {
|
||||
ast::StructMemberList members;
|
||||
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"), {});
|
||||
|
||||
Func("ep_func", {in_var}, ty.void_(), {Return()},
|
||||
@@ -966,7 +965,7 @@ TEST_P(InspectorGetEntryPointInterpolateTest, Test) {
|
||||
members.push_back(
|
||||
Member("struct_inner", ty.f32(),
|
||||
{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"), {});
|
||||
|
||||
Func("ep_func", {in_var}, ty.void_(), {Return()},
|
||||
@@ -1548,8 +1547,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
|
||||
auto* foo_struct_type = Structure(
|
||||
"foo_type",
|
||||
{Member("0i32", ty.i32()),
|
||||
Member("b", ty.array(ty.u32(), 4, /*stride*/ 16), {MemberAlign(16)})},
|
||||
{create<ast::StructBlockAttribute>()});
|
||||
Member("b", ty.array(ty.u32(), 4, /*stride*/ 16), {MemberAlign(16)})});
|
||||
|
||||
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
|
||||
// from the 4-element array with 16-byte stride.
|
||||
auto* wg_struct_type = MakeStructType(
|
||||
"WgStruct", {ty.i32(), ty.array(ty.i32(), 4, /*stride=*/16)},
|
||||
/*is_block=*/false);
|
||||
"WgStruct", {ty.i32(), ty.array(ty.i32(), 4, /*stride=*/16)});
|
||||
AddWorkgroupStorage("wg_struct_var", ty.Of(wg_struct_type));
|
||||
MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var",
|
||||
{{0, ty.i32()}});
|
||||
@@ -2992,8 +2989,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, StructAlignment) {
|
||||
const auto* wg_struct_type = MakeStructTypeFromMembers(
|
||||
"WgStruct",
|
||||
{MakeStructMember(0, ty.f32(),
|
||||
{create<ast::StructMemberAlignAttribute>(1024)})},
|
||||
/*is_block=*/false);
|
||||
{create<ast::StructMemberAlignAttribute>(1024)})});
|
||||
|
||||
AddWorkgroupStorage("wg_struct_var", ty.Of(wg_struct_type));
|
||||
MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var",
|
||||
|
||||
@@ -91,24 +91,18 @@ std::string InspectorBuilder::StructMemberName(size_t idx,
|
||||
|
||||
const ast::Struct* InspectorBuilder::MakeStructType(
|
||||
const std::string& name,
|
||||
std::vector<const ast::Type*> member_types,
|
||||
bool is_block) {
|
||||
std::vector<const ast::Type*> member_types) {
|
||||
ast::StructMemberList members;
|
||||
for (auto* type : member_types) {
|
||||
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 std::string& name,
|
||||
ast::StructMemberList members,
|
||||
bool is_block) {
|
||||
ast::AttributeList attrs;
|
||||
if (is_block) {
|
||||
attrs.push_back(create<ast::StructBlockAttribute>());
|
||||
}
|
||||
return Structure(name, std::move(members), attrs);
|
||||
ast::StructMemberList members) {
|
||||
return Structure(name, std::move(members));
|
||||
}
|
||||
|
||||
const ast::StructMember* InspectorBuilder::MakeStructMember(
|
||||
@@ -121,13 +115,13 @@ const ast::StructMember* InspectorBuilder::MakeStructMember(
|
||||
const ast::Struct* InspectorBuilder::MakeUniformBufferType(
|
||||
const std::string& name,
|
||||
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(
|
||||
const std::string& name,
|
||||
std::vector<const ast::Type*> member_types) {
|
||||
MakeStructType(name, member_types, true);
|
||||
MakeStructType(name, member_types);
|
||||
return [this, name] { return ty.type_name(name); };
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "src/tint/ast/disable_validation_attribute.h"
|
||||
#include "src/tint/ast/id_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/program_builder.h"
|
||||
#include "src/tint/sem/depth_texture_type.h"
|
||||
@@ -153,20 +152,16 @@ class InspectorBuilder : public ProgramBuilder {
|
||||
/// Generates a struct type
|
||||
/// @param name name for the type
|
||||
/// @param member_types a vector of member types
|
||||
/// @param is_block whether or not to decorate as a Block
|
||||
/// @returns a struct type
|
||||
const ast::Struct* MakeStructType(const std::string& name,
|
||||
std::vector<const ast::Type*> member_types,
|
||||
bool is_block);
|
||||
std::vector<const ast::Type*> member_types);
|
||||
|
||||
/// Generates a struct type from a list of member nodes.
|
||||
/// @param name name for the struct type
|
||||
/// @param members a vector of members
|
||||
/// @param is_block whether or not to decorate as a Block
|
||||
/// @returns a struct type
|
||||
const ast::Struct* MakeStructTypeFromMembers(const std::string& name,
|
||||
ast::StructMemberList members,
|
||||
bool is_block);
|
||||
ast::StructMemberList members);
|
||||
|
||||
/// Generates a struct member with a specified index and type.
|
||||
/// @param index index of the field within the struct
|
||||
|
||||
Reference in New Issue
Block a user