vsg: include/vsg/commands/ExecuteCommands.h Source File

vsg 1.1.10 VulkanSceneGraph library |

Loading...
Searching...
No Matches
ExecuteCommands.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2020 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/app/SecondaryCommandGraph.h>
16#include <vsg/threading/Latch.h>
17
18namespace vsg
19{
20
22 class VSG_DECLSPEC ExecuteCommands : public Inherit<Command, ExecuteCommands>
23 {
24 public:
25 ExecuteCommands();
26
28 void connect(ref_ptr<SecondaryCommandGraph> commandGraph);
29
31 void reset();
32
34 void completed(const SecondaryCommandGraph& commandGraph, ref_ptr<CommandBuffer> commandBuffer);
35
37 void record(CommandBuffer& commandBuffer) const override;
38
39 protected:
40 virtual ~ExecuteCommands();
41
42 struct CommandGraphAndBuffer
43 {
44 ref_ptr<SecondaryCommandGraph> cg;
45 ref_ptr<CommandBuffer> cb;
46 };
47
48 mutable std::mutex _mutex;
49 ref_ptr<Latch> _latch;
50
51 std::vector<CommandGraphAndBuffer> _commandGraphsAndBuffers;
52 };
53 VSG_type_name(vsg::ExecuteCommands);
54
55} // namespace vsg
vsg::CommandBuffer
CommandBuffer encapsulates VkCommandBuffer.
Definition CommandBuffer.h:27
vsg::ExecuteCommands
Encapsulation of vkCmdExecuteCommands with thread safe integration with SecondaryCommandGraph that pr...
Definition ExecuteCommands.h:23
vsg::ExecuteCommands::completed
void completed(const SecondaryCommandGraph &commandGraph, ref_ptr< CommandBuffer > commandBuffer)
called by SecondaryCommandGraph to pass on the completed CommandBuffer that was recorded.
vsg::ExecuteCommands::record
void record(CommandBuffer &commandBuffer) const override
call vkCmdExecuteCommands with all the CommandBuffer that have been recorded with this ExecuteCommand...
vsg::ExecuteCommands::connect
void connect(ref_ptr< SecondaryCommandGraph > commandGraph)
connect a SecondaryCommmandGraph that will provide the CommandBuffer each frame
vsg::ExecuteCommands::reset
void reset()
clean the internal cache of CommandBuffer and reset the Latch used to signal when all the connected C...
vsg::SecondaryCommandGraph
SecondaryCommandGraph is a specialization of CommandGraph that provides Vulkan secondary command buff...
Definition SecondaryCommandGraph.h:25
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::ExecuteCommands::CommandGraphAndBuffer
Definition ExecuteCommands.h:43