further reduce g_dev usage

This commit is contained in:
jacekpoz 2024-09-25 19:54:41 +02:00
parent fc5695fce8
commit 2f0c678d89
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
4 changed files with 13 additions and 13 deletions

View file

@ -37,7 +37,7 @@ bool vk_draw_frame(void) {
);
if (acquire_next_image_result == VK_ERROR_OUT_OF_DATE_KHR) {
if (!vk_recreate_swapchain(g_window, g_physical_dev, g_surface, g_render_pass)) {
if (!vk_recreate_swapchain(g_window, g_dev, g_physical_dev, g_surface, g_render_pass)) {
return false;
}
return true;
@ -94,7 +94,7 @@ bool vk_draw_frame(void) {
m_framebuffer_resized
) {
m_framebuffer_resized = false;
if (!vk_recreate_swapchain(g_window, g_physical_dev, g_surface, g_render_pass)) {
if (!vk_recreate_swapchain(g_window, g_dev, g_physical_dev, g_surface, g_render_pass)) {
return false;
}
PTK_TRACE("recreated swapchain");

View file

@ -242,7 +242,7 @@ bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const
m_pipeline = pipeline_stuff_opt.value.pipeline;
m_pipeline_layout = pipeline_stuff_opt.value.pipeline_layout;
if (!vk_create_framebuffers(g_render_pass)) {
if (!vk_create_framebuffers(g_dev, g_render_pass)) {
PTK_ERR("failed creating framebuffers");
return false;
}

View file

@ -220,7 +220,7 @@ bool vk_create_swapchain(GLFWwindow *window, VkDevice dev, VkPhysicalDevice phys
return true;
}
bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, VkSurfaceKHR surface, VkRenderPass render_pass) {
bool vk_recreate_swapchain(GLFWwindow *window, VkDevice dev, VkPhysicalDevice physical_dev, VkSurfaceKHR surface, VkRenderPass render_pass) {
int width = 0, height = 0;
glfwGetFramebufferSize(window, &width, &height);
@ -229,21 +229,21 @@ bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, Vk
glfwWaitEvents();
}
vkDeviceWaitIdle(g_dev);
vkDeviceWaitIdle(dev);
vk_cleanup_swapchain(g_dev);
vk_cleanup_swapchain(dev);
if (!vk_create_swapchain(window, g_dev, physical_dev, surface)) {
if (!vk_create_swapchain(window, dev, physical_dev, surface)) {
PTK_ERR("failed creating new swapchain");
return false;
}
if (!vk_create_image_views(g_dev)) {
if (!vk_create_image_views(dev)) {
PTK_ERR("failed creating new image views");
return false;
}
if (!vk_create_framebuffers(render_pass)) {
if (!vk_create_framebuffers(dev, render_pass)) {
PTK_ERR("failed creating new framebuffers");
return false;
}
@ -251,7 +251,7 @@ bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, Vk
return true;
}
bool vk_create_framebuffers(VkRenderPass render_pass) {
bool vk_create_framebuffers(VkDevice dev, VkRenderPass render_pass) {
g_swapchain_framebuffers = PTK_LIST_NEW(VkFramebuffer, m_swapchain_image_views.size);
VkFramebuffer fb;
@ -259,7 +259,7 @@ bool vk_create_framebuffers(VkRenderPass render_pass) {
PTK_LIST_FOR_EACH(VkImageView, m_swapchain_image_views, swapchain_image_view, {
VK_TRY(false,
vkCreateFramebuffer(
g_dev,
dev,
&(VkFramebufferCreateInfo){
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
.pNext = NULL,

View file

@ -31,9 +31,9 @@ bool vk_create_swapchain(GLFWwindow *window, VkDevice dev, VkPhysicalDevice phys
bool vk_create_image_views(VkDevice dev);
bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, VkSurfaceKHR surface, VkRenderPass render_pass);
bool vk_recreate_swapchain(GLFWwindow *window, VkDevice dev, VkPhysicalDevice physical_dev, VkSurfaceKHR surface, VkRenderPass render_pass);
bool vk_create_framebuffers(VkRenderPass render_pass);
bool vk_create_framebuffers(VkDevice dev, VkRenderPass render_pass);
void vk_cleanup_swapchain(VkDevice dev);