Skip to content

Commit 6c90330

Browse files
committed
Typo fix, more hardening of SPIR-V linker null checks
1 parent 998b268 commit 6c90330

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

mojoshader.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,16 +4042,22 @@ int MOJOSHADER_linkSPIRVShaders(const MOJOSHADER_parseData *vertex_spirv,
40424042
uint32 typeDeclOffset = vTable->attrib_type_offsets[element->usage][element->usageIndex];
40434043
if (typeDeclOffset > 0) // Vertex attribs passed may not exist in the vertex shader
40444044
{
4045+
((uint32*)vertex_spirv->output)[typeDeclOffset] = typeDecl;
40454046
for (uint32 j = 0; j < vTable->attrib_type_load_offsets[element->usage][element->usageIndex].num_loads; j += 1)
40464047
{
4048+
40474049
uint32 typeLoadOffset = vTable->attrib_type_load_offsets[element->usage][element->usageIndex].load_types[j];
40484050
uint32 opcodeLoadOffset = vTable->attrib_type_load_offsets[element->usage][element->usageIndex].load_opcodes[j];
4049-
uint32 *ptr_to_opcode_u32 = &((uint32*)vertex_spirv->output)[opcodeLoadOffset];
4050-
((uint32*)vertex_spirv->output)[typeLoadOffset] = typeLoad;
4051-
*ptr_to_opcode_u32 = (*ptr_to_opcode_u32 & 0xFFFF0000) | opcodeLoad;
4052-
}
4053-
}
4054-
}
4051+
if (typeLoadOffset > 0)
4052+
((uint32*)vertex_spirv->output)[typeLoadOffset] = typeLoad;
4053+
if (opcodeLoadOffset > 0)
4054+
{
4055+
uint32* ptr_to_opcode_u32 = &((uint32*)vertex_spirv->output)[opcodeLoadOffset];
4056+
*ptr_to_opcode_u32 = (*ptr_to_opcode_u32 & 0xFFFF0000) | opcodeLoad;
4057+
} // if
4058+
} // for
4059+
} // if
4060+
} // if
40554061

40564062
MOJOSHADER_spirv_link_attributes(vertex_spirv, pixel_spirv, 0);
40574063
return sizeof(SpirvPatchTable);

0 commit comments

Comments
 (0)