Move type/access to builtin.

This CL moves the type::Access builtin to the builtin:: tree.

Change-Id: I3276d364f7b597671612a23c8823f0afd1914d81
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120363
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-02-19 04:01:29 +00:00 committed by Dawn LUCI CQ
parent 79781f26d1
commit b6cc4cbf89
115 changed files with 710 additions and 672 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::type::Access::kReadWrite);
remappedAccessControls.emplace(srcBindingPoint, tint::builtin::Access::kReadWrite);
}
}

View File

@ -693,6 +693,8 @@ libtint_source_set("libtint_sem_src") {
libtint_source_set("libtint_builtins_src") {
sources = [
"builtin/access.cc",
"builtin/access.h",
"builtin/builtin_value.cc",
"builtin/builtin_value.h",
"builtin/extension.cc",
@ -709,8 +711,6 @@ libtint_source_set("libtint_type_src") {
"type/abstract_int.h",
"type/abstract_numeric.cc",
"type/abstract_numeric.h",
"type/access.cc",
"type/access.h",
"type/address_space.cc",
"type/address_space.h",
"type/array.cc",
@ -776,7 +776,10 @@ libtint_source_set("libtint_type_src") {
"type/void.h",
]
deps = [ ":libtint_base_src" ]
deps = [
":libtint_base_src",
":libtint_builtins_src",
]
}
libtint_source_set("libtint_constant_src") {
@ -931,6 +934,7 @@ libtint_source_set("libtint_wgsl_reader_src") {
deps = [
":libtint_ast_src",
":libtint_base_src",
":libtint_builtins_src",
":libtint_program_src",
":libtint_reader_src",
":libtint_text_src",
@ -949,6 +953,7 @@ libtint_source_set("libtint_wgsl_writer_src") {
deps = [
":libtint_ast_src",
":libtint_base_src",
":libtint_builtins_src",
":libtint_program_src",
":libtint_sem_src",
":libtint_type_src",
@ -1007,6 +1012,7 @@ libtint_source_set("libtint_glsl_writer_src") {
deps = [
":libtint_ast_src",
":libtint_base_src",
":libtint_builtins_src",
":libtint_constant_src",
":libtint_program_src",
":libtint_sem_src",
@ -1275,6 +1281,7 @@ if (tint_build_unittests) {
deps = [
":libtint_ast_src",
":libtint_base_src",
":libtint_builtins_src",
":libtint_transform_src",
":libtint_unittests_ast_helper",
]
@ -1287,6 +1294,7 @@ if (tint_build_unittests) {
tint_unittests_source_set("tint_unittests_builtins_src") {
sources = [
"builtin/access_test.cc",
"builtin/builtin_value_test.cc",
"builtin/extension_test.cc",
]
@ -1405,7 +1413,6 @@ if (tint_build_unittests) {
tint_unittests_source_set("tint_unittests_type_src") {
sources = [
"type/access_test.cc",
"type/address_space_test.cc",
"type/atomic_test.cc",
"type/bool_test.cc",

View File

@ -548,6 +548,7 @@ list(APPEND TINT_LIB_SRCS
writer/writer.h
)
tint_generated(builtin/access BENCH TEST)
tint_generated(builtin/builtin_value BENCH TEST)
tint_generated(builtin/extension BENCH TEST)
tint_generated(ast/diagnostic_control BENCH TEST)
@ -555,7 +556,6 @@ tint_generated(ast/interpolate_attribute BENCH TEST)
tint_generated(resolver/init_conv_intrinsic)
tint_generated(sem/builtin_type)
tint_generated(sem/parameter_usage)
tint_generated(type/access BENCH TEST)
tint_generated(type/address_space BENCH TEST)
tint_generated(type/builtin BENCH TEST)
tint_generated(type/texel_format BENCH TEST)

View File

@ -14,7 +14,7 @@
#include "src/tint/ast/alias.h"
#include "src/tint/ast/test_helper.h"
#include "src/tint/type/access.h"
#include "src/tint/builtin/access.h"
namespace tint::ast {
namespace {

View File

@ -55,7 +55,7 @@ TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o,
args(std::move(a)) {}
TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o,
const char* d,
type::Access acc,
tint::builtin::Access acc,
type::TexelFormat fmt,
type::TextureDimension dims,
TextureDataType datatype,
@ -404,7 +404,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
{
ValidTextureOverload::kDimensionsStorageWO1d,
"textureDimensions(t : texture_storage_1d<rgba32float>) -> u32",
type::Access::kWrite,
tint::builtin::Access::kWrite,
type::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>",
type::Access::kWrite,
tint::builtin::Access::kWrite,
type::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>",
type::Access::kWrite,
tint::builtin::Access::kWrite,
type::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>",
type::Access::kWrite,
tint::builtin::Access::kWrite,
type::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",
type::Access::kWrite,
tint::builtin::Access::kWrite,
type::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>)",
type::Access::kWrite,
tint::builtin::Access::kWrite,
type::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>)",
type::Access::kWrite,
tint::builtin::Access::kWrite,
type::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>)",
type::Access::kWrite,
tint::builtin::Access::kWrite,
type::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>)",
type::Access::kWrite,
tint::builtin::Access::kWrite,
type::TexelFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,

View File

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

View File

@ -23,7 +23,7 @@
#include "src/tint/ast/expression.h"
#include "src/tint/ast/group_attribute.h"
#include "src/tint/ast/type.h"
#include "src/tint/type/access.h"
#include "src/tint/builtin/access.h"
#include "src/tint/type/address_space.h"
// Forward declarations

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1655,8 +1655,8 @@ TEST_F(InspectorGetStorageSizeTest, Empty) {
TEST_F(InspectorGetStorageSizeTest, Simple_NonStruct) {
AddUniformBuffer("ub_var", ty.i32(), 0, 0);
AddStorageBuffer("sb_var", ty.i32(), type::Access::kReadWrite, 1, 0);
AddStorageBuffer("rosb_var", ty.i32(), type::Access::kRead, 1, 1);
AddStorageBuffer("sb_var", ty.i32(), builtin::Access::kReadWrite, 1, 0);
AddStorageBuffer("rosb_var", ty.i32(), builtin::Access::kRead, 1, 1);
Func("ep_func", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("ub", Expr("ub_var"))),
@ -1687,7 +1687,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_Struct) {
auto sb = MakeStorageBufferTypes("sb_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("sb_var", sb(), type::Access::kReadWrite, 1, 0);
AddStorageBuffer("sb_var", sb(), builtin::Access::kReadWrite, 1, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "sb_var",
utils::Vector{
MemberInfo{0, ty.i32()},
@ -1696,7 +1696,7 @@ TEST_F(InspectorGetStorageSizeTest, Simple_Struct) {
auto ro_sb = MakeStorageBufferTypes("rosb_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("rosb_var", ro_sb(), type::Access::kRead, 1, 1);
AddStorageBuffer("rosb_var", ro_sb(), builtin::Access::kRead, 1, 1);
MakeStructVariableReferenceBodyFunction("rosb_func", "rosb_var",
utils::Vector{
MemberInfo{0, ty.i32()},
@ -1774,7 +1774,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
auto sb = MakeStorageBufferTypes("sb_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("sb_var", sb(), type::Access::kReadWrite, 1, 0);
AddStorageBuffer("sb_var", sb(), builtin::Access::kReadWrite, 1, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "sb_var",
utils::Vector{
MemberInfo{0, ty.i32()},
@ -1783,7 +1783,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
auto ro_sb = MakeStorageBufferTypes("rosb_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("rosb_var", ro_sb(), type::Access::kRead, 1, 1);
AddStorageBuffer("rosb_var", ro_sb(), builtin::Access::kRead, 1, 1);
MakeStructVariableReferenceBodyFunction("rosb_func", "rosb_var",
utils::Vector{
MemberInfo{0, ty.i32()},
@ -2140,7 +2140,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple_NonStruct) {
AddStorageBuffer("foo_sb", ty.i32(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", ty.i32(), builtin::Access::kReadWrite, 0, 0);
MakePlainGlobalReferenceBodyFunction("sb_func", "foo_sb", ty.i32(), utils::Empty);
MakeCallerBodyFunction("ep_func", utils::Vector{std::string("sb_func")},
@ -2165,7 +2165,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple_Struct) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2196,7 +2196,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
ty.u32(),
ty.f32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2229,9 +2229,9 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
ty.u32(),
ty.f32(),
});
AddStorageBuffer("sb_foo", sb_struct_type(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("sb_bar", sb_struct_type(), type::Access::kReadWrite, 0, 1);
AddStorageBuffer("sb_baz", sb_struct_type(), type::Access::kReadWrite, 2, 0);
AddStorageBuffer("sb_foo", sb_struct_type(), builtin::Access::kReadWrite, 0, 0);
AddStorageBuffer("sb_bar", sb_struct_type(), builtin::Access::kReadWrite, 0, 1);
AddStorageBuffer("sb_baz", sb_struct_type(), builtin::Access::kReadWrite, 2, 0);
auto AddReferenceFunc = [this](const std::string& func_name, const std::string& var_name) {
MakeStructVariableReferenceBodyFunction(func_name, var_name,
@ -2288,7 +2288,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
ty.i32(),
ty.array<u32, 4>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2318,7 +2318,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
ty.i32(),
ty.array<u32>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2347,7 +2347,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.vec3<f32>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2373,7 +2373,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) {
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, NonStructVec3) {
AddStorageBuffer("foo_ub", ty.vec3<f32>(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_ub", ty.vec3<f32>(), builtin::Access::kReadWrite, 0, 0);
MakePlainGlobalReferenceBodyFunction("ub_func", "foo_ub", ty.vec3<f32>(), utils::Empty);
MakeCallerBodyFunction("ep_func", utils::Vector{std::string("ub_func")},
@ -2398,7 +2398,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kRead, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2421,7 +2421,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kRead, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2452,9 +2452,9 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, MultipleStorageBuf
ty.u32(),
ty.f32(),
});
AddStorageBuffer("sb_foo", sb_struct_type(), type::Access::kRead, 0, 0);
AddStorageBuffer("sb_bar", sb_struct_type(), type::Access::kRead, 0, 1);
AddStorageBuffer("sb_baz", sb_struct_type(), type::Access::kRead, 2, 0);
AddStorageBuffer("sb_foo", sb_struct_type(), builtin::Access::kRead, 0, 0);
AddStorageBuffer("sb_bar", sb_struct_type(), builtin::Access::kRead, 0, 1);
AddStorageBuffer("sb_baz", sb_struct_type(), builtin::Access::kRead, 2, 0);
auto AddReferenceFunc = [this](const std::string& func_name, const std::string& var_name) {
MakeStructVariableReferenceBodyFunction(func_name, var_name,
@ -2511,7 +2511,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
ty.i32(),
ty.array<u32, 4>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kRead, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2541,7 +2541,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingRuntimeA
ty.i32(),
ty.array<u32>(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kRead, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kRead, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{
@ -2570,7 +2570,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
auto foo_struct_type = MakeStorageBufferTypes("foo_type", utils::Vector{
ty.i32(),
});
AddStorageBuffer("foo_sb", foo_struct_type(), type::Access::kReadWrite, 0, 0);
AddStorageBuffer("foo_sb", foo_struct_type(), builtin::Access::kReadWrite, 0, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
utils::Vector{

View File

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

View File

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

View File

@ -237,8 +237,8 @@ class ProgramBuilder {
address_space = b.Expr(addr_space);
}
}
void Set(ProgramBuilder& b, type::Access ac) {
if (ac != type::Access::kUndefined) {
void Set(ProgramBuilder& b, builtin::Access ac) {
if (ac != builtin::Access::kUndefined) {
access = b.Expr(ac);
}
}
@ -1202,7 +1202,7 @@ class ProgramBuilder {
/// @return the pointer to `type` with the given type::AddressSpace
ast::Type pointer(ast::Type type,
type::AddressSpace address_space,
type::Access access = type::Access::kUndefined) const {
builtin::Access access = builtin::Access::kUndefined) const {
return pointer(builder->source_, type, address_space, access);
}
@ -1214,8 +1214,8 @@ class ProgramBuilder {
ast::Type pointer(const Source& source,
ast::Type type,
type::AddressSpace address_space,
type::Access access = type::Access::kUndefined) const {
if (access != type::Access::kUndefined) {
builtin::Access access = builtin::Access::kUndefined) const {
if (access != builtin::Access::kUndefined) {
return (*this)(source, "ptr", address_space, type, access);
} else {
return (*this)(source, "ptr", address_space, type);
@ -1227,7 +1227,7 @@ class ProgramBuilder {
/// @return the pointer to type `T` with the given type::AddressSpace.
template <typename T>
ast::Type pointer(type::AddressSpace address_space,
type::Access access = type::Access::kUndefined) const {
builtin::Access access = builtin::Access::kUndefined) const {
return pointer<T>(builder->source_, address_space, access);
}
@ -1238,8 +1238,8 @@ class ProgramBuilder {
template <typename T>
ast::Type pointer(const Source& source,
type::AddressSpace address_space,
type::Access access = type::Access::kUndefined) const {
if (access != type::Access::kUndefined) {
builtin::Access access = builtin::Access::kUndefined) const {
if (access != builtin::Access::kUndefined) {
return (*this)(source, "ptr", address_space, Of<T>(), access);
} else {
return (*this)(source, "ptr", address_space, Of<T>());
@ -1390,7 +1390,7 @@ class ProgramBuilder {
/// @returns the storage texture
ast::Type storage_texture(type::TextureDimension dims,
type::TexelFormat format,
type::Access access) const {
builtin::Access access) const {
return storage_texture(builder->source_, dims, format, access);
}
@ -1402,7 +1402,7 @@ class ProgramBuilder {
ast::Type storage_texture(const Source& source,
type::TextureDimension dims,
type::TexelFormat format,
type::Access access) const {
builtin::Access access) const {
switch (dims) {
case type::TextureDimension::k1d:
return (*this)(source, "texture_storage_1d", format, access);
@ -2067,7 +2067,7 @@ class ProgramBuilder {
/// Can be any of the following, in any order:
/// * ast::Type - specifies the variable's type
/// * type::AddressSpace - specifies the variable's address space
/// * type::Access - specifies the variable's access control
/// * builtin::Access - specifies the variable's access control
/// * ast::Expression* - specifies the variable's initializer expression
/// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector)
/// Note that non-repeatable arguments of the same type will use the last argument's value.
@ -2084,7 +2084,7 @@ class ProgramBuilder {
/// Can be any of the following, in any order:
/// * ast::Type - specifies the variable's type
/// * type::AddressSpace - specifies the variable's address space
/// * type::Access - specifies the variable's access control
/// * builtin::Access - specifies the variable's access control
/// * ast::Expression* - specifies the variable's initializer expression
/// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector)
/// Note that non-repeatable arguments of the same type will use the last argument's value.
@ -2186,7 +2186,7 @@ class ProgramBuilder {
/// Can be any of the following, in any order:
/// * ast::Type - specifies the variable's type
/// * type::AddressSpace - specifies the variable address space
/// * type::Access - specifies the variable's access control
/// * builtin::Access - specifies the variable's access control
/// * ast::Expression* - specifies the variable's initializer expression
/// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector)
/// Note that non-repeatable arguments of the same type will use the last argument's value.
@ -2203,7 +2203,7 @@ class ProgramBuilder {
/// Can be any of the following, in any order:
/// * ast::Type - specifies the variable's type
/// * type::AddressSpace - specifies the variable address space
/// * type::Access - specifies the variable's access control
/// * builtin::Access - specifies the variable's access control
/// * ast::Expression* - specifies the variable's initializer expression
/// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector)
/// Note that non-repeatable arguments of the same type will use the last argument's value.

View File

@ -2522,7 +2522,7 @@ bool FunctionEmitter::EmitFunctionVariables() {
}
}
auto* var = parser_impl_.MakeVar(inst.result_id(), type::AddressSpace::kUndefined,
type::Access::kUndefined, var_store_type, initializer,
builtin::Access::kUndefined, var_store_type, initializer,
AttributeList{});
auto* var_decl_stmt = create<ast::VariableDeclStatement>(Source{}, var);
AddStatement(var_decl_stmt);
@ -3369,7 +3369,7 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info,
auto* store_type = parser_impl_.ConvertType(def_inst->type_id());
AddStatement(create<ast::VariableDeclStatement>(
Source{},
parser_impl_.MakeVar(id, type::AddressSpace::kUndefined, type::Access::kUndefined,
parser_impl_.MakeVar(id, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
store_type, nullptr, AttributeList{})));
auto* type = ty_.Reference(store_type, type::AddressSpace::kUndefined);
identifier_types_.emplace(id, type);
@ -4842,7 +4842,7 @@ DefInfo::Pointer FunctionEmitter::GetPointerInfo(uint32_t id) {
}
// Local variables are always Function storage class, with default
// access mode.
return DefInfo::Pointer{type::AddressSpace::kFunction, type::Access::kUndefined};
return DefInfo::Pointer{type::AddressSpace::kFunction, builtin::Access::kUndefined};
}
case spv::Op::OpFunctionParameter: {
const auto* type = As<Pointer>(parser_impl_.ConvertType(inst.type_id()));
@ -4855,7 +4855,7 @@ DefInfo::Pointer FunctionEmitter::GetPointerInfo(uint32_t id) {
// parameters. In that case we need to do a global analysis to
// determine what the formal argument parameter type should be,
// whether it has read_only or read_write access mode.
return DefInfo::Pointer{type->address_space, type::Access::kUndefined};
return DefInfo::Pointer{type->address_space, builtin::Access::kUndefined};
}
default:
break;

View File

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

View File

@ -1576,9 +1576,9 @@ const spvtools::opt::analysis::IntConstant* ParserImpl::GetArraySize(uint32_t va
return size->AsIntConstant();
}
type::Access ParserImpl::VarAccess(const Type* storage_type, type::AddressSpace address_space) {
builtin::Access ParserImpl::VarAccess(const Type* storage_type, type::AddressSpace address_space) {
if (address_space != type::AddressSpace::kStorage) {
return type::Access::kUndefined;
return builtin::Access::kUndefined;
}
bool read_only = false;
@ -1587,12 +1587,12 @@ type::Access ParserImpl::VarAccess(const Type* storage_type, type::AddressSpace
}
// Apply the access(read) or access(read_write) modifier.
return read_only ? type::Access::kRead : type::Access::kReadWrite;
return read_only ? builtin::Access::kRead : builtin::Access::kReadWrite;
}
const ast::Var* ParserImpl::MakeVar(uint32_t id,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const Type* storage_type,
const ast::Expression* initializer,
AttributeList decorations) {
@ -2526,7 +2526,7 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc
ast_handle_type = ty_.SampledTexture(dim, ast_sampled_component_type);
}
} else {
const auto access = type::Access::kWrite;
const auto access = builtin::Access::kWrite;
const auto format = enum_converter_.ToTexelFormat(image_type->format());
if (format == type::TexelFormat::kUndefined) {
return nullptr;

View File

@ -424,7 +424,7 @@ class ParserImpl : Reader {
/// @param address_space the 'var' address space
/// @returns the access mode for a 'var' declaration with the given storage type and address
/// space.
type::Access VarAccess(const Type* storage_type, type::AddressSpace address_space);
builtin::Access VarAccess(const Type* storage_type, type::AddressSpace address_space);
/// Creates an AST 'var' node for a SPIR-V ID, including any attached decorations, unless it's
/// an ignorable builtin variable.
@ -438,7 +438,7 @@ class ParserImpl : Reader {
/// in the error case
const ast::Var* MakeVar(uint32_t id,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const Type* storage_type,
const ast::Expression* initializer,
AttributeList decorations);
@ -674,7 +674,7 @@ class ParserImpl : Reader {
/// The address space of the var
type::AddressSpace address_space = type::AddressSpace::kUndefined;
/// The access mode of the var
type::Access access = type::Access::kUndefined;
builtin::Access access = builtin::Access::kUndefined;
};
/// Returns the AST variable for the SPIR-V ID of a module-scope variable,

View File

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

View File

@ -20,9 +20,9 @@
#include <vector>
#include "src/tint/ast/type.h"
#include "src/tint/builtin/access.h"
#include "src/tint/castable.h"
#include "src/tint/symbol.h"
#include "src/tint/type/access.h"
#include "src/tint/type/address_space.h"
#include "src/tint/type/sampler_kind.h"
#include "src/tint/type/texel_format.h"
@ -162,7 +162,7 @@ struct Pointer final : public Castable<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, type::Access access);
Pointer(const Type* ty, type::AddressSpace sc, builtin::Access access);
/// Copy constructor
/// @param other the other type to copy
@ -182,7 +182,7 @@ struct Pointer final : public Castable<Pointer, Type> {
/// the pointer address space
type::AddressSpace const address_space;
/// the pointer declared access mode
type::Access const access;
builtin::Access const access;
};
/// `ref<SC, T, AM>` type
@ -193,7 +193,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, type::Access access);
Reference(const Type* ty, type::AddressSpace sc, builtin::Access access);
/// Copy constructor
/// @param other the other type to copy
@ -213,7 +213,7 @@ struct Reference final : public Castable<Reference, Type> {
/// the pointer address space
type::AddressSpace const address_space;
/// the pointer declared access mode
type::Access const access;
builtin::Access const access;
};
/// `vecN<T>` type
@ -434,7 +434,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, type::TexelFormat f, type::Access a);
StorageTexture(type::TextureDimension d, type::TexelFormat f, builtin::Access a);
/// Copy constructor
/// @param other the other type to copy
@ -453,7 +453,7 @@ struct StorageTexture final : public Castable<StorageTexture, Texture> {
type::TexelFormat const format;
/// the access control
type::Access const access;
builtin::Access const access;
};
/// Base class for named types
@ -550,7 +550,7 @@ class TypeManager {
/// the same pointer.
const spirv::Pointer* Pointer(const Type* ty,
type::AddressSpace address_space,
type::Access access = type::Access::kUndefined);
builtin::Access access = builtin::Access::kUndefined);
/// @param ty the referenced type
/// @param address_space the reference address space
/// @param access the declared access mode
@ -558,7 +558,7 @@ class TypeManager {
/// return the same pointer.
const spirv::Reference* Reference(const Type* ty,
type::AddressSpace address_space,
type::Access access = type::Access::kUndefined);
builtin::Access access = builtin::Access::kUndefined);
/// @param ty the element type
/// @param sz the number of elements in the vector
/// @return a Vector type. Repeated calls with the same arguments will return
@ -616,7 +616,7 @@ class TypeManager {
/// return the same pointer.
const spirv::StorageTexture* StorageTexture(type::TextureDimension d,
type::TexelFormat f,
type::Access a);
builtin::Access a);
private:
struct State;

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, type::TexelFormat::kR32Uint,
type::Access::kRead),
builtin::Access::kRead),
ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kRead));
builtin::Access::kRead));
}
TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
@ -81,17 +81,17 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
EXPECT_NE(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()),
ty.SampledTexture(type::TextureDimension::k2d, ty.U32()));
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kRead),
builtin::Access::kRead),
ty.StorageTexture(type::TextureDimension::k3d, type::TexelFormat::kR32Uint,
type::Access::kRead));
builtin::Access::kRead));
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kRead),
builtin::Access::kRead),
ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Sint,
type::Access::kRead));
builtin::Access::kRead));
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kRead),
builtin::Access::kRead),
ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
type::Access::kWrite));
builtin::Access::kWrite));
}
} // namespace

View File

@ -22,6 +22,7 @@
#include <utility>
#include <vector>
#include "src/tint/builtin/access.h"
#include "src/tint/program_builder.h"
#include "src/tint/reader/wgsl/parser_impl_detail.h"
#include "src/tint/reader/wgsl/token.h"

View File

@ -21,7 +21,7 @@ namespace {
struct VariableStorageData {
const char* input;
type::AddressSpace address_space;
type::Access access;
builtin::Access access;
};
inline std::ostream& operator<<(std::ostream& out, VariableStorageData data) {
out << std::string(data.input);
@ -44,7 +44,7 @@ TEST_P(VariableQualifierTest, ParsesAddressSpace) {
} else {
EXPECT_EQ(sc->address_space, nullptr);
}
if (params.access != type::Access::kUndefined) {
if (params.access != builtin::Access::kUndefined) {
ast::CheckIdentifier(p->builder().Symbols(), sc->access, utils::ToString(params.access));
} else {
EXPECT_EQ(sc->access, nullptr);
@ -57,15 +57,17 @@ INSTANTIATE_TEST_SUITE_P(
ParserImplTest,
VariableQualifierTest,
testing::Values(
VariableStorageData{"uniform", type::AddressSpace::kUniform, type::Access::kUndefined},
VariableStorageData{"workgroup", type::AddressSpace::kWorkgroup, type::Access::kUndefined},
VariableStorageData{"storage", type::AddressSpace::kStorage, type::Access::kUndefined},
VariableStorageData{"private", type::AddressSpace::kPrivate, type::Access::kUndefined},
VariableStorageData{"function", type::AddressSpace::kFunction, type::Access::kUndefined},
VariableStorageData{"storage, read", type::AddressSpace::kStorage, type::Access::kRead},
VariableStorageData{"storage, write", type::AddressSpace::kStorage, type::Access::kWrite},
VariableStorageData{"uniform", type::AddressSpace::kUniform, builtin::Access::kUndefined},
VariableStorageData{"workgroup", type::AddressSpace::kWorkgroup,
builtin::Access::kUndefined},
VariableStorageData{"storage", type::AddressSpace::kStorage, builtin::Access::kUndefined},
VariableStorageData{"private", type::AddressSpace::kPrivate, builtin::Access::kUndefined},
VariableStorageData{"function", type::AddressSpace::kFunction, builtin::Access::kUndefined},
VariableStorageData{"storage, read", type::AddressSpace::kStorage, builtin::Access::kRead},
VariableStorageData{"storage, write", type::AddressSpace::kStorage,
builtin::Access::kWrite},
VariableStorageData{"storage, read_write", type::AddressSpace::kStorage,
type::Access::kReadWrite}));
builtin::Access::kReadWrite}));
TEST_F(ParserImplTest, VariableQualifier_Empty) {
auto p = parser("var<> name");

View File

@ -325,7 +325,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF32) {
// struct S{ a : f32 };
// var<storage, read> g : array<S, 3u>;
Structure("S", utils::Vector{Member("a", ty.f32())});
GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead,
GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, builtin::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -347,7 +347,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF16) {
Enable(builtin::Extension::kF16);
Structure("S", utils::Vector{Member("a", ty.f16())});
GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead,
GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, builtin::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -361,7 +361,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF16) {
Structure("S", utils::Vector{Member("a", ty.f16())});
Alias("t",
ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead));
ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -370,7 +370,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32) {
// struct S { x : i32 };
// var<storage, read> g : S;
Structure("S", utils::Vector{Member("x", ty.i32())});
GlobalVar("g", ty("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
GlobalVar("g", ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a),
Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -380,7 +380,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32) {
// struct S { x : i32 };
// type t = ptr<storage, read, S>;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, type::Access::kRead));
Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -392,7 +392,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32Alias
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a),
Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -405,7 +405,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32Aliases
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
Alias("t", ty.pointer(ty("a2"), type::AddressSpace::kStorage, type::Access::kRead));
Alias("t", ty.pointer(ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -416,7 +416,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16) {
Enable(builtin::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
GlobalVar("g", ty("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
GlobalVar("g", ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a),
Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -428,7 +428,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16) {
Enable(builtin::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, type::Access::kRead));
Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -442,7 +442,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16Alias
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a),
Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -457,14 +457,15 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16Aliases
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
Alias("g", ty.pointer(ty("a2"), type::AddressSpace::kStorage, type::Access::kRead));
Alias("g", ty.pointer(ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_NotStorage_AccessMode) {
// var<private, read> g : a;
GlobalVar(Source{{12, 34}}, "g", ty.i32(), type::AddressSpace::kPrivate, type::Access::kRead);
GlobalVar(Source{{12, 34}}, "g", ty.i32(), type::AddressSpace::kPrivate,
builtin::Access::kRead);
ASSERT_FALSE(r()->Resolve());
@ -476,7 +477,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_NotStorage_AccessMode)
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NotStorage_AccessMode) {
// type t = ptr<private, i32, read>;
Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kPrivate,
type::Access::kRead));
builtin::Access::kRead));
ASSERT_FALSE(r()->Resolve());
@ -487,7 +488,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NotStorage_AccessMode) {
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadAccessMode) {
// @group(0) @binding(0) var<storage, read> a : i32;
GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, type::Access::kRead, Group(0_a),
GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a),
Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -495,14 +496,14 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadAccessMode
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadAccessMode) {
// type t = ptr<storage, read, i32>;
Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, type::Access::kRead));
Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadWriteAccessMode) {
// @group(0) @binding(0) var<storage, read_write> a : i32;
GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite, Group(0_a),
GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(0_a),
Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -510,15 +511,15 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadWriteAcces
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadWriteAccessMode) {
// type t = ptr<storage, read_write, i32>;
Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, type::Access::kReadWrite));
Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, builtin::Access::kReadWrite));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_WriteAccessMode) {
// @group(0) @binding(0) var<storage, read_write> a : i32;
GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, type::Access::kWrite,
Group(0_a), Binding(0_a));
GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage,
builtin::Access::kWrite, Group(0_a), Binding(0_a));
ASSERT_FALSE(r()->Resolve());
@ -529,7 +530,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_WriteAccessMod
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_WriteAccessMode) {
// type t = ptr<storage, read_write, i32>;
Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kStorage,
type::Access::kWrite));
builtin::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, type::Access::kRead,
GlobalVar(Source{{12, 34}}, "a", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead,
Binding(0_a), Group(0_a));
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i));
@ -232,7 +232,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
auto make_type = [&] {
return ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kRgba8Unorm,
type::Access::kWrite);
builtin::Access::kWrite);
};
GlobalVar("a", make_type(), Binding(0_a), Group(0_a));
@ -253,7 +253,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) {
Member("a", ty.atomic(ty.i32())),
});
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), type::AddressSpace::kStorage,
type::Access::kReadWrite, Binding(0_a), Group(0_a));
builtin::Access::kReadWrite, Binding(0_a), Group(0_a));
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a")));
@ -270,7 +270,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) {
Member("a", ty.array(ty.f32())),
});
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), type::AddressSpace::kStorage,
type::Access::kReadWrite, Binding(0_a), Group(0_a));
builtin::Access::kReadWrite, Binding(0_a), Group(0_a));
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a")));

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, type::Access::kReadWrite,
auto* g = GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(0_a));
EXPECT_TRUE(r()->Resolve()) << r()->error();

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

View File

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

View File

@ -215,7 +215,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, type::Access::kRead, Binding(0_a),
GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a),
Group(0_a));
auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x")));

View File

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

View File

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

View File

@ -487,7 +487,7 @@ class DependencyScanner {
graph_.resolved_identifiers.Add(from, ResolvedIdentifier(fmt));
return;
}
if (auto access = type::ParseAccess(s); access != type::Access::kUndefined) {
if (auto access = builtin::ParseAccess(s); access != builtin::Access::kUndefined) {
graph_.resolved_identifiers.Add(from, ResolvedIdentifier(access));
return;
}
@ -861,7 +861,7 @@ std::string ResolvedIdentifier::String(const SymbolTable& symbols, diag::List& d
if (auto builtin_ty = BuiltinType(); builtin_ty != type::Builtin::kUndefined) {
return "builtin type '" + utils::ToString(builtin_ty) + "'";
}
if (auto access = Access(); access != type::Access::kUndefined) {
if (auto access = Access(); access != builtin::Access::kUndefined) {
return "access '" + utils::ToString(access) + "'";
}
if (auto addr = AddressSpace(); addr != type::AddressSpace::kUndefined) {

View File

@ -19,10 +19,10 @@
#include <vector>
#include "src/tint/ast/module.h"
#include "src/tint/builtin/access.h"
#include "src/tint/diagnostic/diagnostic.h"
#include "src/tint/sem/builtin_type.h"
#include "src/tint/symbol_table.h"
#include "src/tint/type/access.h"
#include "src/tint/type/builtin.h"
#include "src/tint/type/texel_format.h"
#include "src/tint/utils/hashmap.h"
@ -35,7 +35,7 @@ namespace tint::resolver {
/// - const ast::Variable* (as const ast::Node*)
/// - const ast::Function* (as const ast::Node*)
/// - sem::BuiltinType
/// - type::Access
/// - builtin::Access
/// - type::AddressSpace
/// - type::Builtin
/// - type::TexelFormat
@ -68,13 +68,13 @@ class ResolvedIdentifier {
return sem::BuiltinType::kNone;
}
/// @return the access if the ResolvedIdentifier holds type::Access, otherwise
/// type::Access::kUndefined
type::Access Access() const {
if (auto n = std::get_if<type::Access>(&value_)) {
/// @return the access if the ResolvedIdentifier holds builtin::Access, otherwise
/// builtin::Access::kUndefined
builtin::Access Access() const {
if (auto n = std::get_if<builtin::Access>(&value_)) {
return *n;
}
return type::Access::kUndefined;
return builtin::Access::kUndefined;
}
/// @return the address space if the ResolvedIdentifier holds type::AddressSpace, otherwise
@ -130,7 +130,7 @@ class ResolvedIdentifier {
std::variant<std::monostate,
const ast::Node*,
sem::BuiltinType,
type::Access,
builtin::Access,
type::AddressSpace,
type::Builtin,
type::TexelFormat>

View File

@ -1330,7 +1330,7 @@ INSTANTIATE_TEST_SUITE_P(Functions,
} // namespace resolve_to_builtin_type
////////////////////////////////////////////////////////////////////////////////
// Resolve to type::Access tests
// Resolve to builtin::Access tests
////////////////////////////////////////////////////////////////////////////////
namespace resolve_to_access {
@ -1348,7 +1348,7 @@ TEST_P(ResolverDependencyGraphResolveToAccess, Resolve) {
auto resolved = Build().resolved_identifiers.Get(ident);
ASSERT_TRUE(resolved);
EXPECT_EQ(resolved->Access(), type::ParseAccess(name))
EXPECT_EQ(resolved->Access(), builtin::ParseAccess(name))
<< resolved->String(Symbols(), Diagnostics());
}
@ -1400,17 +1400,17 @@ TEST_P(ResolverDependencyGraphResolveToAccess, ShadowedByFunc) {
INSTANTIATE_TEST_SUITE_P(Types,
ResolverDependencyGraphResolveToAccess,
testing::Combine(testing::ValuesIn(kTypeUseKinds),
testing::ValuesIn(type::kAccessStrings)));
testing::ValuesIn(builtin::kAccessStrings)));
INSTANTIATE_TEST_SUITE_P(Values,
ResolverDependencyGraphResolveToAccess,
testing::Combine(testing::ValuesIn(kValueUseKinds),
testing::ValuesIn(type::kAccessStrings)));
testing::ValuesIn(builtin::kAccessStrings)));
INSTANTIATE_TEST_SUITE_P(Functions,
ResolverDependencyGraphResolveToAccess,
testing::Combine(testing::ValuesIn(kFuncUseKinds),
testing::ValuesIn(type::kAccessStrings)));
testing::ValuesIn(builtin::kAccessStrings)));
} // namespace resolve_to_access
@ -1735,7 +1735,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
GlobalVar(Sym(), ty.external_texture());
GlobalVar(Sym(), ty.multisampled_texture(type::TextureDimension::k2d, T));
GlobalVar(Sym(), ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
type::Access::kRead));
builtin::Access::kRead));
GlobalVar(Sym(), ty.sampler(type::SamplerKind::kSampler));
GlobalVar(Sym(), ty.i32(), utils::Vector{Binding(V), Group(V)});

View File

@ -125,9 +125,9 @@ TEST_P(ResolverExpressionKindTest, Test) {
sym = Sym("write");
check_expr = [](const sem::Expression* expr) {
ASSERT_NE(expr, nullptr);
auto* enum_expr = expr->As<sem::BuiltinEnumExpression<type::Access>>();
auto* enum_expr = expr->As<sem::BuiltinEnumExpression<builtin::Access>>();
ASSERT_NE(enum_expr, nullptr);
EXPECT_EQ(enum_expr->Value(), type::Access::kWrite);
EXPECT_EQ(enum_expr->Value(), builtin::Access::kWrite);
};
break;
}

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

View File

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

View File

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

View File

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

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,
type::Access::kReadWrite);
builtin::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,
type::Access::kReadWrite);
builtin::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(), 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);
EXPECT_EQ(TypeOf(function_ptr)->As<type::Pointer>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(private_ptr)->As<type::Pointer>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(workgroup_ptr)->As<type::Pointer>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(uniform_ptr)->As<type::Pointer>()->Access(), builtin::Access::kRead);
EXPECT_EQ(TypeOf(storage_ptr)->As<type::Pointer>()->Access(), builtin::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,
type::Access::kReadWrite, Binding(0_a), Group(0_a));
builtin::Access::kReadWrite, Binding(0_a), Group(0_a));
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i);
auto* ptr =

View File

@ -87,7 +87,7 @@
#include "src/tint/utils/transform.h"
#include "src/tint/utils/vector.h"
TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression<tint::type::Access>);
TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression<tint::builtin::Access>);
TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression<tint::type::AddressSpace>);
TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression<tint::type::TexelFormat>);
@ -270,12 +270,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::kUndefined,
type::Access::kUndefined,
builtin::Access::kUndefined,
/* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt);
} else {
sem = builder_->create<sem::LocalVariable>(v, ty, sem::EvaluationStage::kRuntime,
type::AddressSpace::kUndefined,
type::Access::kUndefined, current_statement_,
builtin::Access::kUndefined, current_statement_,
/* constant_value */ nullptr);
}
@ -331,7 +331,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) {
auto* sem = builder_->create<sem::GlobalVariable>(
v, ty, sem::EvaluationStage::kOverride, type::AddressSpace::kUndefined,
type::Access::kUndefined,
builtin::Access::kUndefined,
/* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt);
sem->SetInitializer(rhs);
@ -427,10 +427,10 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
auto* sem = is_global
? static_cast<sem::Variable*>(builder_->create<sem::GlobalVariable>(
c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kUndefined,
type::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt))
builtin::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt))
: static_cast<sem::Variable*>(builder_->create<sem::LocalVariable>(
c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kUndefined,
type::Access::kUndefined, current_statement_, value));
builtin::Access::kUndefined, current_statement_, value));
sem->SetInitializer(rhs);
builder_->Sem().Add(c, sem);
@ -500,7 +500,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
return nullptr;
}
auto access = type::Access::kUndefined;
auto access = builtin::Access::kUndefined;
if (var->declared_access) {
auto expr = AccessExpression(var->declared_access);
if (!expr) {
@ -673,7 +673,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index)
}
auto* sem = builder_->create<sem::Parameter>(
param, index, ty, type::AddressSpace::kUndefined, type::Access::kUndefined,
param, index, ty, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
sem::ParameterUsage::kNone, binding_point, location);
builder_->Sem().Add(param, sem);
return sem;
@ -703,17 +703,17 @@ utils::Result<uint32_t> Resolver::LocationAttribute(const ast::LocationAttribute
return static_cast<uint32_t>(value);
}
type::Access Resolver::DefaultAccessForAddressSpace(type::AddressSpace address_space) {
builtin::Access Resolver::DefaultAccessForAddressSpace(type::AddressSpace address_space) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class
switch (address_space) {
case type::AddressSpace::kStorage:
case type::AddressSpace::kUniform:
case type::AddressSpace::kHandle:
return type::Access::kRead;
return builtin::Access::kRead;
default:
break;
}
return type::Access::kReadWrite;
return builtin::Access::kReadWrite;
}
bool Resolver::AllocateOverridableConstantIds() {
@ -1507,7 +1507,8 @@ sem::BuiltinEnumExpression<type::TexelFormat>* Resolver::TexelFormatExpression(
return sem_.AsTexelFormat(Expression(expr));
}
sem::BuiltinEnumExpression<type::Access>* Resolver::AccessExpression(const ast::Expression* expr) {
sem::BuiltinEnumExpression<builtin::Access>* Resolver::AccessExpression(
const ast::Expression* expr) {
return sem_.AsAccess(Expression(expr));
}
@ -2027,7 +2028,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
static_cast<uint32_t>(i), // index
arr->ElemType(), // type
type::AddressSpace::kUndefined, // address_space
type::Access::kUndefined);
builtin::Access::kUndefined);
});
return builder_->create<sem::TypeInitializer>(arr, std::move(params),
args_stage);
@ -2056,7 +2057,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
static_cast<uint32_t>(i), // index
str->Members()[i]->Type(), // type
type::AddressSpace::kUndefined, // address_space
type::Access::kUndefined); // access
builtin::Access::kUndefined); // access
}
return builder_->create<sem::TypeInitializer>(str, std::move(params),
args_stage);
@ -2976,9 +2977,9 @@ sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) {
return nullptr;
}
if (auto access = resolved->Access(); access != type::Access::kUndefined) {
return builder_->create<sem::BuiltinEnumExpression<type::Access>>(expr, current_statement_,
access);
if (auto access = resolved->Access(); access != builtin::Access::kUndefined) {
return builder_->create<sem::BuiltinEnumExpression<builtin::Access>>(
expr, current_statement_, access);
}
if (auto addr = resolved->AddressSpace(); addr != type::AddressSpace::kUndefined) {

View File

@ -150,10 +150,10 @@ class Resolver {
sem::BuiltinEnumExpression<type::TexelFormat>* TexelFormatExpression(
const ast::Expression* expr);
/// @returns the call of Expression() cast to a sem::BuiltinEnumExpression<type::Access>*.
/// If the sem::Expression is not a sem::BuiltinEnumExpression<type::Access>*, then an error
/// @returns the call of Expression() cast to a sem::BuiltinEnumExpression<builtin::Access>*.
/// If the sem::Expression is not a sem::BuiltinEnumExpression<builtin::Access>*, then an error
/// diagnostic is raised and nullptr is returned.
sem::BuiltinEnumExpression<type::Access>* AccessExpression(const ast::Expression* expr);
sem::BuiltinEnumExpression<builtin::Access>* AccessExpression(const ast::Expression* expr);
/// Expression traverses the graph of expressions starting at `expr`, building a post-ordered
/// list (leaf-first) of all the expression nodes. Each of the expressions are then resolved by
@ -405,7 +405,7 @@ class Resolver {
/// @param address_space the address space
/// @returns the default access control for the given address space
type::Access DefaultAccessForAddressSpace(type::AddressSpace address_space);
builtin::Access DefaultAccessForAddressSpace(type::AddressSpace address_space);
/// Allocate constant IDs for pipeline-overridable constants.
/// @returns true on success, false on error

View File

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

View File

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

View File

@ -74,7 +74,7 @@ void SemHelper::ErrorUnexpectedExprKind(const sem::Expression* expr,
fn_expr->Declaration()->source);
NoteDeclarationSource(fn);
},
[&](const sem::BuiltinEnumExpression<type::Access>* access) {
[&](const sem::BuiltinEnumExpression<builtin::Access>* access) {
AddError("cannot use access '" + utils::ToString(access->Value()) + "' as " +
std::string(wanted),
access->Declaration()->source);

View File

@ -135,11 +135,11 @@ class SemHelper {
/// @param expr the semantic node
/// @returns nullptr if @p expr is nullptr, or @p expr cast to
/// sem::BuiltinEnumExpression<type::Access> if the cast is successful, otherwise an error
/// sem::BuiltinEnumExpression<builtin::Access> if the cast is successful, otherwise an error
/// diagnostic is raised.
sem::BuiltinEnumExpression<type::Access>* AsAccess(sem::Expression* expr) const {
sem::BuiltinEnumExpression<builtin::Access>* AsAccess(sem::Expression* expr) const {
if (TINT_LIKELY(expr)) {
auto* enum_expr = expr->As<sem::BuiltinEnumExpression<type::Access>>();
auto* enum_expr = expr->As<sem::BuiltinEnumExpression<builtin::Access>>();
if (TINT_LIKELY(enum_expr)) {
return enum_expr;
}

View File

@ -179,8 +179,8 @@ 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, type::Access::kReadWrite,
Group(0_a), Binding(AInt(next_binding++)));
GlobalVar("a", ty.atomic(ty.i32()), type::AddressSpace::kStorage,
tint::builtin::Access::kReadWrite, Group(0_a), Binding(AInt(next_binding++)));
if (c.pipeline_stage != ast::PipelineStage::kCompute) {
GlobalVar("t2d", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(0_a),
Binding(AInt(next_binding++)));
@ -192,7 +192,7 @@ TEST_P(SideEffectsBuiltinTest, Test) {
Group(0_a), Binding(AInt(next_binding++)));
GlobalVar("tstorage2d",
ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
type::Access::kWrite),
tint::builtin::Access::kWrite),
Group(0_a), Binding(AInt(next_binding++)));
GlobalVar("s2d", ty.sampler(type::SamplerKind::kSampler), Group(0_a),
Binding(AInt(next_binding++)));

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, type::Access::kRead, Binding(1_a),
GlobalVar("y", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a),
Group(0_a));
WrapInFunction(Var("g", ty.Of(s)));

View File

@ -97,8 +97,9 @@ 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, type::Access::kReadWrite);
auto* expected =
create<type::Reference>(params.create_rhs_sem_type(*this), type::AddressSpace::kFunction,
builtin::Access::kReadWrite);
ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n"
<< "expected: " << FriendlyName(expected) << "\n";
}
@ -151,8 +152,9 @@ TEST_P(InferTypeTest_FromArithmeticExpression, All) {
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* got = TypeOf(a_ident);
auto* expected = create<type::Reference>(
params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, type::Access::kReadWrite);
auto* expected =
create<type::Reference>(params.create_rhs_sem_type(*this), type::AddressSpace::kFunction,
builtin::Access::kReadWrite);
ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n"
<< "expected: " << FriendlyName(expected) << "\n";
}
@ -199,8 +201,9 @@ TEST_P(InferTypeTest_FromCallExpression, All) {
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* got = TypeOf(a_ident);
auto* expected = create<type::Reference>(
params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, type::Access::kReadWrite);
auto* expected =
create<type::Reference>(params.create_rhs_sem_type(*this), type::AddressSpace::kFunction,
builtin::Access::kReadWrite);
ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n"
<< "expected: " << FriendlyName(expected) << "\n";
}

View File

@ -1066,7 +1066,7 @@ TEST_P(StorageTextureDimensionTest, All) {
auto& params = GetParam();
auto st = ty(Source{{12, 34}}, params.name, utils::ToString(type::TexelFormat::kR32Uint),
utils::ToString(type::Access::kWrite));
utils::ToString(builtin::Access::kWrite));
GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1117,19 +1117,19 @@ TEST_P(StorageTextureFormatTest, All) {
// var d : texture_storage_3d<*, write>;
auto st_a = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, params.format,
type::Access::kWrite);
builtin::Access::kWrite);
GlobalVar("a", st_a, Group(0_a), Binding(0_a));
ast::Type st_b =
ty.storage_texture(type::TextureDimension::k2d, params.format, type::Access::kWrite);
ty.storage_texture(type::TextureDimension::k2d, params.format, builtin::Access::kWrite);
GlobalVar("b", st_b, Group(0_a), Binding(1_a));
ast::Type st_c =
ty.storage_texture(type::TextureDimension::k2dArray, params.format, type::Access::kWrite);
ast::Type st_c = ty.storage_texture(type::TextureDimension::k2dArray, params.format,
builtin::Access::kWrite);
GlobalVar("c", st_c, Group(0_a), Binding(2_a));
ast::Type st_d =
ty.storage_texture(type::TextureDimension::k3d, params.format, type::Access::kWrite);
ty.storage_texture(type::TextureDimension::k3d, params.format, builtin::Access::kWrite);
GlobalVar("d", st_d, Group(0_a), Binding(3_a));
if (params.is_valid) {
@ -1176,7 +1176,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) {
// var a : texture_storage_1d<r32uint, read_write>;
auto st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
type::TexelFormat::kR32Uint, type::Access::kReadWrite);
type::TexelFormat::kR32Uint, builtin::Access::kReadWrite);
GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1190,7 +1190,7 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) {
// var a : texture_storage_1d<r32uint, read>;
auto st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
type::TexelFormat::kR32Uint, type::Access::kRead);
type::TexelFormat::kR32Uint, builtin::Access::kRead);
GlobalVar("a", st, Group(0_a), Binding(0_a));
@ -1204,7 +1204,7 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) {
// var a : texture_storage_1d<r32uint, write>;
auto st = ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kR32Uint,
type::Access::kWrite);
builtin::Access::kWrite);
GlobalVar("a", st, Group(0_a), Binding(0_a));

View File

@ -1211,7 +1211,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() != type::Access::kRead && load_rule) {
global->Access() != builtin::Access::kRead && load_rule) {
node->AddEdge(current_function_->may_be_non_uniform);
} else {
node->AddEdge(cf);
@ -1228,7 +1228,7 @@ class UniformityGraph {
// We are loading from the pointer, so add an edge to its contents.
auto* root = var_user->RootIdentifier();
if (root->Is<sem::GlobalVariable>()) {
if (root->Access() != type::Access::kRead) {
if (root->Access() != builtin::Access::kRead) {
// The contents of a mutable global variable is always non-uniform.
node->AddEdge(current_function_->may_be_non_uniform);
}
@ -1473,7 +1473,7 @@ class UniformityGraph {
auto* root = sem_arg->RootIdentifier();
if (root->Is<sem::GlobalVariable>()) {
if (root->Access() != type::Access::kRead) {
if (root->Access() != builtin::Access::kRead) {
// The contents of a mutable global variable is always non-uniform.
arg_contents->AddEdge(current_function_->may_be_non_uniform);
}

View File

@ -311,9 +311,9 @@ bool Validator::Pointer(const ast::TemplatedIdentifier* a, const type::Pointer*
bool Validator::StorageTexture(const type::StorageTexture* t, const Source& source) const {
switch (t->access()) {
case type::Access::kWrite:
case builtin::Access::kWrite:
break;
case type::Access::kUndefined:
case builtin::Access::kUndefined:
AddError("storage texture missing access control", source);
return false;
default:
@ -2373,7 +2373,7 @@ bool Validator::Assignment(const ast::Statement* a, const type::Type* rhs_ty) co
AddError("storage type of assignment must be constructible", a->source);
return false;
}
if (lhs_ref->Access() == type::Access::kRead) {
if (lhs_ref->Access() == builtin::Access::kRead) {
AddError("cannot store into a read-only type '" + sem_.RawTypeNameOf(lhs_ty) + "'",
a->source);
return false;
@ -2414,7 +2414,7 @@ bool Validator::IncrementDecrementStatement(const ast::IncrementDecrementStateme
return false;
}
if (lhs_ref->Access() == type::Access::kRead) {
if (lhs_ref->Access() == builtin::Access::kRead) {
AddError("cannot modify read-only type '" + sem_.RawTypeNameOf(lhs_ty) + "'", inc->source);
return false;
}
@ -2505,7 +2505,7 @@ std::string Validator::VectorPretty(uint32_t size, const type::Type* element_typ
bool Validator::CheckTypeAccessAddressSpace(
const type::Type* store_ty,
type::Access access,
builtin::Access access,
type::AddressSpace address_space,
utils::VectorRef<const tint::ast::Attribute*> attributes,
const Source& source) const {
@ -2523,7 +2523,7 @@ bool Validator::CheckTypeAccessAddressSpace(
return false;
}
if (address_space == type::AddressSpace::kStorage && access == type::Access::kWrite) {
if (address_space == type::AddressSpace::kStorage && access == builtin::Access::kWrite) {
// The access mode for the storage address space can only be 'read' or
// 'read_write'.
AddError("access mode 'write' is not valid for the 'storage' address space", source);
@ -2535,7 +2535,8 @@ bool Validator::CheckTypeAccessAddressSpace(
address_space != type::AddressSpace::kWorkgroup) {
return "atomic variables must have <storage> or <workgroup> address space";
}
if (address_space == type::AddressSpace::kStorage && access != type::Access::kReadWrite) {
if (address_space == type::AddressSpace::kStorage &&
access != builtin::Access::kReadWrite) {
return "atomic variables in <storage> address space must have read_write access "
"mode";
}

View File

@ -542,7 +542,7 @@ class Validator {
/// @param source the source for the error
/// @returns true on success, false if an error was raised.
bool CheckTypeAccessAddressSpace(const type::Type* store_ty,
type::Access access,
builtin::Access access,
type::AddressSpace address_space,
utils::VectorRef<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,
type::Access::kReadWrite);
builtin::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(), 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_EQ(TypeOf(i)->As<type::Reference>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(u)->As<type::Reference>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(f)->As<type::Reference>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(b)->As<type::Reference>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(s)->As<type::Reference>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(a)->As<type::Reference>()->Access(), builtin::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,
type::Access::kReadWrite, Binding(0_a), Group(0_a));
builtin::Access::kReadWrite, Binding(0_a), Group(0_a));
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 3_i);
auto* ptr = Let("p", AddressOf(expr));
@ -485,8 +485,8 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) {
ASSERT_TRUE(TypeOf(expr)->Is<type::Reference>());
ASSERT_TRUE(TypeOf(ptr)->Is<type::Pointer>());
EXPECT_EQ(TypeOf(expr)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(ptr)->As<type::Pointer>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(expr)->As<type::Reference>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(ptr)->As<type::Pointer>()->Access(), builtin::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(), 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);
EXPECT_EQ(TypeOf(private_)->As<type::Reference>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(workgroup)->As<type::Reference>()->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(TypeOf(uniform)->As<type::Reference>()->Access(), builtin::Access::kRead);
EXPECT_EQ(TypeOf(storage)->As<type::Reference>()->Access(), builtin::Access::kRead);
EXPECT_EQ(TypeOf(handle)->As<type::Reference>()->Access(), builtin::Access::kRead);
}
TEST_F(ResolverVariableTest, GlobalVar_ExplicitAddressSpace) {
@ -1066,13 +1066,13 @@ TEST_F(ResolverVariableTest, GlobalVar_ExplicitAddressSpace) {
auto* buf = Structure("S", utils::Vector{Member("m", ty.i32())});
auto* storage = GlobalVar("sb", ty.Of(buf), type::AddressSpace::kStorage,
type::Access::kReadWrite, Binding(1_a), Group(0_a));
builtin::Access::kReadWrite, Binding(1_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
ASSERT_TRUE(TypeOf(storage)->Is<type::Reference>());
EXPECT_EQ(TypeOf(storage)->As<type::Reference>()->Access(), type::Access::kReadWrite);
EXPECT_EQ(TypeOf(storage)->As<type::Reference>()->Access(), builtin::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, type::Access::kReadWrite),
ty.pointer<i32>(type::AddressSpace::kStorage, builtin::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,
type::Access access,
builtin::Access access,
const constant::Value* constant_value)
: declaration_(declaration),
type_(type),
@ -47,7 +47,7 @@ LocalVariable::LocalVariable(const ast::Variable* declaration,
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const sem::Statement* statement,
const constant::Value* constant_value)
: Base(declaration, type, stage, address_space, access, constant_value),
@ -59,7 +59,7 @@ GlobalVariable::GlobalVariable(const ast::Variable* declaration,
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const constant::Value* constant_value,
sem::BindingPoint binding_point,
std::optional<uint32_t> location)
@ -73,7 +73,7 @@ Parameter::Parameter(const ast::Parameter* declaration,
uint32_t index,
const type::Type* type,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const ParameterUsage usage /* = ParameterUsage::kNone */,
sem::BindingPoint binding_point /* = {} */,
std::optional<uint32_t> location /* = std::nullopt */)

View File

@ -22,10 +22,10 @@
#include "tint/override_id.h"
#include "src/tint/ast/parameter.h"
#include "src/tint/builtin/access.h"
#include "src/tint/sem/binding_point.h"
#include "src/tint/sem/parameter_usage.h"
#include "src/tint/sem/value_expression.h"
#include "src/tint/type/access.h"
#include "src/tint/type/address_space.h"
#include "src/tint/type/type.h"
#include "src/tint/utils/unique_vector.h"
@ -58,7 +58,7 @@ class Variable : public Castable<Variable, Node> {
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const constant::Value* constant_value);
/// Destructor
@ -77,7 +77,7 @@ class Variable : public Castable<Variable, Node> {
type::AddressSpace AddressSpace() const { return address_space_; }
/// @returns the access control for the variable
type::Access Access() const { return access_; }
builtin::Access Access() const { return access_; }
/// @return the constant value of this expression
const constant::Value* ConstantValue() const { return constant_value_; }
@ -101,7 +101,7 @@ class Variable : public Castable<Variable, Node> {
const type::Type* const type_;
const EvaluationStage stage_;
const type::AddressSpace address_space_;
const type::Access access_;
const builtin::Access access_;
const constant::Value* constant_value_;
const ValueExpression* initializer_ = nullptr;
std::vector<const VariableUser*> users_;
@ -122,7 +122,7 @@ class LocalVariable final : public Castable<LocalVariable, Variable> {
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const sem::Statement* statement,
const constant::Value* constant_value);
@ -163,7 +163,7 @@ class GlobalVariable final : public Castable<GlobalVariable, Variable> {
const type::Type* type,
EvaluationStage stage,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const constant::Value* constant_value,
sem::BindingPoint binding_point = {},
std::optional<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,
type::Access access,
builtin::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()) {
type::Access access = ac_it->second;
if (access == type::Access::kUndefined) {
builtin::Access access = ac_it->second;
if (access == builtin::Access::kUndefined) {
b.Diagnostics().add_error(diag::System::Transform,
"invalid access mode (" +
std::to_string(static_cast<uint32_t>(access)) +

View File

@ -17,9 +17,9 @@
#include <unordered_map>
#include "src/tint/builtin/access.h"
#include "src/tint/sem/binding_point.h"
#include "src/tint/transform/transform.h"
#include "src/tint/type/access.h"
namespace tint::transform {
@ -34,7 +34,7 @@ class BindingRemapper final : public Castable<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, type::Access>;
using AccessControls = std::unordered_map<BindingPoint, builtin::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}, type::Access::kWrite},
{{2, 1}, builtin::Access::kWrite},
});
EXPECT_TRUE(ShouldRun<BindingRemapper>(src, data));
@ -162,9 +162,9 @@ fn f() {
data.Add<BindingRemapper::Remappings>(
BindingRemapper::BindingPoints{},
BindingRemapper::AccessControls{
{{2, 1}, type::Access::kReadWrite}, // Modify access control
{{2, 1}, builtin::Access::kReadWrite}, // Modify access control
// Keep @group(3) @binding(2) as is
{{4, 3}, type::Access::kRead}, // Add access control
{{4, 3}, builtin::Access::kRead}, // Add access control
});
auto got = Run<BindingRemapper>(src, data);
@ -207,8 +207,8 @@ fn f() {
{{3, 2}, {6, 7}},
},
BindingRemapper::AccessControls{
{{2, 1}, type::Access::kReadWrite},
{{3, 2}, type::Access::kReadWrite},
{{2, 1}, builtin::Access::kReadWrite},
{{3, 2}, builtin::Access::kReadWrite},
});
auto got = Run<BindingRemapper>(src, data);

View File

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

View File

@ -396,7 +396,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) {
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array<f32, 4u>(utils::Vector{
b.Stride(32),
}))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -458,7 +458,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) {
b.Stride(4),
})),
});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -516,7 +516,7 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array<f32, 4u>(utils::Vector{
b.Stride(32),
}))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -582,7 +582,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
b.Stride(32),
}));
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR"))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
@ -658,7 +658,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
b.Stride(128),
}));
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR_B"))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{

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

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,
type::Access::kReadWrite)),
builtin::Access::kReadWrite)),
b.Param(kValueParamName, CreateASTTypeFor(ctx, ty)),
};
b.Func(helper_name, params, b.ty.void_(), body());

View File

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

View File

@ -1934,7 +1934,7 @@ std::vector<const char*> Identifiers() {
for (auto* ident : type::kTexelFormatStrings) {
out.push_back(ident);
}
for (auto* ident : type::kAccessStrings) {
for (auto* ident : builtin::kAccessStrings) {
out.push_back(ident);
}
return out;

View File

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

View File

@ -24,14 +24,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Pointer);
namespace tint::type {
Pointer::Pointer(const Type* subtype, type::AddressSpace address_space, type::Access access)
Pointer::Pointer(const Type* subtype, type::AddressSpace address_space, builtin::Access access)
: Base(utils::Hash(TypeInfo::Of<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 != type::Access::kUndefined);
TINT_ASSERT(Type, access != builtin::Access::kUndefined);
}
bool Pointer::Equals(const UniqueNode& other) const {

View File

@ -17,7 +17,7 @@
#include <string>
#include "src/tint/type/access.h"
#include "src/tint/builtin/access.h"
#include "src/tint/type/address_space.h"
#include "src/tint/type/type.h"
@ -30,7 +30,7 @@ class Pointer final : public Castable<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, type::Access access);
Pointer(const Type* subtype, type::AddressSpace address_space, builtin::Access access);
/// Destructor
~Pointer() override;
@ -46,7 +46,7 @@ class Pointer final : public Castable<Pointer, Type> {
type::AddressSpace AddressSpace() const { return address_space_; }
/// @returns the access control of the reference
type::Access Access() const { return access_; }
builtin::Access Access() const { return access_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
@ -60,7 +60,7 @@ class Pointer final : public Castable<Pointer, Type> {
private:
Type const* const subtype_;
type::AddressSpace const address_space_;
type::Access const access_;
builtin::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, 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);
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* c = create<Pointer>(create<F32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* d = create<Pointer>(create<I32>(), AddressSpace::kPrivate, builtin::Access::kReadWrite);
auto* e = create<Pointer>(create<I32>(), AddressSpace::kStorage, builtin::Access::kRead);
EXPECT_TRUE(a->StoreType()->Is<I32>());
EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage);
EXPECT_EQ(a->Access(), type::Access::kReadWrite);
EXPECT_EQ(a->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(a, b);
EXPECT_NE(a, c);
@ -38,18 +38,18 @@ TEST_F(PointerTest, Creation) {
}
TEST_F(PointerTest, Hash) {
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
EXPECT_EQ(a->unique_hash, b->unique_hash);
}
TEST_F(PointerTest, Equals) {
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);
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* c = create<Pointer>(create<F32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* d = create<Pointer>(create<I32>(), AddressSpace::kPrivate, builtin::Access::kReadWrite);
auto* e = create<Pointer>(create<I32>(), AddressSpace::kStorage, builtin::Access::kRead);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
@ -59,17 +59,17 @@ TEST_F(PointerTest, Equals) {
}
TEST_F(PointerTest, FriendlyName) {
auto* r = create<Pointer>(create<I32>(), AddressSpace::kUndefined, type::Access::kRead);
auto* r = create<Pointer>(create<I32>(), AddressSpace::kUndefined, builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<i32, read>");
}
TEST_F(PointerTest, FriendlyNameWithAddressSpace) {
auto* r = create<Pointer>(create<I32>(), AddressSpace::kWorkgroup, type::Access::kRead);
auto* r = create<Pointer>(create<I32>(), AddressSpace::kWorkgroup, builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<workgroup, i32, read>");
}
TEST_F(PointerTest, Clone) {
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* a = create<Pointer>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
type::Manager mgr;
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
@ -77,7 +77,7 @@ TEST_F(PointerTest, Clone) {
auto* ptr = a->Clone(ctx);
EXPECT_TRUE(ptr->StoreType()->Is<I32>());
EXPECT_EQ(ptr->AddressSpace(), AddressSpace::kStorage);
EXPECT_EQ(ptr->Access(), type::Access::kReadWrite);
EXPECT_EQ(ptr->Access(), builtin::Access::kReadWrite);
}
} // namespace

View File

@ -23,14 +23,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Reference);
namespace tint::type {
Reference::Reference(const Type* subtype, type::AddressSpace address_space, type::Access access)
Reference::Reference(const Type* subtype, type::AddressSpace address_space, builtin::Access access)
: Base(utils::Hash(TypeInfo::Of<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 != type::Access::kUndefined);
TINT_ASSERT(Type, access != builtin::Access::kUndefined);
}
bool Reference::Equals(const UniqueNode& other) const {

View File

@ -17,7 +17,7 @@
#include <string>
#include "src/tint/type/access.h"
#include "src/tint/builtin/access.h"
#include "src/tint/type/address_space.h"
#include "src/tint/type/type.h"
@ -30,7 +30,7 @@ class Reference final : public Castable<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, type::Access access);
Reference(const Type* subtype, type::AddressSpace address_space, builtin::Access access);
/// Destructor
~Reference() override;
@ -46,7 +46,7 @@ class Reference final : public Castable<Reference, Type> {
type::AddressSpace AddressSpace() const { return address_space_; }
/// @returns the resolved access control of the reference.
type::Access Access() const { return access_; }
builtin::Access Access() const { return access_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
@ -60,7 +60,7 @@ class Reference final : public Castable<Reference, Type> {
private:
Type const* const subtype_;
type::AddressSpace const address_space_;
type::Access const access_;
builtin::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, 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);
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* c = create<Reference>(create<F32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* d = create<Reference>(create<I32>(), AddressSpace::kPrivate, builtin::Access::kReadWrite);
auto* e = create<Reference>(create<I32>(), AddressSpace::kStorage, builtin::Access::kRead);
EXPECT_TRUE(a->StoreType()->Is<I32>());
EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage);
EXPECT_EQ(a->Access(), type::Access::kReadWrite);
EXPECT_EQ(a->Access(), builtin::Access::kReadWrite);
EXPECT_EQ(a, b);
EXPECT_NE(a, c);
@ -38,18 +38,18 @@ TEST_F(ReferenceTest, Creation) {
}
TEST_F(ReferenceTest, Hash) {
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
EXPECT_EQ(a->unique_hash, b->unique_hash);
}
TEST_F(ReferenceTest, Equals) {
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);
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* b = create<Reference>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* c = create<Reference>(create<F32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
auto* d = create<Reference>(create<I32>(), AddressSpace::kPrivate, builtin::Access::kReadWrite);
auto* e = create<Reference>(create<I32>(), AddressSpace::kStorage, builtin::Access::kRead);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
@ -59,17 +59,17 @@ TEST_F(ReferenceTest, Equals) {
}
TEST_F(ReferenceTest, FriendlyName) {
auto* r = create<Reference>(create<I32>(), AddressSpace::kUndefined, type::Access::kRead);
auto* r = create<Reference>(create<I32>(), AddressSpace::kUndefined, builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<i32, read>");
}
TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) {
auto* r = create<Reference>(create<I32>(), AddressSpace::kWorkgroup, type::Access::kRead);
auto* r = create<Reference>(create<I32>(), AddressSpace::kWorkgroup, builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<workgroup, i32, read>");
}
TEST_F(ReferenceTest, Clone) {
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, type::Access::kReadWrite);
auto* a = create<Reference>(create<I32>(), AddressSpace::kStorage, builtin::Access::kReadWrite);
type::Manager mgr;
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
@ -77,7 +77,7 @@ TEST_F(ReferenceTest, Clone) {
auto* ref = a->Clone(ctx);
EXPECT_TRUE(ref->StoreType()->Is<I32>());
EXPECT_EQ(ref->AddressSpace(), AddressSpace::kStorage);
EXPECT_EQ(ref->Access(), type::Access::kReadWrite);
EXPECT_EQ(ref->Access(), builtin::Access::kReadWrite);
}
} // namespace

View File

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

View File

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

View File

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

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, type::Access::kReadWrite);
create<Reference>(u32, AddressSpace::kPrivate, builtin::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::kUndefined, type::Access::kUndefined),
type::AddressSpace::kUndefined, builtin::Access::kUndefined),
sem::EvaluationStage::kRuntime);
auto* scalar_cast_sem = b->create<sem::Call>(
scalar_cast_ast, scalar_cast_target, sem::EvaluationStage::kRuntime,
@ -160,7 +160,7 @@ const sem::Call* AppendVector(ProgramBuilder* b,
[&](const tint::sem::ValueExpression* arg, size_t i) -> const sem::Parameter* {
return b->create<sem::Parameter>(
nullptr, static_cast<uint32_t>(i), arg->Type()->UnwrapRef(),
type::AddressSpace::kUndefined, type::Access::kUndefined);
type::AddressSpace::kUndefined, builtin::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, type::Access::kRead,
b.GlobalVar("buffer3", b.ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead,
b.Group(2_a), b.Binding(2_a));
const size_t num_samplers = 2;
@ -103,7 +103,7 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) {
b.Group(6_a), b.Binding(6_a));
b.GlobalVar("texture3",
b.ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
type::Access::kWrite),
builtin::Access::kWrite),
b.Group(7_a), b.Binding(7_a));
b.GlobalVar("texture4", b.ty.depth_texture(type::TextureDimension::k2d), b.Group(8_a),
b.Binding(8_a));

View File

@ -22,9 +22,9 @@
#include <vector>
#include "src/tint/ast/pipeline_stage.h"
#include "src/tint/builtin/access.h"
#include "src/tint/sem/binding_point.h"
#include "src/tint/sem/sampler_texture_pair.h"
#include "src/tint/type/access.h"
#include "src/tint/writer/glsl/version.h"
#include "src/tint/writer/text.h"
@ -61,7 +61,7 @@ struct Options {
/// A map of old binding point to new access control for the BindingRemapper
/// transform
std::unordered_map<sem::BindingPoint, type::Access> access_controls;
std::unordered_map<sem::BindingPoint, builtin::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::kUndefined, type::Access::kReadWrite,
if (!EmitType(out, dst_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"")) {
return false;
}
@ -438,12 +438,14 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres
auto* uint_type = BoolTypeToUint(bool_type);
// Cast result to bool scalar or vector type.
if (!EmitType(out, bool_type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
if (!EmitType(out, bool_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"")) {
return false;
}
ScopedParen outerCastParen(out);
// Cast LHS to uint scalar or vector type.
if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"")) {
return false;
}
{
@ -463,7 +465,8 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres
return false;
}
// Cast RHS to uint scalar or vector type.
if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"")) {
return false;
}
{
@ -491,20 +494,20 @@ bool GeneratorImpl::EmitFloatModulo(std::ostream& out, const ast::BinaryExpressi
{
auto decl = line(&b);
if (!EmitTypeAndName(decl, ret_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, fn_name)) {
builtin::Access::kUndefined, fn_name)) {
return "";
}
{
ScopedParen sp(decl);
const auto* ty = TypeOf(expr->lhs)->UnwrapRef();
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "lhs")) {
builtin::Access::kUndefined, "lhs")) {
return "";
}
decl << ", ";
ty = TypeOf(expr->rhs)->UnwrapRef();
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "rhs")) {
builtin::Access::kUndefined, "rhs")) {
return "";
}
}
@ -827,7 +830,7 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out,
bool GeneratorImpl::EmitTypeConversion(std::ostream& out,
const sem::Call* call,
const sem::TypeConversion* conv) {
if (!EmitType(out, conv->Target(), type::AddressSpace::kUndefined, type::Access::kReadWrite,
if (!EmitType(out, conv->Target(), type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"")) {
return false;
}
@ -851,7 +854,7 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out,
return EmitZeroValue(out, type);
}
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) {
return false;
}
ScopedParen sp(out);
@ -922,7 +925,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
{
auto pre = line();
if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined, result)) {
builtin::Access::kUndefined, result)) {
return false;
}
pre << ";";
@ -1060,7 +1063,7 @@ bool GeneratorImpl::EmitCountOneBitsCall(std::ostream& out, const ast::CallExpre
// GLSL's bitCount returns an integer type, so cast it to the appropriate
// unsigned type.
if (!EmitType(out, TypeOf(expr)->UnwrapRef(), type::AddressSpace::kUndefined,
type::Access::kReadWrite, "")) {
builtin::Access::kReadWrite, "")) {
return false;
}
out << "(bitCount(";
@ -1132,7 +1135,7 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out,
{
std::stringstream s;
if (!EmitType(s, vec_ty->type(), type::AddressSpace::kUndefined,
type::Access::kRead, "")) {
builtin::Access::kRead, "")) {
return "";
}
v = s.str();
@ -1140,15 +1143,17 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out,
{ // (u)int tint_int_dot([i|u]vecN a, [i|u]vecN b) {
auto l = line(&b);
if (!EmitType(l, vec_ty->type(), type::AddressSpace::kUndefined,
type::Access::kRead, "")) {
builtin::Access::kRead, "")) {
return "";
}
l << " " << fn_name << "(";
if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, type::Access::kRead, "")) {
if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, builtin::Access::kRead,
"")) {
return "";
}
l << " a, ";
if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, type::Access::kRead, "")) {
if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, builtin::Access::kRead,
"")) {
return "";
}
l << " b) {";
@ -1200,7 +1205,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out,
{
auto l = line(b);
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined, "")) {
builtin::Access::kUndefined, "")) {
return false;
}
l << " result;";
@ -1226,7 +1231,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out,
{
auto l = line(b);
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined, "")) {
builtin::Access::kUndefined, "")) {
return false;
}
l << " result;";
@ -1884,7 +1889,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
auto out = line();
auto name = builder_.Symbols().NameFor(func->name->symbol);
if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kReadWrite, "")) {
builtin::Access::kReadWrite, "")) {
return false;
}
@ -2261,7 +2266,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
{
auto out = line();
if (!EmitTypeAndName(out, func_sem->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined,
builtin::Access::kUndefined,
builder_.Symbols().NameFor(func->name->symbol))) {
return false;
}
@ -2341,7 +2346,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const
return true;
},
[&](const type::Vector* v) {
if (!EmitType(out, v, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
if (!EmitType(out, v, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
"")) {
return false;
}
@ -2362,7 +2368,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const
return true;
},
[&](const type::Matrix* m) {
if (!EmitType(out, m, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
if (!EmitType(out, m, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
"")) {
return false;
}
@ -2379,7 +2386,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const
return true;
},
[&](const type::Array* a) {
if (!EmitType(out, a, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
if (!EmitType(out, a, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
"")) {
return false;
}
@ -2471,7 +2479,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
} else if (type->Is<type::U32>()) {
out << "0u";
} else if (auto* vec = type->As<type::Vector>()) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) {
return false;
}
ScopedParen sp(out);
@ -2484,7 +2492,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
}
}
} else if (auto* mat = type->As<type::Matrix>()) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) {
return false;
}
ScopedParen sp(out);
@ -2497,7 +2505,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
}
}
} else if (auto* str = type->As<sem::Struct>()) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) {
return false;
}
bool first = true;
@ -2511,7 +2519,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
EmitZeroValue(out, member->Type());
}
} else if (auto* arr = type->As<type::Array>()) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) {
return false;
}
ScopedParen sp(out);
@ -2837,7 +2845,7 @@ bool GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) {
bool GeneratorImpl::EmitType(std::ostream& out,
const type::Type* type,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const std::string& name,
bool* name_printed /* = nullptr */) {
if (name_printed) {
@ -2934,7 +2942,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
out << "highp ";
if (storage && storage->access() != type::Access::kRead) {
if (storage && storage->access() != builtin::Access::kRead) {
out << "writeonly ";
}
auto* subtype = sampled ? sampled->type()
@ -3018,7 +3026,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
bool GeneratorImpl::EmitTypeAndName(std::ostream& out,
const type::Type* type,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const std::string& name) {
bool printed_name = false;
if (!EmitType(out, type, address_space, access, name, &printed_name)) {
@ -3054,7 +3062,7 @@ bool GeneratorImpl::EmitStructMembers(TextBuffer* b, const sem::Struct* str) {
auto out = line(b);
if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, type::Access::kReadWrite,
if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
name)) {
return false;
}
@ -3123,7 +3131,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
auto out = line();
// TODO(senorblanco): handle const
if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined,
if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
builder_.Symbols().NameFor(let->name->symbol))) {
return false;
}
@ -3145,7 +3153,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) {
auto out = line();
out << "const ";
if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined,
if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
builder_.Symbols().NameFor(var->name->symbol))) {
return false;
}
@ -3173,7 +3181,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out,
{
auto decl = line(&b);
if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined, fn_name)) {
builtin::Access::kUndefined, fn_name)) {
return "";
}
{
@ -3189,7 +3197,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out,
ty = ptr->StoreType();
}
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, param_name)) {
builtin::Access::kUndefined, param_name)) {
return "";
}
parameter_names.emplace_back(std::move(param_name));

View File

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

View File

@ -442,7 +442,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
Member("b", ty.f32()),
});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(1_a));
auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b"));
@ -489,7 +489,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
Member("b", ty.f32()),
});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a),
Group(1_a));
auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b"));
@ -537,7 +537,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
Member("b", ty.f32()),
});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(1_a));
Func("frag_main", utils::Empty, ty.void_(),
@ -582,7 +582,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
Member("b", ty.f32()),
});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(1_a));
Func("frag_main", utils::Empty, ty.void_(),
@ -668,7 +668,7 @@ void frag_main() {
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) {
auto* s = Structure("S", utils::Vector{Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(1_a));
Func("sub_func", utils::Vector{Param("param", ty.f32())}, ty.f32(),
@ -879,7 +879,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())});
GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(0_a));
{

View File

@ -91,7 +91,7 @@ class GlslGeneratorImplTest_MemberAccessorBase : public BASE {
auto* s = b.Structure("Data", members);
b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
b.Group(1_a), b.Binding(0_a));
}

View File

@ -26,7 +26,7 @@ using GlslSanitizerTest = TestHelper;
TEST_F(GlslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array<f32>())});
GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a),
GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a),
Group(2_a));
Func("a_func", utils::Empty, ty.void_(),
@ -66,7 +66,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
Member(0, "z", ty.f32()),
Member(4, "a", ty.array<f32>()),
});
GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a),
GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a),
Group(2_a));
Func("a_func", utils::Empty, ty.void_(),
@ -105,7 +105,7 @@ void main() {
TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array<f32>())});
GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(1_a),
GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a),
Group(2_a));
auto* p = Let("p", AddressOf("b"));

View File

@ -40,7 +40,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) {
std::stringstream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined,
type::Access::kReadWrite, "ary"))
builtin::Access::kReadWrite, "ary"))
<< gen.error();
EXPECT_EQ(out.str(), "bool ary[4]");
}
@ -53,7 +53,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
std::stringstream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined,
type::Access::kReadWrite, "ary"))
builtin::Access::kReadWrite, "ary"))
<< gen.error();
EXPECT_EQ(out.str(), "bool ary[5][4]");
}
@ -66,7 +66,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
std::stringstream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined,
type::Access::kReadWrite, "ary"))
builtin::Access::kReadWrite, "ary"))
<< gen.error();
EXPECT_EQ(out.str(), "bool ary[6][5][4]");
}
@ -79,7 +79,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
std::stringstream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined,
type::Access::kReadWrite, ""))
builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "bool[4]");
}
@ -91,7 +91,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, bool_, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, bool_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "bool");
}
@ -103,7 +103,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, f32, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, f32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "float");
}
@ -117,7 +117,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, f16, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, f16, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "float16_t");
}
@ -129,7 +129,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, i32, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, i32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "int");
}
@ -143,7 +143,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "mat2x3");
}
@ -159,7 +159,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "f16mat2x3");
}
@ -196,7 +196,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct) {
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, sem_s, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, sem_s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "S");
}
@ -245,7 +245,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, u32, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, u32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "uint");
}
@ -258,7 +258,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, vec3, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, vec3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "vec3");
}
@ -273,7 +273,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, vec3, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, vec3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "f16vec3");
}
@ -285,7 +285,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) {
std::stringstream out;
ASSERT_TRUE(
gen.EmitType(out, void_, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, void_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "void");
}
@ -297,7 +297,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSampler) {
std::stringstream out;
ASSERT_FALSE(
gen.EmitType(out, sampler, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
}
@ -308,7 +308,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) {
std::stringstream out;
ASSERT_FALSE(
gen.EmitType(out, sampler, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
}
@ -514,7 +514,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
GeneratorImpl& gen = Build();
std::stringstream out;
ASSERT_TRUE(gen.EmitType(out, s, type::AddressSpace::kUndefined, type::Access::kReadWrite, ""))
ASSERT_TRUE(
gen.EmitType(out, s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
EXPECT_EQ(out.str(), "highp sampler2DMS");
}
@ -531,7 +532,7 @@ using GlslStorageTexturesTest = TestParamHelper<GlslStorageTextureData>;
TEST_P(GlslStorageTexturesTest, Emit) {
auto params = GetParam();
auto t = ty.storage_texture(params.dim, params.imgfmt, type::Access::kWrite);
auto t = ty.storage_texture(params.dim, params.imgfmt, builtin::Access::kWrite);
GlobalVar("tex", t, Binding(1_a), Group(2_a));

View File

@ -377,8 +377,8 @@ bool GeneratorImpl::EmitDynamicVectorAssignment(const ast::AssignmentStatement*
std::string fn;
{
std::ostringstream ss;
if (!EmitType(ss, vec, tint::type::AddressSpace::kUndefined, type::Access::kUndefined,
"")) {
if (!EmitType(ss, vec, tint::type::AddressSpace::kUndefined,
builtin::Access::kUndefined, "")) {
return "";
}
fn = UniqueIdentifier("set_" + ss.str());
@ -386,13 +386,13 @@ bool GeneratorImpl::EmitDynamicVectorAssignment(const ast::AssignmentStatement*
{
auto out = line(&helpers_);
out << "void " << fn << "(inout ";
if (!EmitTypeAndName(out, vec, type::AddressSpace::kUndefined, type::Access::kUndefined,
"vec")) {
if (!EmitTypeAndName(out, vec, type::AddressSpace::kUndefined,
builtin::Access::kUndefined, "vec")) {
return "";
}
out << ", int idx, ";
if (!EmitTypeAndName(out, vec->type(), type::AddressSpace::kUndefined,
type::Access::kUndefined, "val")) {
builtin::Access::kUndefined, "val")) {
return "";
}
out << ") {";
@ -451,8 +451,8 @@ bool GeneratorImpl::EmitDynamicMatrixVectorAssignment(const ast::AssignmentState
std::string fn;
{
std::ostringstream ss;
if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, type::Access::kUndefined,
"")) {
if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined,
builtin::Access::kUndefined, "")) {
return "";
}
fn = UniqueIdentifier("set_vector_" + ss.str());
@ -460,13 +460,13 @@ bool GeneratorImpl::EmitDynamicMatrixVectorAssignment(const ast::AssignmentState
{
auto out = line(&helpers_);
out << "void " << fn << "(inout ";
if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, type::Access::kUndefined,
"mat")) {
if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined,
builtin::Access::kUndefined, "mat")) {
return "";
}
out << ", int col, ";
if (!EmitTypeAndName(out, mat->ColumnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined, "val")) {
builtin::Access::kUndefined, "val")) {
return "";
}
out << ") {";
@ -520,8 +520,8 @@ bool GeneratorImpl::EmitDynamicMatrixScalarAssignment(const ast::AssignmentState
std::string fn;
{
std::ostringstream ss;
if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, type::Access::kUndefined,
"")) {
if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined,
builtin::Access::kUndefined, "")) {
return "";
}
fn = UniqueIdentifier("set_scalar_" + ss.str());
@ -529,13 +529,13 @@ bool GeneratorImpl::EmitDynamicMatrixScalarAssignment(const ast::AssignmentState
{
auto out = line(&helpers_);
out << "void " << fn << "(inout ";
if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, type::Access::kUndefined,
"mat")) {
if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined,
builtin::Access::kUndefined, "mat")) {
return "";
}
out << ", int col, int row, ";
if (!EmitTypeAndName(out, mat->type(), type::AddressSpace::kUndefined,
type::Access::kUndefined, "val")) {
builtin::Access::kUndefined, "val")) {
return "";
}
out << ") {";
@ -642,7 +642,7 @@ bool GeneratorImpl::EmitBitcast(std::ostream& out, const ast::BitcastExpression*
}
out << "as";
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) {
return false;
}
out << "(";
@ -1030,7 +1030,7 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out,
bool GeneratorImpl::EmitTypeConversion(std::ostream& out,
const sem::Call* call,
const sem::TypeConversion* conv) {
if (!EmitType(out, conv->Target(), type::AddressSpace::kUndefined, type::Access::kReadWrite,
if (!EmitType(out, conv->Target(), type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"")) {
return false;
}
@ -1076,7 +1076,7 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out,
if (brackets) {
out << "{";
} else {
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) {
return false;
}
out << "(";
@ -1594,12 +1594,12 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic(
{
auto fn = line(&buf);
if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, name)) {
builtin::Access::kUndefined, name)) {
return false;
}
fn << "(RWByteAddressBuffer buffer, uint offset, ";
if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "value")) {
builtin::Access::kUndefined, "value")) {
return false;
}
fn << ") {";
@ -1615,7 +1615,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic(
{
auto l = line(&buf);
if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "original_value")) {
builtin::Access::kUndefined, "original_value")) {
return false;
}
l << " = 0;";
@ -1664,7 +1664,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic(
{
auto fn = line(&buf);
if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, name)) {
builtin::Access::kUndefined, name)) {
return false;
}
fn << "(RWByteAddressBuffer buffer, uint offset) {";
@ -1680,7 +1680,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic(
{
auto l = line(&buf);
if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "value")) {
builtin::Access::kUndefined, "value")) {
return false;
}
l << " = 0;";
@ -1698,7 +1698,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic(
auto fn = line(&buf);
fn << "void " << name << "(RWByteAddressBuffer buffer, uint offset, ";
if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "value")) {
builtin::Access::kUndefined, "value")) {
return false;
}
fn << ") {";
@ -1714,7 +1714,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic(
{
auto l = line(&buf);
if (!EmitTypeAndName(l, value_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "ignored")) {
builtin::Access::kUndefined, "ignored")) {
return false;
}
l << ";";
@ -1729,17 +1729,17 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic(
{
auto fn = line(&buf);
if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, name)) {
builtin::Access::kUndefined, name)) {
return false;
}
fn << "(RWByteAddressBuffer buffer, uint offset, ";
if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "compare")) {
builtin::Access::kUndefined, "compare")) {
return false;
}
fn << ", ";
if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "value")) {
builtin::Access::kUndefined, "value")) {
return false;
}
fn << ") {";
@ -1755,7 +1755,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic(
{ // T result = {0};
auto l = line(&buf);
if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, "result")) {
builtin::Access::kUndefined, "result")) {
return false;
}
l << "=";
@ -1790,7 +1790,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
if (!builtin->ReturnType()->Is<type::Void>()) {
auto pre = line();
if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined, result)) {
builtin::Access::kUndefined, result)) {
return false;
}
pre << " = ";
@ -1854,7 +1854,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
auto pre = line();
auto* value_ty = builtin->Parameters()[1]->Type()->UnwrapRef();
if (!EmitTypeAndName(pre, value_ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, result)) {
builtin::Access::kUndefined, result)) {
return false;
}
pre << " = ";
@ -1892,7 +1892,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
{ // T compare_value = <compare_value>;
auto pre = line();
if (!EmitTypeAndName(pre, TypeOf(compare_value)->UnwrapRef(),
type::AddressSpace::kUndefined, type::Access::kUndefined,
type::AddressSpace::kUndefined, builtin::Access::kUndefined,
compare)) {
return false;
}
@ -2003,7 +2003,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out,
{
auto l = line(b);
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined, "")) {
builtin::Access::kUndefined, "")) {
return false;
}
l << " result;";
@ -2045,7 +2045,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out,
{
auto l = line(b);
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined, "")) {
builtin::Access::kUndefined, "")) {
return false;
}
l << " result = {fract, int" << width << "(exp)};";
@ -2082,7 +2082,8 @@ bool GeneratorImpl::EmitRadiansCall(std::ostream& out,
// type after the call to `sign`.
bool GeneratorImpl::EmitSignCall(std::ostream& out, const sem::Call* call, const sem::Builtin*) {
auto* arg = call->Arguments()[0];
if (!EmitType(out, arg->Type(), type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
if (!EmitType(out, arg->Type(), type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"")) {
return false;
}
out << "(sign(";
@ -2885,14 +2886,14 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
auto pre = line();
pre << "typedef ";
if (!EmitTypeAndName(pre, sem->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kReadWrite, typedef_name)) {
builtin::Access::kReadWrite, typedef_name)) {
return false;
}
pre << ";";
out << typedef_name;
} else {
if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kReadWrite, "")) {
builtin::Access::kReadWrite, "")) {
return false;
}
}
@ -2909,7 +2910,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
auto const* type = v->Type();
auto address_space = type::AddressSpace::kUndefined;
auto access = type::Access::kUndefined;
auto access = builtin::Access::kUndefined;
if (auto* ptr = type->As<type::Pointer>()) {
type = ptr->StoreType();
@ -2983,7 +2984,7 @@ bool GeneratorImpl::EmitFunctionBodyWithDiscard(const ast::Function* func) {
{
auto out = line();
if (!EmitTypeAndName(out, sem->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kReadWrite, name)) {
builtin::Access::kReadWrite, name)) {
return false;
}
out << ";";
@ -3068,7 +3069,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable
}
auto* global_sem = sem->As<sem::GlobalVariable>();
out << RegisterAndSpace(sem->Access() == type::Access::kRead ? 't' : 'u',
out << RegisterAndSpace(sem->Access() == builtin::Access::kRead ? 't' : 'u',
global_sem->BindingPoint())
<< ";";
@ -3241,7 +3242,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
}
if (!EmitTypeAndName(out, func_sem->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined,
builtin::Access::kUndefined,
builder_.Symbols().NameFor(func->name->symbol))) {
return false;
}
@ -3336,7 +3337,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out,
return true;
}
if (!EmitType(out, v, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
if (!EmitType(out, v, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
"")) {
return false;
}
@ -3353,7 +3355,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out,
return true;
},
[&](const type::Matrix* m) {
if (!EmitType(out, m, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
if (!EmitType(out, m, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
"")) {
return false;
}
@ -3372,7 +3375,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out,
[&](const type::Array* a) {
if (constant->AllZero()) {
out << "(";
if (!EmitType(out, a, type::AddressSpace::kUndefined, type::Access::kUndefined,
if (!EmitType(out, a, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
"")) {
return false;
}
@ -3513,7 +3516,7 @@ bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int val
return true;
},
[&](const type::Vector* vec) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite,
if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"")) {
return false;
}
@ -3529,7 +3532,7 @@ bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int val
return true;
},
[&](const type::Matrix* mat) {
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite,
if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"")) {
return false;
}
@ -3547,13 +3550,13 @@ bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int val
[&](const sem::Struct*) {
out << "(";
TINT_DEFER(out << ")" << value);
return EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined,
return EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
"");
},
[&](const type::Array*) {
out << "(";
TINT_DEFER(out << ")" << value);
return EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined,
return EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
"");
},
[&](Default) {
@ -3929,7 +3932,7 @@ bool GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) {
bool GeneratorImpl::EmitType(std::ostream& out,
const type::Type* type,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const std::string& name,
bool* name_printed /* = nullptr */) {
if (name_printed) {
@ -3937,7 +3940,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
}
switch (address_space) {
case type::AddressSpace::kStorage:
if (access != type::Access::kRead) {
if (access != builtin::Access::kRead) {
out << "RW";
}
out << "ByteAddressBuffer";
@ -4059,7 +4062,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
auto* depth_ms = tex->As<type::DepthMultisampledTexture>();
auto* sampled = tex->As<type::SampledTexture>();
if (storage && storage->access() != type::Access::kRead) {
if (storage && storage->access() != builtin::Access::kRead) {
out << "RW";
}
out << "Texture";
@ -4156,7 +4159,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
bool GeneratorImpl::EmitTypeAndName(std::ostream& out,
const type::Type* type,
type::AddressSpace address_space,
type::Access access,
builtin::Access access,
const std::string& name) {
bool name_printed = false;
if (!EmitType(out, type, address_space, access, name, &name_printed)) {
@ -4238,8 +4241,8 @@ bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) {
}
out << pre;
if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, type::Access::kReadWrite,
mem_name)) {
if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined,
builtin::Access::kReadWrite, mem_name)) {
return false;
}
out << post << ";";
@ -4308,7 +4311,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
auto out = line();
out << "const ";
if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined,
if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined,
builder_.Symbols().NameFor(let->name->symbol))) {
return false;
}
@ -4336,7 +4339,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out,
{
auto decl = line(&b);
if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kUndefined,
type::Access::kUndefined, fn_name)) {
builtin::Access::kUndefined, fn_name)) {
return "";
}
{
@ -4352,7 +4355,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out,
ty = ptr->StoreType();
}
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined,
type::Access::kUndefined, param_name)) {
builtin::Access::kUndefined, param_name)) {
return "";
}
parameter_names.emplace_back(std::move(param_name));

View File

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

View File

@ -436,7 +436,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
Member("b", ty.f32()),
});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(1_a));
auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b"));
@ -469,7 +469,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
Member("b", ty.f32()),
});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a),
Group(1_a));
auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b"));
@ -502,7 +502,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
Member("b", ty.f32()),
});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(1_a));
Func("frag_main", utils::Empty, ty.void_(),
@ -533,7 +533,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
Member("b", ty.f32()),
});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(1_a));
Func("frag_main", utils::Empty, ty.void_(),
@ -602,7 +602,7 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) {
auto* s = Structure("S", utils::Vector{Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(1_a));
Func("sub_func",
@ -830,7 +830,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())});
GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, type::Access::kReadWrite,
GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(0_a));
{

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