vsg: include/vsg/state/ComputePipeline.h Source File

vsg 1.1.10 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:
26 ComputePipeline();
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
35 ref_ptr<PipelineLayout> layout;
36 ref_ptr<ShaderStage> stage;
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, const PipelineLayout* pipelineLayout, const 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 explicit 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
75 ref_ptr<ComputePipeline> pipeline;
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
vsg::BindComputePipeline
BindComputePipeline state command encapsulates the vkCmdBindPipeline call for a ComputePipeline.
Definition ComputePipeline.h:65
vsg::BindComputePipeline::pipeline
ref_ptr< ComputePipeline > pipeline
pipeline to pass in the vkCmdBindPipeline call;
Definition ComputePipeline.h:75
vsg::BindComputePipeline::compare
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,...
vsg::CommandBuffer
CommandBuffer encapsulates VkCommandBuffer.
Definition CommandBuffer.h:27
vsg::ComputePipeline
ComputePipeline encapsulates compute VkPipeline and the VkComputePipelineCreateInfo settings used to ...
Definition ComputePipeline.h:24
vsg::ComputePipeline::compare
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,...
vsg::ComputePipeline::layout
ref_ptr< PipelineLayout > layout
VkComputePipelineCreateInfo settings.
Definition ComputePipeline.h:35
vsg::Context
Definition Context.h:67
vsg::Device
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition Device.h:39
vsg::Input
Definition Input.h:44
vsg::Object
Definition Object.h:60
vsg::Output
Definition Output.h:41
vsg::PipelineLayout
PipelineLayout encapsulates VkPipelineLayout and the VkPipelineLayoutCreateInfo settings used to set ...
Definition PipelineLayout.h:27
vsg::ShaderStage
ShaderStage encapsulates VkPipelineShaderStageCreateInfo settings passed when setting up GraphicsPipe...
Definition ShaderStage.h:24
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::vk_buffer
vk_buffer that manages a single logical device supported.
Definition vk_buffer.h:28