make render pass a member in init

This commit is contained in:
jacekpoz 2024-09-24 11:21:54 +02:00
parent 854416f651
commit e664c74cb2
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -100,6 +100,8 @@ static PTK_LIST(VkBuffer) m_uniform_buffers;
static PTK_LIST(VkDeviceMemory) m_uniform_buffers_memory; static PTK_LIST(VkDeviceMemory) m_uniform_buffers_memory;
static PTK_LIST(voidptr) m_uniform_buffers_mapped; static PTK_LIST(voidptr) m_uniform_buffers_mapped;
static VkRenderPass m_render_pass;
static VkDescriptorPool m_descriptor_pool; static VkDescriptorPool m_descriptor_pool;
static PTK_LIST(VkDescriptorSet) m_descriptor_sets; static PTK_LIST(VkDescriptorSet) m_descriptor_sets;
@ -385,7 +387,7 @@ bool create_graphics_pipeline(void) {
.pColorBlendState = &color_blending, .pColorBlendState = &color_blending,
.pDynamicState = &dynamic_state, .pDynamicState = &dynamic_state,
.layout = m_pipeline_layout, .layout = m_pipeline_layout,
.renderPass = g_render_pass, .renderPass = m_render_pass,
.subpass = 0, .subpass = 0,
.basePipelineHandle = VK_NULL_HANDLE, .basePipelineHandle = VK_NULL_HANDLE,
.basePipelineIndex = -1, .basePipelineIndex = -1,
@ -782,7 +784,7 @@ bool vk_record_command_buffer(const VkCommandBuffer command_buffer, const uint32
&(VkRenderPassBeginInfo){ &(VkRenderPassBeginInfo){
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
.pNext = NULL, .pNext = NULL,
.renderPass = g_render_pass, .renderPass = m_render_pass,
.framebuffer = g_swapchain_framebuffers.data[image_index], .framebuffer = g_swapchain_framebuffers.data[image_index],
.renderArea = (VkRect2D){ .renderArea = (VkRect2D){
.offset = (VkOffset2D){ .offset = (VkOffset2D){
@ -920,7 +922,7 @@ bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const
return false; return false;
} }
VkRenderPass render_pass = render_pass_opt.value; m_render_pass = render_pass_opt.value;
if (!create_descriptor_set_layout()) { if (!create_descriptor_set_layout()) {
PTK_ERR("failed creating descriptor set layout"); PTK_ERR("failed creating descriptor set layout");
@ -932,7 +934,7 @@ bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const
return false; return false;
} }
if (!vk_create_framebuffers(render_pass)) { if (!vk_create_framebuffers(m_render_pass)) {
PTK_ERR("failed creating framebuffers"); PTK_ERR("failed creating framebuffers");
return false; return false;
} }
@ -986,7 +988,7 @@ void vk_cleanup(void) {
vkDestroyPipeline(g_dev, m_pipeline, NULL); vkDestroyPipeline(g_dev, m_pipeline, NULL);
vkDestroyPipelineLayout(g_dev, m_pipeline_layout, NULL); vkDestroyPipelineLayout(g_dev, m_pipeline_layout, NULL);
vkDestroyRenderPass(g_dev, g_render_pass, NULL); vkDestroyRenderPass(g_dev, m_render_pass, NULL);
for (size_t i = 0; i < g_max_frames_in_flight; ++i) { for (size_t i = 0; i < g_max_frames_in_flight; ++i) {
vkDestroyBuffer(g_dev, m_uniform_buffers.data[i], NULL); vkDestroyBuffer(g_dev, m_uniform_buffers.data[i], NULL);