VPP  0.8
A high-level modern C++ API for Vulkan
vppComputePass.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 
139 class ComputePass :
140  public NonRenderingCommands,
141  public UniversalCommands
142 {
143 public:
145  ComputePass (
146  const Device& hDevice );
147 
149  ComputePass (
150  const Device& hDevice,
151  const PipelineCache& hPipelineCache );
152 
154  const Device& device() const;
155 
157  const PipelineCache& pipelineCache() const;
158 
162  const ComputePipeline& pipeline ( std::uint32_t iPipeline ) const;
163 
166  template< class DefinitionT >
167  std::uint32_t addPipeline ( const ComputePipelineLayout< DefinitionT> layout );
168 
172  void operator<< ( const std::function< void () >& cmds );
173 
260  static void cmdDispatch (
261  unsigned int nx = 1, unsigned int ny = 1, unsigned int nz = 1,
262  CommandBuffer hCmdBuffer = CommandBuffer() );
263 
280  static void cmdDispatchIndirect (
281  const IndirectBufferView& data,
282  unsigned int index,
283  CommandBuffer hCmdBuffer = CommandBuffer() );
284 };
285 
286 // -----------------------------------------------------------------------------
287 } // namespace vpp
288 // -----------------------------------------------------------------------------
const Device & device() const
Retrieves the device associated with this compute pass.
Represents logical rendering device.
Definition: vppDevice.hpp:49
const ComputePipeline & pipeline(std::uint32_t iPipeline) const
Retrieves a pipeline associated with this compute pass and specified pipeline index.
Definition: vppPipelineCache.hpp:31
Represents compute pass.
Definition: vppComputePass.hpp:139
Set of commands that may be used anywhere (inside or outside rendering context).
Definition: vppCommands.hpp:333
The VPP namespace.
Definition: main.hpp:1
Set of commands that may be used outside rendering context.
Definition: vppCommands.hpp:52
Represents a sequence of Vulkan commands.
Definition: vppCommandBuffer.hpp:68
static void cmdDispatchIndirect(const IndirectBufferView &data, unsigned int index, CommandBuffer hCmdBuffer=CommandBuffer())
Generates a command to dispatch specified item of indirect dispatch buffer.
Definition: vppBufferView.hpp:183
static void cmdDispatch(unsigned int nx=1, unsigned int ny=1, unsigned int nz=1, CommandBuffer hCmdBuffer=CommandBuffer())
Generates a command which starts execution of currently selected pipeline in the compute pass...
Pipeline layout template for a compute pipeline. Use to create actual pipeline layout (Vulkan objects...
Definition: vppPipelineLayout.hpp:206
Compiled pipeline class for compute pipelines.
Definition: vppPipeline.hpp:87
ComputePass(const Device &hDevice)
Construct a compute pass.
const PipelineCache & pipelineCache() const
Retrieves the pipeline cache associated with this compute pass.
std::uint32_t addPipeline(const ComputePipelineLayout< DefinitionT > layout)
Registers a pipeline with this compute pass. Returns pipeline index.