From 6fbce335bbe5829976854335b1c5863a454cb079 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 8 Dec 2021 21:08:37 +0900 Subject: [PATCH] [vulkan] Add an array view for default_magenta The validation layers get very picky about image view types (rightfully so, I imagine). --- include/vid_vulkan.h | 1 + libs/video/renderer/vulkan/vulkan_texture.c | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/vid_vulkan.h b/include/vid_vulkan.h index 27fadb159..bb5b8a779 100644 --- a/include/vid_vulkan.h +++ b/include/vid_vulkan.h @@ -80,6 +80,7 @@ typedef struct vulkan_ctx_s { struct qfv_tex_s *default_black; struct qfv_tex_s *default_white; struct qfv_tex_s *default_magenta; + struct qfv_tex_s *default_magenta_array; VkViewport viewport; VkRect2D scissor; diff --git a/libs/video/renderer/vulkan/vulkan_texture.c b/libs/video/renderer/vulkan/vulkan_texture.c index 4a6949881..b90601102 100644 --- a/libs/video/renderer/vulkan/vulkan_texture.c +++ b/libs/video/renderer/vulkan/vulkan_texture.c @@ -404,9 +404,15 @@ Vulkan_UnloadTex (vulkan_ctx_t *ctx, qfv_tex_t *tex) qfv_device_t *device = ctx->device; qfv_devfuncs_t *dfunc = device->funcs; - dfunc->vkDestroyImageView (device->dev, tex->view, 0); - dfunc->vkDestroyImage (device->dev, tex->image, 0); - dfunc->vkFreeMemory (device->dev, tex->memory, 0); + if (tex->view) { + dfunc->vkDestroyImageView (device->dev, tex->view, 0); + } + if (tex->image) { + dfunc->vkDestroyImage (device->dev, tex->image, 0); + } + if (tex->memory) { + dfunc->vkFreeMemory (device->dev, tex->memory, 0); + } free (tex); } @@ -426,6 +432,14 @@ Vulkan_Texture_Init (vulkan_ctx_t *ctx) "default_white"); ctx->default_magenta = Vulkan_LoadTex (ctx, &default_magenta_tex, 1, "default_magenta"); + qfv_tex_t *tex; + tex = ctx->default_magenta_array = malloc (sizeof (qfv_tex_t)); + tex->memory = 0; + tex->image = 0; + tex->view = QFV_CreateImageView (ctx->device, ctx->default_magenta->image, + VK_IMAGE_VIEW_TYPE_2D_ARRAY, + VK_FORMAT_R8G8B8A8_UNORM, + VK_IMAGE_ASPECT_COLOR_BIT); } void @@ -434,4 +448,5 @@ Vulkan_Texture_Shutdown (vulkan_ctx_t *ctx) Vulkan_UnloadTex (ctx, ctx->default_black); Vulkan_UnloadTex (ctx, ctx->default_white); Vulkan_UnloadTex (ctx, ctx->default_magenta); + Vulkan_UnloadTex (ctx, ctx->default_magenta_array); }