From 8fa221cb60c19638d4ad0833965fee605593eea3 Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Mon, 2 Oct 2023 14:36:20 -0300 Subject: refa Remove redundant framebuffers * src/vk/framebuffer.hpp: Move to this class all the framebuffers. --- src/core.cpp | 22 +++- src/core.hpp | 2 + src/vk/framebuffer.cpp | 198 +++++++++++++++++++++++++++++++ src/vk/framebuffer.hpp | 43 +++++++ src/vk/graphics_pipeline_2d_solid.cpp | 40 ------- src/vk/graphics_pipeline_2d_solid.hpp | 7 +- src/vk/graphics_pipeline_2d_wired.cpp | 40 ------- src/vk/graphics_pipeline_2d_wired.hpp | 3 - src/vk/graphics_pipeline_3d.cpp | 117 ------------------ src/vk/graphics_pipeline_3d.hpp | 7 -- src/vk/graphics_pipeline_3d_skeletal.cpp | 117 ------------------ src/vk/graphics_pipeline_3d_skeletal.hpp | 7 -- src/vk/renderer.cpp | 5 +- 13 files changed, 268 insertions(+), 340 deletions(-) create mode 100644 src/vk/framebuffer.cpp create mode 100644 src/vk/framebuffer.hpp diff --git a/src/core.cpp b/src/core.cpp index 0197e97..591eaba 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -524,6 +524,25 @@ unload_vk_swapchain(void *obj) delete cg_core.vk_swapchain; } +void +load_vk_framebuffer(void *obj) +{ + try + { + cg_core.vk_framebuffer = new VK::Framebuffer(); + } + catch(const CommandError &e) + { + throw CommandError{"Failed to create framebuffer."}; + } +} + +void +unload_vk_framebuffer(void *obj) +{ + delete cg_core.vk_framebuffer; +} + void load_vk_render_pass(void *obj) { @@ -533,7 +552,7 @@ load_vk_render_pass(void *obj) } catch(const CommandError &e) { - throw CommandError{"Failed to create descriptor set layouts."}; + throw CommandError{"Failed to create render pass."}; } } @@ -786,6 +805,7 @@ const CommandChain cg_sCore::loader{ {&load_vk_swapchain, &unload_vk_swapchain}, {&load_vk_render_pass, &unload_vk_render_pass}, + {&load_vk_framebuffer, &unload_vk_framebuffer}, {&load_vk_descriptor_set_layout, &unload_vk_descriptor_set_layout}, {&load_vk_graphics_pipeline_3d_layout, &unload_vk_graphics_pipeline_3d_layout}, diff --git a/src/core.hpp b/src/core.hpp index 917920b..9566a52 100644 --- a/src/core.hpp +++ b/src/core.hpp @@ -50,6 +50,7 @@ #include "vk/device.hpp" #include "vk/descriptor_set_layout.hpp" #include "vk/render_pass.hpp" +#include "vk/framebuffer.hpp" #include "vk/graphics_pipeline_2d_solid_layout.hpp" #include "vk/graphics_pipeline_2d_wired_layout.hpp" #include "vk/light.hpp" @@ -120,6 +121,7 @@ struct cg_sCore VK::Device *vk_device_with_swapchain; VK::Swapchain *vk_swapchain; + VK::Framebuffer *vk_framebuffer; VK::RenderPass *vk_render_pass; VK::DescriptorSetLayout *vk_descriptor_set_layout; VK::GraphicsPipeline3DLayout *vk_graphics_pipeline_3d_layout; diff --git a/src/vk/framebuffer.cpp b/src/vk/framebuffer.cpp new file mode 100644 index 0000000..4104554 --- /dev/null +++ b/src/vk/framebuffer.cpp @@ -0,0 +1,198 @@ +/* + * Copyright 2022-2023 Frederico de Oliveira Linhares + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "framebuffer.hpp" + +#include "../core.hpp" +#include "image.hpp" + +namespace +{ +void +load_depth_image(void *obj) +{ + auto self = static_cast(obj); + + VkExtent3D extent3d{}; + extent3d.width = cg_core.display_width; + extent3d.height = cg_core.display_height; + extent3d.depth = 1; + + try + { + VK::Image::create( + cg_core.vk_device_with_swapchain, + &self->depth_image, + &self->depth_image_memory, + VK_FORMAT_D32_SFLOAT, + extent3d, + 1, + VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT + ); + } + catch(VK::Image::Error error) + { + std::string error_message{"Failed to create depth image → "}; + error_message += error.what(); + throw CommandError{error_message}; + } +} + +void +unload_depth_image(void *obj) +{ + auto self = static_cast(obj); + + vkDestroyImage( + cg_core.vk_device_with_swapchain->device, self->depth_image, + nullptr); + vkFreeMemory( + cg_core.vk_device_with_swapchain->device, + self->depth_image_memory, nullptr); +} + +void +load_depth_image_view(void *obj) +{ + auto self = static_cast(obj); + + try + { + VK::Image::create_view( + cg_core.vk_device_with_swapchain, &self->depth_image_view, + self->depth_image, + VK_FORMAT_D32_SFLOAT, VK_IMAGE_ASPECT_DEPTH_BIT); + } + catch(VK::Image::Error error) + { + std::string error_message{"Failed to create depth image view → "}; + error_message += error.what(); + throw CommandError{error_message}; + } +} + +void +unload_depth_image_view(void *obj) +{ + auto self = static_cast(obj); + + vkDestroyImageView( + cg_core.vk_device_with_swapchain->device, self->depth_image_view, nullptr); +} + +void +load_3d(void *obj) +{ + auto self = static_cast(obj); + + self->pipeline_3d.resize(cg_core.vk_swapchain->images_count); + for (auto i{0}; i < cg_core.vk_swapchain->images_count; i++) + { + std::array attachments = { + cg_core.vk_swapchain->image_views[i], + self->depth_image_view + }; + + VkFramebufferCreateInfo framebuffer_info{}; + framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; + framebuffer_info.renderPass = cg_core.vk_render_pass->pipeline_3d; + framebuffer_info.attachmentCount = attachments.size(); + framebuffer_info.pAttachments = attachments.data(); + framebuffer_info.width = cg_core.display_width; + framebuffer_info.height = cg_core.display_height; + + framebuffer_info.layers = 1; + + if(vkCreateFramebuffer( + cg_core.vk_device_with_swapchain->device, &framebuffer_info, nullptr, + &self->pipeline_3d[i]) != VK_SUCCESS) + throw CommandError{"Failed to create Vulkan Framebuffer."}; + } +} + +void +unload_3d(void *obj) +{ + auto self = static_cast(obj); + + for(auto framebuffer: self->pipeline_3d) + vkDestroyFramebuffer( + cg_core.vk_device_with_swapchain->device, framebuffer, nullptr); +} + +void +load_2d(void *obj) +{ + auto self = static_cast(obj); + + self->pipeline_2d.resize(cg_core.vk_swapchain->images_count); + for (auto i{0}; i < cg_core.vk_swapchain->images_count; i++) + { + std::array attachments = { + cg_core.vk_swapchain->image_views[i] + }; + + VkFramebufferCreateInfo framebuffer_info{}; + framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; + framebuffer_info.renderPass = cg_core.vk_render_pass->pipeline_2d; + framebuffer_info.attachmentCount = attachments.size(); + framebuffer_info.pAttachments = attachments.data(); + framebuffer_info.width = cg_core.display_width; + framebuffer_info.height = cg_core.display_height; + framebuffer_info.layers = 1; + + if(vkCreateFramebuffer( + cg_core.vk_device_with_swapchain->device, &framebuffer_info, nullptr, + &self->pipeline_2d[i]) + != VK_SUCCESS) + throw CommandError{"Failed to create Vulkan Framebuffer."}; + } +} + +void +unload_2d(void *obj) +{ + auto self = static_cast(obj); + + for(auto framebuffer: self->pipeline_2d) + vkDestroyFramebuffer( + cg_core.vk_device_with_swapchain->device, framebuffer, nullptr); +} + +const CommandChain loader{ + {&load_depth_image, &unload_depth_image}, + {&load_depth_image_view, &unload_depth_image_view}, + {&load_3d, &unload_3d}, + {&load_2d, &unload_2d} +}; + +} + +namespace VK +{ + +Framebuffer::Framebuffer() +{ + loader.execute(this); +} + +Framebuffer::~Framebuffer() +{ + loader.revert(this); +} + +} diff --git a/src/vk/framebuffer.hpp b/src/vk/framebuffer.hpp new file mode 100644 index 0000000..2867fa1 --- /dev/null +++ b/src/vk/framebuffer.hpp @@ -0,0 +1,43 @@ +/* + * Copyright 2022-2023 Frederico de Oliveira Linhares + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CANDY_GEAR_VK_FRAMEBUFFER_H +#define CANDY_GEAR_VK_FRAMEBUFFER_H 1 + +#include + +#include "core.hpp" + +namespace VK +{ + +struct Framebuffer +{ + // Depth image. + VkImage depth_image; + VkDeviceMemory depth_image_memory; + VkImageView depth_image_view; + + std::vector pipeline_3d; + std::vector pipeline_2d; + + Framebuffer(); + ~Framebuffer(); +}; + +} + +#endif /* CANDY_GEAR_VK_FRAMEBUFFER_H */ diff --git a/src/vk/graphics_pipeline_2d_solid.cpp b/src/vk/graphics_pipeline_2d_solid.cpp index 8432a8a..d0c1768 100644 --- a/src/vk/graphics_pipeline_2d_solid.cpp +++ b/src/vk/graphics_pipeline_2d_solid.cpp @@ -25,45 +25,6 @@ namespace { -void -load_framebuffer(void *obj) -{ - auto self = static_cast(obj); - - self->swapchain_framebuffers.resize(cg_core.vk_swapchain->images_count); - for (auto i{0}; i < cg_core.vk_swapchain->images_count; i++) - { - std::array attachments = { - cg_core.vk_swapchain->image_views[i] - }; - - VkFramebufferCreateInfo framebuffer_info{}; - framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - framebuffer_info.renderPass = cg_core.vk_render_pass->pipeline_2d; - framebuffer_info.attachmentCount = attachments.size(); - framebuffer_info.pAttachments = attachments.data(); - framebuffer_info.width = cg_core.display_width; - framebuffer_info.height = cg_core.display_height; - framebuffer_info.layers = 1; - - if(vkCreateFramebuffer( - cg_core.vk_device_with_swapchain->device, &framebuffer_info, nullptr, - &self->swapchain_framebuffers[i]) - != VK_SUCCESS) - throw CommandError{"Failed to create Vulkan Framebuffer."}; - } -} - -void -unload_framebuffer(void *obj) -{ - auto self = static_cast(obj); - - for(auto framebuffer: self->swapchain_framebuffers) - vkDestroyFramebuffer( - cg_core.vk_device_with_swapchain->device, framebuffer, nullptr); -} - void load_pipeline(void *obj) { @@ -253,7 +214,6 @@ unload_pipeline(void *obj) } const CommandChain loader{ - {&load_framebuffer, &unload_framebuffer}, {&load_pipeline, &unload_pipeline} }; diff --git a/src/vk/graphics_pipeline_2d_solid.hpp b/src/vk/graphics_pipeline_2d_solid.hpp index ec3c744..eac825f 100644 --- a/src/vk/graphics_pipeline_2d_solid.hpp +++ b/src/vk/graphics_pipeline_2d_solid.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 Frederico de Oliveira Linhares + * Copyright 2022-2023 Frederico de Oliveira Linhares * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,9 @@ #define CANDY_GEAR_VK_GRAPHICS_PIPELINE_2D_SOLID_H 1 #include -#include -#include #include "core.hpp" -#include "sprite.hpp" +#include "command_pool.hpp" #include "view_2d.hpp" namespace VK @@ -30,7 +28,6 @@ namespace VK struct GraphicsPipeline2DSolid { - std::vector swapchain_framebuffers; VkPipeline graphic_pipeline; GraphicsPipeline2DSolid(); diff --git a/src/vk/graphics_pipeline_2d_wired.cpp b/src/vk/graphics_pipeline_2d_wired.cpp index 6590508..ef43cd1 100644 --- a/src/vk/graphics_pipeline_2d_wired.cpp +++ b/src/vk/graphics_pipeline_2d_wired.cpp @@ -52,45 +52,6 @@ unload_indexes(void *obj) delete self->index_buffer; } -void -load_framebuffer(void *obj) -{ - auto self = static_cast(obj); - - self->swapchain_framebuffers.resize( - cg_core.vk_swapchain->images_count); - for (auto i{0}; i < cg_core.vk_swapchain->images_count; i++) - { - std::array attachments = { - cg_core.vk_swapchain->image_views[i] - }; - - VkFramebufferCreateInfo framebuffer_info{}; - framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - framebuffer_info.renderPass = cg_core.vk_render_pass->pipeline_2d; - framebuffer_info.attachmentCount = attachments.size(); - framebuffer_info.pAttachments = attachments.data(); - framebuffer_info.width = cg_core.display_width; - framebuffer_info.height = cg_core.display_height; - framebuffer_info.layers = 1; - - if(vkCreateFramebuffer( - cg_core.vk_device_with_swapchain->device, &framebuffer_info, nullptr, - &self->swapchain_framebuffers[i]) != VK_SUCCESS) - throw CommandError{"Failed to create Vulkan Framebuffer."}; - } -} - -void -unload_framebuffer(void *obj) -{ - auto self = static_cast(obj); - - for(auto framebuffer: self->swapchain_framebuffers) - vkDestroyFramebuffer( - cg_core.vk_device_with_swapchain->device, framebuffer, nullptr); -} - void load_pipeline(void *obj) { @@ -265,7 +226,6 @@ unload_pipeline(void *obj) const CommandChain loader{ {&load_indexes, &unload_indexes}, - {&load_framebuffer, &unload_framebuffer}, {&load_pipeline, &unload_pipeline} }; diff --git a/src/vk/graphics_pipeline_2d_wired.hpp b/src/vk/graphics_pipeline_2d_wired.hpp index 8c7765d..932ed61 100644 --- a/src/vk/graphics_pipeline_2d_wired.hpp +++ b/src/vk/graphics_pipeline_2d_wired.hpp @@ -18,8 +18,6 @@ #define CANDY_GEAR_VK_GRAPHICS_PIPELINE_2D_WIRED_H 1 #include -#include -#include #include "core.hpp" #include "view_2d.hpp" @@ -31,7 +29,6 @@ struct GraphicsPipeline2DWired { QueueFamily *queue_family; - std::vector swapchain_framebuffers; VkPipeline graphic_pipeline; DestinationBuffer *index_buffer; diff --git a/src/vk/graphics_pipeline_3d.cpp b/src/vk/graphics_pipeline_3d.cpp index a98db2c..43ab734 100644 --- a/src/vk/graphics_pipeline_3d.cpp +++ b/src/vk/graphics_pipeline_3d.cpp @@ -21,126 +21,12 @@ #include "../core.hpp" #include "core.hpp" -#include "image.hpp" #include "static_mesh_vertex.hpp" #include "uniform_data_object.hpp" namespace { -void -load_depth_image(void *obj) -{ - auto self = static_cast(obj); - - VkExtent3D extent3d{}; - extent3d.width = cg_core.display_width; - extent3d.height = cg_core.display_height; - extent3d.depth = 1; - - try - { - VK::Image::create( - cg_core.vk_device_with_swapchain, - &self->depth_image, - &self->depth_image_memory, - VK_FORMAT_D32_SFLOAT, - extent3d, - 1, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT - ); - } - catch(VK::Image::Error error) - { - std::string error_message{"Failed to create depth image → "}; - error_message += error.what(); - throw CommandError{error_message}; - } -} - -void -unload_depth_image(void *obj) -{ - auto self = static_cast(obj); - - vkDestroyImage( - cg_core.vk_device_with_swapchain->device, self->depth_image, - nullptr); - vkFreeMemory( - cg_core.vk_device_with_swapchain->device, - self->depth_image_memory, nullptr); -} - -void -load_depth_image_view(void *obj) -{ - auto self = static_cast(obj); - - try - { - VK::Image::create_view( - cg_core.vk_device_with_swapchain, &self->depth_image_view, - self->depth_image, - VK_FORMAT_D32_SFLOAT, VK_IMAGE_ASPECT_DEPTH_BIT); - } - catch(VK::Image::Error error) - { - std::string error_message{"Failed to create depth image view → "}; - error_message += error.what(); - throw CommandError{error_message}; - } -} - -void -unload_depth_image_view(void *obj) -{ - auto self = static_cast(obj); - - vkDestroyImageView( - cg_core.vk_device_with_swapchain->device, self->depth_image_view, nullptr); -} - -void -load_framebuffer(void *obj) -{ - auto self = static_cast(obj); - - self->swapchain_framebuffers.resize(cg_core.vk_swapchain->images_count); - for (auto i{0}; i < cg_core.vk_swapchain->images_count; i++) - { - std::array attachments = { - cg_core.vk_swapchain->image_views[i], - self->depth_image_view - }; - - VkFramebufferCreateInfo framebuffer_info{}; - framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - framebuffer_info.renderPass = cg_core.vk_render_pass->pipeline_3d; - framebuffer_info.attachmentCount = attachments.size(); - framebuffer_info.pAttachments = attachments.data(); - framebuffer_info.width = cg_core.display_width; - framebuffer_info.height = cg_core.display_height; - - framebuffer_info.layers = 1; - - if(vkCreateFramebuffer( - cg_core.vk_device_with_swapchain->device, &framebuffer_info, nullptr, - &self->swapchain_framebuffers[i]) != VK_SUCCESS) - throw CommandError{"Failed to create Vulkan Framebuffer."}; - } -} - -void -unload_framebuffer(void *obj) -{ - auto self = static_cast(obj); - - for(auto framebuffer: self->swapchain_framebuffers) - vkDestroyFramebuffer( - cg_core.vk_device_with_swapchain->device, framebuffer, nullptr); -} - void load_pipeline(void *obj) { @@ -350,9 +236,6 @@ unload_pipeline(void *obj) } const CommandChain loader{ - {&load_depth_image, &unload_depth_image}, - {&load_depth_image_view, &unload_depth_image_view}, - {&load_framebuffer, &unload_framebuffer}, {&load_pipeline, &unload_pipeline} }; diff --git a/src/vk/graphics_pipeline_3d.hpp b/src/vk/graphics_pipeline_3d.hpp index af09d28..bfe034d 100644 --- a/src/vk/graphics_pipeline_3d.hpp +++ b/src/vk/graphics_pipeline_3d.hpp @@ -18,7 +18,6 @@ #define CANDY_GEAR_VK_GRAPHICS_PIPELINE_3D_H 1 #include -#include #include "core.hpp" #include "command_pool.hpp" @@ -29,12 +28,6 @@ namespace VK struct GraphicsPipeline3D { - // Depth image. - VkImage depth_image; - VkDeviceMemory depth_image_memory; - VkImageView depth_image_view; - - std::vector swapchain_framebuffers; VkPipeline graphic_pipeline; GraphicsPipeline3D(); diff --git a/src/vk/graphics_pipeline_3d_skeletal.cpp b/src/vk/graphics_pipeline_3d_skeletal.cpp index 3386352..e0e75a9 100644 --- a/src/vk/graphics_pipeline_3d_skeletal.cpp +++ b/src/vk/graphics_pipeline_3d_skeletal.cpp @@ -21,126 +21,12 @@ #include "../core.hpp" #include "core.hpp" -#include "image.hpp" #include "skeletal_mesh_vertex.hpp" #include "uniform_data_object.hpp" namespace { -void -load_depth_image(void *obj) -{ - auto self = static_cast(obj); - - VkExtent3D extent3d{}; - extent3d.width = cg_core.display_width; - extent3d.height = cg_core.display_height; - extent3d.depth = 1; - - try - { - VK::Image::create( - cg_core.vk_device_with_swapchain, - &self->depth_image, - &self->depth_image_memory, - VK_FORMAT_D32_SFLOAT, - extent3d, - 1, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT - ); - } - catch(VK::Image::Error error) - { - std::string error_message{"Failed to create depth image → "}; - error_message += error.what(); - throw CommandError{error_message}; - } -} - -void -unload_depth_image(void *obj) -{ - auto self = static_cast(obj); - - vkDestroyImage( - cg_core.vk_device_with_swapchain->device, self->depth_image, - nullptr); - vkFreeMemory( - cg_core.vk_device_with_swapchain->device, - self->depth_image_memory, nullptr); -} - -void -load_depth_image_view(void *obj) -{ - auto self = static_cast(obj); - - try - { - VK::Image::create_view( - cg_core.vk_device_with_swapchain, &self->depth_image_view, - self->depth_image, - VK_FORMAT_D32_SFLOAT, VK_IMAGE_ASPECT_DEPTH_BIT); - } - catch(VK::Image::Error error) - { - std::string error_message{"Failed to create depth image view → "}; - error_message += error.what(); - throw CommandError{error_message}; - } -} - -void -unload_depth_image_view(void *obj) -{ - auto self = static_cast(obj); - - vkDestroyImageView( - cg_core.vk_device_with_swapchain->device, self->depth_image_view, nullptr); -} - -void -load_framebuffer(void *obj) -{ - auto self = static_cast(obj); - - self->swapchain_framebuffers.resize(cg_core.vk_swapchain->images_count); - for (auto i{0}; i < cg_core.vk_swapchain->images_count; i++) - { - std::array attachments = { - cg_core.vk_swapchain->image_views[i], - self->depth_image_view - }; - - VkFramebufferCreateInfo framebuffer_info{}; - framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - framebuffer_info.renderPass = cg_core.vk_render_pass->pipeline_3d; - framebuffer_info.attachmentCount = attachments.size(); - framebuffer_info.pAttachments = attachments.data(); - framebuffer_info.width = cg_core.display_width; - framebuffer_info.height = cg_core.display_height; - - framebuffer_info.layers = 1; - - if(vkCreateFramebuffer( - cg_core.vk_device_with_swapchain->device, &framebuffer_info, nullptr, - &self->swapchain_framebuffers[i]) != VK_SUCCESS) - throw CommandError{"Failed to create Vulkan Framebuffer."}; - } -} - -void -unload_framebuffer(void *obj) -{ - auto self = static_cast(obj); - - for(auto framebuffer: self->swapchain_framebuffers) - vkDestroyFramebuffer( - cg_core.vk_device_with_swapchain->device, framebuffer, nullptr); -} - void load_pipeline(void *obj) { @@ -360,9 +246,6 @@ unload_pipeline(void *obj) } const CommandChain loader{ - {&load_depth_image, &unload_depth_image}, - {&load_depth_image_view, &unload_depth_image_view}, - {&load_framebuffer, &unload_framebuffer}, {&load_pipeline, &unload_pipeline} }; diff --git a/src/vk/graphics_pipeline_3d_skeletal.hpp b/src/vk/graphics_pipeline_3d_skeletal.hpp index fa9226a..027b42e 100644 --- a/src/vk/graphics_pipeline_3d_skeletal.hpp +++ b/src/vk/graphics_pipeline_3d_skeletal.hpp @@ -18,7 +18,6 @@ #define CANDY_GEAR_VK_GRAPHICS_PIPELINE_3D_SKELETAL_H 1 #include -#include #include "core.hpp" #include "command_pool.hpp" @@ -29,12 +28,6 @@ namespace VK struct GraphicsPipeline3DSkeletal { - // Depth image. - VkImage depth_image; - VkDeviceMemory depth_image_memory; - VkImageView depth_image_view; - - std::vector swapchain_framebuffers; VkPipeline graphic_pipeline; GraphicsPipeline3DSkeletal(); diff --git a/src/vk/renderer.cpp b/src/vk/renderer.cpp index 3497db9..766690f 100644 --- a/src/vk/renderer.cpp +++ b/src/vk/renderer.cpp @@ -229,7 +229,7 @@ Renderer::draw() render_pass_begin.pNext = nullptr; render_pass_begin.renderPass = cg_core.vk_render_pass->pipeline_3d; render_pass_begin.framebuffer = - cg_core.vk_graphics_pipeline_3d->swapchain_framebuffers[image_index]; + cg_core.vk_framebuffer->pipeline_3d[image_index]; render_pass_begin.renderArea.offset = {0, 0}; render_pass_begin.renderArea.extent = { static_cast(cg_core.display_width), @@ -254,8 +254,7 @@ Renderer::draw() render_pass_begin.pNext = nullptr; render_pass_begin.renderPass = cg_core.vk_render_pass->pipeline_2d; render_pass_begin.framebuffer = - cg_core.vk_graphics_pipeline_2d_solid->swapchain_framebuffers[ - image_index]; + cg_core.vk_framebuffer->pipeline_2d[image_index]; render_pass_begin.renderArea.offset = {0, 0}; render_pass_begin.renderArea.extent = { static_cast(cg_core.display_width), -- cgit v1.2.3