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

vsg 1.1.3 VulkanSceneGraph library

Loading...
Searching...
No Matches
CopyAndReleaseImage.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/ImageInfo.h>
16#include <vsg/vk/MemoryBufferPools.h>
17
18#include <vsg/commands/Command.h>
19
20namespace vsg
21{
22
24 class VSG_DECLSPEC CopyAndReleaseImage : public Inherit<Command, CopyAndReleaseImage>
25 {
26 public:
27 CopyAndReleaseImage(ref_ptr<MemoryBufferPools> optional_stagingMemoryBufferPools = {});
28
29 struct VSG_DECLSPEC CopyData
30 {
31 CopyData() {}
32 CopyData(ref_ptr<BufferInfo> src, ref_ptr<ImageInfo> dest, uint32_t numMipMapLevels = 1);
33
34 ref_ptr<BufferInfo> source;
35 ref_ptr<ImageInfo> destination;
36
37 uint32_t mipLevels = 1;
38
39 Data::Properties layout;
40 uint32_t width = 0;
41 uint32_t height = 0;
42 uint32_t depth = 0;
43 Data::MipmapOffsets mipmapOffsets;
44
45 void record(CommandBuffer& commandBuffer) const;
46 };
47
48 void add(const CopyData& cd);
49 void add(ref_ptr<BufferInfo> src, ref_ptr<ImageInfo> dest);
50 void add(ref_ptr<BufferInfo> src, ref_ptr<ImageInfo> dest, uint32_t numMipMapLevels);
51
53 ref_ptr<MemoryBufferPools> stagingMemoryBufferPools;
54
56 void copy(ref_ptr<Data> data, ref_ptr<ImageInfo> dest);
57 void copy(ref_ptr<Data> data, ref_ptr<ImageInfo> dest, uint32_t numMipMapLevels);
58
59 void record(CommandBuffer& commandBuffer) const override;
60
61 protected:
62 virtual ~CopyAndReleaseImage();
63
64 void _copyDirectly(ref_ptr<Data> data, ref_ptr<ImageInfo> dest, uint32_t numMipMapLevels);
65
66 mutable std::mutex _mutex;
67 mutable std::vector<CopyData> _pending;
68 mutable std::vector<CopyData> _completed;
69 mutable std::vector<CopyData> _readyToClear;
70 };
71
72} // namespace vsg
vsg::CommandBuffer
CommandBuffer encapsulates VkCommandBuffer.
Definition CommandBuffer.h:27
vsg::CopyAndReleaseImage
Deprecated - use vsg::Data dataVariance and Data::dirty() to signal vsg::TransferTask to transfer dat...
Definition CopyAndReleaseImage.h:25
vsg::CopyAndReleaseImage::stagingMemoryBufferPools
ref_ptr< MemoryBufferPools > stagingMemoryBufferPools
MemoryBufferPools used for allocation of staging buffer used by the copy(ref_ptr<Data>,...
Definition CopyAndReleaseImage.h:53
vsg::CopyAndReleaseImage::copy
void copy(ref_ptr< Data > data, ref_ptr< ImageInfo > dest)
copy data into a staging buffer and then use copy command to transfer this to the GPU image specified...
vsg::Inherit
Definition Inherit.h:28
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::CopyAndReleaseImage::CopyData
Definition CopyAndReleaseImage.h:30
vsg::Data::Properties
Definition Data.h:116