mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
ProgramBuilder: Swap parameter order for Var and Const
Move the storage parameter after type. Const() has no use for storage classes, so this parameter will be removed in the next change. This reordering keeps Var() and Const() parameter types identical for the first two non-optional fields Change-Id: I66669d19fa2175c4f10f615941e69efcab4c23e1 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41540 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
4b9e7f92b9
commit
37571bc32d
@@ -31,7 +31,7 @@ using FunctionTest = TestHelper;
|
||||
|
||||
TEST_F(FunctionTest, Creation) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
auto* var = params[0];
|
||||
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{},
|
||||
@@ -44,7 +44,7 @@ TEST_F(FunctionTest, Creation) {
|
||||
|
||||
TEST_F(FunctionTest, Creation_WithSource) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
|
||||
auto* f = Func(Source{Source::Location{20, 2}}, "func", params, ty.void_(),
|
||||
StatementList{}, FunctionDecorationList{});
|
||||
@@ -55,7 +55,7 @@ TEST_F(FunctionTest, Creation_WithSource) {
|
||||
|
||||
TEST_F(FunctionTest, IsValid) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
@@ -67,7 +67,7 @@ TEST_F(FunctionTest, IsValid) {
|
||||
|
||||
TEST_F(FunctionTest, IsValid_InvalidName) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
|
||||
auto* f =
|
||||
Func("", params, ty.void_(), StatementList{}, FunctionDecorationList{});
|
||||
@@ -76,7 +76,7 @@ TEST_F(FunctionTest, IsValid_InvalidName) {
|
||||
|
||||
TEST_F(FunctionTest, IsValid_MissingReturnType) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
|
||||
auto* f =
|
||||
Func("func", params, nullptr, StatementList{}, FunctionDecorationList{});
|
||||
@@ -85,7 +85,7 @@ TEST_F(FunctionTest, IsValid_MissingReturnType) {
|
||||
|
||||
TEST_F(FunctionTest, IsValid_NullParam) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
params.push_back(nullptr);
|
||||
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{},
|
||||
@@ -95,7 +95,7 @@ TEST_F(FunctionTest, IsValid_NullParam) {
|
||||
|
||||
TEST_F(FunctionTest, IsValid_InvalidParam) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, nullptr));
|
||||
params.push_back(Var("var", nullptr, StorageClass::kNone));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
@@ -104,7 +104,7 @@ TEST_F(FunctionTest, IsValid_InvalidParam) {
|
||||
|
||||
TEST_F(FunctionTest, IsValid_NullBodyStatement) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
@@ -118,7 +118,7 @@ TEST_F(FunctionTest, IsValid_NullBodyStatement) {
|
||||
|
||||
TEST_F(FunctionTest, IsValid_InvalidBodyStatement) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
@@ -162,7 +162,7 @@ WorkgroupDecoration{2 4 6}
|
||||
|
||||
TEST_F(FunctionTest, ToStr_WithParams) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
@@ -192,8 +192,8 @@ TEST_F(FunctionTest, TypeName) {
|
||||
|
||||
TEST_F(FunctionTest, TypeName_WithParams) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var1", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var2", StorageClass::kNone, ty.f32()));
|
||||
params.push_back(Var("var1", ty.i32(), StorageClass::kNone));
|
||||
params.push_back(Var("var2", ty.f32(), StorageClass::kNone));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
|
||||
@@ -161,27 +161,27 @@ ast::Variable* TextureOverloadCase::buildTextureVariable(
|
||||
switch (texture_kind) {
|
||||
case ast::intrinsic::test::TextureKind::kRegular:
|
||||
return b->Global(
|
||||
"texture", ast::StorageClass::kUniformConstant,
|
||||
b->create<type::SampledTexture>(texture_dimension, datatype), nullptr,
|
||||
decos);
|
||||
"texture",
|
||||
b->create<type::SampledTexture>(texture_dimension, datatype),
|
||||
ast::StorageClass::kUniformConstant, nullptr, decos);
|
||||
|
||||
case ast::intrinsic::test::TextureKind::kDepth:
|
||||
return b->Global("texture", ast::StorageClass::kUniformConstant,
|
||||
return b->Global("texture",
|
||||
b->create<type::DepthTexture>(texture_dimension),
|
||||
nullptr, decos);
|
||||
ast::StorageClass::kUniformConstant, nullptr, decos);
|
||||
|
||||
case ast::intrinsic::test::TextureKind::kMultisampled:
|
||||
return b->Global(
|
||||
"texture", ast::StorageClass::kUniformConstant,
|
||||
"texture",
|
||||
b->create<type::MultisampledTexture>(texture_dimension, datatype),
|
||||
nullptr, decos);
|
||||
ast::StorageClass::kUniformConstant, nullptr, decos);
|
||||
|
||||
case ast::intrinsic::test::TextureKind::kStorage: {
|
||||
auto* st = b->create<type::StorageTexture>(texture_dimension,
|
||||
image_format, datatype);
|
||||
|
||||
auto* ac = b->create<type::AccessControl>(access_control, st);
|
||||
return b->Global("texture", ast::StorageClass::kUniformConstant, ac,
|
||||
return b->Global("texture", ac, ast::StorageClass::kUniformConstant,
|
||||
nullptr, decos);
|
||||
}
|
||||
}
|
||||
@@ -196,8 +196,8 @@ ast::Variable* TextureOverloadCase::buildSamplerVariable(
|
||||
b->create<ast::GroupDecoration>(0),
|
||||
b->create<ast::BindingDecoration>(1),
|
||||
};
|
||||
return b->Global("sampler", ast::StorageClass::kUniformConstant,
|
||||
b->create<type::Sampler>(sampler_kind), nullptr, decos);
|
||||
return b->Global("sampler", b->create<type::Sampler>(sampler_kind),
|
||||
ast::StorageClass::kUniformConstant, nullptr, decos);
|
||||
}
|
||||
|
||||
std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
||||
|
||||
@@ -62,7 +62,7 @@ TEST_F(ModuleTest, IsValid_Empty) {
|
||||
}
|
||||
|
||||
TEST_F(ModuleTest, IsValid_GlobalVariable) {
|
||||
Global("var", StorageClass::kInput, ty.f32());
|
||||
Global("var", ty.f32(), StorageClass::kInput);
|
||||
Program program(std::move(*this));
|
||||
EXPECT_TRUE(program.AST().IsValid());
|
||||
}
|
||||
@@ -74,7 +74,7 @@ TEST_F(ModuleTest, IsValid_Null_GlobalVariable) {
|
||||
}
|
||||
|
||||
TEST_F(ModuleTest, IsValid_Invalid_GlobalVariable) {
|
||||
Global("var", StorageClass::kInput, nullptr);
|
||||
Global("var", nullptr, StorageClass::kInput);
|
||||
Program program(std::move(*this));
|
||||
EXPECT_FALSE(program.AST().IsValid());
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace {
|
||||
using VariableDeclStatementTest = TestHelper;
|
||||
|
||||
TEST_F(VariableDeclStatementTest, Creation) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
auto* var = Var("a", ty.f32(), StorageClass::kNone);
|
||||
|
||||
auto* stmt = create<VariableDeclStatement>(var);
|
||||
EXPECT_EQ(stmt->variable(), var);
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, Creation_WithSource) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
auto* var = Var("a", ty.f32(), StorageClass::kNone);
|
||||
|
||||
auto* stmt =
|
||||
create<VariableDeclStatement>(Source{Source::Location{20, 2}}, var);
|
||||
@@ -42,20 +42,20 @@ TEST_F(VariableDeclStatementTest, Creation_WithSource) {
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, IsVariableDecl) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
auto* var = Var("a", ty.f32(), StorageClass::kNone);
|
||||
|
||||
auto* stmt = create<VariableDeclStatement>(var);
|
||||
EXPECT_TRUE(stmt->Is<VariableDeclStatement>());
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, IsValid) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
auto* var = Var("a", ty.f32(), StorageClass::kNone);
|
||||
auto* stmt = create<VariableDeclStatement>(var);
|
||||
EXPECT_TRUE(stmt->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, IsValid_InvalidVariable) {
|
||||
auto* var = Var("", StorageClass::kNone, ty.f32());
|
||||
auto* var = Var("", ty.f32(), StorageClass::kNone);
|
||||
auto* stmt = create<VariableDeclStatement>(var);
|
||||
EXPECT_FALSE(stmt->IsValid());
|
||||
}
|
||||
@@ -66,7 +66,7 @@ TEST_F(VariableDeclStatementTest, IsValid_NullVariable) {
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, ToStr) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
auto* var = Var("a", ty.f32(), StorageClass::kNone);
|
||||
|
||||
auto* stmt =
|
||||
create<VariableDeclStatement>(Source{Source::Location{20, 2}}, var);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace {
|
||||
using VariableTest = TestHelper;
|
||||
|
||||
TEST_F(VariableTest, Creation) {
|
||||
auto* v = Var("my_var", StorageClass::kFunction, ty.i32());
|
||||
auto* v = Var("my_var", ty.i32(), StorageClass::kFunction);
|
||||
|
||||
EXPECT_EQ(v->symbol(), Symbol(1));
|
||||
EXPECT_EQ(v->declared_storage_class(), StorageClass::kFunction);
|
||||
@@ -41,7 +41,7 @@ TEST_F(VariableTest, Creation) {
|
||||
TEST_F(VariableTest, CreationWithSource) {
|
||||
auto* v = Var(
|
||||
Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}},
|
||||
"i", StorageClass::kPrivate, ty.f32(), nullptr, VariableDecorationList{});
|
||||
"i", ty.f32(), StorageClass::kPrivate, nullptr, VariableDecorationList{});
|
||||
|
||||
EXPECT_EQ(v->symbol(), Symbol(1));
|
||||
EXPECT_EQ(v->declared_storage_class(), StorageClass::kPrivate);
|
||||
@@ -55,7 +55,7 @@ TEST_F(VariableTest, CreationWithSource) {
|
||||
TEST_F(VariableTest, CreationEmpty) {
|
||||
auto* v = Var(
|
||||
Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 7}}},
|
||||
"a_var", StorageClass::kWorkgroup, ty.i32(), nullptr,
|
||||
"a_var", ty.i32(), StorageClass::kWorkgroup, nullptr,
|
||||
VariableDecorationList{});
|
||||
|
||||
EXPECT_EQ(v->symbol(), Symbol(1));
|
||||
@@ -68,39 +68,39 @@ TEST_F(VariableTest, CreationEmpty) {
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid) {
|
||||
auto* v = Var("my_var", StorageClass::kNone, ty.i32());
|
||||
auto* v = Var("my_var", ty.i32(), StorageClass::kNone);
|
||||
EXPECT_TRUE(v->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_WithConstructor) {
|
||||
auto* v = Var("my_var", StorageClass::kNone, ty.i32(), Expr("ident"),
|
||||
auto* v = Var("my_var", ty.i32(), StorageClass::kNone, Expr("ident"),
|
||||
ast::VariableDecorationList{});
|
||||
EXPECT_TRUE(v->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_MissingSymbol) {
|
||||
auto* v = Var("", StorageClass::kNone, ty.i32());
|
||||
auto* v = Var("", ty.i32(), StorageClass::kNone);
|
||||
EXPECT_FALSE(v->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_MissingType) {
|
||||
auto* v = Var("x", StorageClass::kNone, nullptr);
|
||||
auto* v = Var("x", nullptr, StorageClass::kNone);
|
||||
EXPECT_FALSE(v->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_MissingBoth) {
|
||||
auto* v = Var("", StorageClass::kNone, nullptr);
|
||||
auto* v = Var("", nullptr, StorageClass::kNone);
|
||||
EXPECT_FALSE(v->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_InvalidConstructor) {
|
||||
auto* v = Var("my_var", StorageClass::kNone, ty.i32(), Expr(""),
|
||||
auto* v = Var("my_var", ty.i32(), StorageClass::kNone, Expr(""),
|
||||
ast::VariableDecorationList{});
|
||||
EXPECT_FALSE(v->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, to_str) {
|
||||
auto* v = Var("my_var", StorageClass::kFunction, ty.f32(), nullptr,
|
||||
auto* v = Var("my_var", ty.f32(), StorageClass::kFunction, nullptr,
|
||||
ast::VariableDecorationList{});
|
||||
EXPECT_EQ(str(v), R"(Variable{
|
||||
my_var
|
||||
@@ -111,7 +111,7 @@ TEST_F(VariableTest, to_str) {
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, WithDecorations) {
|
||||
auto* var = Var("my_var", StorageClass::kFunction, ty.i32(), nullptr,
|
||||
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
|
||||
VariableDecorationList{
|
||||
create<LocationDecoration>(1),
|
||||
create<BuiltinDecoration>(Builtin::kPosition),
|
||||
@@ -128,7 +128,7 @@ TEST_F(VariableTest, WithDecorations) {
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, ConstantId) {
|
||||
auto* var = Var("my_var", StorageClass::kFunction, ty.i32(), nullptr,
|
||||
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
|
||||
VariableDecorationList{
|
||||
create<ConstantIdDecoration>(1200),
|
||||
});
|
||||
@@ -137,7 +137,7 @@ TEST_F(VariableTest, ConstantId) {
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, Decorated_to_str) {
|
||||
auto* var = Var("my_var", StorageClass::kFunction, ty.f32(), Expr("expr"),
|
||||
auto* var = Var("my_var", ty.f32(), StorageClass::kFunction, Expr("expr"),
|
||||
VariableDecorationList{
|
||||
create<BindingDecoration>(2),
|
||||
create<GroupDecoration>(1),
|
||||
|
||||
Reference in New Issue
Block a user