[vulkan] Allow deletion of some null resources

I very much doubt it's all of them but it was enough to let QF shutdown
cleanly mid-initialization.
This commit is contained in:
Bill Currie 2024-02-01 22:02:05 +09:00
parent a50eaab1e6
commit e96050daa5
6 changed files with 23 additions and 7 deletions

View file

@ -282,6 +282,9 @@ void
QFV_DestroyResource (qfv_device_t *device, qfv_resource_t *resource)
{
qfZoneScoped (true);
if (!resource) {
return;
}
qfv_devfuncs_t *dfunc = device->funcs;
for (unsigned i = 0; i < resource->num_objects; i++) {

View file

@ -173,6 +173,9 @@ QFV_ScrapClear (scrap_t *scrap)
void
QFV_DestroyScrap (scrap_t *scrap)
{
if (!scrap) {
return;
}
qfv_device_t *device = scrap->device;
qfv_devfuncs_t *dfunc = device->funcs;

View file

@ -96,6 +96,9 @@ QFV_CreateStagingBuffer (qfv_device_t *device, const char *name, size_t size,
void
QFV_DestroyStagingBuffer (qfv_stagebuf_t *stage)
{
if (!stage) {
return;
}
qfv_device_t *device = stage->device;
qfv_devfuncs_t *dfunc = device->funcs;

View file

@ -1243,11 +1243,13 @@ static void
delete_configs (void)
{
int num_plists = 0;
for (exprsym_t *sym = builtin_plist_syms; sym->name; sym++) {
PL_Release (builtin_plists[num_plists]);
num_plists++;
if (builtin_plists) {
for (exprsym_t *sym = builtin_plist_syms; sym->name; sym++) {
PL_Release (builtin_plists[num_plists]);
num_plists++;
}
free (builtin_plists);
}
free (builtin_plists);
Hash_DelTable (builtin_configs.tab);
}

View file

@ -831,9 +831,11 @@ draw_shutdown (exprctx_t *ectx)
auto device = ctx->device;
auto dctx = ctx->draw_context;
QFV_DestroyResource (device, &dctx->draw_resource[0]);
QFV_DestroyResource (device, &dctx->draw_resource[1]);
free (dctx->draw_resource);
if (dctx->draw_resource) {
QFV_DestroyResource (device, &dctx->draw_resource[0]);
QFV_DestroyResource (device, &dctx->draw_resource[1]);
free (dctx->draw_resource);
}
for (size_t i = 0; i < dctx->fonts.size; i++) {
if (dctx->fonts.a[i].resource) {
QFV_DestroyResource (device, &dctx->fonts.a[i].resource->resource);

View file

@ -463,6 +463,9 @@ Vulkan_UpdateTex (vulkan_ctx_t *ctx, qfv_tex_t *tex, tex_t *src,
void
Vulkan_UnloadTex (vulkan_ctx_t *ctx, qfv_tex_t *tex)
{
if (!tex) {
return;
}
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;