[vulkan] Plug some leaking sprite descriptors

I'd forgotten to free them when unloading a model, thus the segfault
after about 31 timedemo runs.
This commit is contained in:
Bill Currie 2022-05-11 01:39:33 +09:00
parent 1e65ec22f9
commit 86faeba31a
3 changed files with 15 additions and 0 deletions

View file

@ -81,6 +81,8 @@ struct qfv_renderframe_s;
struct entity_s;
struct mod_sprite_ctx_s;
void Vulkan_Sprint_FreeDescriptors (struct vulkan_ctx_s *ctx,
qfv_sprite_t *sprite);
void Vulkan_Sprite_DescriptorSet (struct vulkan_ctx_s *ctx,
qfv_sprite_t *sprite);
void Vulkan_Mod_SpriteLoadFrames (struct mod_sprite_ctx_s *sprite_ctx,

View file

@ -67,6 +67,8 @@ vulkan_sprite_clear (model_t *m, void *data)
msprite_t *msprite = m->cache.data;
__auto_type sprite = (qfv_sprite_t *) ((byte *) msprite + msprite->data);
Vulkan_Sprint_FreeDescriptors (ctx, sprite);
dfunc->vkDestroyBuffer (device->dev, sprite->verts, 0);
dfunc->vkDestroyImageView (device->dev, sprite->view, 0);
dfunc->vkDestroyImage (device->dev, sprite->image, 0);

View file

@ -271,6 +271,17 @@ Vulkan_Sprite_DescriptorSet (vulkan_ctx_t *ctx, qfv_sprite_t *sprite)
dfunc->vkUpdateDescriptorSets (device->dev, 2, write, 0, 0);
}
void
Vulkan_Sprint_FreeDescriptors (vulkan_ctx_t *ctx, qfv_sprite_t *sprite)
{
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;
spritectx_t *sctx = ctx->sprite_context;
dfunc->vkFreeDescriptorSets (device->dev, sctx->pool, 1,
&sprite->descriptors);
}
void
Vulkan_Sprite_Init (vulkan_ctx_t *ctx)
{