Skip to content

Commit dd955e2

Browse files
author
danginsburg
committed
Fixes issue #287 - fix crash caused by assumption that PhysicalStorageBuffers will always point to structs. They can point to plain data types.
1 parent 4c6d3f3 commit dd955e2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spirv_reflect.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,6 @@ static SpvReflectResult ParseType(SpvReflectPrvParser* p_parser, SpvReflectPrvNo
19981998
}
19991999
}
20002000
if (!found_recursion) {
2001-
p_parser->physical_pointer_struct_count++;
20022001
p_parser->physical_pointer_check[p_parser->physical_pointer_count] = p_type;
20032002
p_parser->physical_pointer_count++;
20042003
if (p_parser->physical_pointer_count >= MAX_RECURSIVE_PHYSICAL_POINTER_CHECK) {
@@ -2014,6 +2013,7 @@ static SpvReflectResult ParseType(SpvReflectPrvParser* p_parser, SpvReflectPrvNo
20142013
SPV_REFLECT_ASSERT(false);
20152014
} else if (!found_recursion) {
20162015
if (p_next_node->op == SpvOpTypeStruct) {
2016+
p_parser->physical_pointer_struct_count++;
20172017
p_type->struct_type_description = FindType(p_module, p_next_node->result_id);
20182018
}
20192019

@@ -2517,6 +2517,7 @@ static SpvReflectResult ParseDescriptorBlockVariable(SpvReflectPrvParser* p_pars
25172517
SpvReflectBlockVariable* p_member_var = &p_var->members[member_index];
25182518
// If pointer type, treat like reference and resolve to pointee type
25192519
SpvReflectTypeDescription* p_member_ptr_type = 0;
2520+
SpvReflectTypeDescription* p_struct_type_description = 0;
25202521
bool found_recursion = false;
25212522

25222523
if ((p_member_type->storage_class == SpvStorageClassPhysicalStorageBuffer) &&
@@ -2545,6 +2546,9 @@ static SpvReflectResult ParseDescriptorBlockVariable(SpvReflectPrvParser* p_pars
25452546
}
25462547
}
25472548
if (!found_recursion) {
2549+
p_struct_type_description = FindType(p_module, p_member_type->id)->struct_type_description;
2550+
}
2551+
if (p_struct_type_description) {
25482552
uint32_t struct_id = FindType(p_module, p_member_type->id)->struct_type_description->id;
25492553
p_parser->physical_pointer_structs[p_parser->physical_pointer_struct_count].struct_id = struct_id;
25502554
p_parser->physical_pointer_structs[p_parser->physical_pointer_struct_count].p_var = p_member_var;
@@ -2724,7 +2728,6 @@ static SpvReflectResult ParseDescriptorBlockVariableSizes(SpvReflectPrvParser* p
27242728
if (IsNull(p_member_type)) {
27252729
return SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_ID_REFERENCE;
27262730
}
2727-
assert(p_member_type->op == SpvOpTypeStruct);
27282731
FALLTHROUGH;
27292732
}
27302733

0 commit comments

Comments
 (0)