Skip to content

Commit cbbad0b

Browse files
committed
pull from asset-conversion-v3
1 parent a0881e2 commit cbbad0b

File tree

4 files changed

+99
-701
lines changed

4 files changed

+99
-701
lines changed

include/nbl/video/IDeviceMemoryBacked.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ class IDeviceMemoryBacked : public IBackendObject
5959
struct SDeviceMemoryRequirements
6060
{
6161
// the allocation size required to back the resource
62-
size_t size; // TODO: C++23 default-initialize to 0ull
62+
size_t size = 0ull;
6363
// a bitmask of all memory type IDs (one bit per ID) which are compatible with the resource
64-
uint32_t memoryTypeBits; // TODO: C++23 default-initialize to 0x0u
64+
uint32_t memoryTypeBits = 0x0u;
6565
// what alignment should be memory allocation should have, encoded as Log2 as alignments need to be PoT
66-
uint32_t alignmentLog2 : 6; // TODO: C++23 default-initialize to 63
66+
uint32_t alignmentLog2 : 6 = 63;
6767
// whether you'll get better performance from having one allocation exclusively bound to this resource
68-
uint32_t prefersDedicatedAllocation : 1; // TODO: C++23 default-initialize to true
68+
uint32_t prefersDedicatedAllocation : 1 = true;
6969
// whether you need to have one allocation exclusively bound to this resource, always true in OpenGL
70-
uint32_t requiresDedicatedAllocation : 1; // TODO: C++23 default-initialize to true
70+
uint32_t requiresDedicatedAllocation : 1 = true;
7171
};
7272
static_assert(sizeof(SDeviceMemoryRequirements)==16);
7373
//! Before allocating memory from the driver or trying to bind a range of an existing allocation
@@ -113,6 +113,9 @@ class IDeviceMemoryBacked : public IBackendObject
113113
SDeviceMemoryRequirements m_cachedMemoryReqs;
114114
};
115115

116+
template<typename T>
117+
concept DeviceMemoryBacked = std::is_base_of_v<IDeviceMemoryBacked,T>;
118+
116119
} // end namespace nbl::video
117120

118121
#endif

include/nbl/video/asset_traits.h

Lines changed: 90 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,33 @@ struct asset_traits<asset::ICPUComputePipeline>
106106
using lookup_t = const video_t*;
107107
};
108108

109-
/*
109+
110110
template<>
111-
struct asset_traits<asset::ICPUDescriptorSetLayout> { using GPUObjectType = IGPUDescriptorSetLayout; };
112-
*/
111+
struct asset_traits<asset::ICPURenderpass>
112+
{
113+
// the asset type
114+
using asset_t = asset::ICPURenderpass;
115+
// we don't need to descend during DFS into other assets
116+
constexpr static inline bool HasChildren = false;
117+
// the video type
118+
using video_t = IGPURenderpass;
119+
// lookup type
120+
using lookup_t = const video_t*;
121+
};
122+
123+
template<>
124+
struct asset_traits<asset::ICPUGraphicsPipeline>
125+
{
126+
// the asset type
127+
using asset_t = asset::ICPUGraphicsPipeline;
128+
// we reference a pipeline layout and a renderpass
129+
constexpr static inline bool HasChildren = true;
130+
// the video type
131+
using video_t = IGPUGraphicsPipeline;
132+
// lookup type
133+
using lookup_t = const video_t*;
134+
};
135+
113136

114137
template<>
115138
struct asset_traits<asset::ICPUBuffer>
@@ -138,25 +161,81 @@ struct asset_traits<asset::ICPUBufferView>
138161
};
139162

140163

141-
/*
142164
template<>
143-
struct asset_traits<asset::ICPUImage> { using GPUObjectType = IGPUImage; };
165+
struct asset_traits<asset::ICPUImage>
166+
{
167+
// the asset type
168+
using asset_t = asset::ICPUImage;
169+
// we don't need to descend during DFS into other assets
170+
constexpr static inline bool HasChildren = false;
171+
// the video type
172+
using video_t = IGPUImage;
173+
// lookup type
174+
using lookup_t = const video_t*;
175+
};
144176

145177
template<>
146-
struct asset_traits<asset::ICPUImageView> { using GPUObjectType = IGPUImageView; };
147-
*/
178+
struct asset_traits<asset::ICPUImageView>
179+
{
180+
// the asset type
181+
using asset_t = asset::ICPUImageView;
182+
// depends on ICPUImage
183+
constexpr static inline bool HasChildren = true;
184+
// the video type
185+
using video_t = IGPUImageView;
186+
// lookup type
187+
using lookup_t = const video_t*;
188+
};
189+
190+
191+
template<>
192+
struct asset_traits<asset::ICPUBottomLevelAccelerationStructure>
193+
{
194+
// the asset type
195+
using asset_t = asset::ICPUBottomLevelAccelerationStructure;
196+
// we don't need to descend during DFS into other assets
197+
constexpr static inline bool HasChildren = true;
198+
// the video type
199+
using video_t = IGPUImageView;
200+
// lookup type
201+
using lookup_t = const video_t*;
202+
};
148203

149-
/*
150204
template<>
151-
struct asset_traits<asset::ICPUShader> { using GPUObjectType = IGPUShader; };
205+
struct asset_traits<asset::ICPUTopLevelAccelerationStructure>
206+
{
207+
// the asset type
208+
using asset_t = asset::ICPUTopLevelAccelerationStructure;
209+
// depends on ICPUBottomLevelAccelerationStructure
210+
constexpr static inline bool HasChildren = true;
211+
// the video type
212+
using video_t = IGPUTopLevelAccelerationStructure;
213+
// lookup type
214+
using lookup_t = const video_t*;
215+
};
216+
152217

153218
template<>
154-
struct asset_traits<asset::ICPUDescriptorSet> { using GPUObjectType = IGPUDescriptorSet; };
219+
struct asset_traits<asset::ICPUDescriptorSet>
220+
{
221+
// the asset type
222+
using asset_t = asset::ICPUDescriptorSet;
223+
// depends on a lot of `IDescriptor` ICPU... types
224+
constexpr static inline bool HasChildren = true;
225+
// the video type
226+
using video_t = IGPUDescriptorSet;
227+
// lookup type
228+
using lookup_t = const video_t*;
229+
};
155230

231+
232+
/* TODO
156233
template<>
157-
struct asset_traits<asset::ICPUAccelerationStructure> { using GPUObjectType = IGPUAccelerationStructure; };
234+
struct asset_traits<asset::ICPUFramebuffer>;
158235
*/
159236

237+
// Every other ICPU type not present in the list here is deprecated
238+
160239

161240
// Slight wrapper to allow copyable smart pointers
162241
template<asset::Asset AssetType>

0 commit comments

Comments
 (0)