diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp index c18f8879f7..c6a2d4d453 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::type::Access::kReadWrite); + remappedAccessControls.emplace(srcBindingPoint, tint::builtin::Access::kReadWrite); } } diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index fbed83aca3..b7022b300d 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -693,6 +693,8 @@ libtint_source_set("libtint_sem_src") { libtint_source_set("libtint_builtins_src") { sources = [ + "builtin/access.cc", + "builtin/access.h", "builtin/builtin_value.cc", "builtin/builtin_value.h", "builtin/extension.cc", @@ -709,8 +711,6 @@ 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", @@ -776,7 +776,10 @@ libtint_source_set("libtint_type_src") { "type/void.h", ] - deps = [ ":libtint_base_src" ] + deps = [ + ":libtint_base_src", + ":libtint_builtins_src", + ] } libtint_source_set("libtint_constant_src") { @@ -931,6 +934,7 @@ libtint_source_set("libtint_wgsl_reader_src") { deps = [ ":libtint_ast_src", ":libtint_base_src", + ":libtint_builtins_src", ":libtint_program_src", ":libtint_reader_src", ":libtint_text_src", @@ -949,6 +953,7 @@ libtint_source_set("libtint_wgsl_writer_src") { deps = [ ":libtint_ast_src", ":libtint_base_src", + ":libtint_builtins_src", ":libtint_program_src", ":libtint_sem_src", ":libtint_type_src", @@ -1007,6 +1012,7 @@ libtint_source_set("libtint_glsl_writer_src") { deps = [ ":libtint_ast_src", ":libtint_base_src", + ":libtint_builtins_src", ":libtint_constant_src", ":libtint_program_src", ":libtint_sem_src", @@ -1275,6 +1281,7 @@ if (tint_build_unittests) { deps = [ ":libtint_ast_src", ":libtint_base_src", + ":libtint_builtins_src", ":libtint_transform_src", ":libtint_unittests_ast_helper", ] @@ -1287,6 +1294,7 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_builtins_src") { sources = [ + "builtin/access_test.cc", "builtin/builtin_value_test.cc", "builtin/extension_test.cc", ] @@ -1405,7 +1413,6 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_type_src") { sources = [ - "type/access_test.cc", "type/address_space_test.cc", "type/atomic_test.cc", "type/bool_test.cc", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 4b87d7b4a8..149505d0d8 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -548,6 +548,7 @@ list(APPEND TINT_LIB_SRCS writer/writer.h ) +tint_generated(builtin/access BENCH TEST) tint_generated(builtin/builtin_value BENCH TEST) tint_generated(builtin/extension BENCH TEST) tint_generated(ast/diagnostic_control BENCH TEST) @@ -555,7 +556,6 @@ tint_generated(ast/interpolate_attribute 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/builtin BENCH TEST) tint_generated(type/texel_format BENCH TEST) diff --git a/src/tint/ast/alias_test.cc b/src/tint/ast/alias_test.cc index 6e5d6473b1..d99fb21748 100644 --- a/src/tint/ast/alias_test.cc +++ b/src/tint/ast/alias_test.cc @@ -14,7 +14,7 @@ #include "src/tint/ast/alias.h" #include "src/tint/ast/test_helper.h" -#include "src/tint/type/access.h" +#include "src/tint/builtin/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 4aefbc67ca..7b55d696b5 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, - type::Access acc, + tint::builtin::Access acc, type::TexelFormat fmt, type::TextureDimension dims, TextureDataType datatype, @@ -404,7 +404,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kDimensionsStorageWO1d, "textureDimensions(t : texture_storage_1d) -> u32", - type::Access::kWrite, + tint::builtin::Access::kWrite, type::TexelFormat::kRgba32Float, type::TextureDimension::k1d, TextureDataType::kF32, @@ -414,7 +414,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kDimensionsStorageWO2d, "textureDimensions(t : texture_storage_2d) -> vec2", - type::Access::kWrite, + tint::builtin::Access::kWrite, type::TexelFormat::kRgba32Float, type::TextureDimension::k2d, TextureDataType::kF32, @@ -424,7 +424,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kDimensionsStorageWO2dArray, "textureDimensions(t : texture_storage_2d_array) -> vec2", - type::Access::kWrite, + tint::builtin::Access::kWrite, type::TexelFormat::kRgba32Float, type::TextureDimension::k2dArray, TextureDataType::kF32, @@ -434,7 +434,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kDimensionsStorageWO3d, "textureDimensions(t : texture_storage_3d) -> vec3", - type::Access::kWrite, + tint::builtin::Access::kWrite, type::TexelFormat::kRgba32Float, type::TextureDimension::k3d, TextureDataType::kF32, @@ -827,7 +827,7 @@ std::vector TextureOverloadCase::ValidCases() { { ValidTextureOverload::kNumLayersStorageWO2dArray, "textureNumLayers(t : texture_storage_2d_array) -> u32", - type::Access::kWrite, + tint::builtin::Access::kWrite, type::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)", - type::Access::kWrite, + tint::builtin::Access::kWrite, type::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)", - type::Access::kWrite, + tint::builtin::Access::kWrite, type::TexelFormat::kRgba32Float, type::TextureDimension::k2d, TextureDataType::kF32, @@ -2360,7 +2360,7 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " array_index : u32,\n" " value : vec4)", - type::Access::kWrite, + tint::builtin::Access::kWrite, type::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)", - type::Access::kWrite, + tint::builtin::Access::kWrite, type::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 6fe0193770..46f14427ea 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/builtin/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" @@ -207,7 +207,7 @@ struct TextureOverloadCase { /// Constructor for textureLoad() with storage textures TextureOverloadCase(ValidTextureOverload, const char*, - type::Access, + tint::builtin::Access, type::TexelFormat, type::TextureDimension, TextureDataType, @@ -245,7 +245,7 @@ struct TextureOverloadCase { type::SamplerKind const sampler_kind = type::SamplerKind::kSampler; /// The access control for the storage texture /// Used only when texture_kind is kStorage - type::Access const access = type::Access::kReadWrite; + tint::builtin::Access const access = tint::builtin::Access::kReadWrite; /// The image format for the storage texture /// Used only when texture_kind is kStorage type::TexelFormat const texel_format = type::TexelFormat::kUndefined; diff --git a/src/tint/ast/variable.h b/src/tint/ast/variable.h index 7663e4fdce..78e3b758fe 100644 --- a/src/tint/ast/variable.h +++ b/src/tint/ast/variable.h @@ -23,7 +23,7 @@ #include "src/tint/ast/expression.h" #include "src/tint/ast/group_attribute.h" #include "src/tint/ast/type.h" -#include "src/tint/type/access.h" +#include "src/tint/builtin/access.h" #include "src/tint/type/address_space.h" // Forward declarations diff --git a/src/tint/type/access.cc b/src/tint/builtin/access.cc similarity index 92% rename from src/tint/type/access.cc rename to src/tint/builtin/access.cc index 04ccd9d32e..56b326c4db 100644 --- a/src/tint/type/access.cc +++ b/src/tint/builtin/access.cc @@ -15,14 +15,14 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/type/access.cc.tmpl +// src/tint/builtin/access.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/type/access.h" +#include "src/tint/builtin/access.h" -namespace tint::type { +namespace tint::builtin { /// 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::type +} // namespace tint::builtin diff --git a/src/tint/type/access.cc.tmpl b/src/tint/builtin/access.cc.tmpl similarity index 86% rename from src/tint/type/access.cc.tmpl rename to src/tint/builtin/access.cc.tmpl index b34ff6130a..d0f967fb39 100644 --- a/src/tint/type/access.cc.tmpl +++ b/src/tint/builtin/access.cc.tmpl @@ -14,12 +14,12 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "access") -}} -#include "src/tint/type/access.h" +#include "src/tint/builtin/access.h" -namespace tint::type { +namespace tint::builtin { {{ Eval "ParseEnum" $enum}} {{ Eval "EnumOStream" $enum}} -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/type/access.h b/src/tint/builtin/access.h similarity index 88% rename from src/tint/type/access.h rename to src/tint/builtin/access.h index 26f24f6241..f59f50eca7 100644 --- a/src/tint/type/access.h +++ b/src/tint/builtin/access.h @@ -15,17 +15,17 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/type/access.h.tmpl +// src/tint/builtin/access.h.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#ifndef SRC_TINT_TYPE_ACCESS_H_ -#define SRC_TINT_TYPE_ACCESS_H_ +#ifndef SRC_TINT_BUILTIN_ACCESS_H_ +#define SRC_TINT_BUILTIN_ACCESS_H_ #include -namespace tint::type { +namespace tint::builtin { /// Address space of a given pointer. enum class Access { @@ -51,6 +51,6 @@ constexpr const char* kAccessStrings[] = { "write", }; -} // namespace tint::type +} // namespace tint::builtin -#endif // SRC_TINT_TYPE_ACCESS_H_ +#endif // SRC_TINT_BUILTIN_ACCESS_H_ diff --git a/src/tint/type/access.h.tmpl b/src/tint/builtin/access.h.tmpl similarity index 79% rename from src/tint/type/access.h.tmpl rename to src/tint/builtin/access.h.tmpl index 6d353e5578..6e4587a5f9 100644 --- a/src/tint/type/access.h.tmpl +++ b/src/tint/builtin/access.h.tmpl @@ -14,16 +14,16 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "access") -}} -#ifndef SRC_TINT_TYPE_ACCESS_H_ -#define SRC_TINT_TYPE_ACCESS_H_ +#ifndef SRC_TINT_BUILTIN_ACCESS_H_ +#define SRC_TINT_BUILTIN_ACCESS_H_ #include -namespace tint::type { +namespace tint::builtin { /// Address space of a given pointer. {{ Eval "DeclareEnum" $enum}} -} // namespace tint::type +} // namespace tint::builtin -#endif // SRC_TINT_TYPE_ACCESS_H_ +#endif // SRC_TINT_BUILTIN_ACCESS_H_ diff --git a/src/tint/type/access_bench.cc b/src/tint/builtin/access_bench.cc similarity index 91% rename from src/tint/type/access_bench.cc rename to src/tint/builtin/access_bench.cc index ab578ebf1d..91f808f1b1 100644 --- a/src/tint/type/access_bench.cc +++ b/src/tint/builtin/access_bench.cc @@ -15,18 +15,18 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/type/access_bench.cc.tmpl +// src/tint/builtin/access_bench.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/type/access.h" +#include "src/tint/builtin/access.h" #include #include "benchmark/benchmark.h" -namespace tint::type { +namespace tint::builtin { namespace { void AccessParser(::benchmark::State& state) { @@ -48,4 +48,4 @@ void AccessParser(::benchmark::State& state) { BENCHMARK(AccessParser); } // namespace -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/type/access_bench.cc.tmpl b/src/tint/builtin/access_bench.cc.tmpl similarity index 87% rename from src/tint/type/access_bench.cc.tmpl rename to src/tint/builtin/access_bench.cc.tmpl index 420f48642e..c701ab9638 100644 --- a/src/tint/type/access_bench.cc.tmpl +++ b/src/tint/builtin/access_bench.cc.tmpl @@ -14,16 +14,16 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "access") -}} -#include "src/tint/type/access.h" +#include "src/tint/builtin/access.h" #include #include "benchmark/benchmark.h" -namespace tint::type { +namespace tint::builtin { namespace { {{ Eval "BenchmarkParseEnum" $enum }} } // namespace -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/type/access_test.cc b/src/tint/builtin/access_test.cc similarity index 93% rename from src/tint/type/access_test.cc rename to src/tint/builtin/access_test.cc index 77968efa3f..91786eff2c 100644 --- a/src/tint/type/access_test.cc +++ b/src/tint/builtin/access_test.cc @@ -15,19 +15,20 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/type/access_test.cc.tmpl +// src/tint/builtin/access_test.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/type/access.h" +#include "src/tint/builtin/access.h" + +#include #include -#include "src/tint/type/test_helper.h" #include "src/tint/utils/string.h" -namespace tint::type { +namespace tint::builtin { namespace { namespace parse_print_tests { @@ -79,4 +80,4 @@ INSTANTIATE_TEST_SUITE_P(ValidCases, AccessPrintTest, testing::ValuesIn(kValidCa } // namespace parse_print_tests } // namespace -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/type/access_test.cc.tmpl b/src/tint/builtin/access_test.cc.tmpl similarity index 84% rename from src/tint/type/access_test.cc.tmpl rename to src/tint/builtin/access_test.cc.tmpl index dd6ed44c34..0674f4bf05 100644 --- a/src/tint/type/access_test.cc.tmpl +++ b/src/tint/builtin/access_test.cc.tmpl @@ -14,17 +14,18 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "access") -}} -#include "src/tint/type/access.h" +#include "src/tint/builtin/access.h" + +#include #include -#include "src/tint/type/test_helper.h" #include "src/tint/utils/string.h" -namespace tint::type { +namespace tint::builtin { namespace { {{ Eval "TestParsePrintEnum" $enum}} } // namespace -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/fuzzers/transform_builder.h b/src/tint/fuzzers/transform_builder.h index 90d6af5d4d..73b5b51bb5 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; - type::Access new_access; + builtin::Access new_access; }; std::vector configs = tb->builder()->vector(); diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index 40658db790..396d0e50db 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -719,7 +719,7 @@ std::vector Inspector::GetStorageBufferResourceBindingsImpl( auto* var = rsv.first; auto binding_info = rsv.second; - if (read_only != (var->Access() == type::Access::kRead)) { + if (read_only != (var->Access() == builtin::Access::kRead)) { continue; } diff --git a/src/tint/inspector/inspector_test.cc b/src/tint/inspector/inspector_test.cc index 743f87822c..22f1332881 100644 --- a/src/tint/inspector/inspector_test.cc +++ b/src/tint/inspector/inspector_test.cc @@ -1655,8 +1655,8 @@ TEST_F(InspectorGetStorageSizeTest, Empty) { TEST_F(InspectorGetStorageSizeTest, Simple_NonStruct) { AddUniformBuffer("ub_var", ty.i32(), 0, 0); - AddStorageBuffer("sb_var", ty.i32(), type::Access::kReadWrite, 1, 0); - AddStorageBuffer("rosb_var", ty.i32(), type::Access::kRead, 1, 1); + AddStorageBuffer("sb_var", ty.i32(), builtin::Access::kReadWrite, 1, 0); + AddStorageBuffer("rosb_var", ty.i32(), builtin::Access::kRead, 1, 1); Func("ep_func", utils::Empty, ty.void_(), utils::Vector{ Decl(Let("ub", Expr("ub_var"))), @@ -1687,7 +1687,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_Struct) { auto sb = MakeStorageBufferTypes("sb_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("sb_var", sb(), type::Access::kReadWrite, 1, 0); + AddStorageBuffer("sb_var", sb(), builtin::Access::kReadWrite, 1, 0); MakeStructVariableReferenceBodyFunction("sb_func", "sb_var", utils::Vector{ MemberInfo{0, ty.i32()}, @@ -1696,7 +1696,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_Struct) { auto ro_sb = MakeStorageBufferTypes("rosb_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("rosb_var", ro_sb(), type::Access::kRead, 1, 1); + AddStorageBuffer("rosb_var", ro_sb(), builtin::Access::kRead, 1, 1); MakeStructVariableReferenceBodyFunction("rosb_func", "rosb_var", utils::Vector{ MemberInfo{0, ty.i32()}, @@ -1774,7 +1774,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) { auto sb = MakeStorageBufferTypes("sb_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("sb_var", sb(), type::Access::kReadWrite, 1, 0); + AddStorageBuffer("sb_var", sb(), builtin::Access::kReadWrite, 1, 0); MakeStructVariableReferenceBodyFunction("sb_func", "sb_var", utils::Vector{ MemberInfo{0, ty.i32()}, @@ -1783,7 +1783,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) { auto ro_sb = MakeStorageBufferTypes("rosb_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("rosb_var", ro_sb(), type::Access::kRead, 1, 1); + AddStorageBuffer("rosb_var", ro_sb(), builtin::Access::kRead, 1, 1); MakeStructVariableReferenceBodyFunction("rosb_func", "rosb_var", utils::Vector{ MemberInfo{0, ty.i32()}, @@ -2140,7 +2140,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple_NonStruct) { - AddStorageBuffer("foo_sb", ty.i32(), type::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", ty.i32(), builtin::Access::kReadWrite, 0, 0); MakePlainGlobalReferenceBodyFunction("sb_func", "foo_sb", ty.i32(), utils::Empty); MakeCallerBodyFunction("ep_func", utils::Vector{std::string("sb_func")}, @@ -2165,7 +2165,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple_Struct) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2196,7 +2196,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) { ty.u32(), ty.f32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2229,9 +2229,9 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { ty.u32(), ty.f32(), }); - 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); + AddStorageBuffer("sb_foo", sb_struct_type(), builtin::Access::kReadWrite, 0, 0); + AddStorageBuffer("sb_bar", sb_struct_type(), builtin::Access::kReadWrite, 0, 1); + AddStorageBuffer("sb_baz", sb_struct_type(), builtin::Access::kReadWrite, 2, 0); auto AddReferenceFunc = [this](const std::string& func_name, const std::string& var_name) { MakeStructVariableReferenceBodyFunction(func_name, var_name, @@ -2288,7 +2288,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) { ty.i32(), ty.array(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2318,7 +2318,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) { ty.i32(), ty.array(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2347,7 +2347,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.vec3(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2373,7 +2373,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, NonStructVec3) { - AddStorageBuffer("foo_ub", ty.vec3(), type::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_ub", ty.vec3(), builtin::Access::kReadWrite, 0, 0); MakePlainGlobalReferenceBodyFunction("ub_func", "foo_ub", ty.vec3(), utils::Empty); MakeCallerBodyFunction("ep_func", utils::Vector{std::string("ub_func")}, @@ -2398,7 +2398,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kRead, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2421,7 +2421,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kRead, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2452,9 +2452,9 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, MultipleStorageBuf ty.u32(), ty.f32(), }); - 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); + AddStorageBuffer("sb_foo", sb_struct_type(), builtin::Access::kRead, 0, 0); + AddStorageBuffer("sb_bar", sb_struct_type(), builtin::Access::kRead, 0, 1); + AddStorageBuffer("sb_baz", sb_struct_type(), builtin::Access::kRead, 2, 0); auto AddReferenceFunc = [this](const std::string& func_name, const std::string& var_name) { MakeStructVariableReferenceBodyFunction(func_name, var_name, @@ -2511,7 +2511,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) { ty.i32(), ty.array(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kRead, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2541,7 +2541,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingRuntimeA ty.i32(), ty.array(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kRead, 0, 0); MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", utils::Vector{ @@ -2570,7 +2570,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) { auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{ ty.i32(), }); - AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0); + AddStorageBuffer("foo_sb", foo_struct_type(), builtin::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 e73c6f5324..1de6dd3ea8 100644 --- a/src/tint/inspector/test_inspector_builder.cc +++ b/src/tint/inspector/test_inspector_builder.cc @@ -134,7 +134,7 @@ void InspectorBuilder::AddWorkgroupStorage(const std::string& name, ast::Type ty void InspectorBuilder::AddStorageBuffer(const std::string& name, ast::Type type, - type::Access access, + builtin::Access access, uint32_t group, uint32_t binding) { GlobalVar(name, type, type::AddressSpace::kStorage, access, Binding(AInt(binding)), @@ -279,7 +279,7 @@ ast::Type InspectorBuilder::GetCoordsType(type::TextureDimension dim, ast::Type ast::Type InspectorBuilder::MakeStorageTextureTypes(type::TextureDimension dim, type::TexelFormat format) { - return ty.storage_texture(dim, format, type::Access::kWrite); + return ty.storage_texture(dim, format, builtin::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 1d99863851..70567383bb 100644 --- a/src/tint/inspector/test_inspector_builder.h +++ b/src/tint/inspector/test_inspector_builder.h @@ -182,7 +182,7 @@ class InspectorBuilder : public ProgramBuilder { /// @param binding the binding number to use for the storage buffer void AddStorageBuffer(const std::string& name, ast::Type type, - type::Access access, + builtin::Access access, uint32_t group, uint32_t binding); diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index f89a30baee..481656778f 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -237,8 +237,8 @@ class ProgramBuilder { address_space = b.Expr(addr_space); } } - void Set(ProgramBuilder& b, type::Access ac) { - if (ac != type::Access::kUndefined) { + void Set(ProgramBuilder& b, builtin::Access ac) { + if (ac != builtin::Access::kUndefined) { access = b.Expr(ac); } } @@ -1202,7 +1202,7 @@ class ProgramBuilder { /// @return the pointer to `type` with the given type::AddressSpace ast::Type pointer(ast::Type type, type::AddressSpace address_space, - type::Access access = type::Access::kUndefined) const { + builtin::Access access = builtin::Access::kUndefined) const { return pointer(builder->source_, type, address_space, access); } @@ -1214,8 +1214,8 @@ class ProgramBuilder { ast::Type pointer(const Source& source, ast::Type type, type::AddressSpace address_space, - type::Access access = type::Access::kUndefined) const { - if (access != type::Access::kUndefined) { + builtin::Access access = builtin::Access::kUndefined) const { + if (access != builtin::Access::kUndefined) { return (*this)(source, "ptr", address_space, type, access); } else { return (*this)(source, "ptr", address_space, type); @@ -1227,7 +1227,7 @@ class ProgramBuilder { /// @return the pointer to type `T` with the given type::AddressSpace. template ast::Type pointer(type::AddressSpace address_space, - type::Access access = type::Access::kUndefined) const { + builtin::Access access = builtin::Access::kUndefined) const { return pointer(builder->source_, address_space, access); } @@ -1238,8 +1238,8 @@ class ProgramBuilder { template ast::Type pointer(const Source& source, type::AddressSpace address_space, - type::Access access = type::Access::kUndefined) const { - if (access != type::Access::kUndefined) { + builtin::Access access = builtin::Access::kUndefined) const { + if (access != builtin::Access::kUndefined) { return (*this)(source, "ptr", address_space, Of(), access); } else { return (*this)(source, "ptr", address_space, Of()); @@ -1390,7 +1390,7 @@ class ProgramBuilder { /// @returns the storage texture ast::Type storage_texture(type::TextureDimension dims, type::TexelFormat format, - type::Access access) const { + builtin::Access access) const { return storage_texture(builder->source_, dims, format, access); } @@ -1402,7 +1402,7 @@ class ProgramBuilder { ast::Type storage_texture(const Source& source, type::TextureDimension dims, type::TexelFormat format, - type::Access access) const { + builtin::Access access) const { switch (dims) { case type::TextureDimension::k1d: return (*this)(source, "texture_storage_1d", format, access); @@ -2067,7 +2067,7 @@ class ProgramBuilder { /// Can be any of the following, in any order: /// * ast::Type - specifies the variable's type /// * type::AddressSpace - specifies the variable's address space - /// * type::Access - specifies the variable's access control + /// * builtin::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. @@ -2084,7 +2084,7 @@ class ProgramBuilder { /// Can be any of the following, in any order: /// * ast::Type - specifies the variable's type /// * type::AddressSpace - specifies the variable's address space - /// * type::Access - specifies the variable's access control + /// * builtin::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. @@ -2186,7 +2186,7 @@ class ProgramBuilder { /// Can be any of the following, in any order: /// * ast::Type - specifies the variable's type /// * type::AddressSpace - specifies the variable address space - /// * type::Access - specifies the variable's access control + /// * builtin::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. @@ -2203,7 +2203,7 @@ class ProgramBuilder { /// Can be any of the following, in any order: /// * ast::Type - specifies the variable's type /// * type::AddressSpace - specifies the variable address space - /// * type::Access - specifies the variable's access control + /// * builtin::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 513b7f3a81..ca35917e39 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -2522,7 +2522,7 @@ bool FunctionEmitter::EmitFunctionVariables() { } } auto* var = parser_impl_.MakeVar(inst.result_id(), type::AddressSpace::kUndefined, - type::Access::kUndefined, var_store_type, initializer, + builtin::Access::kUndefined, var_store_type, initializer, AttributeList{}); auto* var_decl_stmt = create(Source{}, var); AddStatement(var_decl_stmt); @@ -3369,7 +3369,7 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info, auto* store_type = parser_impl_.ConvertType(def_inst->type_id()); AddStatement(create( Source{}, - parser_impl_.MakeVar(id, type::AddressSpace::kUndefined, type::Access::kUndefined, + parser_impl_.MakeVar(id, type::AddressSpace::kUndefined, builtin::Access::kUndefined, store_type, nullptr, AttributeList{}))); auto* type = ty_.Reference(store_type, type::AddressSpace::kUndefined); identifier_types_.emplace(id, type); @@ -4842,7 +4842,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, type::Access::kUndefined}; + return DefInfo::Pointer{type::AddressSpace::kFunction, builtin::Access::kUndefined}; } case spv::Op::OpFunctionParameter: { const auto* type = As(parser_impl_.ConvertType(inst.type_id())); @@ -4855,7 +4855,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, type::Access::kUndefined}; + return DefInfo::Pointer{type->address_space, builtin::Access::kUndefined}; } default: break; diff --git a/src/tint/reader/spirv/function.h b/src/tint/reader/spirv/function.h index d035591ecb..5879859ff1 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. - type::Access access = type::Access::kUndefined; + builtin::Access access = builtin::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 443b28f357..282e2854fb 100644 --- a/src/tint/reader/spirv/parser_impl.cc +++ b/src/tint/reader/spirv/parser_impl.cc @@ -1576,9 +1576,9 @@ const spvtools::opt::analysis::IntConstant* ParserImpl::GetArraySize(uint32_t va return size->AsIntConstant(); } -type::Access ParserImpl::VarAccess(const Type* storage_type, type::AddressSpace address_space) { +builtin::Access ParserImpl::VarAccess(const Type* storage_type, type::AddressSpace address_space) { if (address_space != type::AddressSpace::kStorage) { - return type::Access::kUndefined; + return builtin::Access::kUndefined; } bool read_only = false; @@ -1587,12 +1587,12 @@ type::Access ParserImpl::VarAccess(const Type* storage_type, type::AddressSpace } // Apply the access(read) or access(read_write) modifier. - return read_only ? type::Access::kRead : type::Access::kReadWrite; + return read_only ? builtin::Access::kRead : builtin::Access::kReadWrite; } const ast::Var* ParserImpl::MakeVar(uint32_t id, type::AddressSpace address_space, - type::Access access, + builtin::Access access, const Type* storage_type, const ast::Expression* initializer, AttributeList decorations) { @@ -2526,7 +2526,7 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc ast_handle_type = ty_.SampledTexture(dim, ast_sampled_component_type); } } else { - const auto access = type::Access::kWrite; + const auto access = builtin::Access::kWrite; const auto format = enum_converter_.ToTexelFormat(image_type->format()); if (format == type::TexelFormat::kUndefined) { return nullptr; diff --git a/src/tint/reader/spirv/parser_impl.h b/src/tint/reader/spirv/parser_impl.h index 0c77a02849..7f934970ed 100644 --- a/src/tint/reader/spirv/parser_impl.h +++ b/src/tint/reader/spirv/parser_impl.h @@ -424,7 +424,7 @@ class ParserImpl : Reader { /// @param address_space the 'var' address space /// @returns the access mode for a 'var' declaration with the given storage type and address /// space. - type::Access VarAccess(const Type* storage_type, type::AddressSpace address_space); + builtin::Access VarAccess(const Type* storage_type, type::AddressSpace address_space); /// Creates an AST 'var' node for a SPIR-V ID, including any attached decorations, unless it's /// an ignorable builtin variable. @@ -438,7 +438,7 @@ class ParserImpl : Reader { /// in the error case const ast::Var* MakeVar(uint32_t id, type::AddressSpace address_space, - type::Access access, + builtin::Access access, const Type* storage_type, const ast::Expression* initializer, AttributeList decorations); @@ -674,7 +674,7 @@ class ParserImpl : Reader { /// The address space of the var type::AddressSpace address_space = type::AddressSpace::kUndefined; /// The access mode of the var - type::Access access = type::Access::kUndefined; + builtin::Access access = builtin::Access::kUndefined; }; /// Returns the AST variable for the SPIR-V ID of a module-scope variable, diff --git a/src/tint/reader/spirv/parser_type.cc b/src/tint/reader/spirv/parser_type.cc index 9051b78459..3164c6e5ce 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, type::Access a) +Pointer::Pointer(const Type* t, type::AddressSpace s, builtin::Access a) : type(t), address_space(s), access(a) {} Pointer::Pointer(const Pointer&) = default; @@ -189,7 +189,7 @@ 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, type::Access a) +Reference::Reference(const Type* t, type::AddressSpace s, builtin::Access a) : type(t), address_space(s), access(a) {} Reference::Reference(const Reference&) = default; @@ -269,7 +269,7 @@ ast::Type SampledTexture::Build(ProgramBuilder& b) const { return b.ty.sampled_texture(dims, type->Build(b)); } -StorageTexture::StorageTexture(type::TextureDimension d, type::TexelFormat f, type::Access a) +StorageTexture::StorageTexture(type::TextureDimension d, type::TexelFormat f, builtin::Access a) : Base(d), format(f), access(a) {} StorageTexture::StorageTexture(const StorageTexture&) = default; @@ -475,13 +475,13 @@ const Type* TypeManager::AsUnsigned(const Type* ty) { const spirv::Pointer* TypeManager::Pointer(const Type* el, type::AddressSpace address_space, - type::Access access) { + builtin::Access access) { return state->pointers_.Get(el, address_space, access); } const spirv::Reference* TypeManager::Reference(const Type* el, type::AddressSpace address_space, - type::Access access) { + builtin::Access access) { return state->references_.Get(el, address_space, access); } @@ -530,7 +530,7 @@ const spirv::SampledTexture* TypeManager::SampledTexture(type::TextureDimension const spirv::StorageTexture* TypeManager::StorageTexture(type::TextureDimension dims, type::TexelFormat fmt, - type::Access access) { + builtin::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 98056075f2..18f47d38ef 100644 --- a/src/tint/reader/spirv/parser_type.h +++ b/src/tint/reader/spirv/parser_type.h @@ -20,9 +20,9 @@ #include #include "src/tint/ast/type.h" +#include "src/tint/builtin/access.h" #include "src/tint/castable.h" #include "src/tint/symbol.h" -#include "src/tint/type/access.h" #include "src/tint/type/address_space.h" #include "src/tint/type/sampler_kind.h" #include "src/tint/type/texel_format.h" @@ -162,7 +162,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, type::Access access); + Pointer(const Type* ty, type::AddressSpace sc, builtin::Access access); /// Copy constructor /// @param other the other type to copy @@ -182,7 +182,7 @@ struct Pointer final : public Castable { /// the pointer address space type::AddressSpace const address_space; /// the pointer declared access mode - type::Access const access; + builtin::Access const access; }; /// `ref` type @@ -193,7 +193,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, type::Access access); + Reference(const Type* ty, type::AddressSpace sc, builtin::Access access); /// Copy constructor /// @param other the other type to copy @@ -213,7 +213,7 @@ struct Reference final : public Castable { /// the pointer address space type::AddressSpace const address_space; /// the pointer declared access mode - type::Access const access; + builtin::Access const access; }; /// `vecN` type @@ -434,7 +434,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, type::TexelFormat f, type::Access a); + StorageTexture(type::TextureDimension d, type::TexelFormat f, builtin::Access a); /// Copy constructor /// @param other the other type to copy @@ -453,7 +453,7 @@ struct StorageTexture final : public Castable { type::TexelFormat const format; /// the access control - type::Access const access; + builtin::Access const access; }; /// Base class for named types @@ -550,7 +550,7 @@ class TypeManager { /// the same pointer. const spirv::Pointer* Pointer(const Type* ty, type::AddressSpace address_space, - type::Access access = type::Access::kUndefined); + builtin::Access access = builtin::Access::kUndefined); /// @param ty the referenced type /// @param address_space the reference address space /// @param access the declared access mode @@ -558,7 +558,7 @@ class TypeManager { /// return the same pointer. const spirv::Reference* Reference(const Type* ty, type::AddressSpace address_space, - type::Access access = type::Access::kUndefined); + builtin::Access access = builtin::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 @@ -616,7 +616,7 @@ class TypeManager { /// return the same pointer. const spirv::StorageTexture* StorageTexture(type::TextureDimension d, type::TexelFormat f, - type::Access a); + builtin::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 af1d090242..560b24eda1 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, type::TexelFormat::kR32Uint, - type::Access::kRead), + builtin::Access::kRead), ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint, - type::Access::kRead)); + builtin::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, type::TexelFormat::kR32Uint, - type::Access::kRead), + builtin::Access::kRead), ty.StorageTexture(type::TextureDimension::k3d, type::TexelFormat::kR32Uint, - type::Access::kRead)); + builtin::Access::kRead)); EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint, - type::Access::kRead), + builtin::Access::kRead), ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Sint, - type::Access::kRead)); + builtin::Access::kRead)); EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint, - type::Access::kRead), + builtin::Access::kRead), ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint, - type::Access::kWrite)); + builtin::Access::kWrite)); } } // namespace diff --git a/src/tint/reader/wgsl/parser_impl.h b/src/tint/reader/wgsl/parser_impl.h index 64618b3704..a034010a97 100644 --- a/src/tint/reader/wgsl/parser_impl.h +++ b/src/tint/reader/wgsl/parser_impl.h @@ -22,6 +22,7 @@ #include #include +#include "src/tint/builtin/access.h" #include "src/tint/program_builder.h" #include "src/tint/reader/wgsl/parser_impl_detail.h" #include "src/tint/reader/wgsl/token.h" 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 9a8b936e67..9708f0d5ed 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc @@ -21,7 +21,7 @@ namespace { struct VariableStorageData { const char* input; type::AddressSpace address_space; - type::Access access; + builtin::Access access; }; inline std::ostream& operator<<(std::ostream& out, VariableStorageData data) { out << std::string(data.input); @@ -44,7 +44,7 @@ TEST_P(VariableQualifierTest, ParsesAddressSpace) { } else { EXPECT_EQ(sc->address_space, nullptr); } - if (params.access != type::Access::kUndefined) { + if (params.access != builtin::Access::kUndefined) { ast::CheckIdentifier(p->builder().Symbols(), sc->access, utils::ToString(params.access)); } else { EXPECT_EQ(sc->access, nullptr); @@ -57,15 +57,17 @@ INSTANTIATE_TEST_SUITE_P( ParserImplTest, VariableQualifierTest, testing::Values( - 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{"uniform", type::AddressSpace::kUniform, builtin::Access::kUndefined}, + VariableStorageData{"workgroup", type::AddressSpace::kWorkgroup, + builtin::Access::kUndefined}, + VariableStorageData{"storage", type::AddressSpace::kStorage, builtin::Access::kUndefined}, + VariableStorageData{"private", type::AddressSpace::kPrivate, builtin::Access::kUndefined}, + VariableStorageData{"function", type::AddressSpace::kFunction, builtin::Access::kUndefined}, + VariableStorageData{"storage, read", type::AddressSpace::kStorage, builtin::Access::kRead}, + VariableStorageData{"storage, write", type::AddressSpace::kStorage, + builtin::Access::kWrite}, VariableStorageData{"storage, read_write", type::AddressSpace::kStorage, - type::Access::kReadWrite})); + builtin::Access::kReadWrite})); TEST_F(ParserImplTest, VariableQualifier_Empty) { auto p = parser("var<> name"); diff --git a/src/tint/resolver/address_space_validation_test.cc b/src/tint/resolver/address_space_validation_test.cc index 95301c74ad..b0c27e7557 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) { // struct S{ a : f32 }; // var g : array; Structure("S", utils::Vector{Member("a", ty.f32())}); - GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead, + GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -347,7 +347,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF16) { Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("a", ty.f16())}); - GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead, + GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -361,7 +361,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF16) { Structure("S", utils::Vector{Member("a", ty.f16())}); Alias("t", - ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead)); + ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -370,7 +370,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("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + GlobalVar("g", ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -380,7 +380,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("S"), type::AddressSpace::kStorage, type::Access::kRead)); + Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -392,7 +392,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32Alias Structure("S", utils::Vector{Member("x", ty.i32())}); Alias("a1", ty("S")); Alias("a2", ty("a1")); - GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -405,7 +405,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32Aliases Structure("S", utils::Vector{Member("x", ty.i32())}); Alias("a1", ty("S")); Alias("a2", ty("a1")); - Alias("t", ty.pointer(ty("a2"), type::AddressSpace::kStorage, type::Access::kRead)); + Alias("t", ty.pointer(ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -416,7 +416,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16) { Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - GlobalVar("g", ty("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + GlobalVar("g", ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -428,7 +428,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16) { Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, type::Access::kRead)); + Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -442,7 +442,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16Alias Structure("S", utils::Vector{Member("x", ty.f16())}); Alias("a1", ty("S")); Alias("a2", ty("a1")); - GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -457,14 +457,15 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16Aliases Structure("S", utils::Vector{Member("x", ty.f16())}); Alias("a1", ty("S")); Alias("a2", ty("a1")); - Alias("g", ty.pointer(ty("a2"), type::AddressSpace::kStorage, type::Access::kRead)); + Alias("g", ty.pointer(ty("a2"), type::AddressSpace::kStorage, builtin::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, type::Access::kRead); + GlobalVar(Source{{12, 34}}, "g", ty.i32(), type::AddressSpace::kPrivate, + builtin::Access::kRead); ASSERT_FALSE(r()->Resolve()); @@ -476,7 +477,7 @@ 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, - type::Access::kRead)); + builtin::Access::kRead)); ASSERT_FALSE(r()->Resolve()); @@ -487,7 +488,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, type::Access::kRead, Group(0_a), + GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -495,14 +496,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, type::Access::kRead)); + Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, builtin::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, type::Access::kReadWrite, Group(0_a), + GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -510,15 +511,15 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadWriteAcces TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadWriteAccessMode) { // type t = ptr; - Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite)); + Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, builtin::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, type::Access::kWrite, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, + builtin::Access::kWrite, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -529,7 +530,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, - type::Access::kWrite)); + builtin::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 cf8b505e7b..f8f663bcaf 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, type::Access::kRead, + GlobalVar(Source{{12, 34}}, "a", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::TexelFormat::kRgba8Unorm, - type::Access::kWrite); + builtin::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, - type::Access::kReadWrite, Binding(0_a), Group(0_a)); + builtin::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, - type::Access::kReadWrite, Binding(0_a), Group(0_a)); + builtin::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 ba83fcd5a1..45d56bf377 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, type::Access::kReadWrite, + auto* g = GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, builtin::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 bd0c5ccca5..919722b4ea 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, - type::Access::kReadWrite, Group(0_a), Binding(0_a)); + builtin::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, type::Access::kReadWrite, Group(0_a), + GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kRead, + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kRead, + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); @@ -229,7 +229,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStruct) { 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, - type::Access::kRead, Group(0_a), Binding(0_a)); + builtin::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -247,7 +247,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStructOfArray) { 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, - type::Access::kRead, Group(0_a), Binding(0_a)); + builtin::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -287,8 +287,8 @@ 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, type::Access::kRead, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{12, 34}}, "g", ty.Of(s0), type::AddressSpace::kStorage, + builtin::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( diff --git a/src/tint/resolver/attribute_validation_test.cc b/src/tint/resolver/attribute_validation_test.cc index 2e4084e9a2..85257f96b0 100644 --- a/src/tint/resolver/attribute_validation_test.cc +++ b/src/tint/resolver/attribute_validation_test.cc @@ -735,7 +735,7 @@ TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAFloat) { TEST_F(StructMemberAttributeTest, Align_Attribute_Var) { GlobalVar(Source{{1, 2}}, "val", ty.f32(), type::AddressSpace::kPrivate, - type::Access::kUndefined, Expr(1.23_f)); + builtin::Access::kUndefined, Expr(1.23_f)); Structure(Source{{6, 4}}, "mystruct", utils::Vector{Member(Source{{12, 5}}, "a", ty.f32(), @@ -809,7 +809,7 @@ TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAFloat) { TEST_F(StructMemberAttributeTest, Size_Attribute_Var) { GlobalVar(Source{{1, 2}}, "val", ty.f32(), type::AddressSpace::kPrivate, - type::Access::kUndefined, Expr(1.23_f)); + builtin::Access::kUndefined, Expr(1.23_f)); Structure(Source{{6, 4}}, "mystruct", utils::Vector{Member(Source{{12, 5}}, "a", ty.f32(), @@ -1270,7 +1270,8 @@ 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, type::Access::kRead); + GlobalVar(Source{{12, 34}}, "G", ty.Of(s), type::AddressSpace::kStorage, + builtin::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 e3becab6b8..475fd4d14f 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -215,7 +215,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, type::Access::kRead, Binding(0_a), + GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, builtin::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 22e13c2806..4158bf1b5b 100644 --- a/src/tint/resolver/builtin_validation_test.cc +++ b/src/tint/resolver/builtin_validation_test.cc @@ -581,7 +581,7 @@ TEST_F(ResolverBuiltinValidationTest, WorkgroupUniformLoad_WrongAddressSpace) { // fn foo() { // workgroupUniformLoad(&v); // } - GlobalVar("v", ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite, + GlobalVar("v", ty.i32(), type::AddressSpace::kStorage, builtin::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 64a542cc90..58f479df2d 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, type::Access::kRead, + GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, builtin::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.cc b/src/tint/resolver/dependency_graph.cc index 75e377fcab..37a22449fe 100644 --- a/src/tint/resolver/dependency_graph.cc +++ b/src/tint/resolver/dependency_graph.cc @@ -487,7 +487,7 @@ class DependencyScanner { graph_.resolved_identifiers.Add(from, ResolvedIdentifier(fmt)); return; } - if (auto access = type::ParseAccess(s); access != type::Access::kUndefined) { + if (auto access = builtin::ParseAccess(s); access != builtin::Access::kUndefined) { graph_.resolved_identifiers.Add(from, ResolvedIdentifier(access)); return; } @@ -861,7 +861,7 @@ std::string ResolvedIdentifier::String(const SymbolTable& symbols, diag::List& d if (auto builtin_ty = BuiltinType(); builtin_ty != type::Builtin::kUndefined) { return "builtin type '" + utils::ToString(builtin_ty) + "'"; } - if (auto access = Access(); access != type::Access::kUndefined) { + if (auto access = Access(); access != builtin::Access::kUndefined) { return "access '" + utils::ToString(access) + "'"; } if (auto addr = AddressSpace(); addr != type::AddressSpace::kUndefined) { diff --git a/src/tint/resolver/dependency_graph.h b/src/tint/resolver/dependency_graph.h index 7819b528de..189e7c2a62 100644 --- a/src/tint/resolver/dependency_graph.h +++ b/src/tint/resolver/dependency_graph.h @@ -19,10 +19,10 @@ #include #include "src/tint/ast/module.h" +#include "src/tint/builtin/access.h" #include "src/tint/diagnostic/diagnostic.h" #include "src/tint/sem/builtin_type.h" #include "src/tint/symbol_table.h" -#include "src/tint/type/access.h" #include "src/tint/type/builtin.h" #include "src/tint/type/texel_format.h" #include "src/tint/utils/hashmap.h" @@ -35,7 +35,7 @@ namespace tint::resolver { /// - const ast::Variable* (as const ast::Node*) /// - const ast::Function* (as const ast::Node*) /// - sem::BuiltinType -/// - type::Access +/// - builtin::Access /// - type::AddressSpace /// - type::Builtin /// - type::TexelFormat @@ -68,13 +68,13 @@ class ResolvedIdentifier { return sem::BuiltinType::kNone; } - /// @return the access if the ResolvedIdentifier holds type::Access, otherwise - /// type::Access::kUndefined - type::Access Access() const { - if (auto n = std::get_if(&value_)) { + /// @return the access if the ResolvedIdentifier holds builtin::Access, otherwise + /// builtin::Access::kUndefined + builtin::Access Access() const { + if (auto n = std::get_if(&value_)) { return *n; } - return type::Access::kUndefined; + return builtin::Access::kUndefined; } /// @return the address space if the ResolvedIdentifier holds type::AddressSpace, otherwise @@ -130,7 +130,7 @@ class ResolvedIdentifier { std::variant diff --git a/src/tint/resolver/dependency_graph_test.cc b/src/tint/resolver/dependency_graph_test.cc index a316ad0443..e9ef46bddd 100644 --- a/src/tint/resolver/dependency_graph_test.cc +++ b/src/tint/resolver/dependency_graph_test.cc @@ -1330,7 +1330,7 @@ INSTANTIATE_TEST_SUITE_P(Functions, } // namespace resolve_to_builtin_type //////////////////////////////////////////////////////////////////////////////// -// Resolve to type::Access tests +// Resolve to builtin::Access tests //////////////////////////////////////////////////////////////////////////////// namespace resolve_to_access { @@ -1348,7 +1348,7 @@ TEST_P(ResolverDependencyGraphResolveToAccess, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); - EXPECT_EQ(resolved->Access(), type::ParseAccess(name)) + EXPECT_EQ(resolved->Access(), builtin::ParseAccess(name)) << resolved->String(Symbols(), Diagnostics()); } @@ -1400,17 +1400,17 @@ TEST_P(ResolverDependencyGraphResolveToAccess, ShadowedByFunc) { INSTANTIATE_TEST_SUITE_P(Types, ResolverDependencyGraphResolveToAccess, testing::Combine(testing::ValuesIn(kTypeUseKinds), - testing::ValuesIn(type::kAccessStrings))); + testing::ValuesIn(builtin::kAccessStrings))); INSTANTIATE_TEST_SUITE_P(Values, ResolverDependencyGraphResolveToAccess, testing::Combine(testing::ValuesIn(kValueUseKinds), - testing::ValuesIn(type::kAccessStrings))); + testing::ValuesIn(builtin::kAccessStrings))); INSTANTIATE_TEST_SUITE_P(Functions, ResolverDependencyGraphResolveToAccess, testing::Combine(testing::ValuesIn(kFuncUseKinds), - testing::ValuesIn(type::kAccessStrings))); + testing::ValuesIn(builtin::kAccessStrings))); } // namespace resolve_to_access @@ -1735,7 +1735,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, type::TexelFormat::kR32Float, - type::Access::kRead)); + builtin::Access::kRead)); GlobalVar(Sym(), ty.sampler(type::SamplerKind::kSampler)); GlobalVar(Sym(), ty.i32(), utils::Vector{Binding(V), Group(V)}); diff --git a/src/tint/resolver/expression_kind_test.cc b/src/tint/resolver/expression_kind_test.cc index dc3d8a8d1b..183597133d 100644 --- a/src/tint/resolver/expression_kind_test.cc +++ b/src/tint/resolver/expression_kind_test.cc @@ -125,9 +125,9 @@ TEST_P(ResolverExpressionKindTest, Test) { sym = Sym("write"); check_expr = [](const sem::Expression* expr) { ASSERT_NE(expr, nullptr); - auto* enum_expr = expr->As>(); + auto* enum_expr = expr->As>(); ASSERT_NE(enum_expr, nullptr); - EXPECT_EQ(enum_expr->Value(), type::Access::kWrite); + EXPECT_EQ(enum_expr->Value(), builtin::Access::kWrite); }; break; } diff --git a/src/tint/resolver/host_shareable_validation_test.cc b/src/tint/resolver/host_shareable_validation_test.cc index b518b57570..059a3e5b3b 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, type::Access::kRead, + GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kRead, + GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -62,8 +62,8 @@ TEST_F(ResolverHostShareableValidationTest, Aliases) { auto* s = Structure("S", utils::Vector{Member(Source{{56, 78}}, "x", ty(Source{{12, 34}}, "a1"))}); auto* a2 = Alias("a2", ty.Of(s)); - GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), type::AddressSpace::kStorage, type::Access::kRead, - Binding(0_a), Group(0_a)); + GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), type::AddressSpace::kStorage, + builtin::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, type::Access::kRead, + GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kRead, + GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::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 7cca73683b..7848daabd3 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, type::Access::kRead, + GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, builtin::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 ecaefb20ce..12d07acc3f 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 = type::TexelFormat; -using Access = type::Access; +using Access = builtin::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::kUndefined, type::Access::kUndefined, p.usage)); + type::AddressSpace::kUndefined, builtin::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::kUndefined, type::Access::kUndefined, p.usage)); + type::AddressSpace::kUndefined, builtin::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::kUndefined, - type::Access::kUndefined, match.parameters[0].usage); + builtin::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 c649c468f7..624a208e68 100644 --- a/src/tint/resolver/intrinsic_table_test.cc +++ b/src/tint/resolver/intrinsic_table_test.cc @@ -231,8 +231,8 @@ TEST_F(IntrinsicTableTest, MismatchBool) { TEST_F(IntrinsicTableTest, MatchPointer) { auto* i32 = create(); auto* atomicI32 = create(i32); - auto* ptr = - create(atomicI32, type::AddressSpace::kWorkgroup, type::Access::kReadWrite); + auto* ptr = create(atomicI32, type::AddressSpace::kWorkgroup, + builtin::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, type::Access::kReadWrite); + create(arr, type::AddressSpace::kStorage, builtin::Access::kReadWrite); auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{arr_ptr}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -415,8 +415,9 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) { auto* vec2_i32 = create(i32, 2u); auto* vec4_f32 = create(f32, 4u); auto* subtype = type::StorageTexture::SubtypeFor(type::TexelFormat::kR32Float, Types()); - auto* tex = create( - type::TextureDimension::k2d, type::TexelFormat::kR32Float, type::Access::kWrite, subtype); + auto* tex = + create(type::TextureDimension::k2d, type::TexelFormat::kR32Float, + builtin::Access::kWrite, subtype); auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32}, sem::EvaluationStage::kConstant, Source{}); @@ -445,12 +446,12 @@ TEST_F(IntrinsicTableTest, MismatchTexture) { TEST_F(IntrinsicTableTest, ImplicitLoadOnReference) { auto* f32 = create(); - auto result = table->Lookup( - BuiltinType::kCos, - utils::Vector{ - create(f32, type::AddressSpace::kFunction, type::Access::kReadWrite), - }, - sem::EvaluationStage::kConstant, Source{}); + auto result = table->Lookup(BuiltinType::kCos, + utils::Vector{ + create(f32, type::AddressSpace::kFunction, + builtin::Access::kReadWrite), + }, + sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); ASSERT_EQ(Diagnostics().str(), ""); EXPECT_EQ(result.sem->Type(), BuiltinType::kCos); @@ -549,7 +550,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) { TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) { auto* af = create(); auto* bool_ref = create(create(), type::AddressSpace::kFunction, - type::Access::kReadWrite); + builtin::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 8696900efc..0d6511113a 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, - type::Access::kReadWrite); + builtin::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 bfe64c4a71..af48077c84 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, - type::Access::kReadWrite); + builtin::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 692bd3b513..7f9c9573ca 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(), 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); + EXPECT_EQ(TypeOf(function_ptr)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(private_ptr)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(workgroup_ptr)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(uniform_ptr)->As()->Access(), builtin::Access::kRead); + EXPECT_EQ(TypeOf(storage_ptr)->As()->Access(), builtin::Access::kRead); } } // namespace diff --git a/src/tint/resolver/ptr_ref_validation_test.cc b/src/tint/resolver/ptr_ref_validation_test.cc index 9f6f39054f..078782c156 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, - type::Access::kReadWrite, Binding(0_a), Group(0_a)); + builtin::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 833676577a..5f4e89dee2 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -87,7 +87,7 @@ #include "src/tint/utils/transform.h" #include "src/tint/utils/vector.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression); +TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression); TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression); TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression); @@ -270,12 +270,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::kUndefined, - type::Access::kUndefined, + builtin::Access::kUndefined, /* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt); } else { sem = builder_->create(v, ty, sem::EvaluationStage::kRuntime, type::AddressSpace::kUndefined, - type::Access::kUndefined, current_statement_, + builtin::Access::kUndefined, current_statement_, /* constant_value */ nullptr); } @@ -331,7 +331,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) { auto* sem = builder_->create( v, ty, sem::EvaluationStage::kOverride, type::AddressSpace::kUndefined, - type::Access::kUndefined, + builtin::Access::kUndefined, /* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt); sem->SetInitializer(rhs); @@ -427,10 +427,10 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) { auto* sem = is_global ? static_cast(builder_->create( c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kUndefined, - type::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt)) + builtin::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt)) : static_cast(builder_->create( c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kUndefined, - type::Access::kUndefined, current_statement_, value)); + builtin::Access::kUndefined, current_statement_, value)); sem->SetInitializer(rhs); builder_->Sem().Add(c, sem); @@ -500,7 +500,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { return nullptr; } - auto access = type::Access::kUndefined; + auto access = builtin::Access::kUndefined; if (var->declared_access) { auto expr = AccessExpression(var->declared_access); if (!expr) { @@ -673,7 +673,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) } auto* sem = builder_->create( - param, index, ty, type::AddressSpace::kUndefined, type::Access::kUndefined, + param, index, ty, type::AddressSpace::kUndefined, builtin::Access::kUndefined, sem::ParameterUsage::kNone, binding_point, location); builder_->Sem().Add(param, sem); return sem; @@ -703,17 +703,17 @@ utils::Result Resolver::LocationAttribute(const ast::LocationAttribute return static_cast(value); } -type::Access Resolver::DefaultAccessForAddressSpace(type::AddressSpace address_space) { +builtin::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 type::Access::kRead; + return builtin::Access::kRead; default: break; } - return type::Access::kReadWrite; + return builtin::Access::kReadWrite; } bool Resolver::AllocateOverridableConstantIds() { @@ -1507,7 +1507,8 @@ sem::BuiltinEnumExpression* Resolver::TexelFormatExpression( return sem_.AsTexelFormat(Expression(expr)); } -sem::BuiltinEnumExpression* Resolver::AccessExpression(const ast::Expression* expr) { +sem::BuiltinEnumExpression* Resolver::AccessExpression( + const ast::Expression* expr) { return sem_.AsAccess(Expression(expr)); } @@ -2027,7 +2028,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { static_cast(i), // index arr->ElemType(), // type type::AddressSpace::kUndefined, // address_space - type::Access::kUndefined); + builtin::Access::kUndefined); }); return builder_->create(arr, std::move(params), args_stage); @@ -2056,7 +2057,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { static_cast(i), // index str->Members()[i]->Type(), // type type::AddressSpace::kUndefined, // address_space - type::Access::kUndefined); // access + builtin::Access::kUndefined); // access } return builder_->create(str, std::move(params), args_stage); @@ -2976,9 +2977,9 @@ sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) { return nullptr; } - if (auto access = resolved->Access(); access != type::Access::kUndefined) { - return builder_->create>(expr, current_statement_, - access); + if (auto access = resolved->Access(); access != builtin::Access::kUndefined) { + return builder_->create>( + expr, current_statement_, access); } if (auto addr = resolved->AddressSpace(); addr != type::AddressSpace::kUndefined) { diff --git a/src/tint/resolver/resolver.h b/src/tint/resolver/resolver.h index 003fa3d753..4057f73a64 100644 --- a/src/tint/resolver/resolver.h +++ b/src/tint/resolver/resolver.h @@ -150,10 +150,10 @@ class Resolver { sem::BuiltinEnumExpression* TexelFormatExpression( const ast::Expression* expr); - /// @returns the call of Expression() cast to a sem::BuiltinEnumExpression*. - /// If the sem::Expression is not a sem::BuiltinEnumExpression*, then an error + /// @returns the call of Expression() cast to a sem::BuiltinEnumExpression*. + /// If the sem::Expression is not a sem::BuiltinEnumExpression*, then an error /// diagnostic is raised and nullptr is returned. - sem::BuiltinEnumExpression* AccessExpression(const ast::Expression* expr); + sem::BuiltinEnumExpression* AccessExpression(const ast::Expression* expr); /// Expression traverses the graph of expressions starting at `expr`, building a post-ordered /// list (leaf-first) of all the expression nodes. Each of the expressions are then resolved by @@ -405,7 +405,7 @@ class Resolver { /// @param address_space the address space /// @returns the default access control for the given address space - type::Access DefaultAccessForAddressSpace(type::AddressSpace address_space); + builtin::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 c926f7ac2b..1d14498804 100644 --- a/src/tint/resolver/resolver_test.cc +++ b/src/tint/resolver/resolver_test.cc @@ -921,7 +921,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, - type::Access::kReadWrite, Binding(0_a), Group(0_a)); + builtin::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); @@ -989,7 +989,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, - type::Access::kReadWrite, Binding(0_a), Group(0_a)); + builtin::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); @@ -1913,7 +1913,7 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) { EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_EQ(Sem().Get(var)->Access(), type::Access::kRead); + EXPECT_EQ(Sem().Get(var)->Access(), builtin::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 67d71b8772..7f68f251bd 100644 --- a/src/tint/resolver/resolver_test_helper.h +++ b/src/tint/resolver/resolver_test_helper.h @@ -629,13 +629,13 @@ struct DataType> { /// @return a new AST alias type static inline ast::Type AST(ProgramBuilder& b) { return b.ty.pointer(DataType::AST(b), type::AddressSpace::kPrivate, - type::Access::kUndefined); + builtin::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, - type::Access::kReadWrite); + builtin::Access::kReadWrite); } /// @param b the ProgramBuilder diff --git a/src/tint/resolver/sem_helper.cc b/src/tint/resolver/sem_helper.cc index 01a737cae5..1515812d05 100644 --- a/src/tint/resolver/sem_helper.cc +++ b/src/tint/resolver/sem_helper.cc @@ -74,7 +74,7 @@ void SemHelper::ErrorUnexpectedExprKind(const sem::Expression* expr, fn_expr->Declaration()->source); NoteDeclarationSource(fn); }, - [&](const sem::BuiltinEnumExpression* access) { + [&](const sem::BuiltinEnumExpression* access) { AddError("cannot use access '" + utils::ToString(access->Value()) + "' as " + std::string(wanted), access->Declaration()->source); diff --git a/src/tint/resolver/sem_helper.h b/src/tint/resolver/sem_helper.h index dd752d3ca3..a1de91be22 100644 --- a/src/tint/resolver/sem_helper.h +++ b/src/tint/resolver/sem_helper.h @@ -135,11 +135,11 @@ class SemHelper { /// @param expr the semantic node /// @returns nullptr if @p expr is nullptr, or @p expr cast to - /// sem::BuiltinEnumExpression if the cast is successful, otherwise an error + /// sem::BuiltinEnumExpression if the cast is successful, otherwise an error /// diagnostic is raised. - sem::BuiltinEnumExpression* AsAccess(sem::Expression* expr) const { + sem::BuiltinEnumExpression* AsAccess(sem::Expression* expr) const { if (TINT_LIKELY(expr)) { - auto* enum_expr = expr->As>(); + auto* enum_expr = expr->As>(); if (TINT_LIKELY(enum_expr)) { return enum_expr; } diff --git a/src/tint/resolver/side_effects_test.cc b/src/tint/resolver/side_effects_test.cc index 456b37175d..90fcdb980a 100644 --- a/src/tint/resolver/side_effects_test.cc +++ b/src/tint/resolver/side_effects_test.cc @@ -179,8 +179,8 @@ 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, type::Access::kReadWrite, - Group(0_a), Binding(AInt(next_binding++))); + GlobalVar("a", ty.atomic(ty.i32()), type::AddressSpace::kStorage, + tint::builtin::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), Binding(AInt(next_binding++))); @@ -192,7 +192,7 @@ TEST_P(SideEffectsBuiltinTest, Test) { Group(0_a), Binding(AInt(next_binding++))); GlobalVar("tstorage2d", ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float, - type::Access::kWrite), + tint::builtin::Access::kWrite), Group(0_a), Binding(AInt(next_binding++))); GlobalVar("s2d", ty.sampler(type::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 ae4e544744..1b42e75522 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, type::Access::kRead, Binding(1_a), + GlobalVar("y", ty.Of(s), type::AddressSpace::kStorage, builtin::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 dde1a2e969..f269aa2413 100644 --- a/src/tint/resolver/type_initializer_validation_test.cc +++ b/src/tint/resolver/type_initializer_validation_test.cc @@ -97,8 +97,9 @@ 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, type::Access::kReadWrite); + auto* expected = + create(params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, + builtin::Access::kReadWrite); ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n" << "expected: " << FriendlyName(expected) << "\n"; } @@ -151,8 +152,9 @@ 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, type::Access::kReadWrite); + auto* expected = + create(params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, + builtin::Access::kReadWrite); ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n" << "expected: " << FriendlyName(expected) << "\n"; } @@ -199,8 +201,9 @@ 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, type::Access::kReadWrite); + auto* expected = + create(params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, + builtin::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 efc55f0b28..8559b9a143 100644 --- a/src/tint/resolver/type_validation_test.cc +++ b/src/tint/resolver/type_validation_test.cc @@ -1066,7 +1066,7 @@ TEST_P(StorageTextureDimensionTest, All) { auto& params = GetParam(); auto st = ty(Source{{12, 34}}, params.name, utils::ToString(type::TexelFormat::kR32Uint), - utils::ToString(type::Access::kWrite)); + utils::ToString(builtin::Access::kWrite)); GlobalVar("a", st, Group(0_a), Binding(0_a)); @@ -1117,19 +1117,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, - type::Access::kWrite); + builtin::Access::kWrite); GlobalVar("a", st_a, Group(0_a), Binding(0_a)); ast::Type st_b = - ty.storage_texture(type::TextureDimension::k2d, params.format, type::Access::kWrite); + ty.storage_texture(type::TextureDimension::k2d, params.format, builtin::Access::kWrite); GlobalVar("b", st_b, Group(0_a), Binding(1_a)); - ast::Type st_c = - ty.storage_texture(type::TextureDimension::k2dArray, params.format, type::Access::kWrite); + ast::Type st_c = ty.storage_texture(type::TextureDimension::k2dArray, params.format, + builtin::Access::kWrite); GlobalVar("c", st_c, Group(0_a), Binding(2_a)); ast::Type st_d = - ty.storage_texture(type::TextureDimension::k3d, params.format, type::Access::kWrite); + ty.storage_texture(type::TextureDimension::k3d, params.format, builtin::Access::kWrite); GlobalVar("d", st_d, Group(0_a), Binding(3_a)); if (params.is_valid) { @@ -1176,7 +1176,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) { // var a : texture_storage_1d; auto st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, - type::TexelFormat::kR32Uint, type::Access::kReadWrite); + type::TexelFormat::kR32Uint, builtin::Access::kReadWrite); GlobalVar("a", st, Group(0_a), Binding(0_a)); @@ -1190,7 +1190,7 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) { // var a : texture_storage_1d; auto st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, - type::TexelFormat::kR32Uint, type::Access::kRead); + type::TexelFormat::kR32Uint, builtin::Access::kRead); GlobalVar("a", st, Group(0_a), Binding(0_a)); @@ -1204,7 +1204,7 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) { // var a : texture_storage_1d; auto st = ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kR32Uint, - type::Access::kWrite); + builtin::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 61e0dad810..1fe67c8de2 100644 --- a/src/tint/resolver/uniformity.cc +++ b/src/tint/resolver/uniformity.cc @@ -1211,7 +1211,7 @@ class UniformityGraph { [&](const sem::GlobalVariable* global) { // Loads from global read-write variables may be non-uniform. if (global->Declaration()->Is() && - global->Access() != type::Access::kRead && load_rule) { + global->Access() != builtin::Access::kRead && load_rule) { node->AddEdge(current_function_->may_be_non_uniform); } else { node->AddEdge(cf); @@ -1228,7 +1228,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() != type::Access::kRead) { + if (root->Access() != builtin::Access::kRead) { // The contents of a mutable global variable is always non-uniform. node->AddEdge(current_function_->may_be_non_uniform); } @@ -1473,7 +1473,7 @@ class UniformityGraph { auto* root = sem_arg->RootIdentifier(); if (root->Is()) { - if (root->Access() != type::Access::kRead) { + if (root->Access() != builtin::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 2935c70c24..c7f790be90 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -311,9 +311,9 @@ bool Validator::Pointer(const ast::TemplatedIdentifier* a, const type::Pointer* bool Validator::StorageTexture(const type::StorageTexture* t, const Source& source) const { switch (t->access()) { - case type::Access::kWrite: + case builtin::Access::kWrite: break; - case type::Access::kUndefined: + case builtin::Access::kUndefined: AddError("storage texture missing access control", source); return false; default: @@ -2373,7 +2373,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() == type::Access::kRead) { + if (lhs_ref->Access() == builtin::Access::kRead) { AddError("cannot store into a read-only type '" + sem_.RawTypeNameOf(lhs_ty) + "'", a->source); return false; @@ -2414,7 +2414,7 @@ bool Validator::IncrementDecrementStatement(const ast::IncrementDecrementStateme return false; } - if (lhs_ref->Access() == type::Access::kRead) { + if (lhs_ref->Access() == builtin::Access::kRead) { AddError("cannot modify read-only type '" + sem_.RawTypeNameOf(lhs_ty) + "'", inc->source); return false; } @@ -2505,7 +2505,7 @@ std::string Validator::VectorPretty(uint32_t size, const type::Type* element_typ bool Validator::CheckTypeAccessAddressSpace( const type::Type* store_ty, - type::Access access, + builtin::Access access, type::AddressSpace address_space, utils::VectorRef attributes, const Source& source) const { @@ -2523,7 +2523,7 @@ bool Validator::CheckTypeAccessAddressSpace( return false; } - if (address_space == type::AddressSpace::kStorage && access == type::Access::kWrite) { + if (address_space == type::AddressSpace::kStorage && access == builtin::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); @@ -2535,7 +2535,8 @@ bool Validator::CheckTypeAccessAddressSpace( address_space != type::AddressSpace::kWorkgroup) { return "atomic variables must have or address space"; } - if (address_space == type::AddressSpace::kStorage && access != type::Access::kReadWrite) { + if (address_space == type::AddressSpace::kStorage && + access != builtin::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 499dcdac72..55be986a43 100644 --- a/src/tint/resolver/validator.h +++ b/src/tint/resolver/validator.h @@ -542,7 +542,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, - type::Access access, + builtin::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 6c1fce4d9b..558953e497 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, - type::Access::kReadWrite); + builtin::Access::kReadWrite); EXPECT_FALSE(v()->IsStorable(ptr)); } diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc index 2239945062..dbfc94fc10 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(), 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_EQ(TypeOf(i)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(u)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(f)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(b)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(s)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(a)->As()->Access(), builtin::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, - type::Access::kReadWrite, Binding(0_a), Group(0_a)); + builtin::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(), type::Access::kReadWrite); - EXPECT_EQ(TypeOf(ptr)->As()->Access(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(expr)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(ptr)->As()->Access(), builtin::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(), 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); + EXPECT_EQ(TypeOf(private_)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(workgroup)->As()->Access(), builtin::Access::kReadWrite); + EXPECT_EQ(TypeOf(uniform)->As()->Access(), builtin::Access::kRead); + EXPECT_EQ(TypeOf(storage)->As()->Access(), builtin::Access::kRead); + EXPECT_EQ(TypeOf(handle)->As()->Access(), builtin::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, - type::Access::kReadWrite, Binding(1_a), Group(0_a)); + builtin::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(), type::Access::kReadWrite); + EXPECT_EQ(TypeOf(storage)->As()->Access(), builtin::Access::kReadWrite); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/tint/resolver/variable_validation_test.cc b/src/tint/resolver/variable_validation_test.cc index 3898d1534f..1d0837d141 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, type::Access::kReadWrite), + ty.pointer(type::AddressSpace::kStorage, builtin::Access::kReadWrite), AddressOf(expr)); WrapInFunction(ptr); diff --git a/src/tint/sem/variable.cc b/src/tint/sem/variable.cc index 6dc327d7f0..e3f5f75268 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, - type::Access access, + builtin::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, - type::Access access, + builtin::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, - type::Access access, + builtin::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, - type::Access access, + builtin::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 afaa0d1d7c..fcaf1455fe 100644 --- a/src/tint/sem/variable.h +++ b/src/tint/sem/variable.h @@ -22,10 +22,10 @@ #include "tint/override_id.h" #include "src/tint/ast/parameter.h" +#include "src/tint/builtin/access.h" #include "src/tint/sem/binding_point.h" #include "src/tint/sem/parameter_usage.h" #include "src/tint/sem/value_expression.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, - type::Access access, + builtin::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 - type::Access Access() const { return access_; } + builtin::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 type::Access access_; + const builtin::Access access_; const constant::Value* constant_value_; const ValueExpression* initializer_ = nullptr; std::vector users_; @@ -122,7 +122,7 @@ class LocalVariable final : public Castable { const type::Type* type, EvaluationStage stage, type::AddressSpace address_space, - type::Access access, + builtin::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, - type::Access access, + builtin::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, - type::Access access, + builtin::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 192b2c93fd..e4f2e6e692 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()) { - type::Access access = ac_it->second; - if (access == type::Access::kUndefined) { + builtin::Access access = ac_it->second; + if (access == builtin::Access::kUndefined) { b.Diagnostics().add_error(diag::System::Transform, "invalid access mode (" + std::to_string(static_cast(access)) + diff --git a/src/tint/transform/binding_remapper.h b/src/tint/transform/binding_remapper.h index e0f48b3568..8fdba2a208 100644 --- a/src/tint/transform/binding_remapper.h +++ b/src/tint/transform/binding_remapper.h @@ -17,9 +17,9 @@ #include +#include "src/tint/builtin/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 5bed528ca5..b4b7b29be9 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}, type::Access::kWrite}, + {{2, 1}, builtin::Access::kWrite}, }); EXPECT_TRUE(ShouldRun(src, data)); @@ -162,9 +162,9 @@ fn f() { data.Add( BindingRemapper::BindingPoints{}, BindingRemapper::AccessControls{ - {{2, 1}, type::Access::kReadWrite}, // Modify access control + {{2, 1}, builtin::Access::kReadWrite}, // Modify access control // Keep @group(3) @binding(2) as is - {{4, 3}, type::Access::kRead}, // Add access control + {{4, 3}, builtin::Access::kRead}, // Add access control }); auto got = Run(src, data); @@ -207,8 +207,8 @@ fn f() { {{3, 2}, {6, 7}}, }, BindingRemapper::AccessControls{ - {{2, 1}, type::Access::kReadWrite}, - {{3, 2}, type::Access::kReadWrite}, + {{2, 1}, builtin::Access::kReadWrite}, + {{3, 2}, builtin::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 072c9c6661..47cefcf1f7 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -109,7 +109,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 - type::Access const access; // buffer access + builtin::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 { @@ -125,7 +125,7 @@ struct LoadStoreKey { /// AtomicKey is the unordered map key to an atomic intrinsic. struct AtomicKey { - type::Access const access; // buffer access + builtin::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 @@ -466,7 +466,7 @@ struct DecomposeMemoryAccess::State { auto address_space = var_user->Variable()->AddressSpace(); auto access = var_user->Variable()->Access(); if (address_space != type::AddressSpace::kStorage) { - access = type::Access::kUndefined; + access = builtin::Access::kUndefined; } return utils::GetOrCreate( load_funcs, LoadStoreKey{address_space, access, buf_ty, el_ty}, [&] { @@ -562,7 +562,7 @@ struct DecomposeMemoryAccess::State { auto address_space = var_user->Variable()->AddressSpace(); auto access = var_user->Variable()->Access(); if (address_space != type::AddressSpace::kStorage) { - access = type::Access::kUndefined; + access = builtin::Access::kUndefined; } return utils::GetOrCreate( store_funcs, LoadStoreKey{address_space, access, buf_ty, el_ty}, [&] { @@ -672,7 +672,7 @@ struct DecomposeMemoryAccess::State { auto address_space = var_user->Variable()->AddressSpace(); auto access = var_user->Variable()->Access(); if (address_space != type::AddressSpace::kStorage) { - access = type::Access::kUndefined; + access = builtin::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 72bc1b1a7b..bd4b49ffdd 100644 --- a/src/tint/transform/decompose_strided_array_test.cc +++ b/src/tint/transform/decompose_strided_array_test.cc @@ -396,7 +396,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) { auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(utils::Vector{ b.Stride(32), }))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -458,7 +458,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) { b.Stride(4), })), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -516,7 +516,7 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) { auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(utils::Vector{ b.Stride(32), }))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -582,7 +582,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) { b.Stride(32), })); auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR"))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -658,7 +658,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) { b.Stride(128), })); auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR_B"))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::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 e097acb645..0da9e71afb 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, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::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, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::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, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::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, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::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, type::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::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 ba30933291..1dbd2afad0 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, - type::Access::kReadWrite)), + builtin::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 15f4674568..65ec7316cc 100644 --- a/src/tint/transform/promote_side_effects_to_decl.cc +++ b/src/tint/transform/promote_side_effects_to_decl.cc @@ -284,7 +284,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() == type::Access::kRead) { + if (var_user->Variable()->Access() == builtin::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/renamer_test.cc b/src/tint/transform/renamer_test.cc index 2d13436ccd..d4b681cda2 100644 --- a/src/tint/transform/renamer_test.cc +++ b/src/tint/transform/renamer_test.cc @@ -1934,7 +1934,7 @@ std::vector Identifiers() { for (auto* ident : type::kTexelFormatStrings) { out.push_back(ident); } - for (auto* ident : type::kAccessStrings) { + for (auto* ident : builtin::kAccessStrings) { out.push_back(ident); } return out; diff --git a/src/tint/transform/vertex_pulling.cc b/src/tint/transform/vertex_pulling.cc index 8d151bf37f..6a1b5b4506 100644 --- a/src/tint/transform/vertex_pulling.cc +++ b/src/tint/transform/vertex_pulling.cc @@ -322,7 +322,8 @@ 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, - type::Access::kRead, b.Binding(AInt(i)), b.Group(AInt(cfg.pulling_group))); + builtin::Access::kRead, b.Binding(AInt(i)), + b.Group(AInt(cfg.pulling_group))); } } diff --git a/src/tint/type/pointer.cc b/src/tint/type/pointer.cc index 3dcb0788a4..1175961f0f 100644 --- a/src/tint/type/pointer.cc +++ b/src/tint/type/pointer.cc @@ -24,14 +24,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Pointer); namespace tint::type { -Pointer::Pointer(const Type* subtype, type::AddressSpace address_space, type::Access access) +Pointer::Pointer(const Type* subtype, type::AddressSpace address_space, builtin::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 != type::Access::kUndefined); + TINT_ASSERT(Type, access != builtin::Access::kUndefined); } bool Pointer::Equals(const UniqueNode& other) const { diff --git a/src/tint/type/pointer.h b/src/tint/type/pointer.h index 61eab7676c..8a4d1c9340 100644 --- a/src/tint/type/pointer.h +++ b/src/tint/type/pointer.h @@ -17,7 +17,7 @@ #include -#include "src/tint/type/access.h" +#include "src/tint/builtin/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, type::Access access); + Pointer(const Type* subtype, type::AddressSpace address_space, builtin::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 - type::Access Access() const { return access_; } + builtin::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_; - type::Access const access_; + builtin::Access const access_; }; } // namespace tint::type diff --git a/src/tint/type/pointer_test.cc b/src/tint/type/pointer_test.cc index a0c8bbbfaa..932548ae1c 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, 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); + auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* c = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* d = create(create(), AddressSpace::kPrivate, builtin::Access::kReadWrite); + auto* e = create(create(), AddressSpace::kStorage, builtin::Access::kRead); EXPECT_TRUE(a->StoreType()->Is()); EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage); - EXPECT_EQ(a->Access(), type::Access::kReadWrite); + EXPECT_EQ(a->Access(), builtin::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, type::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); EXPECT_EQ(a->unique_hash, b->unique_hash); } TEST_F(PointerTest, Equals) { - 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); + auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* c = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* d = create(create(), AddressSpace::kPrivate, builtin::Access::kReadWrite); + auto* e = create(create(), AddressSpace::kStorage, builtin::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::kUndefined, type::Access::kRead); + auto* r = create(create(), AddressSpace::kUndefined, builtin::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); } TEST_F(PointerTest, FriendlyNameWithAddressSpace) { - auto* r = create(create(), AddressSpace::kWorkgroup, type::Access::kRead); + auto* r = create(create(), AddressSpace::kWorkgroup, builtin::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); } TEST_F(PointerTest, Clone) { - auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* a = create(create(), AddressSpace::kStorage, builtin::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(), type::Access::kReadWrite); + EXPECT_EQ(ptr->Access(), builtin::Access::kReadWrite); } } // namespace diff --git a/src/tint/type/reference.cc b/src/tint/type/reference.cc index 6a7e2c6caf..ca676ccedb 100644 --- a/src/tint/type/reference.cc +++ b/src/tint/type/reference.cc @@ -23,14 +23,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Reference); namespace tint::type { -Reference::Reference(const Type* subtype, type::AddressSpace address_space, type::Access access) +Reference::Reference(const Type* subtype, type::AddressSpace address_space, builtin::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 != type::Access::kUndefined); + TINT_ASSERT(Type, access != builtin::Access::kUndefined); } bool Reference::Equals(const UniqueNode& other) const { diff --git a/src/tint/type/reference.h b/src/tint/type/reference.h index 1999880570..b1981ab059 100644 --- a/src/tint/type/reference.h +++ b/src/tint/type/reference.h @@ -17,7 +17,7 @@ #include -#include "src/tint/type/access.h" +#include "src/tint/builtin/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, type::Access access); + Reference(const Type* subtype, type::AddressSpace address_space, builtin::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. - type::Access Access() const { return access_; } + builtin::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_; - type::Access const access_; + builtin::Access const access_; }; } // namespace tint::type diff --git a/src/tint/type/reference_test.cc b/src/tint/type/reference_test.cc index ceee77fa72..65dde2bd9a 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, 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); + auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* c = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* d = create(create(), AddressSpace::kPrivate, builtin::Access::kReadWrite); + auto* e = create(create(), AddressSpace::kStorage, builtin::Access::kRead); EXPECT_TRUE(a->StoreType()->Is()); EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage); - EXPECT_EQ(a->Access(), type::Access::kReadWrite); + EXPECT_EQ(a->Access(), builtin::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, type::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); EXPECT_EQ(a->unique_hash, b->unique_hash); } TEST_F(ReferenceTest, Equals) { - 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); + auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* c = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* d = create(create(), AddressSpace::kPrivate, builtin::Access::kReadWrite); + auto* e = create(create(), AddressSpace::kStorage, builtin::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::kUndefined, type::Access::kRead); + auto* r = create(create(), AddressSpace::kUndefined, builtin::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); } TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) { - auto* r = create(create(), AddressSpace::kWorkgroup, type::Access::kRead); + auto* r = create(create(), AddressSpace::kWorkgroup, builtin::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); } TEST_F(ReferenceTest, Clone) { - auto* a = create(create(), AddressSpace::kStorage, type::Access::kReadWrite); + auto* a = create(create(), AddressSpace::kStorage, builtin::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(), type::Access::kReadWrite); + EXPECT_EQ(ref->Access(), builtin::Access::kReadWrite); } } // namespace diff --git a/src/tint/type/storage_texture.cc b/src/tint/type/storage_texture.cc index 25beb74747..c7fede40d2 100644 --- a/src/tint/type/storage_texture.cc +++ b/src/tint/type/storage_texture.cc @@ -26,7 +26,7 @@ namespace tint::type { StorageTexture::StorageTexture(TextureDimension dim, type::TexelFormat format, - type::Access access, + builtin::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 6e9690785f..62086ee41a 100644 --- a/src/tint/type/storage_texture.h +++ b/src/tint/type/storage_texture.h @@ -17,7 +17,7 @@ #include -#include "src/tint/type/access.h" +#include "src/tint/builtin/access.h" #include "src/tint/type/texel_format.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, type::TexelFormat format, - type::Access access, + builtin::Access access, Type* subtype); /// Destructor @@ -56,7 +56,7 @@ class StorageTexture final : public Castable { type::TexelFormat texel_format() const { return texel_format_; } /// @returns the access control - type::Access access() const { return access_; } + builtin::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: type::TexelFormat const texel_format_; - type::Access const access_; + builtin::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 2ffc0b7b5c..9a1b8c6799 100644 --- a/src/tint/type/storage_texture_test.cc +++ b/src/tint/type/storage_texture_test.cc @@ -24,22 +24,23 @@ namespace tint::type { namespace { struct StorageTextureTest : public TestHelper { - StorageTexture* Create(TextureDimension dims, type::TexelFormat fmt, type::Access access) { + StorageTexture* Create(TextureDimension dims, type::TexelFormat fmt, builtin::Access access) { auto* subtype = StorageTexture::SubtypeFor(fmt, Types()); return create(dims, fmt, access, subtype); } }; TEST_F(StorageTextureTest, Creation) { - auto* a = - Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite); - auto* b = - Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite); + auto* a = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, + builtin::Access::kReadWrite); + auto* b = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, + builtin::Access::kReadWrite); auto* c = - Create(TextureDimension::k2d, type::TexelFormat::kRgba32Float, type::Access::kReadWrite); + Create(TextureDimension::k2d, type::TexelFormat::kRgba32Float, builtin::Access::kReadWrite); auto* d = - Create(TextureDimension::kCube, type::TexelFormat::kR32Float, type::Access::kReadWrite); - auto* e = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kRead); + Create(TextureDimension::kCube, type::TexelFormat::kR32Float, builtin::Access::kReadWrite); + auto* e = + Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, builtin::Access::kRead); EXPECT_TRUE(a->type()->Is()); EXPECT_EQ(a->dim(), TextureDimension::kCube); @@ -51,24 +52,25 @@ TEST_F(StorageTextureTest, Creation) { } TEST_F(StorageTextureTest, Hash) { - auto* a = - Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite); - auto* b = - Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite); + auto* a = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, + builtin::Access::kReadWrite); + auto* b = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, + builtin::Access::kReadWrite); EXPECT_EQ(a->unique_hash, b->unique_hash); } TEST_F(StorageTextureTest, Equals) { - auto* a = - Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite); - auto* b = - Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite); + auto* a = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, + builtin::Access::kReadWrite); + auto* b = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, + builtin::Access::kReadWrite); auto* c = - Create(TextureDimension::k2d, type::TexelFormat::kRgba32Float, type::Access::kReadWrite); + Create(TextureDimension::k2d, type::TexelFormat::kRgba32Float, builtin::Access::kReadWrite); auto* d = - Create(TextureDimension::kCube, type::TexelFormat::kR32Float, type::Access::kReadWrite); - auto* e = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kRead); + Create(TextureDimension::kCube, type::TexelFormat::kR32Float, builtin::Access::kReadWrite); + auto* e = + Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, builtin::Access::kRead); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); @@ -79,25 +81,25 @@ TEST_F(StorageTextureTest, Equals) { TEST_F(StorageTextureTest, Dim) { auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float, - type::Access::kReadWrite); + builtin::Access::kReadWrite); EXPECT_EQ(s->dim(), TextureDimension::k2dArray); } TEST_F(StorageTextureTest, Format) { auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float, - type::Access::kReadWrite); + builtin::Access::kReadWrite); EXPECT_EQ(s->texel_format(), type::TexelFormat::kRgba32Float); } TEST_F(StorageTextureTest, FriendlyName) { auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float, - type::Access::kReadWrite); + builtin::Access::kReadWrite); EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array"); } TEST_F(StorageTextureTest, F32) { auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float, - type::Access::kReadWrite); + builtin::Access::kReadWrite); auto program = Build(); @@ -110,7 +112,7 @@ TEST_F(StorageTextureTest, F32) { TEST_F(StorageTextureTest, U32) { auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRg32Uint, Types()); auto* s = create(TextureDimension::k2dArray, type::TexelFormat::kRg32Uint, - type::Access::kReadWrite, subtype); + builtin::Access::kReadWrite, subtype); auto program = Build(); @@ -123,7 +125,7 @@ TEST_F(StorageTextureTest, U32) { TEST_F(StorageTextureTest, I32) { auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRgba32Sint, Types()); auto* s = create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Sint, - type::Access::kReadWrite, subtype); + builtin::Access::kReadWrite, subtype); auto program = Build(); @@ -134,8 +136,8 @@ TEST_F(StorageTextureTest, I32) { } TEST_F(StorageTextureTest, Clone) { - auto* a = - Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, type::Access::kReadWrite); + auto* a = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, + builtin::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 62ec7061ff..f6adb9378a 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, type::Access::kReadWrite); + create(u32, AddressSpace::kPrivate, builtin::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 e702c901ba..53f11dbe67 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::kUndefined, type::Access::kUndefined), + type::AddressSpace::kUndefined, builtin::Access::kUndefined), sem::EvaluationStage::kRuntime); auto* scalar_cast_sem = b->create( scalar_cast_ast, scalar_cast_target, sem::EvaluationStage::kRuntime, @@ -160,7 +160,7 @@ const sem::Call* AppendVector(ProgramBuilder* b, [&](const tint::sem::ValueExpression* arg, size_t i) -> const sem::Parameter* { return b->create( nullptr, static_cast(i), arg->Type()->UnwrapRef(), - type::AddressSpace::kUndefined, type::Access::kUndefined); + type::AddressSpace::kUndefined, builtin::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 0464742142..3b0c7a6d73 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, type::Access::kRead, + b.GlobalVar("buffer3", b.ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead, b.Group(2_a), b.Binding(2_a)); const size_t num_samplers = 2; @@ -103,7 +103,7 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) { b.Group(6_a), b.Binding(6_a)); b.GlobalVar("texture3", b.ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float, - type::Access::kWrite), + builtin::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 60d5aa17c3..4d31bdf152 100644 --- a/src/tint/writer/glsl/generator.h +++ b/src/tint/writer/glsl/generator.h @@ -22,9 +22,9 @@ #include #include "src/tint/ast/pipeline_stage.h" +#include "src/tint/builtin/access.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 cd8639a603..76a0d18753 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::kUndefined, type::Access::kReadWrite, + if (!EmitType(out, dst_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -438,12 +438,14 @@ 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::kUndefined, type::Access::kReadWrite, "")) { + if (!EmitType(out, bool_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + "")) { return false; } ScopedParen outerCastParen(out); // Cast LHS to uint scalar or vector type. - if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) { + if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + "")) { return false; } { @@ -463,7 +465,8 @@ 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::kUndefined, type::Access::kReadWrite, "")) { + if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + "")) { return false; } { @@ -491,20 +494,20 @@ bool GeneratorImpl::EmitFloatModulo(std::ostream& out, const ast::BinaryExpressi { auto decl = line(&b); if (!EmitTypeAndName(decl, ret_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, fn_name)) { + builtin::Access::kUndefined, fn_name)) { return ""; } { ScopedParen sp(decl); const auto* ty = TypeOf(expr->lhs)->UnwrapRef(); if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "lhs")) { + builtin::Access::kUndefined, "lhs")) { return ""; } decl << ", "; ty = TypeOf(expr->rhs)->UnwrapRef(); if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "rhs")) { + builtin::Access::kUndefined, "rhs")) { return ""; } } @@ -827,7 +830,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::kUndefined, type::Access::kReadWrite, + if (!EmitType(out, conv->Target(), type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -851,7 +854,7 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out, return EmitZeroValue(out, type); } - if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -922,7 +925,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, { auto pre = line(); if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, result)) { + builtin::Access::kUndefined, result)) { return false; } pre << ";"; @@ -1060,7 +1063,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::kUndefined, - type::Access::kReadWrite, "")) { + builtin::Access::kReadWrite, "")) { return false; } out << "(bitCount("; @@ -1132,7 +1135,7 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out, { std::stringstream s; if (!EmitType(s, vec_ty->type(), type::AddressSpace::kUndefined, - type::Access::kRead, "")) { + builtin::Access::kRead, "")) { return ""; } v = s.str(); @@ -1140,15 +1143,17 @@ 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::kUndefined, - type::Access::kRead, "")) { + builtin::Access::kRead, "")) { return ""; } l << " " << fn_name << "("; - if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, type::Access::kRead, "")) { + if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, builtin::Access::kRead, + "")) { return ""; } l << " a, "; - if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, type::Access::kRead, "")) { + if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, builtin::Access::kRead, + "")) { return ""; } l << " b) {"; @@ -1200,7 +1205,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out, { auto l = line(b); if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, "")) { + builtin::Access::kUndefined, "")) { return false; } l << " result;"; @@ -1226,7 +1231,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out, { auto l = line(b); if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, "")) { + builtin::Access::kUndefined, "")) { return false; } l << " result;"; @@ -1884,7 +1889,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { auto out = line(); auto name = builder_.Symbols().NameFor(func->name->symbol); if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "")) { + builtin::Access::kReadWrite, "")) { return false; } @@ -2261,7 +2266,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { { auto out = line(); if (!EmitTypeAndName(out, func_sem->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, + builtin::Access::kUndefined, builder_.Symbols().NameFor(func->name->symbol))) { return false; } @@ -2341,7 +2346,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const return true; }, [&](const type::Vector* v) { - if (!EmitType(out, v, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) { + if (!EmitType(out, v, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + "")) { return false; } @@ -2362,7 +2368,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const return true; }, [&](const type::Matrix* m) { - if (!EmitType(out, m, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) { + if (!EmitType(out, m, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + "")) { return false; } @@ -2379,7 +2386,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const return true; }, [&](const type::Array* a) { - if (!EmitType(out, a, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) { + if (!EmitType(out, a, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + "")) { return false; } @@ -2471,7 +2479,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::kUndefined, type::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -2484,7 +2492,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { } } } else if (auto* mat = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -2497,7 +2505,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { } } } else if (auto* str = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) { + if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } bool first = true; @@ -2511,7 +2519,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::kUndefined, type::Access::kUndefined, "")) { + if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } ScopedParen sp(out); @@ -2837,7 +2845,7 @@ bool GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) { bool GeneratorImpl::EmitType(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - type::Access access, + builtin::Access access, const std::string& name, bool* name_printed /* = nullptr */) { if (name_printed) { @@ -2934,7 +2942,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, out << "highp "; - if (storage && storage->access() != type::Access::kRead) { + if (storage && storage->access() != builtin::Access::kRead) { out << "writeonly "; } auto* subtype = sampled ? sampled->type() @@ -3018,7 +3026,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, bool GeneratorImpl::EmitTypeAndName(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - type::Access access, + builtin::Access access, const std::string& name) { bool printed_name = false; if (!EmitType(out, type, address_space, access, name, &printed_name)) { @@ -3054,7 +3062,7 @@ bool GeneratorImpl::EmitStructMembers(TextBuffer* b, const sem::Struct* str) { auto out = line(b); - if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, type::Access::kReadWrite, + if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, name)) { return false; } @@ -3123,7 +3131,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { auto out = line(); // TODO(senorblanco): handle const - if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined, + if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, builder_.Symbols().NameFor(let->name->symbol))) { return false; } @@ -3145,7 +3153,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) { auto out = line(); out << "const "; - if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined, + if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, builder_.Symbols().NameFor(var->name->symbol))) { return false; } @@ -3173,7 +3181,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, { auto decl = line(&b); if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, fn_name)) { + builtin::Access::kUndefined, fn_name)) { return ""; } { @@ -3189,7 +3197,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, ty = ptr->StoreType(); } if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, param_name)) { + builtin::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 71fb23e980..d01500012e 100644 --- a/src/tint/writer/glsl/generator_impl.h +++ b/src/tint/writer/glsl/generator_impl.h @@ -415,7 +415,7 @@ class GeneratorImpl : public TextGenerator { bool EmitType(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - type::Access access, + builtin::Access access, const std::string& name, bool* name_printed = nullptr); /// Handles generating type and name @@ -428,7 +428,7 @@ class GeneratorImpl : public TextGenerator { bool EmitTypeAndName(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - type::Access access, + builtin::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 2d1ed02d48..be96c9bca6 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, type::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kRead, Binding(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{Param("param", ty.f32())}, ty.f32(), @@ -879,7 +879,7 @@ 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, type::Access::kReadWrite, + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); { 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 1023ad0058..37005e8464 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, type::Access::kReadWrite, + b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, builtin::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 051d8e0ac3..cd4d821b15 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())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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 1f1c8a6795..72c5048c3a 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(ty), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "ary")) + builtin::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(ty), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "ary")) + builtin::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(ty), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "ary")) + builtin::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(ty), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "")) + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool[4]"); } @@ -91,7 +91,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, bool_, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, bool_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool"); } @@ -103,7 +103,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, f32, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, f32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float"); } @@ -117,7 +117,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, f16, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, f16, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float16_t"); } @@ -129,7 +129,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, i32, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, i32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "int"); } @@ -143,7 +143,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "mat2x3"); } @@ -159,7 +159,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "f16mat2x3"); } @@ -196,7 +196,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::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, sem_s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "S"); } @@ -245,7 +245,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, u32, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, u32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "uint"); } @@ -258,7 +258,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, vec3, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, vec3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "vec3"); } @@ -273,7 +273,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, vec3, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, vec3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "f16vec3"); } @@ -285,7 +285,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, void_, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, void_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "void"); } @@ -297,7 +297,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSampler) { std::stringstream out; ASSERT_FALSE( - gen.EmitType(out, sampler, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); } @@ -308,7 +308,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) { std::stringstream out; ASSERT_FALSE( - gen.EmitType(out, sampler, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); } @@ -514,7 +514,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, s, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + ASSERT_TRUE( + gen.EmitType(out, s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "highp sampler2DMS"); } @@ -531,7 +532,7 @@ using GlslStorageTexturesTest = TestParamHelper; TEST_P(GlslStorageTexturesTest, Emit) { auto params = GetParam(); - auto t = ty.storage_texture(params.dim, params.imgfmt, type::Access::kWrite); + auto t = ty.storage_texture(params.dim, params.imgfmt, builtin::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 df7de5cbed..f75cf06575 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -377,8 +377,8 @@ bool GeneratorImpl::EmitDynamicVectorAssignment(const ast::AssignmentStatement* std::string fn; { std::ostringstream ss; - if (!EmitType(ss, vec, tint::type::AddressSpace::kUndefined, type::Access::kUndefined, - "")) { + if (!EmitType(ss, vec, tint::type::AddressSpace::kUndefined, + builtin::Access::kUndefined, "")) { return ""; } fn = UniqueIdentifier("set_" + ss.str()); @@ -386,13 +386,13 @@ bool GeneratorImpl::EmitDynamicVectorAssignment(const ast::AssignmentStatement* { auto out = line(&helpers_); out << "void " << fn << "(inout "; - if (!EmitTypeAndName(out, vec, type::AddressSpace::kUndefined, type::Access::kUndefined, - "vec")) { + if (!EmitTypeAndName(out, vec, type::AddressSpace::kUndefined, + builtin::Access::kUndefined, "vec")) { return ""; } out << ", int idx, "; if (!EmitTypeAndName(out, vec->type(), type::AddressSpace::kUndefined, - type::Access::kUndefined, "val")) { + builtin::Access::kUndefined, "val")) { return ""; } out << ") {"; @@ -451,8 +451,8 @@ bool GeneratorImpl::EmitDynamicMatrixVectorAssignment(const ast::AssignmentState std::string fn; { std::ostringstream ss; - if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, type::Access::kUndefined, - "")) { + if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, + builtin::Access::kUndefined, "")) { return ""; } fn = UniqueIdentifier("set_vector_" + ss.str()); @@ -460,13 +460,13 @@ bool GeneratorImpl::EmitDynamicMatrixVectorAssignment(const ast::AssignmentState { auto out = line(&helpers_); out << "void " << fn << "(inout "; - if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, type::Access::kUndefined, - "mat")) { + if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, + builtin::Access::kUndefined, "mat")) { return ""; } out << ", int col, "; if (!EmitTypeAndName(out, mat->ColumnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, "val")) { + builtin::Access::kUndefined, "val")) { return ""; } out << ") {"; @@ -520,8 +520,8 @@ bool GeneratorImpl::EmitDynamicMatrixScalarAssignment(const ast::AssignmentState std::string fn; { std::ostringstream ss; - if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, type::Access::kUndefined, - "")) { + if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, + builtin::Access::kUndefined, "")) { return ""; } fn = UniqueIdentifier("set_scalar_" + ss.str()); @@ -529,13 +529,13 @@ bool GeneratorImpl::EmitDynamicMatrixScalarAssignment(const ast::AssignmentState { auto out = line(&helpers_); out << "void " << fn << "(inout "; - if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, type::Access::kUndefined, - "mat")) { + if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, + builtin::Access::kUndefined, "mat")) { return ""; } out << ", int col, int row, "; if (!EmitTypeAndName(out, mat->type(), type::AddressSpace::kUndefined, - type::Access::kUndefined, "val")) { + builtin::Access::kUndefined, "val")) { return ""; } out << ") {"; @@ -642,7 +642,7 @@ bool GeneratorImpl::EmitBitcast(std::ostream& out, const ast::BitcastExpression* } out << "as"; - if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } out << "("; @@ -1030,7 +1030,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::kUndefined, type::Access::kReadWrite, + if (!EmitType(out, conv->Target(), type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -1076,7 +1076,7 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out, if (brackets) { out << "{"; } else { - if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) { + if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } out << "("; @@ -1594,12 +1594,12 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto fn = line(&buf); if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, name)) { + builtin::Access::kUndefined, name)) { return false; } fn << "(RWByteAddressBuffer buffer, uint offset, "; if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "value")) { + builtin::Access::kUndefined, "value")) { return false; } fn << ") {"; @@ -1615,7 +1615,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto l = line(&buf); if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "original_value")) { + builtin::Access::kUndefined, "original_value")) { return false; } l << " = 0;"; @@ -1664,7 +1664,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto fn = line(&buf); if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, name)) { + builtin::Access::kUndefined, name)) { return false; } fn << "(RWByteAddressBuffer buffer, uint offset) {"; @@ -1680,7 +1680,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto l = line(&buf); if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "value")) { + builtin::Access::kUndefined, "value")) { return false; } l << " = 0;"; @@ -1698,7 +1698,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( auto fn = line(&buf); fn << "void " << name << "(RWByteAddressBuffer buffer, uint offset, "; if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "value")) { + builtin::Access::kUndefined, "value")) { return false; } fn << ") {"; @@ -1714,7 +1714,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto l = line(&buf); if (!EmitTypeAndName(l, value_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "ignored")) { + builtin::Access::kUndefined, "ignored")) { return false; } l << ";"; @@ -1729,17 +1729,17 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto fn = line(&buf); if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, name)) { + builtin::Access::kUndefined, name)) { return false; } fn << "(RWByteAddressBuffer buffer, uint offset, "; if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "compare")) { + builtin::Access::kUndefined, "compare")) { return false; } fn << ", "; if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "value")) { + builtin::Access::kUndefined, "value")) { return false; } fn << ") {"; @@ -1755,7 +1755,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { // T result = {0}; auto l = line(&buf); if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, "result")) { + builtin::Access::kUndefined, "result")) { return false; } l << "="; @@ -1790,7 +1790,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, if (!builtin->ReturnType()->Is()) { auto pre = line(); if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, result)) { + builtin::Access::kUndefined, result)) { return false; } pre << " = "; @@ -1854,7 +1854,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::kUndefined, - type::Access::kUndefined, result)) { + builtin::Access::kUndefined, result)) { return false; } pre << " = "; @@ -1892,7 +1892,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, { // T compare_value = ; auto pre = line(); if (!EmitTypeAndName(pre, TypeOf(compare_value)->UnwrapRef(), - type::AddressSpace::kUndefined, type::Access::kUndefined, + type::AddressSpace::kUndefined, builtin::Access::kUndefined, compare)) { return false; } @@ -2003,7 +2003,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out, { auto l = line(b); if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, "")) { + builtin::Access::kUndefined, "")) { return false; } l << " result;"; @@ -2045,7 +2045,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out, { auto l = line(b); if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, "")) { + builtin::Access::kUndefined, "")) { return false; } l << " result = {fract, int" << width << "(exp)};"; @@ -2082,7 +2082,8 @@ 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::kUndefined, type::Access::kReadWrite, "")) { + if (!EmitType(out, arg->Type(), type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + "")) { return false; } out << "(sign("; @@ -2885,14 +2886,14 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { auto pre = line(); pre << "typedef "; if (!EmitTypeAndName(pre, sem->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kReadWrite, typedef_name)) { + builtin::Access::kReadWrite, typedef_name)) { return false; } pre << ";"; out << typedef_name; } else { if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "")) { + builtin::Access::kReadWrite, "")) { return false; } } @@ -2909,7 +2910,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { auto const* type = v->Type(); auto address_space = type::AddressSpace::kUndefined; - auto access = type::Access::kUndefined; + auto access = builtin::Access::kUndefined; if (auto* ptr = type->As()) { type = ptr->StoreType(); @@ -2983,7 +2984,7 @@ bool GeneratorImpl::EmitFunctionBodyWithDiscard(const ast::Function* func) { { auto out = line(); if (!EmitTypeAndName(out, sem->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kReadWrite, name)) { + builtin::Access::kReadWrite, name)) { return false; } out << ";"; @@ -3068,7 +3069,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable } auto* global_sem = sem->As(); - out << RegisterAndSpace(sem->Access() == type::Access::kRead ? 't' : 'u', + out << RegisterAndSpace(sem->Access() == builtin::Access::kRead ? 't' : 'u', global_sem->BindingPoint()) << ";"; @@ -3241,7 +3242,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { } if (!EmitTypeAndName(out, func_sem->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, + builtin::Access::kUndefined, builder_.Symbols().NameFor(func->name->symbol))) { return false; } @@ -3336,7 +3337,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, return true; } - if (!EmitType(out, v, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) { + if (!EmitType(out, v, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + "")) { return false; } @@ -3353,7 +3355,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, return true; }, [&](const type::Matrix* m) { - if (!EmitType(out, m, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) { + if (!EmitType(out, m, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + "")) { return false; } @@ -3372,7 +3375,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, [&](const type::Array* a) { if (constant->AllZero()) { out << "("; - if (!EmitType(out, a, type::AddressSpace::kUndefined, type::Access::kUndefined, + if (!EmitType(out, a, type::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -3513,7 +3516,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::kUndefined, type::Access::kReadWrite, + if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -3529,7 +3532,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::kUndefined, type::Access::kReadWrite, + if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -3547,13 +3550,13 @@ 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::kUndefined, type::Access::kUndefined, + return EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, ""); }, [&](const type::Array*) { out << "("; TINT_DEFER(out << ")" << value); - return EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined, + return EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, ""); }, [&](Default) { @@ -3929,7 +3932,7 @@ bool GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) { bool GeneratorImpl::EmitType(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - type::Access access, + builtin::Access access, const std::string& name, bool* name_printed /* = nullptr */) { if (name_printed) { @@ -3937,7 +3940,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } switch (address_space) { case type::AddressSpace::kStorage: - if (access != type::Access::kRead) { + if (access != builtin::Access::kRead) { out << "RW"; } out << "ByteAddressBuffer"; @@ -4059,7 +4062,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, auto* depth_ms = tex->As(); auto* sampled = tex->As(); - if (storage && storage->access() != type::Access::kRead) { + if (storage && storage->access() != builtin::Access::kRead) { out << "RW"; } out << "Texture"; @@ -4156,7 +4159,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, bool GeneratorImpl::EmitTypeAndName(std::ostream& out, const type::Type* type, type::AddressSpace address_space, - type::Access access, + builtin::Access access, const std::string& name) { bool name_printed = false; if (!EmitType(out, type, address_space, access, name, &name_printed)) { @@ -4238,8 +4241,8 @@ bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) { } out << pre; - if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, type::Access::kReadWrite, - mem_name)) { + if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, + builtin::Access::kReadWrite, mem_name)) { return false; } out << post << ";"; @@ -4308,7 +4311,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { auto out = line(); out << "const "; - if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined, + if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, builder_.Symbols().NameFor(let->name->symbol))) { return false; } @@ -4336,7 +4339,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, { auto decl = line(&b); if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kUndefined, - type::Access::kUndefined, fn_name)) { + builtin::Access::kUndefined, fn_name)) { return ""; } { @@ -4352,7 +4355,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, ty = ptr->StoreType(); } if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined, - type::Access::kUndefined, param_name)) { + builtin::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 b5f53bfd4d..1e2faa120f 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, - type::Access access, + builtin::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, - type::Access access, + builtin::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 afad67cf5a..43e474ad16 100644 --- a/src/tint/writer/hlsl/generator_impl_function_test.cc +++ b/src/tint/writer/hlsl/generator_impl_function_test.cc @@ -436,7 +436,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -469,7 +469,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -502,7 +502,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -533,7 +533,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -602,7 +602,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, type::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("sub_func", @@ -830,7 +830,7 @@ 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, type::Access::kReadWrite, + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); { 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 f2607c552a..2c11fc28df 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, type::Access::kReadWrite, + b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kUndefined, + b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kUniform, builtin::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 961a27b07b..8013045570 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())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); - GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(2_a), + GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, builtin::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 fc347ac648..0aa019ef23 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(ty), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "ary")) + builtin::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(ty), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "ary")) + builtin::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(ty), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "ary")) + builtin::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(ty), type::AddressSpace::kUndefined, - type::Access::kReadWrite, "")) + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool[4]"); } @@ -91,7 +91,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, bool_, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, bool_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool"); } @@ -103,7 +103,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F16) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, f16, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, f16, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float16_t"); } @@ -115,7 +115,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, f32, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, f32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float"); } @@ -127,7 +127,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, i32, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, i32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "int"); } @@ -141,7 +141,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F16) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "matrix"); } @@ -155,7 +155,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float2x3"); } @@ -184,8 +184,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) { Member("a", ty.i32()), Member("b", ty.f32()), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(0_a), - Group(0_a)); + GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -205,7 +205,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::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, sem_s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "S"); } @@ -253,7 +253,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, u32, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, u32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "uint"); } @@ -266,7 +266,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, vec3, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, vec3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float3"); } @@ -278,7 +278,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, void_, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, void_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "void"); } @@ -290,7 +290,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSampler) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, sampler, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "SamplerState"); } @@ -302,7 +302,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, sampler, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "SamplerComparisonState"); } @@ -512,7 +512,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, s, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) + ASSERT_TRUE( + gen.EmitType(out, s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "Texture2DMS"); } @@ -530,7 +531,7 @@ using HlslStorageTexturesTest = TestParamHelper; TEST_P(HlslStorageTexturesTest, Emit) { auto params = GetParam(); - auto t = ty.storage_texture(params.dim, params.imgfmt, type::Access::kWrite); + auto t = ty.storage_texture(params.dim, params.imgfmt, builtin::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 39c3ec7693..5fc779ad3f 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -2610,7 +2610,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, return true; }, [&](const type::Pointer* ptr) { - if (ptr->Access() == type::Access::kRead) { + if (ptr->Access() == builtin::Access::kRead) { out << "const "; } if (!EmitAddressSpace(out, ptr->AddressSpace())) { @@ -2694,9 +2694,9 @@ bool GeneratorImpl::EmitType(std::ostream& out, } std::string access_str; - if (storage->access() == type::Access::kRead) { + if (storage->access() == builtin::Access::kRead) { out << ", access::read"; - } else if (storage->access() == type::Access::kWrite) { + } else if (storage->access() == builtin::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 de88ecb53d..05e85311db 100644 --- a/src/tint/writer/msl/generator_impl_function_test.cc +++ b/src/tint/writer/msl/generator_impl_function_test.cc @@ -341,8 +341,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RW_StorageBu Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a), - Binding(0_a)); + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Group(0_a), Binding(0_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -380,7 +380,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RO_StorageBu Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -466,8 +466,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RW Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a), - Binding(0_a)); + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Group(0_a), Binding(0_a)); Func("sub_func", utils::Vector{ @@ -518,7 +518,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RO Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a), + GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); Func("sub_func", @@ -656,8 +656,8 @@ 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, type::Access::kReadWrite, Group(0_a), - Binding(0_a)); + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Group(0_a), Binding(0_a)); { auto* var = Var("v", ty.f32(), MemberAccessor("data", "d")); diff --git a/src/tint/writer/msl/generator_impl_sanitizer_test.cc b/src/tint/writer/msl/generator_impl_sanitizer_test.cc index 3b35e6dfd3..05708dde66 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())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(0_a)); - GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(2_a), + GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, builtin::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())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(0_a)); - GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(2_a), + GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, builtin::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 971d2a6084..1062fcd9a6 100644 --- a/src/tint/writer/msl/generator_impl_type_test.cc +++ b/src/tint/writer/msl/generator_impl_type_test.cc @@ -212,7 +212,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix_F16) { TEST_F(MslGeneratorImplTest, EmitType_Pointer) { auto* f32 = create(); - auto* p = create(f32, type::AddressSpace::kWorkgroup, type::Access::kReadWrite); + auto* p = + create(f32, type::AddressSpace::kWorkgroup, builtin::Access::kReadWrite); GeneratorImpl& gen = Build(); @@ -283,7 +284,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) { Member("z", ty.f32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, + ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; @@ -392,7 +393,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) { Member("e", ty.f32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, + ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; @@ -484,7 +485,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) { Member("f", array_z), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, + ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; @@ -568,7 +569,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) { Member("c", ty.i32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, + ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; @@ -630,7 +631,7 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) { Member("tint_pad_21", ty.f32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, + ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; @@ -689,7 +690,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) { Member("b", ty.f32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, + ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; @@ -853,7 +854,7 @@ using MslStorageTexturesTest = TestParamHelper; TEST_P(MslStorageTexturesTest, Emit) { auto params = GetParam(); - auto s = ty.storage_texture(params.dim, type::TexelFormat::kR32Float, type::Access::kWrite); + auto s = ty.storage_texture(params.dim, type::TexelFormat::kR32Float, builtin::Access::kWrite); ast::Type type = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type; GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index efee8667a9..33b7cbf839 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -799,16 +799,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 type::Access::kWrite: + case builtin::Access::kWrite: push_annot(spv::Op::OpDecorate, {Operand(var_id), U32Operand(SpvDecorationNonReadable)}); break; - case type::Access::kRead: + case builtin::Access::kRead: push_annot(spv::Op::OpDecorate, {Operand(var_id), U32Operand(SpvDecorationNonWritable)}); break; - case type::Access::kUndefined: - case type::Access::kReadWrite: + case builtin::Access::kUndefined: + case builtin::Access::kReadWrite: break; } } @@ -1900,7 +1900,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, type::Access::kReadWrite); + vec_type, type::AddressSpace::kFunction, builtin::Access::kReadWrite); push_function_var({Operand(GenerateTypeIfNeeded(splat_vector_type)), splat_vector, U32Operand(ConvertAddressSpace(type::AddressSpace::kFunction)), Operand(GenerateConstantNullIfNeeded(vec_type))}); @@ -3656,10 +3656,10 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { // fine. if (auto* ptr = type->As()) { type = builder_.create(ptr->StoreType(), ptr->AddressSpace(), - type::Access::kReadWrite); + builtin::Access::kReadWrite); } else if (auto* ref = type->As()) { type = builder_.create(ref->StoreType(), ref->AddressSpace(), - type::Access::kReadWrite); + builtin::Access::kReadWrite); } return utils::GetOrCreate(type_to_id_, type, [&]() -> uint32_t { @@ -3718,11 +3718,12 @@ 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(), type::Access::kRead, tex->type())] = id; + tex->dim(), tex->texel_format(), builtin::Access::kRead, tex->type())] = id; type_to_id_[builder_.create( - tex->dim(), tex->texel_format(), type::Access::kWrite, tex->type())] = id; + tex->dim(), tex->texel_format(), builtin::Access::kWrite, tex->type())] = id; type_to_id_[builder_.create( - tex->dim(), tex->texel_format(), type::Access::kReadWrite, tex->type())] = id; + tex->dim(), tex->texel_format(), builtin::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 693fdb1478..a895e5f2d6 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()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::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()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf(Deref(AddressOf("b")))); @@ -3513,8 +3513,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicLoad) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), - Group(2_a)); + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3577,8 +3577,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicStore) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), - Group(2_a)); + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3649,8 +3649,8 @@ 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, type::Access::kReadWrite, Binding(1_a), - Group(2_a)); + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3722,8 +3722,8 @@ 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, type::Access::kReadWrite, Binding(1_a), - Group(2_a)); + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3797,8 +3797,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicExchange) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), - Group(2_a)); + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3873,8 +3873,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Binding(1_a), - Group(2_a)); + GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ diff --git a/src/tint/writer/spirv/builder_function_test.cc b/src/tint/writer/spirv/builder_function_test.cc index 618a84e4c1..bdfc412686 100644 --- a/src/tint/writer/spirv/builder_function_test.cc +++ b/src/tint/writer/spirv/builder_function_test.cc @@ -198,7 +198,7 @@ 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, type::Access::kReadWrite, + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); { diff --git a/src/tint/writer/spirv/builder_global_variable_test.cc b/src/tint/writer/spirv/builder_global_variable_test.cc index dae3a504d7..d412db2f25 100644 --- a/src/tint/writer/spirv/builder_global_variable_test.cc +++ b/src/tint/writer/spirv/builder_global_variable_test.cc @@ -314,7 +314,7 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { Member("b", ty.i32()), }); - GlobalVar("b", ty.Of(A), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + GlobalVar("b", ty.Of(A), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -356,7 +356,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, type::Access::kRead, Binding(0_a), + GlobalVar("b", ty.Of(B), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -396,7 +396,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, type::Access::kRead, Binding(0_a), + GlobalVar("b", ty.Of(B), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -435,9 +435,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, type::Access::kRead, Group(0_a), + GlobalVar("b", ty.Of(A), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); - GlobalVar("c", ty.Of(A), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(1_a), + GlobalVar("c", ty.Of(A), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(1_a), Binding(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -477,7 +477,7 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) { // var a : texture_storage_2d; auto type = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint, - type::Access::kWrite); + builtin::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 93831afb70..a6c7b2b53e 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, type::Access::kRead, Binding(0_a), + GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ast::Type type = str->members[0]->type; @@ -47,7 +47,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, type::Access::kRead, Binding(0_a), + GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ast::Type type = str->members[0]->type; @@ -296,7 +296,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF16Matrix) { TEST_F(BuilderTest_Type, GeneratePtr) { auto* i32 = create(); - auto* ptr = create(i32, type::AddressSpace::kOut, type::Access::kReadWrite); + auto* ptr = create(i32, type::AddressSpace::kOut, builtin::Access::kReadWrite); spirv::Builder& b = Build(); @@ -311,7 +311,7 @@ TEST_F(BuilderTest_Type, GeneratePtr) { TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { auto* i32 = create(); - auto* ptr = create(i32, type::AddressSpace::kOut, type::Access::kReadWrite); + auto* ptr = create(i32, type::AddressSpace::kOut, builtin::Access::kReadWrite); spirv::Builder& b = Build(); @@ -863,7 +863,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) { auto s = ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kR32Float, - type::Access::kWrite); + builtin::Access::kWrite); ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type; @@ -878,7 +878,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { auto s = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float, - type::Access::kWrite); + builtin::Access::kWrite); ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type; @@ -893,7 +893,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { auto s = ty.storage_texture(type::TextureDimension::k2dArray, type::TexelFormat::kR32Float, - type::Access::kWrite); + builtin::Access::kWrite); ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type; @@ -908,7 +908,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) { auto s = ty.storage_texture(type::TextureDimension::k3d, type::TexelFormat::kR32Float, - type::Access::kWrite); + builtin::Access::kWrite); ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type; @@ -923,7 +923,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, type::TexelFormat::kR32Float, - type::Access::kWrite); + builtin::Access::kWrite); ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type; @@ -938,7 +938,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, type::TexelFormat::kR32Sint, - type::Access::kWrite); + builtin::Access::kWrite); ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type; @@ -953,7 +953,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, type::TexelFormat::kR32Uint, - type::Access::kWrite); + builtin::Access::kWrite); ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type; diff --git a/src/tint/writer/wgsl/generator_impl_function_test.cc b/src/tint/writer/wgsl/generator_impl_function_test.cc index 34e26b40da..e29f0f4713 100644 --- a/src/tint/writer/wgsl/generator_impl_function_test.cc +++ b/src/tint/writer/wgsl/generator_impl_function_test.cc @@ -179,7 +179,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_Module Member("d", ty.f32()), }); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, + GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); { diff --git a/src/tint/writer/wgsl/generator_impl_type_test.cc b/src/tint/writer/wgsl/generator_impl_type_test.cc index 4f8740c10c..18fb678d28 100644 --- a/src/tint/writer/wgsl/generator_impl_type_test.cc +++ b/src/tint/writer/wgsl/generator_impl_type_test.cc @@ -143,7 +143,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Pointer) { TEST_F(WgslGeneratorImplTest, EmitType_PointerAccessMode) { auto type = Alias("make_type_reachable", - ty.pointer(type::AddressSpace::kStorage, type::Access::kReadWrite)) + ty.pointer(type::AddressSpace::kStorage, builtin::Access::kReadWrite)) ->type; GeneratorImpl& gen = Build(); @@ -441,7 +441,7 @@ INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest, struct StorageTextureData { type::TexelFormat fmt; type::TextureDimension dim; - type::Access access; + builtin::Access access; const char* name; }; inline std::ostream& operator<<(std::ostream& out, StorageTextureData data) { @@ -466,13 +466,13 @@ INSTANTIATE_TEST_SUITE_P( WgslGenerator_StorageTextureTest, testing::Values( StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k1d, - type::Access::kWrite, "texture_storage_1d"}, + builtin::Access::kWrite, "texture_storage_1d"}, StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k2d, - type::Access::kWrite, "texture_storage_2d"}, + builtin::Access::kWrite, "texture_storage_2d"}, StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k2dArray, - type::Access::kWrite, "texture_storage_2d_array"}, + builtin::Access::kWrite, "texture_storage_2d_array"}, StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k3d, - type::Access::kWrite, "texture_storage_3d"})); + builtin::Access::kWrite, "texture_storage_3d"})); struct ImageFormatData { type::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 3d39ce9e30..33ead1d03c 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, type::Access::kRead, + auto* v = GlobalVar("a", ty.Of(s), type::AddressSpace::kStorage, builtin::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, type::Access::kReadWrite, + auto* v = GlobalVar("a", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build();