vsg: include/vsg/vk/RenderPass.h Source File

vsg 1.1.9 VulkanSceneGraph library |

Loading...
Searching...
No Matches
RenderPass.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/vk/Device.h>
16
17namespace vsg
18{
20 struct AttachmentDescription
21 {
22 VkAttachmentDescriptionFlags flags;
23 VkFormat format;
24 VkSampleCountFlagBits samples;
25 VkAttachmentLoadOp loadOp;
26 VkAttachmentStoreOp storeOp;
27 VkAttachmentLoadOp stencilLoadOp;
28 VkAttachmentStoreOp stencilStoreOp;
29 VkImageLayout initialLayout;
30 VkImageLayout finalLayout;
31 };
32 VSG_type_name(vsg::AttachmentDescription);
33
35 struct SubpassDependency
36 {
37 uint32_t srcSubpass = 0;
38 uint32_t dstSubpass = 0;
39 VkPipelineStageFlags srcStageMask;
40 VkPipelineStageFlags dstStageMask;
41 VkAccessFlags srcAccessMask;
42 VkAccessFlags dstAccessMask;
43 VkDependencyFlags dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
44
46 int32_t viewOffset = 0;
47 };
48 VSG_type_name(vsg::SubpassDependency);
49
51 struct AttachmentReference
52 {
53 uint32_t attachment = 0;
54 VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
55
57 VkImageAspectFlags aspectMask = 0;
58 };
59 VSG_type_name(vsg::AttachmentReference);
60
62 struct SubpassDescription
63 {
64 VkSubpassDescriptionFlags flags = 0;
65 VkPipelineBindPoint pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
66
67 std::vector<AttachmentReference> inputAttachments;
68 std::vector<AttachmentReference> colorAttachments;
69 std::vector<AttachmentReference> resolveAttachments;
70 std::vector<AttachmentReference> depthStencilAttachments;
71
72 std::vector<uint32_t> preserveAttachments;
73
75 uint32_t viewMask = 0;
76
78 VkResolveModeFlagBits depthResolveMode = VK_RESOLVE_MODE_NONE;
79 VkResolveModeFlagBits stencilResolveMode = VK_RESOLVE_MODE_NONE;
80 std::vector<AttachmentReference> depthStencilResolveAttachments;
81 };
82 VSG_type_name(vsg::SubpassDescription);
83
85 class VSG_DECLSPEC RenderPass : public Inherit<Object, RenderPass>
86 {
87 public:
88 using Attachments = std::vector<AttachmentDescription>;
89 using Subpasses = std::vector<SubpassDescription>;
90 using Dependencies = std::vector<SubpassDependency>;
91 using CorrelatedViewMasks = std::vector<uint32_t>;
92
93 RenderPass(Device* in_device, const Attachments& in_attachments, const Subpasses& in_subpasses, const Dependencies& in_dependencies, const CorrelatedViewMasks& in_correlatedViewMasks = {});
94
95 operator VkRenderPass() const { return _renderPass; }
96 VkRenderPass vk() const { return _renderPass; }
97
98 // configuration of RenderPass used when creating vkRenderPass
99 const ref_ptr<Device> device;
100 const Attachments attachments;
101 const Subpasses subpasses;
102 const Dependencies dependencies;
103 const CorrelatedViewMasks correlatedViewMasks;
104
107 const VkSampleCountFlagBits maxSamples;
108
109 protected:
110 virtual ~RenderPass();
111
113 VkRenderPass _renderPass;
114 };
115 VSG_type_name(vsg::RenderPass);
116
117 extern VSG_DECLSPEC AttachmentDescription defaultColorAttachment(VkFormat imageFormat);
118 extern VSG_DECLSPEC AttachmentDescription defaultDepthAttachment(VkFormat depthFormat);
119
121 extern VSG_DECLSPEC ref_ptr<RenderPass> createRenderPass(Device* device, VkFormat imageFormat, VkFormat depthFormat, bool requiresDepthRead = false);
122
124 extern VSG_DECLSPEC ref_ptr<RenderPass> createMultisampledRenderPass(Device* device, VkFormat imageFormat, VkFormat depthFormat, VkSampleCountFlagBits samples, bool requiresDepthRead = false);
125
127 extern VSG_DECLSPEC ref_ptr<RenderPass> createRenderPass(Device* device, VkFormat imageFormat);
128
130 extern VSG_DECLSPEC ref_ptr<RenderPass> createMultisampledRenderPass(Device* device, VkFormat imageFormat, VkSampleCountFlagBits samples);
131
132} // namespace vsg
vsg::Device
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition Device.h:39
vsg::RenderPass
RenderPass encapsulation of VkRenderPass.
Definition RenderPass.h:86
vsg::RenderPass::maxSamples
const VkSampleCountFlagBits maxSamples
Definition RenderPass.h:107
vsg::RenderPass::_renderPass
VkRenderPass _renderPass
Vulkan renderPass handle, created in RenderPass constructor.
Definition RenderPass.h:113
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::AttachmentDescription
AttachmentDescription is used by RenderPass to specify VkAttachmentDescription settings.
Definition RenderPass.h:21
vsg::AttachmentReference
AttachmentReference is used by RenderPass to specify VkAttachmentReference settings.
Definition RenderPass.h:52
vsg::AttachmentReference::aspectMask
VkImageAspectFlags aspectMask
multiview support requires Vulkan 1.2 or later.
Definition RenderPass.h:57
vsg::SubpassDependency
SubpassDependency is used by RenderPass to specify VkSubpassDependency settings.
Definition RenderPass.h:36
vsg::SubpassDependency::viewOffset
int32_t viewOffset
multiview support requires Vulkan 1.2 or later.
Definition RenderPass.h:46
vsg::SubpassDescription
SubpassDescription is used by RenderPass to specify VkSubpassDescription settings.
Definition RenderPass.h:63
vsg::SubpassDescription::depthResolveMode
VkResolveModeFlagBits depthResolveMode
maps to VkSubpassDescriptionDepthStencilResolve, requires Vulkan 1.2 or later or an extension.
Definition RenderPass.h:78
vsg::SubpassDescription::viewMask
uint32_t viewMask
multiview support requires Vulkan 1.2 or later.
Definition RenderPass.h:75