summaryrefslogtreecommitdiff
path: root/src/vk/graphics_pipeline_3d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vk/graphics_pipeline_3d.cpp')
-rw-r--r--src/vk/graphics_pipeline_3d.cpp96
1 files changed, 4 insertions, 92 deletions
diff --git a/src/vk/graphics_pipeline_3d.cpp b/src/vk/graphics_pipeline_3d.cpp
index 04a2adb..de5adde 100644
--- a/src/vk/graphics_pipeline_3d.cpp
+++ b/src/vk/graphics_pipeline_3d.cpp
@@ -22,7 +22,6 @@
#include "../core.hpp"
#include "core.hpp"
#include "image.hpp"
-#include "uniform_buffer.hpp"
#include "vertex_3d.hpp"
namespace
@@ -371,92 +370,6 @@ unload_depth_image_view(void *obj)
}
void
-load_render_pass(void *obj)
-{
- auto self = static_cast<VK::GraphicsPipeline3D*>(obj);
-
- std::array<VkAttachmentDescription, 2> attachments{};
- // Color attachment.
- attachments[0].flags = 0;
- attachments[0].format = cg_core.vk_swapchain->image_format;
- attachments[0].samples = VK_SAMPLE_COUNT_1_BIT;
- attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
- attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
- attachments[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- attachments[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
- attachments[0].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- attachments[0].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- // Depth attachment.
- attachments[1].flags = 0;
- attachments[1].format = VK_FORMAT_D32_SFLOAT;
- attachments[1].samples = VK_SAMPLE_COUNT_1_BIT;
- attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
- attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
- attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- attachments[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
- attachments[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- attachments[1].finalLayout =
- VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
-
- VkAttachmentReference color_attachment_ref{};
- color_attachment_ref.attachment = 0;
- color_attachment_ref.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- VkAttachmentReference depth_attachment_ref{};
- depth_attachment_ref.attachment = 1;
- depth_attachment_ref.layout =
- VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
-
- VkSubpassDescription subpass = {};
- subpass.flags = 0;
- subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
- subpass.inputAttachmentCount = 0;
- subpass.pInputAttachments = nullptr;
- subpass.colorAttachmentCount = 1;
- subpass.pColorAttachments = &color_attachment_ref;
- subpass.pResolveAttachments = nullptr;
- subpass.pDepthStencilAttachment = &depth_attachment_ref;
- subpass.preserveAttachmentCount = 0;
- subpass.pPreserveAttachments = nullptr;
-
- VkSubpassDependency dependency = {};
- dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
- dependency.dstSubpass = 0;
- dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
- VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
- dependency.srcAccessMask = 0;
- dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
- VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
- dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
-
- VkRenderPassCreateInfo render_pass_info{};
- render_pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
- render_pass_info.pNext = nullptr;
- render_pass_info.flags = 0;
- render_pass_info.attachmentCount = attachments.size();
- render_pass_info.pAttachments = attachments.data();
- render_pass_info.subpassCount = 1;
- render_pass_info.pSubpasses = &subpass;
- render_pass_info.dependencyCount = 1;
- render_pass_info.pDependencies = &dependency;
-
- if(vkCreateRenderPass(
- cg_core.vk_device_with_swapchain->device, &render_pass_info,
- nullptr, &self->render_pass) != VK_SUCCESS)
- throw CommandError{"Failed to create Vulkan Render Pass."};
-}
-
-void
-unload_render_pass(void *obj)
-{
- auto self = static_cast<VK::GraphicsPipeline3D*>(obj);
-
- vkDestroyRenderPass(
- cg_core.vk_device_with_swapchain->device, self->render_pass, nullptr);
-}
-
-void
load_framebuffer(void *obj)
{
auto self = static_cast<VK::GraphicsPipeline3D*>(obj);
@@ -471,7 +384,7 @@ load_framebuffer(void *obj)
VkFramebufferCreateInfo framebuffer_info{};
framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
- framebuffer_info.renderPass = self->render_pass;
+ framebuffer_info.renderPass = cg_core.vk_render_pass_3d;
framebuffer_info.attachmentCount = attachments.size();
framebuffer_info.pAttachments = attachments.data();
framebuffer_info.width = cg_core.screen_width;
@@ -683,7 +596,7 @@ load_pipeline(void *obj)
pipeline_info.pColorBlendState = &color_blending;
pipeline_info.pDynamicState = &dynamic_state_info;
pipeline_info.layout = self->pipeline_layout;
- pipeline_info.renderPass = self->render_pass;
+ pipeline_info.renderPass = cg_core.vk_render_pass_3d;
pipeline_info.subpass = 0;
pipeline_info.basePipelineHandle = VK_NULL_HANDLE;
pipeline_info.basePipelineIndex = -1;
@@ -719,7 +632,6 @@ const CommandChain loader{
{&load_resources_to_descriptor_sets, nullptr},
{&load_depth_image, &unload_depth_image},
{&load_depth_image_view, &unload_depth_image_view},
- {&load_render_pass, &unload_render_pass},
{&load_framebuffer, &unload_framebuffer},
{&load_pipeline, &unload_pipeline}
};
@@ -757,7 +669,7 @@ GraphicsPipeline3D::draw(
VkRenderPassBeginInfo render_pass_begin{};
render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
render_pass_begin.pNext = nullptr;
- render_pass_begin.renderPass = this->render_pass;
+ render_pass_begin.renderPass = cg_core.vk_render_pass_3d;
render_pass_begin.framebuffer = this->swapchain_framebuffers[image_index];
render_pass_begin.renderArea.offset = {0, 0};
render_pass_begin.renderArea.extent = {
@@ -766,7 +678,7 @@ GraphicsPipeline3D::draw(
render_pass_begin.pClearValues = clear_values.data();
vkCmdBeginRenderPass(
- draw_command_buffer, &render_pass_begin,VK_SUBPASS_CONTENTS_INLINE);
+ draw_command_buffer, &render_pass_begin, VK_SUBPASS_CONTENTS_INLINE);
VkViewport vk_viewport{};
vk_viewport.width = static_cast<float>(cg_core.screen_width);