writer/hlsl: Ignore struct member offset attribute
These are generated by the SPIR-V reader. Structures used by the storage and uniform storage classes are handled separately, so we can safely ignore this attribute for the other storage classes which are not shared with the host. Fixed: tint:1027 Change-Id: I8df4b41c687922a97f3b0ed97804cecc17d8997a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59240 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
eb39420ae6
commit
4261466a84
|
@ -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<ast::StructMemberAlignDecoration,
|
||||
ast::StructMemberOffsetDecoration,
|
||||
ast::StructMemberSizeDecoration>()) {
|
||||
TINT_ICE(Writer, diagnostics_)
|
||||
<< "unhandled struct member attribute: " << deco->name();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ast::StructBlockDecoration>()});
|
||||
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
|
||||
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<sem::U32>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue