From b33cc99374e3fbd69ef11adf2418b0aeb19f11b7 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 9 Mar 2023 18:36:23 -0800 Subject: [PATCH] Fix potential crash when creating textures; beginFrame needs to be called a little bit earlier (before getting the buffer to write the texture contents). --- src/modules/graphics/graphics.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/graphics/graphics.c b/src/modules/graphics/graphics.c index 29d3060d..d9319c2d 100644 --- a/src/modules/graphics/graphics.c +++ b/src/modules/graphics/graphics.c @@ -1255,6 +1255,8 @@ Texture* lovrTextureCreate(const TextureInfo* info) { uint32_t levelSizes[16]; gpu_buffer* scratchpad = NULL; + beginFrame(); + if (info->imageCount > 0) { levelCount = lovrImageGetLevelCount(info->images[0]); lovrCheck(info->type != TEXTURE_3D || levelCount == 1, "Images used to initialize 3D textures can not have mipmaps"); @@ -1284,8 +1286,6 @@ Texture* lovrTextureCreate(const TextureInfo* info) { } } - beginFrame(); - gpu_texture_init(texture->gpu, &(gpu_texture_info) { .type = (gpu_texture_type) info->type, .format = (gpu_texture_format) info->format,