diff --git a/src/api/l_graphics_pass.c b/src/api/l_graphics_pass.c index 9c38e380..96a9ea8f 100644 --- a/src/api/l_graphics_pass.c +++ b/src/api/l_graphics_pass.c @@ -440,7 +440,7 @@ static int l_lovrPassSetStencilWrite(lua_State* L) { static int l_lovrPassSetVertexFormat(lua_State* L) { uint32_t count = 0; - BufferField fields[11]; + BufferField fields[16]; Pass* pass = luax_checktype(L, 1, Pass); if (lua_isnil(L, 2)) { lovrPassSetVertexFormat(pass, NULL, 0); diff --git a/src/modules/graphics/graphics.c b/src/modules/graphics/graphics.c index 86ff87b4..1e309346 100644 --- a/src/modules/graphics/graphics.c +++ b/src/modules/graphics/graphics.c @@ -28,6 +28,7 @@ const char** os_vk_get_instance_extensions(uint32_t* count); #define MAX_TRANSFORMS 16 #define MAX_PIPELINES 4 #define MAX_SHADER_RESOURCES 32 +#define MAX_CUSTOM_ATTRIBUTES 10 #define FLOAT_BITS(f) ((union { float f; uint32_t u; }) { f }).u typedef struct { @@ -4090,8 +4091,8 @@ void lovrPassSetStencilWrite(Pass* pass, StencilAction actions[3], uint8_t value void lovrPassSetVertexFormat(Pass* pass, BufferField* fields, uint32_t count) { if (!pass->pipeline->vertexFormat) { // Vertex formats are huge, allocate it lazily only if needed - pass->pipeline->vertexFormat = tempAlloc(11 * sizeof(BufferField)); - memset(pass->pipeline->vertexFormat, 0, 11 * sizeof(BufferField)); + pass->pipeline->vertexFormat = tempAlloc((MAX_CUSTOM_ATTRIBUTES + 1) * sizeof(BufferField)); + memset(pass->pipeline->vertexFormat, 0, (MAX_CUSTOM_ATTRIBUTES + 1) * sizeof(BufferField)); pass->pipeline->vertexFormat[0].children = &pass->pipeline->vertexFormat[1]; } @@ -4114,7 +4115,7 @@ void lovrPassSetVertexFormat(Pass* pass, BufferField* fields, uint32_t count) { lovrCheck(attribute->length == 0, "Vertex attributes can not be arrays"); } - lovrCheck(array->childCount <= 10, "Too many vertex attributes (max is %d)", 10); + lovrCheck(array->childCount <= MAX_CUSTOM_ATTRIBUTES, "Too many vertex attributes (max is %d)", MAX_CUSTOM_ATTRIBUTES); memcpy(array, fields, count * sizeof(BufferField)); array->children = array + (fields[0].children - fields); alignField(array, LAYOUT_PACKED);