vsg: include/vsg/app/RecordAndSubmitTask.h Source File

vsg 1.1.3 VulkanSceneGraph library

Loading...
Searching...
No Matches
RecordAndSubmitTask.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/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/utils/Instrumentation.h>
21#include <vsg/vk/CommandBuffer.h>
22
23namespace vsg
24{
25
27 class VSG_DECLSPEC RecordAndSubmitTask : public Inherit<Object, RecordAndSubmitTask>
28 {
29 public:
30 explicit RecordAndSubmitTask(Device* in_device, uint32_t numBuffers = 3);
31
32 virtual VkResult submit(ref_ptr<FrameStamp> frameStamp = {});
33
34 virtual VkResult start();
35 virtual VkResult record(ref_ptr<RecordedCommandBuffers> recordedCommandBuffers, ref_ptr<FrameStamp> frameStamp);
36 virtual VkResult finish(ref_ptr<RecordedCommandBuffers> recordedCommandBuffers);
37
38 ref_ptr<Device> device;
39 Windows windows;
40 Semaphores waitSemaphores;
41 CommandGraphs commandGraphs; // assign in application setup
42 Semaphores signalSemaphores; // connect to Presentation.waitSemaphores
43
44 ref_ptr<TransferTask> earlyTransferTask; // data is updated prior to record traversal so can be transferred before/in parallel to record traversal
45 ref_ptr<Semaphore> earlyTransferTaskConsumerCompletedSemaphore;
46
47 ref_ptr<TransferTask> lateTransferTask; // data is updated during the record traversal so has to be transferred after record traversal
48 ref_ptr<Semaphore> lateTransferTaskConsumerCompletedSemaphore;
49
51 void advance();
52
54 size_t index(size_t relativeFrameIndex = 0) const;
55
57 Fence* fence(size_t relativeFrameIndex = 0);
58
59 ref_ptr<Queue> queue;
60
61 ref_ptr<DatabasePager> databasePager;
62
64 ref_ptr<Instrumentation> instrumentation;
65
67 void assignInstrumentation(ref_ptr<Instrumentation> in_instrumentation);
68
69 protected:
70 size_t _currentFrameIndex;
71 std::vector<size_t> _indices;
72 std::vector<ref_ptr<Fence>> _fences;
73 };
74 VSG_type_name(vsg::RecordAndSubmitTask);
75
76 using RecordAndSubmitTasks = std::vector<ref_ptr<RecordAndSubmitTask>>;
77
79 extern VSG_DECLSPEC void updateTasks(RecordAndSubmitTasks& tasks, ref_ptr<CompileManager> compileManager, const CompileResult& compileResult);
80
81} // namespace vsg
vsg::Device
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition Device.h:37
vsg::Fence
Definition Fence.h:23
vsg::Inherit
Definition Inherit.h:28
vsg::RecordAndSubmitTask
RecordAndSubmitTask manages the recording of its list of CommandGraph to CommandBuffer which are then...
Definition RecordAndSubmitTask.h:28
vsg::RecordAndSubmitTask::advance
void advance()
advance the currentFrameIndex
vsg::RecordAndSubmitTask::instrumentation
ref_ptr< Instrumentation > instrumentation
hook for assigning Instrumentation to enable profiling of record traversal.
Definition RecordAndSubmitTask.h:64
vsg::RecordAndSubmitTask::assignInstrumentation
void assignInstrumentation(ref_ptr< Instrumentation > in_instrumentation)
Convenience method for assigning Instrumentation to the viewer and any associated objects.
vsg::RecordAndSubmitTask::index
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...
vsg::RecordAndSubmitTask::fence
Fence * fence(size_t relativeFrameIndex=0)
fence() and fence(0) return the Fence for the frame currently being rendered, fence(1) returns the pr...
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::CompileResult
Definition CompileManager.h:24