Update storage_buffer storage class.
This Cl updates the `storage_buffer` storage class to just be `storage`. Change-Id: Ibfaecbb0862bd60d39665eb937c0b6300899e177 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38161 Auto-Submit: dan sinclair <dsinclair@chromium.org> Reviewed-by: David Neto <dneto@google.com> Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
7edf1fbc20
commit
336bb0b4dd
|
@ -76,7 +76,7 @@
|
|||
"sampler"
|
||||
"sampler_comparison"
|
||||
"set"
|
||||
"storage_buffer"
|
||||
"storage"
|
||||
"stage"
|
||||
"stride"
|
||||
"struct"
|
||||
|
|
|
@ -130,7 +130,7 @@ Function::referenced_storagebuffer_variables() const {
|
|||
std::vector<std::pair<Variable*, Function::BindingInfo>> ret;
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
if (var->storage_class() != StorageClass::kStorageBuffer) {
|
||||
if (var->storage_class() != StorageClass::kStorage) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,10 +51,10 @@ var<uniform> g5 : [[access(read)]] texture_storage_2d<r32uint>;
|
|||
var<uniform> g6 : [[access(write)]] texture_storage_2d<rg32float>;
|
||||
|
||||
[[builtin(position)]] var<uniform> g7 : vec3<f32>;
|
||||
[[group(10), binding(20)]] var<storage_buffer> g7 : S;
|
||||
[[group(10), binding(20)]] var<storage_buffer> g8 : [[access(read)]]
|
||||
[[group(10), binding(20)]] var<storage> g7 : S;
|
||||
[[group(10), binding(20)]] var<storage> g8 : [[access(read)]]
|
||||
S;
|
||||
[[group(10), binding(20)]] var<storage_buffer> g9 : [[access(read_write)]]
|
||||
[[group(10), binding(20)]] var<storage> g9 : [[access(read_write)]]
|
||||
S;
|
||||
|
||||
fn f0(p0 : bool) -> f32 {
|
||||
|
|
|
@ -43,8 +43,8 @@ std::ostream& operator<<(std::ostream& out, StorageClass sc) {
|
|||
out << "uniform_constant";
|
||||
break;
|
||||
}
|
||||
case StorageClass::kStorageBuffer: {
|
||||
out << "storage_buffer";
|
||||
case StorageClass::kStorage: {
|
||||
out << "storage";
|
||||
break;
|
||||
}
|
||||
case StorageClass::kImage: {
|
||||
|
|
|
@ -28,7 +28,7 @@ enum class StorageClass {
|
|||
kUniform,
|
||||
kWorkgroup,
|
||||
kUniformConstant,
|
||||
kStorageBuffer,
|
||||
kStorage,
|
||||
kImage,
|
||||
kPrivate,
|
||||
kFunction
|
||||
|
|
|
@ -35,9 +35,9 @@ using PointerTest = TestHelper;
|
|||
|
||||
TEST_F(PointerTest, Creation) {
|
||||
I32 i32;
|
||||
Pointer p{&i32, StorageClass::kStorageBuffer};
|
||||
Pointer p{&i32, StorageClass::kStorage};
|
||||
EXPECT_EQ(p.type(), &i32);
|
||||
EXPECT_EQ(p.storage_class(), StorageClass::kStorageBuffer);
|
||||
EXPECT_EQ(p.storage_class(), StorageClass::kStorage);
|
||||
}
|
||||
|
||||
TEST_F(PointerTest, Is) {
|
||||
|
|
|
@ -356,7 +356,7 @@ class InspectorHelper : public ast::BuilderWithModule {
|
|||
ast::type::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
AddBinding(name, type, ast::StorageClass::kStorageBuffer, group, binding);
|
||||
AddBinding(name, type, ast::StorageClass::kStorage, group, binding);
|
||||
}
|
||||
|
||||
/// Generates a function that references a specific struct variable
|
||||
|
|
|
@ -51,7 +51,7 @@ ast::StorageClass EnumConverter::ToStorageClass(const SpvStorageClass sc) {
|
|||
case SpvStorageClassUniformConstant:
|
||||
return ast::StorageClass::kUniformConstant;
|
||||
case SpvStorageClassStorageBuffer:
|
||||
return ast::StorageClass::kStorageBuffer;
|
||||
return ast::StorageClass::kStorage;
|
||||
case SpvStorageClassImage:
|
||||
return ast::StorageClass::kImage;
|
||||
case SpvStorageClassPrivate:
|
||||
|
|
|
@ -148,7 +148,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
StorageClassCase{SpvStorageClassUniformConstant, true,
|
||||
ast::StorageClass::kUniformConstant},
|
||||
StorageClassCase{SpvStorageClassStorageBuffer, true,
|
||||
ast::StorageClass::kStorageBuffer},
|
||||
ast::StorageClass::kStorage},
|
||||
StorageClassCase{SpvStorageClassImage, true, ast::StorageClass::kImage},
|
||||
StorageClassCase{SpvStorageClassPrivate, true,
|
||||
ast::StorageClass::kPrivate},
|
||||
|
|
|
@ -811,7 +811,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_TypesAndVarDeclarations) {
|
|||
}
|
||||
Variable{
|
||||
myvar
|
||||
storage_buffer
|
||||
storage
|
||||
__access_control_read_write__struct_S
|
||||
})"));
|
||||
}
|
||||
|
@ -913,7 +913,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) {
|
|||
VariableConst{
|
||||
x_2
|
||||
none
|
||||
__ptr_storage_buffer__u32
|
||||
__ptr_storage__u32
|
||||
{
|
||||
ArrayAccessor[not set]{
|
||||
MemberAccessor[not set]{
|
||||
|
@ -969,7 +969,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithHoisting) {
|
|||
Variable{
|
||||
x_2
|
||||
function
|
||||
__ptr_storage_buffer__u32
|
||||
__ptr_storage__u32
|
||||
}
|
||||
}
|
||||
If{
|
||||
|
|
|
@ -26,84 +26,32 @@ namespace {
|
|||
|
||||
const char* kWGSLReservedWords[] = {
|
||||
// Please keep this list sorted
|
||||
"array",
|
||||
"as",
|
||||
"asm",
|
||||
"bf16",
|
||||
"binding",
|
||||
"block",
|
||||
"bool",
|
||||
"break",
|
||||
"builtin",
|
||||
"case",
|
||||
"cast",
|
||||
"compute",
|
||||
"const",
|
||||
"constant_id",
|
||||
"continue",
|
||||
"default",
|
||||
"discard",
|
||||
"do",
|
||||
"else",
|
||||
"elseif",
|
||||
"entry_point",
|
||||
"enum",
|
||||
"f16",
|
||||
"f32",
|
||||
"fallthrough",
|
||||
"false",
|
||||
"fn",
|
||||
"for",
|
||||
"fragment",
|
||||
"i16",
|
||||
"i32",
|
||||
"i64",
|
||||
"i8",
|
||||
"if",
|
||||
"image",
|
||||
"import",
|
||||
"in",
|
||||
"let",
|
||||
"location",
|
||||
"loop",
|
||||
"mat2x2",
|
||||
"mat2x3",
|
||||
"mat2x4",
|
||||
"mat3x2",
|
||||
"mat3x3",
|
||||
"mat3x4",
|
||||
"mat4x2",
|
||||
"mat4x3",
|
||||
"mat4x4",
|
||||
"offset",
|
||||
"out",
|
||||
"premerge",
|
||||
"private",
|
||||
"ptr",
|
||||
"regardless",
|
||||
"return",
|
||||
"set",
|
||||
"storage_buffer",
|
||||
"struct",
|
||||
"switch",
|
||||
"true",
|
||||
"type",
|
||||
"typedef",
|
||||
"u16",
|
||||
"u32",
|
||||
"u64",
|
||||
"u8",
|
||||
"uniform",
|
||||
"uniform_constant",
|
||||
"unless",
|
||||
"using",
|
||||
"var",
|
||||
"vec2",
|
||||
"vec3",
|
||||
"vec4",
|
||||
"vertex",
|
||||
"void",
|
||||
"while",
|
||||
"array", "as", "asm",
|
||||
"bf16", "binding", "block",
|
||||
"bool", "break", "builtin",
|
||||
"case", "cast", "compute",
|
||||
"const", "constant_id", "continue",
|
||||
"default", "discard", "do",
|
||||
"else", "elseif", "entry_point",
|
||||
"enum", "f16", "f32",
|
||||
"fallthrough", "false", "fn",
|
||||
"for", "fragment", "i16",
|
||||
"i32", "i64", "i8",
|
||||
"if", "image", "import",
|
||||
"in", "let", "location",
|
||||
"loop", "mat2x2", "mat2x3",
|
||||
"mat2x4", "mat3x2", "mat3x3",
|
||||
"mat3x4", "mat4x2", "mat4x3",
|
||||
"mat4x4", "offset", "out",
|
||||
"premerge", "private", "ptr",
|
||||
"regardless", "return", "set",
|
||||
"storage", "struct", "switch",
|
||||
"true", "type", "typedef",
|
||||
"u16", "u32", "u64",
|
||||
"u8", "uniform", "uniform_constant",
|
||||
"unless", "using", "var",
|
||||
"vec2", "vec3", "vec4",
|
||||
"vertex", "void", "while",
|
||||
"workgroup",
|
||||
};
|
||||
|
||||
|
|
|
@ -324,84 +324,32 @@ INSTANTIATE_TEST_SUITE_P(SpvParserTest_ReservedWords,
|
|||
SpvNamerReservedWordTest,
|
||||
::testing::ValuesIn(std::vector<std::string>{
|
||||
// Please keep this list sorted.
|
||||
"array",
|
||||
"as",
|
||||
"asm",
|
||||
"bf16",
|
||||
"binding",
|
||||
"block",
|
||||
"bool",
|
||||
"break",
|
||||
"builtin",
|
||||
"case",
|
||||
"cast",
|
||||
"compute",
|
||||
"const",
|
||||
"constant_id",
|
||||
"continue",
|
||||
"default",
|
||||
"discard",
|
||||
"do",
|
||||
"else",
|
||||
"elseif",
|
||||
"entry_point",
|
||||
"enum",
|
||||
"f16",
|
||||
"f32",
|
||||
"fallthrough",
|
||||
"false",
|
||||
"fn",
|
||||
"for",
|
||||
"fragment",
|
||||
"i16",
|
||||
"i32",
|
||||
"i64",
|
||||
"i8",
|
||||
"if",
|
||||
"image",
|
||||
"import",
|
||||
"in",
|
||||
"let",
|
||||
"location",
|
||||
"loop",
|
||||
"mat2x2",
|
||||
"mat2x3",
|
||||
"mat2x4",
|
||||
"mat3x2",
|
||||
"mat3x3",
|
||||
"mat3x4",
|
||||
"mat4x2",
|
||||
"mat4x3",
|
||||
"mat4x4",
|
||||
"offset",
|
||||
"out",
|
||||
"premerge",
|
||||
"private",
|
||||
"ptr",
|
||||
"regardless",
|
||||
"return",
|
||||
"set",
|
||||
"storage_buffer",
|
||||
"struct",
|
||||
"switch",
|
||||
"true",
|
||||
"type",
|
||||
"typedef",
|
||||
"u16",
|
||||
"u32",
|
||||
"u64",
|
||||
"u8",
|
||||
"uniform",
|
||||
"uniform_constant",
|
||||
"unless",
|
||||
"using",
|
||||
"var",
|
||||
"vec2",
|
||||
"vec3",
|
||||
"vec4",
|
||||
"vertex",
|
||||
"void",
|
||||
"while",
|
||||
"array", "as", "asm",
|
||||
"bf16", "binding", "block",
|
||||
"bool", "break", "builtin",
|
||||
"case", "cast", "compute",
|
||||
"const", "constant_id", "continue",
|
||||
"default", "discard", "do",
|
||||
"else", "elseif", "entry_point",
|
||||
"enum", "f16", "f32",
|
||||
"fallthrough", "false", "fn",
|
||||
"for", "fragment", "i16",
|
||||
"i32", "i64", "i8",
|
||||
"if", "image", "import",
|
||||
"in", "let", "location",
|
||||
"loop", "mat2x2", "mat2x3",
|
||||
"mat2x4", "mat3x2", "mat3x3",
|
||||
"mat3x4", "mat4x2", "mat4x3",
|
||||
"mat4x4", "offset", "out",
|
||||
"premerge", "private", "ptr",
|
||||
"regardless", "return", "set",
|
||||
"storage", "struct", "switch",
|
||||
"true", "type", "typedef",
|
||||
"u16", "u32", "u64",
|
||||
"u8", "uniform", "uniform_constant",
|
||||
"unless", "using", "var",
|
||||
"vec2", "vec3", "vec4",
|
||||
"vertex", "void", "while",
|
||||
"workgroup",
|
||||
}));
|
||||
|
||||
|
|
|
@ -1002,7 +1002,7 @@ ast::type::Type* ParserImpl::ConvertType(
|
|||
}
|
||||
if (ast_storage_class == ast::StorageClass::kUniform &&
|
||||
remap_buffer_block_type_.count(pointee_type_id)) {
|
||||
ast_storage_class = ast::StorageClass::kStorageBuffer;
|
||||
ast_storage_class = ast::StorageClass::kStorage;
|
||||
remap_buffer_block_type_.insert(type_id);
|
||||
}
|
||||
return ast_module_.create<ast::type::Pointer>(ast_elem_ty, ast_storage_class);
|
||||
|
@ -1163,7 +1163,7 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
|||
case ast::StorageClass::kOutput:
|
||||
case ast::StorageClass::kUniform:
|
||||
case ast::StorageClass::kUniformConstant:
|
||||
case ast::StorageClass::kStorageBuffer:
|
||||
case ast::StorageClass::kStorage:
|
||||
case ast::StorageClass::kImage:
|
||||
case ast::StorageClass::kWorkgroup:
|
||||
case ast::StorageClass::kPrivate:
|
||||
|
@ -1246,7 +1246,7 @@ ast::Variable* ParserImpl::MakeVariable(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (sc == ast::StorageClass::kStorageBuffer) {
|
||||
if (sc == ast::StorageClass::kStorage) {
|
||||
// Apply the access(read) or access(read_write) modifier.
|
||||
auto access = read_only_struct_types_.count(type)
|
||||
? ast::AccessControl::kReadOnly
|
||||
|
|
|
@ -742,7 +742,7 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
|
|||
auto* ptr_ty = type->As<ast::type::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorageBuffer);
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorage);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
|
|
|
@ -1590,7 +1590,7 @@ TEST_F(SpvModuleScopeVarParserTest, DescriptorGroupDecoration_Valid) {
|
|||
GroupDecoration{3}
|
||||
}
|
||||
myvar
|
||||
storage_buffer
|
||||
storage
|
||||
__access_control_read_write__struct_S
|
||||
})"))
|
||||
<< module_str;
|
||||
|
@ -1645,7 +1645,7 @@ TEST_F(SpvModuleScopeVarParserTest, BindingDecoration_Valid) {
|
|||
BindingDecoration{3}
|
||||
}
|
||||
myvar
|
||||
storage_buffer
|
||||
storage
|
||||
__access_control_read_write__struct_S
|
||||
})"))
|
||||
<< module_str;
|
||||
|
@ -1703,7 +1703,7 @@ TEST_F(SpvModuleScopeVarParserTest,
|
|||
}
|
||||
Variable{
|
||||
myvar
|
||||
storage_buffer
|
||||
storage
|
||||
__access_control_read_write__struct_S
|
||||
}
|
||||
)")) << module_str;
|
||||
|
@ -1733,7 +1733,7 @@ TEST_F(SpvModuleScopeVarParserTest, ColMajorDecoration_Dropped) {
|
|||
}
|
||||
Variable{
|
||||
myvar
|
||||
storage_buffer
|
||||
storage
|
||||
__access_control_read_write__struct_S
|
||||
}
|
||||
})")) << module_str;
|
||||
|
@ -1763,7 +1763,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixStrideDecoration_Dropped) {
|
|||
}
|
||||
Variable{
|
||||
myvar
|
||||
storage_buffer
|
||||
storage
|
||||
__access_control_read_write__struct_S
|
||||
}
|
||||
})")) << module_str;
|
||||
|
@ -1814,7 +1814,7 @@ TEST_F(SpvModuleScopeVarParserTest, StorageBuffer_NonWritable_AllMembers) {
|
|||
}
|
||||
Variable{
|
||||
myvar
|
||||
storage_buffer
|
||||
storage
|
||||
__access_control_read_only__struct_S
|
||||
}
|
||||
})")) << module_str;
|
||||
|
@ -1844,7 +1844,7 @@ TEST_F(SpvModuleScopeVarParserTest, StorageBuffer_NonWritable_NotAllMembers) {
|
|||
}
|
||||
Variable{
|
||||
myvar
|
||||
storage_buffer
|
||||
storage
|
||||
__access_control_read_write__struct_S
|
||||
}
|
||||
})")) << module_str;
|
||||
|
@ -1877,7 +1877,7 @@ TEST_F(
|
|||
}
|
||||
Variable{
|
||||
myvar
|
||||
storage_buffer
|
||||
storage
|
||||
__access_control_read_write__struct_S
|
||||
}
|
||||
})")) << module_str;
|
||||
|
|
|
@ -640,8 +640,8 @@ Token Lexer::check_keyword(const Source& source, const std::string& str) {
|
|||
return {Token::Type::kSampler, source, "sampler"};
|
||||
if (str == "sampler_comparison")
|
||||
return {Token::Type::kComparisonSampler, source, "sampler_comparison"};
|
||||
if (str == "storage_buffer")
|
||||
return {Token::Type::kStorageBuffer, source, "storage_buffer"};
|
||||
if (str == "storage_buffer" || str == "storage")
|
||||
return {Token::Type::kStorage, source, "storage"};
|
||||
if (str == "struct")
|
||||
return {Token::Type::kStruct, source, "struct"};
|
||||
if (str == "switch")
|
||||
|
@ -821,6 +821,8 @@ Token Lexer::check_reserved(const Source& source, const std::string& str) {
|
|||
return {Token::Type::kReservedKeyword, source, "f16"};
|
||||
if (str == "f64")
|
||||
return {Token::Type::kReservedKeyword, source, "f64"};
|
||||
if (str == "handle")
|
||||
return {Token::Type::kReservedKeyword, source, "handle"};
|
||||
if (str == "i8")
|
||||
return {Token::Type::kReservedKeyword, source, "i8"};
|
||||
if (str == "i16")
|
||||
|
|
|
@ -540,7 +540,8 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
TokenData{"return", Token::Type::kReturn},
|
||||
TokenData{"sampler", Token::Type::kSampler},
|
||||
TokenData{"sampler_comparison", Token::Type::kComparisonSampler},
|
||||
TokenData{"storage_buffer", Token::Type::kStorageBuffer},
|
||||
TokenData{"storage", Token::Type::kStorage},
|
||||
TokenData{"storage_buffer", Token::Type::kStorage},
|
||||
TokenData{"struct", Token::Type::kStruct},
|
||||
TokenData{"switch", Token::Type::kSwitch},
|
||||
TokenData{"texture_1d", Token::Type::kTextureSampled1d},
|
||||
|
@ -638,6 +639,7 @@ INSTANTIATE_TEST_SUITE_P(LexerTest,
|
|||
"enum",
|
||||
"f16",
|
||||
"f64",
|
||||
"handle",
|
||||
"i8",
|
||||
"i16",
|
||||
"i64",
|
||||
|
|
|
@ -1177,7 +1177,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
|||
// | UNIFORM
|
||||
// | WORKGROUP
|
||||
// | UNIFORM_CONSTANT
|
||||
// | STORAGE_BUFFER
|
||||
// | STORAGE
|
||||
// | IMAGE
|
||||
// | PRIVATE
|
||||
// | FUNCTION
|
||||
|
@ -1198,8 +1198,8 @@ Expect<ast::StorageClass> ParserImpl::expect_storage_class(
|
|||
if (match(Token::Type::kUniformConstant))
|
||||
return ast::StorageClass::kUniformConstant;
|
||||
|
||||
if (match(Token::Type::kStorageBuffer))
|
||||
return ast::StorageClass::kStorageBuffer;
|
||||
if (match(Token::Type::kStorage))
|
||||
return ast::StorageClass::kStorage;
|
||||
|
||||
if (match(Token::Type::kImage))
|
||||
return ast::StorageClass::kImage;
|
||||
|
|
|
@ -55,7 +55,8 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
StorageClassData{"workgroup", ast::StorageClass::kWorkgroup},
|
||||
StorageClassData{"uniform_constant",
|
||||
ast::StorageClass::kUniformConstant},
|
||||
StorageClassData{"storage_buffer", ast::StorageClass::kStorageBuffer},
|
||||
StorageClassData{"storage", ast::StorageClass::kStorage},
|
||||
StorageClassData{"storage_buffer", ast::StorageClass::kStorage},
|
||||
StorageClassData{"image", ast::StorageClass::kImage},
|
||||
StorageClassData{"private", ast::StorageClass::kPrivate},
|
||||
StorageClassData{"function", ast::StorageClass::kFunction}));
|
||||
|
|
|
@ -57,8 +57,8 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
VariableStorageData{"workgroup", ast::StorageClass::kWorkgroup},
|
||||
VariableStorageData{"uniform_constant",
|
||||
ast::StorageClass::kUniformConstant},
|
||||
VariableStorageData{"storage_buffer",
|
||||
ast::StorageClass::kStorageBuffer},
|
||||
VariableStorageData{"storage", ast::StorageClass::kStorage},
|
||||
VariableStorageData{"storage_buffer", ast::StorageClass::kStorage},
|
||||
VariableStorageData{"image", ast::StorageClass::kImage},
|
||||
VariableStorageData{"private", ast::StorageClass::kPrivate},
|
||||
VariableStorageData{"function", ast::StorageClass::kFunction}));
|
||||
|
|
|
@ -251,8 +251,8 @@ std::string Token::TypeToName(Type type) {
|
|||
return "sampler";
|
||||
case Token::Type::kComparisonSampler:
|
||||
return "sampler_comparison";
|
||||
case Token::Type::kStorageBuffer:
|
||||
return "storage_buffer";
|
||||
case Token::Type::kStorage:
|
||||
return "storage";
|
||||
case Token::Type::kStruct:
|
||||
return "struct";
|
||||
case Token::Type::kSwitch:
|
||||
|
|
|
@ -262,8 +262,8 @@ class Token {
|
|||
kSampler,
|
||||
/// A 'sampler_comparison'
|
||||
kComparisonSampler,
|
||||
/// A 'storage_buffer'
|
||||
kStorageBuffer,
|
||||
/// A 'storage'
|
||||
kStorage,
|
||||
/// A 'struct'
|
||||
kStruct,
|
||||
/// A 'switch'
|
||||
|
@ -629,8 +629,8 @@ class Token {
|
|||
bool IsReturn() const { return type_ == Type::kReturn; }
|
||||
/// @returns true if token is a 'sampler'
|
||||
bool IsSampler() const { return type_ == Type::kSampler; }
|
||||
/// @returns true if token is a 'storage_buffer'
|
||||
bool IsStorageBuffer() const { return type_ == Type::kStorageBuffer; }
|
||||
/// @returns true if token is a 'storage'
|
||||
bool IsStorage() const { return type_ == Type::kStorage; }
|
||||
/// @returns true if token is a 'struct'
|
||||
bool IsStruct() const { return type_ == Type::kStruct; }
|
||||
/// @returns true if token is a 'switch'
|
||||
|
|
|
@ -290,7 +290,7 @@ void VertexPulling::State::AddVertexStorageBuffers() {
|
|||
auto* var = out->create<ast::Variable>(
|
||||
Source{}, // source
|
||||
out->RegisterSymbol(name), // symbol
|
||||
ast::StorageClass::kStorageBuffer, // storage_class
|
||||
ast::StorageClass::kStorage, // storage_class
|
||||
struct_type, // type
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
|
|
|
@ -134,7 +134,7 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_index)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
|
@ -173,7 +173,7 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(instance_index)]] var<in> _tint_pulling_instance_index : i32;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
|
@ -212,7 +212,7 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_index)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), group(5)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(0), group(5)]] var<storage> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
|
@ -255,8 +255,8 @@ struct TintVertexData {
|
|||
_tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
};
|
||||
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(1), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(1), group(4)]] var<storage> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
var<private> var_b : f32;
|
||||
[[builtin(vertex_index)]] var<in> custom_vertex_index : i32;
|
||||
|
@ -302,7 +302,7 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_index)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
var<private> var_a : f32;
|
||||
var<private> var_b : array<f32, 4>;
|
||||
|
||||
|
@ -348,9 +348,9 @@ struct TintVertexData {
|
|||
};
|
||||
|
||||
[[builtin(vertex_index)]] var<in> _tint_pulling_vertex_index : i32;
|
||||
[[binding(0), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(1), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
[[binding(2), group(4)]] var<storage_buffer> _tint_pulling_vertex_buffer_2 : TintVertexData;
|
||||
[[binding(0), group(4)]] var<storage> _tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
[[binding(1), group(4)]] var<storage> _tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
[[binding(2), group(4)]] var<storage> _tint_pulling_vertex_buffer_2 : TintVertexData;
|
||||
var<private> var_a : array<f32, 2>;
|
||||
var<private> var_b : array<f32, 3>;
|
||||
var<private> var_c : array<f32, 4>;
|
||||
|
|
|
@ -650,7 +650,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) {
|
|||
TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) {
|
||||
auto* in_var = Var("in_var", ast::StorageClass::kInput, ty.f32);
|
||||
auto* out_var = Var("out_var", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* sb_var = Var("sb_var", ast::StorageClass::kStorageBuffer, ty.f32);
|
||||
auto* sb_var = Var("sb_var", ast::StorageClass::kStorage, ty.f32);
|
||||
auto* wg_var = Var("wg_var", ast::StorageClass::kWorkgroup, ty.f32);
|
||||
auto* priv_var = Var("priv_var", ast::StorageClass::kPrivate, ty.f32);
|
||||
|
||||
|
@ -687,7 +687,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) {
|
|||
TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
|
||||
auto* in_var = Var("in_var", ast::StorageClass::kInput, ty.f32);
|
||||
auto* out_var = Var("out_var", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* sb_var = Var("sb_var", ast::StorageClass::kStorageBuffer, ty.f32);
|
||||
auto* sb_var = Var("sb_var", ast::StorageClass::kStorage, ty.f32);
|
||||
auto* wg_var = Var("wg_var", ast::StorageClass::kWorkgroup, ty.f32);
|
||||
auto* priv_var = Var("priv_var", ast::StorageClass::kPrivate, ty.f32);
|
||||
|
||||
|
|
|
@ -2067,7 +2067,7 @@ bool GeneratorImpl::is_storage_buffer_access(
|
|||
if (!global_variables_.get(ident->symbol(), &var)) {
|
||||
return false;
|
||||
}
|
||||
return var->storage_class() == ast::StorageClass::kStorageBuffer;
|
||||
return var->storage_class() == ast::StorageClass::kStorage;
|
||||
} else if (auto* member = structure->As<ast::MemberAccessorExpression>()) {
|
||||
return is_storage_buffer_access(member);
|
||||
} else if (auto* array = structure->As<ast::ArrayAccessorExpression>()) {
|
||||
|
|
|
@ -382,8 +382,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
auto* s = ty.struct_("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||
|
||||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(1),
|
||||
|
@ -429,8 +428,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
auto* s = ty.struct_("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, s);
|
||||
|
||||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
create<ast::BindingDecoration>(0),
|
||||
|
@ -477,8 +475,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
auto* s = ty.struct_("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||
|
||||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(1),
|
||||
|
@ -777,8 +774,7 @@ void frag_main() {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_Called_By_EntryPoint_With_StorageBuffer) {
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, ty.vec4<f32>());
|
||||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(1),
|
||||
|
@ -969,7 +965,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
// [[block]] struct Data {
|
||||
// [[offset(0)]] d : f32;
|
||||
// };
|
||||
// [[binding(0), group(0)]] var<storage_buffer> data : Data;
|
||||
// [[binding(0), group(0)]] var<storage> data : Data;
|
||||
//
|
||||
// [[stage(compute)]]
|
||||
// fn a() -> void {
|
||||
|
@ -988,7 +984,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
auto* s = ty.struct_("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||
|
||||
auto* data_var = Var("data", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
auto* data_var = Var("data", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(0),
|
||||
|
|
|
@ -63,7 +63,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] a : i32;
|
||||
// [[offset(4)]] b : f32;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.b;
|
||||
//
|
||||
// -> asfloat(data.Load(4));
|
||||
|
@ -74,7 +74,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
auto* expr = MemberAccessor("data", "b");
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -94,7 +94,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] a : i32;
|
||||
// [[offset(4)]] b : f32;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.a;
|
||||
//
|
||||
// -> asint(data.Load(0));
|
||||
|
@ -104,7 +104,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
auto* expr = MemberAccessor("data", "a");
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -123,7 +123,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] z : f32;
|
||||
// [[offset(4)]] a : mat2x3<f32>;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// mat2x3<f32> b;
|
||||
// data.a = b;
|
||||
//
|
||||
|
@ -138,7 +138,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* b_var = Var("b", ast::StorageClass::kPrivate, ty.mat2x3<f32>());
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
|
||||
auto* lhs = MemberAccessor("data", "a");
|
||||
auto* rhs = Expr("b");
|
||||
|
@ -168,7 +168,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] z : f32;
|
||||
// [[offset(4)]] a : mat2x3<f32>;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.a = mat2x3<f32>();
|
||||
//
|
||||
// -> float3x2 _tint_tmp = float3x2(0.0f, 0.0f, 0.0f,
|
||||
|
@ -182,7 +182,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
|
||||
auto* lhs = MemberAccessor("data", "a");
|
||||
auto* rhs = Construct(ty.mat2x3<f32>(), ast::ExpressionList{});
|
||||
|
@ -211,7 +211,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] z : f32;
|
||||
// [[offset(4)]] a : mat3x2<f32>;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.a;
|
||||
//
|
||||
// -> asfloat(uint2x3(data.Load2(4 + 0), data.Load2(4 + 8),
|
||||
|
@ -223,7 +223,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
|
||||
auto* expr = MemberAccessor("data", "a");
|
||||
|
||||
|
@ -250,7 +250,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] c : f32;
|
||||
// [[offset(4)]] b : Data;
|
||||
// };
|
||||
// var<storage_buffer> data : Outer;
|
||||
// var<storage> data : Outer;
|
||||
// data.b.a;
|
||||
//
|
||||
// -> asfloat(uint3x2(data.Load3(4 + 0), data.Load3(4 + 16)));
|
||||
|
@ -263,7 +263,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
auto* expr = MemberAccessor("data", "a");
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -284,7 +284,7 @@ TEST_F(
|
|||
// struct Data {
|
||||
// [[offset(4)]] a : mat3x3<f32;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.a;
|
||||
//
|
||||
// -> asfloat(uint3x3(data.Load3(0), data.Load3(16),
|
||||
|
@ -295,7 +295,7 @@ TEST_F(
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
auto* expr = MemberAccessor("data", "a");
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -317,7 +317,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] z : f32;
|
||||
// [[offset(16)]] a : mat4x3<f32>;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.a[2][1];
|
||||
//
|
||||
// -> asfloat(data.Load((2 * 16) + (1 * 4) + 16)))
|
||||
|
@ -328,7 +328,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
auto* expr = IndexAccessor(
|
||||
IndexAccessor(MemberAccessor("data", "a"), Expr(2)), Expr(1));
|
||||
|
||||
|
@ -348,7 +348,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// struct Data {
|
||||
// [[offset(0)]] a : [[stride(4)]] array<i32, 5>;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.a[2];
|
||||
//
|
||||
// -> asint(data.Load((2 * 4));
|
||||
|
@ -361,7 +361,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructMemberList{Member("a", &ary, {MemberOffset(0)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
auto* expr = IndexAccessor(MemberAccessor("data", "a"), Expr(2));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
|
@ -380,7 +380,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// struct Data {
|
||||
// [[offset(0)]] a : [[stride(4)]] array<i32, 5>;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.a[(2 + 4) - 3];
|
||||
//
|
||||
// -> asint(data.Load((4 * ((2 + 4) - 3)));
|
||||
|
@ -393,7 +393,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructMemberList{Member("a", &ary, {MemberOffset(0)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
auto* expr = IndexAccessor(MemberAccessor("data", "a"),
|
||||
Sub(Add(Expr(2), Expr(4)), Expr(3)));
|
||||
|
||||
|
@ -414,7 +414,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] a : i32;
|
||||
// [[offset(4)]] b : f32;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.b = 2.3f;
|
||||
//
|
||||
// -> data.Store(0, asuint(2.0f));
|
||||
|
@ -425,7 +425,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -448,7 +448,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// struct Data {
|
||||
// [[offset(0)]] a : [[stride(4)]] array<i32, 5>;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.a[2] = 2;
|
||||
//
|
||||
// -> data.Store((2 * 4), asuint(2.3f));
|
||||
|
@ -463,7 +463,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -487,7 +487,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] a : i32;
|
||||
// [[offset(4)]] b : f32;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.a = 2;
|
||||
//
|
||||
// -> data.Store(0, asuint(2));
|
||||
|
@ -498,7 +498,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -522,7 +522,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] a : vec3<i32>;
|
||||
// [[offset(16)]] b : vec3<f32>;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.b;
|
||||
//
|
||||
// -> asfloat(data.Load(16));
|
||||
|
@ -533,7 +533,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -554,7 +554,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// [[offset(0)]] a : vec3<i32>;
|
||||
// [[offset(16)]] b : vec3<f32>;
|
||||
// };
|
||||
// var<storage_buffer> data : Data;
|
||||
// var<storage> data : Data;
|
||||
// data.b = vec3<f32>(2.3f, 1.2f, 0.2f);
|
||||
//
|
||||
// -> data.Store(16, asuint(float3(2.3f, 1.2f, 0.2f)));
|
||||
|
@ -565,7 +565,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, s);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -595,7 +595,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// var c : [[stride(32)]] array<Data, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage_buffer> data : Pre;
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b
|
||||
//
|
||||
// -> asfloat(data.Load3(16 + (2 * 32)))
|
||||
|
@ -618,7 +618,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* pre_struct = ty.struct_("Pre", pre_str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, pre_struct);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -644,7 +644,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// var c : [[stride(32)]] array<Data, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage_buffer> data : Pre;
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b.xy
|
||||
//
|
||||
// -> asfloat(data.Load3(16 + (2 * 32))).xy
|
||||
|
@ -665,7 +665,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* pre_struct = ty.struct_("Pre", pre_str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, pre_struct);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -693,7 +693,7 @@ TEST_F(
|
|||
// var c : [[stride(32)]] array<Data, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage_buffer> data : Pre;
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b.g
|
||||
//
|
||||
// -> asfloat(data.Load((4 * 1) + 16 + (2 * 32) + 0))
|
||||
|
@ -716,7 +716,7 @@ TEST_F(
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* pre_struct = ty.struct_("Pre", pre_str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, pre_struct);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -743,7 +743,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// var c : [[stride(32)]] array<Data, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage_buffer> data : Pre;
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b[1]
|
||||
//
|
||||
// -> asfloat(data.Load(4 + 16 + (2 * 32)))
|
||||
|
@ -766,7 +766,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* pre_struct = ty.struct_("Pre", pre_str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, pre_struct);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -793,7 +793,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// var c : [[stride(32)]] array<Data, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage_buffer> data : Pre;
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b = vec3<f32>(1.f, 2.f, 3.f);
|
||||
//
|
||||
// -> data.Store3(16 + (2 * 32), asuint(float3(1.0f, 2.0f, 3.0f)));
|
||||
|
@ -816,7 +816,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* pre_struct = ty.struct_("Pre", pre_str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, pre_struct);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -847,7 +847,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// var c : [[stride(32)]] array<Data, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage_buffer> data : Pre;
|
||||
// var<storage> data : Pre;
|
||||
// data.c[2].b.y = 1.f;
|
||||
//
|
||||
// -> data.Store((4 * 1) + 16 + (2 * 32) + 0, asuint(1.0f));
|
||||
|
@ -870,7 +870,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::StructDecorationList{});
|
||||
|
||||
auto* pre_struct = ty.struct_("Pre", pre_str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorageBuffer, pre_struct);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct);
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
|
|
@ -334,7 +334,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod->AddConstructedType(s);
|
||||
|
||||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
|
@ -386,7 +386,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod->AddConstructedType(s);
|
||||
|
||||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
|
@ -691,7 +691,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod->AddConstructedType(s);
|
||||
|
||||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
|
@ -758,7 +758,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod->AddConstructedType(s);
|
||||
|
||||
auto* coord_var =
|
||||
Var("coord", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(1)});
|
||||
|
||||
|
@ -914,7 +914,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
// [[block]] struct Data {
|
||||
// [[offset(0)]] d : f32;
|
||||
// };
|
||||
// [[binding(0), group(0)]] var<storage_buffer> data : Data;
|
||||
// [[binding(0), group(0)]] var<storage> data : Data;
|
||||
//
|
||||
// [[stage(compute)]]
|
||||
// fn a() -> void {
|
||||
|
@ -936,7 +936,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||
|
||||
auto* data_var =
|
||||
Var("data", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
Var("data", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(0)});
|
||||
|
||||
|
|
|
@ -3114,7 +3114,7 @@ SpvStorageClass Builder::ConvertStorageClass(ast::StorageClass klass) const {
|
|||
return SpvStorageClassWorkgroup;
|
||||
case ast::StorageClass::kUniformConstant:
|
||||
return SpvStorageClassUniformConstant;
|
||||
case ast::StorageClass::kStorageBuffer:
|
||||
case ast::StorageClass::kStorage:
|
||||
return SpvStorageClassStorageBuffer;
|
||||
case ast::StorageClass::kImage:
|
||||
return SpvStorageClassImage;
|
||||
|
|
|
@ -198,7 +198,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
// [[block]] struct Data {
|
||||
// [[offset(0)]] d : f32;
|
||||
// };
|
||||
// [[binding(0), group(0)]] var<storage_buffer> data : Data;
|
||||
// [[binding(0), group(0)]] var<storage> data : Data;
|
||||
//
|
||||
// [[stage(compute)]]
|
||||
// fn a() -> void {
|
||||
|
@ -219,7 +219,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
auto* s = ty.struct_("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||
|
||||
auto* data_var = Var("data", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
auto* data_var = Var("data", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
create<ast::GroupDecoration>(0),
|
||||
|
|
|
@ -386,7 +386,7 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) {
|
|||
ast::StructDecorationList{}));
|
||||
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, A};
|
||||
|
||||
auto* var = Var("b", ast::StorageClass::kStorageBuffer, &ac);
|
||||
auto* var = Var("b", ast::StorageClass::kStorage, &ac);
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
|
||||
|
||||
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
|
||||
|
@ -416,7 +416,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) {
|
|||
ast::StructDecorationList{}));
|
||||
auto* B = ty.alias("B", A);
|
||||
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, B};
|
||||
auto* var = Var("b", ast::StorageClass::kStorageBuffer, &ac);
|
||||
auto* var = Var("b", ast::StorageClass::kStorage, &ac);
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
|
||||
|
||||
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
|
||||
|
@ -444,7 +444,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) {
|
|||
ast::StructDecorationList{}));
|
||||
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, A};
|
||||
auto* B = ty.alias("B", &ac);
|
||||
auto* var = Var("b", ast::StorageClass::kStorageBuffer, B);
|
||||
auto* var = Var("b", ast::StorageClass::kStorage, B);
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
|
||||
|
||||
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
|
||||
|
@ -473,8 +473,8 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) {
|
|||
ast::type::AccessControl read{ast::AccessControl::kReadOnly, A};
|
||||
ast::type::AccessControl rw{ast::AccessControl::kReadWrite, A};
|
||||
|
||||
auto* var_b = Var("b", ast::StorageClass::kStorageBuffer, &read);
|
||||
auto* var_c = Var("c", ast::StorageClass::kStorageBuffer, &rw);
|
||||
auto* var_b = Var("b", ast::StorageClass::kStorage, &read);
|
||||
auto* var_c = Var("c", ast::StorageClass::kStorage, &rw);
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(var_b)) << b.error();
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(var_c)) << b.error();
|
||||
|
||||
|
|
|
@ -527,8 +527,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
PtrData{ast::StorageClass::kWorkgroup, SpvStorageClassWorkgroup},
|
||||
PtrData{ast::StorageClass::kUniformConstant,
|
||||
SpvStorageClassUniformConstant},
|
||||
PtrData{ast::StorageClass::kStorageBuffer,
|
||||
SpvStorageClassStorageBuffer},
|
||||
PtrData{ast::StorageClass::kStorage, SpvStorageClassStorageBuffer},
|
||||
PtrData{ast::StorageClass::kImage, SpvStorageClassImage},
|
||||
PtrData{ast::StorageClass::kPrivate, SpvStorageClassPrivate},
|
||||
PtrData{ast::StorageClass::kFunction, SpvStorageClassFunction}));
|
||||
|
|
|
@ -153,7 +153,7 @@ TEST_F(WgslGeneratorImplTest,
|
|||
// [[block]] struct Data {
|
||||
// [[offset(0)]] d : f32;
|
||||
// };
|
||||
// [[binding(0), group(0)]] var<storage_buffer> data : Data;
|
||||
// [[binding(0), group(0)]] var<storage> data : Data;
|
||||
//
|
||||
// [[stage(compute)]]
|
||||
// fn a() -> void {
|
||||
|
@ -174,7 +174,7 @@ TEST_F(WgslGeneratorImplTest,
|
|||
auto* s = ty.struct_("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||
|
||||
auto* data_var = Var("data", ast::StorageClass::kStorageBuffer, &ac, nullptr,
|
||||
auto* data_var = Var("data", ast::StorageClass::kStorage, &ac, nullptr,
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
create<ast::BindingDecoration>(0),
|
||||
|
@ -233,7 +233,7 @@ struct Data {
|
|||
d : f32;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<storage_buffer> data : [[access(read_write)]]
|
||||
[[binding(0), group(0)]] var<storage> data : [[access(read_write)]]
|
||||
Data;
|
||||
|
||||
[[stage(compute)]]
|
||||
|
|
|
@ -57,8 +57,8 @@ fn frag_main() -> void {
|
|||
};
|
||||
|
||||
[[binding(0), group(0)]] var<uniform> params : [[access(read)]] SimParams;
|
||||
[[binding(1), group(0)]] var<storage_buffer> particlesA : [[access(read_write)]] Particles;
|
||||
[[binding(2), group(0)]] var<storage_buffer> particlesB : [[access(read_write)]] Particles;
|
||||
[[binding(1), group(0)]] var<storage> particlesA : [[access(read_write)]] Particles;
|
||||
[[binding(2), group(0)]] var<storage> particlesB : [[access(read_write)]] Particles;
|
||||
|
||||
[[builtin(global_invocation_id)]] var<in> gl_GlobalInvocationID : vec3<u32>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue