vsg 1.1.3
VulkanSceneGraph library
Loading...
Searching...
No Matches
RenderGraph.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/nodes/Group.h>
16
17#include <vsg/app/Camera.h>
18#include <vsg/app/Window.h>
19#include <vsg/app/WindowResizeHandler.h>
20
21namespace vsg
22{
23
27 class VSG_DECLSPEC RenderGraph : public Inherit<Group, RenderGraph>
28 {
29 public:
31
33 explicit RenderGraph(ref_ptr<Window> in_window, ref_ptr<View> view = {});
34
35 using Group::accept;
36
38 void accept(RecordTraversal& recordTraversal) const override;
39
42 ref_ptr<Window> window;
43
46
48 VkExtent2D getExtent() const;
49
51 VkRect2D renderArea;
52
55
57 using ClearValues = std::vector<VkClearValue>;
58 ClearValues clearValues; // initialize window colour and depth/stencil
59
62 void setClearValues(VkClearColorValue clearColor = {{0.2f, 0.2f, 0.4f, 1.0f}}, VkClearDepthStencilValue clearDepthStencil = {0.0f, 0});
63
65 VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE;
66
70
72 void resized();
73
75 constexpr static uint32_t invalid_dimension = std::numeric_limits<uint32_t>::max();
76 mutable VkExtent2D previous_extent = VkExtent2D{invalid_dimension, invalid_dimension};
77 };
78 VSG_type_name(vsg::RenderGraph);
79
82 extern VSG_DECLSPEC ref_ptr<RenderGraph> createRenderGraphForView(ref_ptr<Window> window, ref_ptr<Camera> camera, ref_ptr<Node> scenegraph, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE, bool assignHeadlight = true);
83
84} // namespace vsg
Definition Inherit.h:28
RecordTraversal traverses a scene graph doing view frustum culling and invoking state/commands to rec...
Definition RecordTraversal.h:69
Definition RenderGraph.h:28
void resized()
invoke the WindowResizeHandler, called automatically when a window dimension change is detected.
RenderPass * getRenderPass()
RenderPass to use passed to the vkCmdBeginRenderPass, if renderPass is set it takes precedence,...
VkRect2D renderArea
RenderArea settings for VkRenderPassBeginInfo.renderArea passed to the vkCmdBeginRenderPass,...
Definition RenderGraph.h:51
std::vector< VkClearValue > ClearValues
Buffer clearing settings for VkRenderPassBeginInfo.clearValueCount & VkRenderPassBeginInfo....
Definition RenderGraph.h:57
RenderGraph(ref_ptr< Window > in_window, ref_ptr< View > view={})
Construct RenderGraph assigning window and setting up clearValues with the appropriate settings for t...
VkExtent2D getExtent() const
Get the Extent2D of the attached Framebuffer or Window.
void accept(RecordTraversal &recordTraversal) const override
execute vkCmdBeginRenderPass and then traverse the RenderGraph subgraph
ref_ptr< RenderPass > renderPass
RenderPass to use passed to the vkCmdBeginRenderPass in place of the framebuffer's or window's render...
Definition RenderGraph.h:54
ref_ptr< WindowResizeHandler > windowResizeHandler
Definition RenderGraph.h:69
ref_ptr< Framebuffer > framebuffer
either window or framebuffer must be assigned. If framebuffer is set then it takes precedence,...
Definition RenderGraph.h:41
void setClearValues(VkClearColorValue clearColor={{0.2f, 0.2f, 0.4f, 1.0f}}, VkClearDepthStencilValue clearDepthStencil={0.0f, 0})
RenderPass encapsulation of VkRenderPass.
Definition RenderPass.h:86
Definition ref_ptr.h:22