mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 06:03:34 +00:00
spirv-reader: reject empty structure types
SPIR-V supports them but WGSL does not. Fixed: chromium:1230976 Change-Id: I27dbbf4a0f584bcff7355bf513bbd2b924dc349b Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/62922 Auto-Submit: David Neto <dneto@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com> Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
parent
d30c07e4df
commit
293d313bbc
@ -1089,6 +1089,11 @@ const Type* ParserImpl::ConvertType(
|
|||||||
// Compute members
|
// Compute members
|
||||||
ast::StructMemberList ast_members;
|
ast::StructMemberList ast_members;
|
||||||
const auto members = struct_ty->element_types();
|
const auto members = struct_ty->element_types();
|
||||||
|
if (members.empty()) {
|
||||||
|
Fail() << "WGSL does not support empty structures. can't convert type: "
|
||||||
|
<< def_use_mgr_->GetDef(type_id)->PrettyPrint();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
TypeList ast_member_types;
|
TypeList ast_member_types;
|
||||||
unsigned num_non_writable_members = 0;
|
unsigned num_non_writable_members = 0;
|
||||||
for (uint32_t member_index = 0; member_index < members.size();
|
for (uint32_t member_index = 0; member_index < members.size();
|
||||||
|
@ -568,6 +568,19 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_SpecifiedTwiceIsError) {
|
|||||||
Eq("invalid array type ID 10: multiple ArrayStride decorations"));
|
Eq("invalid array type ID 10: multiple ArrayStride decorations"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SpvParserTest, ConvertType_StructEmpty) {
|
||||||
|
auto p = parser(test::Assemble(Preamble() + R"(
|
||||||
|
%10 = OpTypeStruct
|
||||||
|
)" + MainBody()));
|
||||||
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
|
auto* type = p->ConvertType(10);
|
||||||
|
EXPECT_EQ(type, nullptr);
|
||||||
|
EXPECT_EQ(p->error(),
|
||||||
|
"WGSL does not support empty structures. can't convert type: %10 = "
|
||||||
|
"OpTypeStruct");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
|
TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
|
||||||
auto p = parser(test::Assemble(Preamble() + R"(
|
auto p = parser(test::Assemble(Preamble() + R"(
|
||||||
%uint = OpTypeInt 32 0
|
%uint = OpTypeInt 32 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user