summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-08-12 17:41:10 -0400
committerAndrew Opalach <andrew@akon.city> 2025-08-12 17:41:10 -0400
commit88d24e4caa0211b78d3d86d9fab5ec9e11d9b66d (patch)
tree9de6723a650f8f27350849ff46341d1c11fc3f5e /src
parentf595bcadb2305d5bbc5ea945935a42bcfbf6bdb1 (diff)
downloadstela-88d24e4caa0211b78d3d86d9fab5ec9e11d9b66d.tar.gz
stela-88d24e4caa0211b78d3d86d9fab5ec9e11d9b66d.tar.bz2
stela-88d24e4caa0211b78d3d86d9fab5ec9e11d9b66d.zip
Add method to destroy the created Vulkan surface
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src')
-rw-r--r--src/window.h1
-rw-r--r--src/window_wayland.c22
-rw-r--r--src/window_win32.c12
3 files changed, 32 insertions, 3 deletions
diff --git a/src/window.h b/src/window.h
index 35aa5f0..e293a8f 100644
--- a/src/window.h
+++ b/src/window.h
@@ -98,6 +98,7 @@ struct stl_window {
#if defined STELA_API_VULKAN
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL (*get_vk_proc_address)(VkInstance, const char *);
VkResult (*vk_create_surface)(void *, VkInstance, VkSurfaceKHR *);
+ VkResult (*vk_destroy_surface)(VkInstance, VkSurfaceKHR);
const char *const *(*vk_get_extensions)(u32 *);
#elif defined STELA_API_DX11
HWND win32_window;
diff --git a/src/window_wayland.c b/src/window_wayland.c
index 1c707f8..a313a08 100644
--- a/src/window_wayland.c
+++ b/src/window_wayland.c
@@ -1213,11 +1213,13 @@ static VkResult window_wayland_vk_create_surface(void *window, VkInstance inst,
.surface = wl->surface
};
- PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR;
- CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)get_vk_proc_address(inst, "vkCreateWaylandSurfaceKHR");
- if (!CreateWaylandSurfaceKHR) {
+ /*
+ PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
+ vkCreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)get_vk_proc_address(inst, "vkCreateWaylandSurfaceKHR");
+ if (!vkCreateWaylandSurfaceKHR) {
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
+ */
VkResult ret = vkCreateWaylandSurfaceKHR(inst, &info, NULL, surface);
if (ret != VK_SUCCESS) {
@@ -1226,6 +1228,19 @@ static VkResult window_wayland_vk_create_surface(void *window, VkInstance inst,
return ret;
}
+static VkResult window_wayland_vk_destroy_surface(VkInstance inst, VkSurfaceKHR surface)
+{
+ /*
+ PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
+ vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)get_vk_proc_address(inst, "vkDestroySurfaceKHR");
+ if (!vkDestroySurfaceKHR) {
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+ */
+ vkDestroySurfaceKHR(inst, surface, NULL);
+ return VK_SUCCESS;
+}
+
static const char *const *window_wayland_vk_get_extensions(u32 *num)
{
*num = 2;
@@ -1283,6 +1298,7 @@ struct stl_window *stl_window_create(void)
#if defined STELA_API_VULKAN
wl->w.get_vk_proc_address = window_wayland_get_vk_proc_address;
wl->w.vk_create_surface = window_wayland_vk_create_surface;
+ wl->w.vk_destroy_surface = window_wayland_vk_destroy_surface;
wl->w.vk_get_extensions = window_wayland_vk_get_extensions;
#elif defined STELA_API_OPENGL
wl->w.get_gl_proc_address = NULL;
diff --git a/src/window_win32.c b/src/window_win32.c
index 6e47db6..38cf6bf 100644
--- a/src/window_win32.c
+++ b/src/window_win32.c
@@ -1278,6 +1278,17 @@ static VkResult window_win32_vk_create_surface(void *window, VkInstance inst, Vk
return ret;
}
+static VkResult window_win32_vk_destroy_surface(VkInstance inst, VkSurfaceKHR surface)
+{
+ PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
+ DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)GetVKProcAddress(inst, "vkDestroySurfaceKHR");
+ if (!DestroySurfaceKHR) {
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+ DestroySurfaceKHR(inst, surface, NULL);
+ return VK_SUCCESS;
+}
+
static const char *const *window_win32_vk_get_extensions(u32 *num)
{
*num = 2;
@@ -1343,6 +1354,7 @@ struct stl_window *stl_window_create(void)
#if defined STELA_API_VULKAN
w32->w.get_vk_proc_address = window_win32_get_vk_proc_address;
w32->w.vk_create_surface = window_win32_vk_create_surface;
+ w32->w.vk_destroy_surface = window_win32_vk_destroy_surface;
w32->w.vk_get_extensions = window_win32_vk_get_extensions;
#elif defined STELA_API_OPENGL
w32->w.get_gl_proc_address = (void (*(*)(const char *))(void))GetAnyGLFuncAddress;