mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-29 07:32:02 +00:00
Ensure vulkan gets shut down
This commit is contained in:
parent
4e4d1b99b4
commit
1eafc33052
7 changed files with 37 additions and 11 deletions
|
@ -20,7 +20,8 @@ typedef struct qfv_device_s {
|
||||||
} qfv_device_t;
|
} qfv_device_t;
|
||||||
|
|
||||||
struct vulkan_ctx_s;
|
struct vulkan_ctx_s;
|
||||||
qfv_device_t *QFV_CreateDevice(struct vulkan_ctx_s *ctx,
|
qfv_device_t *QFV_CreateDevice (struct vulkan_ctx_s *ctx,
|
||||||
const char **extensions);
|
const char **extensions);
|
||||||
|
void QFV_DestroyDevice (qfv_device_t *device);
|
||||||
|
|
||||||
#endif//__QF_Vulkan_swapchain_h
|
#endif//__QF_Vulkan_swapchain_h
|
||||||
|
|
|
@ -48,6 +48,8 @@ INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||||
(vkGetPhysicalDeviceSurfaceCapabilitiesKHR, VK_KHR_SURFACE_EXTENSION_NAME)
|
(vkGetPhysicalDeviceSurfaceCapabilitiesKHR, VK_KHR_SURFACE_EXTENSION_NAME)
|
||||||
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||||
(vkGetPhysicalDeviceSurfaceFormatsKHR, VK_KHR_SURFACE_EXTENSION_NAME)
|
(vkGetPhysicalDeviceSurfaceFormatsKHR, VK_KHR_SURFACE_EXTENSION_NAME)
|
||||||
|
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||||
|
(vkDestroySurfaceKHR, VK_KHR_SURFACE_EXTENSION_NAME)
|
||||||
|
|
||||||
#undef INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
#undef INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||||
|
|
||||||
|
@ -99,5 +101,9 @@ DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||||
(vkDestroySwapchainKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
|
(vkDestroySwapchainKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
|
||||||
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||||
(vkGetSwapchainImagesKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
|
(vkGetSwapchainImagesKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
|
||||||
|
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||||
|
(vkAcquireNextImageKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
|
||||||
|
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||||
|
(vkQueuePresentKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
|
||||||
|
|
||||||
#undef DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
#undef DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||||
|
|
|
@ -13,5 +13,6 @@ typedef struct qfv_swapchain_s {
|
||||||
struct vulkan_ctx_s;
|
struct vulkan_ctx_s;
|
||||||
qfv_swapchain_t *QFV_CreateSwapchain (struct vulkan_ctx_s *ctx,
|
qfv_swapchain_t *QFV_CreateSwapchain (struct vulkan_ctx_s *ctx,
|
||||||
VkSwapchainKHR old_swapchain);
|
VkSwapchainKHR old_swapchain);
|
||||||
|
void QFV_DestroySwapchain (qfv_swapchain_t *swapchain);
|
||||||
|
|
||||||
#endif//__QF_Vulkan_swapchain_h
|
#endif//__QF_Vulkan_swapchain_h
|
||||||
|
|
|
@ -63,6 +63,14 @@ vid_render_funcs_t *r_funcs;
|
||||||
static U void (*const r_progs_init)(struct progs_s *) = R_Progs_Init;
|
static U void (*const r_progs_init)(struct progs_s *) = R_Progs_Init;
|
||||||
#undef U
|
#undef U
|
||||||
|
|
||||||
|
static void
|
||||||
|
R_shutdown (void)
|
||||||
|
{
|
||||||
|
if (vidrendmodule->functions->general->p_Shutdown) {
|
||||||
|
vidrendmodule->functions->general->p_Shutdown ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VISIBLE void
|
VISIBLE void
|
||||||
R_LoadModule (vid_internal_t *vid_internal)
|
R_LoadModule (vid_internal_t *vid_internal)
|
||||||
{
|
{
|
||||||
|
@ -80,6 +88,7 @@ R_LoadModule (vid_internal_t *vid_internal)
|
||||||
r_data->vid->vid_internal = vid_internal;
|
r_data->vid->vid_internal = vid_internal;
|
||||||
|
|
||||||
vidrendmodule->functions->general->p_Init ();
|
vidrendmodule->functions->general->p_Init ();
|
||||||
|
Sys_RegisterShutdown (R_shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE void
|
VISIBLE void
|
||||||
|
|
|
@ -133,9 +133,6 @@ QFV_CreateDevice (vulkan_ctx_t *ctx, const char **extensions)
|
||||||
{
|
{
|
||||||
uint32_t nlay = 1; // ensure alloca doesn't see 0 and terminated
|
uint32_t nlay = 1; // ensure alloca doesn't see 0 and terminated
|
||||||
uint32_t next = count_strings (extensions) + 1; // ensure terminated
|
uint32_t next = count_strings (extensions) + 1; // ensure terminated
|
||||||
//if (vulkan_use_validation->int_val) {
|
|
||||||
// nlay += count_strings (vulkanValidationLayers);
|
|
||||||
//}
|
|
||||||
const char **lay = alloca (nlay * sizeof (const char *));
|
const char **lay = alloca (nlay * sizeof (const char *));
|
||||||
const char **ext = alloca (next * sizeof (const char *));
|
const char **ext = alloca (next * sizeof (const char *));
|
||||||
// ensure there are null pointers so merge_strings can act as append
|
// ensure there are null pointers so merge_strings can act as append
|
||||||
|
@ -144,9 +141,6 @@ QFV_CreateDevice (vulkan_ctx_t *ctx, const char **extensions)
|
||||||
memset (lay, 0, nlay-- * sizeof (const char *));
|
memset (lay, 0, nlay-- * sizeof (const char *));
|
||||||
memset (ext, 0, next-- * sizeof (const char *));
|
memset (ext, 0, next-- * sizeof (const char *));
|
||||||
merge_strings (ext, extensions, 0);
|
merge_strings (ext, extensions, 0);
|
||||||
//if (vulkan_use_validation->int_val) {
|
|
||||||
// merge_strings (lay, lay, vulkanValidationLayers);
|
|
||||||
//}
|
|
||||||
|
|
||||||
qfv_instance_t *inst = ctx->instance;
|
qfv_instance_t *inst = ctx->instance;
|
||||||
VkInstance instance = inst->instance;
|
VkInstance instance = inst->instance;
|
||||||
|
@ -160,9 +154,6 @@ QFV_CreateDevice (vulkan_ctx_t *ctx, const char **extensions)
|
||||||
for (uint32_t i = 0; i < numDevices; i++) {
|
for (uint32_t i = 0; i < numDevices; i++) {
|
||||||
VkPhysicalDevice physdev = devices[i];
|
VkPhysicalDevice physdev = devices[i];
|
||||||
/*
|
/*
|
||||||
if (!Vulkan_LayersSupported (phys->layers, phys->numLayers, lay)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!Vulkan_ExtensionsSupported (phys->extensions, phys->numExtensions,
|
if (!Vulkan_ExtensionsSupported (phys->extensions, phys->numExtensions,
|
||||||
ext)) {
|
ext)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -209,3 +200,11 @@ QFV_CreateDevice (vulkan_ctx_t *ctx, const char **extensions)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
QFV_DestroyDevice (qfv_device_t *device)
|
||||||
|
{
|
||||||
|
device->funcs->vkDestroyDevice (device->dev, 0);
|
||||||
|
del_strset (device->enabled_extensions);
|
||||||
|
free (device);
|
||||||
|
}
|
||||||
|
|
|
@ -146,3 +146,11 @@ QFV_CreateSwapchain (vulkan_ctx_t *ctx, VkSwapchainKHR old_swapchain)
|
||||||
sc->images);
|
sc->images);
|
||||||
return sc;
|
return sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
QFV_DestroySwapchain (qfv_swapchain_t *swapchain)
|
||||||
|
{
|
||||||
|
swapchain->funcs->vkDestroySwapchainKHR (swapchain->dev,
|
||||||
|
swapchain->swapchain, 0);
|
||||||
|
free (swapchain);
|
||||||
|
}
|
||||||
|
|
|
@ -116,6 +116,8 @@ Vulkan_Init_Common (vulkan_ctx_t *ctx)
|
||||||
void
|
void
|
||||||
Vulkan_Shutdown_Common (vulkan_ctx_t *ctx)
|
Vulkan_Shutdown_Common (vulkan_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
|
Sys_Printf ("are we here?\n");
|
||||||
|
QFV_DestroyDevice (ctx->device);
|
||||||
QFV_DestroyInstance (ctx->instance);
|
QFV_DestroyInstance (ctx->instance);
|
||||||
ctx->instance = 0;
|
ctx->instance = 0;
|
||||||
ctx->unload_vulkan (ctx);
|
ctx->unload_vulkan (ctx);
|
||||||
|
|
Loading…
Reference in a new issue