diff --git a/src/writer/wgsl/generator_impl_binary_test.cc b/src/writer/wgsl/generator_impl_binary_test.cc index e83bd883ed..7c37d9b99d 100644 --- a/src/writer/wgsl/generator_impl_binary_test.cc +++ b/src/writer/wgsl/generator_impl_binary_test.cc @@ -31,6 +31,17 @@ using WgslBinaryTest = TestParamHelper; TEST_P(WgslBinaryTest, Emit) { auto params = GetParam(); + auto op_ty = [&]() -> ast::Type* { + if (params.op == ast::BinaryOp::kLogicalAnd || + params.op == ast::BinaryOp::kLogicalOr) { + return ty.bool_(); + } else { + return ty.u32(); + } + }; + + Global("left", op_ty(), ast::StorageClass::kPrivate); + Global("right", op_ty(), ast::StorageClass::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); diff --git a/src/writer/wgsl/generator_impl_global_decl_test.cc b/src/writer/wgsl/generator_impl_global_decl_test.cc index a77acee31f..50b8269e5d 100644 --- a/src/writer/wgsl/generator_impl_global_decl_test.cc +++ b/src/writer/wgsl/generator_impl_global_decl_test.cc @@ -101,27 +101,30 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { } TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) { - Global("s", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone); + Global("s", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, + nullptr, + {create(0), create(0)}); GeneratorImpl& gen = Build(); gen.increment_indent(); ASSERT_TRUE(gen.Generate(nullptr)) << gen.error(); - EXPECT_EQ(gen.result(), " var s : sampler;\n"); + EXPECT_EQ(gen.result(), " [[group(0), binding(0)]] var s : sampler;\n"); } TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) { auto st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); Global("t", ty.access(ast::AccessControl::kReadOnly, st), - ast::StorageClass::kNone); + ast::StorageClass::kNone, nullptr, + {create(0), create(0)}); GeneratorImpl& gen = Build(); gen.increment_indent(); ASSERT_TRUE(gen.Generate(nullptr)) << gen.error(); - EXPECT_EQ(gen.result(), " var t : [[access(read)]] texture_1d;\n"); + EXPECT_EQ(gen.result(), " [[group(0), binding(0)]] var t : [[access(read)]] texture_1d;\n"); } } // namespace diff --git a/src/writer/wgsl/generator_impl_identifier_test.cc b/src/writer/wgsl/generator_impl_identifier_test.cc index 41330a9675..2a66db11b6 100644 --- a/src/writer/wgsl/generator_impl_identifier_test.cc +++ b/src/writer/wgsl/generator_impl_identifier_test.cc @@ -22,6 +22,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitIdentifierExpression_Single) { + Global("glsl", ty.f32(), ast::StorageClass::kPrivate); auto* i = Expr("glsl"); WrapInFunction(i); diff --git a/src/writer/wgsl/generator_impl_variable_test.cc b/src/writer/wgsl/generator_impl_variable_test.cc index 055e08530b..0605aac418 100644 --- a/src/writer/wgsl/generator_impl_variable_test.cc +++ b/src/writer/wgsl/generator_impl_variable_test.cc @@ -59,10 +59,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) { auto* v = Global("a", ty.f32(), ast::StorageClass::kPrivate, nullptr, ast::DecorationList{ Builtin(ast::Builtin::kPosition), - create(0), - create(1), Location(2), - create(42), }); GeneratorImpl& gen = Build(); @@ -70,7 +67,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) { ASSERT_TRUE(gen.EmitVariable(v)) << gen.error(); EXPECT_EQ( gen.result(), - R"([[builtin(position), binding(0), group(1), location(2), override(42)]] var a : f32; + R"([[builtin(position), location(2)]] var a : f32; )"); } diff --git a/src/writer/wgsl/test_helper.h b/src/writer/wgsl/test_helper.h index 074264fd29..b7839380af 100644 --- a/src/writer/wgsl/test_helper.h +++ b/src/writer/wgsl/test_helper.h @@ -43,6 +43,11 @@ class TestHelperBase : public BASE, public ProgramBuilder { return *gen_; } program = std::make_unique(std::move(*this)); + diag::Formatter formatter; + [&]() { + ASSERT_TRUE(program->IsValid()) + << formatter.format(program->Diagnostics()); + }(); gen_ = std::make_unique(program.get()); return *gen_; }