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

vsg 1.1.3 VulkanSceneGraph library

Loading...
Searching...
No Matches
TransferTask.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2022 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/Window.h>
17#include <vsg/io/DatabasePager.h>
18#include <vsg/nodes/Group.h>
19#include <vsg/vk/CommandBuffer.h>
20
21namespace vsg
22{
23
28 class VSG_DECLSPEC TransferTask : public Inherit<Object, TransferTask>
29 {
30 public:
31 explicit TransferTask(Device* in_device, uint32_t numBuffers = 3);
32
34 virtual VkResult transferDynamicData();
35
36 virtual bool containsDataToTransfer() const;
37
38 ref_ptr<Device> device;
39 Semaphores waitSemaphores;
40 Semaphores signalSemaphores;
41
43 void advance();
44
45 void assign(const ResourceRequirements::DynamicData& dynamicData);
46 void assign(const BufferInfoList& bufferInfoList);
47 void assign(const ImageInfoList& imageInfoList);
48
49 ref_ptr<Queue> transferQueue;
50 ref_ptr<Semaphore> currentTransferCompletedSemaphore;
51
53 ref_ptr<Instrumentation> instrumentation;
54
56 Logger::Level level = Logger::LOGGER_DEBUG;
57
58 protected:
59 using OffsetBufferInfoMap = std::map<VkDeviceSize, ref_ptr<BufferInfo>>;
60 using BufferMap = std::map<ref_ptr<Buffer>, OffsetBufferInfoMap>;
61
62 size_t index(size_t relativeFrameIndex = 0) const;
63
64 VkDeviceSize _dynamicDataTotalRegions = 0;
65 VkDeviceSize _dynamicDataTotalSize = 0;
66 VkDeviceSize _dynamicImageTotalSize = 0;
67 BufferMap _dynamicDataMap;
68 std::set<ref_ptr<ImageInfo>> _dynamicImageInfoSet;
69
70 size_t _currentFrameIndex;
71 std::vector<size_t> _indices;
72
73 struct Frame
74 {
75 ref_ptr<CommandBuffer> transferCommandBuffer;
76 ref_ptr<Semaphore> transferCompleteSemaphore;
77 ref_ptr<Buffer> staging;
78 void* buffer_data = nullptr;
79 std::vector<VkBufferCopy> copyRegions;
80 };
81
82 std::vector<Frame> _frames;
83
84 void _transferBufferInfos(VkCommandBuffer vk_commandBuffer, Frame& frame, VkDeviceSize& offset);
85
86 void _transferImageInfos(VkCommandBuffer vk_commandBuffer, Frame& frame, VkDeviceSize& offset);
87 void _transferImageInfo(VkCommandBuffer vk_commandBuffer, Frame& frame, VkDeviceSize& offset, ImageInfo& imageInfo);
88 };
89 VSG_type_name(vsg::TransferTask);
90
91} // namespace vsg
vsg::Device
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition Device.h:37
vsg::ImageInfo
ImageInfo class provides the VkDescriptorImageInfo settings used when setting up vsg::/vkDescriptorIm...
Definition ImageInfo.h:23
vsg::Inherit
Definition Inherit.h:28
vsg::TransferTask
Definition TransferTask.h:29
vsg::TransferTask::instrumentation
ref_ptr< Instrumentation > instrumentation
hook for assigning Instrumentation to enable profiling of record traversal.
Definition TransferTask.h:53
vsg::TransferTask::transferDynamicData
virtual VkResult transferDynamicData()
transfer any vsg::Data entries that have been updated to the associated GPU memory.
vsg::TransferTask::advance
void advance()
advance the currentFrameIndex
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::ResourceRequirements::DynamicData
Definition ResourceRequirements.h:63
vsg::TransferTask::Frame
Definition TransferTask.h:74