mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 06:45:16 +00:00
Add ProgramBuilder::Param() helpers and use them
Fix some SPIR-V tests that were wrongly expecting parameters to be loaded from memory as a result of them not being const. Change-Id: Ieab6f1edd4a4ba6efd226fe190e7a49b309048c5 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47281 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: James Price <jrprice@google.com> Auto-Submit: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
a12ccb20a0
commit
daf1f1c0a8
@@ -38,7 +38,7 @@ Function::Function(const Source& source,
|
||||
decorations_(std::move(decorations)),
|
||||
return_type_decorations_(std::move(return_type_decorations)) {
|
||||
for (auto* param : params_) {
|
||||
TINT_ASSERT(param);
|
||||
TINT_ASSERT(param && param->is_const());
|
||||
}
|
||||
TINT_ASSERT(symbol_.IsValid());
|
||||
TINT_ASSERT(return_type_);
|
||||
|
||||
@@ -26,7 +26,7 @@ using FunctionTest = TestHelper;
|
||||
|
||||
TEST_F(FunctionTest, Creation) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
params.push_back(Param("var", ty.i32()));
|
||||
auto* var = params[0];
|
||||
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{}, DecorationList{});
|
||||
@@ -38,7 +38,7 @@ TEST_F(FunctionTest, Creation) {
|
||||
|
||||
TEST_F(FunctionTest, Creation_WithSource) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
params.push_back(Param("var", ty.i32()));
|
||||
|
||||
auto* f = Func(Source{Source::Location{20, 2}}, "func", params, ty.void_(),
|
||||
StatementList{}, DecorationList{});
|
||||
@@ -71,7 +71,7 @@ TEST_F(FunctionTest, Assert_NullParam) {
|
||||
{
|
||||
ProgramBuilder b;
|
||||
VariableList params;
|
||||
params.push_back(b.Var("var", b.ty.i32(), StorageClass::kNone));
|
||||
params.push_back(b.Param("var", b.ty.i32()));
|
||||
params.push_back(nullptr);
|
||||
|
||||
b.Func("f", params, b.ty.void_(), StatementList{}, DecorationList{});
|
||||
@@ -79,6 +79,18 @@ TEST_F(FunctionTest, Assert_NullParam) {
|
||||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, Assert_NonConstParam) {
|
||||
EXPECT_FATAL_FAILURE(
|
||||
{
|
||||
ProgramBuilder b;
|
||||
VariableList params;
|
||||
params.push_back(b.Var("var", b.ty.i32(), ast::StorageClass::kNone));
|
||||
|
||||
b.Func("f", params, b.ty.void_(), StatementList{}, DecorationList{});
|
||||
},
|
||||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, ToStr) {
|
||||
auto* f = Func("func", VariableList{}, ty.void_(),
|
||||
StatementList{
|
||||
@@ -112,7 +124,7 @@ WorkgroupDecoration{2 4 6}
|
||||
|
||||
TEST_F(FunctionTest, ToStr_WithParams) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", ty.i32(), StorageClass::kNone));
|
||||
params.push_back(Param("var", ty.i32()));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
@@ -122,7 +134,7 @@ TEST_F(FunctionTest, ToStr_WithParams) {
|
||||
|
||||
EXPECT_EQ(str(f), R"(Function func -> __void
|
||||
(
|
||||
Variable{
|
||||
VariableConst{
|
||||
var
|
||||
none
|
||||
__i32
|
||||
@@ -142,8 +154,8 @@ TEST_F(FunctionTest, TypeName) {
|
||||
|
||||
TEST_F(FunctionTest, TypeName_WithParams) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var1", ty.i32(), StorageClass::kNone));
|
||||
params.push_back(Var("var2", ty.f32(), StorageClass::kNone));
|
||||
params.push_back(Param("var1", ty.i32()));
|
||||
params.push_back(Param("var2", ty.f32()));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{}, DecorationList{});
|
||||
EXPECT_EQ(f->type_name(), "__func__void__i32__f32");
|
||||
|
||||
Reference in New Issue
Block a user