Move ast/access to type/access.

This CL moves the ast/access files into type/access to resolve the type
dependency on ast

Change-Id: Ic0973c5ad162166736abb07cf9bbed7efa91695b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117605
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair 2023-01-21 23:44:38 +00:00 committed by Dawn LUCI CQ
parent e2ff3431f4
commit 61c16eb448
124 changed files with 665 additions and 660 deletions

View File

@ -562,7 +562,7 @@ ResultOrError<CompiledShader> ShaderModule::Compile(
wgpu::BufferBindingType::Storage ||
bgl->GetBindingInfo(bindingIndex).buffer.type == kInternalStorageBufferBinding));
if (forceStorageBufferAsUAV) {
remappedAccessControls.emplace(srcBindingPoint, tint::ast::Access::kReadWrite);
remappedAccessControls.emplace(srcBindingPoint, tint::type::Access::kReadWrite);
}
}

View File

@ -181,8 +181,6 @@ template("libtint_source_set") {
libtint_source_set("libtint_core_all_src") {
sources = [
"ast/access.cc",
"ast/access.h",
"ast/alias.cc",
"ast/alias.h",
"ast/array.cc",
@ -459,6 +457,7 @@ libtint_source_set("libtint_core_all_src") {
"type/abstract_float.h",
"type/abstract_int.h",
"type/abstract_numeric.h",
"type/access.h",
"type/address_space.h",
"type/array.h",
"type/array_count.h",
@ -700,6 +699,8 @@ libtint_source_set("libtint_type_src") {
"type/abstract_int.h",
"type/abstract_numeric.cc",
"type/abstract_numeric.h",
"type/access.cc",
"type/access.h",
"type/address_space.cc",
"type/address_space.h",
"type/array.cc",
@ -1139,7 +1140,6 @@ if (tint_build_unittests) {
tint_unittests_source_set("tint_unittests_ast_src") {
sources = [
"ast/access_test.cc",
"ast/alias_test.cc",
"ast/array_test.cc",
"ast/assignment_statement_test.cc",
@ -1322,6 +1322,7 @@ if (tint_build_unittests) {
tint_unittests_source_set("tint_unittests_type_src") {
sources = [
"type/access_test.cc",
"type/address_space_test.cc",
"type/array_test.cc",
"type/atomic_test.cc",

View File

@ -566,7 +566,6 @@ list(APPEND TINT_LIB_SRCS
writer/writer.h
)
tint_generated(ast/access BENCH TEST)
tint_generated(ast/builtin_value BENCH TEST)
tint_generated(ast/extension BENCH TEST)
tint_generated(ast/interpolate_attribute BENCH TEST)
@ -574,6 +573,7 @@ tint_generated(ast/texel_format BENCH TEST)
tint_generated(resolver/init_conv_intrinsic)
tint_generated(sem/builtin_type)
tint_generated(sem/parameter_usage)
tint_generated(type/access BENCH TEST)
tint_generated(type/address_space BENCH TEST)
tint_generated(type/short_name BENCH TEST)

View File

@ -13,7 +13,6 @@
// limitations under the License.
#include "src/tint/ast/alias.h"
#include "src/tint/ast/access.h"
#include "src/tint/ast/array.h"
#include "src/tint/ast/bool.h"
#include "src/tint/ast/f32.h"
@ -26,6 +25,7 @@
#include "src/tint/ast/texture.h"
#include "src/tint/ast/u32.h"
#include "src/tint/ast/vector.h"
#include "src/tint/type/access.h"
namespace tint::ast {
namespace {

View File

@ -55,7 +55,7 @@ TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o,
args(std::move(a)) {}
TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o,
const char* d,
Access acc,
type::Access acc,
ast::TexelFormat fmt,
type::TextureDimension dims,
TextureDataType datatype,
@ -404,7 +404,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
{
ValidTextureOverload::kDimensionsStorageWO1d,
"textureDimensions(t : texture_storage_1d<rgba32float>) -> u32",
ast::Access::kWrite,
type::Access::kWrite,
ast::TexelFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
@ -414,7 +414,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
{
ValidTextureOverload::kDimensionsStorageWO2d,
"textureDimensions(t : texture_storage_2d<rgba32float>) -> vec2<u32>",
ast::Access::kWrite,
type::Access::kWrite,
ast::TexelFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
@ -424,7 +424,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
{
ValidTextureOverload::kDimensionsStorageWO2dArray,
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> vec2<u32>",
ast::Access::kWrite,
type::Access::kWrite,
ast::TexelFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
@ -434,7 +434,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
{
ValidTextureOverload::kDimensionsStorageWO3d,
"textureDimensions(t : texture_storage_3d<rgba32float>) -> vec3<u32>",
ast::Access::kWrite,
type::Access::kWrite,
ast::TexelFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,
@ -827,7 +827,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
{
ValidTextureOverload::kNumLayersStorageWO2dArray,
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> u32",
ast::Access::kWrite,
type::Access::kWrite,
ast::TexelFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
@ -2327,7 +2327,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
"textureStore(t : texture_storage_1d<rgba32float>,\n"
" coords : i32,\n"
" value : vec4<T>)",
ast::Access::kWrite,
type::Access::kWrite,
ast::TexelFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
@ -2343,7 +2343,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
"textureStore(t : texture_storage_2d<rgba32float>,\n"
" coords : vec2<i32>,\n"
" value : vec4<T>)",
ast::Access::kWrite,
type::Access::kWrite,
ast::TexelFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
@ -2360,7 +2360,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
" coords : vec2<u32>,\n"
" array_index : u32,\n"
" value : vec4<T>)",
ast::Access::kWrite,
type::Access::kWrite,
ast::TexelFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
@ -2377,7 +2377,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
"textureStore(t : texture_storage_3d<rgba32float>,\n"
" coords : vec3<u32>,\n"
" value : vec4<T>)",
ast::Access::kWrite,
type::Access::kWrite,
ast::TexelFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,

View File

@ -17,8 +17,8 @@
#include <vector>
#include "src/tint/ast/access.h"
#include "src/tint/program_builder.h"
#include "src/tint/type/access.h"
#include "src/tint/type/storage_texture.h"
#include "src/tint/type/texture_dimension.h"
@ -201,7 +201,7 @@ struct TextureOverloadCase {
/// Constructor for textureLoad() with storage textures
TextureOverloadCase(ValidTextureOverload,
const char*,
Access,
type::Access,
ast::TexelFormat,
type::TextureDimension,
TextureDataType,
@ -239,7 +239,7 @@ struct TextureOverloadCase {
ast::SamplerKind const sampler_kind = ast::SamplerKind::kSampler;
/// The access control for the storage texture
/// Used only when texture_kind is kStorage
Access const access = Access::kReadWrite;
type::Access const access = type::Access::kReadWrite;
/// The image format for the storage texture
/// Used only when texture_kind is kStorage
ast::TexelFormat const texel_format = ast::TexelFormat::kUndefined;

View File

@ -13,7 +13,6 @@
// limitations under the License.
#include "src/tint/ast/matrix.h"
#include "src/tint/ast/access.h"
#include "src/tint/ast/alias.h"
#include "src/tint/ast/array.h"
#include "src/tint/ast/bool.h"
@ -26,6 +25,7 @@
#include "src/tint/ast/texture.h"
#include "src/tint/ast/u32.h"
#include "src/tint/ast/vector.h"
#include "src/tint/type/access.h"
namespace tint::ast {
namespace {

View File

@ -14,7 +14,6 @@
#include "src/tint/ast/multisampled_texture.h"
#include "src/tint/ast/access.h"
#include "src/tint/ast/alias.h"
#include "src/tint/ast/array.h"
#include "src/tint/ast/bool.h"
@ -31,6 +30,7 @@
#include "src/tint/ast/texture.h"
#include "src/tint/ast/u32.h"
#include "src/tint/ast/vector.h"
#include "src/tint/type/access.h"
namespace tint::ast {
namespace {

View File

@ -25,7 +25,7 @@ Pointer::Pointer(ProgramID pid,
const Source& src,
const Type* const subtype,
type::AddressSpace addr_space,
ast::Access ac)
type::Access ac)
: Base(pid, nid, src), type(subtype), address_space(addr_space), access(ac) {}
std::string Pointer::FriendlyName(const SymbolTable& symbols) const {
@ -35,7 +35,7 @@ std::string Pointer::FriendlyName(const SymbolTable& symbols) const {
out << address_space << ", ";
}
out << type->FriendlyName(symbols);
if (access != ast::Access::kUndefined) {
if (access != type::Access::kUndefined) {
out << ", " << access;
}
out << ">";

View File

@ -17,8 +17,8 @@
#include <string>
#include "src/tint/ast/access.h"
#include "src/tint/ast/type.h"
#include "src/tint/type/access.h"
#include "src/tint/type/address_space.h"
namespace tint::ast {
@ -38,7 +38,7 @@ class Pointer final : public Castable<Pointer, Type> {
const Source& src,
const Type* const subtype,
type::AddressSpace address_space,
ast::Access access);
type::Access access);
/// Move constructor
Pointer(Pointer&&);
~Pointer() override;
@ -60,7 +60,7 @@ class Pointer final : public Castable<Pointer, Type> {
type::AddressSpace const address_space;
/// The access control of the pointer
ast::Access const access;
type::Access const access;
};
} // namespace tint::ast

View File

@ -24,21 +24,21 @@ using AstPointerTest = TestHelper;
TEST_F(AstPointerTest, Creation) {
auto* i32 = create<I32>();
auto* p = create<Pointer>(i32, type::AddressSpace::kStorage, Access::kRead);
auto* p = create<Pointer>(i32, type::AddressSpace::kStorage, type::Access::kRead);
EXPECT_EQ(p->type, i32);
EXPECT_EQ(p->address_space, type::AddressSpace::kStorage);
EXPECT_EQ(p->access, Access::kRead);
EXPECT_EQ(p->access, type::Access::kRead);
}
TEST_F(AstPointerTest, FriendlyName) {
auto* i32 = create<I32>();
auto* p = create<Pointer>(i32, type::AddressSpace::kWorkgroup, Access::kUndefined);
auto* p = create<Pointer>(i32, type::AddressSpace::kWorkgroup, type::Access::kUndefined);
EXPECT_EQ(p->FriendlyName(Symbols()), "ptr<workgroup, i32>");
}
TEST_F(AstPointerTest, FriendlyNameWithAccess) {
auto* i32 = create<I32>();
auto* p = create<Pointer>(i32, type::AddressSpace::kStorage, Access::kReadWrite);
auto* p = create<Pointer>(i32, type::AddressSpace::kStorage, type::Access::kReadWrite);
EXPECT_EQ(p->FriendlyName(Symbols()), "ptr<storage, i32, read_write>");
}

View File

@ -29,7 +29,7 @@ StorageTexture::StorageTexture(ProgramID pid,
type::TextureDimension d,
TexelFormat fmt,
const Type* subtype,
Access ac)
type::Access ac)
: Base(pid, nid, src, d), format(fmt), type(subtype), access(ac) {}
StorageTexture::StorageTexture(StorageTexture&&) = default;

View File

@ -17,9 +17,9 @@
#include <string>
#include "src/tint/ast/access.h"
#include "src/tint/ast/texel_format.h"
#include "src/tint/ast/texture.h"
#include "src/tint/type/access.h"
#include "src/tint/type/texture_dimension.h"
namespace tint::ast {
@ -41,7 +41,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
type::TextureDimension dim,
TexelFormat format,
const Type* subtype,
Access access_control);
type::Access access_control);
/// Move constructor
StorageTexture(StorageTexture&&);
@ -69,7 +69,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
const Type* const type;
/// The access control
const Access access;
const type::Access access;
};
} // namespace tint::ast

View File

@ -24,7 +24,7 @@ using AstStorageTextureTest = TestHelper;
TEST_F(AstStorageTextureTest, IsTexture) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
Texture* ty = create<StorageTexture>(type::TextureDimension::k2dArray,
TexelFormat::kRgba32Float, subtype, Access::kRead);
TexelFormat::kRgba32Float, subtype, type::Access::kRead);
EXPECT_FALSE(ty->Is<DepthTexture>());
EXPECT_FALSE(ty->Is<SampledTexture>());
EXPECT_TRUE(ty->Is<StorageTexture>());
@ -33,28 +33,28 @@ TEST_F(AstStorageTextureTest, IsTexture) {
TEST_F(AstStorageTextureTest, Dim) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
auto* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float,
subtype, Access::kRead);
subtype, type::Access::kRead);
EXPECT_EQ(s->dim, type::TextureDimension::k2dArray);
}
TEST_F(AstStorageTextureTest, Format) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
auto* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float,
subtype, Access::kRead);
subtype, type::Access::kRead);
EXPECT_EQ(s->format, TexelFormat::kRgba32Float);
}
TEST_F(AstStorageTextureTest, FriendlyName) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
auto* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float,
subtype, Access::kRead);
subtype, type::Access::kRead);
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read>");
}
TEST_F(AstStorageTextureTest, F32) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float,
subtype, Access::kRead);
subtype, type::Access::kRead);
ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>());
@ -64,7 +64,7 @@ TEST_F(AstStorageTextureTest, F32) {
TEST_F(AstStorageTextureTest, U32) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRg32Uint, *this);
Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRg32Uint,
subtype, Access::kRead);
subtype, type::Access::kRead);
ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>());
@ -74,7 +74,7 @@ TEST_F(AstStorageTextureTest, U32) {
TEST_F(AstStorageTextureTest, I32) {
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Sint, *this);
Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Sint,
subtype, Access::kRead);
subtype, type::Access::kRead);
ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>());

View File

@ -26,7 +26,7 @@ Var::Var(ProgramID pid,
const Symbol& sym,
const ast::Type* ty,
type::AddressSpace address_space,
Access access,
type::Access access,
const Expression* init,
utils::VectorRef<const Attribute*> attrs)
: Base(pid, nid, src, sym, ty, init, std::move(attrs)),

View File

@ -57,7 +57,7 @@ class Var final : public Castable<Var, Variable> {
const Symbol& sym,
const ast::Type* type,
type::AddressSpace declared_address_space,
Access declared_access,
type::Access declared_access,
const Expression* initializer,
utils::VectorRef<const Attribute*> attributes);
@ -80,7 +80,7 @@ class Var final : public Castable<Var, Variable> {
const type::AddressSpace declared_address_space;
/// The declared access control
const Access declared_access;
const type::Access declared_access;
};
/// A list of `var` declarations

View File

@ -18,11 +18,11 @@
#include <utility>
#include <vector>
#include "src/tint/ast/access.h"
#include "src/tint/ast/attribute.h"
#include "src/tint/ast/binding_attribute.h"
#include "src/tint/ast/expression.h"
#include "src/tint/ast/group_attribute.h"
#include "src/tint/type/access.h"
#include "src/tint/type/address_space.h"
// Forward declarations

View File

@ -131,7 +131,7 @@ class TransformBuilder {
uint8_t old_binding;
uint8_t new_group;
uint8_t new_binding;
ast::Access new_access;
type::Access new_access;
};
std::vector<Config> configs = tb->builder()->vector<Config>();

View File

@ -718,7 +718,7 @@ std::vector<ResourceBinding> Inspector::GetStorageBufferResourceBindingsImpl(
auto* var = rsv.first;
auto binding_info = rsv.second;
if (read_only != (var->Access() == ast::Access::kRead)) {
if (read_only != (var->Access() == type::Access::kRead)) {
continue;
}

View File

@ -1651,8 +1651,8 @@ TEST_F(InspectorGetStorageSizeTest, Empty) {
TEST_F(InspectorGetStorageSizeTest, Simple_NonStruct) {
AddUniformBuffer("ub_var", ty.i32(), 0, 0);
AddStorageBuffer("sb_var", ty.i32(), ast::Access::kReadWrite, 1, 0);
AddStorageBuffer("rosb_var", ty.i32(), ast::Access::kRead, 1, 1);
AddStorageBuffer("sb_var", ty.i32(), type::Access::kReadWrite, 1, 0);
AddStorageBuffer("rosb_var", ty.i32(), type::Access::kRead, 1, 1);
Func("ep_func", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("ub", Expr("ub_var"))),
@ -1683,7 +1683,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_Struct) {
auto sb = MakeStorageBufferTypes("sb_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("sb_var", sb(), ast::Access::kReadWrite, 1, 0);
AddStorageBuffer("sb_var", sb(), type::Access::kReadWrite, 1, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "sb_var",
utils::Vector{
MemberInfo{0, ty.i32()},
@ -1692,7 +1692,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_Struct) {
auto ro_sb = MakeStorageBufferTypes("rosb_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("rosb_var", ro_sb(), ast::Access::kRead, 1, 1);
AddStorageBuffer("rosb_var", ro_sb(), type::Access::kRead, 1, 1);
MakeStructVariableReferenceBodyFunction("rosb_func", "rosb_var",
utils::Vector{
MemberInfo{0, ty.i32()},
@ -1770,7 +1770,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
auto sb = MakeStorageBufferTypes("sb_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("sb_var", sb(), ast::Access::kReadWrite, 1, 0);
AddStorageBuffer("sb_var", sb(), type::Access::kReadWrite, 1, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "sb_var",
utils::Vector{
MemberInfo{0, ty.i32()},
@ -1779,7 +1779,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
auto ro_sb = MakeStorageBufferTypes("rosb_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("rosb_var", ro_sb(), ast::Access::kRead, 1, 1);
AddStorageBuffer("rosb_var", ro_sb(), type::Access::kRead, 1, 1);
MakeStructVariableReferenceBodyFunction("rosb_func", "rosb_var",
utils::Vector{
MemberInfo{0, ty.i32()},
@ -2134,7 +2134,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple_NonStruct) {
AddStorageBuffer("foo_sb", ty.i32(), ast::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", ty.i32(), type::Access::kReadWrite, 0, 0);
MakePlainGlobalReferenceBodyFunction("sb_func", "foo_sb", ty.i32(), utils::Empty);
MakeCallerBodyFunction("ep_func", utils::Vector{std::string("sb_func")},
@ -2159,7 +2159,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple_Struct) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2190,7 +2190,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
ty.u32(),
ty.f32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2223,9 +2223,9 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
ty.u32(),
ty.f32(),
});
AddStorageBuffer("sb_foo", sb_struct_type(), ast::Access::kReadWrite, 0, 0);
AddStorageBuffer("sb_bar", sb_struct_type(), ast::Access::kReadWrite, 0, 1);
AddStorageBuffer("sb_baz", sb_struct_type(), ast::Access::kReadWrite, 2, 0);
AddStorageBuffer("sb_foo", sb_struct_type(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("sb_bar", sb_struct_type(), type::Access::kReadWrite, 0, 1);
AddStorageBuffer("sb_baz", sb_struct_type(), type::Access::kReadWrite, 2, 0);
auto AddReferenceFunc = [this](const std::string& func_name, const std::string& var_name) {
MakeStructVariableReferenceBodyFunction(func_name, var_name,
@ -2284,7 +2284,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
ty.i32(),
ty.array<u32, 4>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2314,7 +2314,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
ty.i32(),
ty.array<u32>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2343,7 +2343,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.vec3<f32>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2369,7 +2369,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) {
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, NonStructVec3) {
AddStorageBuffer("foo_ub", ty.vec3<f32>(), ast::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_ub", ty.vec3<f32>(), type::Access::kReadWrite, 0, 0);
MakePlainGlobalReferenceBodyFunction("ub_func", "foo_ub", ty.vec3<f32>(), utils::Empty);
MakeCallerBodyFunction("ep_func", utils::Vector{std::string("ub_func")},
@ -2394,7 +2394,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kRead, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2417,7 +2417,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kRead, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2448,9 +2448,9 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, MultipleStorageBuf
ty.u32(),
ty.f32(),
});
AddStorageBuffer("sb_foo", sb_struct_type(), ast::Access::kRead, 0, 0);
AddStorageBuffer("sb_bar", sb_struct_type(), ast::Access::kRead, 0, 1);
AddStorageBuffer("sb_baz", sb_struct_type(), ast::Access::kRead, 2, 0);
AddStorageBuffer("sb_foo", sb_struct_type(), type::Access::kRead, 0, 0);
AddStorageBuffer("sb_bar", sb_struct_type(), type::Access::kRead, 0, 1);
AddStorageBuffer("sb_baz", sb_struct_type(), type::Access::kRead, 2, 0);
auto AddReferenceFunc = [this](const std::string& func_name, const std::string& var_name) {
MakeStructVariableReferenceBodyFunction(func_name, var_name,
@ -2509,7 +2509,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
ty.i32(),
ty.array<u32, 4>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kRead, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2539,7 +2539,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingRuntimeA
ty.i32(),
ty.array<u32>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kRead, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2568,7 +2568,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), ast::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{

View File

@ -135,7 +135,7 @@ void InspectorBuilder::AddWorkgroupStorage(const std::string& name, const ast::T
void InspectorBuilder::AddStorageBuffer(const std::string& name,
const ast::Type* type,
ast::Access access,
type::Access access,
uint32_t group,
uint32_t binding) {
GlobalVar(name, type, type::AddressSpace::kStorage, access, Binding(AInt(binding)),
@ -279,7 +279,7 @@ const ast::Type* InspectorBuilder::GetCoordsType(type::TextureDimension dim,
const ast::Type* InspectorBuilder::MakeStorageTextureTypes(type::TextureDimension dim,
ast::TexelFormat format) {
return ty.storage_texture(dim, format, ast::Access::kWrite);
return ty.storage_texture(dim, format, type::Access::kWrite);
}
void InspectorBuilder::AddStorageTexture(const std::string& name,

View File

@ -183,7 +183,7 @@ class InspectorBuilder : public ProgramBuilder {
/// @param binding the binding number to use for the storage buffer
void AddStorageBuffer(const std::string& name,
const ast::Type* type,
ast::Access access,
type::Access access,
uint32_t group,
uint32_t binding);

View File

@ -182,14 +182,14 @@ class ProgramBuilder {
const ast::Type* type = nullptr;
type::AddressSpace address_space = type::AddressSpace::kNone;
ast::Access access = ast::Access::kUndefined;
type::Access access = type::Access::kUndefined;
const ast::Expression* initializer = nullptr;
utils::Vector<const ast::Attribute*, 4> attributes;
private:
void Set(const ast::Type* t) { type = t; }
void Set(type::AddressSpace addr_space) { address_space = addr_space; }
void Set(ast::Access ac) { access = ac; }
void Set(type::Access ac) { access = ac; }
void Set(const ast::Expression* c) { initializer = c; }
void Set(utils::VectorRef<const ast::Attribute*> l) { attributes = std::move(l); }
void Set(const ast::Attribute* a) { attributes.Push(a); }
@ -943,7 +943,7 @@ class ProgramBuilder {
/// @return the pointer to `type` with the given type::AddressSpace
const ast::Pointer* pointer(const ast::Type* type,
type::AddressSpace address_space,
ast::Access access = ast::Access::kUndefined) const {
type::Access access = type::Access::kUndefined) const {
return builder->create<ast::Pointer>(type, address_space, access);
}
@ -955,7 +955,7 @@ class ProgramBuilder {
const ast::Pointer* pointer(const Source& source,
const ast::Type* type,
type::AddressSpace address_space,
ast::Access access = ast::Access::kUndefined) const {
type::Access access = type::Access::kUndefined) const {
return builder->create<ast::Pointer>(source, type, address_space, access);
}
@ -964,7 +964,7 @@ class ProgramBuilder {
/// @return the pointer to type `T` with the given type::AddressSpace.
template <typename T>
const ast::Pointer* pointer(type::AddressSpace address_space,
ast::Access access = ast::Access::kUndefined) const {
type::Access access = type::Access::kUndefined) const {
return pointer(Of<T>(), address_space, access);
}
@ -975,7 +975,7 @@ class ProgramBuilder {
template <typename T>
const ast::Pointer* pointer(const Source& source,
type::AddressSpace address_space,
ast::Access access = ast::Access::kUndefined) const {
type::Access access = type::Access::kUndefined) const {
return pointer(source, Of<T>(), address_space, access);
}
@ -1083,7 +1083,7 @@ class ProgramBuilder {
/// @returns the storage texture
const ast::StorageTexture* storage_texture(type::TextureDimension dims,
ast::TexelFormat format,
ast::Access access) const {
type::Access access) const {
auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder);
return builder->create<ast::StorageTexture>(dims, format, subtype, access);
}
@ -1096,7 +1096,7 @@ class ProgramBuilder {
const ast::StorageTexture* storage_texture(const Source& source,
type::TextureDimension dims,
ast::TexelFormat format,
ast::Access access) const {
type::Access access) const {
auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder);
return builder->create<ast::StorageTexture>(source, dims, format, subtype, access);
}
@ -1698,7 +1698,7 @@ class ProgramBuilder {
/// Can be any of the following, in any order:
/// * ast::Type* - specifies the variable type
/// * type::AddressSpace - specifies the variable address space
/// * ast::Access - specifies the variable's access control
/// * type::Access - specifies the variable's access control
/// * ast::Expression* - specifies the variable's initializer expression
/// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector)
/// Note that non-repeatable arguments of the same type will use the last argument's value.
@ -1717,7 +1717,7 @@ class ProgramBuilder {
/// Can be any of the following, in any order:
/// * ast::Type* - specifies the variable type
/// * type::AddressSpace - specifies the variable address space
/// * ast::Access - specifies the variable's access control
/// * type::Access - specifies the variable's access control
/// * ast::Expression* - specifies the variable's initializer expression
/// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector)
/// Note that non-repeatable arguments of the same type will use the last argument's value.
@ -1821,7 +1821,7 @@ class ProgramBuilder {
/// Can be any of the following, in any order:
/// * ast::Type* - specifies the variable type
/// * type::AddressSpace - specifies the variable address space
/// * ast::Access - specifies the variable's access control
/// * type::Access - specifies the variable's access control
/// * ast::Expression* - specifies the variable's initializer expression
/// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector)
/// Note that non-repeatable arguments of the same type will use the last argument's value.
@ -1840,7 +1840,7 @@ class ProgramBuilder {
/// Can be any of the following, in any order:
/// * ast::Type* - specifies the variable type
/// * type::AddressSpace - specifies the variable address space
/// * ast::Access - specifies the variable's access control
/// * type::Access - specifies the variable's access control
/// * ast::Expression* - specifies the variable's initializer expression
/// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector)
/// Note that non-repeatable arguments of the same type will use the last argument's value.

View File

@ -4882,7 +4882,7 @@ DefInfo::Pointer FunctionEmitter::GetPointerInfo(uint32_t id) {
}
// Local variables are always Function storage class, with default
// access mode.
return DefInfo::Pointer{type::AddressSpace::kFunction, ast::Access::kUndefined};
return DefInfo::Pointer{type::AddressSpace::kFunction, type::Access::kUndefined};
}
case spv::Op::OpFunctionParameter: {
const auto* type = As<Pointer>(parser_impl_.ConvertType(inst.type_id()));
@ -4895,7 +4895,7 @@ DefInfo::Pointer FunctionEmitter::GetPointerInfo(uint32_t id) {
// parameters. In that case we need to do a global analysis to
// determine what the formal argument parameter type should be,
// whether it has read_only or read_write access mode.
return DefInfo::Pointer{type->address_space, ast::Access::kUndefined};
return DefInfo::Pointer{type->address_space, type::Access::kUndefined};
}
default:
break;

View File

@ -334,7 +334,7 @@ struct DefInfo {
type::AddressSpace address_space = type::AddressSpace::kUndefined;
/// The declared access mode.
ast::Access access = ast::Access::kUndefined;
type::Access access = type::Access::kUndefined;
};
/// The expression to use when sinking pointers into their use.

View File

@ -1587,7 +1587,7 @@ ast::Var* ParserImpl::MakeVar(uint32_t id,
return nullptr;
}
ast::Access access = ast::Access::kUndefined;
type::Access access = type::Access::kUndefined;
if (address_space == type::AddressSpace::kStorage) {
bool read_only = false;
if (auto* tn = storage_type->As<Named>()) {
@ -1595,7 +1595,7 @@ ast::Var* ParserImpl::MakeVar(uint32_t id,
}
// Apply the access(read) or access(read_write) modifier.
access = read_only ? ast::Access::kRead : ast::Access::kReadWrite;
access = read_only ? type::Access::kRead : type::Access::kReadWrite;
}
// Handle variables (textures and samplers) are always in the handle
@ -2518,7 +2518,7 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc
ast_handle_type = ty_.SampledTexture(dim, ast_sampled_component_type);
}
} else {
const auto access = ast::Access::kWrite;
const auto access = type::Access::kWrite;
const auto format = enum_converter_.ToTexelFormat(image_type->format());
if (format == ast::TexelFormat::kUndefined) {
return nullptr;

View File

@ -175,7 +175,7 @@ Type::~Type() = default;
Texture::~Texture() = default;
Pointer::Pointer(const Type* t, type::AddressSpace s, ast::Access a)
Pointer::Pointer(const Type* t, type::AddressSpace s, type::Access a)
: type(t), address_space(s), access(a) {}
Pointer::Pointer(const Pointer&) = default;
@ -183,7 +183,7 @@ const ast::Type* Pointer::Build(ProgramBuilder& b) const {
return b.ty.pointer(type->Build(b), address_space, access);
}
Reference::Reference(const Type* t, type::AddressSpace s, ast::Access a)
Reference::Reference(const Type* t, type::AddressSpace s, type::Access a)
: type(t), address_space(s), access(a) {}
Reference::Reference(const Reference&) = default;
@ -255,7 +255,7 @@ const ast::Type* SampledTexture::Build(ProgramBuilder& b) const {
return b.ty.sampled_texture(dims, type->Build(b));
}
StorageTexture::StorageTexture(type::TextureDimension d, ast::TexelFormat f, ast::Access a)
StorageTexture::StorageTexture(type::TextureDimension d, ast::TexelFormat f, type::Access a)
: Base(d), format(f), access(a) {}
StorageTexture::StorageTexture(const StorageTexture&) = default;
@ -461,13 +461,13 @@ const Type* TypeManager::AsUnsigned(const Type* ty) {
const spirv::Pointer* TypeManager::Pointer(const Type* el,
type::AddressSpace address_space,
ast::Access access) {
type::Access access) {
return state->pointers_.Get(el, address_space, access);
}
const spirv::Reference* TypeManager::Reference(const Type* el,
type::AddressSpace address_space,
ast::Access access) {
type::Access access) {
return state->references_.Get(el, address_space, access);
}
@ -516,7 +516,7 @@ const spirv::SampledTexture* TypeManager::SampledTexture(type::TextureDimension
const spirv::StorageTexture* TypeManager::StorageTexture(type::TextureDimension dims,
ast::TexelFormat fmt,
ast::Access access) {
type::Access access) {
return state->storage_textures_.Get(dims, fmt, access);
}

View File

@ -19,10 +19,10 @@
#include <string>
#include <vector>
#include "src/tint/ast/access.h"
#include "src/tint/ast/sampler.h"
#include "src/tint/ast/storage_texture.h"
#include "src/tint/castable.h"
#include "src/tint/type/access.h"
#include "src/tint/type/address_space.h"
#include "src/tint/type/texture_dimension.h"
#include "src/tint/utils/block_allocator.h"
@ -163,7 +163,7 @@ struct Pointer final : public Castable<Pointer, Type> {
/// @param ty the store type
/// @param sc the pointer address space
/// @param access the declared access mode
Pointer(const Type* ty, type::AddressSpace sc, ast::Access access);
Pointer(const Type* ty, type::AddressSpace sc, type::Access access);
/// Copy constructor
/// @param other the other type to copy
@ -183,7 +183,7 @@ struct Pointer final : public Castable<Pointer, Type> {
/// the pointer address space
type::AddressSpace const address_space;
/// the pointer declared access mode
ast::Access const access;
type::Access const access;
};
/// `ref<SC, T, AM>` type
@ -194,7 +194,7 @@ struct Reference final : public Castable<Reference, Type> {
/// @param ty the referenced type
/// @param sc the reference address space
/// @param access the reference declared access mode
Reference(const Type* ty, type::AddressSpace sc, ast::Access access);
Reference(const Type* ty, type::AddressSpace sc, type::Access access);
/// Copy constructor
/// @param other the other type to copy
@ -214,7 +214,7 @@ struct Reference final : public Castable<Reference, Type> {
/// the pointer address space
type::AddressSpace const address_space;
/// the pointer declared access mode
ast::Access const access;
type::Access const access;
};
/// `vecN<T>` type
@ -435,7 +435,7 @@ struct StorageTexture final : public Castable<StorageTexture, Texture> {
/// @param d the texture dimensions
/// @param f the storage image format
/// @param a the access control
StorageTexture(type::TextureDimension d, ast::TexelFormat f, ast::Access a);
StorageTexture(type::TextureDimension d, ast::TexelFormat f, type::Access a);
/// Copy constructor
/// @param other the other type to copy
@ -454,7 +454,7 @@ struct StorageTexture final : public Castable<StorageTexture, Texture> {
ast::TexelFormat const format;
/// the access control
ast::Access const access;
type::Access const access;
};
/// Base class for named types
@ -551,7 +551,7 @@ class TypeManager {
/// the same pointer.
const spirv::Pointer* Pointer(const Type* ty,
type::AddressSpace address_space,
ast::Access access = ast::Access::kUndefined);
type::Access access = type::Access::kUndefined);
/// @param ty the referenced type
/// @param address_space the reference address space
/// @param access the declared access mode
@ -559,7 +559,7 @@ class TypeManager {
/// return the same pointer.
const spirv::Reference* Reference(const Type* ty,
type::AddressSpace address_space,
ast::Access access = ast::Access::kUndefined);
type::Access access = type::Access::kUndefined);
/// @param ty the element type
/// @param sz the number of elements in the vector
/// @return a Vector type. Repeated calls with the same arguments will return
@ -617,7 +617,7 @@ class TypeManager {
/// return the same pointer.
const spirv::StorageTexture* StorageTexture(type::TextureDimension d,
ast::TexelFormat f,
ast::Access a);
type::Access a);
private:
struct State;

View File

@ -44,9 +44,9 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) {
EXPECT_EQ(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()),
ty.SampledTexture(type::TextureDimension::k2d, ty.I32()));
EXPECT_EQ(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
ast::Access::kRead),
type::Access::kRead),
ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
ast::Access::kRead));
type::Access::kRead));
}
TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
@ -81,17 +81,17 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
EXPECT_NE(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()),
ty.SampledTexture(type::TextureDimension::k2d, ty.U32()));
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
ast::Access::kRead),
type::Access::kRead),
ty.StorageTexture(type::TextureDimension::k3d, ast::TexelFormat::kR32Uint,
ast::Access::kRead));
type::Access::kRead));
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
ast::Access::kRead),
type::Access::kRead),
ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Sint,
ast::Access::kRead));
type::Access::kRead));
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
ast::Access::kRead),
type::Access::kRead),
ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
ast::Access::kWrite));
type::Access::kWrite));
}
} // namespace

View File

@ -214,7 +214,7 @@ ParserImpl::VarDeclInfo::VarDeclInfo(const VarDeclInfo&) = default;
ParserImpl::VarDeclInfo::VarDeclInfo(Source source_in,
std::string name_in,
type::AddressSpace address_space_in,
ast::Access access_in,
type::Access access_in,
const ast::Type* type_in)
: source(std::move(source_in)),
name(std::move(name_in)),
@ -754,7 +754,7 @@ Maybe<const ast::Type*> ParserImpl::texture_and_sampler_types() {
auto storage = storage_texture_type();
if (storage.matched) {
const char* use = "storage texture type";
using StorageTextureInfo = std::pair<tint::ast::TexelFormat, tint::ast::Access>;
using StorageTextureInfo = std::pair<tint::ast::TexelFormat, tint::type::Access>;
auto params = expect_lt_gt_block(use, [&]() -> Expect<StorageTextureInfo> {
auto format = expect_texel_format(use);
if (format.errored) {
@ -971,8 +971,8 @@ Expect<ParserImpl::TypedIdentifier> ParserImpl::expect_ident_with_type_specifier
// : 'read'
// | 'write'
// | 'read_write'
Expect<ast::Access> ParserImpl::expect_access_mode(std::string_view use) {
return expect_enum("access control", ast::ParseAccess, ast::kAccessStrings, use);
Expect<type::Access> ParserImpl::expect_access_mode(std::string_view use) {
return expect_enum("access control", type::ParseAccess, type::kAccessStrings, use);
}
// variable_qualifier
@ -996,7 +996,7 @@ Maybe<ParserImpl::VariableQualifier> ParserImpl::variable_qualifier() {
}
return VariableQualifier{sc.value, ac.value};
}
return Expect<VariableQualifier>{VariableQualifier{sc.value, ast::Access::kUndefined},
return Expect<VariableQualifier>{VariableQualifier{sc.value, type::Access::kUndefined},
source};
});
@ -1252,7 +1252,7 @@ Expect<const ast::Type*> ParserImpl::expect_type_specifier_pointer(const Source&
const char* use = "ptr declaration";
auto address_space = type::AddressSpace::kNone;
auto access = ast::Access::kUndefined;
auto access = type::Access::kUndefined;
auto subtype = expect_lt_gt_block(use, [&]() -> Expect<const ast::Type*> {
auto sc = expect_address_space(use);

View File

@ -22,10 +22,10 @@
#include <utility>
#include <vector>
#include "src/tint/ast/access.h"
#include "src/tint/program_builder.h"
#include "src/tint/reader/wgsl/parser_impl_detail.h"
#include "src/tint/reader/wgsl/token.h"
#include "src/tint/type/access.h"
#include "src/tint/type/storage_texture.h"
#include "src/tint/type/texture_dimension.h"
@ -285,7 +285,7 @@ class ParserImpl {
VarDeclInfo(Source source_in,
std::string name_in,
type::AddressSpace address_space_in,
ast::Access access_in,
type::Access access_in,
const ast::Type* type_in);
/// Destructor
~VarDeclInfo();
@ -297,7 +297,7 @@ class ParserImpl {
/// Variable address space
type::AddressSpace address_space = type::AddressSpace::kNone;
/// Variable access control
ast::Access access = ast::Access::kUndefined;
type::Access access = type::Access::kUndefined;
/// Variable type
const ast::Type* type = nullptr;
};
@ -307,7 +307,7 @@ class ParserImpl {
/// The variable's address space
type::AddressSpace address_space = type::AddressSpace::kNone;
/// The variable's access control
ast::Access access = ast::Access::kUndefined;
type::Access access = type::Access::kUndefined;
};
/// MatrixDimensions contains the column and row information for a matrix
@ -525,7 +525,7 @@ class ParserImpl {
/// match a valid access control.
/// @param use a description of what was being parsed if an error was raised
/// @returns the parsed access control.
Expect<ast::Access> expect_access_mode(std::string_view use);
Expect<type::Access> expect_access_mode(std::string_view use);
/// Parses an interpolation sample name identifier, erroring if the next token does not match a
/// valid sample name.
/// @returns the parsed sample name.

View File

@ -192,7 +192,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dRg32Float) {
ASSERT_TRUE(t->Is<ast::Texture>());
ASSERT_TRUE(t->Is<ast::StorageTexture>());
EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::TexelFormat::kRg32Float);
EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kRead);
EXPECT_EQ(t->As<ast::StorageTexture>()->access, type::Access::kRead);
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k1d);
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 36u}}));
}
@ -208,7 +208,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR32Uint) {
ASSERT_TRUE(t->Is<ast::Texture>());
ASSERT_TRUE(t->Is<ast::StorageTexture>());
EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::TexelFormat::kR32Uint);
EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kWrite);
EXPECT_EQ(t->As<ast::StorageTexture>()->access, type::Access::kWrite);
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 35u}}));
}

View File

@ -192,7 +192,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_WithAccess) {
auto* ptr = t.value->As<ast::Pointer>();
ASSERT_TRUE(ptr->type->Is<ast::F32>());
ASSERT_EQ(ptr->address_space, type::AddressSpace::kFunction);
ASSERT_EQ(ptr->access, ast::Access::kRead);
ASSERT_EQ(ptr->access, type::Access::kRead);
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 25u}}));
}

View File

@ -183,7 +183,7 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Ptr_WithAccess) {
auto* ptr = t.value->As<ast::Pointer>();
ASSERT_TRUE(ptr->type->Is<ast::F32>());
ASSERT_EQ(ptr->address_space, type::AddressSpace::kFunction);
ASSERT_EQ(ptr->access, ast::Access::kRead);
ASSERT_EQ(ptr->access, type::Access::kRead);
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 25u}}));
}

View File

@ -20,7 +20,7 @@ namespace {
struct VariableStorageData {
const char* input;
type::AddressSpace address_space;
ast::Access access;
type::Access access;
};
inline std::ostream& operator<<(std::ostream& out, VariableStorageData data) {
out << std::string(data.input);
@ -47,15 +47,15 @@ INSTANTIATE_TEST_SUITE_P(
ParserImplTest,
VariableQualifierTest,
testing::Values(
VariableStorageData{"uniform", type::AddressSpace::kUniform, ast::Access::kUndefined},
VariableStorageData{"workgroup", type::AddressSpace::kWorkgroup, ast::Access::kUndefined},
VariableStorageData{"storage", type::AddressSpace::kStorage, ast::Access::kUndefined},
VariableStorageData{"private", type::AddressSpace::kPrivate, ast::Access::kUndefined},
VariableStorageData{"function", type::AddressSpace::kFunction, ast::Access::kUndefined},
VariableStorageData{"storage, read", type::AddressSpace::kStorage, ast::Access::kRead},
VariableStorageData{"storage, write", type::AddressSpace::kStorage, ast::Access::kWrite},
VariableStorageData{"uniform", type::AddressSpace::kUniform, type::Access::kUndefined},
VariableStorageData{"workgroup", type::AddressSpace::kWorkgroup, type::Access::kUndefined},
VariableStorageData{"storage", type::AddressSpace::kStorage, type::Access::kUndefined},
VariableStorageData{"private", type::AddressSpace::kPrivate, type::Access::kUndefined},
VariableStorageData{"function", type::AddressSpace::kFunction, type::Access::kUndefined},
VariableStorageData{"storage, read", type::AddressSpace::kStorage, type::Access::kRead},
VariableStorageData{"storage, write", type::AddressSpace::kStorage, type::Access::kWrite},
VariableStorageData{"storage, read_write", type::AddressSpace::kStorage,
ast::Access::kReadWrite}));
type::Access::kReadWrite}));
TEST_F(ParserImplTest, VariableQualifier_NoMatch) {
auto p = parser("<not-a-storage-class>");

View File

@ -325,7 +325,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF32) {
// var<storage, read> g : array<S, 3u>;
Structure("S", utils::Vector{Member("a", ty.f32())});
GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage,
ast::Access::kRead, Binding(0_a), Group(0_a));
type::Access::kRead, Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -347,7 +347,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF16) {
Structure("S", utils::Vector{Member("a", ty.f16())});
GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage,
ast::Access::kRead, Binding(0_a), Group(0_a));
type::Access::kRead, Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -360,7 +360,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF16) {
Structure("S", utils::Vector{Member("a", ty.f16())});
Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage,
ast::Access::kRead));
type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -369,7 +369,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32) {
// struct S { x : i32 };
// var<storage, read> g : S;
Structure("S", utils::Vector{Member("x", ty.i32())});
GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -379,7 +379,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32) {
// struct S { x : i32 };
// type t = ptr<storage, read, S>;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, ast::Access::kRead));
Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -391,7 +391,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32Alias
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty.type_name("S"));
Alias("a2", ty.type_name("a1"));
GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -404,7 +404,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32Aliases
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty.type_name("S"));
Alias("a2", ty.type_name("a1"));
Alias("t", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, ast::Access::kRead));
Alias("t", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -415,7 +415,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16) {
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -427,7 +427,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16) {
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, ast::Access::kRead));
Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -441,7 +441,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16Alias
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty.type_name("S"));
Alias("a2", ty.type_name("a1"));
GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -456,14 +456,14 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16Aliases
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty.type_name("S"));
Alias("a2", ty.type_name("a1"));
Alias("g", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, ast::Access::kRead));
Alias("g", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_NotStorage_AccessMode) {
// var<private, read> g : a;
GlobalVar(Source{{12, 34}}, "g", ty.i32(), type::AddressSpace::kPrivate, ast::Access::kRead);
GlobalVar(Source{{12, 34}}, "g", ty.i32(), type::AddressSpace::kPrivate, type::Access::kRead);
ASSERT_FALSE(r()->Resolve());
@ -474,8 +474,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_NotStorage_AccessMode)
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NotStorage_AccessMode) {
// type t = ptr<private, read, a>;
Alias("t",
ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kPrivate, ast::Access::kRead));
Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kPrivate,
type::Access::kRead));
ASSERT_FALSE(r()->Resolve());
@ -486,7 +486,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NotStorage_AccessMode) {
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadAccessMode) {
// @group(0) @binding(0) var<storage, read> a : i32;
GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead, Group(0_a),
GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a),
Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -494,14 +494,14 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadAccessMode
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadAccessMode) {
// type t = ptr<storage, read, i32>;
Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead));
Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadWriteAccessMode) {
// @group(0) @binding(0) var<storage, read_write> a : i32;
GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kReadWrite, Group(0_a),
GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a),
Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -509,14 +509,14 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadWriteAcces
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadWriteAccessMode) {
// type t = ptr<storage, read_write, i32>;
Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, ast::Access::kReadWrite));
Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_WriteAccessMode) {
// @group(0) @binding(0) var<storage, read_write> a : i32;
GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kWrite,
GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, type::Access::kWrite,
Group(0_a), Binding(0_a));
ASSERT_FALSE(r()->Resolve());
@ -528,7 +528,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_WriteAccessMod
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_WriteAccessMode) {
// type t = ptr<storage, read_write, i32>;
Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kStorage,
ast::Access::kWrite));
type::Access::kWrite));
ASSERT_FALSE(r()->Resolve());

View File

@ -33,7 +33,7 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) {
auto* s = Structure("S", utils::Vector{
Member("m", ty.i32()),
});
GlobalVar(Source{{12, 34}}, "a", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{12, 34}}, "a", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i));
@ -232,7 +232,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
auto make_type = [&] {
return ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kRgba8Unorm,
ast::Access::kWrite);
type::Access::kWrite);
};
GlobalVar("a", make_type(), Binding(0_a), Group(0_a));
@ -253,7 +253,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) {
Member("a", ty.atomic(ty.i32())),
});
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), type::AddressSpace::kStorage,
ast::Access::kReadWrite, Binding(0_a), Group(0_a));
type::Access::kReadWrite, Binding(0_a), Group(0_a));
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a")));
@ -270,7 +270,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) {
Member("a", ty.array(ty.f32())),
});
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), type::AddressSpace::kStorage,
ast::Access::kReadWrite, Binding(0_a), Group(0_a));
type::Access::kReadWrite, Binding(0_a), Group(0_a));
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a")));

View File

@ -48,7 +48,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) {
TEST_F(ResolverAtomicTest, GlobalStorageStruct) {
auto* s = Structure("s", utils::Vector{Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
auto* g = GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite,
auto* g = GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
Binding(0_a), Group(0_a));
EXPECT_TRUE(r()->Resolve()) << r()->error();

View File

@ -34,14 +34,14 @@ TEST_F(ResolverAtomicValidationTest, AddressSpace_WorkGroup) {
TEST_F(ResolverAtomicValidationTest, AddressSpace_Storage) {
GlobalVar("g", ty.atomic(Source{{12, 34}}, ty.i32()), type::AddressSpace::kStorage,
ast::Access::kReadWrite, Group(0_a), Binding(0_a));
type::Access::kReadWrite, Group(0_a), Binding(0_a));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverAtomicValidationTest, AddressSpace_Storage_Struct) {
auto* s = Structure("s", utils::Vector{Member(Source{{12, 34}}, "a", ty.atomic(ty.i32()))});
GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kReadWrite, Group(0_a),
GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a),
Binding(0_a));
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -198,7 +198,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_Complex) {
TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) {
auto* s = Structure("s", utils::Vector{Member(Source{{12, 34}}, "a", ty.atomic(ty.i32()))});
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead,
Group(0_a), Binding(0_a));
EXPECT_FALSE(r()->Resolve());
@ -210,7 +210,7 @@ TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) {
TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Struct) {
auto* s = Structure("s", utils::Vector{Member(Source{{12, 34}}, "a", ty.atomic(ty.i32()))});
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead,
Group(0_a), Binding(0_a));
EXPECT_FALSE(r()->Resolve());
@ -228,8 +228,8 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStruct) {
auto* Inner =
Structure("Inner", utils::Vector{Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))});
auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))});
GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage, ast::Access::kRead,
Group(0_a), Binding(0_a));
GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage,
type::Access::kRead, Group(0_a), Binding(0_a));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -246,8 +246,8 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStructOfArray) {
auto* Inner =
Structure("Inner", utils::Vector{Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))});
auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))});
GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage, ast::Access::kRead,
Group(0_a), Binding(0_a));
GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage,
type::Access::kRead, Group(0_a), Binding(0_a));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -287,7 +287,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Complex) {
auto* s2 = Structure("S2", utils::Vector{Member("x", ty.Of(s3))});
auto* s1 = Structure("S1", utils::Vector{Member("x", ty.Of(s2))});
auto* s0 = Structure("S0", utils::Vector{Member("x", ty.Of(s1))});
GlobalVar(Source{{12, 34}}, "g", ty.Of(s0), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{12, 34}}, "g", ty.Of(s0), type::AddressSpace::kStorage, type::Access::kRead,
Group(0_a), Binding(0_a));
EXPECT_FALSE(r()->Resolve());

View File

@ -723,7 +723,7 @@ TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAFloat) {
TEST_F(StructMemberAttributeTest, Align_Attribute_Var) {
GlobalVar(Source{{1, 2}}, "val", ty.f32(), type::AddressSpace::kPrivate,
ast::Access::kUndefined, Expr(1.23_f));
type::Access::kUndefined, Expr(1.23_f));
Structure(Source{{6, 4}}, "mystruct",
utils::Vector{Member(Source{{12, 5}}, "a", ty.f32(),
@ -797,7 +797,7 @@ TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAFloat) {
TEST_F(StructMemberAttributeTest, Size_Attribute_Var) {
GlobalVar(Source{{1, 2}}, "val", ty.f32(), type::AddressSpace::kPrivate,
ast::Access::kUndefined, Expr(1.23_f));
type::Access::kUndefined, Expr(1.23_f));
Structure(Source{{6, 4}}, "mystruct",
utils::Vector{Member(Source{{12, 5}}, "a", ty.f32(),
@ -1159,7 +1159,7 @@ TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) {
auto* s = Structure("S", utils::Vector{
Member("x", ty.i32()),
});
GlobalVar(Source{{12, 34}}, "G", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead);
GlobalVar(Source{{12, 34}}, "G", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),

View File

@ -214,7 +214,7 @@ using ResolverBuiltinArrayTest = ResolverTest;
TEST_F(ResolverBuiltinArrayTest, ArrayLength_Vector) {
auto* ary = ty.array<i32>();
auto* str = Structure("S", utils::Vector{Member("x", ary)});
GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, ast::Access::kRead, Binding(0_a),
GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
Group(0_a));
auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x")));

View File

@ -652,7 +652,7 @@ TEST_F(ResolverBuiltinValidationTest, WorkgroupUniformLoad_WrongAddressSpace) {
// fn foo() {
// workgroupUniformLoad(&v);
// }
GlobalVar("v", ty.i32(), type::AddressSpace::kStorage, ast::Access::kReadWrite,
GlobalVar("v", ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite,
utils::Vector{Group(0_a), Binding(0_a)});
WrapInFunction(CallStmt(Call("workgroupUniformLoad", AddressOf(Source{{12, 34}}, "v"))));

View File

@ -233,7 +233,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, ReadOnlyBuffer) {
// {
// a += 1i;
// }
GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, type::Access::kRead,
Group(0_a), Binding(0_a));
WrapInFunction(CompoundAssign(Source{{56, 78}}, "a", 1_i, ast::BinaryOp::kAdd));

View File

@ -1297,7 +1297,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
GlobalVar(Sym(), ty.external_texture());
GlobalVar(Sym(), ty.multisampled_texture(type::TextureDimension::k2d, T));
GlobalVar(Sym(), ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float,
ast::Access::kRead)); //
type::Access::kRead)); //
GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler));
GlobalVar(Sym(), ty.i32(), utils::Vector{Binding(V), Group(V)});

View File

@ -29,7 +29,7 @@ TEST_F(ResolverHostShareableValidationTest, BoolMember) {
auto* s =
Structure("S", utils::Vector{Member(Source{{56, 78}}, "x", ty.bool_(Source{{12, 34}}))});
GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_FALSE(r()->Resolve());
@ -45,7 +45,7 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) {
auto* s = Structure(
"S", utils::Vector{Member(Source{{56, 78}}, "x", ty.vec3<bool>(Source{{12, 34}}))});
GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_FALSE(r()->Resolve());
@ -62,7 +62,7 @@ TEST_F(ResolverHostShareableValidationTest, Aliases) {
auto* s = Structure(
"S", utils::Vector{Member(Source{{56, 78}}, "x", ty.type_name(Source{{12, 34}}, "a1"))});
auto* a2 = Alias("a2", ty.Of(s));
GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_FALSE(r()->Resolve());
@ -81,7 +81,7 @@ TEST_F(ResolverHostShareableValidationTest, NestedStructures) {
auto* s = Structure("S", utils::Vector{Member(Source{{7, 8}}, "m", ty.Of(i3))});
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_FALSE(r()->Resolve());
@ -120,7 +120,7 @@ TEST_F(ResolverHostShareableValidationTest, NoError) {
auto* s = Structure("S", utils::Vector{Member(Source{{7, 8}}, "m", ty.Of(i3))});
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();

View File

@ -193,7 +193,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, ReadOnlyBuffer) {
// {
// a++;
// }
GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead,
GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, type::Access::kRead,
Group(0_a), Binding(0_a));
WrapInFunction(Increment(Source{{56, 78}}, "a"));

View File

@ -329,7 +329,7 @@ class TemplateNumberMatcher : public NumberMatcher {
// template
////////////////////////////////////////////////////////////////////////////////
using TexelFormat = ast::TexelFormat;
using Access = ast::Access;
using Access = type::Access;
using AddressSpace = type::AddressSpace;
using ParameterUsage = sem::ParameterUsage;
using PipelineStage = ast::PipelineStage;
@ -561,7 +561,7 @@ bool match_ptr(MatchState&, const type::Type* ty, Number& S, const type::Type*&
const type::Pointer* build_ptr(MatchState& state, Number S, const type::Type* T, Number& A) {
return state.builder.create<type::Pointer>(T, static_cast<type::AddressSpace>(S.Value()),
static_cast<ast::Access>(A.Value()));
static_cast<type::Access>(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<sem::Parameter>(
nullptr, static_cast<uint32_t>(params.Length()), p.type, type::AddressSpace::kNone,
ast::Access::kUndefined, p.usage));
type::Access::kUndefined, p.usage));
}
sem::PipelineStageSet supported_stages;
if (match.overload->flags.Contains(OverloadFlag::kSupportsVertexPipeline)) {
@ -1477,7 +1477,7 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type,
for (auto& p : match.parameters) {
params.Push(builder.create<sem::Parameter>(
nullptr, static_cast<uint32_t>(params.Length()), p.type, type::AddressSpace::kNone,
ast::Access::kUndefined, p.usage));
type::Access::kUndefined, p.usage));
}
auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant
: sem::EvaluationStage::kRuntime;
@ -1492,7 +1492,7 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type,
auto* target = converters.GetOrCreate(match, [&]() {
auto param = builder.create<sem::Parameter>(
nullptr, 0u, match.parameters[0].type, type::AddressSpace::kNone,
ast::Access::kUndefined, match.parameters[0].usage);
type::Access::kUndefined, match.parameters[0].usage);
auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant
: sem::EvaluationStage::kRuntime;
return builder.create<sem::TypeConversion>(match.return_type, param, eval_stage);

View File

@ -232,7 +232,7 @@ TEST_F(IntrinsicTableTest, MatchPointer) {
auto* i32 = create<type::I32>();
auto* atomicI32 = create<type::Atomic>(i32);
auto* ptr =
create<type::Pointer>(atomicI32, type::AddressSpace::kWorkgroup, ast::Access::kReadWrite);
create<type::Pointer>(atomicI32, type::AddressSpace::kWorkgroup, type::Access::kReadWrite);
auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{ptr},
sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@ -256,7 +256,7 @@ TEST_F(IntrinsicTableTest, MatchArray) {
auto* arr =
create<type::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
auto* arr_ptr =
create<type::Pointer>(arr, type::AddressSpace::kStorage, ast::Access::kReadWrite);
create<type::Pointer>(arr, type::AddressSpace::kStorage, type::Access::kReadWrite);
auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{arr_ptr},
sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@ -416,7 +416,7 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
auto* vec4_f32 = create<type::Vector>(f32, 4u);
auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types());
auto* tex = create<type::StorageTexture>(
type::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite, subtype);
type::TextureDimension::k2d, ast::TexelFormat::kR32Float, type::Access::kWrite, subtype);
auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32},
sem::EvaluationStage::kConstant, Source{});
@ -448,7 +448,7 @@ TEST_F(IntrinsicTableTest, ImplicitLoadOnReference) {
auto result = table->Lookup(
BuiltinType::kCos,
utils::Vector{
create<type::Reference>(f32, type::AddressSpace::kFunction, ast::Access::kReadWrite),
create<type::Reference>(f32, type::AddressSpace::kFunction, type::Access::kReadWrite),
},
sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@ -549,7 +549,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
auto* af = create<type::AbstractFloat>();
auto* bool_ref = create<type::Reference>(create<type::Bool>(), type::AddressSpace::kFunction,
ast::Access::kReadWrite);
type::Access::kReadWrite);
auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_ref},
sem::EvaluationStage::kRuntime, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();

View File

@ -96,7 +96,7 @@ TEST_F(ResolverIsHostShareable, Matrix) {
TEST_F(ResolverIsHostShareable, Pointer) {
auto* ptr = create<type::Pointer>(create<type::I32>(), type::AddressSpace::kPrivate,
ast::Access::kReadWrite);
type::Access::kReadWrite);
EXPECT_FALSE(r()->IsHostShareable(ptr));
}

View File

@ -79,7 +79,7 @@ TEST_F(ResolverIsStorableTest, Matrix) {
TEST_F(ResolverIsStorableTest, Pointer) {
auto* ptr = create<type::Pointer>(create<type::I32>(), type::AddressSpace::kPrivate,
ast::Access::kReadWrite);
type::Access::kReadWrite);
EXPECT_FALSE(r()->IsStorable(ptr));
}

View File

@ -101,11 +101,11 @@ TEST_F(ResolverPtrRefTest, DefaultPtrAddressSpace) {
ASSERT_TRUE(TypeOf(storage_ptr)->Is<type::Pointer>())
<< "storage_ptr is " << TypeOf(storage_ptr)->TypeInfo().name;
EXPECT_EQ(TypeOf(function_ptr)->As<type::Pointer>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(private_ptr)->As<type::Pointer>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(workgroup_ptr)->As<type::Pointer>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(uniform_ptr)->As<type::Pointer>()->Access(), ast::Access::kRead);
EXPECT_EQ(TypeOf(storage_ptr)->As<type::Pointer>()->Access(), ast::Access::kRead);
EXPECT_EQ(TypeOf(function_ptr)->As<type::Pointer>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(private_ptr)->As<type::Pointer>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(workgroup_ptr)->As<type::Pointer>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(uniform_ptr)->As<type::Pointer>()->Access(), type::Access::kRead);
EXPECT_EQ(TypeOf(storage_ptr)->As<type::Pointer>()->Access(), type::Access::kRead);
}
} // namespace

View File

@ -144,7 +144,7 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) {
auto* inner = Structure("Inner", utils::Vector{Member("arr", ty.array<i32, 4>())});
auto* buf = Structure("S", utils::Vector{Member("inner", ty.Of(inner))});
auto* storage = GlobalVar("s", ty.Of(buf), type::AddressSpace::kStorage,
ast::Access::kReadWrite, Binding(0_a), Group(0_a));
type::Access::kReadWrite, Binding(0_a), Group(0_a));
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i);
auto* ptr =

View File

@ -257,7 +257,7 @@ type::Type* Resolver::Type(const ast::Type* ty) {
[&](const ast::Pointer* t) -> type::Pointer* {
if (auto* el = Type(t->type)) {
auto access = t->access;
if (access == ast::Access::kUndefined) {
if (access == type::Access::kUndefined) {
access = DefaultAccessForAddressSpace(t->address_space);
}
auto ptr = builder_->create<type::Pointer>(el, t->address_space, access);
@ -405,12 +405,12 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) {
if (is_global) {
sem = builder_->create<sem::GlobalVariable>(
v, ty, sem::EvaluationStage::kRuntime, type::AddressSpace::kNone,
ast::Access::kUndefined,
type::Access::kUndefined,
/* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt);
} else {
sem = builder_->create<sem::LocalVariable>(v, ty, sem::EvaluationStage::kRuntime,
type::AddressSpace::kNone,
ast::Access::kUndefined, current_statement_,
type::Access::kUndefined, current_statement_,
/* constant_value */ nullptr);
}
@ -465,7 +465,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) {
}
auto* sem = builder_->create<sem::GlobalVariable>(
v, ty, sem::EvaluationStage::kOverride, type::AddressSpace::kNone, ast::Access::kUndefined,
v, ty, sem::EvaluationStage::kOverride, type::AddressSpace::kNone, type::Access::kUndefined,
/* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt);
sem->SetInitializer(rhs);
@ -559,10 +559,10 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
const auto value = rhs->ConstantValue();
auto* sem = is_global ? static_cast<sem::Variable*>(builder_->create<sem::GlobalVariable>(
c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kNone,
ast::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt))
type::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt))
: static_cast<sem::Variable*>(builder_->create<sem::LocalVariable>(
c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kNone,
ast::Access::kUndefined, current_statement_, value));
type::Access::kUndefined, current_statement_, value));
sem->SetInitializer(rhs);
builder_->Sem().Add(c, sem);
@ -627,7 +627,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
}
auto access = var->declared_access;
if (access == ast::Access::kUndefined) {
if (access == type::Access::kUndefined) {
access = DefaultAccessForAddressSpace(address_space);
}
@ -791,7 +791,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index)
}
auto* sem = builder_->create<sem::Parameter>(
param, index, ty, type::AddressSpace::kNone, ast::Access::kUndefined,
param, index, ty, type::AddressSpace::kNone, type::Access::kUndefined,
sem::ParameterUsage::kNone, binding_point, location);
builder_->Sem().Add(param, sem);
return sem;
@ -821,17 +821,17 @@ utils::Result<uint32_t> Resolver::LocationAttribute(const ast::LocationAttribute
return static_cast<uint32_t>(value);
}
ast::Access Resolver::DefaultAccessForAddressSpace(type::AddressSpace address_space) {
type::Access Resolver::DefaultAccessForAddressSpace(type::AddressSpace address_space) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class
switch (address_space) {
case type::AddressSpace::kStorage:
case type::AddressSpace::kUniform:
case type::AddressSpace::kHandle:
return ast::Access::kRead;
return type::Access::kRead;
default:
break;
}
return ast::Access::kReadWrite;
return type::Access::kReadWrite;
}
bool Resolver::AllocateOverridableConstantIds() {
@ -2103,7 +2103,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
static_cast<uint32_t>(i), // index
arr->ElemType(), // type
type::AddressSpace::kNone, // address_space
ast::Access::kUndefined);
type::Access::kUndefined);
});
return builder_->create<sem::TypeInitializer>(arr, std::move(params),
args_stage);
@ -2132,7 +2132,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
static_cast<uint32_t>(i), // index
str->Members()[i]->Type(), // type
type::AddressSpace::kNone, // address_space
ast::Access::kUndefined); // access
type::Access::kUndefined); // access
}
return builder_->create<sem::TypeInitializer>(str, std::move(params),
args_stage);

View File

@ -382,7 +382,7 @@ class Resolver {
/// @param address_space the address space
/// @returns the default access control for the given address space
ast::Access DefaultAccessForAddressSpace(type::AddressSpace address_space);
type::Access DefaultAccessForAddressSpace(type::AddressSpace address_space);
/// Allocate constant IDs for pipeline-overridable constants.
/// @returns true on success, false on error

View File

@ -920,7 +920,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) {
auto* s = Structure("S", utils::Vector{Member("m", ty.u32())});
auto* sb_var = GlobalVar("sb_var", ty.Of(s), type::AddressSpace::kStorage,
ast::Access::kReadWrite, Binding(0_a), Group(0_a));
type::Access::kReadWrite, Binding(0_a), Group(0_a));
auto* wg_var = GlobalVar("wg_var", ty.f32(), type::AddressSpace::kWorkgroup);
auto* priv_var = GlobalVar("priv_var", ty.f32(), type::AddressSpace::kPrivate);
@ -988,7 +988,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) {
auto* s = Structure("S", utils::Vector{Member("m", ty.u32())});
auto* sb_var = GlobalVar("sb_var", ty.Of(s), type::AddressSpace::kStorage,
ast::Access::kReadWrite, Binding(0_a), Group(0_a));
type::Access::kReadWrite, Binding(0_a), Group(0_a));
auto* wg_var = GlobalVar("wg_var", ty.f32(), type::AddressSpace::kWorkgroup);
auto* priv_var = GlobalVar("priv_var", ty.f32(), type::AddressSpace::kPrivate);
@ -1914,7 +1914,7 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
EXPECT_EQ(Sem().Get(var)->Access(), ast::Access::kRead);
EXPECT_EQ(Sem().Get(var)->Access(), type::Access::kRead);
}
TEST_F(ResolverTest, BindingPoint_SetForResources) {

View File

@ -617,13 +617,13 @@ struct DataType<ptr<T>> {
/// @return a new AST alias type
static inline const ast::Type* AST(ProgramBuilder& b) {
return b.create<ast::Pointer>(DataType<T>::AST(b), type::AddressSpace::kPrivate,
ast::Access::kUndefined);
type::Access::kUndefined);
}
/// @param b the ProgramBuilder
/// @return the semantic aliased type
static inline const type::Type* Sem(ProgramBuilder& b) {
return b.create<type::Pointer>(DataType<T>::Sem(b), type::AddressSpace::kPrivate,
ast::Access::kReadWrite);
type::Access::kReadWrite);
}
/// @param b the ProgramBuilder

View File

@ -178,7 +178,7 @@ TEST_P(SideEffectsBuiltinTest, Test) {
GlobalVar("storage_arr", ty.array<f32>(), type::AddressSpace::kStorage, Group(0_a),
Binding(AInt(next_binding++)));
GlobalVar("workgroup_arr", ty.array<f32, 4>(), type::AddressSpace::kWorkgroup);
GlobalVar("a", ty.atomic(ty.i32()), type::AddressSpace::kStorage, ast::Access::kReadWrite,
GlobalVar("a", ty.atomic(ty.i32()), type::AddressSpace::kStorage, type::Access::kReadWrite,
Group(0_a), Binding(AInt(next_binding++)));
if (c.pipeline_stage != ast::PipelineStage::kCompute) {
GlobalVar("t2d", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(0_a),
@ -191,7 +191,7 @@ TEST_P(SideEffectsBuiltinTest, Test) {
Group(0_a), Binding(AInt(next_binding++)));
GlobalVar("tstorage2d",
ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float,
ast::Access::kWrite),
type::Access::kWrite),
Group(0_a), Binding(AInt(next_binding++)));
GlobalVar("s2d", ty.sampler(ast::SamplerKind::kSampler), Group(0_a),
Binding(AInt(next_binding++)));

View File

@ -160,7 +160,7 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableViaLocalArray) {
TEST_F(ResolverAddressSpaceUseTest, StructMultipleAddressSpaceUses) {
auto* s = Structure("S", utils::Vector{Member("a", ty.f32())});
GlobalVar("x", ty.Of(s), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
GlobalVar("y", ty.Of(s), type::AddressSpace::kStorage, ast::Access::kRead, Binding(1_a),
GlobalVar("y", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a),
Group(0_a));
WrapInFunction(Var("g", ty.Of(s)));

View File

@ -98,7 +98,7 @@ TEST_P(InferTypeTest_FromInitializerExpression, All) {
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* got = TypeOf(a_ident);
auto* expected = create<type::Reference>(
params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, ast::Access::kReadWrite);
params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, type::Access::kReadWrite);
ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n"
<< "expected: " << FriendlyName(expected) << "\n";
}
@ -152,7 +152,7 @@ TEST_P(InferTypeTest_FromArithmeticExpression, All) {
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* got = TypeOf(a_ident);
auto* expected = create<type::Reference>(
params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, ast::Access::kReadWrite);
params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, type::Access::kReadWrite);
ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n"
<< "expected: " << FriendlyName(expected) << "\n";
}
@ -200,7 +200,7 @@ TEST_P(InferTypeTest_FromCallExpression, All) {
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* got = TypeOf(a_ident);
auto* expected = create<type::Reference>(
params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, ast::Access::kReadWrite);
params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, type::Access::kReadWrite);
ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n"
<< "expected: " << FriendlyName(expected) << "\n";
}

View File

@ -1114,7 +1114,7 @@ TEST_P(StorageTextureDimensionTest, All) {
auto& params = GetParam();
auto* st = ty.storage_texture(Source{{12, 34}}, params.dim, ast::TexelFormat::kR32Uint,
ast::Access::kWrite);
type::Access::kWrite);
GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1166,19 +1166,19 @@ TEST_P(StorageTextureFormatTest, All) {
// var d : texture_storage_3d<*, write>;
auto* st_a = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, params.format,
ast::Access::kWrite);
type::Access::kWrite);
GlobalVar("a", st_a, Group(0_a), Binding(0_a));
auto* st_b =
ty.storage_texture(type::TextureDimension::k2d, params.format, ast::Access::kWrite);
ty.storage_texture(type::TextureDimension::k2d, params.format, type::Access::kWrite);
GlobalVar("b", st_b, Group(0_a), Binding(1_a));
auto* st_c =
ty.storage_texture(type::TextureDimension::k2dArray, params.format, ast::Access::kWrite);
ty.storage_texture(type::TextureDimension::k2dArray, params.format, type::Access::kWrite);
GlobalVar("c", st_c, Group(0_a), Binding(2_a));
auto* st_d =
ty.storage_texture(type::TextureDimension::k3d, params.format, ast::Access::kWrite);
ty.storage_texture(type::TextureDimension::k3d, params.format, type::Access::kWrite);
GlobalVar("d", st_d, Group(0_a), Binding(3_a));
if (params.is_valid) {
@ -1201,7 +1201,7 @@ TEST_F(StorageTextureAccessTest, MissingAccess_Fail) {
// var a : texture_storage_1d<ru32int>;
auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
ast::TexelFormat::kR32Uint, ast::Access::kUndefined);
ast::TexelFormat::kR32Uint, type::Access::kUndefined);
GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1214,7 +1214,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) {
// var a : texture_storage_1d<ru32int, read_write>;
auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
ast::TexelFormat::kR32Uint, ast::Access::kReadWrite);
ast::TexelFormat::kR32Uint, type::Access::kReadWrite);
GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1228,7 +1228,7 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) {
// var a : texture_storage_1d<ru32int, read>;
auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
ast::TexelFormat::kR32Uint, ast::Access::kRead);
ast::TexelFormat::kR32Uint, type::Access::kRead);
GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1242,7 +1242,7 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) {
// var a : texture_storage_1d<ru32int, write>;
auto* st = ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kR32Uint,
ast::Access::kWrite);
type::Access::kWrite);
GlobalVar("a", st, Group(0_a), Binding(0_a));

View File

@ -1151,7 +1151,7 @@ class UniformityGraph {
[&](const sem::GlobalVariable* global) {
// Loads from global read-write variables may be non-uniform.
if (global->Declaration()->Is<ast::Var>() &&
global->Access() != ast::Access::kRead && load_rule) {
global->Access() != type::Access::kRead && load_rule) {
node->AddEdge(current_function_->may_be_non_uniform);
} else {
node->AddEdge(cf);
@ -1168,7 +1168,7 @@ class UniformityGraph {
// We are loading from the pointer, so add an edge to its contents.
auto* root = var_user->RootIdentifier();
if (root->Is<sem::GlobalVariable>()) {
if (root->Access() != ast::Access::kRead) {
if (root->Access() != type::Access::kRead) {
// The contents of a mutable global variable is always non-uniform.
node->AddEdge(current_function_->may_be_non_uniform);
}
@ -1420,7 +1420,7 @@ class UniformityGraph {
auto* root = sem_arg->RootIdentifier();
if (root->Is<sem::GlobalVariable>()) {
if (root->Access() != ast::Access::kRead) {
if (root->Access() != type::Access::kRead) {
// The contents of a mutable global variable is always non-uniform.
arg_contents->AddEdge(current_function_->may_be_non_uniform);
}

View File

@ -278,7 +278,7 @@ bool Validator::Pointer(const ast::Pointer* a, const type::Pointer* s) const {
return false;
}
if (a->access != ast::Access::kUndefined) {
if (a->access != type::Access::kUndefined) {
// https://www.w3.org/TR/WGSL/#access-mode-defaults
// When writing a variable declaration or a pointer type in WGSL source:
// * For the storage address space, the access mode is optional, and defaults to read.
@ -296,9 +296,9 @@ bool Validator::Pointer(const ast::Pointer* a, const type::Pointer* s) const {
bool Validator::StorageTexture(const ast::StorageTexture* t) const {
switch (t->access) {
case ast::Access::kWrite:
case type::Access::kWrite:
break;
case ast::Access::kUndefined:
case type::Access::kUndefined:
AddError("storage texture missing access control", t->source);
return false;
default:
@ -693,7 +693,7 @@ bool Validator::Var(const sem::Variable* v) const {
}
}
if (var->declared_access != ast::Access::kUndefined) {
if (var->declared_access != type::Access::kUndefined) {
// https://www.w3.org/TR/WGSL/#access-mode-defaults
// When writing a variable declaration or a pointer type in WGSL source:
// * For the storage address space, the access mode is optional, and defaults to read.
@ -2353,7 +2353,7 @@ bool Validator::Assignment(const ast::Statement* a, const type::Type* rhs_ty) co
AddError("storage type of assignment must be constructible", a->source);
return false;
}
if (lhs_ref->Access() == ast::Access::kRead) {
if (lhs_ref->Access() == type::Access::kRead) {
AddError("cannot store into a read-only type '" + sem_.RawTypeNameOf(lhs_ty) + "'",
a->source);
return false;
@ -2394,7 +2394,7 @@ bool Validator::IncrementDecrementStatement(const ast::IncrementDecrementStateme
return false;
}
if (lhs_ref->Access() == ast::Access::kRead) {
if (lhs_ref->Access() == type::Access::kRead) {
AddError("cannot modify read-only type '" + sem_.RawTypeNameOf(lhs_ty) + "'", inc->source);
return false;
}
@ -2454,7 +2454,7 @@ std::string Validator::VectorPretty(uint32_t size, const type::Type* element_typ
bool Validator::CheckTypeAccessAddressSpace(
const type::Type* store_ty,
ast::Access access,
type::Access access,
type::AddressSpace address_space,
utils::VectorRef<const tint::ast::Attribute*> attributes,
const Source& source) const {
@ -2472,7 +2472,7 @@ bool Validator::CheckTypeAccessAddressSpace(
return false;
}
if (address_space == type::AddressSpace::kStorage && access == ast::Access::kWrite) {
if (address_space == type::AddressSpace::kStorage && access == type::Access::kWrite) {
// The access mode for the storage address space can only be 'read' or
// 'read_write'.
AddError("access mode 'write' is not valid for the 'storage' address space", source);
@ -2484,7 +2484,7 @@ bool Validator::CheckTypeAccessAddressSpace(
address_space != type::AddressSpace::kWorkgroup) {
return "atomic variables must have <storage> or <workgroup> address space";
}
if (address_space == type::AddressSpace::kStorage && access != ast::Access::kReadWrite) {
if (address_space == type::AddressSpace::kStorage && access != type::Access::kReadWrite) {
return "atomic variables in <storage> address space must have read_write access "
"mode";
}

View File

@ -518,7 +518,7 @@ class Validator {
/// @param source the source for the error
/// @returns true on success, false if an error was raised.
bool CheckTypeAccessAddressSpace(const type::Type* store_ty,
ast::Access access,
type::Access access,
type::AddressSpace address_space,
utils::VectorRef<const tint::ast::Attribute*> attributes,
const Source& source) const;

View File

@ -79,7 +79,7 @@ TEST_F(ValidatorIsStorableTest, Matrix) {
TEST_F(ValidatorIsStorableTest, Pointer) {
auto* ptr = create<type::Pointer>(create<type::I32>(), type::AddressSpace::kPrivate,
ast::Access::kReadWrite);
type::Access::kReadWrite);
EXPECT_FALSE(v()->IsStorable(ptr));
}

View File

@ -149,12 +149,12 @@ TEST_F(ResolverVariableTest, LocalVar_WithInitializer) {
ASSERT_TRUE(TypeOf(s)->Is<type::Reference>());
ASSERT_TRUE(TypeOf(a)->Is<type::Reference>());
EXPECT_EQ(TypeOf(i)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(u)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(f)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(b)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(s)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(a)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(i)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(u)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(f)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(b)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(s)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(a)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_TRUE(TypeOf(i)->As<type::Reference>()->StoreType()->Is<type::I32>());
EXPECT_TRUE(TypeOf(u)->As<type::Reference>()->StoreType()->Is<type::U32>());
@ -473,7 +473,7 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) {
auto* inner = Structure("Inner", utils::Vector{Member("arr", ty.array<i32, 4>())});
auto* buf = Structure("S", utils::Vector{Member("inner", ty.Of(inner))});
auto* storage = GlobalVar("s", ty.Of(buf), type::AddressSpace::kStorage,
ast::Access::kReadWrite, Binding(0_a), Group(0_a));
type::Access::kReadWrite, Binding(0_a), Group(0_a));
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 3_i);
auto* ptr = Let("p", AddressOf(expr));
@ -485,8 +485,8 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) {
ASSERT_TRUE(TypeOf(expr)->Is<type::Reference>());
ASSERT_TRUE(TypeOf(ptr)->Is<type::Pointer>());
EXPECT_EQ(TypeOf(expr)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(ptr)->As<type::Pointer>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(expr)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(ptr)->As<type::Pointer>()->Access(), type::Access::kReadWrite);
}
TEST_F(ResolverVariableTest, LocalLet_ShadowsAlias) {
@ -1054,11 +1054,11 @@ TEST_F(ResolverVariableTest, GlobalVar_AddressSpace) {
ASSERT_TRUE(TypeOf(storage)->Is<type::Reference>());
ASSERT_TRUE(TypeOf(handle)->Is<type::Reference>());
EXPECT_EQ(TypeOf(private_)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(workgroup)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(uniform)->As<type::Reference>()->Access(), ast::Access::kRead);
EXPECT_EQ(TypeOf(storage)->As<type::Reference>()->Access(), ast::Access::kRead);
EXPECT_EQ(TypeOf(handle)->As<type::Reference>()->Access(), ast::Access::kRead);
EXPECT_EQ(TypeOf(private_)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(workgroup)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(uniform)->As<type::Reference>()->Access(), type::Access::kRead);
EXPECT_EQ(TypeOf(storage)->As<type::Reference>()->Access(), type::Access::kRead);
EXPECT_EQ(TypeOf(handle)->As<type::Reference>()->Access(), type::Access::kRead);
}
TEST_F(ResolverVariableTest, GlobalVar_ExplicitAddressSpace) {
@ -1066,13 +1066,13 @@ TEST_F(ResolverVariableTest, GlobalVar_ExplicitAddressSpace) {
auto* buf = Structure("S", utils::Vector{Member("m", ty.i32())});
auto* storage = GlobalVar("sb", ty.Of(buf), type::AddressSpace::kStorage,
ast::Access::kReadWrite, Binding(1_a), Group(0_a));
type::Access::kReadWrite, Binding(1_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
ASSERT_TRUE(TypeOf(storage)->Is<type::Reference>());
EXPECT_EQ(TypeOf(storage)->As<type::Reference>()->Access(), ast::Access::kReadWrite);
EXPECT_EQ(TypeOf(storage)->As<type::Reference>()->Access(), type::Access::kReadWrite);
}
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -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<i32>(type::AddressSpace::kStorage, ast::Access::kReadWrite),
ty.pointer<i32>(type::AddressSpace::kStorage, type::Access::kReadWrite),
AddressOf(expr));
WrapInFunction(ptr);

View File

@ -32,7 +32,7 @@ Variable::Variable(const ast::Variable* declaration,
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const constant::Value* constant_value)
: declaration_(declaration),
type_(type),
@ -47,7 +47,7 @@ LocalVariable::LocalVariable(const ast::Variable* declaration,
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const sem::Statement* statement,
const constant::Value* constant_value)
: Base(declaration, type, stage, address_space, access, constant_value),
@ -59,7 +59,7 @@ GlobalVariable::GlobalVariable(const ast::Variable* declaration,
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const constant::Value* constant_value,
sem::BindingPoint binding_point,
std::optional<uint32_t> location)
@ -73,7 +73,7 @@ Parameter::Parameter(const ast::Parameter* declaration,
uint32_t index,
const type::Type* type,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const ParameterUsage usage /* = ParameterUsage::kNone */,
sem::BindingPoint binding_point /* = {} */,
std::optional<uint32_t> location /* = std::nullopt */)

View File

@ -21,11 +21,11 @@
#include "tint/override_id.h"
#include "src/tint/ast/access.h"
#include "src/tint/ast/parameter.h"
#include "src/tint/sem/binding_point.h"
#include "src/tint/sem/expression.h"
#include "src/tint/sem/parameter_usage.h"
#include "src/tint/type/access.h"
#include "src/tint/type/address_space.h"
#include "src/tint/type/type.h"
#include "src/tint/utils/unique_vector.h"
@ -58,7 +58,7 @@ class Variable : public Castable<Variable, Node> {
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const constant::Value* constant_value);
/// Destructor
@ -77,7 +77,7 @@ class Variable : public Castable<Variable, Node> {
type::AddressSpace AddressSpace() const { return address_space_; }
/// @returns the access control for the variable
ast::Access Access() const { return access_; }
type::Access Access() const { return access_; }
/// @return the constant value of this expression
const constant::Value* ConstantValue() const { return constant_value_; }
@ -101,7 +101,7 @@ class Variable : public Castable<Variable, Node> {
const type::Type* const type_;
const EvaluationStage stage_;
const type::AddressSpace address_space_;
const ast::Access access_;
const type::Access access_;
const constant::Value* constant_value_;
const Expression* initializer_ = nullptr;
std::vector<const VariableUser*> users_;
@ -122,7 +122,7 @@ class LocalVariable final : public Castable<LocalVariable, Variable> {
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const sem::Statement* statement,
const constant::Value* constant_value);
@ -163,7 +163,7 @@ class GlobalVariable final : public Castable<GlobalVariable, Variable> {
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const constant::Value* constant_value,
sem::BindingPoint binding_point = {},
std::optional<uint32_t> location = std::nullopt);
@ -206,7 +206,7 @@ class Parameter final : public Castable<Parameter, Variable> {
uint32_t index,
const type::Type* type,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const ParameterUsage usage = ParameterUsage::kNone,
sem::BindingPoint binding_point = {},
std::optional<uint32_t> location = std::nullopt);

View File

@ -122,8 +122,8 @@ Transform::ApplyResult BindingRemapper::Apply(const Program* src,
// Replace any access controls.
auto ac_it = remappings->access_controls.find(from);
if (ac_it != remappings->access_controls.end()) {
ast::Access ac = ac_it->second;
if (ac == ast::Access::kUndefined) {
type::Access ac = ac_it->second;
if (ac == type::Access::kUndefined) {
b.Diagnostics().add_error(
diag::System::Transform,
"invalid access mode (" + std::to_string(static_cast<uint32_t>(ac)) + ")");

View File

@ -17,9 +17,9 @@
#include <unordered_map>
#include "src/tint/ast/access.h"
#include "src/tint/sem/binding_point.h"
#include "src/tint/transform/transform.h"
#include "src/tint/type/access.h"
namespace tint::transform {
@ -34,7 +34,7 @@ class BindingRemapper final : public Castable<BindingRemapper, Transform> {
using BindingPoints = std::unordered_map<BindingPoint, BindingPoint>;
/// AccessControls is a map of old binding point to new access control
using AccessControls = std::unordered_map<BindingPoint, ast::Access>;
using AccessControls = std::unordered_map<BindingPoint, type::Access>;
/// Remappings is consumed by the BindingRemapper transform.
/// Data holds information about shader usage and constant buffer offsets.

View File

@ -52,7 +52,7 @@ TEST_F(BindingRemapperTest, ShouldRunAccessControlRemappings) {
DataMap data;
data.Add<BindingRemapper::Remappings>(BindingRemapper::BindingPoints{},
BindingRemapper::AccessControls{
{{2, 1}, ast::Access::kWrite},
{{2, 1}, type::Access::kWrite},
});
EXPECT_TRUE(ShouldRun<BindingRemapper>(src, data));
@ -162,9 +162,9 @@ fn f() {
data.Add<BindingRemapper::Remappings>(
BindingRemapper::BindingPoints{},
BindingRemapper::AccessControls{
{{2, 1}, ast::Access::kReadWrite}, // Modify access control
{{2, 1}, type::Access::kReadWrite}, // Modify access control
// Keep @group(3) @binding(2) as is
{{4, 3}, ast::Access::kRead}, // Add access control
{{4, 3}, type::Access::kRead}, // Add access control
});
auto got = Run<BindingRemapper>(src, data);
@ -207,8 +207,8 @@ fn f() {
{{3, 2}, {6, 7}},
},
BindingRemapper::AccessControls{
{{2, 1}, ast::Access::kReadWrite},
{{3, 2}, ast::Access::kReadWrite},
{{2, 1}, type::Access::kReadWrite},
{{3, 2}, type::Access::kReadWrite},
});
auto got = Run<BindingRemapper>(src, data);

View File

@ -110,7 +110,7 @@ struct OffsetBinOp : Offset {
/// LoadStoreKey is the unordered map key to a load or store intrinsic.
struct LoadStoreKey {
type::AddressSpace const address_space; // buffer address space
ast::Access const access; // buffer access
type::Access const access; // buffer access
type::Type const* buf_ty = nullptr; // buffer type
type::Type const* el_ty = nullptr; // element type
bool operator==(const LoadStoreKey& rhs) const {
@ -126,7 +126,7 @@ struct LoadStoreKey {
/// AtomicKey is the unordered map key to an atomic intrinsic.
struct AtomicKey {
ast::Access const access; // buffer access
type::Access const access; // buffer access
type::Type const* buf_ty = nullptr; // buffer type
type::Type const* el_ty = nullptr; // element type
sem::BuiltinType const op; // atomic op
@ -467,7 +467,7 @@ struct DecomposeMemoryAccess::State {
auto address_space = var_user->Variable()->AddressSpace();
auto access = var_user->Variable()->Access();
if (address_space != type::AddressSpace::kStorage) {
access = ast::Access::kUndefined;
access = type::Access::kUndefined;
}
return utils::GetOrCreate(
load_funcs, LoadStoreKey{address_space, access, buf_ty, el_ty}, [&] {
@ -566,7 +566,7 @@ struct DecomposeMemoryAccess::State {
auto address_space = var_user->Variable()->AddressSpace();
auto access = var_user->Variable()->Access();
if (address_space != type::AddressSpace::kStorage) {
access = ast::Access::kUndefined;
access = type::Access::kUndefined;
}
return utils::GetOrCreate(
store_funcs, LoadStoreKey{address_space, access, buf_ty, el_ty}, [&] {
@ -679,7 +679,7 @@ struct DecomposeMemoryAccess::State {
auto address_space = var_user->Variable()->AddressSpace();
auto access = var_user->Variable()->Access();
if (address_space != type::AddressSpace::kStorage) {
access = ast::Access::kUndefined;
access = type::Access::kUndefined;
}
return utils::GetOrCreate(atomic_funcs, AtomicKey{access, buf_ty, el_ty, op}, [&] {
// The first parameter to all WGSL atomics is the expression to the

View File

@ -344,7 +344,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array<f32, 4u>(32))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -398,7 +398,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array<f32, 4u>(4))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -450,7 +450,7 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array<f32, 4u>(32))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -511,7 +511,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
ProgramBuilder b;
b.Alias("ARR", b.ty.array<f32, 4u>(32));
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR"))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -581,7 +581,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16), //
4_u, 128));
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR_B"))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{

View File

@ -241,7 +241,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -299,7 +299,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func(
"f", utils::Empty, b.ty.void_(),
@ -354,7 +354,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -413,7 +413,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -473,7 +473,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{

View File

@ -121,7 +121,7 @@ struct PreservePadding::State {
utils::Vector<const ast::Parameter*, 2> params = {
b.Param(kDestParamName,
b.ty.pointer(CreateASTTypeFor(ctx, ty), type::AddressSpace::kStorage,
ast::Access::kReadWrite)),
type::Access::kReadWrite)),
b.Param(kValueParamName, CreateASTTypeFor(ctx, ty)),
};
b.Func(helper_name, params, b.ty.void_(), body());

View File

@ -282,7 +282,7 @@ class DecomposeSideEffects::CollectHoistsState : public StateBase {
return false;
}
// Don't hoist read-only variables as they cannot receive side-effects.
if (var_user->Variable()->Access() == ast::Access::kRead) {
if (var_user->Variable()->Access() == type::Access::kRead) {
return false;
}
// Don't hoist textures / samplers as they can't be placed into a let, nor

View File

@ -322,7 +322,7 @@ struct VertexPulling::State {
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
// The decorated variable with struct type
b.GlobalVar(GetVertexBufferName(i), b.ty.Of(struct_type), type::AddressSpace::kStorage,
ast::Access::kRead, b.Binding(AInt(i)), b.Group(AInt(cfg.pulling_group)));
type::Access::kRead, b.Binding(AInt(i)), b.Group(AInt(cfg.pulling_group)));
}
}

View File

@ -15,14 +15,14 @@
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/ast/access.cc.tmpl
// src/tint/type/access.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/access.h"
#include "src/tint/type/access.h"
namespace tint::ast {
namespace tint::type {
/// ParseAccess parses a Access from a string.
/// @param str the string to parse
@ -54,4 +54,4 @@ std::ostream& operator<<(std::ostream& out, Access value) {
return out << "<unknown>";
}
} // namespace tint::ast
} // namespace tint::type

View File

@ -14,12 +14,12 @@ See:
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "access") -}}
#include "src/tint/ast/access.h"
#include "src/tint/type/access.h"
namespace tint::ast {
namespace tint::type {
{{ Eval "ParseEnum" $enum}}
{{ Eval "EnumOStream" $enum}}
} // namespace tint::ast
} // namespace tint::type

View File

@ -15,17 +15,17 @@
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/ast/access.h.tmpl
// src/tint/type/access.h.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#ifndef SRC_TINT_AST_ACCESS_H_
#define SRC_TINT_AST_ACCESS_H_
#ifndef SRC_TINT_TYPE_ACCESS_H_
#define SRC_TINT_TYPE_ACCESS_H_
#include <ostream>
namespace tint::ast {
namespace tint::type {
/// Address space of a given pointer.
enum class Access {
@ -51,6 +51,6 @@ constexpr const char* kAccessStrings[] = {
"write",
};
} // namespace tint::ast
} // namespace tint::type
#endif // SRC_TINT_AST_ACCESS_H_
#endif // SRC_TINT_TYPE_ACCESS_H_

View File

@ -14,16 +14,16 @@ See:
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "access") -}}
#ifndef SRC_TINT_AST_ACCESS_H_
#define SRC_TINT_AST_ACCESS_H_
#ifndef SRC_TINT_TYPE_ACCESS_H_
#define SRC_TINT_TYPE_ACCESS_H_
#include <ostream>
namespace tint::ast {
namespace tint::type {
/// Address space of a given pointer.
{{ Eval "DeclareEnum" $enum}}
} // namespace tint::ast
} // namespace tint::type
#endif // SRC_TINT_AST_ACCESS_H_
#endif // SRC_TINT_TYPE_ACCESS_H_

View File

@ -15,18 +15,18 @@
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/ast/access_bench.cc.tmpl
// src/tint/type/access_bench.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/access.h"
#include "src/tint/type/access.h"
#include <array>
#include "benchmark/benchmark.h"
namespace tint::ast {
namespace tint::type {
namespace {
void AccessParser(::benchmark::State& state) {
@ -48,4 +48,4 @@ void AccessParser(::benchmark::State& state) {
BENCHMARK(AccessParser);
} // namespace
} // namespace tint::ast
} // namespace tint::type

View File

@ -14,16 +14,16 @@ See:
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "access") -}}
#include "src/tint/ast/access.h"
#include "src/tint/type/access.h"
#include <array>
#include "benchmark/benchmark.h"
namespace tint::ast {
namespace tint::type {
namespace {
{{ Eval "BenchmarkParseEnum" $enum }}
} // namespace
} // namespace tint::ast
} // namespace tint::type

View File

@ -15,19 +15,19 @@
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/ast/access_test.cc.tmpl
// src/tint/type/access_test.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/access.h"
#include "src/tint/type/access.h"
#include <string>
#include "src/tint/ast/test_helper.h"
#include "src/tint/type/test_helper.h"
#include "src/tint/utils/string.h"
namespace tint::ast {
namespace tint::type {
namespace {
namespace parse_print_tests {
@ -79,4 +79,4 @@ INSTANTIATE_TEST_SUITE_P(ValidCases, AccessPrintTest, testing::ValuesIn(kValidCa
} // namespace parse_print_tests
} // namespace
} // namespace tint::ast
} // namespace tint::type

View File

@ -14,17 +14,17 @@ See:
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "access") -}}
#include "src/tint/ast/access.h"
#include "src/tint/type/access.h"
#include <string>
#include "src/tint/ast/test_helper.h"
#include "src/tint/type/test_helper.h"
#include "src/tint/utils/string.h"
namespace tint::ast {
namespace tint::type {
namespace {
{{ Eval "TestParsePrintEnum" $enum}}
} // namespace
} // namespace tint::ast
} // namespace tint::type

View File

@ -22,14 +22,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Pointer);
namespace tint::type {
Pointer::Pointer(const Type* subtype, type::AddressSpace address_space, ast::Access access)
Pointer::Pointer(const Type* subtype, type::AddressSpace address_space, type::Access access)
: Base(utils::Hash(TypeInfo::Of<Pointer>().full_hashcode, address_space, subtype, access),
type::Flags{}),
subtype_(subtype),
address_space_(address_space),
access_(access) {
TINT_ASSERT(Type, !subtype->Is<Reference>());
TINT_ASSERT(Type, access != ast::Access::kUndefined);
TINT_ASSERT(Type, access != type::Access::kUndefined);
}
bool Pointer::Equals(const UniqueNode& other) const {

View File

@ -17,7 +17,7 @@
#include <string>
#include "src/tint/ast/access.h"
#include "src/tint/type/access.h"
#include "src/tint/type/address_space.h"
#include "src/tint/type/type.h"
@ -30,7 +30,7 @@ class Pointer final : public Castable<Pointer, Type> {
/// @param subtype the pointee type
/// @param address_space the address space of the pointer
/// @param access the resolved access control of the reference
Pointer(const Type* subtype, type::AddressSpace address_space, ast::Access access);
Pointer(const Type* subtype, type::AddressSpace address_space, type::Access access);
/// Destructor
~Pointer() override;
@ -46,7 +46,7 @@ class Pointer final : public Castable<Pointer, Type> {
type::AddressSpace AddressSpace() const { return address_space_; }
/// @returns the access control of the reference
ast::Access Access() const { return access_; }
type::Access Access() const { return access_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
@ -60,7 +60,7 @@ class Pointer final : public Castable<Pointer, Type> {
private:
Type const* const subtype_;
type::AddressSpace const address_space_;
ast::Access const access_;
type::Access const access_;
};
} // namespace tint::type

View File

@ -21,15 +21,15 @@ namespace {
using PointerTest = TestHelper;
TEST_F(PointerTest, Creation) {
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c = create<Pointer>(create<F32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d = create<Pointer>(create<I32>(), AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Pointer>(create<I32>(), AddressSpace::kStorage, ast::Access::kRead);
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* c = create<Pointer>(create<F32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* d = create<Pointer>(create<I32>(), AddressSpace::kPrivate, type::Access::kReadWrite);
auto* e = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kRead);
EXPECT_TRUE(a->StoreType()->Is<I32>());
EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage);
EXPECT_EQ(a->Access(), ast::Access::kReadWrite);
EXPECT_EQ(a->Access(), type::Access::kReadWrite);
EXPECT_EQ(a, b);
EXPECT_NE(a, c);
@ -38,18 +38,18 @@ TEST_F(PointerTest, Creation) {
}
TEST_F(PointerTest, Hash) {
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
EXPECT_EQ(a->unique_hash, b->unique_hash);
}
TEST_F(PointerTest, Equals) {
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c = create<Pointer>(create<F32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d = create<Pointer>(create<I32>(), AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Pointer>(create<I32>(), AddressSpace::kStorage, ast::Access::kRead);
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* c = create<Pointer>(create<F32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* d = create<Pointer>(create<I32>(), AddressSpace::kPrivate, type::Access::kReadWrite);
auto* e = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kRead);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
@ -59,17 +59,17 @@ TEST_F(PointerTest, Equals) {
}
TEST_F(PointerTest, FriendlyName) {
auto* r = create<Pointer>(create<I32>(), AddressSpace::kNone, ast::Access::kRead);
auto* r = create<Pointer>(create<I32>(), AddressSpace::kNone, type::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<i32, read>");
}
TEST_F(PointerTest, FriendlyNameWithAddressSpace) {
auto* r = create<Pointer>(create<I32>(), AddressSpace::kWorkgroup, ast::Access::kRead);
auto* r = create<Pointer>(create<I32>(), AddressSpace::kWorkgroup, type::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<workgroup, i32, read>");
}
TEST_F(PointerTest, Clone) {
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
type::Manager mgr;
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
@ -77,7 +77,7 @@ TEST_F(PointerTest, Clone) {
auto* ptr = a->Clone(ctx);
EXPECT_TRUE(ptr->StoreType()->Is<I32>());
EXPECT_EQ(ptr->AddressSpace(), AddressSpace::kStorage);
EXPECT_EQ(ptr->Access(), ast::Access::kReadWrite);
EXPECT_EQ(ptr->Access(), type::Access::kReadWrite);
}
} // namespace

View File

@ -21,14 +21,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Reference);
namespace tint::type {
Reference::Reference(const Type* subtype, type::AddressSpace address_space, ast::Access access)
Reference::Reference(const Type* subtype, type::AddressSpace address_space, type::Access access)
: Base(utils::Hash(TypeInfo::Of<Reference>().full_hashcode, address_space, subtype, access),
type::Flags{}),
subtype_(subtype),
address_space_(address_space),
access_(access) {
TINT_ASSERT(Type, !subtype->Is<Reference>());
TINT_ASSERT(Type, access != ast::Access::kUndefined);
TINT_ASSERT(Type, access != type::Access::kUndefined);
}
bool Reference::Equals(const UniqueNode& other) const {

View File

@ -17,7 +17,7 @@
#include <string>
#include "src/tint/ast/access.h"
#include "src/tint/type/access.h"
#include "src/tint/type/address_space.h"
#include "src/tint/type/type.h"
@ -30,7 +30,7 @@ class Reference final : public Castable<Reference, Type> {
/// @param subtype the pointee type
/// @param address_space the address space of the reference
/// @param access the resolved access control of the reference
Reference(const Type* subtype, type::AddressSpace address_space, ast::Access access);
Reference(const Type* subtype, type::AddressSpace address_space, type::Access access);
/// Destructor
~Reference() override;
@ -46,7 +46,7 @@ class Reference final : public Castable<Reference, Type> {
type::AddressSpace AddressSpace() const { return address_space_; }
/// @returns the resolved access control of the reference.
ast::Access Access() const { return access_; }
type::Access Access() const { return access_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
@ -60,7 +60,7 @@ class Reference final : public Castable<Reference, Type> {
private:
Type const* const subtype_;
type::AddressSpace const address_space_;
ast::Access const access_;
type::Access const access_;
};
} // namespace tint::type

View File

@ -21,15 +21,15 @@ namespace {
using ReferenceTest = TestHelper;
TEST_F(ReferenceTest, Creation) {
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c = create<Reference>(create<F32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d = create<Reference>(create<I32>(), AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Reference>(create<I32>(), AddressSpace::kStorage, ast::Access::kRead);
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* c = create<Reference>(create<F32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* d = create<Reference>(create<I32>(), AddressSpace::kPrivate, type::Access::kReadWrite);
auto* e = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kRead);
EXPECT_TRUE(a->StoreType()->Is<I32>());
EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage);
EXPECT_EQ(a->Access(), ast::Access::kReadWrite);
EXPECT_EQ(a->Access(), type::Access::kReadWrite);
EXPECT_EQ(a, b);
EXPECT_NE(a, c);
@ -38,18 +38,18 @@ TEST_F(ReferenceTest, Creation) {
}
TEST_F(ReferenceTest, Hash) {
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
EXPECT_EQ(a->unique_hash, b->unique_hash);
}
TEST_F(ReferenceTest, Equals) {
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c = create<Reference>(create<F32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d = create<Reference>(create<I32>(), AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Reference>(create<I32>(), AddressSpace::kStorage, ast::Access::kRead);
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* c = create<Reference>(create<F32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* d = create<Reference>(create<I32>(), AddressSpace::kPrivate, type::Access::kReadWrite);
auto* e = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kRead);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
@ -59,17 +59,17 @@ TEST_F(ReferenceTest, Equals) {
}
TEST_F(ReferenceTest, FriendlyName) {
auto* r = create<Reference>(create<I32>(), AddressSpace::kNone, ast::Access::kRead);
auto* r = create<Reference>(create<I32>(), AddressSpace::kNone, type::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<i32, read>");
}
TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) {
auto* r = create<Reference>(create<I32>(), AddressSpace::kWorkgroup, ast::Access::kRead);
auto* r = create<Reference>(create<I32>(), AddressSpace::kWorkgroup, type::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<workgroup, i32, read>");
}
TEST_F(ReferenceTest, Clone) {
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, ast::Access::kReadWrite);
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
type::Manager mgr;
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
@ -77,7 +77,7 @@ TEST_F(ReferenceTest, Clone) {
auto* ref = a->Clone(ctx);
EXPECT_TRUE(ref->StoreType()->Is<I32>());
EXPECT_EQ(ref->AddressSpace(), AddressSpace::kStorage);
EXPECT_EQ(ref->Access(), ast::Access::kReadWrite);
EXPECT_EQ(ref->Access(), type::Access::kReadWrite);
}
} // namespace

View File

@ -23,7 +23,7 @@ namespace tint::type {
StorageTexture::StorageTexture(TextureDimension dim,
ast::TexelFormat format,
ast::Access access,
type::Access access,
Type* subtype)
: Base(utils::Hash(TypeInfo::Of<StorageTexture>().full_hashcode, dim, format, access), dim),
texel_format_(format),

View File

@ -17,8 +17,8 @@
#include <string>
#include "src/tint/ast/access.h"
#include "src/tint/ast/storage_texture.h"
#include "src/tint/type/access.h"
#include "src/tint/type/texture.h"
#include "src/tint/type/texture_dimension.h"
@ -39,7 +39,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
/// @param subtype the storage subtype. Use SubtypeFor() to calculate this.
StorageTexture(TextureDimension dim,
ast::TexelFormat format,
ast::Access access,
type::Access access,
Type* subtype);
/// Destructor
@ -56,7 +56,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
ast::TexelFormat texel_format() const { return texel_format_; }
/// @returns the access control
ast::Access access() const { return access_; }
type::Access access() const { return access_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
@ -74,7 +74,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
private:
ast::TexelFormat const texel_format_;
ast::Access const access_;
type::Access const access_;
Type* const subtype_;
};

View File

@ -24,7 +24,7 @@ namespace tint::type {
namespace {
struct StorageTextureTest : public TestHelper {
StorageTexture* Create(TextureDimension dims, ast::TexelFormat fmt, ast::Access access) {
StorageTexture* Create(TextureDimension dims, ast::TexelFormat fmt, type::Access access) {
auto* subtype = StorageTexture::SubtypeFor(fmt, Types());
return create<StorageTexture>(dims, fmt, access, subtype);
}
@ -32,13 +32,14 @@ struct StorageTextureTest : public TestHelper {
TEST_F(StorageTextureTest, Creation) {
auto* a =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* b =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* c =
Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
auto* d = Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, ast::Access::kReadWrite);
auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* d =
Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, type::Access::kReadWrite);
auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kRead);
EXPECT_TRUE(a->type()->Is<F32>());
EXPECT_EQ(a->dim(), TextureDimension::kCube);
@ -51,22 +52,23 @@ TEST_F(StorageTextureTest, Creation) {
TEST_F(StorageTextureTest, Hash) {
auto* a =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* b =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite);
EXPECT_EQ(a->unique_hash, b->unique_hash);
}
TEST_F(StorageTextureTest, Equals) {
auto* a =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* b =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* c =
Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
auto* d = Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, ast::Access::kReadWrite);
auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite);
auto* d =
Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, type::Access::kReadWrite);
auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kRead);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
@ -76,26 +78,26 @@ TEST_F(StorageTextureTest, Equals) {
}
TEST_F(StorageTextureTest, Dim) {
auto* s =
Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
auto* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
type::Access::kReadWrite);
EXPECT_EQ(s->dim(), TextureDimension::k2dArray);
}
TEST_F(StorageTextureTest, Format) {
auto* s =
Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
auto* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
type::Access::kReadWrite);
EXPECT_EQ(s->texel_format(), ast::TexelFormat::kRgba32Float);
}
TEST_F(StorageTextureTest, FriendlyName) {
auto* s =
Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
auto* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
type::Access::kReadWrite);
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read_write>");
}
TEST_F(StorageTextureTest, F32) {
Type* s =
Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
Type* s = Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
type::Access::kReadWrite);
auto program = Build();
@ -108,7 +110,7 @@ TEST_F(StorageTextureTest, F32) {
TEST_F(StorageTextureTest, U32) {
auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint,
ast::Access::kReadWrite, subtype);
type::Access::kReadWrite, subtype);
auto program = Build();
@ -121,7 +123,7 @@ TEST_F(StorageTextureTest, U32) {
TEST_F(StorageTextureTest, I32) {
auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types());
Type* s = create<StorageTexture>(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint,
ast::Access::kReadWrite, subtype);
type::Access::kReadWrite, subtype);
auto program = Build();
@ -133,7 +135,7 @@ TEST_F(StorageTextureTest, I32) {
TEST_F(StorageTextureTest, Clone) {
auto* a =
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, type::Access::kReadWrite);
type::Manager mgr;
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};

View File

@ -44,7 +44,7 @@ struct TypeTest : public TestHelper {
const Matrix* mat4x3_f16 = create<Matrix>(vec3_f16, 4u);
const Matrix* mat4x3_af = create<Matrix>(vec3_af, 4u);
const Reference* ref_u32 =
create<Reference>(u32, AddressSpace::kPrivate, ast::Access::kReadWrite);
create<Reference>(u32, AddressSpace::kPrivate, type::Access::kReadWrite);
const Struct* str_f32 = create<Struct>(Source{},
Sym("str_f32"),
utils::Vector{

View File

@ -137,7 +137,7 @@ const sem::Call* AppendVector(ProgramBuilder* b,
auto* scalar_cast_target = b->create<sem::TypeConversion>(
packed_el_sem_ty,
b->create<sem::Parameter>(nullptr, 0u, scalar_sem->Type()->UnwrapRef(),
type::AddressSpace::kNone, ast::Access::kUndefined),
type::AddressSpace::kNone, type::Access::kUndefined),
sem::EvaluationStage::kRuntime);
auto* scalar_cast_sem = b->create<sem::Call>(
scalar_cast_ast, scalar_cast_target, sem::EvaluationStage::kRuntime,
@ -158,7 +158,7 @@ const sem::Call* AppendVector(ProgramBuilder* b,
[&](const tint::sem::Expression* arg, size_t i) -> const sem::Parameter* {
return b->create<sem::Parameter>(
nullptr, static_cast<uint32_t>(i), arg->Type()->UnwrapRef(),
type::AddressSpace::kNone, ast::Access::kUndefined);
type::AddressSpace::kNone, type::Access::kUndefined);
}),
sem::EvaluationStage::kRuntime);
auto* initializer_sem =

View File

@ -87,7 +87,7 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) {
const size_t num_buffers = 3;
b.GlobalVar("buffer1", b.ty.i32(), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a));
b.GlobalVar("buffer2", b.ty.i32(), type::AddressSpace::kStorage, b.Group(1_a), b.Binding(1_a));
b.GlobalVar("buffer3", b.ty.i32(), type::AddressSpace::kStorage, ast::Access::kRead,
b.GlobalVar("buffer3", b.ty.i32(), type::AddressSpace::kStorage, type::Access::kRead,
b.Group(2_a), b.Binding(2_a));
const size_t num_samplers = 2;
@ -102,7 +102,7 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) {
b.Group(6_a), b.Binding(6_a));
b.GlobalVar("texture3",
b.ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float,
ast::Access::kWrite),
type::Access::kWrite),
b.Group(7_a), b.Binding(7_a));
b.GlobalVar("texture4", b.ty.depth_texture(type::TextureDimension::k2d), b.Group(8_a),
b.Binding(8_a));

View File

@ -21,10 +21,10 @@
#include <utility>
#include <vector>
#include "src/tint/ast/access.h"
#include "src/tint/ast/pipeline_stage.h"
#include "src/tint/sem/binding_point.h"
#include "src/tint/sem/sampler_texture_pair.h"
#include "src/tint/type/access.h"
#include "src/tint/writer/glsl/version.h"
#include "src/tint/writer/text.h"
@ -61,7 +61,7 @@ struct Options {
/// A map of old binding point to new access control for the BindingRemapper
/// transform
std::unordered_map<sem::BindingPoint, ast::Access> access_controls;
std::unordered_map<sem::BindingPoint, type::Access> access_controls;
/// If true, then validation will be disabled for binding point collisions
/// generated by the BindingRemapper transform

View File

@ -374,7 +374,7 @@ bool GeneratorImpl::EmitBitcast(std::ostream& out, const ast::BitcastExpression*
dst_type->is_float_scalar_or_vector()) {
out << "uintBitsToFloat";
} else {
if (!EmitType(out, dst_type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
if (!EmitType(out, dst_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
return false;
}
}
@ -437,12 +437,12 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres
auto* uint_type = BoolTypeToUint(bool_type);
// Cast result to bool scalar or vector type.
if (!EmitType(out, bool_type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
if (!EmitType(out, bool_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
return false;
}
ScopedParen outerCastParen(out);
// Cast LHS to uint scalar or vector type.
if (!EmitType(out, uint_type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
if (!EmitType(out, uint_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
return false;
}
{
@ -462,7 +462,7 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres
return false;
}
// Cast RHS to uint scalar or vector type.
if (!EmitType(out, uint_type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
if (!EmitType(out, uint_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
return false;
}
{
@ -490,20 +490,20 @@ bool GeneratorImpl::EmitFloatModulo(std::ostream& out, const ast::BinaryExpressi
{
auto decl = line(&b);
if (!EmitTypeAndName(decl, ret_ty, type::AddressSpace::kNone,
ast::Access::kUndefined, fn_name)) {
type::Access::kUndefined, fn_name)) {
return "";
}
{
ScopedParen sp(decl);
const auto* ty = TypeOf(expr->lhs)->UnwrapRef();
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone,
ast::Access::kUndefined, "lhs")) {
type::Access::kUndefined, "lhs")) {
return "";
}
decl << ", ";
ty = TypeOf(expr->rhs)->UnwrapRef();
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone,
ast::Access::kUndefined, "rhs")) {
type::Access::kUndefined, "rhs")) {
return "";
}
}
@ -828,7 +828,7 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out,
bool GeneratorImpl::EmitTypeConversion(std::ostream& out,
const sem::Call* call,
const sem::TypeConversion* conv) {
if (!EmitType(out, conv->Target(), type::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
if (!EmitType(out, conv->Target(), type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
return false;
}
ScopedParen sp(out);
@ -851,7 +851,7 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out,
return EmitZeroValue(out, type);
}
if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
return false;
}
ScopedParen sp(out);
@ -922,7 +922,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
{
auto pre = line();
if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kNone,
ast::Access::kUndefined, result)) {
type::Access::kUndefined, result)) {
return false;
}
pre << ";";
@ -1060,7 +1060,7 @@ bool GeneratorImpl::EmitCountOneBitsCall(std::ostream& out, const ast::CallExpre
// GLSL's bitCount returns an integer type, so cast it to the appropriate
// unsigned type.
if (!EmitType(out, TypeOf(expr)->UnwrapRef(), type::AddressSpace::kNone,
ast::Access::kReadWrite, "")) {
type::Access::kReadWrite, "")) {
return false;
}
out << "(bitCount(";
@ -1131,7 +1131,7 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out,
std::string v;
{
std::stringstream s;
if (!EmitType(s, vec_ty->type(), type::AddressSpace::kNone, ast::Access::kRead,
if (!EmitType(s, vec_ty->type(), type::AddressSpace::kNone, type::Access::kRead,
"")) {
return "";
}
@ -1139,16 +1139,16 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out,
}
{ // (u)int tint_int_dot([i|u]vecN a, [i|u]vecN b) {
auto l = line(&b);
if (!EmitType(l, vec_ty->type(), type::AddressSpace::kNone, ast::Access::kRead,
if (!EmitType(l, vec_ty->type(), type::AddressSpace::kNone, type::Access::kRead,
"")) {
return "";
}
l << " " << fn_name << "(";
if (!EmitType(l, vec_ty, type::AddressSpace::kNone, ast::Access::kRead, "")) {
if (!EmitType(l, vec_ty, type::AddressSpace::kNone, type::Access::kRead, "")) {
return "";
}
l << " a, ";
if (!EmitType(l, vec_ty, type::AddressSpace::kNone, ast::Access::kRead, "")) {
if (!EmitType(l, vec_ty, type::AddressSpace::kNone, type::Access::kRead, "")) {
return "";
}
l << " b) {";
@ -1200,7 +1200,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out,
{
auto l = line(b);
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kNone,
ast::Access::kUndefined, "")) {
type::Access::kUndefined, "")) {
return false;
}
l << " result;";
@ -1226,7 +1226,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out,
{
auto l = line(b);
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kNone,
ast::Access::kUndefined, "")) {
type::Access::kUndefined, "")) {
return false;
}
l << " result;";
@ -1883,7 +1883,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
{
auto out = line();
auto name = builder_.Symbols().NameFor(func->symbol);
if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kNone, ast::Access::kReadWrite,
if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kNone, type::Access::kReadWrite,
"")) {
return false;
}
@ -2337,7 +2337,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const
return true;
},
[&](const type::Vector* v) {
if (!EmitType(out, v, type::AddressSpace::kNone, ast::Access::kUndefined, "")) {
if (!EmitType(out, v, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
return false;
}
@ -2358,7 +2358,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const
return true;
},
[&](const type::Matrix* m) {
if (!EmitType(out, m, type::AddressSpace::kNone, ast::Access::kUndefined, "")) {
if (!EmitType(out, m, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
return false;
}
@ -2375,7 +2375,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const
return true;
},
[&](const type::Array* a) {
if (!EmitType(out, a, type::AddressSpace::kNone, ast::Access::kUndefined, "")) {
if (!EmitType(out, a, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
return false;
}
@ -2467,7 +2467,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
} else if (type->Is<type::U32>()) {
out << "0u";
} else if (auto* vec = type->As<type::Vector>()) {
if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
return false;
}
ScopedParen sp(out);
@ -2480,7 +2480,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
}
}
} else if (auto* mat = type->As<type::Matrix>()) {
if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kReadWrite, "")) {
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
return false;
}
ScopedParen sp(out);
@ -2493,7 +2493,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
}
}
} else if (auto* str = type->As<sem::Struct>()) {
if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kUndefined, "")) {
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
return false;
}
bool first = true;
@ -2507,7 +2507,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
EmitZeroValue(out, member->Type());
}
} else if (auto* arr = type->As<type::Array>()) {
if (!EmitType(out, type, type::AddressSpace::kNone, ast::Access::kUndefined, "")) {
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
return false;
}
ScopedParen sp(out);
@ -2833,7 +2833,7 @@ bool GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) {
bool GeneratorImpl::EmitType(std::ostream& out,
const type::Type* type,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const std::string& name,
bool* name_printed /* = nullptr */) {
if (name_printed) {
@ -2930,7 +2930,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
out << "highp ";
if (storage && storage->access() != ast::Access::kRead) {
if (storage && storage->access() != type::Access::kRead) {
out << "writeonly ";
}
auto* subtype = sampled ? sampled->type()
@ -3014,7 +3014,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
bool GeneratorImpl::EmitTypeAndName(std::ostream& out,
const type::Type* type,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const std::string& name) {
bool printed_name = false;
if (!EmitType(out, type, address_space, access, name, &printed_name)) {
@ -3050,7 +3050,7 @@ bool GeneratorImpl::EmitStructMembers(TextBuffer* b, const sem::Struct* str) {
auto out = line(b);
if (!EmitTypeAndName(out, ty, type::AddressSpace::kNone, ast::Access::kReadWrite, name)) {
if (!EmitTypeAndName(out, ty, type::AddressSpace::kNone, type::Access::kReadWrite, name)) {
return false;
}
out << ";";
@ -3118,7 +3118,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
auto out = line();
// TODO(senorblanco): handle const
if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, ast::Access::kUndefined,
if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined,
builder_.Symbols().NameFor(let->symbol))) {
return false;
}
@ -3140,7 +3140,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) {
auto out = line();
out << "const ";
if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, ast::Access::kUndefined,
if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined,
builder_.Symbols().NameFor(var->symbol))) {
return false;
}
@ -3168,7 +3168,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out,
{
auto decl = line(&b);
if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kNone,
ast::Access::kUndefined, fn_name)) {
type::Access::kUndefined, fn_name)) {
return "";
}
{
@ -3184,7 +3184,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out,
ty = ptr->StoreType();
}
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone,
ast::Access::kUndefined, param_name)) {
type::Access::kUndefined, param_name)) {
return "";
}
parameter_names.emplace_back(std::move(param_name));

View File

@ -414,7 +414,7 @@ class GeneratorImpl : public TextGenerator {
bool EmitType(std::ostream& out,
const type::Type* type,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const std::string& name,
bool* name_printed = nullptr);
/// Handles generating type and name
@ -427,7 +427,7 @@ class GeneratorImpl : public TextGenerator {
bool EmitTypeAndName(std::ostream& out,
const type::Type* type,
type::AddressSpace address_space,
ast::Access access,
type::Access access,
const std::string& name);
/// Handles generating a structure declaration. If the structure has already been emitted, then
/// this function will simply return `true` without emitting anything.

Some files were not shown because too many files have changed in this diff Show More