VPP  0.8
A high-level modern C++ API for Vulkan
vppRenderGraphNodes.hpp
1 /*
2  Copyright 2016-2018 SOFT-ERG, Przemek Kuczmierczyk (www.softerg.com)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 // -----------------------------------------------------------------------------
28 namespace vpp {
29 // -----------------------------------------------------------------------------
30 
73 template< class FormatT >
75 {
76 public:
87  Attachment (
88  std::uint32_t width,
89  std::uint32_t height,
90  EImagePurpose imagePurpose = RENDER );
91 
99  Attachment (
100  RenderGraph* pGraph,
101  std::uint32_t width,
102  std::uint32_t height,
103  EImagePurpose imagePurpose = RENDER );
104 
115  template< class ViewT >
116  Attachment (
117  const ViewT& imageView );
118 
128  template< class ViewT >
129  Attachment (
130  RenderGraph* pGraph,
131  const ViewT& imageView );
132 
134  RenderGraph* graph() const;
135 
137  std::uint32_t index() const;
138 
140  std::uint32_t width() const;
141 
143  std::uint32_t height() const;
144 };
145 
146 // -----------------------------------------------------------------------------
147 // -----------------------------------------------------------------------------
148 
160 class Display
161 {
162 public:
163  Display (
164  const Surface& hSurface );
165 
166  Display (
167  RenderGraph* pGraph,
168  const Surface& hSurface );
169 
170  RenderGraph* graph() const;
171  std::uint32_t index() const;
172  std::uint32_t width() const;
173  std::uint32_t height() const;
174 };
175 
176 // -----------------------------------------------------------------------------
177 // -----------------------------------------------------------------------------
178 
231 class Process
232 {
233 public:
241  Process();
242 
248  Process ( RenderGraph* pGraph );
249 
256  Process ( RenderGraph* pGraph, std::uint32_t index );
257 
265  std::uint32_t index() const;
266 
270  RenderGraph* graph() const;
271 
291  template< class FormatT >
292  void addColorOutput (
293  const Attachment< FormatT >& d,
294  const typename FormatT::init_type& initValue,
295  VkImageLayout destLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL );
296 
308  template< class FormatT >
309  void addReusedColorOutput (
310  const Attachment< FormatT >& d,
311  VkImageLayout destLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL );
312 
317  void addColorOutput ( const Display& d );
318 
326  void addColorOutput ( const Display& d, const VkClearColorValue& color );
327 
342  template< class FormatT >
343  void setDepthOutput (
344  const Attachment< FormatT >& d,
345  const typename FormatT::init_type& initValue,
346  VkImageLayout preserveInLayout = VK_IMAGE_LAYOUT_UNDEFINED );
347 
364  template< class FormatT >
365  void setReusedDepthOutput (
366  const Attachment< FormatT >& d,
367  VkImageLayout preserveInLayout = VK_IMAGE_LAYOUT_UNDEFINED );
368 
380  template< class FormatT >
381  void setDepthInput ( const Attachment< FormatT >& d );
382 
383  template< class FormatT >
384  void addColorAndResolveOutput (
385  const Attachment< FormatT >& dc,
386  const Attachment< FormatT >& dr,
387  const typename FormatT::init_type& initValue );
388 
389  void addPreservedOutput ( const BaseAttachment& d );
390 
421  template< class FormatT >
422  void addInput (
423  const Attachment< FormatT >& d,
424  VkImageLayout nodeImageLayout = VK_IMAGE_LAYOUT_GENERAL,
425  bool bAddDependency = true );
426 
436  void addDependency (
437  const Process& targetProcess,
438  const VkSubpassDependency& dependency );
439 };
440 
441 // -----------------------------------------------------------------------------
463 {
464 public:
472  Preprocess();
473 
479  Preprocess ( RenderGraph* pGraph );
480 
487  std::uint32_t index() const;
488 
492  RenderGraph* graph() const;
493 };
494 
495 // -----------------------------------------------------------------------------
507 {
508 public:
516  Postprocess();
517 
523  Postprocess ( RenderGraph* pGraph );
524 
530  std::uint32_t index() const;
531 
535  RenderGraph* graph() const;
536 };
537 
538 // -----------------------------------------------------------------------------
539 
544 void operator<< ( const Process& target, const std::function< void () >& cmds );
545 
550 void operator<< ( const Preprocess& target, const std::function< void () >& cmds );
551 
555 void operator<< ( const Postprocess& target, const std::function< void () >& cmds );
556 
557 // -----------------------------------------------------------------------------
558 } // namespace vpp
559 // -----------------------------------------------------------------------------
std::uint32_t width() const
Retrieves image width of the attachment.
void setDepthOutput(const Attachment< FormatT > &d, const typename FormatT::init_type &initValue, VkImageLayout preserveInLayout=VK_IMAGE_LAYOUT_UNDEFINED)
Sets depth attachment to be produced from scratch. Any previous content of the attachment is destroye...
Process()
Constructs process node for currently defined graph.
RenderGraph * graph() const
Retrieves the parent render graph object.
Represents preparation process graph node.
Definition: vppRenderGraphNodes.hpp:462
RenderGraph * graph() const
Retrieves the parent render graph.
Attachment(std::uint32_t width, std::uint32_t height, EImagePurpose imagePurpose=RENDER)
Constructs attachment mode without fixed image view.
The VPP namespace.
Definition: main.hpp:1
Represents attachment graph node.
Definition: vppRenderGraphNodes.hpp:74
void setReusedDepthOutput(const Attachment< FormatT > &d, VkImageLayout preserveInLayout=VK_IMAGE_LAYOUT_UNDEFINED)
Sets depth attachment which has been already filled by previous render passes, to be modified by this...
void addColorOutput(const Attachment< FormatT > &d, const typename FormatT::init_type &initValue, VkImageLayout destLayout=VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
Adds color output attachment to be produced from scratch. Any previous content of the attachment is d...
Represents process graph node.
Definition: vppRenderGraphNodes.hpp:231
Represents a surface visible on the screen.
Definition: vppSurface.hpp:59
std::uint32_t index() const
Retrieves the index of the Process node.
void addDependency(const Process &targetProcess, const VkSubpassDependency &dependency)
Adds a dependency arc from current process to specified process.
std::uint32_t height() const
Retrieves image height of the attachment.
void addReusedColorOutput(const Attachment< FormatT > &d, VkImageLayout destLayout=VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
Adds color output attachment which has been already filled by previous render passes, to be modified by this render pass.
std::uint32_t index() const
Retrieves the index of the Postprocess node.
Represents finalization process graph node.
Definition: vppRenderGraphNodes.hpp:506
Base class for render graphs.
Definition: vppRenderGraph.hpp:190
std::uint32_t index() const
Retrieves the index of the attachment.
All images used for normal rendering.
Definition: vppImageInfo.hpp:37
Represents display attachment graph node.
Definition: vppRenderGraphNodes.hpp:160
Postprocess()
Constructs postprocess node for currently defined graph.
void setDepthInput(const Attachment< FormatT > &d)
Sets depth attachment which has been already filled by previous render passes, to be read by this ren...
EImagePurpose
Enumeration specifying general purpose of an image.
Definition: vppImageInfo.hpp:35
std::uint32_t index() const
Retrieves the index of the Preprocess node.
RenderGraph * graph() const
Retrieves the parent render graph.
RenderGraph * graph() const
Retrieves the parent render graph.
Preprocess()
Constructs preprocess node for currently defined graph.
void addInput(const Attachment< FormatT > &d, VkImageLayout nodeImageLayout=VK_IMAGE_LAYOUT_GENERAL, bool bAddDependency=true)
Adds input attachment to be read by this process.