diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index 65b44c9fd1..1a0bc9a4cc 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -3089,9 +3089,11 @@ bool GeneratorImpl::EmitStructType(const sem::Struct* str) { // See discussion here: https://github.com/gpuweb/gpuweb/issues/893 pre += "precise "; } else if (!deco->IsAnyOf()) { TINT_ICE(Writer, diagnostics_) << "unhandled struct member attribute: " << deco->name(); + return false; } } diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc index 7db8426653..3417ec1d2e 100644 --- a/src/writer/hlsl/generator_impl_type_test.cc +++ b/src/writer/hlsl/generator_impl_type_test.cc @@ -236,6 +236,26 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { )")); } +TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) { + auto* s = Structure("S", + { + Member("a", ty.i32(), {MemberOffset(0)}), + Member("b", ty.f32(), {MemberOffset(8)}), + }, + {create()}); + Global("g", ty.Of(s), ast::StorageClass::kPrivate); + + GeneratorImpl& gen = Build(); + + auto* sem_s = program->TypeOf(s)->As(); + ASSERT_TRUE(gen.EmitStructType(sem_s)) << gen.error(); + EXPECT_EQ(gen.result(), R"(struct S { + int a; + float b; +}; +)"); +} + TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) { auto* u32 = create();