vsg 1.1.3
VulkanSceneGraph library
Loading...
Searching...
No Matches
ComputePipeline.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/state/PipelineLayout.h>
16#include <vsg/state/ShaderStage.h>
17#include <vsg/state/StateCommand.h>
18
19namespace vsg
20{
21
23 class VSG_DECLSPEC ComputePipeline : public Inherit<Object, ComputePipeline>
24 {
25 public:
27 ComputePipeline(PipelineLayout* pipelineLayout, ShaderStage* shaderStage);
28
29 int compare(const Object& rhs_object) const override;
30
31 void read(Input& input) override;
32 void write(Output& output) const override;
33
37
38 // compile the Vulkan object, context parameter used for Device
39 void compile(Context& context);
40
41 // remove the local reference to the Vulkan implementation
42 void release(uint32_t deviceID) { _implementation[deviceID] = {}; }
43 void release() { _implementation.clear(); }
44
45 VkPipeline vk(uint32_t deviceID) const { return _implementation[deviceID]->_pipeline; }
46
47 protected:
48 virtual ~ComputePipeline();
49
50 struct Implementation : public Inherit<Object, Implementation>
51 {
52 Implementation(Context& context, Device* device, PipelineLayout* pipelineLayout, ShaderStage* shaderStage);
53 virtual ~Implementation();
54
55 VkPipeline _pipeline;
56 ref_ptr<Device> _device;
57 };
58
59 vk_buffer<ref_ptr<Implementation>> _implementation;
60 };
61 VSG_type_name(vsg::ComputePipeline);
62
64 class VSG_DECLSPEC BindComputePipeline : public Inherit<StateCommand, BindComputePipeline>
65 {
66 public:
67 BindComputePipeline(ComputePipeline* pipeline = nullptr);
68
69 int compare(const Object& rhs_object) const override;
70
71 void read(Input& input) override;
72 void write(Output& output) const override;
73
76
77 void record(CommandBuffer& commandBuffer) const override;
78
79 // compile the Vulkan object, context parameter used for Device
80 void compile(Context& context) override;
81
82 public:
83 virtual ~BindComputePipeline();
84 };
85 VSG_type_name(vsg::BindComputePipeline);
86
87} // namespace vsg
BindComputePipeline state command encapsulates the vkCmdBindPipeline call for a ComputePipeline.
Definition ComputePipeline.h:65
ref_ptr< ComputePipeline > pipeline
pipeline to pass in the vkCmdBindPipeline call;
Definition ComputePipeline.h:75
int compare(const Object &rhs_object) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
CommandBuffer encapsulates VkCommandBuffer.
Definition CommandBuffer.h:27
ComputePipeline encapsulates compute VkPipeline and the VkComputePipelineCreateInfo settings used to ...
Definition ComputePipeline.h:24
int compare(const Object &rhs_object) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
ref_ptr< PipelineLayout > layout
VkComputePipelineCreateInfo settings.
Definition ComputePipeline.h:35
Definition Context.h:67
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition Device.h:37
Definition Inherit.h:28
Definition Input.h:44
Definition Object.h:60
Definition Output.h:41
PipelineLayout encapsulates VkPipelineLayout and the VkPipelineLayoutCreateInfo settings used to set ...
Definition PipelineLayout.h:27
ShaderStage encapsulates VkPipelineShaderStageCreateInfo settings passed when setting up GraphicsPipe...
Definition ShaderStage.h:24
Definition ref_ptr.h:22
Definition ComputePipeline.h:51
vk_buffer that manages a single logical device supported.
Definition vk_buffer.h:28