From b35dbd3450904e5300f96f6e650d38964078fca7 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 23 Jul 2020 20:41:58 -0700 Subject: Implemented RenderPassAttachmentDesc struct; added render pass creation test; WIP implementation of render pass initialization in Vulkan --- .../include/VulkanTypeConversions.hpp | 6 ++++ .../GraphicsEngineVulkan/src/RenderPassVkImpl.cpp | 33 +++++++++++++++++++++- .../src/VulkanTypeConversions.cpp | 20 +++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.hpp b/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.hpp index 15420ead..c680c22d 100644 --- a/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.hpp +++ b/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.hpp @@ -73,4 +73,10 @@ RESOURCE_STATE VkImageLayoutToResourceState(VkImageLayout Layout); SURFACE_TRANSFORM VkSurfaceTransformFlagToSurfaceTransform(VkSurfaceTransformFlagBitsKHR vkTransformFlag); VkSurfaceTransformFlagBitsKHR SurfaceTransformToVkSurfaceTransformFlag(SURFACE_TRANSFORM SrfTransform); +VkAttachmentLoadOp AttachmentLoadOpToVkAttachmentLoadOp(ATTACHMENT_LOAD_OP LoadOp); +ATTACHMENT_LOAD_OP VkAttachmentLoadOpToAttachmentLoadOp(VkAttachmentLoadOp VkLoadOp); + +VkAttachmentStoreOp AttachmentStoreOpToVkAttachmentStoreOp(ATTACHMENT_STORE_OP StoreOp); +ATTACHMENT_STORE_OP VkAttachmentStoreOpToAttachmentStoreOp(VkAttachmentStoreOp VkStoreOp); + } // namespace Diligent diff --git a/Graphics/GraphicsEngineVulkan/src/RenderPassVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderPassVkImpl.cpp index 7ea5b8b9..4483fcdc 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderPassVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderPassVkImpl.cpp @@ -26,9 +26,10 @@ */ #include "pch.h" +#include #include "RenderPassVkImpl.hpp" -#include "EngineMemory.h" +#include "VulkanTypeConversions.hpp" namespace Diligent { @@ -38,6 +39,36 @@ RenderPassVkImpl::RenderPassVkImpl(IReferenceCounters* pRefCounters, const RenderPassDesc& Desc) : TRenderPassBase{pRefCounters, pDevice, Desc} { + VkRenderPassCreateInfo RenderPassCI = {}; + + RenderPassCI.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; + RenderPassCI.pNext = nullptr; + RenderPassCI.flags = 0; + + std::array vkAttachments = {}; + for (Uint32 i = 0; i < m_Desc.AttachmentCount; ++i) + { + const auto& Attachment = m_Desc.pAttachments[i]; + auto& vkAttachment = vkAttachments[i]; + vkAttachment.flags = 0; + vkAttachment.format = TexFormatToVkFormat(Attachment.Format); + vkAttachment.samples = static_cast(0x01 << Attachment.SampleCount); + vkAttachment.loadOp = AttachmentLoadOpToVkAttachmentLoadOp(Attachment.LoadOp); + vkAttachment.storeOp = AttachmentStoreOpToVkAttachmentStoreOp(Attachment.StoreOp); + vkAttachment.stencilLoadOp = AttachmentLoadOpToVkAttachmentLoadOp(Attachment.StencilLoadOp); + vkAttachment.stencilStoreOp = AttachmentStoreOpToVkAttachmentStoreOp(Attachment.StencilStoreOp); + vkAttachment.initialLayout = ResourceStateToVkImageLayout(Attachment.InitialState); + vkAttachment.finalLayout = ResourceStateToVkImageLayout(Attachment.FinalState); + } + RenderPassCI.attachmentCount = Desc.AttachmentCount; + RenderPassCI.pAttachments = vkAttachments.data(); + + + RenderPassCI.subpassCount = Desc.SubpassCount; + RenderPassCI.pSubpasses; + + RenderPassCI.dependencyCount = Desc.DependencyCount; + RenderPassCI.pDependencies; } RenderPassVkImpl::~RenderPassVkImpl() diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp index d5e4f48b..592f9522 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp @@ -1421,4 +1421,24 @@ VkSurfaceTransformFlagBitsKHR SurfaceTransformToVkSurfaceTransformFlag(SURFACE_T // clang-format on } +VkAttachmentLoadOp AttachmentLoadOpToVkAttachmentLoadOp(ATTACHMENT_LOAD_OP LoadOp) +{ + return static_cast(LoadOp); +} + +ATTACHMENT_LOAD_OP VkAttachmentLoadOpToAttachmentLoadOp(VkAttachmentLoadOp VkLoadOp) +{ + return static_cast(VkLoadOp); +} + +VkAttachmentStoreOp AttachmentStoreOpToVkAttachmentStoreOp(ATTACHMENT_STORE_OP StoreOp) +{ + return static_cast(StoreOp); +} + +ATTACHMENT_STORE_OP VkAttachmentStoreOpToAttachmentStoreOp(VkAttachmentStoreOp VkStoreOp) +{ + return static_cast(VkStoreOp); +} + } // namespace Diligent -- cgit v1.2.3