Diligent Engine  v.2.4.g
TextureUploader.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
30 #include "../../GraphicsEngine/interface/RenderDevice.h"
31 #include "../../GraphicsEngine/interface/DeviceContext.h"
32 
33 namespace Diligent
34 {
35 
36 // clang-format off
37 
40 {
47 
48  bool operator == (const UploadBufferDesc &rhs) const
49  {
50  return Width == rhs.Width &&
51  Height == rhs.Height &&
52  Depth == rhs.Depth &&
53  Format == rhs.Format;
54  }
55 };
56 // clang-format on
57 
58 class IUploadBuffer : public IObject
59 {
60 public:
61  virtual void WaitForCopyScheduled() = 0;
62  virtual MappedTextureSubresource GetMappedData(Uint32 Mip, Uint32 Slice) = 0;
63  virtual const UploadBufferDesc& GetDesc() const = 0;
64 };
65 
68 {
69 };
70 
71 
74 {
76 };
77 
79 class ITextureUploader : public IObject
80 {
81 public:
83  virtual void RenderThreadUpdate(IDeviceContext* pContext) = 0;
84 
85 
87 
106  virtual void AllocateUploadBuffer(IDeviceContext* pContext,
107  const UploadBufferDesc& Desc,
108  IUploadBuffer** ppBuffer) = 0;
109 
110 
112 
130  virtual void ScheduleGPUCopy(IDeviceContext* pContext,
131  ITexture* pDstTexture,
132  Uint32 ArraySlice,
133  Uint32 MipLevel,
134  IUploadBuffer* pUploadBuffer) = 0;
135 
136 
138 
140  virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) = 0;
141 
142 
144  virtual TextureUploaderStats GetStats() = 0;
145 };
146 
147 void CreateTextureUploader(IRenderDevice* pDevice, const TextureUploaderDesc& Desc, ITextureUploader** ppUploader);
148 
149 } // namespace Diligent
Diligent::ITextureUploader::GetStats
virtual TextureUploaderStats GetStats()=0
Returns texture uploader statistics, see Diligent::TextureUploaderStats.
Diligent::UploadBufferDesc::ArraySize
Uint32 ArraySize
Definition: TextureUploader.hpp:45
Diligent::IObject
Base interface for all dynamic objects in the engine.
Definition: Object.h:41
Diligent::CreateTextureUploader
void CreateTextureUploader(IRenderDevice *pDevice, const TextureUploaderDesc &Desc, ITextureUploader **ppUploader)
Definition: TextureUploader.cpp:43
Diligent::UploadBufferDesc::MipLevels
Uint32 MipLevels
Definition: TextureUploader.hpp:44
Diligent::MappedTextureSubresource
Definition: Texture.h:245
Diligent::UploadBufferDesc::operator==
bool operator==(const UploadBufferDesc &rhs) const
Definition: TextureUploader.hpp:48
Diligent::IUploadBuffer::GetMappedData
virtual MappedTextureSubresource GetMappedData(Uint32 Mip, Uint32 Slice)=0
Diligent::TEX_FORMAT_UNKNOWN
@ TEX_FORMAT_UNKNOWN
Unknown format.
Definition: GraphicsTypes.h:331
Diligent::ITextureUploader::ScheduleGPUCopy
virtual void ScheduleGPUCopy(IDeviceContext *pContext, ITexture *pDstTexture, Uint32 ArraySlice, Uint32 MipLevel, IUploadBuffer *pUploadBuffer)=0
Schedules a GPU copy or executes the copy immediately.
Diligent::ITextureUploader::RecycleBuffer
virtual void RecycleBuffer(IUploadBuffer *pUploadBuffer)=0
Recycles upload buffer to make it available for future operations.
Diligent::IRenderDevice
Render device interface.
Definition: RenderDevice.h:75
Diligent::IUploadBuffer::WaitForCopyScheduled
virtual void WaitForCopyScheduled()=0
Diligent::ITextureUploader::RenderThreadUpdate
virtual void RenderThreadUpdate(IDeviceContext *pContext)=0
Executes pending render-thread operations.
Diligent::IUploadBuffer
Definition: TextureUploader.hpp:58
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::UploadBufferDesc::Format
TEXTURE_FORMAT Format
Definition: TextureUploader.hpp:46
Diligent::TextureUploaderDesc
Texture uploader description.
Definition: TextureUploader.hpp:67
Diligent::TEXTURE_FORMAT
TEXTURE_FORMAT
Texture formats.
Definition: GraphicsTypes.h:328
Diligent::UploadBufferDesc::Width
Uint32 Width
Definition: TextureUploader.hpp:41
Diligent::TextureUploaderStats
Texture uploader statistics.
Definition: TextureUploader.hpp:73
Diligent::ITextureUploader::AllocateUploadBuffer
virtual void AllocateUploadBuffer(IDeviceContext *pContext, const UploadBufferDesc &Desc, IUploadBuffer **ppBuffer)=0
Allocates upload buffer.
Diligent::IDeviceContext
Device context interface.
Definition: DeviceContext.h:1460
Diligent::IUploadBuffer::GetDesc
virtual const UploadBufferDesc & GetDesc() const =0
Diligent::ITextureUploader
Asynchronous texture uplader.
Definition: TextureUploader.hpp:79
Diligent::TextureUploaderStats::NumPendingOperations
Uint32 NumPendingOperations
Definition: TextureUploader.hpp:75
Diligent::UploadBufferDesc::Height
Uint32 Height
Definition: TextureUploader.hpp:42
Diligent::UploadBufferDesc::Depth
Uint32 Depth
Definition: TextureUploader.hpp:43
Diligent::ITexture
Texture inteface.
Definition: Texture.h:273
Diligent::UploadBufferDesc
Upload buffer description.
Definition: TextureUploader.hpp:39
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37