diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp index ad56d08b5e..c18f8879f7 100644 --- a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp @@ -562,7 +562,7 @@ ResultOrError ShaderModule::Compile( wgpu::BufferBindingType::Storage || bgl->GetBindingInfo(bindingIndex).buffer.type == kInternalStorageBufferBinding)); if (forceStorageBufferAsUAV) { - remappedAccessControls.emplace(srcBindingPoint, tint::ast::Access::kReadWrite); + remappedAccessControls.emplace(srcBindingPoint, tint::type::Access::kReadWrite); } } diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index ccd5b3dca5..dd8744f0a2 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -181,8 +181,6 @@ template("libtint_source_set") { libtint_source_set("libtint_core_all_src") { sources = [ - "ast/access.cc", - "ast/access.h", "ast/alias.cc", "ast/alias.h", "ast/array.cc", @@ -459,6 +457,7 @@ libtint_source_set("libtint_core_all_src") { "type/abstract_float.h", "type/abstract_int.h", "type/abstract_numeric.h", + "type/access.h", "type/address_space.h", "type/array.h", "type/array_count.h", @@ -700,6 +699,8 @@ libtint_source_set("libtint_type_src") { "type/abstract_int.h", "type/abstract_numeric.cc", "type/abstract_numeric.h", + "type/access.cc", + "type/access.h", "type/address_space.cc", "type/address_space.h", "type/array.cc", @@ -1139,7 +1140,6 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_ast_src") { sources = [ - "ast/access_test.cc", "ast/alias_test.cc", "ast/array_test.cc", "ast/assignment_statement_test.cc", @@ -1322,6 +1322,7 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_type_src") { sources = [ + "type/access_test.cc", "type/address_space_test.cc", "type/array_test.cc", "type/atomic_test.cc", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 7d390abaa4..bff3a3a8b9 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -566,7 +566,6 @@ list(APPEND TINT_LIB_SRCS writer/writer.h ) -tint_generated(ast/access BENCH TEST) tint_generated(ast/builtin_value BENCH TEST) tint_generated(ast/extension BENCH TEST) tint_generated(ast/interpolate_attribute BENCH TEST) @@ -574,6 +573,7 @@ tint_generated(ast/texel_format BENCH TEST) tint_generated(resolver/init_conv_intrinsic) tint_generated(sem/builtin_type) tint_generated(sem/parameter_usage) +tint_generated(type/access BENCH TEST) tint_generated(type/address_space BENCH TEST) tint_generated(type/short_name BENCH TEST) diff --git a/src/tint/ast/alias_test.cc b/src/tint/ast/alias_test.cc index c73475168e..20a9c5dc2f 100644 --- a/src/tint/ast/alias_test.cc +++ b/src/tint/ast/alias_test.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "src/tint/ast/alias.h" -#include "src/tint/ast/access.h" #include "src/tint/ast/array.h" #include "src/tint/ast/bool.h" #include "src/tint/ast/f32.h" @@ -26,6 +25,7 @@ #include "src/tint/ast/texture.h" #include "src/tint/ast/u32.h" #include "src/tint/ast/vector.h" +#include "src/tint/type/access.h" namespace tint::ast { namespace { diff --git a/src/tint/ast/builtin_texture_helper_test.cc b/src/tint/ast/builtin_texture_helper_test.cc index 7dda560e1b..1232c4356d 100644 --- a/src/tint/ast/builtin_texture_helper_test.cc +++ b/src/tint/ast/builtin_texture_helper_test.cc @@ -55,7 +55,7 @@ TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o, args(std::move(a)) {} TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o, const char* d, - Access acc, + type::Access acc, ast::TexelFormat fmt, type::TextureDimension dims, TextureDataType datatype, @@ -404,7 +404,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kDimensionsStorageWO1d, "textureDimensions(t : texture_storage_1d) -> u32", - ast::Access::kWrite, + type::Access::kWrite, ast::TexelFormat::kRgba32Float, type::TextureDimension::k1d, TextureDataType::kF32, @@ -414,7 +414,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kDimensionsStorageWO2d, "textureDimensions(t : texture_storage_2d) -> vec2", - ast::Access::kWrite, + type::Access::kWrite, ast::TexelFormat::kRgba32Float, type::TextureDimension::k2d, TextureDataType::kF32, @@ -424,7 +424,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kDimensionsStorageWO2dArray, "textureDimensions(t : texture_storage_2d_array) -> vec2", - ast::Access::kWrite, + type::Access::kWrite, ast::TexelFormat::kRgba32Float, type::TextureDimension::k2dArray, TextureDataType::kF32, @@ -434,7 +434,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kDimensionsStorageWO3d, "textureDimensions(t : texture_storage_3d) -> vec3", - ast::Access::kWrite, + type::Access::kWrite, ast::TexelFormat::kRgba32Float, type::TextureDimension::k3d, TextureDataType::kF32, @@ -827,7 +827,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kNumLayersStorageWO2dArray, "textureNumLayers(t : texture_storage_2d_array) -> u32", - ast::Access::kWrite, + type::Access::kWrite, ast::TexelFormat::kRgba32Float, type::TextureDimension::k2dArray, TextureDataType::kF32, @@ -2327,7 +2327,7 @@ std::vector TextureOverloadCase::ValidCases() { "textureStore(t : texture_storage_1d,\n" " coords : i32,\n" " value : vec4)", - ast::Access::kWrite, + type::Access::kWrite, ast::TexelFormat::kRgba32Float, type::TextureDimension::k1d, TextureDataType::kF32, @@ -2343,7 +2343,7 @@ std::vector TextureOverloadCase::ValidCases() { "textureStore(t : texture_storage_2d,\n" " coords : vec2,\n" " value : vec4)", - ast::Access::kWrite, + type::Access::kWrite, ast::TexelFormat::kRgba32Float, type::TextureDimension::k2d, TextureDataType::kF32, @@ -2360,7 +2360,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " array_index : u32,\n" " value : vec4)", - ast::Access::kWrite, + type::Access::kWrite, ast::TexelFormat::kRgba32Float, type::TextureDimension::k2dArray, TextureDataType::kF32, @@ -2377,7 +2377,7 @@ std::vector TextureOverloadCase::ValidCases() { "textureStore(t : texture_storage_3d,\n" " coords : vec3,\n" " value : vec4)", - ast::Access::kWrite, + type::Access::kWrite, ast::TexelFormat::kRgba32Float, type::TextureDimension::k3d, TextureDataType::kF32, diff --git a/src/tint/ast/builtin_texture_helper_test.h b/src/tint/ast/builtin_texture_helper_test.h index cfa180a7dc..775eade10b 100644 --- a/src/tint/ast/builtin_texture_helper_test.h +++ b/src/tint/ast/builtin_texture_helper_test.h @@ -17,8 +17,8 @@ #include -#include "src/tint/ast/access.h" #include "src/tint/program_builder.h" +#include "src/tint/type/access.h" #include "src/tint/type/storage_texture.h" #include "src/tint/type/texture_dimension.h" @@ -201,7 +201,7 @@ struct TextureOverloadCase { /// Constructor for textureLoad() with storage textures TextureOverloadCase(ValidTextureOverload, const char*, - Access, + type::Access, ast::TexelFormat, type::TextureDimension, TextureDataType, @@ -239,7 +239,7 @@ struct TextureOverloadCase { ast::SamplerKind const sampler_kind = ast::SamplerKind::kSampler; /// The access control for the storage texture /// Used only when texture_kind is kStorage - Access const access = Access::kReadWrite; + type::Access const access = type::Access::kReadWrite; /// The image format for the storage texture /// Used only when texture_kind is kStorage ast::TexelFormat const texel_format = ast::TexelFormat::kUndefined; diff --git a/src/tint/ast/matrix_test.cc b/src/tint/ast/matrix_test.cc index dbb88e38f8..ff47494a74 100644 --- a/src/tint/ast/matrix_test.cc +++ b/src/tint/ast/matrix_test.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "src/tint/ast/matrix.h" -#include "src/tint/ast/access.h" #include "src/tint/ast/alias.h" #include "src/tint/ast/array.h" #include "src/tint/ast/bool.h" @@ -26,6 +25,7 @@ #include "src/tint/ast/texture.h" #include "src/tint/ast/u32.h" #include "src/tint/ast/vector.h" +#include "src/tint/type/access.h" namespace tint::ast { namespace { diff --git a/src/tint/ast/multisampled_texture_test.cc b/src/tint/ast/multisampled_texture_test.cc index ee05710ac0..8cb3b00b52 100644 --- a/src/tint/ast/multisampled_texture_test.cc +++ b/src/tint/ast/multisampled_texture_test.cc @@ -14,7 +14,6 @@ #include "src/tint/ast/multisampled_texture.h" -#include "src/tint/ast/access.h" #include "src/tint/ast/alias.h" #include "src/tint/ast/array.h" #include "src/tint/ast/bool.h" @@ -31,6 +30,7 @@ #include "src/tint/ast/texture.h" #include "src/tint/ast/u32.h" #include "src/tint/ast/vector.h" +#include "src/tint/type/access.h" namespace tint::ast { namespace { diff --git a/src/tint/ast/pointer.cc b/src/tint/ast/pointer.cc index 503f92fb4e..2216872bbd 100644 --- a/src/tint/ast/pointer.cc +++ b/src/tint/ast/pointer.cc @@ -25,7 +25,7 @@ Pointer::Pointer(ProgramID pid, const Source& src, const Type* const subtype, type::AddressSpace addr_space, - ast::Access ac) + type::Access ac) : Base(pid, nid, src), type(subtype), address_space(addr_space), access(ac) {} std::string Pointer::FriendlyName(const SymbolTable& symbols) const { @@ -35,7 +35,7 @@ std::string Pointer::FriendlyName(const SymbolTable& symbols) const { out << address_space << ", "; } out << type->FriendlyName(symbols); - if (access != ast::Access::kUndefined) { + if (access != type::Access::kUndefined) { out << ", " << access; } out << ">"; diff --git a/src/tint/ast/pointer.h b/src/tint/ast/pointer.h index ca724fa463..dda146accc 100644 --- a/src/tint/ast/pointer.h +++ b/src/tint/ast/pointer.h @@ -17,8 +17,8 @@ #include -#include "src/tint/ast/access.h" #include "src/tint/ast/type.h" +#include "src/tint/type/access.h" #include "src/tint/type/address_space.h" namespace tint::ast { @@ -38,7 +38,7 @@ class Pointer final : public Castable { const Source& src, const Type* const subtype, type::AddressSpace address_space, - ast::Access access); + type::Access access); /// Move constructor Pointer(Pointer&&); ~Pointer() override; @@ -60,7 +60,7 @@ class Pointer final : public Castable { type::AddressSpace const address_space; /// The access control of the pointer - ast::Access const access; + type::Access const access; }; } // namespace tint::ast diff --git a/src/tint/ast/pointer_test.cc b/src/tint/ast/pointer_test.cc index 6513e16eaa..648d76797a 100644 --- a/src/tint/ast/pointer_test.cc +++ b/src/tint/ast/pointer_test.cc @@ -24,21 +24,21 @@ using AstPointerTest = TestHelper; TEST_F(AstPointerTest, Creation) { auto* i32 = create(); - auto* p = create(i32, type::AddressSpace::kStorage, Access::kRead); + auto* p = create(i32, type::AddressSpace::kStorage, type::Access::kRead); EXPECT_EQ(p->type, i32); EXPECT_EQ(p->address_space, type::AddressSpace::kStorage); - EXPECT_EQ(p->access, Access::kRead); + EXPECT_EQ(p->access, type::Access::kRead); } TEST_F(AstPointerTest, FriendlyName) { auto* i32 = create(); - auto* p = create(i32, type::AddressSpace::kWorkgroup, Access::kUndefined); + auto* p = create(i32, type::AddressSpace::kWorkgroup, type::Access::kUndefined); EXPECT_EQ(p->FriendlyName(Symbols()), "ptr"); } TEST_F(AstPointerTest, FriendlyNameWithAccess) { auto* i32 = create(); - auto* p = create(i32, type::AddressSpace::kStorage, Access::kReadWrite); + auto* p = create(i32, type::AddressSpace::kStorage, type::Access::kReadWrite); EXPECT_EQ(p->FriendlyName(Symbols()), "ptr"); } diff --git a/src/tint/ast/storage_texture.cc b/src/tint/ast/storage_texture.cc index 32e233b10b..fe7b7e89d6 100644 --- a/src/tint/ast/storage_texture.cc +++ b/src/tint/ast/storage_texture.cc @@ -29,7 +29,7 @@ StorageTexture::StorageTexture(ProgramID pid, type::TextureDimension d, TexelFormat fmt, const Type* subtype, - Access ac) + type::Access ac) : Base(pid, nid, src, d), format(fmt), type(subtype), access(ac) {} StorageTexture::StorageTexture(StorageTexture&&) = default; diff --git a/src/tint/ast/storage_texture.h b/src/tint/ast/storage_texture.h index a16212dd34..232eb8e4ca 100644 --- a/src/tint/ast/storage_texture.h +++ b/src/tint/ast/storage_texture.h @@ -17,9 +17,9 @@ #include -#include "src/tint/ast/access.h" #include "src/tint/ast/texel_format.h" #include "src/tint/ast/texture.h" +#include "src/tint/type/access.h" #include "src/tint/type/texture_dimension.h" namespace tint::ast { @@ -41,7 +41,7 @@ class StorageTexture final : public Castable { type::TextureDimension dim, TexelFormat format, const Type* subtype, - Access access_control); + type::Access access_control); /// Move constructor StorageTexture(StorageTexture&&); @@ -69,7 +69,7 @@ class StorageTexture final : public Castable { const Type* const type; /// The access control - const Access access; + const type::Access access; }; } // namespace tint::ast diff --git a/src/tint/ast/storage_texture_test.cc b/src/tint/ast/storage_texture_test.cc index 69ee4a0802..d83db3e698 100644 --- a/src/tint/ast/storage_texture_test.cc +++ b/src/tint/ast/storage_texture_test.cc @@ -24,7 +24,7 @@ using AstStorageTextureTest = TestHelper; TEST_F(AstStorageTextureTest, IsTexture) { auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this); Texture* ty = create(type::TextureDimension::k2dArray, - TexelFormat::kRgba32Float, subtype, Access::kRead); + TexelFormat::kRgba32Float, subtype, type::Access::kRead); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); @@ -33,28 +33,28 @@ TEST_F(AstStorageTextureTest, IsTexture) { TEST_F(AstStorageTextureTest, Dim) { auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this); auto* s = create(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float, - subtype, Access::kRead); + subtype, type::Access::kRead); EXPECT_EQ(s->dim, type::TextureDimension::k2dArray); } TEST_F(AstStorageTextureTest, Format) { auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this); auto* s = create(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float, - subtype, Access::kRead); + subtype, type::Access::kRead); EXPECT_EQ(s->format, TexelFormat::kRgba32Float); } TEST_F(AstStorageTextureTest, FriendlyName) { auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this); auto* s = create(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float, - subtype, Access::kRead); + subtype, type::Access::kRead); EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array"); } TEST_F(AstStorageTextureTest, F32) { auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this); Type* s = create(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float, - subtype, Access::kRead); + subtype, type::Access::kRead); ASSERT_TRUE(s->Is()); ASSERT_TRUE(s->Is()); @@ -64,7 +64,7 @@ TEST_F(AstStorageTextureTest, F32) { TEST_F(AstStorageTextureTest, U32) { auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRg32Uint, *this); Type* s = create(type::TextureDimension::k2dArray, TexelFormat::kRg32Uint, - subtype, Access::kRead); + subtype, type::Access::kRead); ASSERT_TRUE(s->Is()); ASSERT_TRUE(s->Is()); @@ -74,7 +74,7 @@ TEST_F(AstStorageTextureTest, U32) { TEST_F(AstStorageTextureTest, I32) { auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Sint, *this); Type* s = create(type::TextureDimension::k2dArray, TexelFormat::kRgba32Sint, - subtype, Access::kRead); + subtype, type::Access::kRead); ASSERT_TRUE(s->Is()); ASSERT_TRUE(s->Is()); diff --git a/src/tint/ast/var.cc b/src/tint/ast/var.cc index bac2ae2c85..3ed6677da8 100644 --- a/src/tint/ast/var.cc +++ b/src/tint/ast/var.cc @@ -26,7 +26,7 @@ Var::Var(ProgramID pid, const Symbol& sym, const ast::Type* ty, type::AddressSpace address_space, - Access access, + type::Access access, const Expression* init, utils::VectorRef attrs) : Base(pid, nid, src, sym, ty, init, std::move(attrs)), diff --git a/src/tint/ast/var.h b/src/tint/ast/var.h index 36c4b51c6b..3fdd7dbfa5 100644 --- a/src/tint/ast/var.h +++ b/src/tint/ast/var.h @@ -57,7 +57,7 @@ class Var final : public Castable { const Symbol& sym, const ast::Type* type, type::AddressSpace declared_address_space, - Access declared_access, + type::Access declared_access, const Expression* initializer, utils::VectorRef attributes); @@ -80,7 +80,7 @@ class Var final : public Castable { const type::AddressSpace declared_address_space; /// The declared access control - const Access declared_access; + const type::Access declared_access; }; /// A list of `var` declarations diff --git a/src/tint/ast/variable.h b/src/tint/ast/variable.h index cca137c04b..7a75c3f104 100644 --- a/src/tint/ast/variable.h +++ b/src/tint/ast/variable.h @@ -18,11 +18,11 @@ #include #include -#include "src/tint/ast/access.h" #include "src/tint/ast/attribute.h" #include "src/tint/ast/binding_attribute.h" #include "src/tint/ast/expression.h" #include "src/tint/ast/group_attribute.h" +#include "src/tint/type/access.h" #include "src/tint/type/address_space.h" // Forward declarations diff --git a/src/tint/fuzzers/transform_builder.h b/src/tint/fuzzers/transform_builder.h index 58675260af..90d6af5d4d 100644 --- a/src/tint/fuzzers/transform_builder.h +++ b/src/tint/fuzzers/transform_builder.h @@ -131,7 +131,7 @@ class TransformBuilder { uint8_t old_binding; uint8_t new_group; uint8_t new_binding; - ast::Access new_access; + type::Access new_access; }; std::vector configs = tb->builder()->vector(); diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index 8762b25a8e..e57dce3e86 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -718,7 +718,7 @@ std::vector Inspector::GetStorageBufferResourceBindingsImpl( auto* var = rsv.first; auto binding_info = rsv.second; - if (read_only != (var->Access() == ast::Access::kRead)) { + if (read_only != (var->Access() == type::Access::kRead)) { continue; } diff --git a/src/tint/inspector/inspector_test.cc b/src/tint/inspector/inspector_test.cc index 233ca3a235..bd8b3ee626 100644 --- a/src/tint/inspector/inspector_test.cc +++ b/src/tint/inspector/inspector_test.cc @@ -1651,8 +1651,8 @@ TEST_F(InspectorGetStorageSizeTest, Empty) { TEST_F(InspectorGetStorageSizeTest, Simple_NonStruct) { AddUniformBuffer("ub_var", ty.i32(), 0, 0); - AddStorageBuffer("sb_var", ty.i32(), ast::Access::kReadWrite, 1, 0); - AddStorageBuffer("rosb_var", ty.i32(), ast::Access::kRead, 1, 1); + AddStorageBuffer("sb_var", ty.i32(), type::Access::kReadWrite, 1, 0); + AddStorageBuffer("rosb_var", ty.i32(), type::Access::kRead, 1, 1); Func("ep_func", utils::Empty, ty.void_(), utils::Vector{ Decl(Let("ub", Expr("ub_var"))), @@ -1683,7 +1683,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_Struct) { auto sb = MakeStorageBufferTypes("sb_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("sb_var", sb(), ast::Access::kReadWrite, 1, 0); + AddStorageBuffer("sb_var", sb(), type::Access::kReadWrite, 1, 0); MakeStructVariableReferenceBodyFunction("sb_func", "sb_var", utils::Vector{ MemberInfo{0, ty.i32()}, @@ -1692,7 +1692,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_Struct) { auto ro_sb = MakeStorageBufferTypes("rosb_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("rosb_var", ro_sb(), ast::Access::kRead, 1, 1); + AddStorageBuffer("rosb_var", ro_sb(), type::Access::kRead, 1, 1); MakeStructVariableReferenceBodyFunction("rosb_func", "rosb_var", utils::Vector{ MemberInfo{0, ty.i32()}, @@ -1770,7 +1770,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) { auto sb = MakeStorageBufferTypes("sb_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("sb_var", sb(), ast::Access::kReadWrite, 1, 0); + AddStorageBuffer("sb_var", sb(), type::Access::kReadWrite, 1, 0); MakeStructVariableReferenceBodyFunction("sb_func", "sb_var", utils::Vector{ MemberInfo{0, ty.i32()}, @@ -1779,7 +1779,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) { auto ro_sb = MakeStorageBufferTypes("rosb_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("rosb_var", ro_sb(), ast::Access::kRead, 1, 1); + AddStorageBuffer("rosb_var", ro_sb(), type::Access::kRead, 1, 1); MakeStructVariableReferenceBodyFunction("rosb_func", "rosb_var", utils::Vector{ MemberInfo{0, ty.i32()}, @@ -2134,7 +2134,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple_NonStruct) { - AddStorageBuffer("foo_sb", ty.i32(), ast::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", ty.i32(), type::Access::kReadWrite, 0, 0); MakePlainGlobalReferenceBodyFunction("sb_func", "foo_sb", ty.i32(), utils::Empty); MakeCallerBodyFunction("ep_func", utils::Vector{std::string("sb_func")}, @@ -2159,7 +2159,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple_Struct) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2190,7 +2190,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) { ty.u32(), ty.f32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2223,9 +2223,9 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { ty.u32(), ty.f32(), }); - AddStorageBuffer("sb_foo", sb_struct_type(), ast::Access::kReadWrite, 0, 0); - AddStorageBuffer("sb_bar", sb_struct_type(), ast::Access::kReadWrite, 0, 1); - AddStorageBuffer("sb_baz", sb_struct_type(), ast::Access::kReadWrite, 2, 0); + AddStorageBuffer("sb_foo", sb_struct_type(), type::Access::kReadWrite, 0, 0); + AddStorageBuffer("sb_bar", sb_struct_type(), type::Access::kReadWrite, 0, 1); + AddStorageBuffer("sb_baz", sb_struct_type(), type::Access::kReadWrite, 2, 0); auto AddReferenceFunc = [this](const std::string& func_name, const std::string& var_name) { MakeStructVariableReferenceBodyFunction(func_name, var_name, @@ -2284,7 +2284,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) { ty.i32(), ty.array(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2314,7 +2314,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) { ty.i32(), ty.array(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2343,7 +2343,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.vec3(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2369,7 +2369,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, NonStructVec3) { - AddStorageBuffer("foo_ub", ty.vec3(), ast::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_ub", ty.vec3(), type::Access::kReadWrite, 0, 0); MakePlainGlobalReferenceBodyFunction("ub_func", "foo_ub", ty.vec3(), utils::Empty); MakeCallerBodyFunction("ep_func", utils::Vector{std::string("ub_func")}, @@ -2394,7 +2394,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kRead, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2417,7 +2417,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kRead, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2448,9 +2448,9 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, MultipleStorageBuf ty.u32(), ty.f32(), }); - AddStorageBuffer("sb_foo", sb_struct_type(), ast::Access::kRead, 0, 0); - AddStorageBuffer("sb_bar", sb_struct_type(), ast::Access::kRead, 0, 1); - AddStorageBuffer("sb_baz", sb_struct_type(), ast::Access::kRead, 2, 0); + AddStorageBuffer("sb_foo", sb_struct_type(), type::Access::kRead, 0, 0); + AddStorageBuffer("sb_bar", sb_struct_type(), type::Access::kRead, 0, 1); + AddStorageBuffer("sb_baz", sb_struct_type(), type::Access::kRead, 2, 0); auto AddReferenceFunc = [this](const std::string& func_name, const std::string& var_name) { MakeStructVariableReferenceBodyFunction(func_name, var_name, @@ -2509,7 +2509,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) { ty.i32(), ty.array(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kRead, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2539,7 +2539,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingRuntimeA ty.i32(), ty.array(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kRead, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2568,7 +2568,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ diff --git a/src/tint/inspector/test_inspector_builder.cc b/src/tint/inspector/test_inspector_builder.cc index e801fcb606..373e2de9ca 100644 --- a/src/tint/inspector/test_inspector_builder.cc +++ b/src/tint/inspector/test_inspector_builder.cc @@ -135,7 +135,7 @@ void InspectorBuilder::AddWorkgroupStorage(const std::string& name, const ast::T void InspectorBuilder::AddStorageBuffer(const std::string& name, const ast::Type* type, - ast::Access access, + type::Access access, uint32_t group, uint32_t binding) { GlobalVar(name, type, type::AddressSpace::kStorage, access, Binding(AInt(binding)), @@ -279,7 +279,7 @@ const ast::Type* InspectorBuilder::GetCoordsType(type::TextureDimension dim, const ast::Type* InspectorBuilder::MakeStorageTextureTypes(type::TextureDimension dim, ast::TexelFormat format) { - return ty.storage_texture(dim, format, ast::Access::kWrite); + return ty.storage_texture(dim, format, type::Access::kWrite); } void InspectorBuilder::AddStorageTexture(const std::string& name, diff --git a/src/tint/inspector/test_inspector_builder.h b/src/tint/inspector/test_inspector_builder.h index 36c70b7cd5..13172ce392 100644 --- a/src/tint/inspector/test_inspector_builder.h +++ b/src/tint/inspector/test_inspector_builder.h @@ -183,7 +183,7 @@ class InspectorBuilder : public ProgramBuilder { /// @param binding the binding number to use for the storage buffer void AddStorageBuffer(const std::string& name, const ast::Type* type, - ast::Access access, + type::Access access, uint32_t group, uint32_t binding); diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index 676617f3d7..2b0d42cddc 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -182,14 +182,14 @@ class ProgramBuilder { const ast::Type* type = nullptr; type::AddressSpace address_space = type::AddressSpace::kNone; - ast::Access access = ast::Access::kUndefined; + type::Access access = type::Access::kUndefined; const ast::Expression* initializer = nullptr; utils::Vector attributes; private: void Set(const ast::Type* t) { type = t; } void Set(type::AddressSpace addr_space) { address_space = addr_space; } - void Set(ast::Access ac) { access = ac; } + void Set(type::Access ac) { access = ac; } void Set(const ast::Expression* c) { initializer = c; } void Set(utils::VectorRef l) { attributes = std::move(l); } void Set(const ast::Attribute* a) { attributes.Push(a); } @@ -943,7 +943,7 @@ class ProgramBuilder { /// @return the pointer to `type` with the given type::AddressSpace const ast::Pointer* pointer(const ast::Type* type, type::AddressSpace address_space, - ast::Access access = ast::Access::kUndefined) const { + type::Access access = type::Access::kUndefined) const { return builder->create(type, address_space, access); } @@ -955,7 +955,7 @@ class ProgramBuilder { const ast::Pointer* pointer(const Source& source, const ast::Type* type, type::AddressSpace address_space, - ast::Access access = ast::Access::kUndefined) const { + type::Access access = type::Access::kUndefined) const { return builder->create(source, type, address_space, access); } @@ -964,7 +964,7 @@ class ProgramBuilder { /// @return the pointer to type `T` with the given type::AddressSpace. template const ast::Pointer* pointer(type::AddressSpace address_space, - ast::Access access = ast::Access::kUndefined) const { + type::Access access = type::Access::kUndefined) const { return pointer(Of(), address_space, access); } @@ -975,7 +975,7 @@ class ProgramBuilder { template const ast::Pointer* pointer(const Source& source, type::AddressSpace address_space, - ast::Access access = ast::Access::kUndefined) const { + type::Access access = type::Access::kUndefined) const { return pointer(source, Of(), address_space, access); } @@ -1083,7 +1083,7 @@ class ProgramBuilder { /// @returns the storage texture const ast::StorageTexture* storage_texture(type::TextureDimension dims, ast::TexelFormat format, - ast::Access access) const { + type::Access access) const { auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder); return builder->create(dims, format, subtype, access); } @@ -1096,7 +1096,7 @@ class ProgramBuilder { const ast::StorageTexture* storage_texture(const Source& source, type::TextureDimension dims, ast::TexelFormat format, - ast::Access access) const { + type::Access access) const { auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder); return builder->create(source, dims, format, subtype, access); } @@ -1698,7 +1698,7 @@ class ProgramBuilder { /// Can be any of the following, in any order: /// * ast::Type* - specifies the variable type /// * type::AddressSpace - specifies the variable address space - /// * ast::Access - specifies the variable's access control + /// * type::Access - specifies the variable's access control /// * ast::Expression* - specifies the variable's initializer expression /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) /// Note that non-repeatable arguments of the same type will use the last argument's value. @@ -1717,7 +1717,7 @@ class ProgramBuilder { /// Can be any of the following, in any order: /// * ast::Type* - specifies the variable type /// * type::AddressSpace - specifies the variable address space - /// * ast::Access - specifies the variable's access control + /// * type::Access - specifies the variable's access control /// * ast::Expression* - specifies the variable's initializer expression /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) /// Note that non-repeatable arguments of the same type will use the last argument's value. @@ -1821,7 +1821,7 @@ class ProgramBuilder { /// Can be any of the following, in any order: /// * ast::Type* - specifies the variable type /// * type::AddressSpace - specifies the variable address space - /// * ast::Access - specifies the variable's access control + /// * type::Access - specifies the variable's access control /// * ast::Expression* - specifies the variable's initializer expression /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) /// Note that non-repeatable arguments of the same type will use the last argument's value. @@ -1840,7 +1840,7 @@ class ProgramBuilder { /// Can be any of the following, in any order: /// * ast::Type* - specifies the variable type /// * type::AddressSpace - specifies the variable address space - /// * ast::Access - specifies the variable's access control + /// * type::Access - specifies the variable's access control /// * ast::Expression* - specifies the variable's initializer expression /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) /// Note that non-repeatable arguments of the same type will use the last argument's value. diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc index 2e87551212..9ea9866289 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -4882,7 +4882,7 @@ DefInfo::Pointer FunctionEmitter::GetPointerInfo(uint32_t id) { } // Local variables are always Function storage class, with default // access mode. - return DefInfo::Pointer{type::AddressSpace::kFunction, ast::Access::kUndefined}; + return DefInfo::Pointer{type::AddressSpace::kFunction, type::Access::kUndefined}; } case spv::Op::OpFunctionParameter: { const auto* type = As(parser_impl_.ConvertType(inst.type_id())); @@ -4895,7 +4895,7 @@ DefInfo::Pointer FunctionEmitter::GetPointerInfo(uint32_t id) { // parameters. In that case we need to do a global analysis to // determine what the formal argument parameter type should be, // whether it has read_only or read_write access mode. - return DefInfo::Pointer{type->address_space, ast::Access::kUndefined}; + return DefInfo::Pointer{type->address_space, type::Access::kUndefined}; } default: break; diff --git a/src/tint/reader/spirv/function.h b/src/tint/reader/spirv/function.h index 3be0a005f0..53afcdc41a 100644 --- a/src/tint/reader/spirv/function.h +++ b/src/tint/reader/spirv/function.h @@ -334,7 +334,7 @@ struct DefInfo { type::AddressSpace address_space = type::AddressSpace::kUndefined; /// The declared access mode. - ast::Access access = ast::Access::kUndefined; + type::Access access = type::Access::kUndefined; }; /// The expression to use when sinking pointers into their use. diff --git a/src/tint/reader/spirv/parser_impl.cc b/src/tint/reader/spirv/parser_impl.cc index 50e290b81c..469424f9ec 100644 --- a/src/tint/reader/spirv/parser_impl.cc +++ b/src/tint/reader/spirv/parser_impl.cc @@ -1587,7 +1587,7 @@ ast::Var* ParserImpl::MakeVar(uint32_t id, return nullptr; } - ast::Access access = ast::Access::kUndefined; + type::Access access = type::Access::kUndefined; if (address_space == type::AddressSpace::kStorage) { bool read_only = false; if (auto* tn = storage_type->As()) { @@ -1595,7 +1595,7 @@ ast::Var* ParserImpl::MakeVar(uint32_t id, } // Apply the access(read) or access(read_write) modifier. - access = read_only ? ast::Access::kRead : ast::Access::kReadWrite; + access = read_only ? type::Access::kRead : type::Access::kReadWrite; } // Handle variables (textures and samplers) are always in the handle @@ -2518,7 +2518,7 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc ast_handle_type = ty_.SampledTexture(dim, ast_sampled_component_type); } } else { - const auto access = ast::Access::kWrite; + const auto access = type::Access::kWrite; const auto format = enum_converter_.ToTexelFormat(image_type->format()); if (format == ast::TexelFormat::kUndefined) { return nullptr; diff --git a/src/tint/reader/spirv/parser_type.cc b/src/tint/reader/spirv/parser_type.cc index c66286a7c9..fd1d8a0521 100644 --- a/src/tint/reader/spirv/parser_type.cc +++ b/src/tint/reader/spirv/parser_type.cc @@ -175,7 +175,7 @@ Type::~Type() = default; Texture::~Texture() = default; -Pointer::Pointer(const Type* t, type::AddressSpace s, ast::Access a) +Pointer::Pointer(const Type* t, type::AddressSpace s, type::Access a) : type(t), address_space(s), access(a) {} Pointer::Pointer(const Pointer&) = default; @@ -183,7 +183,7 @@ const ast::Type* Pointer::Build(ProgramBuilder& b) const { return b.ty.pointer(type->Build(b), address_space, access); } -Reference::Reference(const Type* t, type::AddressSpace s, ast::Access a) +Reference::Reference(const Type* t, type::AddressSpace s, type::Access a) : type(t), address_space(s), access(a) {} Reference::Reference(const Reference&) = default; @@ -255,7 +255,7 @@ const ast::Type* SampledTexture::Build(ProgramBuilder& b) const { return b.ty.sampled_texture(dims, type->Build(b)); } -StorageTexture::StorageTexture(type::TextureDimension d, ast::TexelFormat f, ast::Access a) +StorageTexture::StorageTexture(type::TextureDimension d, ast::TexelFormat f, type::Access a) : Base(d), format(f), access(a) {} StorageTexture::StorageTexture(const StorageTexture&) = default; @@ -461,13 +461,13 @@ const Type* TypeManager::AsUnsigned(const Type* ty) { const spirv::Pointer* TypeManager::Pointer(const Type* el, type::AddressSpace address_space, - ast::Access access) { + type::Access access) { return state->pointers_.Get(el, address_space, access); } const spirv::Reference* TypeManager::Reference(const Type* el, type::AddressSpace address_space, - ast::Access access) { + type::Access access) { return state->references_.Get(el, address_space, access); } @@ -516,7 +516,7 @@ const spirv::SampledTexture* TypeManager::SampledTexture(type::TextureDimension const spirv::StorageTexture* TypeManager::StorageTexture(type::TextureDimension dims, ast::TexelFormat fmt, - ast::Access access) { + type::Access access) { return state->storage_textures_.Get(dims, fmt, access); } diff --git a/src/tint/reader/spirv/parser_type.h b/src/tint/reader/spirv/parser_type.h index fc949d6f37..888a4de7fa 100644 --- a/src/tint/reader/spirv/parser_type.h +++ b/src/tint/reader/spirv/parser_type.h @@ -19,10 +19,10 @@ #include #include -#include "src/tint/ast/access.h" #include "src/tint/ast/sampler.h" #include "src/tint/ast/storage_texture.h" #include "src/tint/castable.h" +#include "src/tint/type/access.h" #include "src/tint/type/address_space.h" #include "src/tint/type/texture_dimension.h" #include "src/tint/utils/block_allocator.h" @@ -163,7 +163,7 @@ struct Pointer final : public Castable { /// @param ty the store type /// @param sc the pointer address space /// @param access the declared access mode - Pointer(const Type* ty, type::AddressSpace sc, ast::Access access); + Pointer(const Type* ty, type::AddressSpace sc, type::Access access); /// Copy constructor /// @param other the other type to copy @@ -183,7 +183,7 @@ struct Pointer final : public Castable { /// the pointer address space type::AddressSpace const address_space; /// the pointer declared access mode - ast::Access const access; + type::Access const access; }; /// `ref` type @@ -194,7 +194,7 @@ struct Reference final : public Castable { /// @param ty the referenced type /// @param sc the reference address space /// @param access the reference declared access mode - Reference(const Type* ty, type::AddressSpace sc, ast::Access access); + Reference(const Type* ty, type::AddressSpace sc, type::Access access); /// Copy constructor /// @param other the other type to copy @@ -214,7 +214,7 @@ struct Reference final : public Castable { /// the pointer address space type::AddressSpace const address_space; /// the pointer declared access mode - ast::Access const access; + type::Access const access; }; /// `vecN` type @@ -435,7 +435,7 @@ struct StorageTexture final : public Castable { /// @param d the texture dimensions /// @param f the storage image format /// @param a the access control - StorageTexture(type::TextureDimension d, ast::TexelFormat f, ast::Access a); + StorageTexture(type::TextureDimension d, ast::TexelFormat f, type::Access a); /// Copy constructor /// @param other the other type to copy @@ -454,7 +454,7 @@ struct StorageTexture final : public Castable { ast::TexelFormat const format; /// the access control - ast::Access const access; + type::Access const access; }; /// Base class for named types @@ -551,7 +551,7 @@ class TypeManager { /// the same pointer. const spirv::Pointer* Pointer(const Type* ty, type::AddressSpace address_space, - ast::Access access = ast::Access::kUndefined); + type::Access access = type::Access::kUndefined); /// @param ty the referenced type /// @param address_space the reference address space /// @param access the declared access mode @@ -559,7 +559,7 @@ class TypeManager { /// return the same pointer. const spirv::Reference* Reference(const Type* ty, type::AddressSpace address_space, - ast::Access access = ast::Access::kUndefined); + type::Access access = type::Access::kUndefined); /// @param ty the element type /// @param sz the number of elements in the vector /// @return a Vector type. Repeated calls with the same arguments will return @@ -617,7 +617,7 @@ class TypeManager { /// return the same pointer. const spirv::StorageTexture* StorageTexture(type::TextureDimension d, ast::TexelFormat f, - ast::Access a); + type::Access a); private: struct State; diff --git a/src/tint/reader/spirv/parser_type_test.cc b/src/tint/reader/spirv/parser_type_test.cc index 1934fd8adb..249d990d6b 100644 --- a/src/tint/reader/spirv/parser_type_test.cc +++ b/src/tint/reader/spirv/parser_type_test.cc @@ -44,9 +44,9 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) { EXPECT_EQ(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()), ty.SampledTexture(type::TextureDimension::k2d, ty.I32())); EXPECT_EQ(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, - ast::Access::kRead), + type::Access::kRead), ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, - ast::Access::kRead)); + type::Access::kRead)); } TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) { @@ -81,17 +81,17 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) { EXPECT_NE(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()), ty.SampledTexture(type::TextureDimension::k2d, ty.U32())); EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, - ast::Access::kRead), + type::Access::kRead), ty.StorageTexture(type::TextureDimension::k3d, ast::TexelFormat::kR32Uint, - ast::Access::kRead)); + type::Access::kRead)); EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, - ast::Access::kRead), + type::Access::kRead), ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Sint, - ast::Access::kRead)); + type::Access::kRead)); EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, - ast::Access::kRead), + type::Access::kRead), ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, - ast::Access::kWrite)); + type::Access::kWrite)); } } // namespace diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index 9e9930ebbe..657515c4f7 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -214,7 +214,7 @@ ParserImpl::VarDeclInfo::VarDeclInfo(const VarDeclInfo&) = default; ParserImpl::VarDeclInfo::VarDeclInfo(Source source_in, std::string name_in, type::AddressSpace address_space_in, - ast::Access access_in, + type::Access access_in, const ast::Type* type_in) : source(std::move(source_in)), name(std::move(name_in)), @@ -754,7 +754,7 @@ Maybe ParserImpl::texture_and_sampler_types() { auto storage = storage_texture_type(); if (storage.matched) { const char* use = "storage texture type"; - using StorageTextureInfo = std::pair; + using StorageTextureInfo = std::pair; auto params = expect_lt_gt_block(use, [&]() -> Expect { auto format = expect_texel_format(use); if (format.errored) { @@ -971,8 +971,8 @@ Expect ParserImpl::expect_ident_with_type_specifier // : 'read' // | 'write' // | 'read_write' -Expect ParserImpl::expect_access_mode(std::string_view use) { - return expect_enum("access control", ast::ParseAccess, ast::kAccessStrings, use); +Expect ParserImpl::expect_access_mode(std::string_view use) { + return expect_enum("access control", type::ParseAccess, type::kAccessStrings, use); } // variable_qualifier @@ -996,7 +996,7 @@ Maybe ParserImpl::variable_qualifier() { } return VariableQualifier{sc.value, ac.value}; } - return Expect{VariableQualifier{sc.value, ast::Access::kUndefined}, + return Expect{VariableQualifier{sc.value, type::Access::kUndefined}, source}; }); @@ -1252,7 +1252,7 @@ Expect ParserImpl::expect_type_specifier_pointer(const Source& const char* use = "ptr declaration"; auto address_space = type::AddressSpace::kNone; - auto access = ast::Access::kUndefined; + auto access = type::Access::kUndefined; auto subtype = expect_lt_gt_block(use, [&]() -> Expect { auto sc = expect_address_space(use); diff --git a/src/tint/reader/wgsl/parser_impl.h b/src/tint/reader/wgsl/parser_impl.h index a60cfef858..93a7a1c562 100644 --- a/src/tint/reader/wgsl/parser_impl.h +++ b/src/tint/reader/wgsl/parser_impl.h @@ -22,10 +22,10 @@ #include #include -#include "src/tint/ast/access.h" #include "src/tint/program_builder.h" #include "src/tint/reader/wgsl/parser_impl_detail.h" #include "src/tint/reader/wgsl/token.h" +#include "src/tint/type/access.h" #include "src/tint/type/storage_texture.h" #include "src/tint/type/texture_dimension.h" @@ -285,7 +285,7 @@ class ParserImpl { VarDeclInfo(Source source_in, std::string name_in, type::AddressSpace address_space_in, - ast::Access access_in, + type::Access access_in, const ast::Type* type_in); /// Destructor ~VarDeclInfo(); @@ -297,7 +297,7 @@ class ParserImpl { /// Variable address space type::AddressSpace address_space = type::AddressSpace::kNone; /// Variable access control - ast::Access access = ast::Access::kUndefined; + type::Access access = type::Access::kUndefined; /// Variable type const ast::Type* type = nullptr; }; @@ -307,7 +307,7 @@ class ParserImpl { /// The variable's address space type::AddressSpace address_space = type::AddressSpace::kNone; /// The variable's access control - ast::Access access = ast::Access::kUndefined; + type::Access access = type::Access::kUndefined; }; /// MatrixDimensions contains the column and row information for a matrix @@ -525,7 +525,7 @@ class ParserImpl { /// match a valid access control. /// @param use a description of what was being parsed if an error was raised /// @returns the parsed access control. - Expect expect_access_mode(std::string_view use); + Expect expect_access_mode(std::string_view use); /// Parses an interpolation sample name identifier, erroring if the next token does not match a /// valid sample name. /// @returns the parsed sample name. diff --git a/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc b/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc index 41fab414b4..b0ee0a8642 100644 --- a/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc +++ b/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc @@ -192,7 +192,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dRg32Float) { ASSERT_TRUE(t->Is()); ASSERT_TRUE(t->Is()); EXPECT_EQ(t->As()->format, ast::TexelFormat::kRg32Float); - EXPECT_EQ(t->As()->access, ast::Access::kRead); + EXPECT_EQ(t->As()->access, type::Access::kRead); EXPECT_EQ(t->As()->dim, type::TextureDimension::k1d); EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 36u}})); } @@ -208,7 +208,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR32Uint) { ASSERT_TRUE(t->Is()); ASSERT_TRUE(t->Is()); EXPECT_EQ(t->As()->format, ast::TexelFormat::kR32Uint); - EXPECT_EQ(t->As()->access, ast::Access::kWrite); + EXPECT_EQ(t->As()->access, type::Access::kWrite); EXPECT_EQ(t->As()->dim, type::TextureDimension::k2d); EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 35u}})); } diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc index 972d49bccc..1d5425503b 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc @@ -192,7 +192,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_WithAccess) { auto* ptr = t.value->As(); ASSERT_TRUE(ptr->type->Is()); ASSERT_EQ(ptr->address_space, type::AddressSpace::kFunction); - ASSERT_EQ(ptr->access, ast::Access::kRead); + ASSERT_EQ(ptr->access, type::Access::kRead); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 25u}})); } diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc index 503c88d6d4..f2ab1725c0 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc @@ -183,7 +183,7 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Ptr_WithAccess) { auto* ptr = t.value->As(); ASSERT_TRUE(ptr->type->Is()); ASSERT_EQ(ptr->address_space, type::AddressSpace::kFunction); - ASSERT_EQ(ptr->access, ast::Access::kRead); + ASSERT_EQ(ptr->access, type::Access::kRead); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 25u}})); } diff --git a/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc b/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc index a9373ae187..111f20787a 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc @@ -20,7 +20,7 @@ namespace { struct VariableStorageData { const char* input; type::AddressSpace address_space; - ast::Access access; + type::Access access; }; inline std::ostream& operator<<(std::ostream& out, VariableStorageData data) { out << std::string(data.input); @@ -47,15 +47,15 @@ INSTANTIATE_TEST_SUITE_P( ParserImplTest, VariableQualifierTest, testing::Values( - VariableStorageData{"uniform", type::AddressSpace::kUniform, ast::Access::kUndefined}, - VariableStorageData{"workgroup", type::AddressSpace::kWorkgroup, ast::Access::kUndefined}, - VariableStorageData{"storage", type::AddressSpace::kStorage, ast::Access::kUndefined}, - VariableStorageData{"private", type::AddressSpace::kPrivate, ast::Access::kUndefined}, - VariableStorageData{"function", type::AddressSpace::kFunction, ast::Access::kUndefined}, - VariableStorageData{"storage, read", type::AddressSpace::kStorage, ast::Access::kRead}, - VariableStorageData{"storage, write", type::AddressSpace::kStorage, ast::Access::kWrite}, + VariableStorageData{"uniform", type::AddressSpace::kUniform, type::Access::kUndefined}, + VariableStorageData{"workgroup", type::AddressSpace::kWorkgroup, type::Access::kUndefined}, + VariableStorageData{"storage", type::AddressSpace::kStorage, type::Access::kUndefined}, + VariableStorageData{"private", type::AddressSpace::kPrivate, type::Access::kUndefined}, + VariableStorageData{"function", type::AddressSpace::kFunction, type::Access::kUndefined}, + VariableStorageData{"storage, read", type::AddressSpace::kStorage, type::Access::kRead}, + VariableStorageData{"storage, write", type::AddressSpace::kStorage, type::Access::kWrite}, VariableStorageData{"storage, read_write", type::AddressSpace::kStorage, - ast::Access::kReadWrite})); + type::Access::kReadWrite})); TEST_F(ParserImplTest, VariableQualifier_NoMatch) { auto p = parser(""); diff --git a/src/tint/resolver/address_space_validation_test.cc b/src/tint/resolver/address_space_validation_test.cc index d9513fe15a..b85feeb473 100644 --- a/src/tint/resolver/address_space_validation_test.cc +++ b/src/tint/resolver/address_space_validation_test.cc @@ -325,7 +325,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF32) { // var g : array; Structure("S", utils::Vector{Member("a", ty.f32())}); GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage, - ast::Access::kRead, Binding(0_a), Group(0_a)); + type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -347,7 +347,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF16) { Structure("S", utils::Vector{Member("a", ty.f16())}); GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage, - ast::Access::kRead, Binding(0_a), Group(0_a)); + type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -360,7 +360,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF16) { Structure("S", utils::Vector{Member("a", ty.f16())}); Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage, - ast::Access::kRead)); + type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -369,7 +369,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32) { // struct S { x : i32 }; // var g : S; Structure("S", utils::Vector{Member("x", ty.i32())}); - GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -379,7 +379,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32) { // struct S { x : i32 }; // type t = ptr; Structure("S", utils::Vector{Member("x", ty.i32())}); - Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, ast::Access::kRead)); + Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -391,7 +391,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32Alias Structure("S", utils::Vector{Member("x", ty.i32())}); Alias("a1", ty.type_name("S")); Alias("a2", ty.type_name("a1")); - GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -404,7 +404,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32Aliases Structure("S", utils::Vector{Member("x", ty.i32())}); Alias("a1", ty.type_name("S")); Alias("a2", ty.type_name("a1")); - Alias("t", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, ast::Access::kRead)); + Alias("t", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -415,7 +415,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16) { Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -427,7 +427,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16) { Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, ast::Access::kRead)); + Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -441,7 +441,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16Alias Structure("S", utils::Vector{Member("x", ty.f16())}); Alias("a1", ty.type_name("S")); Alias("a2", ty.type_name("a1")); - GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -456,14 +456,14 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16Aliases Structure("S", utils::Vector{Member("x", ty.f16())}); Alias("a1", ty.type_name("S")); Alias("a2", ty.type_name("a1")); - Alias("g", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, ast::Access::kRead)); + Alias("g", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_NotStorage_AccessMode) { // var g : a; - GlobalVar(Source{{12, 34}}, "g", ty.i32(), type::AddressSpace::kPrivate, ast::Access::kRead); + GlobalVar(Source{{12, 34}}, "g", ty.i32(), type::AddressSpace::kPrivate, type::Access::kRead); ASSERT_FALSE(r()->Resolve()); @@ -474,8 +474,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_NotStorage_AccessMode) TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NotStorage_AccessMode) { // type t = ptr; - Alias("t", - ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kPrivate, ast::Access::kRead)); + Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kPrivate, + type::Access::kRead)); ASSERT_FALSE(r()->Resolve()); @@ -486,7 +486,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NotStorage_AccessMode) { TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadAccessMode) { // @group(0) @binding(0) var a : i32; - GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead, Group(0_a), + GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -494,14 +494,14 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadAccessMode TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadAccessMode) { // type t = ptr; - Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead)); + Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadWriteAccessMode) { // @group(0) @binding(0) var a : i32; - GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kReadWrite, Group(0_a), + GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -509,14 +509,14 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadWriteAcces TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadWriteAccessMode) { // type t = ptr; - Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, ast::Access::kReadWrite)); + Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_WriteAccessMode) { // @group(0) @binding(0) var a : i32; - GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kWrite, + GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, type::Access::kWrite, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -528,7 +528,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_WriteAccessMod TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_WriteAccessMode) { // type t = ptr; Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kStorage, - ast::Access::kWrite)); + type::Access::kWrite)); ASSERT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/assignment_validation_test.cc b/src/tint/resolver/assignment_validation_test.cc index ca94780f7a..ad2b94fc8d 100644 --- a/src/tint/resolver/assignment_validation_test.cc +++ b/src/tint/resolver/assignment_validation_test.cc @@ -33,7 +33,7 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) { auto* s = Structure("S", utils::Vector{ Member("m", ty.i32()), }); - GlobalVar(Source{{12, 34}}, "a", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{12, 34}}, "a", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i)); @@ -232,7 +232,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) { auto make_type = [&] { return ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kRgba8Unorm, - ast::Access::kWrite); + type::Access::kWrite); }; GlobalVar("a", make_type(), Binding(0_a), Group(0_a)); @@ -253,7 +253,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) { Member("a", ty.atomic(ty.i32())), }); GlobalVar(Source{{12, 34}}, "v", ty.Of(s), type::AddressSpace::kStorage, - ast::Access::kReadWrite, Binding(0_a), Group(0_a)); + type::Access::kReadWrite, Binding(0_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); @@ -270,7 +270,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) { Member("a", ty.array(ty.f32())), }); GlobalVar(Source{{12, 34}}, "v", ty.Of(s), type::AddressSpace::kStorage, - ast::Access::kReadWrite, Binding(0_a), Group(0_a)); + type::Access::kReadWrite, Binding(0_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); diff --git a/src/tint/resolver/atomics_test.cc b/src/tint/resolver/atomics_test.cc index a35dcc6538..ba83fcd5a1 100644 --- a/src/tint/resolver/atomics_test.cc +++ b/src/tint/resolver/atomics_test.cc @@ -48,7 +48,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) { TEST_F(ResolverAtomicTest, GlobalStorageStruct) { auto* s = Structure("s", utils::Vector{Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}); - auto* g = GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + auto* g = GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/atomics_validation_test.cc b/src/tint/resolver/atomics_validation_test.cc index e8de3cb37e..f8f66a75c1 100644 --- a/src/tint/resolver/atomics_validation_test.cc +++ b/src/tint/resolver/atomics_validation_test.cc @@ -34,14 +34,14 @@ TEST_F(ResolverAtomicValidationTest, AddressSpace_WorkGroup) { TEST_F(ResolverAtomicValidationTest, AddressSpace_Storage) { GlobalVar("g", ty.atomic(Source{{12, 34}}, ty.i32()), type::AddressSpace::kStorage, - ast::Access::kReadWrite, Group(0_a), Binding(0_a)); + type::Access::kReadWrite, Group(0_a), Binding(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAtomicValidationTest, AddressSpace_Storage_Struct) { auto* s = Structure("s", utils::Vector{Member(Source{{12, 34}}, "a", ty.atomic(ty.i32()))}); - GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Group(0_a), + GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a), Binding(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -198,7 +198,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_Complex) { TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) { auto* s = Structure("s", utils::Vector{Member(Source{{12, 34}}, "a", ty.atomic(ty.i32()))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); @@ -210,7 +210,7 @@ TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) { TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Struct) { auto* s = Structure("s", utils::Vector{Member(Source{{12, 34}}, "a", ty.atomic(ty.i32()))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); @@ -228,8 +228,8 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStruct) { auto* Inner = Structure("Inner", utils::Vector{Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))}); auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage, ast::Access::kRead, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage, + type::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -246,8 +246,8 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStructOfArray) { auto* Inner = Structure("Inner", utils::Vector{Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))}); auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage, ast::Access::kRead, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage, + type::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -287,7 +287,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Complex) { auto* s2 = Structure("S2", utils::Vector{Member("x", ty.Of(s3))}); auto* s1 = Structure("S1", utils::Vector{Member("x", ty.Of(s2))}); auto* s0 = Structure("S0", utils::Vector{Member("x", ty.Of(s1))}); - GlobalVar(Source{{12, 34}}, "g", ty.Of(s0), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{12, 34}}, "g", ty.Of(s0), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/attribute_validation_test.cc b/src/tint/resolver/attribute_validation_test.cc index 31a5e9ea05..00ee7aa780 100644 --- a/src/tint/resolver/attribute_validation_test.cc +++ b/src/tint/resolver/attribute_validation_test.cc @@ -723,7 +723,7 @@ TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAFloat) { TEST_F(StructMemberAttributeTest, Align_Attribute_Var) { GlobalVar(Source{{1, 2}}, "val", ty.f32(), type::AddressSpace::kPrivate, - ast::Access::kUndefined, Expr(1.23_f)); + type::Access::kUndefined, Expr(1.23_f)); Structure(Source{{6, 4}}, "mystruct", utils::Vector{Member(Source{{12, 5}}, "a", ty.f32(), @@ -797,7 +797,7 @@ TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAFloat) { TEST_F(StructMemberAttributeTest, Size_Attribute_Var) { GlobalVar(Source{{1, 2}}, "val", ty.f32(), type::AddressSpace::kPrivate, - ast::Access::kUndefined, Expr(1.23_f)); + type::Access::kUndefined, Expr(1.23_f)); Structure(Source{{6, 4}}, "mystruct", utils::Vector{Member(Source{{12, 5}}, "a", ty.f32(), @@ -1159,7 +1159,7 @@ TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) { auto* s = Structure("S", utils::Vector{ Member("x", ty.i32()), }); - GlobalVar(Source{{12, 34}}, "G", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead); + GlobalVar(Source{{12, 34}}, "G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index 2a689c5f8b..5e13ba9fa5 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -214,7 +214,7 @@ using ResolverBuiltinArrayTest = ResolverTest; TEST_F(ResolverBuiltinArrayTest, ArrayLength_Vector) { auto* ary = ty.array(); auto* str = Structure("S", utils::Vector{Member("x", ary)}); - GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x"))); diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc index 1b785ebe51..2d3f2f3809 100644 --- a/src/tint/resolver/builtin_validation_test.cc +++ b/src/tint/resolver/builtin_validation_test.cc @@ -652,7 +652,7 @@ TEST_F(ResolverBuiltinValidationTest, WorkgroupUniformLoad_WrongAddressSpace) { // fn foo() { // workgroupUniformLoad(&v); // } - GlobalVar("v", ty.i32(), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("v", ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite, utils::Vector{Group(0_a), Binding(0_a)}); WrapInFunction(CallStmt(Call("workgroupUniformLoad", AddressOf(Source{{12, 34}}, "v")))); diff --git a/src/tint/resolver/compound_assignment_validation_test.cc b/src/tint/resolver/compound_assignment_validation_test.cc index f8f2ee6607..64a542cc90 100644 --- a/src/tint/resolver/compound_assignment_validation_test.cc +++ b/src/tint/resolver/compound_assignment_validation_test.cc @@ -233,7 +233,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, ReadOnlyBuffer) { // { // a += 1i; // } - GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), Binding(0_a)); WrapInFunction(CompoundAssign(Source{{56, 78}}, "a", 1_i, ast::BinaryOp::kAdd)); diff --git a/src/tint/resolver/dependency_graph_test.cc b/src/tint/resolver/dependency_graph_test.cc index 756cb3f8a0..4853ade538 100644 --- a/src/tint/resolver/dependency_graph_test.cc +++ b/src/tint/resolver/dependency_graph_test.cc @@ -1297,7 +1297,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) { GlobalVar(Sym(), ty.external_texture()); GlobalVar(Sym(), ty.multisampled_texture(type::TextureDimension::k2d, T)); GlobalVar(Sym(), ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, - ast::Access::kRead)); // + type::Access::kRead)); // GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler)); GlobalVar(Sym(), ty.i32(), utils::Vector{Binding(V), Group(V)}); diff --git a/src/tint/resolver/host_shareable_validation_test.cc b/src/tint/resolver/host_shareable_validation_test.cc index 12560e3851..10358426f7 100644 --- a/src/tint/resolver/host_shareable_validation_test.cc +++ b/src/tint/resolver/host_shareable_validation_test.cc @@ -29,7 +29,7 @@ TEST_F(ResolverHostShareableValidationTest, BoolMember) { auto* s = Structure("S", utils::Vector{Member(Source{{56, 78}}, "x", ty.bool_(Source{{12, 34}}))}); - GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -45,7 +45,7 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) { auto* s = Structure( "S", utils::Vector{Member(Source{{56, 78}}, "x", ty.vec3(Source{{12, 34}}))}); - GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -62,7 +62,7 @@ TEST_F(ResolverHostShareableValidationTest, Aliases) { auto* s = Structure( "S", utils::Vector{Member(Source{{56, 78}}, "x", ty.type_name(Source{{12, 34}}, "a1"))}); auto* a2 = Alias("a2", ty.Of(s)); - GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -81,7 +81,7 @@ TEST_F(ResolverHostShareableValidationTest, NestedStructures) { auto* s = Structure("S", utils::Vector{Member(Source{{7, 8}}, "m", ty.Of(i3))}); - GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -120,7 +120,7 @@ TEST_F(ResolverHostShareableValidationTest, NoError) { auto* s = Structure("S", utils::Vector{Member(Source{{7, 8}}, "m", ty.Of(i3))}); - GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/increment_decrement_validation_test.cc b/src/tint/resolver/increment_decrement_validation_test.cc index d03e6f3608..9f41f3a7a0 100644 --- a/src/tint/resolver/increment_decrement_validation_test.cc +++ b/src/tint/resolver/increment_decrement_validation_test.cc @@ -193,7 +193,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, ReadOnlyBuffer) { // { // a++; // } - GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead, + GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), Binding(0_a)); WrapInFunction(Increment(Source{{56, 78}}, "a")); diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 234eb49a2f..5172e4fe5e 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -329,7 +329,7 @@ class TemplateNumberMatcher : public NumberMatcher { // template //////////////////////////////////////////////////////////////////////////////// using TexelFormat = ast::TexelFormat; -using Access = ast::Access; +using Access = type::Access; using AddressSpace = type::AddressSpace; using ParameterUsage = sem::ParameterUsage; using PipelineStage = ast::PipelineStage; @@ -561,7 +561,7 @@ bool match_ptr(MatchState&, const type::Type* ty, Number& S, const type::Type*& const type::Pointer* build_ptr(MatchState& state, Number S, const type::Type* T, Number& A) { return state.builder.create(T, static_cast(S.Value()), - static_cast(A.Value())); + static_cast(A.Value())); } bool match_atomic(MatchState&, const type::Type* ty, const type::Type*& T) { @@ -1276,7 +1276,7 @@ Impl::Builtin Impl::Lookup(sem::BuiltinType builtin_type, for (auto& p : match.parameters) { params.Push(builder.create( nullptr, static_cast(params.Length()), p.type, type::AddressSpace::kNone, - ast::Access::kUndefined, p.usage)); + type::Access::kUndefined, p.usage)); } sem::PipelineStageSet supported_stages; if (match.overload->flags.Contains(OverloadFlag::kSupportsVertexPipeline)) { @@ -1477,7 +1477,7 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, for (auto& p : match.parameters) { params.Push(builder.create( nullptr, static_cast(params.Length()), p.type, type::AddressSpace::kNone, - ast::Access::kUndefined, p.usage)); + type::Access::kUndefined, p.usage)); } auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant : sem::EvaluationStage::kRuntime; @@ -1492,7 +1492,7 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, auto* target = converters.GetOrCreate(match, [&]() { auto param = builder.create( nullptr, 0u, match.parameters[0].type, type::AddressSpace::kNone, - ast::Access::kUndefined, match.parameters[0].usage); + type::Access::kUndefined, match.parameters[0].usage); auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant : sem::EvaluationStage::kRuntime; return builder.create(match.return_type, param, eval_stage); diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc index 114862acc6..350dd927eb 100644 --- a/src/tint/resolver/intrinsic_table_test.cc +++ b/src/tint/resolver/intrinsic_table_test.cc @@ -232,7 +232,7 @@ TEST_F(IntrinsicTableTest, MatchPointer) { auto* i32 = create(); auto* atomicI32 = create(i32); auto* ptr = - create(atomicI32, type::AddressSpace::kWorkgroup, ast::Access::kReadWrite); + create(atomicI32, type::AddressSpace::kWorkgroup, type::Access::kReadWrite); auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{ptr}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -256,7 +256,7 @@ TEST_F(IntrinsicTableTest, MatchArray) { auto* arr = create(create(), create(), 4u, 4u, 4u, 4u); auto* arr_ptr = - create(arr, type::AddressSpace::kStorage, ast::Access::kReadWrite); + create(arr, type::AddressSpace::kStorage, type::Access::kReadWrite); auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{arr_ptr}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -416,7 +416,7 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) { auto* vec4_f32 = create(f32, 4u); auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types()); auto* tex = create( - type::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite, subtype); + type::TextureDimension::k2d, ast::TexelFormat::kR32Float, type::Access::kWrite, subtype); auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32}, sem::EvaluationStage::kConstant, Source{}); @@ -448,7 +448,7 @@ TEST_F(IntrinsicTableTest, ImplicitLoadOnReference) { auto result = table->Lookup( BuiltinType::kCos, utils::Vector{ - create(f32, type::AddressSpace::kFunction, ast::Access::kReadWrite), + create(f32, type::AddressSpace::kFunction, type::Access::kReadWrite), }, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -549,7 +549,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) { TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) { auto* af = create(); auto* bool_ref = create(create(), type::AddressSpace::kFunction, - ast::Access::kReadWrite); + type::Access::kReadWrite); auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_ref}, sem::EvaluationStage::kRuntime, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); diff --git a/src/tint/resolver/is_host_shareable_test.cc b/src/tint/resolver/is_host_shareable_test.cc index 1e03b652a7..8696900efc 100644 --- a/src/tint/resolver/is_host_shareable_test.cc +++ b/src/tint/resolver/is_host_shareable_test.cc @@ -96,7 +96,7 @@ TEST_F(ResolverIsHostShareable, Matrix) { TEST_F(ResolverIsHostShareable, Pointer) { auto* ptr = create(create(), type::AddressSpace::kPrivate, - ast::Access::kReadWrite); + type::Access::kReadWrite); EXPECT_FALSE(r()->IsHostShareable(ptr)); } diff --git a/src/tint/resolver/is_storeable_test.cc b/src/tint/resolver/is_storeable_test.cc index d7896f2811..bfe64c4a71 100644 --- a/src/tint/resolver/is_storeable_test.cc +++ b/src/tint/resolver/is_storeable_test.cc @@ -79,7 +79,7 @@ TEST_F(ResolverIsStorableTest, Matrix) { TEST_F(ResolverIsStorableTest, Pointer) { auto* ptr = create(create(), type::AddressSpace::kPrivate, - ast::Access::kReadWrite); + type::Access::kReadWrite); EXPECT_FALSE(r()->IsStorable(ptr)); } diff --git a/src/tint/resolver/ptr_ref_test.cc b/src/tint/resolver/ptr_ref_test.cc index 5e41ace703..64b21aef38 100644 --- a/src/tint/resolver/ptr_ref_test.cc +++ b/src/tint/resolver/ptr_ref_test.cc @@ -101,11 +101,11 @@ TEST_F(ResolverPtrRefTest, DefaultPtrAddressSpace) { ASSERT_TRUE(TypeOf(storage_ptr)->Is()) << "storage_ptr is " << TypeOf(storage_ptr)->TypeInfo().name; - EXPECT_EQ(TypeOf(function_ptr)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(private_ptr)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(workgroup_ptr)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(uniform_ptr)->As()->Access(), ast::Access::kRead); - EXPECT_EQ(TypeOf(storage_ptr)->As()->Access(), ast::Access::kRead); + EXPECT_EQ(TypeOf(function_ptr)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(private_ptr)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(workgroup_ptr)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(uniform_ptr)->As()->Access(), type::Access::kRead); + EXPECT_EQ(TypeOf(storage_ptr)->As()->Access(), type::Access::kRead); } } // namespace diff --git a/src/tint/resolver/ptr_ref_validation_test.cc b/src/tint/resolver/ptr_ref_validation_test.cc index 2302689644..9f6f39054f 100644 --- a/src/tint/resolver/ptr_ref_validation_test.cc +++ b/src/tint/resolver/ptr_ref_validation_test.cc @@ -144,7 +144,7 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) { auto* inner = Structure("Inner", utils::Vector{Member("arr", ty.array())}); auto* buf = Structure("S", utils::Vector{Member("inner", ty.Of(inner))}); auto* storage = GlobalVar("s", ty.Of(buf), type::AddressSpace::kStorage, - ast::Access::kReadWrite, Binding(0_a), Group(0_a)); + type::Access::kReadWrite, Binding(0_a), Group(0_a)); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); auto* ptr = diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 032234127b..3f306b594e 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -257,7 +257,7 @@ type::Type* Resolver::Type(const ast::Type* ty) { [&](const ast::Pointer* t) -> type::Pointer* { if (auto* el = Type(t->type)) { auto access = t->access; - if (access == ast::Access::kUndefined) { + if (access == type::Access::kUndefined) { access = DefaultAccessForAddressSpace(t->address_space); } auto ptr = builder_->create(el, t->address_space, access); @@ -405,12 +405,12 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) { if (is_global) { sem = builder_->create( v, ty, sem::EvaluationStage::kRuntime, type::AddressSpace::kNone, - ast::Access::kUndefined, + type::Access::kUndefined, /* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt); } else { sem = builder_->create(v, ty, sem::EvaluationStage::kRuntime, type::AddressSpace::kNone, - ast::Access::kUndefined, current_statement_, + type::Access::kUndefined, current_statement_, /* constant_value */ nullptr); } @@ -465,7 +465,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) { } auto* sem = builder_->create( - v, ty, sem::EvaluationStage::kOverride, type::AddressSpace::kNone, ast::Access::kUndefined, + v, ty, sem::EvaluationStage::kOverride, type::AddressSpace::kNone, type::Access::kUndefined, /* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt); sem->SetInitializer(rhs); @@ -559,10 +559,10 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) { const auto value = rhs->ConstantValue(); auto* sem = is_global ? static_cast(builder_->create( c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kNone, - ast::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt)) + type::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt)) : static_cast(builder_->create( c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kNone, - ast::Access::kUndefined, current_statement_, value)); + type::Access::kUndefined, current_statement_, value)); sem->SetInitializer(rhs); builder_->Sem().Add(c, sem); @@ -627,7 +627,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { } auto access = var->declared_access; - if (access == ast::Access::kUndefined) { + if (access == type::Access::kUndefined) { access = DefaultAccessForAddressSpace(address_space); } @@ -791,7 +791,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) } auto* sem = builder_->create( - param, index, ty, type::AddressSpace::kNone, ast::Access::kUndefined, + param, index, ty, type::AddressSpace::kNone, type::Access::kUndefined, sem::ParameterUsage::kNone, binding_point, location); builder_->Sem().Add(param, sem); return sem; @@ -821,17 +821,17 @@ utils::Result Resolver::LocationAttribute(const ast::LocationAttribute return static_cast(value); } -ast::Access Resolver::DefaultAccessForAddressSpace(type::AddressSpace address_space) { +type::Access Resolver::DefaultAccessForAddressSpace(type::AddressSpace address_space) { // https://gpuweb.github.io/gpuweb/wgsl/#storage-class switch (address_space) { case type::AddressSpace::kStorage: case type::AddressSpace::kUniform: case type::AddressSpace::kHandle: - return ast::Access::kRead; + return type::Access::kRead; default: break; } - return ast::Access::kReadWrite; + return type::Access::kReadWrite; } bool Resolver::AllocateOverridableConstantIds() { @@ -2103,7 +2103,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { static_cast(i), // index arr->ElemType(), // type type::AddressSpace::kNone, // address_space - ast::Access::kUndefined); + type::Access::kUndefined); }); return builder_->create(arr, std::move(params), args_stage); @@ -2132,7 +2132,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { static_cast(i), // index str->Members()[i]->Type(), // type type::AddressSpace::kNone, // address_space - ast::Access::kUndefined); // access + type::Access::kUndefined); // access } return builder_->create(str, std::move(params), args_stage); diff --git a/src/tint/resolver/resolver.h b/src/tint/resolver/resolver.h index e1006a40ee..38d08c020e 100644 --- a/src/tint/resolver/resolver.h +++ b/src/tint/resolver/resolver.h @@ -382,7 +382,7 @@ class Resolver { /// @param address_space the address space /// @returns the default access control for the given address space - ast::Access DefaultAccessForAddressSpace(type::AddressSpace address_space); + type::Access DefaultAccessForAddressSpace(type::AddressSpace address_space); /// Allocate constant IDs for pipeline-overridable constants. /// @returns true on success, false on error diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc index c4fa05fb2a..8be16c1a90 100644 --- a/src/tint/resolver/resolver_test.cc +++ b/src/tint/resolver/resolver_test.cc @@ -920,7 +920,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) { auto* s = Structure("S", utils::Vector{Member("m", ty.u32())}); auto* sb_var = GlobalVar("sb_var", ty.Of(s), type::AddressSpace::kStorage, - ast::Access::kReadWrite, Binding(0_a), Group(0_a)); + type::Access::kReadWrite, Binding(0_a), Group(0_a)); auto* wg_var = GlobalVar("wg_var", ty.f32(), type::AddressSpace::kWorkgroup); auto* priv_var = GlobalVar("priv_var", ty.f32(), type::AddressSpace::kPrivate); @@ -988,7 +988,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) { auto* s = Structure("S", utils::Vector{Member("m", ty.u32())}); auto* sb_var = GlobalVar("sb_var", ty.Of(s), type::AddressSpace::kStorage, - ast::Access::kReadWrite, Binding(0_a), Group(0_a)); + type::Access::kReadWrite, Binding(0_a), Group(0_a)); auto* wg_var = GlobalVar("wg_var", ty.f32(), type::AddressSpace::kWorkgroup); auto* priv_var = GlobalVar("priv_var", ty.f32(), type::AddressSpace::kPrivate); @@ -1914,7 +1914,7 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) { EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_EQ(Sem().Get(var)->Access(), ast::Access::kRead); + EXPECT_EQ(Sem().Get(var)->Access(), type::Access::kRead); } TEST_F(ResolverTest, BindingPoint_SetForResources) { diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h index 449944a650..3158b63e6b 100644 --- a/src/tint/resolver/resolver_test_helper.h +++ b/src/tint/resolver/resolver_test_helper.h @@ -617,13 +617,13 @@ struct DataType> { /// @return a new AST alias type static inline const ast::Type* AST(ProgramBuilder& b) { return b.create(DataType::AST(b), type::AddressSpace::kPrivate, - ast::Access::kUndefined); + type::Access::kUndefined); } /// @param b the ProgramBuilder /// @return the semantic aliased type static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(DataType::Sem(b), type::AddressSpace::kPrivate, - ast::Access::kReadWrite); + type::Access::kReadWrite); } /// @param b the ProgramBuilder diff --git a/src/tint/resolver/side_effects_test.cc b/src/tint/resolver/side_effects_test.cc index ba3950d5e1..45b75cdf60 100644 --- a/src/tint/resolver/side_effects_test.cc +++ b/src/tint/resolver/side_effects_test.cc @@ -178,7 +178,7 @@ TEST_P(SideEffectsBuiltinTest, Test) { GlobalVar("storage_arr", ty.array(), type::AddressSpace::kStorage, Group(0_a), Binding(AInt(next_binding++))); GlobalVar("workgroup_arr", ty.array(), type::AddressSpace::kWorkgroup); - GlobalVar("a", ty.atomic(ty.i32()), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("a", ty.atomic(ty.i32()), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a), Binding(AInt(next_binding++))); if (c.pipeline_stage != ast::PipelineStage::kCompute) { GlobalVar("t2d", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(0_a), @@ -191,7 +191,7 @@ TEST_P(SideEffectsBuiltinTest, Test) { Group(0_a), Binding(AInt(next_binding++))); GlobalVar("tstorage2d", ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, - ast::Access::kWrite), + type::Access::kWrite), Group(0_a), Binding(AInt(next_binding++))); GlobalVar("s2d", ty.sampler(ast::SamplerKind::kSampler), Group(0_a), Binding(AInt(next_binding++))); diff --git a/src/tint/resolver/struct_address_space_use_test.cc b/src/tint/resolver/struct_address_space_use_test.cc index fe7b5cc236..a0ff744984 100644 --- a/src/tint/resolver/struct_address_space_use_test.cc +++ b/src/tint/resolver/struct_address_space_use_test.cc @@ -160,7 +160,7 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableViaLocalArray) { TEST_F(ResolverAddressSpaceUseTest, StructMultipleAddressSpaceUses) { auto* s = Structure("S", utils::Vector{Member("a", ty.f32())}); GlobalVar("x", ty.Of(s), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); - GlobalVar("y", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("y", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(0_a)); WrapInFunction(Var("g", ty.Of(s))); diff --git a/src/tint/resolver/type_initializer_validation_test.cc b/src/tint/resolver/type_initializer_validation_test.cc index 9220fd46eb..27b6dc11d3 100644 --- a/src/tint/resolver/type_initializer_validation_test.cc +++ b/src/tint/resolver/type_initializer_validation_test.cc @@ -98,7 +98,7 @@ TEST_P(InferTypeTest_FromInitializerExpression, All) { ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* got = TypeOf(a_ident); auto* expected = create( - params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, ast::Access::kReadWrite); + params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, type::Access::kReadWrite); ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n" << "expected: " << FriendlyName(expected) << "\n"; } @@ -152,7 +152,7 @@ TEST_P(InferTypeTest_FromArithmeticExpression, All) { ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* got = TypeOf(a_ident); auto* expected = create( - params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, ast::Access::kReadWrite); + params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, type::Access::kReadWrite); ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n" << "expected: " << FriendlyName(expected) << "\n"; } @@ -200,7 +200,7 @@ TEST_P(InferTypeTest_FromCallExpression, All) { ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* got = TypeOf(a_ident); auto* expected = create( - params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, ast::Access::kReadWrite); + params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, type::Access::kReadWrite); ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n" << "expected: " << FriendlyName(expected) << "\n"; } diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc index 88254a8cb9..d32ab06ea2 100644 --- a/src/tint/resolver/type_validation_test.cc +++ b/src/tint/resolver/type_validation_test.cc @@ -1114,7 +1114,7 @@ TEST_P(StorageTextureDimensionTest, All) { auto& params = GetParam(); auto* st = ty.storage_texture(Source{{12, 34}}, params.dim, ast::TexelFormat::kR32Uint, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("a", st, Group(0_a), Binding(0_a)); @@ -1166,19 +1166,19 @@ TEST_P(StorageTextureFormatTest, All) { // var d : texture_storage_3d<*, write>; auto* st_a = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, params.format, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("a", st_a, Group(0_a), Binding(0_a)); auto* st_b = - ty.storage_texture(type::TextureDimension::k2d, params.format, ast::Access::kWrite); + ty.storage_texture(type::TextureDimension::k2d, params.format, type::Access::kWrite); GlobalVar("b", st_b, Group(0_a), Binding(1_a)); auto* st_c = - ty.storage_texture(type::TextureDimension::k2dArray, params.format, ast::Access::kWrite); + ty.storage_texture(type::TextureDimension::k2dArray, params.format, type::Access::kWrite); GlobalVar("c", st_c, Group(0_a), Binding(2_a)); auto* st_d = - ty.storage_texture(type::TextureDimension::k3d, params.format, ast::Access::kWrite); + ty.storage_texture(type::TextureDimension::k3d, params.format, type::Access::kWrite); GlobalVar("d", st_d, Group(0_a), Binding(3_a)); if (params.is_valid) { @@ -1201,7 +1201,7 @@ TEST_F(StorageTextureAccessTest, MissingAccess_Fail) { // var a : texture_storage_1d; auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, - ast::TexelFormat::kR32Uint, ast::Access::kUndefined); + ast::TexelFormat::kR32Uint, type::Access::kUndefined); GlobalVar("a", st, Group(0_a), Binding(0_a)); @@ -1214,7 +1214,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) { // var a : texture_storage_1d; auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, - ast::TexelFormat::kR32Uint, ast::Access::kReadWrite); + ast::TexelFormat::kR32Uint, type::Access::kReadWrite); GlobalVar("a", st, Group(0_a), Binding(0_a)); @@ -1228,7 +1228,7 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) { // var a : texture_storage_1d; auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, - ast::TexelFormat::kR32Uint, ast::Access::kRead); + ast::TexelFormat::kR32Uint, type::Access::kRead); GlobalVar("a", st, Group(0_a), Binding(0_a)); @@ -1242,7 +1242,7 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) { // var a : texture_storage_1d; auto* st = ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kR32Uint, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("a", st, Group(0_a), Binding(0_a)); diff --git a/src/tint/resolver/uniformity.cc b/src/tint/resolver/uniformity.cc index d75b7796d6..7b297e17db 100644 --- a/src/tint/resolver/uniformity.cc +++ b/src/tint/resolver/uniformity.cc @@ -1151,7 +1151,7 @@ class UniformityGraph { [&](const sem::GlobalVariable* global) { // Loads from global read-write variables may be non-uniform. if (global->Declaration()->Is() && - global->Access() != ast::Access::kRead && load_rule) { + global->Access() != type::Access::kRead && load_rule) { node->AddEdge(current_function_->may_be_non_uniform); } else { node->AddEdge(cf); @@ -1168,7 +1168,7 @@ class UniformityGraph { // We are loading from the pointer, so add an edge to its contents. auto* root = var_user->RootIdentifier(); if (root->Is()) { - if (root->Access() != ast::Access::kRead) { + if (root->Access() != type::Access::kRead) { // The contents of a mutable global variable is always non-uniform. node->AddEdge(current_function_->may_be_non_uniform); } @@ -1420,7 +1420,7 @@ class UniformityGraph { auto* root = sem_arg->RootIdentifier(); if (root->Is()) { - if (root->Access() != ast::Access::kRead) { + if (root->Access() != type::Access::kRead) { // The contents of a mutable global variable is always non-uniform. arg_contents->AddEdge(current_function_->may_be_non_uniform); } diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index 1f357d33ad..f04f4b827c 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -278,7 +278,7 @@ bool Validator::Pointer(const ast::Pointer* a, const type::Pointer* s) const { return false; } - if (a->access != ast::Access::kUndefined) { + if (a->access != type::Access::kUndefined) { // https://www.w3.org/TR/WGSL/#access-mode-defaults // When writing a variable declaration or a pointer type in WGSL source: // * For the storage address space, the access mode is optional, and defaults to read. @@ -296,9 +296,9 @@ bool Validator::Pointer(const ast::Pointer* a, const type::Pointer* s) const { bool Validator::StorageTexture(const ast::StorageTexture* t) const { switch (t->access) { - case ast::Access::kWrite: + case type::Access::kWrite: break; - case ast::Access::kUndefined: + case type::Access::kUndefined: AddError("storage texture missing access control", t->source); return false; default: @@ -693,7 +693,7 @@ bool Validator::Var(const sem::Variable* v) const { } } - if (var->declared_access != ast::Access::kUndefined) { + if (var->declared_access != type::Access::kUndefined) { // https://www.w3.org/TR/WGSL/#access-mode-defaults // When writing a variable declaration or a pointer type in WGSL source: // * For the storage address space, the access mode is optional, and defaults to read. @@ -2353,7 +2353,7 @@ bool Validator::Assignment(const ast::Statement* a, const type::Type* rhs_ty) co AddError("storage type of assignment must be constructible", a->source); return false; } - if (lhs_ref->Access() == ast::Access::kRead) { + if (lhs_ref->Access() == type::Access::kRead) { AddError("cannot store into a read-only type '" + sem_.RawTypeNameOf(lhs_ty) + "'", a->source); return false; @@ -2394,7 +2394,7 @@ bool Validator::IncrementDecrementStatement(const ast::IncrementDecrementStateme return false; } - if (lhs_ref->Access() == ast::Access::kRead) { + if (lhs_ref->Access() == type::Access::kRead) { AddError("cannot modify read-only type '" + sem_.RawTypeNameOf(lhs_ty) + "'", inc->source); return false; } @@ -2454,7 +2454,7 @@ std::string Validator::VectorPretty(uint32_t size, const type::Type* element_typ bool Validator::CheckTypeAccessAddressSpace( const type::Type* store_ty, - ast::Access access, + type::Access access, type::AddressSpace address_space, utils::VectorRef attributes, const Source& source) const { @@ -2472,7 +2472,7 @@ bool Validator::CheckTypeAccessAddressSpace( return false; } - if (address_space == type::AddressSpace::kStorage && access == ast::Access::kWrite) { + if (address_space == type::AddressSpace::kStorage && access == type::Access::kWrite) { // The access mode for the storage address space can only be 'read' or // 'read_write'. AddError("access mode 'write' is not valid for the 'storage' address space", source); @@ -2484,7 +2484,7 @@ bool Validator::CheckTypeAccessAddressSpace( address_space != type::AddressSpace::kWorkgroup) { return "atomic variables must have or address space"; } - if (address_space == type::AddressSpace::kStorage && access != ast::Access::kReadWrite) { + if (address_space == type::AddressSpace::kStorage && access != type::Access::kReadWrite) { return "atomic variables in address space must have read_write access " "mode"; } diff --git a/src/tint/resolver/validator.h b/src/tint/resolver/validator.h index 72d9d20fdc..891f02daa9 100644 --- a/src/tint/resolver/validator.h +++ b/src/tint/resolver/validator.h @@ -518,7 +518,7 @@ class Validator { /// @param source the source for the error /// @returns true on success, false if an error was raised. bool CheckTypeAccessAddressSpace(const type::Type* store_ty, - ast::Access access, + type::Access access, type::AddressSpace address_space, utils::VectorRef attributes, const Source& source) const; diff --git a/src/tint/resolver/validator_is_storeable_test.cc b/src/tint/resolver/validator_is_storeable_test.cc index e8a1fdff84..6c1fce4d9b 100644 --- a/src/tint/resolver/validator_is_storeable_test.cc +++ b/src/tint/resolver/validator_is_storeable_test.cc @@ -79,7 +79,7 @@ TEST_F(ValidatorIsStorableTest, Matrix) { TEST_F(ValidatorIsStorableTest, Pointer) { auto* ptr = create(create(), type::AddressSpace::kPrivate, - ast::Access::kReadWrite); + type::Access::kReadWrite); EXPECT_FALSE(v()->IsStorable(ptr)); } diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc index 2ca1719ef3..b62812a41e 100644 --- a/src/tint/resolver/variable_test.cc +++ b/src/tint/resolver/variable_test.cc @@ -149,12 +149,12 @@ TEST_F(ResolverVariableTest, LocalVar_WithInitializer) { ASSERT_TRUE(TypeOf(s)->Is()); ASSERT_TRUE(TypeOf(a)->Is()); - EXPECT_EQ(TypeOf(i)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(u)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(f)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(b)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(s)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(a)->As()->Access(), ast::Access::kReadWrite); + EXPECT_EQ(TypeOf(i)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(u)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(f)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(b)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(s)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(a)->As()->Access(), type::Access::kReadWrite); EXPECT_TRUE(TypeOf(i)->As()->StoreType()->Is()); EXPECT_TRUE(TypeOf(u)->As()->StoreType()->Is()); @@ -473,7 +473,7 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) { auto* inner = Structure("Inner", utils::Vector{Member("arr", ty.array())}); auto* buf = Structure("S", utils::Vector{Member("inner", ty.Of(inner))}); auto* storage = GlobalVar("s", ty.Of(buf), type::AddressSpace::kStorage, - ast::Access::kReadWrite, Binding(0_a), Group(0_a)); + type::Access::kReadWrite, Binding(0_a), Group(0_a)); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 3_i); auto* ptr = Let("p", AddressOf(expr)); @@ -485,8 +485,8 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) { ASSERT_TRUE(TypeOf(expr)->Is()); ASSERT_TRUE(TypeOf(ptr)->Is()); - EXPECT_EQ(TypeOf(expr)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(ptr)->As()->Access(), ast::Access::kReadWrite); + EXPECT_EQ(TypeOf(expr)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(ptr)->As()->Access(), type::Access::kReadWrite); } TEST_F(ResolverVariableTest, LocalLet_ShadowsAlias) { @@ -1054,11 +1054,11 @@ TEST_F(ResolverVariableTest, GlobalVar_AddressSpace) { ASSERT_TRUE(TypeOf(storage)->Is()); ASSERT_TRUE(TypeOf(handle)->Is()); - EXPECT_EQ(TypeOf(private_)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(workgroup)->As()->Access(), ast::Access::kReadWrite); - EXPECT_EQ(TypeOf(uniform)->As()->Access(), ast::Access::kRead); - EXPECT_EQ(TypeOf(storage)->As()->Access(), ast::Access::kRead); - EXPECT_EQ(TypeOf(handle)->As()->Access(), ast::Access::kRead); + EXPECT_EQ(TypeOf(private_)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(workgroup)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(uniform)->As()->Access(), type::Access::kRead); + EXPECT_EQ(TypeOf(storage)->As()->Access(), type::Access::kRead); + EXPECT_EQ(TypeOf(handle)->As()->Access(), type::Access::kRead); } TEST_F(ResolverVariableTest, GlobalVar_ExplicitAddressSpace) { @@ -1066,13 +1066,13 @@ TEST_F(ResolverVariableTest, GlobalVar_ExplicitAddressSpace) { auto* buf = Structure("S", utils::Vector{Member("m", ty.i32())}); auto* storage = GlobalVar("sb", ty.Of(buf), type::AddressSpace::kStorage, - ast::Access::kReadWrite, Binding(1_a), Group(0_a)); + type::Access::kReadWrite, Binding(1_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(TypeOf(storage)->Is()); - EXPECT_EQ(TypeOf(storage)->As()->Access(), ast::Access::kReadWrite); + EXPECT_EQ(TypeOf(storage)->As()->Access(), type::Access::kReadWrite); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/tint/resolver/variable_validation_test.cc b/src/tint/resolver/variable_validation_test.cc index 529a11945f..090632265a 100644 --- a/src/tint/resolver/variable_validation_test.cc +++ b/src/tint/resolver/variable_validation_test.cc @@ -299,7 +299,7 @@ TEST_F(ResolverVariableValidationTest, InferredPtrStorageAccessMismatch) { auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); auto* ptr = Let(Source{{12, 34}}, "p", - ty.pointer(type::AddressSpace::kStorage, ast::Access::kReadWrite), + ty.pointer(type::AddressSpace::kStorage, type::Access::kReadWrite), AddressOf(expr)); WrapInFunction(ptr); diff --git a/src/tint/sem/variable.cc b/src/tint/sem/variable.cc index a772ff56e4..6dc327d7f0 100644 --- a/src/tint/sem/variable.cc +++ b/src/tint/sem/variable.cc @@ -32,7 +32,7 @@ Variable::Variable(const ast::Variable* declaration, const type::Type* type, EvaluationStage stage, type::AddressSpace address_space, - ast::Access access, + type::Access access, const constant::Value* constant_value) : declaration_(declaration), type_(type), @@ -47,7 +47,7 @@ LocalVariable::LocalVariable(const ast::Variable* declaration, const type::Type* type, EvaluationStage stage, type::AddressSpace address_space, - ast::Access access, + type::Access access, const sem::Statement* statement, const constant::Value* constant_value) : Base(declaration, type, stage, address_space, access, constant_value), @@ -59,7 +59,7 @@ GlobalVariable::GlobalVariable(const ast::Variable* declaration, const type::Type* type, EvaluationStage stage, type::AddressSpace address_space, - ast::Access access, + type::Access access, const constant::Value* constant_value, sem::BindingPoint binding_point, std::optional location) @@ -73,7 +73,7 @@ Parameter::Parameter(const ast::Parameter* declaration, uint32_t index, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const ParameterUsage usage /* = ParameterUsage::kNone */, sem::BindingPoint binding_point /* = {} */, std::optional location /* = std::nullopt */) diff --git a/src/tint/sem/variable.h b/src/tint/sem/variable.h index efee4f98a0..cecad1ece0 100644 --- a/src/tint/sem/variable.h +++ b/src/tint/sem/variable.h @@ -21,11 +21,11 @@ #include "tint/override_id.h" -#include "src/tint/ast/access.h" #include "src/tint/ast/parameter.h" #include "src/tint/sem/binding_point.h" #include "src/tint/sem/expression.h" #include "src/tint/sem/parameter_usage.h" +#include "src/tint/type/access.h" #include "src/tint/type/address_space.h" #include "src/tint/type/type.h" #include "src/tint/utils/unique_vector.h" @@ -58,7 +58,7 @@ class Variable : public Castable { const type::Type* type, EvaluationStage stage, type::AddressSpace address_space, - ast::Access access, + type::Access access, const constant::Value* constant_value); /// Destructor @@ -77,7 +77,7 @@ class Variable : public Castable { type::AddressSpace AddressSpace() const { return address_space_; } /// @returns the access control for the variable - ast::Access Access() const { return access_; } + type::Access Access() const { return access_; } /// @return the constant value of this expression const constant::Value* ConstantValue() const { return constant_value_; } @@ -101,7 +101,7 @@ class Variable : public Castable { const type::Type* const type_; const EvaluationStage stage_; const type::AddressSpace address_space_; - const ast::Access access_; + const type::Access access_; const constant::Value* constant_value_; const Expression* initializer_ = nullptr; std::vector users_; @@ -122,7 +122,7 @@ class LocalVariable final : public Castable { const type::Type* type, EvaluationStage stage, type::AddressSpace address_space, - ast::Access access, + type::Access access, const sem::Statement* statement, const constant::Value* constant_value); @@ -163,7 +163,7 @@ class GlobalVariable final : public Castable { const type::Type* type, EvaluationStage stage, type::AddressSpace address_space, - ast::Access access, + type::Access access, const constant::Value* constant_value, sem::BindingPoint binding_point = {}, std::optional location = std::nullopt); @@ -206,7 +206,7 @@ class Parameter final : public Castable { uint32_t index, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const ParameterUsage usage = ParameterUsage::kNone, sem::BindingPoint binding_point = {}, std::optional location = std::nullopt); diff --git a/src/tint/transform/binding_remapper.cc b/src/tint/transform/binding_remapper.cc index 7b22535e25..5967d84e6a 100644 --- a/src/tint/transform/binding_remapper.cc +++ b/src/tint/transform/binding_remapper.cc @@ -122,8 +122,8 @@ Transform::ApplyResult BindingRemapper::Apply(const Program* src, // Replace any access controls. auto ac_it = remappings->access_controls.find(from); if (ac_it != remappings->access_controls.end()) { - ast::Access ac = ac_it->second; - if (ac == ast::Access::kUndefined) { + type::Access ac = ac_it->second; + if (ac == type::Access::kUndefined) { b.Diagnostics().add_error( diag::System::Transform, "invalid access mode (" + std::to_string(static_cast(ac)) + ")"); diff --git a/src/tint/transform/binding_remapper.h b/src/tint/transform/binding_remapper.h index b0efe0dbe4..e0f48b3568 100644 --- a/src/tint/transform/binding_remapper.h +++ b/src/tint/transform/binding_remapper.h @@ -17,9 +17,9 @@ #include -#include "src/tint/ast/access.h" #include "src/tint/sem/binding_point.h" #include "src/tint/transform/transform.h" +#include "src/tint/type/access.h" namespace tint::transform { @@ -34,7 +34,7 @@ class BindingRemapper final : public Castable { using BindingPoints = std::unordered_map; /// AccessControls is a map of old binding point to new access control - using AccessControls = std::unordered_map; + using AccessControls = std::unordered_map; /// Remappings is consumed by the BindingRemapper transform. /// Data holds information about shader usage and constant buffer offsets. diff --git a/src/tint/transform/binding_remapper_test.cc b/src/tint/transform/binding_remapper_test.cc index 5bafb7e61f..5bed528ca5 100644 --- a/src/tint/transform/binding_remapper_test.cc +++ b/src/tint/transform/binding_remapper_test.cc @@ -52,7 +52,7 @@ TEST_F(BindingRemapperTest, ShouldRunAccessControlRemappings) { DataMap data; data.Add(BindingRemapper::BindingPoints{}, BindingRemapper::AccessControls{ - {{2, 1}, ast::Access::kWrite}, + {{2, 1}, type::Access::kWrite}, }); EXPECT_TRUE(ShouldRun(src, data)); @@ -162,9 +162,9 @@ fn f() { data.Add( BindingRemapper::BindingPoints{}, BindingRemapper::AccessControls{ - {{2, 1}, ast::Access::kReadWrite}, // Modify access control + {{2, 1}, type::Access::kReadWrite}, // Modify access control // Keep @group(3) @binding(2) as is - {{4, 3}, ast::Access::kRead}, // Add access control + {{4, 3}, type::Access::kRead}, // Add access control }); auto got = Run(src, data); @@ -207,8 +207,8 @@ fn f() { {{3, 2}, {6, 7}}, }, BindingRemapper::AccessControls{ - {{2, 1}, ast::Access::kReadWrite}, - {{3, 2}, ast::Access::kReadWrite}, + {{2, 1}, type::Access::kReadWrite}, + {{3, 2}, type::Access::kReadWrite}, }); auto got = Run(src, data); diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc index d6f98d5bbb..cbef564edf 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -110,7 +110,7 @@ struct OffsetBinOp : Offset { /// LoadStoreKey is the unordered map key to a load or store intrinsic. struct LoadStoreKey { type::AddressSpace const address_space; // buffer address space - ast::Access const access; // buffer access + type::Access const access; // buffer access type::Type const* buf_ty = nullptr; // buffer type type::Type const* el_ty = nullptr; // element type bool operator==(const LoadStoreKey& rhs) const { @@ -126,7 +126,7 @@ struct LoadStoreKey { /// AtomicKey is the unordered map key to an atomic intrinsic. struct AtomicKey { - ast::Access const access; // buffer access + type::Access const access; // buffer access type::Type const* buf_ty = nullptr; // buffer type type::Type const* el_ty = nullptr; // element type sem::BuiltinType const op; // atomic op @@ -467,7 +467,7 @@ struct DecomposeMemoryAccess::State { auto address_space = var_user->Variable()->AddressSpace(); auto access = var_user->Variable()->Access(); if (address_space != type::AddressSpace::kStorage) { - access = ast::Access::kUndefined; + access = type::Access::kUndefined; } return utils::GetOrCreate( load_funcs, LoadStoreKey{address_space, access, buf_ty, el_ty}, [&] { @@ -566,7 +566,7 @@ struct DecomposeMemoryAccess::State { auto address_space = var_user->Variable()->AddressSpace(); auto access = var_user->Variable()->Access(); if (address_space != type::AddressSpace::kStorage) { - access = ast::Access::kUndefined; + access = type::Access::kUndefined; } return utils::GetOrCreate( store_funcs, LoadStoreKey{address_space, access, buf_ty, el_ty}, [&] { @@ -679,7 +679,7 @@ struct DecomposeMemoryAccess::State { auto address_space = var_user->Variable()->AddressSpace(); auto access = var_user->Variable()->Access(); if (address_space != type::AddressSpace::kStorage) { - access = ast::Access::kUndefined; + access = type::Access::kUndefined; } return utils::GetOrCreate(atomic_funcs, AtomicKey{access, buf_ty, el_ty, op}, [&] { // The first parameter to all WGSL atomics is the expression to the diff --git a/src/tint/transform/decompose_strided_array_test.cc b/src/tint/transform/decompose_strided_array_test.cc index b5cc53dbcd..3befa652f3 100644 --- a/src/tint/transform/decompose_strided_array_test.cc +++ b/src/tint/transform/decompose_strided_array_test.cc @@ -344,7 +344,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) { // } ProgramBuilder b; auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(32))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -398,7 +398,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) { // } ProgramBuilder b; auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(4))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -450,7 +450,7 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) { // } ProgramBuilder b; auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(32))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -511,7 +511,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) { ProgramBuilder b; b.Alias("ARR", b.ty.array(32)); auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR"))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -581,7 +581,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) { b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16), // 4_u, 128)); auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR_B"))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ diff --git a/src/tint/transform/decompose_strided_matrix_test.cc b/src/tint/transform/decompose_strided_matrix_test.cc index 8b36f6101a..e097acb645 100644 --- a/src/tint/transform/decompose_strided_matrix_test.cc +++ b/src/tint/transform/decompose_strided_matrix_test.cc @@ -241,7 +241,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -299,7 +299,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func( "f", utils::Empty, b.ty.void_(), @@ -354,7 +354,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -413,7 +413,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -473,7 +473,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ diff --git a/src/tint/transform/preserve_padding.cc b/src/tint/transform/preserve_padding.cc index 296e055562..0e26d27e29 100644 --- a/src/tint/transform/preserve_padding.cc +++ b/src/tint/transform/preserve_padding.cc @@ -121,7 +121,7 @@ struct PreservePadding::State { utils::Vector params = { b.Param(kDestParamName, b.ty.pointer(CreateASTTypeFor(ctx, ty), type::AddressSpace::kStorage, - ast::Access::kReadWrite)), + type::Access::kReadWrite)), b.Param(kValueParamName, CreateASTTypeFor(ctx, ty)), }; b.Func(helper_name, params, b.ty.void_(), body()); diff --git a/src/tint/transform/promote_side_effects_to_decl.cc b/src/tint/transform/promote_side_effects_to_decl.cc index ff1c18f9d4..d16bf8c081 100644 --- a/src/tint/transform/promote_side_effects_to_decl.cc +++ b/src/tint/transform/promote_side_effects_to_decl.cc @@ -282,7 +282,7 @@ class DecomposeSideEffects::CollectHoistsState : public StateBase { return false; } // Don't hoist read-only variables as they cannot receive side-effects. - if (var_user->Variable()->Access() == ast::Access::kRead) { + if (var_user->Variable()->Access() == type::Access::kRead) { return false; } // Don't hoist textures / samplers as they can't be placed into a let, nor diff --git a/src/tint/transform/vertex_pulling.cc b/src/tint/transform/vertex_pulling.cc index e4cc9ce0ac..60b02a694c 100644 --- a/src/tint/transform/vertex_pulling.cc +++ b/src/tint/transform/vertex_pulling.cc @@ -322,7 +322,7 @@ struct VertexPulling::State { for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) { // The decorated variable with struct type b.GlobalVar(GetVertexBufferName(i), b.ty.Of(struct_type), type::AddressSpace::kStorage, - ast::Access::kRead, b.Binding(AInt(i)), b.Group(AInt(cfg.pulling_group))); + type::Access::kRead, b.Binding(AInt(i)), b.Group(AInt(cfg.pulling_group))); } } diff --git a/src/tint/ast/access.cc b/src/tint/type/access.cc similarity index 93% rename from src/tint/ast/access.cc rename to src/tint/type/access.cc index 7ca9b52da9..04ccd9d32e 100644 --- a/src/tint/ast/access.cc +++ b/src/tint/type/access.cc @@ -15,14 +15,14 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/ast/access.cc.tmpl +// src/tint/type/access.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/ast/access.h" +#include "src/tint/type/access.h" -namespace tint::ast { +namespace tint::type { /// ParseAccess parses a Access from a string. /// @param str the string to parse @@ -54,4 +54,4 @@ std::ostream& operator<<(std::ostream& out, Access value) { return out << ""; } -} // namespace tint::ast +} // namespace tint::type diff --git a/src/tint/ast/access.cc.tmpl b/src/tint/type/access.cc.tmpl similarity index 87% rename from src/tint/ast/access.cc.tmpl rename to src/tint/type/access.cc.tmpl index bd52a3b5a7..b34ff6130a 100644 --- a/src/tint/ast/access.cc.tmpl +++ b/src/tint/type/access.cc.tmpl @@ -14,12 +14,12 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "access") -}} -#include "src/tint/ast/access.h" +#include "src/tint/type/access.h" -namespace tint::ast { +namespace tint::type { {{ Eval "ParseEnum" $enum}} {{ Eval "EnumOStream" $enum}} -} // namespace tint::ast +} // namespace tint::type diff --git a/src/tint/ast/access.h b/src/tint/type/access.h similarity index 89% rename from src/tint/ast/access.h rename to src/tint/type/access.h index e213691852..26f24f6241 100644 --- a/src/tint/ast/access.h +++ b/src/tint/type/access.h @@ -15,17 +15,17 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/ast/access.h.tmpl +// src/tint/type/access.h.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#ifndef SRC_TINT_AST_ACCESS_H_ -#define SRC_TINT_AST_ACCESS_H_ +#ifndef SRC_TINT_TYPE_ACCESS_H_ +#define SRC_TINT_TYPE_ACCESS_H_ #include -namespace tint::ast { +namespace tint::type { /// Address space of a given pointer. enum class Access { @@ -51,6 +51,6 @@ constexpr const char* kAccessStrings[] = { "write", }; -} // namespace tint::ast +} // namespace tint::type -#endif // SRC_TINT_AST_ACCESS_H_ +#endif // SRC_TINT_TYPE_ACCESS_H_ diff --git a/src/tint/ast/access.h.tmpl b/src/tint/type/access.h.tmpl similarity index 80% rename from src/tint/ast/access.h.tmpl rename to src/tint/type/access.h.tmpl index ab14fcfe91..6d353e5578 100644 --- a/src/tint/ast/access.h.tmpl +++ b/src/tint/type/access.h.tmpl @@ -14,16 +14,16 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "access") -}} -#ifndef SRC_TINT_AST_ACCESS_H_ -#define SRC_TINT_AST_ACCESS_H_ +#ifndef SRC_TINT_TYPE_ACCESS_H_ +#define SRC_TINT_TYPE_ACCESS_H_ #include -namespace tint::ast { +namespace tint::type { /// Address space of a given pointer. {{ Eval "DeclareEnum" $enum}} -} // namespace tint::ast +} // namespace tint::type -#endif // SRC_TINT_AST_ACCESS_H_ +#endif // SRC_TINT_TYPE_ACCESS_H_ diff --git a/src/tint/ast/access_bench.cc b/src/tint/type/access_bench.cc similarity index 92% rename from src/tint/ast/access_bench.cc rename to src/tint/type/access_bench.cc index 46b4f93604..6b163179c6 100644 --- a/src/tint/ast/access_bench.cc +++ b/src/tint/type/access_bench.cc @@ -15,18 +15,18 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/ast/access_bench.cc.tmpl +// src/tint/type/access_bench.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/ast/access.h" +#include "src/tint/type/access.h" #include #include "benchmark/benchmark.h" -namespace tint::ast { +namespace tint::type { namespace { void AccessParser(::benchmark::State& state) { @@ -48,4 +48,4 @@ void AccessParser(::benchmark::State& state) { BENCHMARK(AccessParser); } // namespace -} // namespace tint::ast +} // namespace tint::type diff --git a/src/tint/ast/access_bench.cc.tmpl b/src/tint/type/access_bench.cc.tmpl similarity index 88% rename from src/tint/ast/access_bench.cc.tmpl rename to src/tint/type/access_bench.cc.tmpl index e4ef341cd0..420f48642e 100644 --- a/src/tint/ast/access_bench.cc.tmpl +++ b/src/tint/type/access_bench.cc.tmpl @@ -14,16 +14,16 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "access") -}} -#include "src/tint/ast/access.h" +#include "src/tint/type/access.h" #include #include "benchmark/benchmark.h" -namespace tint::ast { +namespace tint::type { namespace { {{ Eval "BenchmarkParseEnum" $enum }} } // namespace -} // namespace tint::ast +} // namespace tint::type diff --git a/src/tint/ast/access_test.cc b/src/tint/type/access_test.cc similarity index 93% rename from src/tint/ast/access_test.cc rename to src/tint/type/access_test.cc index 017915d793..77968efa3f 100644 --- a/src/tint/ast/access_test.cc +++ b/src/tint/type/access_test.cc @@ -15,19 +15,19 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/ast/access_test.cc.tmpl +// src/tint/type/access_test.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/ast/access.h" +#include "src/tint/type/access.h" #include -#include "src/tint/ast/test_helper.h" +#include "src/tint/type/test_helper.h" #include "src/tint/utils/string.h" -namespace tint::ast { +namespace tint::type { namespace { namespace parse_print_tests { @@ -79,4 +79,4 @@ INSTANTIATE_TEST_SUITE_P(ValidCases, AccessPrintTest, testing::ValuesIn(kValidCa } // namespace parse_print_tests } // namespace -} // namespace tint::ast +} // namespace tint::type diff --git a/src/tint/ast/access_test.cc.tmpl b/src/tint/type/access_test.cc.tmpl similarity index 84% rename from src/tint/ast/access_test.cc.tmpl rename to src/tint/type/access_test.cc.tmpl index 9b4b71a007..dd6ed44c34 100644 --- a/src/tint/ast/access_test.cc.tmpl +++ b/src/tint/type/access_test.cc.tmpl @@ -14,17 +14,17 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "access") -}} -#include "src/tint/ast/access.h" +#include "src/tint/type/access.h" #include -#include "src/tint/ast/test_helper.h" +#include "src/tint/type/test_helper.h" #include "src/tint/utils/string.h" -namespace tint::ast { +namespace tint::type { namespace { {{ Eval "TestParsePrintEnum" $enum}} } // namespace -} // namespace tint::ast +} // namespace tint::type diff --git a/src/tint/type/pointer.cc b/src/tint/type/pointer.cc index 5c9b5c6ec3..f00f4fb805 100644 --- a/src/tint/type/pointer.cc +++ b/src/tint/type/pointer.cc @@ -22,14 +22,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Pointer); namespace tint::type { -Pointer::Pointer(const Type* subtype, type::AddressSpace address_space, ast::Access access) +Pointer::Pointer(const Type* subtype, type::AddressSpace address_space, type::Access access) : Base(utils::Hash(TypeInfo::Of().full_hashcode, address_space, subtype, access), type::Flags{}), subtype_(subtype), address_space_(address_space), access_(access) { TINT_ASSERT(Type, !subtype->Is()); - TINT_ASSERT(Type, access != ast::Access::kUndefined); + TINT_ASSERT(Type, access != type::Access::kUndefined); } bool Pointer::Equals(const UniqueNode& other) const { diff --git a/src/tint/type/pointer.h b/src/tint/type/pointer.h index cca919d538..61eab7676c 100644 --- a/src/tint/type/pointer.h +++ b/src/tint/type/pointer.h @@ -17,7 +17,7 @@ #include -#include "src/tint/ast/access.h" +#include "src/tint/type/access.h" #include "src/tint/type/address_space.h" #include "src/tint/type/type.h" @@ -30,7 +30,7 @@ class Pointer final : public Castable { /// @param subtype the pointee type /// @param address_space the address space of the pointer /// @param access the resolved access control of the reference - Pointer(const Type* subtype, type::AddressSpace address_space, ast::Access access); + Pointer(const Type* subtype, type::AddressSpace address_space, type::Access access); /// Destructor ~Pointer() override; @@ -46,7 +46,7 @@ class Pointer final : public Castable { type::AddressSpace AddressSpace() const { return address_space_; } /// @returns the access control of the reference - ast::Access Access() const { return access_; } + type::Access Access() const { return access_; } /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be @@ -60,7 +60,7 @@ class Pointer final : public Castable { private: Type const* const subtype_; type::AddressSpace const address_space_; - ast::Access const access_; + type::Access const access_; }; } // namespace tint::type diff --git a/src/tint/type/pointer_test.cc b/src/tint/type/pointer_test.cc index ddbbbe7d23..aa8d14e829 100644 --- a/src/tint/type/pointer_test.cc +++ b/src/tint/type/pointer_test.cc @@ -21,15 +21,15 @@ namespace { using PointerTest = TestHelper; TEST_F(PointerTest, Creation) { - auto* a = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = create(create(), AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), AddressSpace::kStorage, ast::Access::kRead); + auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* c = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* d = create(create(), AddressSpace::kPrivate, type::Access::kReadWrite); + auto* e = create(create(), AddressSpace::kStorage, type::Access::kRead); EXPECT_TRUE(a->StoreType()->Is()); EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage); - EXPECT_EQ(a->Access(), ast::Access::kReadWrite); + EXPECT_EQ(a->Access(), type::Access::kReadWrite); EXPECT_EQ(a, b); EXPECT_NE(a, c); @@ -38,18 +38,18 @@ TEST_F(PointerTest, Creation) { } TEST_F(PointerTest, Hash) { - auto* a = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); + auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); EXPECT_EQ(a->unique_hash, b->unique_hash); } TEST_F(PointerTest, Equals) { - auto* a = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = create(create(), AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), AddressSpace::kStorage, ast::Access::kRead); + auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* c = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* d = create(create(), AddressSpace::kPrivate, type::Access::kReadWrite); + auto* e = create(create(), AddressSpace::kStorage, type::Access::kRead); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); @@ -59,17 +59,17 @@ TEST_F(PointerTest, Equals) { } TEST_F(PointerTest, FriendlyName) { - auto* r = create(create(), AddressSpace::kNone, ast::Access::kRead); + auto* r = create(create(), AddressSpace::kNone, type::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); } TEST_F(PointerTest, FriendlyNameWithAddressSpace) { - auto* r = create(create(), AddressSpace::kWorkgroup, ast::Access::kRead); + auto* r = create(create(), AddressSpace::kWorkgroup, type::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); } TEST_F(PointerTest, Clone) { - auto* a = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); + auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); type::Manager mgr; type::CloneContext ctx{{nullptr}, {nullptr, &mgr}}; @@ -77,7 +77,7 @@ TEST_F(PointerTest, Clone) { auto* ptr = a->Clone(ctx); EXPECT_TRUE(ptr->StoreType()->Is()); EXPECT_EQ(ptr->AddressSpace(), AddressSpace::kStorage); - EXPECT_EQ(ptr->Access(), ast::Access::kReadWrite); + EXPECT_EQ(ptr->Access(), type::Access::kReadWrite); } } // namespace diff --git a/src/tint/type/reference.cc b/src/tint/type/reference.cc index 8735303739..090d8d71c5 100644 --- a/src/tint/type/reference.cc +++ b/src/tint/type/reference.cc @@ -21,14 +21,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Reference); namespace tint::type { -Reference::Reference(const Type* subtype, type::AddressSpace address_space, ast::Access access) +Reference::Reference(const Type* subtype, type::AddressSpace address_space, type::Access access) : Base(utils::Hash(TypeInfo::Of().full_hashcode, address_space, subtype, access), type::Flags{}), subtype_(subtype), address_space_(address_space), access_(access) { TINT_ASSERT(Type, !subtype->Is()); - TINT_ASSERT(Type, access != ast::Access::kUndefined); + TINT_ASSERT(Type, access != type::Access::kUndefined); } bool Reference::Equals(const UniqueNode& other) const { diff --git a/src/tint/type/reference.h b/src/tint/type/reference.h index 1bb1b86943..1999880570 100644 --- a/src/tint/type/reference.h +++ b/src/tint/type/reference.h @@ -17,7 +17,7 @@ #include -#include "src/tint/ast/access.h" +#include "src/tint/type/access.h" #include "src/tint/type/address_space.h" #include "src/tint/type/type.h" @@ -30,7 +30,7 @@ class Reference final : public Castable { /// @param subtype the pointee type /// @param address_space the address space of the reference /// @param access the resolved access control of the reference - Reference(const Type* subtype, type::AddressSpace address_space, ast::Access access); + Reference(const Type* subtype, type::AddressSpace address_space, type::Access access); /// Destructor ~Reference() override; @@ -46,7 +46,7 @@ class Reference final : public Castable { type::AddressSpace AddressSpace() const { return address_space_; } /// @returns the resolved access control of the reference. - ast::Access Access() const { return access_; } + type::Access Access() const { return access_; } /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be @@ -60,7 +60,7 @@ class Reference final : public Castable { private: Type const* const subtype_; type::AddressSpace const address_space_; - ast::Access const access_; + type::Access const access_; }; } // namespace tint::type diff --git a/src/tint/type/reference_test.cc b/src/tint/type/reference_test.cc index 2a2fab0923..8b3ae183ed 100644 --- a/src/tint/type/reference_test.cc +++ b/src/tint/type/reference_test.cc @@ -21,15 +21,15 @@ namespace { using ReferenceTest = TestHelper; TEST_F(ReferenceTest, Creation) { - auto* a = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = create(create(), AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), AddressSpace::kStorage, ast::Access::kRead); + auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* c = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* d = create(create(), AddressSpace::kPrivate, type::Access::kReadWrite); + auto* e = create(create(), AddressSpace::kStorage, type::Access::kRead); EXPECT_TRUE(a->StoreType()->Is()); EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage); - EXPECT_EQ(a->Access(), ast::Access::kReadWrite); + EXPECT_EQ(a->Access(), type::Access::kReadWrite); EXPECT_EQ(a, b); EXPECT_NE(a, c); @@ -38,18 +38,18 @@ TEST_F(ReferenceTest, Creation) { } TEST_F(ReferenceTest, Hash) { - auto* a = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); + auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); EXPECT_EQ(a->unique_hash, b->unique_hash); } TEST_F(ReferenceTest, Equals) { - auto* a = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = create(create(), AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), AddressSpace::kStorage, ast::Access::kRead); + auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* c = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* d = create(create(), AddressSpace::kPrivate, type::Access::kReadWrite); + auto* e = create(create(), AddressSpace::kStorage, type::Access::kRead); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); @@ -59,17 +59,17 @@ TEST_F(ReferenceTest, Equals) { } TEST_F(ReferenceTest, FriendlyName) { - auto* r = create(create(), AddressSpace::kNone, ast::Access::kRead); + auto* r = create(create(), AddressSpace::kNone, type::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); } TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) { - auto* r = create(create(), AddressSpace::kWorkgroup, ast::Access::kRead); + auto* r = create(create(), AddressSpace::kWorkgroup, type::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); } TEST_F(ReferenceTest, Clone) { - auto* a = create(create(), AddressSpace::kStorage, ast::Access::kReadWrite); + auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); type::Manager mgr; type::CloneContext ctx{{nullptr}, {nullptr, &mgr}}; @@ -77,7 +77,7 @@ TEST_F(ReferenceTest, Clone) { auto* ref = a->Clone(ctx); EXPECT_TRUE(ref->StoreType()->Is()); EXPECT_EQ(ref->AddressSpace(), AddressSpace::kStorage); - EXPECT_EQ(ref->Access(), ast::Access::kReadWrite); + EXPECT_EQ(ref->Access(), type::Access::kReadWrite); } } // namespace diff --git a/src/tint/type/storage_texture.cc b/src/tint/type/storage_texture.cc index 3742681fa0..629546f157 100644 --- a/src/tint/type/storage_texture.cc +++ b/src/tint/type/storage_texture.cc @@ -23,7 +23,7 @@ namespace tint::type { StorageTexture::StorageTexture(TextureDimension dim, ast::TexelFormat format, - ast::Access access, + type::Access access, Type* subtype) : Base(utils::Hash(TypeInfo::Of().full_hashcode, dim, format, access), dim), texel_format_(format), diff --git a/src/tint/type/storage_texture.h b/src/tint/type/storage_texture.h index 5c07bf9e4e..3ecb483c92 100644 --- a/src/tint/type/storage_texture.h +++ b/src/tint/type/storage_texture.h @@ -17,8 +17,8 @@ #include -#include "src/tint/ast/access.h" #include "src/tint/ast/storage_texture.h" +#include "src/tint/type/access.h" #include "src/tint/type/texture.h" #include "src/tint/type/texture_dimension.h" @@ -39,7 +39,7 @@ class StorageTexture final : public Castable { /// @param subtype the storage subtype. Use SubtypeFor() to calculate this. StorageTexture(TextureDimension dim, ast::TexelFormat format, - ast::Access access, + type::Access access, Type* subtype); /// Destructor @@ -56,7 +56,7 @@ class StorageTexture final : public Castable { ast::TexelFormat texel_format() const { return texel_format_; } /// @returns the access control - ast::Access access() const { return access_; } + type::Access access() const { return access_; } /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be @@ -74,7 +74,7 @@ class StorageTexture final : public Castable { private: ast::TexelFormat const texel_format_; - ast::Access const access_; + type::Access const access_; Type* const subtype_; }; diff --git a/src/tint/type/storage_texture_test.cc b/src/tint/type/storage_texture_test.cc index 96d5d195d7..b9ce9d629d 100644 --- a/src/tint/type/storage_texture_test.cc +++ b/src/tint/type/storage_texture_test.cc @@ -24,7 +24,7 @@ namespace tint::type { namespace { struct StorageTextureTest : public TestHelper { - StorageTexture* Create(TextureDimension dims, ast::TexelFormat fmt, ast::Access access) { + StorageTexture* Create(TextureDimension dims, ast::TexelFormat fmt, type::Access access) { auto* subtype = StorageTexture::SubtypeFor(fmt, Types()); return create(dims, fmt, access, subtype); } @@ -32,13 +32,14 @@ struct StorageTextureTest : public TestHelper { TEST_F(StorageTextureTest, Creation) { auto* a = - Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); auto* b = - Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); auto* c = - Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); - auto* d = Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, ast::Access::kReadWrite); - auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead); + Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); + auto* d = + Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, type::Access::kReadWrite); + auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kRead); EXPECT_TRUE(a->type()->Is()); EXPECT_EQ(a->dim(), TextureDimension::kCube); @@ -51,22 +52,23 @@ TEST_F(StorageTextureTest, Creation) { TEST_F(StorageTextureTest, Hash) { auto* a = - Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); auto* b = - Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); EXPECT_EQ(a->unique_hash, b->unique_hash); } TEST_F(StorageTextureTest, Equals) { auto* a = - Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); auto* b = - Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); auto* c = - Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); - auto* d = Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, ast::Access::kReadWrite); - auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead); + Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); + auto* d = + Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, type::Access::kReadWrite); + auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kRead); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); @@ -76,26 +78,26 @@ TEST_F(StorageTextureTest, Equals) { } TEST_F(StorageTextureTest, Dim) { - auto* s = - Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + auto* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, + type::Access::kReadWrite); EXPECT_EQ(s->dim(), TextureDimension::k2dArray); } TEST_F(StorageTextureTest, Format) { - auto* s = - Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + auto* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, + type::Access::kReadWrite); EXPECT_EQ(s->texel_format(), ast::TexelFormat::kRgba32Float); } TEST_F(StorageTextureTest, FriendlyName) { - auto* s = - Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + auto* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, + type::Access::kReadWrite); EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array"); } TEST_F(StorageTextureTest, F32) { - Type* s = - Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + Type* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, + type::Access::kReadWrite); auto program = Build(); @@ -108,7 +110,7 @@ TEST_F(StorageTextureTest, F32) { TEST_F(StorageTextureTest, U32) { auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types()); Type* s = create(TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint, - ast::Access::kReadWrite, subtype); + type::Access::kReadWrite, subtype); auto program = Build(); @@ -121,7 +123,7 @@ TEST_F(StorageTextureTest, U32) { TEST_F(StorageTextureTest, I32) { auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types()); Type* s = create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint, - ast::Access::kReadWrite, subtype); + type::Access::kReadWrite, subtype); auto program = Build(); @@ -133,7 +135,7 @@ TEST_F(StorageTextureTest, I32) { TEST_F(StorageTextureTest, Clone) { auto* a = - Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite); + Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite); type::Manager mgr; type::CloneContext ctx{{nullptr}, {nullptr, &mgr}}; diff --git a/src/tint/type/type_test.cc b/src/tint/type/type_test.cc index 8c7e8e052a..62ec7061ff 100644 --- a/src/tint/type/type_test.cc +++ b/src/tint/type/type_test.cc @@ -44,7 +44,7 @@ struct TypeTest : public TestHelper { const Matrix* mat4x3_f16 = create(vec3_f16, 4u); const Matrix* mat4x3_af = create(vec3_af, 4u); const Reference* ref_u32 = - create(u32, AddressSpace::kPrivate, ast::Access::kReadWrite); + create(u32, AddressSpace::kPrivate, type::Access::kReadWrite); const Struct* str_f32 = create(Source{}, Sym("str_f32"), utils::Vector{ diff --git a/src/tint/writer/append_vector.cc b/src/tint/writer/append_vector.cc index 658a6d2ebf..ab0ab707c7 100644 --- a/src/tint/writer/append_vector.cc +++ b/src/tint/writer/append_vector.cc @@ -137,7 +137,7 @@ const sem::Call* AppendVector(ProgramBuilder* b, auto* scalar_cast_target = b->create( packed_el_sem_ty, b->create(nullptr, 0u, scalar_sem->Type()->UnwrapRef(), - type::AddressSpace::kNone, ast::Access::kUndefined), + type::AddressSpace::kNone, type::Access::kUndefined), sem::EvaluationStage::kRuntime); auto* scalar_cast_sem = b->create( scalar_cast_ast, scalar_cast_target, sem::EvaluationStage::kRuntime, @@ -158,7 +158,7 @@ const sem::Call* AppendVector(ProgramBuilder* b, [&](const tint::sem::Expression* arg, size_t i) -> const sem::Parameter* { return b->create( nullptr, static_cast(i), arg->Type()->UnwrapRef(), - type::AddressSpace::kNone, ast::Access::kUndefined); + type::AddressSpace::kNone, type::Access::kUndefined); }), sem::EvaluationStage::kRuntime); auto* initializer_sem = diff --git a/src/tint/writer/flatten_bindings_test.cc b/src/tint/writer/flatten_bindings_test.cc index 7c67c47d59..dc883d87e0 100644 --- a/src/tint/writer/flatten_bindings_test.cc +++ b/src/tint/writer/flatten_bindings_test.cc @@ -87,7 +87,7 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) { const size_t num_buffers = 3; b.GlobalVar("buffer1", b.ty.i32(), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); b.GlobalVar("buffer2", b.ty.i32(), type::AddressSpace::kStorage, b.Group(1_a), b.Binding(1_a)); - b.GlobalVar("buffer3", b.ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead, + b.GlobalVar("buffer3", b.ty.i32(), type::AddressSpace::kStorage, type::Access::kRead, b.Group(2_a), b.Binding(2_a)); const size_t num_samplers = 2; @@ -102,7 +102,7 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) { b.Group(6_a), b.Binding(6_a)); b.GlobalVar("texture3", b.ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, - ast::Access::kWrite), + type::Access::kWrite), b.Group(7_a), b.Binding(7_a)); b.GlobalVar("texture4", b.ty.depth_texture(type::TextureDimension::k2d), b.Group(8_a), b.Binding(8_a)); diff --git a/src/tint/writer/glsl/generator.h b/src/tint/writer/glsl/generator.h index d48b0bc7d9..60d5aa17c3 100644 --- a/src/tint/writer/glsl/generator.h +++ b/src/tint/writer/glsl/generator.h @@ -21,10 +21,10 @@ #include #include -#include "src/tint/ast/access.h" #include "src/tint/ast/pipeline_stage.h" #include "src/tint/sem/binding_point.h" #include "src/tint/sem/sampler_texture_pair.h" +#include "src/tint/type/access.h" #include "src/tint/writer/glsl/version.h" #include "src/tint/writer/text.h" @@ -61,7 +61,7 @@ struct Options { /// A map of old binding point to new access control for the BindingRemapper /// transform - std::unordered_map access_controls; + std::unordered_map access_controls; /// If true, then validation will be disabled for binding point collisions /// generated by the BindingRemapper transform diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index c3872f0dab..4c16755cda 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -374,7 +374,7 @@ bool GeneratorImpl::EmitBitcast(std::ostream& out, const ast::BitcastExpression* dst_type->is_float_scalar_or_vector()) { out << "uintBitsToFloat"; } else { - if (!EmitType(out, dst_type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, dst_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } } @@ -437,12 +437,12 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres auto* uint_type = BoolTypeToUint(bool_type); // Cast result to bool scalar or vector type. - if (!EmitType(out, bool_type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, bool_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } ScopedParen outerCastParen(out); // Cast LHS to uint scalar or vector type. - if (!EmitType(out, uint_type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, uint_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } { @@ -462,7 +462,7 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres return false; } // Cast RHS to uint scalar or vector type. - if (!EmitType(out, uint_type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, uint_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } { @@ -490,20 +490,20 @@ bool GeneratorImpl::EmitFloatModulo(std::ostream& out, const ast::BinaryExpressi { auto decl = line(&b); if (!EmitTypeAndName(decl, ret_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, fn_name)) { + type::Access::kUndefined, fn_name)) { return ""; } { ScopedParen sp(decl); const auto* ty = TypeOf(expr->lhs)->UnwrapRef(); if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone, - ast::Access::kUndefined, "lhs")) { + type::Access::kUndefined, "lhs")) { return ""; } decl << ", "; ty = TypeOf(expr->rhs)->UnwrapRef(); if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone, - ast::Access::kUndefined, "rhs")) { + type::Access::kUndefined, "rhs")) { return ""; } } @@ -828,7 +828,7 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out, bool GeneratorImpl::EmitTypeConversion(std::ostream& out, const sem::Call* call, const sem::TypeConversion* conv) { - if (!EmitType(out, conv->Target(), type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, conv->Target(), type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -851,7 +851,7 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out, return EmitZeroValue(out, type); } - if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -922,7 +922,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, { auto pre = line(); if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kNone, - ast::Access::kUndefined, result)) { + type::Access::kUndefined, result)) { return false; } pre << ";"; @@ -1060,7 +1060,7 @@ bool GeneratorImpl::EmitCountOneBitsCall(std::ostream& out, const ast::CallExpre // GLSL's bitCount returns an integer type, so cast it to the appropriate // unsigned type. if (!EmitType(out, TypeOf(expr)->UnwrapRef(), type::AddressSpace::kNone, - ast::Access::kReadWrite, "")) { + type::Access::kReadWrite, "")) { return false; } out << "(bitCount("; @@ -1131,7 +1131,7 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out, std::string v; { std::stringstream s; - if (!EmitType(s, vec_ty->type(), type::AddressSpace::kNone, ast::Access::kRead, + if (!EmitType(s, vec_ty->type(), type::AddressSpace::kNone, type::Access::kRead, "")) { return ""; } @@ -1139,16 +1139,16 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out, } { // (u)int tint_int_dot([i|u]vecN a, [i|u]vecN b) { auto l = line(&b); - if (!EmitType(l, vec_ty->type(), type::AddressSpace::kNone, ast::Access::kRead, + if (!EmitType(l, vec_ty->type(), type::AddressSpace::kNone, type::Access::kRead, "")) { return ""; } l << " " << fn_name << "("; - if (!EmitType(l, vec_ty, type::AddressSpace::kNone, ast::Access::kRead, "")) { + if (!EmitType(l, vec_ty, type::AddressSpace::kNone, type::Access::kRead, "")) { return ""; } l << " a, "; - if (!EmitType(l, vec_ty, type::AddressSpace::kNone, ast::Access::kRead, "")) { + if (!EmitType(l, vec_ty, type::AddressSpace::kNone, type::Access::kRead, "")) { return ""; } l << " b) {"; @@ -1200,7 +1200,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out, { auto l = line(b); if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kNone, - ast::Access::kUndefined, "")) { + type::Access::kUndefined, "")) { return false; } l << " result;"; @@ -1226,7 +1226,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out, { auto l = line(b); if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kNone, - ast::Access::kUndefined, "")) { + type::Access::kUndefined, "")) { return false; } l << " result;"; @@ -1883,7 +1883,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { { auto out = line(); auto name = builder_.Symbols().NameFor(func->symbol); - if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kNone, ast::Access::kReadWrite, + if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } @@ -2337,7 +2337,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const return true; }, [&](const type::Vector* v) { - if (!EmitType(out, v, type::AddressSpace::kNone, ast::Access::kUndefined, "")) { + if (!EmitType(out, v, type::AddressSpace::kNone, type::Access::kUndefined, "")) { return false; } @@ -2358,7 +2358,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const return true; }, [&](const type::Matrix* m) { - if (!EmitType(out, m, type::AddressSpace::kNone, ast::Access::kUndefined, "")) { + if (!EmitType(out, m, type::AddressSpace::kNone, type::Access::kUndefined, "")) { return false; } @@ -2375,7 +2375,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const return true; }, [&](const type::Array* a) { - if (!EmitType(out, a, type::AddressSpace::kNone, ast::Access::kUndefined, "")) { + if (!EmitType(out, a, type::AddressSpace::kNone, type::Access::kUndefined, "")) { return false; } @@ -2467,7 +2467,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { } else if (type->Is()) { out << "0u"; } else if (auto* vec = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -2480,7 +2480,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { } } } else if (auto* mat = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -2493,7 +2493,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { } } } else if (auto* str = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kUndefined, "")) { + if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kUndefined, "")) { return false; } bool first = true; @@ -2507,7 +2507,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { EmitZeroValue(out, member->Type()); } } else if (auto* arr = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kUndefined, "")) { + if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kUndefined, "")) { return false; } ScopedParen sp(out); @@ -2833,7 +2833,7 @@ bool GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) { bool GeneratorImpl::EmitType(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const std::string& name, bool* name_printed /* = nullptr */) { if (name_printed) { @@ -2930,7 +2930,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, out << "highp "; - if (storage && storage->access() != ast::Access::kRead) { + if (storage && storage->access() != type::Access::kRead) { out << "writeonly "; } auto* subtype = sampled ? sampled->type() @@ -3014,7 +3014,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, bool GeneratorImpl::EmitTypeAndName(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const std::string& name) { bool printed_name = false; if (!EmitType(out, type, address_space, access, name, &printed_name)) { @@ -3050,7 +3050,7 @@ bool GeneratorImpl::EmitStructMembers(TextBuffer* b, const sem::Struct* str) { auto out = line(b); - if (!EmitTypeAndName(out, ty, type::AddressSpace::kNone, ast::Access::kReadWrite, name)) { + if (!EmitTypeAndName(out, ty, type::AddressSpace::kNone, type::Access::kReadWrite, name)) { return false; } out << ";"; @@ -3118,7 +3118,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { auto out = line(); // TODO(senorblanco): handle const - if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, ast::Access::kUndefined, + if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined, builder_.Symbols().NameFor(let->symbol))) { return false; } @@ -3140,7 +3140,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) { auto out = line(); out << "const "; - if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, ast::Access::kUndefined, + if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined, builder_.Symbols().NameFor(var->symbol))) { return false; } @@ -3168,7 +3168,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, { auto decl = line(&b); if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kNone, - ast::Access::kUndefined, fn_name)) { + type::Access::kUndefined, fn_name)) { return ""; } { @@ -3184,7 +3184,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, ty = ptr->StoreType(); } if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone, - ast::Access::kUndefined, param_name)) { + type::Access::kUndefined, param_name)) { return ""; } parameter_names.emplace_back(std::move(param_name)); diff --git a/src/tint/writer/glsl/generator_impl.h b/src/tint/writer/glsl/generator_impl.h index d38f845a37..7a623ed89b 100644 --- a/src/tint/writer/glsl/generator_impl.h +++ b/src/tint/writer/glsl/generator_impl.h @@ -414,7 +414,7 @@ class GeneratorImpl : public TextGenerator { bool EmitType(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const std::string& name, bool* name_printed = nullptr); /// Handles generating type and name @@ -427,7 +427,7 @@ class GeneratorImpl : public TextGenerator { bool EmitTypeAndName(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const std::string& name); /// Handles generating a structure declaration. If the structure has already been emitted, then /// this function will simply return `true` without emitting anything. diff --git a/src/tint/writer/glsl/generator_impl_function_test.cc b/src/tint/writer/glsl/generator_impl_function_test.cc index 352689bb8d..3c3dd53e65 100644 --- a/src/tint/writer/glsl/generator_impl_function_test.cc +++ b/src/tint/writer/glsl/generator_impl_function_test.cc @@ -442,7 +442,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -489,7 +489,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -537,7 +537,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -582,7 +582,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -668,7 +668,7 @@ void frag_main() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{Param("param", ty.f32())}, ty.f32(), @@ -879,8 +879,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(0_a)); + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, + Binding(0_a), Group(0_a)); { auto* var = Var("v", ty.f32(), MemberAccessor("data", "d")); diff --git a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc index 08f93ccb4e..e062630c0a 100644 --- a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc @@ -91,7 +91,7 @@ class GlslGeneratorImplTest_MemberAccessorBase : public BASE { auto* s = b.Structure("Data", members); - b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(1_a), b.Binding(0_a)); } diff --git a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc index a6ed6f68a0..3bb3e136e9 100644 --- a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc @@ -26,7 +26,7 @@ using GlslSanitizerTest = TestHelper; TEST_F(GlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -66,7 +66,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(0, "z", ty.f32()), Member(4, "a", ty.array(4)), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -105,7 +105,7 @@ void main() { TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf("b")); diff --git a/src/tint/writer/glsl/generator_impl_type_test.cc b/src/tint/writer/glsl/generator_impl_type_test.cc index 36eb31b448..45e4f09cf2 100644 --- a/src/tint/writer/glsl/generator_impl_type_test.cc +++ b/src/tint/writer/glsl/generator_impl_type_test.cc @@ -40,7 +40,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) { std::stringstream out; ASSERT_TRUE(gen.EmitType(out, program->TypeOf(arr), type::AddressSpace::kNone, - ast::Access::kReadWrite, "ary")) + type::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[4]"); } @@ -53,7 +53,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) { std::stringstream out; ASSERT_TRUE(gen.EmitType(out, program->TypeOf(arr), type::AddressSpace::kNone, - ast::Access::kReadWrite, "ary")) + type::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[5][4]"); } @@ -66,7 +66,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) { std::stringstream out; ASSERT_TRUE(gen.EmitType(out, program->TypeOf(arr), type::AddressSpace::kNone, - ast::Access::kReadWrite, "ary")) + type::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[6][5][4]"); } @@ -79,7 +79,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array_WithoutName) { std::stringstream out; ASSERT_TRUE(gen.EmitType(out, program->TypeOf(arr), type::AddressSpace::kNone, - ast::Access::kReadWrite, "")) + type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool[4]"); } @@ -90,7 +90,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, bool_, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, bool_, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool"); } @@ -101,7 +101,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, f32, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, f32, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float"); } @@ -114,7 +114,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, f16, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, f16, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float16_t"); } @@ -125,7 +125,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, i32, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, i32, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "int"); } @@ -138,7 +138,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, mat2x3, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, mat2x3, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "mat2x3"); } @@ -153,7 +153,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, mat2x3, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, mat2x3, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "f16mat2x3"); } @@ -189,7 +189,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct) { auto* sem_s = program->TypeOf(s)->As(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, sem_s, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, sem_s, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "S"); } @@ -237,7 +237,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, u32, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, u32, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "uint"); } @@ -249,7 +249,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, vec3, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, vec3, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "vec3"); } @@ -263,7 +263,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, vec3, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, vec3, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "f16vec3"); } @@ -274,7 +274,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, void_, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, void_, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "void"); } @@ -285,7 +285,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSampler) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_FALSE(gen.EmitType(out, sampler, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_FALSE( + gen.EmitType(out, sampler, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); } @@ -295,7 +296,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_FALSE(gen.EmitType(out, sampler, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_FALSE( + gen.EmitType(out, sampler, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); } @@ -501,7 +503,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, s, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, s, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "highp sampler2DMS"); } @@ -518,7 +520,7 @@ using GlslStorageTexturesTest = TestParamHelper; TEST_P(GlslStorageTexturesTest, Emit) { auto params = GetParam(); - auto* t = ty.storage_texture(params.dim, params.imgfmt, ast::Access::kWrite); + auto* t = ty.storage_texture(params.dim, params.imgfmt, type::Access::kWrite); GlobalVar("tex", t, Binding(1_a), Group(2_a)); diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index a033ff60f9..d1559a241b 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -376,7 +376,7 @@ bool GeneratorImpl::EmitDynamicVectorAssignment(const ast::AssignmentStatement* std::string fn; { std::ostringstream ss; - if (!EmitType(ss, vec, tint::type::AddressSpace::kUndefined, ast::Access::kUndefined, + if (!EmitType(ss, vec, tint::type::AddressSpace::kUndefined, type::Access::kUndefined, "")) { return ""; } @@ -385,13 +385,13 @@ bool GeneratorImpl::EmitDynamicVectorAssignment(const ast::AssignmentStatement* { auto out = line(&helpers_); out << "void " << fn << "(inout "; - if (!EmitTypeAndName(out, vec, type::AddressSpace::kUndefined, ast::Access::kUndefined, + if (!EmitTypeAndName(out, vec, type::AddressSpace::kUndefined, type::Access::kUndefined, "vec")) { return ""; } out << ", int idx, "; if (!EmitTypeAndName(out, vec->type(), type::AddressSpace::kUndefined, - ast::Access::kUndefined, "val")) { + type::Access::kUndefined, "val")) { return ""; } out << ") {"; @@ -450,7 +450,7 @@ bool GeneratorImpl::EmitDynamicMatrixVectorAssignment(const ast::AssignmentState std::string fn; { std::ostringstream ss; - if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, ast::Access::kUndefined, + if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, type::Access::kUndefined, "")) { return ""; } @@ -459,13 +459,13 @@ bool GeneratorImpl::EmitDynamicMatrixVectorAssignment(const ast::AssignmentState { auto out = line(&helpers_); out << "void " << fn << "(inout "; - if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, ast::Access::kUndefined, + if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, type::Access::kUndefined, "mat")) { return ""; } out << ", int col, "; if (!EmitTypeAndName(out, mat->ColumnType(), type::AddressSpace::kUndefined, - ast::Access::kUndefined, "val")) { + type::Access::kUndefined, "val")) { return ""; } out << ") {"; @@ -519,7 +519,7 @@ bool GeneratorImpl::EmitDynamicMatrixScalarAssignment(const ast::AssignmentState std::string fn; { std::ostringstream ss; - if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, ast::Access::kUndefined, + if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, type::Access::kUndefined, "")) { return ""; } @@ -528,13 +528,13 @@ bool GeneratorImpl::EmitDynamicMatrixScalarAssignment(const ast::AssignmentState { auto out = line(&helpers_); out << "void " << fn << "(inout "; - if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, ast::Access::kUndefined, + if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, type::Access::kUndefined, "mat")) { return ""; } out << ", int col, int row, "; if (!EmitTypeAndName(out, mat->type(), type::AddressSpace::kUndefined, - ast::Access::kUndefined, "val")) { + type::Access::kUndefined, "val")) { return ""; } out << ") {"; @@ -638,7 +638,7 @@ bool GeneratorImpl::EmitBitcast(std::ostream& out, const ast::BitcastExpression* } out << "as"; - if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } out << "("; @@ -1026,7 +1026,7 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out, bool GeneratorImpl::EmitTypeConversion(std::ostream& out, const sem::Call* call, const sem::TypeConversion* conv) { - if (!EmitType(out, conv->Target(), type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, conv->Target(), type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } out << "("; @@ -1071,7 +1071,7 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out, if (brackets) { out << "{"; } else { - if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } out << "("; @@ -1588,12 +1588,12 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( auto rmw = [&](const char* hlsl) -> bool { { auto fn = line(&buf); - if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kNone, ast::Access::kUndefined, + if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kNone, type::Access::kUndefined, name)) { return false; } fn << "(RWByteAddressBuffer buffer, uint offset, "; - if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kNone, ast::Access::kUndefined, + if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kNone, type::Access::kUndefined, "value")) { return false; } @@ -1609,7 +1609,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto l = line(&buf); - if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kNone, ast::Access::kUndefined, + if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kNone, type::Access::kUndefined, "original_value")) { return false; } @@ -1659,7 +1659,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto fn = line(&buf); if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, name)) { + type::Access::kUndefined, name)) { return false; } fn << "(RWByteAddressBuffer buffer, uint offset) {"; @@ -1675,7 +1675,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto l = line(&buf); if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, "value")) { + type::Access::kUndefined, "value")) { return false; } l << " = 0;"; @@ -1693,7 +1693,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( auto fn = line(&buf); fn << "void " << name << "(RWByteAddressBuffer buffer, uint offset, "; if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, "value")) { + type::Access::kUndefined, "value")) { return false; } fn << ") {"; @@ -1709,7 +1709,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto l = line(&buf); if (!EmitTypeAndName(l, value_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, "ignored")) { + type::Access::kUndefined, "ignored")) { return false; } l << ";"; @@ -1724,17 +1724,17 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto fn = line(&buf); if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, name)) { + type::Access::kUndefined, name)) { return false; } fn << "(RWByteAddressBuffer buffer, uint offset, "; if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, "compare")) { + type::Access::kUndefined, "compare")) { return false; } fn << ", "; if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, "value")) { + type::Access::kUndefined, "value")) { return false; } fn << ") {"; @@ -1750,7 +1750,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { // T result = {0}; auto l = line(&buf); if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, "result")) { + type::Access::kUndefined, "result")) { return false; } l << "="; @@ -1785,7 +1785,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, if (!builtin->ReturnType()->Is()) { auto pre = line(); if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kNone, - ast::Access::kUndefined, result)) { + type::Access::kUndefined, result)) { return false; } pre << " = "; @@ -1849,7 +1849,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, auto pre = line(); auto* value_ty = builtin->Parameters()[1]->Type()->UnwrapRef(); if (!EmitTypeAndName(pre, value_ty, type::AddressSpace::kNone, - ast::Access::kUndefined, result)) { + type::Access::kUndefined, result)) { return false; } pre << " = "; @@ -1887,7 +1887,8 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, { // T compare_value = ; auto pre = line(); if (!EmitTypeAndName(pre, TypeOf(compare_value)->UnwrapRef(), - type::AddressSpace::kNone, ast::Access::kUndefined, compare)) { + type::AddressSpace::kNone, type::Access::kUndefined, + compare)) { return false; } pre << " = "; @@ -1997,7 +1998,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out, { auto l = line(b); if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kNone, - ast::Access::kUndefined, "")) { + type::Access::kUndefined, "")) { return false; } l << " result;"; @@ -2039,7 +2040,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out, { auto l = line(b); if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kNone, - ast::Access::kUndefined, "")) { + type::Access::kUndefined, "")) { return false; } l << " result = {fract, int" << width << "(exp)};"; @@ -2076,7 +2077,7 @@ bool GeneratorImpl::EmitRadiansCall(std::ostream& out, // type after the call to `sign`. bool GeneratorImpl::EmitSignCall(std::ostream& out, const sem::Call* call, const sem::Builtin*) { auto* arg = call->Arguments()[0]; - if (!EmitType(out, arg->Type(), type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, arg->Type(), type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } out << "(sign("; @@ -2879,14 +2880,14 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { auto pre = line(); pre << "typedef "; if (!EmitTypeAndName(pre, sem->ReturnType(), type::AddressSpace::kNone, - ast::Access::kReadWrite, typedef_name)) { + type::Access::kReadWrite, typedef_name)) { return false; } pre << ";"; out << typedef_name; } else { if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kNone, - ast::Access::kReadWrite, "")) { + type::Access::kReadWrite, "")) { return false; } } @@ -2903,7 +2904,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { auto const* type = v->Type(); auto address_space = type::AddressSpace::kNone; - auto access = ast::Access::kUndefined; + auto access = type::Access::kUndefined; if (auto* ptr = type->As()) { type = ptr->StoreType(); @@ -2977,7 +2978,7 @@ bool GeneratorImpl::EmitFunctionBodyWithDiscard(const ast::Function* func) { { auto out = line(); if (!EmitTypeAndName(out, sem->ReturnType(), type::AddressSpace::kNone, - ast::Access::kReadWrite, name)) { + type::Access::kReadWrite, name)) { return false; } out << ";"; @@ -3062,7 +3063,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable } auto* global_sem = sem->As(); - out << RegisterAndSpace(sem->Access() == ast::Access::kRead ? 't' : 'u', + out << RegisterAndSpace(sem->Access() == type::Access::kRead ? 't' : 'u', global_sem->BindingPoint()) << ";"; @@ -3327,7 +3328,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, return true; } - if (!EmitType(out, v, type::AddressSpace::kNone, ast::Access::kUndefined, "")) { + if (!EmitType(out, v, type::AddressSpace::kNone, type::Access::kUndefined, "")) { return false; } @@ -3344,7 +3345,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, return true; }, [&](const type::Matrix* m) { - if (!EmitType(out, m, type::AddressSpace::kNone, ast::Access::kUndefined, "")) { + if (!EmitType(out, m, type::AddressSpace::kNone, type::Access::kUndefined, "")) { return false; } @@ -3363,7 +3364,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, [&](const type::Array* a) { if (constant->AllZero()) { out << "("; - if (!EmitType(out, a, type::AddressSpace::kNone, ast::Access::kUndefined, "")) { + if (!EmitType(out, a, type::AddressSpace::kNone, type::Access::kUndefined, "")) { return false; } out << ")0"; @@ -3503,7 +3504,7 @@ bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int val return true; }, [&](const type::Vector* vec) { - if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -3518,7 +3519,7 @@ bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int val return true; }, [&](const type::Matrix* mat) { - if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -3535,12 +3536,12 @@ bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int val [&](const sem::Struct*) { out << "("; TINT_DEFER(out << ")" << value); - return EmitType(out, type, type::AddressSpace::kNone, ast::Access::kUndefined, ""); + return EmitType(out, type, type::AddressSpace::kNone, type::Access::kUndefined, ""); }, [&](const type::Array*) { out << "("; TINT_DEFER(out << ")" << value); - return EmitType(out, type, type::AddressSpace::kNone, ast::Access::kUndefined, ""); + return EmitType(out, type, type::AddressSpace::kNone, type::Access::kUndefined, ""); }, [&](Default) { diagnostics_.add_error( @@ -3916,7 +3917,7 @@ bool GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) { bool GeneratorImpl::EmitType(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const std::string& name, bool* name_printed /* = nullptr */) { if (name_printed) { @@ -3924,7 +3925,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } switch (address_space) { case type::AddressSpace::kStorage: - if (access != ast::Access::kRead) { + if (access != type::Access::kRead) { out << "RW"; } out << "ByteAddressBuffer"; @@ -4046,7 +4047,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, auto* depth_ms = tex->As(); auto* sampled = tex->As(); - if (storage && storage->access() != ast::Access::kRead) { + if (storage && storage->access() != type::Access::kRead) { out << "RW"; } out << "Texture"; @@ -4143,7 +4144,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, bool GeneratorImpl::EmitTypeAndName(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const std::string& name) { bool name_printed = false; if (!EmitType(out, type, address_space, access, name, &name_printed)) { @@ -4225,7 +4226,7 @@ bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) { } out << pre; - if (!EmitTypeAndName(out, ty, type::AddressSpace::kNone, ast::Access::kReadWrite, + if (!EmitTypeAndName(out, ty, type::AddressSpace::kNone, type::Access::kReadWrite, mem_name)) { return false; } @@ -4295,7 +4296,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { auto out = line(); out << "const "; - if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, ast::Access::kUndefined, + if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined, builder_.Symbols().NameFor(let->symbol))) { return false; } @@ -4323,7 +4324,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, { auto decl = line(&b); if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kNone, - ast::Access::kUndefined, fn_name)) { + type::Access::kUndefined, fn_name)) { return ""; } { @@ -4339,7 +4340,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, ty = ptr->StoreType(); } if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone, - ast::Access::kUndefined, param_name)) { + type::Access::kUndefined, param_name)) { return ""; } parameter_names.emplace_back(std::move(param_name)); diff --git a/src/tint/writer/hlsl/generator_impl.h b/src/tint/writer/hlsl/generator_impl.h index 04e13a0c69..7b2d97fa35 100644 --- a/src/tint/writer/hlsl/generator_impl.h +++ b/src/tint/writer/hlsl/generator_impl.h @@ -414,7 +414,7 @@ class GeneratorImpl : public TextGenerator { bool EmitType(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const std::string& name, bool* name_printed = nullptr); /// Handles generating type and name @@ -427,7 +427,7 @@ class GeneratorImpl : public TextGenerator { bool EmitTypeAndName(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - ast::Access access, + type::Access access, const std::string& name); /// Handles generating a structure declaration. If the structure has already been emitted, then /// this function will simply return `true` without emitting anything. diff --git a/src/tint/writer/hlsl/generator_impl_function_test.cc b/src/tint/writer/hlsl/generator_impl_function_test.cc index 36051aee41..8e734ca85c 100644 --- a/src/tint/writer/hlsl/generator_impl_function_test.cc +++ b/src/tint/writer/hlsl/generator_impl_function_test.cc @@ -437,7 +437,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -470,7 +470,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -503,7 +503,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -534,7 +534,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -603,7 +603,7 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("sub_func", @@ -831,8 +831,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(0_a)); + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, + Binding(0_a), Group(0_a)); { auto* var = Var("v", ty.f32(), MemberAccessor("data", "d")); diff --git a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc index 3377035a99..bec778a947 100644 --- a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc @@ -93,7 +93,7 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE { ProgramBuilder& b = *this; auto* s = b.Structure("Data", members); - b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(1_a), b.Binding(0_a)); } @@ -101,7 +101,7 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE { ProgramBuilder& b = *this; auto* s = b.Structure("Data", members); - b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kUniform, ast::Access::kUndefined, + b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kUniform, type::Access::kUndefined, b.Group(1_a), b.Binding(1_a)); } diff --git a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc index e39ea02895..10c4147ffa 100644 --- a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc @@ -26,7 +26,7 @@ using HlslSanitizerTest = TestHelper; TEST_F(HlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -60,7 +60,7 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(0, "z", ty.f32()), Member(4, "a", ty.array(4)), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -92,7 +92,7 @@ void a_func() { TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf("b")); @@ -129,9 +129,9 @@ void a_func() { TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); - GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(2_a), + GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(2_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), diff --git a/src/tint/writer/hlsl/generator_impl_type_test.cc b/src/tint/writer/hlsl/generator_impl_type_test.cc index ec072292e2..606ffe4a0f 100644 --- a/src/tint/writer/hlsl/generator_impl_type_test.cc +++ b/src/tint/writer/hlsl/generator_impl_type_test.cc @@ -40,7 +40,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) { std::stringstream out; ASSERT_TRUE(gen.EmitType(out, program->TypeOf(arr), type::AddressSpace::kNone, - ast::Access::kReadWrite, "ary")) + type::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[4]"); } @@ -53,7 +53,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) { std::stringstream out; ASSERT_TRUE(gen.EmitType(out, program->TypeOf(arr), type::AddressSpace::kNone, - ast::Access::kReadWrite, "ary")) + type::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[5][4]"); } @@ -66,7 +66,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) { std::stringstream out; ASSERT_TRUE(gen.EmitType(out, program->TypeOf(arr), type::AddressSpace::kNone, - ast::Access::kReadWrite, "ary")) + type::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[6][5][4]"); } @@ -79,7 +79,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) { std::stringstream out; ASSERT_TRUE(gen.EmitType(out, program->TypeOf(arr), type::AddressSpace::kNone, - ast::Access::kReadWrite, "")) + type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool[4]"); } @@ -90,7 +90,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, bool_, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, bool_, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool"); } @@ -101,7 +101,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F16) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, f16, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, f16, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float16_t"); } @@ -112,7 +112,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, f32, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, f32, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float"); } @@ -123,7 +123,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, i32, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, i32, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "int"); } @@ -136,7 +136,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F16) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, mat2x3, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, mat2x3, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "matrix"); } @@ -149,7 +149,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, mat2x3, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, mat2x3, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float2x3"); } @@ -178,7 +178,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) { Member("a", ty.i32()), Member("b", ty.f32()), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(0_a), + GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -198,7 +198,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) { auto* sem_s = program->TypeOf(s)->As(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, sem_s, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, sem_s, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "S"); } @@ -245,7 +245,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, u32, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, u32, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "uint"); } @@ -257,7 +257,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, vec3, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, vec3, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float3"); } @@ -268,7 +268,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, void_, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, void_, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "void"); } @@ -279,7 +279,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSampler) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, sampler, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, sampler, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "SamplerState"); } @@ -290,7 +290,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, sampler, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, sampler, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "SamplerComparisonState"); } @@ -500,7 +500,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, s, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, s, type::AddressSpace::kNone, type::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "Texture2DMS"); } @@ -518,7 +518,7 @@ using HlslStorageTexturesTest = TestParamHelper; TEST_P(HlslStorageTexturesTest, Emit) { auto params = GetParam(); - auto* t = ty.storage_texture(params.dim, params.imgfmt, ast::Access::kWrite); + auto* t = ty.storage_texture(params.dim, params.imgfmt, type::Access::kWrite); GlobalVar("tex", t, utils::Vector{ diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index f27c45c98e..251483e1d1 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -2585,7 +2585,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, return true; }, [&](const type::Pointer* ptr) { - if (ptr->Access() == ast::Access::kRead) { + if (ptr->Access() == type::Access::kRead) { out << "const "; } if (!EmitAddressSpace(out, ptr->AddressSpace())) { @@ -2669,9 +2669,9 @@ bool GeneratorImpl::EmitType(std::ostream& out, } std::string access_str; - if (storage->access() == ast::Access::kRead) { + if (storage->access() == type::Access::kRead) { out << ", access::read"; - } else if (storage->access() == ast::Access::kWrite) { + } else if (storage->access() == type::Access::kWrite) { out << ", access::write"; } else { diagnostics_.add_error(diag::System::Writer, diff --git a/src/tint/writer/msl/generator_impl_function_test.cc b/src/tint/writer/msl/generator_impl_function_test.cc index c1b9b7af09..0b01e1c559 100644 --- a/src/tint/writer/msl/generator_impl_function_test.cc +++ b/src/tint/writer/msl/generator_impl_function_test.cc @@ -342,7 +342,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RW_StorageBu Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Group(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a), Binding(0_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -381,7 +381,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RO_StorageBu Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Group(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), Binding(0_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -467,7 +467,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RW Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Group(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a), Binding(0_a)); Func("sub_func", @@ -519,7 +519,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RO Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Group(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), Binding(0_a)); Func("sub_func", @@ -657,7 +657,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_ModuleV auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Group(0_a), + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a), Binding(0_a)); { diff --git a/src/tint/writer/msl/generator_impl_sanitizer_test.cc b/src/tint/writer/msl/generator_impl_sanitizer_test.cc index e749f1a126..1a0ce77567 100644 --- a/src/tint/writer/msl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/msl/generator_impl_sanitizer_test.cc @@ -28,7 +28,7 @@ using MslSanitizerTest = TestHelper; TEST_F(MslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -82,7 +82,7 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(0, "z", ty.f32()), Member(4, "a", ty.array(4)), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -135,7 +135,7 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) { TEST_F(MslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf("b")); @@ -192,9 +192,9 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) { TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(0_a)); - GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(2_a), + GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(2_a), Group(0_a)); Func("a_func", utils::Empty, ty.void_(), @@ -251,9 +251,9 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(29)]]) { TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniformMissingBinding) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(0_a)); - GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(2_a), + GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(2_a), Group(0_a)); Func("a_func", utils::Empty, ty.void_(), diff --git a/src/tint/writer/msl/generator_impl_type_test.cc b/src/tint/writer/msl/generator_impl_type_test.cc index 6ac4c84c41..274ff529c8 100644 --- a/src/tint/writer/msl/generator_impl_type_test.cc +++ b/src/tint/writer/msl/generator_impl_type_test.cc @@ -212,7 +212,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix_F16) { TEST_F(MslGeneratorImplTest, EmitType_Pointer) { auto* f32 = create(); - auto* p = create(f32, type::AddressSpace::kWorkgroup, ast::Access::kReadWrite); + auto* p = create(f32, type::AddressSpace::kWorkgroup, type::Access::kReadWrite); GeneratorImpl& gen = Build(); @@ -283,7 +283,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) { Member("z", ty.f32()), }); - GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -391,7 +391,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) { Member("e", ty.f32()), }); - GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -482,7 +482,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) { Member("f", array_z), }); - GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -565,7 +565,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) { Member("c", ty.i32()), }); - GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -626,7 +626,7 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) { Member("tint_pad_21", ty.f32()), }); - GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -684,7 +684,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) { Member("b", ty.f32()), }); - GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -847,7 +847,7 @@ using MslStorageTexturesTest = TestParamHelper; TEST_P(MslStorageTexturesTest, Emit) { auto params = GetParam(); - auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float, ast::Access::kWrite); + auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float, type::Access::kWrite); GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index d35a486053..43aa4d5a79 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -796,16 +796,16 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) { // type is a sem::Struct or a type::StorageTexture auto access = st ? st->access() : sem->Access(); switch (access) { - case ast::Access::kWrite: + case type::Access::kWrite: push_annot(spv::Op::OpDecorate, {Operand(var_id), U32Operand(SpvDecorationNonReadable)}); break; - case ast::Access::kRead: + case type::Access::kRead: push_annot(spv::Op::OpDecorate, {Operand(var_id), U32Operand(SpvDecorationNonWritable)}); break; - case ast::Access::kUndefined: - case ast::Access::kReadWrite: + case type::Access::kUndefined: + case type::Access::kReadWrite: break; } } @@ -1904,7 +1904,7 @@ uint32_t Builder::GenerateSplat(uint32_t scalar_id, const type::Type* vec_type) // Create a new vector to splat scalar into auto splat_vector = result_op(); auto* splat_vector_type = builder_.create( - vec_type, type::AddressSpace::kFunction, ast::Access::kReadWrite); + vec_type, type::AddressSpace::kFunction, type::Access::kReadWrite); push_function_var({Operand(GenerateTypeIfNeeded(splat_vector_type)), splat_vector, U32Operand(ConvertAddressSpace(type::AddressSpace::kFunction)), Operand(GenerateConstantNullIfNeeded(vec_type))}); @@ -3660,10 +3660,10 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { // fine. if (auto* ptr = type->As()) { type = builder_.create(ptr->StoreType(), ptr->AddressSpace(), - ast::Access::kReadWrite); + type::Access::kReadWrite); } else if (auto* ref = type->As()) { type = builder_.create(ref->StoreType(), ref->AddressSpace(), - ast::Access::kReadWrite); + type::Access::kReadWrite); } return utils::GetOrCreate(type_to_id_, type, [&]() -> uint32_t { @@ -3722,11 +3722,11 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { // SPIR-V, we must output a single type, while the variable is // annotated with the access type. Doing this ensures we de-dupe. type_to_id_[builder_.create( - tex->dim(), tex->texel_format(), ast::Access::kRead, tex->type())] = id; + tex->dim(), tex->texel_format(), type::Access::kRead, tex->type())] = id; type_to_id_[builder_.create( - tex->dim(), tex->texel_format(), ast::Access::kWrite, tex->type())] = id; + tex->dim(), tex->texel_format(), type::Access::kWrite, tex->type())] = id; type_to_id_[builder_.create( - tex->dim(), tex->texel_format(), ast::Access::kReadWrite, tex->type())] = id; + tex->dim(), tex->texel_format(), type::Access::kReadWrite, tex->type())] = id; return true; }, [&](const type::Texture* tex) { return GenerateTextureType(tex, result); }, diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc index e15386cf34..aa154b062a 100644 --- a/src/tint/writer/spirv/builder_builtin_test.cc +++ b/src/tint/writer/spirv/builder_builtin_test.cc @@ -278,7 +278,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{ Member("a", ty.array(4)), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); @@ -322,7 +322,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_OtherMembersInStruct) { Member("z", ty.f32()), Member(4, "a", ty.array(4)), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); @@ -365,7 +365,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{ Member("a", ty.array(4)), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf("b")); @@ -424,7 +424,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) { auto* s = Structure("my_struct", utils::Vector{ Member("a", ty.array(4)), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf(Deref(AddressOf("b")))); @@ -3567,7 +3567,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicLoad) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3631,7 +3631,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicStore) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3703,7 +3703,7 @@ TEST_P(Builtin_Builder_AtomicRMW_i32, Test) { auto* s = Structure("S", utils::Vector{ Member("v", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3776,7 +3776,7 @@ TEST_P(Builtin_Builder_AtomicRMW_u32, Test) { auto* s = Structure("S", utils::Vector{ Member("v", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3851,7 +3851,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicExchange) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3927,7 +3927,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), diff --git a/src/tint/writer/spirv/builder_function_test.cc b/src/tint/writer/spirv/builder_function_test.cc index e6171f07dd..7ee1369f47 100644 --- a/src/tint/writer/spirv/builder_function_test.cc +++ b/src/tint/writer/spirv/builder_function_test.cc @@ -198,8 +198,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(0_a)); + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, + Binding(0_a), Group(0_a)); { auto* var = Var("v", ty.f32(), MemberAccessor("data", "d")); diff --git a/src/tint/writer/spirv/builder_global_variable_test.cc b/src/tint/writer/spirv/builder_global_variable_test.cc index 08892da17d..abf34e22ea 100644 --- a/src/tint/writer/spirv/builder_global_variable_test.cc +++ b/src/tint/writer/spirv/builder_global_variable_test.cc @@ -310,7 +310,7 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { Member("b", ty.i32()), }); - GlobalVar("b", ty.Of(A), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("b", ty.Of(A), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -352,7 +352,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { auto* A = Structure("A", utils::Vector{Member("a", ty.i32())}); auto* B = Alias("B", ty.Of(A)); - GlobalVar("b", ty.Of(B), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("b", ty.Of(B), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -392,7 +392,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { auto* A = Structure("A", utils::Vector{Member("a", ty.i32())}); auto* B = Alias("B", ty.Of(A)); - GlobalVar("b", ty.Of(B), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("b", ty.Of(B), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -431,9 +431,9 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { // var c : A auto* A = Structure("A", utils::Vector{Member("a", ty.i32())}); - GlobalVar("b", ty.Of(A), type::AddressSpace::kStorage, ast::Access::kRead, Group(0_a), + GlobalVar("b", ty.Of(A), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), Binding(0_a)); - GlobalVar("c", ty.Of(A), type::AddressSpace::kStorage, ast::Access::kReadWrite, Group(1_a), + GlobalVar("c", ty.Of(A), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(1_a), Binding(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -473,7 +473,7 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) { // var a : texture_storage_2d; auto* type = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, - ast::Access::kWrite); + type::Access::kWrite); auto* var_a = GlobalVar("a", type, Binding(0_a), Group(0_a)); diff --git a/src/tint/writer/spirv/builder_type_test.cc b/src/tint/writer/spirv/builder_type_test.cc index d49956db36..d74fc006b3 100644 --- a/src/tint/writer/spirv/builder_type_test.cc +++ b/src/tint/writer/spirv/builder_type_test.cc @@ -29,7 +29,7 @@ using BuilderTest_Type = TestHelper; TEST_F(BuilderTest_Type, GenerateRuntimeArray) { auto* ary = ty.array(ty.i32()); auto* str = Structure("S", utils::Vector{Member("x", ary)}); - GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); @@ -46,7 +46,7 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) { TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { auto* ary = ty.array(ty.i32()); auto* str = Structure("S", utils::Vector{Member("x", ary)}); - GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a), + GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); @@ -294,7 +294,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF16Matrix) { TEST_F(BuilderTest_Type, GeneratePtr) { auto* i32 = create(); - auto* ptr = create(i32, type::AddressSpace::kOut, ast::Access::kReadWrite); + auto* ptr = create(i32, type::AddressSpace::kOut, type::Access::kReadWrite); spirv::Builder& b = Build(); @@ -309,7 +309,7 @@ TEST_F(BuilderTest_Type, GeneratePtr) { TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { auto* i32 = create(); - auto* ptr = create(i32, type::AddressSpace::kOut, ast::Access::kReadWrite); + auto* ptr = create(i32, type::AddressSpace::kOut, type::Access::kReadWrite); spirv::Builder& b = Build(); @@ -861,7 +861,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) { auto* s = ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kR32Float, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("test_var", s, Binding(0_a), Group(0_a)); @@ -876,7 +876,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("test_var", s, Binding(0_a), Group(0_a)); @@ -891,7 +891,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { auto* s = ty.storage_texture(type::TextureDimension::k2dArray, ast::TexelFormat::kR32Float, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("test_var", s, Binding(0_a), Group(0_a)); @@ -906,7 +906,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) { auto* s = ty.storage_texture(type::TextureDimension::k3d, ast::TexelFormat::kR32Float, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("test_var", s, Binding(0_a), Group(0_a)); @@ -921,7 +921,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32float) { auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("test_var", s, Binding(0_a), Group(0_a)); @@ -936,7 +936,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32floa TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) { auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Sint, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("test_var", s, Binding(0_a), Group(0_a)); @@ -951,7 +951,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint) { auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint, - ast::Access::kWrite); + type::Access::kWrite); GlobalVar("test_var", s, Binding(0_a), Group(0_a)); diff --git a/src/tint/writer/wgsl/generator_impl.cc b/src/tint/writer/wgsl/generator_impl.cc index 863cf3f4a9..a06e4c9d22 100644 --- a/src/tint/writer/wgsl/generator_impl.cc +++ b/src/tint/writer/wgsl/generator_impl.cc @@ -16,7 +16,6 @@ #include -#include "src/tint/ast/access.h" #include "src/tint/ast/alias.h" #include "src/tint/ast/array.h" #include "src/tint/ast/atomic.h" @@ -51,6 +50,7 @@ #include "src/tint/ast/workgroup_attribute.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" +#include "src/tint/type/access.h" #include "src/tint/type/texture_dimension.h" #include "src/tint/utils/math.h" #include "src/tint/utils/scoped_assignment.h" @@ -361,15 +361,15 @@ bool GeneratorImpl::EmitImageFormat(std::ostream& out, const ast::TexelFormat fm return true; } -bool GeneratorImpl::EmitAccess(std::ostream& out, const ast::Access access) { +bool GeneratorImpl::EmitAccess(std::ostream& out, const type::Access access) { switch (access) { - case ast::Access::kRead: + case type::Access::kRead: out << "read"; return true; - case ast::Access::kWrite: + case type::Access::kWrite: out << "write"; return true; - case ast::Access::kReadWrite: + case type::Access::kReadWrite: out << "read_write"; return true; default: @@ -439,7 +439,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, const ast::Type* ty) { if (!EmitType(out, ptr->type)) { return false; } - if (ptr->access != ast::Access::kUndefined) { + if (ptr->access != type::Access::kUndefined) { out << ", "; if (!EmitAccess(out, ptr->access)) { return false; @@ -669,9 +669,9 @@ bool GeneratorImpl::EmitVariable(std::ostream& out, const ast::Variable* v) { out << "var"; auto address_space = var->declared_address_space; auto ac = var->declared_access; - if (address_space != type::AddressSpace::kNone || ac != ast::Access::kUndefined) { + if (address_space != type::AddressSpace::kNone || ac != type::Access::kUndefined) { out << "<" << address_space; - if (ac != ast::Access::kUndefined) { + if (ac != type::Access::kUndefined) { out << ", "; if (!EmitAccess(out, ac)) { return false; diff --git a/src/tint/writer/wgsl/generator_impl.h b/src/tint/writer/wgsl/generator_impl.h index 71c3bd1651..80a818e6c6 100644 --- a/src/tint/writer/wgsl/generator_impl.h +++ b/src/tint/writer/wgsl/generator_impl.h @@ -203,7 +203,7 @@ class GeneratorImpl : public TextGenerator { /// @param out the output of the expression stream /// @param access the access to generate /// @returns true if the access is emitted - bool EmitAccess(std::ostream& out, const ast::Access access); + bool EmitAccess(std::ostream& out, const type::Access access); /// Handles a unary op expression /// @param out the output of the expression stream /// @param expr the expression to emit diff --git a/src/tint/writer/wgsl/generator_impl_function_test.cc b/src/tint/writer/wgsl/generator_impl_function_test.cc index a1eae5b688..6550b6a64e 100644 --- a/src/tint/writer/wgsl/generator_impl_function_test.cc +++ b/src/tint/writer/wgsl/generator_impl_function_test.cc @@ -179,8 +179,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_Module Member("d", ty.f32()), }); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(0_a)); + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, + Binding(0_a), Group(0_a)); { auto* var = Var("v", ty.f32(), MemberAccessor("data", "d")); diff --git a/src/tint/writer/wgsl/generator_impl_type_test.cc b/src/tint/writer/wgsl/generator_impl_type_test.cc index b19a088cd0..443a5e7b32 100644 --- a/src/tint/writer/wgsl/generator_impl_type_test.cc +++ b/src/tint/writer/wgsl/generator_impl_type_test.cc @@ -152,7 +152,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Pointer) { } TEST_F(WgslGeneratorImplTest, EmitType_PointerAccessMode) { - auto* p = ty.pointer(type::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* p = ty.pointer(type::AddressSpace::kStorage, type::Access::kReadWrite); Alias("make_type_reachable", p); GeneratorImpl& gen = Build(); @@ -455,7 +455,7 @@ INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest, struct StorageTextureData { ast::TexelFormat fmt; type::TextureDimension dim; - ast::Access access; + type::Access access; const char* name; }; inline std::ostream& operator<<(std::ostream& out, StorageTextureData data) { @@ -478,16 +478,15 @@ TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) { INSTANTIATE_TEST_SUITE_P( WgslGeneratorImplTest, WgslGenerator_StorageTextureTest, - testing::Values(StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k1d, - ast::Access::kWrite, "texture_storage_1d"}, - StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k2d, - ast::Access::kWrite, "texture_storage_2d"}, - StorageTextureData{ast::TexelFormat::kRgba8Sint, - type::TextureDimension::k2dArray, ast::Access::kWrite, - "texture_storage_2d_array"}, - StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k3d, - ast::Access::kWrite, - "texture_storage_3d"})); + testing::Values( + StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k1d, + type::Access::kWrite, "texture_storage_1d"}, + StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k2d, + type::Access::kWrite, "texture_storage_2d"}, + StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k2dArray, + type::Access::kWrite, "texture_storage_2d_array"}, + StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k3d, + type::Access::kWrite, "texture_storage_3d"})); struct ImageFormatData { ast::TexelFormat fmt; diff --git a/src/tint/writer/wgsl/generator_impl_variable_test.cc b/src/tint/writer/wgsl/generator_impl_variable_test.cc index 075f46321b..e215d29f3a 100644 --- a/src/tint/writer/wgsl/generator_impl_variable_test.cc +++ b/src/tint/writer/wgsl/generator_impl_variable_test.cc @@ -43,7 +43,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_AddressSpace) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { auto* s = Structure("S", utils::Vector{Member("a", ty.i32())}); - auto* v = GlobalVar("a", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, + auto* v = GlobalVar("a", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -55,7 +55,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) { auto* s = Structure("S", utils::Vector{Member("a", ty.i32())}); - auto* v = GlobalVar("a", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, + auto* v = GlobalVar("a", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build();