Вынес управление VkRenderPass в отдельный класс
This commit is contained in:
@@ -31,47 +31,6 @@ VkShaderModule UwURenderEngine::create_shader_module(const std::string& code) co
|
||||
}
|
||||
|
||||
|
||||
void UwURenderEngine::create_render_pass()
|
||||
{
|
||||
VkAttachmentDescription attachment_description{};
|
||||
attachment_description.format = swapchain_.get_image_format();
|
||||
attachment_description.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
attachment_description.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
attachment_description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachment_description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachment_description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachment_description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
attachment_description.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
|
||||
VkAttachmentReference attachment_reference;
|
||||
attachment_reference.attachment = 0;
|
||||
attachment_reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
|
||||
VkSubpassDescription subpass_description{};
|
||||
subpass_description.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
subpass_description.colorAttachmentCount = 1;
|
||||
subpass_description.pColorAttachments = &attachment_reference;
|
||||
|
||||
VkSubpassDependency dependency{};
|
||||
dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependency.dstSubpass = 0;
|
||||
dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
dependency.srcAccessMask = 0;
|
||||
dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
|
||||
VkRenderPassCreateInfo render_pass_info{};
|
||||
render_pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
render_pass_info.attachmentCount = 1;
|
||||
render_pass_info.pAttachments = &attachment_description;
|
||||
render_pass_info.subpassCount = 1;
|
||||
render_pass_info.pSubpasses = &subpass_description;
|
||||
render_pass_info.dependencyCount = 1;
|
||||
render_pass_info.pDependencies = &dependency;
|
||||
|
||||
VK_CHECK(vkCreateRenderPass(device_.get_native(), &render_pass_info, nullptr, &render_pass_))
|
||||
}
|
||||
|
||||
void UwURenderEngine::create_description_set_layout()
|
||||
{
|
||||
VkDescriptorSetLayoutBinding ubo_layout_binding;
|
||||
@@ -287,7 +246,7 @@ void UwURenderEngine::create_graphics_pipeline()
|
||||
graphics_pipeline_info.pViewportState = &viewport_info;
|
||||
graphics_pipeline_info.pVertexInputState = &vertex_input_info;
|
||||
graphics_pipeline_info.pDepthStencilState = nullptr;
|
||||
graphics_pipeline_info.renderPass = render_pass_;
|
||||
graphics_pipeline_info.renderPass = render_pass_.get_native();
|
||||
graphics_pipeline_info.subpass = 0;
|
||||
graphics_pipeline_info.basePipelineHandle = nullptr;
|
||||
graphics_pipeline_info.basePipelineIndex = -1;
|
||||
@@ -304,7 +263,7 @@ void UwURenderEngine::create_framebuffers()
|
||||
|
||||
VkFramebufferCreateInfo framebuffer_info{};
|
||||
framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||
framebuffer_info.renderPass = render_pass_;
|
||||
framebuffer_info.renderPass = render_pass_.get_native();
|
||||
framebuffer_info.attachmentCount = 1;
|
||||
framebuffer_info.width = swapchain_.get_extent().width;
|
||||
framebuffer_info.height = swapchain_.get_extent().height;
|
||||
@@ -433,7 +392,7 @@ void UwURenderEngine::record_command_buffer(VkCommandBuffer command_buffer, uint
|
||||
constexpr VkClearValue clear_color = {{{0.0f, 0.0f, 0.0f, 1.0f}}};
|
||||
VkRenderPassBeginInfo render_pass_begin_info{};
|
||||
render_pass_begin_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||
render_pass_begin_info.renderPass = render_pass_;
|
||||
render_pass_begin_info.renderPass = render_pass_.get_native();
|
||||
render_pass_begin_info.framebuffer = framebuffers_[image_index];
|
||||
render_pass_begin_info.renderArea.offset = {0, 0};
|
||||
render_pass_begin_info.renderArea.extent = swapchain_.get_extent();
|
||||
@@ -551,9 +510,9 @@ instance_(core),
|
||||
surface_(instance_, get_window()),
|
||||
physical_device_(instance_, surface_, deviceExtensions),
|
||||
device_(physical_device_, deviceExtensions),
|
||||
swapchain_(surface_, physical_device_, device_, get_window())
|
||||
swapchain_(surface_, physical_device_, device_, get_window()),
|
||||
render_pass_(device_, swapchain_)
|
||||
{
|
||||
create_render_pass();
|
||||
create_description_set_layout();
|
||||
create_uniform_buffers();
|
||||
create_descriptor_pool();
|
||||
@@ -624,9 +583,6 @@ UwURenderEngine::~UwURenderEngine()
|
||||
|
||||
if (ubo_layout_binding_ != VK_NULL_HANDLE)
|
||||
vkDestroyDescriptorSetLayout(device_.get_native(), ubo_layout_binding_, nullptr);
|
||||
|
||||
if (render_pass_ != VK_NULL_HANDLE)
|
||||
vkDestroyRenderPass(device_.get_native(), render_pass_, nullptr);
|
||||
}
|
||||
|
||||
void UwURenderEngine::start()
|
||||
|
||||
Reference in New Issue
Block a user