VPP  0.8
A high-level modern C++ API for Vulkan
vppBarriers.hpp
1 /*
2  Copyright 2016-2019 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 
37 class Bar
38 {
39 public:
44  enum EStage
45  {
55 
65 
75 
83 
86 
94 
102 
110 
113 
124 
127 
136 
145 
154 
162 
165 
176 
191  };
192 };
193 
194 // -----------------------------------------------------------------------------
195 
211 class Barriers : public Bar
212 {
213 public:
215  Barriers();
216 
218  Barriers ( const Barriers& rhs );
219 
227  void setBarriers ( const std::vector< VkMemoryBarrier >& bar );
228 
236  void setBarriers ( const std::vector< VkBufferMemoryBarrier >& bar );
237 
245  void setBarriers ( const std::vector< VkImageMemoryBarrier >& bar );
246 
254  void setBarriers ( const VkMemoryBarrier& bar );
255 
263  void setBarriers ( const VkBufferMemoryBarrier& bar );
264 
272  void setBarriers ( const VkImageMemoryBarrier bar );
273 
281  template< typename BarriersA >
282  Barriers ( const BarriersA& ba );
283 
291  template< typename BarriersA, typename BarriersB >
292  Barriers ( const BarriersA& ba, const BarriersB& bb );
293 
301  template< typename BarriersA, typename BarriersB, typename BarriersC >
302  Barriers ( const BarriersA& ba, const BarriersB& bb, const BarriersC& bc );
303 };
304 
305 // -----------------------------------------------------------------------------
314  public VkMemoryBarrier,
315  public Barriers
316 {
317  MemoryBarrier (
318  VkAccessFlags srcAccessMask,
319  VkAccessFlags dstAccessMask );
320 };
321 
322 // -----------------------------------------------------------------------------
331  public VkBufferMemoryBarrier,
332  public Barriers
333 {
335  VkAccessFlags srcAccessMask,
336  VkAccessFlags dstAccessMask,
337  const Buf& buffer,
338  VkDeviceSize offset = 0,
339  VkDeviceSize size = VK_WHOLE_SIZE,
340  uint32_t srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
341  uint32_t dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED );
342 };
343 
344 // -----------------------------------------------------------------------------
353  public VkImageMemoryBarrier,
354  public Barriers
355 {
357  VkAccessFlags srcAccessMask,
358  VkAccessFlags dstAccessMask,
359  VkImageLayout oldLayout,
360  VkImageLayout newLayout,
361  const Img& image,
362  std::uint32_t baseArrayLayer = 0,
363  std::uint32_t layerCount = VK_REMAINING_ARRAY_LAYERS,
364  std::uint32_t baseMipLevel = 0,
365  std::uint32_t levelCount = VK_REMAINING_MIP_LEVELS,
366  VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
367  uint32_t srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
368  uint32_t dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED );
369 };
370 
371 // -----------------------------------------------------------------------------
384 class BarrierList : public Barriers
385 {
386 };
387 
388 // -----------------------------------------------------------------------------
430 template< typename ... Args >
432  VkPipelineStageFlags sourceStage, VkPipelineStageFlags targetStage,
433  Args&& ... args );
434 
435 // -----------------------------------------------------------------------------
451  const Img& hImage,
452  const std::vector< VkImageSubresourceRange >& regions,
453  VkPipelineStageFlags sourceStage, VkPipelineStageFlags targetStage );
454 
455 // -----------------------------------------------------------------------------
456 } // namespace vpp
457 // -----------------------------------------------------------------------------
Resource is accessed during gathering vertices for a draw command.
Definition: vppBarriers.hpp:74
Resource is accessed during geometry shader execution.
Definition: vppBarriers.hpp:109
Resource is accessed during fragment shader execution.
Definition: vppBarriers.hpp:123
Resource is accessed from the CPU side.
Definition: vppBarriers.hpp:190
Class representing generic (untyped) Vulkan image.
Definition: vppImage.hpp:54
Same as FSHADER.
Definition: vppBarriers.hpp:126
Barriers()
Constructs empty barrier container.
The VPP namespace.
Definition: main.hpp:1
Single buffer barrier.
Definition: vppBarriers.hpp:330
Resource is accessed during late fragment tests.
Definition: vppBarriers.hpp:144
Resource is accessed during processing of indirect draw commands.
Definition: vppBarriers.hpp:64
Utility base class for barrier classes.
Definition: vppBarriers.hpp:37
BarrierList barriers(VkPipelineStageFlags sourceStage, VkPipelineStageFlags targetStage, Args &&... args)
Creates a BarrierList object for specified resources.
Multiple barriers with default parameters.
Definition: vppBarriers.hpp:384
EStage
Enumeration specifying how the resource was (or will be) accessed.
Definition: vppBarriers.hpp:44
Resource has never been accessed before, or its content does not matter.
Definition: vppBarriers.hpp:54
Resource is accessed during vertex shader execution.
Definition: vppBarriers.hpp:82
Same as VSHADER.
Definition: vppBarriers.hpp:85
Resource is accessed during tessellation control shader execution.
Definition: vppBarriers.hpp:93
Resource is accessed during early fragment tests.
Definition: vppBarriers.hpp:135
Resource is accessed during tessellation evaluation shader execution.
Definition: vppBarriers.hpp:101
General class encapsulating description of a set of pipeline barriers.
Definition: vppBarriers.hpp:211
Resource is accessed during color output.
Definition: vppBarriers.hpp:153
Single image barrier.
Definition: vppBarriers.hpp:352
Resource is accessed during data transfer.
Definition: vppBarriers.hpp:175
Single global memory barrier.
Definition: vppBarriers.hpp:313
Generic class representing Vulkan buffers.
Definition: vppBuffer.hpp:43
Same as CSHADER.
Definition: vppBarriers.hpp:164
void setBarriers(const std::vector< VkMemoryBarrier > &bar)
Assigns a set of Vulkan global memory barriers.
Resource is accessed during compute shader execution.
Definition: vppBarriers.hpp:161
Same as GSHADER.
Definition: vppBarriers.hpp:112