Files
LearningVulkan/src/private/VulkanRenderPass.cpp
Jordan Arch 11ac560009 Triangle posting
https://vulkan-tutorial.com/Vertex_buffers/Staging_buffer

Reached the above part of the tutorial. Adding IMGUI now before
continuing.
2026-02-17 18:37:38 -05:00

61 lines
2.0 KiB
C++

#include "VulkanRenderPass.h"
#include "utilities/Logger.h"
void VulkanRenderPass::Initialize(VkDevice InDevice)
{
Device = InDevice;
}
void VulkanRenderPass::Cleanup()
{
vkDestroyRenderPass(Device, RenderPass, nullptr);
}
void VulkanRenderPass::CreateRenderPass(VkFormat SwapChainImageFormat)
{
VkAttachmentDescription ColorAttachment{};
ColorAttachment.format = SwapChainImageFormat;
ColorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
ColorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
ColorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
ColorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
ColorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
ColorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
ColorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
VkAttachmentReference ColorAttachmentRef{};
ColorAttachmentRef.attachment = 0;
ColorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkSubpassDescription Subpass{};
Subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
Subpass.colorAttachmentCount = 1;
Subpass.pColorAttachments = &ColorAttachmentRef;
VkRenderPassCreateInfo RenderPassInfo{};
RenderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
RenderPassInfo.attachmentCount = 1;
RenderPassInfo.pAttachments = &ColorAttachment;
RenderPassInfo.subpassCount = 1;
RenderPassInfo.pSubpasses = &Subpass;
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;
RenderPassInfo.dependencyCount = 1;
RenderPassInfo.pDependencies = &Dependency;
if (vkCreateRenderPass(Device, &RenderPassInfo, nullptr, &RenderPass) != VK_SUCCESS)
{
Log::Error("Failed to create render pass!");
}
else
{
Log::Info("Successfully created render pass.");
}
}