vsg  1.1.0
VulkanSceneGraph library
RecordAndSubmitTask.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2018 Robert Osfield
6 
7 Permission 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 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE 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/CommandGraph.h>
16 #include <vsg/app/TransferTask.h>
17 #include <vsg/app/Window.h>
18 #include <vsg/io/DatabasePager.h>
19 #include <vsg/nodes/Group.h>
20 #include <vsg/vk/CommandBuffer.h>
21 
22 namespace vsg
23 {
24 
26  class VSG_DECLSPEC RecordAndSubmitTask : public Inherit<Object, RecordAndSubmitTask>
27  {
28  public:
29  explicit RecordAndSubmitTask(Device* in_device, uint32_t numBuffers = 3);
30 
31  virtual VkResult submit(ref_ptr<FrameStamp> frameStamp = {});
32 
33  virtual VkResult start();
34  virtual VkResult record(ref_ptr<RecordedCommandBuffers> recordedCommandBuffers, ref_ptr<FrameStamp> frameStamp);
35  virtual VkResult finish(ref_ptr<RecordedCommandBuffers> recordedCommandBuffers);
36 
37  ref_ptr<Device> device;
38  Windows windows;
39  Semaphores waitSemaphores;
40  CommandGraphs commandGraphs; // assign in application setup
41  Semaphores signalSemaphores; // connect to Presentation.waitSemaphores
42 
43  ref_ptr<TransferTask> earlyTransferTask; // data is updated prior to record traversal so can be transferred before/in parallel to record traversal
44  ref_ptr<Semaphore> earlyTransferTaskConsumerCompletedSemaphore;
45 
46  ref_ptr<TransferTask> lateTransferTask; // data is updated during the record traversal so has to be transferred after record traversal
47  ref_ptr<Semaphore> lateTransferTaskConsumerCompletedSemaphore;
48 
50  void advance();
51 
53  size_t index(size_t relativeFrameIndex = 0) const;
54 
56  Fence* fence(size_t relativeFrameIndex = 0);
57 
58  ref_ptr<Queue> queue;
59 
60  ref_ptr<DatabasePager> databasePager;
61 
62  protected:
63  size_t _currentFrameIndex;
64  std::vector<size_t> _indices;
65  std::vector<ref_ptr<Fence>> _fences;
66  };
67  VSG_type_name(vsg::RecordAndSubmitTask);
68 
69  using RecordAndSubmitTasks = std::vector<ref_ptr<RecordAndSubmitTask>>;
70 
72  extern VSG_DECLSPEC void updateTasks(RecordAndSubmitTasks& tasks, ref_ptr<CompileManager> compileManager, const CompileResult& compileResult);
73 
74 } // namespace vsg
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition: Device.h:37
Definition: Fence.h:23
Definition: Inherit.h:28
RecordAndSubmitTask manages the recording of its list of CommandGraph to CommandBuffer which are then...
Definition: RecordAndSubmitTask.h:27
void advance()
advance the currentFrameIndex
size_t index(size_t relativeFrameIndex=0) const
return the fence index value for relativeFrameIndex where 0 is current frame, 1 is previous frame etc...
Fence * fence(size_t relativeFrameIndex=0)
fence() and fence(0) return the Fence for the frame currently being rendered, fence(1) returns the pr...
Definition: ref_ptr.h:22
Definition: CompileManager.h:24