Diligent Engine  v.2.4.g
BufferSuballocator.h
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 
32 
33 #include "../../GraphicsEngine/interface/RenderDevice.h"
34 #include "../../GraphicsEngine/interface/DeviceContext.h"
35 #include "../../GraphicsEngine/interface/Buffer.h"
36 
37 namespace Diligent
38 {
39 
40 struct IBufferSuballocator;
41 
42 // {562552DA-67F0-40C2-A4AF-F286DFCA1626}
43 static const INTERFACE_ID IID_BufferSuballocation =
44  {0x562552da, 0x67f0, 0x40c2, {0xa4, 0xaf, 0xf2, 0x86, 0xdf, 0xca, 0x16, 0x26}};
45 
46 
47 // {71F59B50-7D13-49A7-A4F7-FC986715FFAC}
48 static const INTERFACE_ID IID_BufferSuballocator =
49  {0x71f59b50, 0x7d13, 0x49a7, {0xa4, 0xf7, 0xfc, 0x98, 0x67, 0x15, 0xff, 0xac}};
50 
51 
54 {
56  virtual Uint32 GetOffset() const = 0;
57 
59  virtual Uint32 GetSize() const = 0;
60 
62  virtual IBufferSuballocator* GetAllocator() = 0;
63 
71  virtual void SetUserData(IObject* pUserData) = 0;
72 
77  virtual IObject* GetUserData() const = 0;
78 };
79 
80 
83 {
85 
95  virtual IBuffer* GetBuffer(IRenderDevice* pDevice, IDeviceContext* pContext) = 0;
96 
97 
99 
106  virtual void Allocate(Uint32 Size,
107  Uint32 Alignment,
108  IBufferSuballocation** ppSuballocation) = 0;
109 
110 
112 
115  virtual Uint32 GetFreeSize() = 0;
116 
117 
120  virtual Uint32 GetVersion() const = 0;
121 };
122 
125 {
128 
129 
131 
136 
137 
139 
144 };
145 
147 
154  const BufferSuballocatorCreateInfo& CreateInfo,
155  IBufferSuballocator** ppBufferSuballocator);
156 
157 } // namespace Diligent
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
Diligent::IObject
Base interface for all dynamic objects in the engine.
Definition: Object.h:41
Diligent::IBufferSuballocation::GetOffset
virtual Uint32 GetOffset() const =0
Returns the start offset of the suballocation.
Diligent::IBufferSuballocation::GetUserData
virtual IObject * GetUserData() const =0
Returns the pointer to the user data object previously set with SetUserData() method.
Diligent::BufferSuballocatorCreateInfo
Buffer suballocator create information.
Definition: BufferSuballocator.h:124
Diligent::IBuffer
Buffer interface.
Definition: Buffer.h:187
Diligent::IRenderDevice
Render device interface.
Definition: RenderDevice.h:75
Diligent::IBufferSuballocator::GetVersion
virtual Uint32 GetVersion() const =0
Returns internal buffer version. The version is incremented every time the buffer is expanded.
Diligent::IBufferSuballocator::GetFreeSize
virtual Uint32 GetFreeSize()=0
Returns the total remaining free size.
Diligent::IBufferSuballocator::GetBuffer
virtual IBuffer * GetBuffer(IRenderDevice *pDevice, IDeviceContext *pContext)=0
Returns the pointer to the internal buffer object.
Diligent::IBufferSuballocator
Buffer suballocator.
Definition: BufferSuballocator.h:82
Diligent::IBufferSuballocator::Allocate
virtual void Allocate(Uint32 Size, Uint32 Alignment, IBufferSuballocation **ppSuballocation)=0
Performs suballocation from the buffer.
Diligent::CreateBufferSuballocator
void CreateBufferSuballocator(IRenderDevice *pDevice, const BufferSuballocatorCreateInfo &CreateInfo, IBufferSuballocator **ppBufferSuballocator)
Creates a new buffer suballocator.
Definition: BufferSuballocator.cpp:242
Diligent::IBufferSuballocation::GetSize
virtual Uint32 GetSize() const =0
Returns the suballocation size.
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::BufferSuballocatorCreateInfo::Desc
BufferDesc Desc
Buffer description.
Definition: BufferSuballocator.h:127
Diligent::IBufferSuballocation::GetAllocator
virtual IBufferSuballocator * GetAllocator()=0
Returns the pointer to the parent allocator.
Diligent::IBufferSuballocation
Buffer suballocation.
Definition: BufferSuballocator.h:53
Diligent::BufferDesc
Buffer description.
Definition: Buffer.h:74
Diligent::IBufferSuballocation::SetUserData
virtual void SetUserData(IObject *pUserData)=0
Stores a pointer to the user-provided data object, which may later be retreived through GetUserData()...
Diligent::IDeviceContext
Device context interface.
Definition: DeviceContext.h:1460
Diligent::BufferSuballocatorCreateInfo::SuballocationObjAllocationGranularity
Uint32 SuballocationObjAllocationGranularity
Allocation granularity for IBufferSuballocator objects.
Definition: BufferSuballocator.h:143
Diligent::BufferSuballocatorCreateInfo::ExpansionSize
Uint32 ExpansionSize
Buffer expansion size, in bytes.
Definition: BufferSuballocator.h:135
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37