Skip to content

Commit 0093d51

Browse files
make more operator bool() explicit, notice a missing _BIT suffix in a BLAS flag, add a CAssetConverter::SReserveResult::moveGPUObjects, make IPreHashed helpers more const poiter friendly
1 parent dc31aa0 commit 0093d51

12 files changed

Lines changed: 26 additions & 15 deletions

include/nbl/asset/IAccelerationStructure.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class IBottomLevelAccelerationStructure : public IAccelerationStructure
7676
// Provided by VK_NV_displacement_micromap
7777
ALLOW_DISPLACEMENT_MICROMAP_UPDATE_BIT = 0x1u<<9u,
7878
// Provided by VK_KHR_ray_tracing_position_fetch
79-
ALLOW_DATA_ACCESS = 0x1u<<11u,
79+
ALLOW_DATA_ACCESS_BIT = 0x1u<<11u,
80+
ALLOW_DATA_ACCESS = ALLOW_DATA_ACCESS_BIT // deprecated
8081
};
8182

8283

include/nbl/asset/IGeometry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class IGeometryBase : public virtual core::IReferenceCounted
176176
struct SDataViewBase
177177
{
178178
// mostly checking validity of the format
179-
inline operator bool() const {return format==EF_UNKNOWN || !isBlockCompressionFormat(format) && !isDepthOrStencilFormat(format);}
179+
explicit inline operator bool() const {return format==EF_UNKNOWN || !isBlockCompressionFormat(format) && !isDepthOrStencilFormat(format);}
180180

181181
//
182182
inline bool isFormatted() const {return format!=EF_UNKNOWN && bool(*this);}
@@ -294,7 +294,7 @@ class IGeometry : public std::conditional_t<std::is_same_v<BufferType,ICPUBuffer
294294

295295
struct SDataView
296296
{
297-
inline operator bool() const {return src && composed;}
297+
explicit inline operator bool() const {return src && composed;}
298298

299299
//
300300
explicit inline operator SBufferBinding<const BufferType>() const

include/nbl/asset/IMorphTargets.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class NBL_API2 IMorphTargets : public virtual core::IReferenceCounted
2222
inline index_t() = default;
2323
explicit inline index_t(uint32_t _value) : value(_value) {}
2424

25-
inline operator bool() const {return value!=(~0u);}
25+
explicit inline operator bool() const {return value!=(~0u);}
2626

2727
uint32_t value = ~0u;
2828
};
@@ -68,7 +68,7 @@ class NBL_API2 IMorphTargets : public virtual core::IReferenceCounted
6868

6969
struct STarget
7070
{
71-
inline operator bool() const
71+
explicit inline operator bool() const
7272
{
7373
if (!geoCollection)
7474
return false;

include/nbl/asset/IPolygonGeometry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class IPolygonGeometry : public IIndexableGeometry<BufferType>, public IPolygonG
208208
struct SJointWeight
209209
{
210210
// one thing this doesn't check is whether every vertex has a weight and index
211-
inline operator bool() const {return indices && isIntegerFormat(indices.composed.format) && weights && weights.composed.isFormatted() && indices.getElementCount()==weights.getElementCount();}
211+
explicit inline operator bool() const {return indices && isIntegerFormat(indices.composed.format) && weights && weights.composed.isFormatted() && indices.getElementCount()==weights.getElementCount();}
212212

213213
SDataView indices;
214214
// Assumption is that only non-zero weights are present, which is why the joints are indexed (sparseness)

include/nbl/asset/IPreHashed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class IPreHashed : public IAsset
3939
discardContent_impl();
4040
}
4141

42-
static inline void discardDependantsContents(const std::span<IAsset*> roots)
42+
static inline void discardDependantsContents(const std::span<IAsset* const> roots)
4343
{
4444
core::vector<IAsset*> stack;
4545
core::unordered_set<IAsset*> alreadyVisited; // whether we have push the node to the stack

include/nbl/asset/IRenderpass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ class NBL_API2 IRenderpass
302302
uint32_t dependencyCount = 0u;
303303
int8_t viewMaskMSB = -1;
304304

305-
inline operator bool() const {return subpassCount;}
305+
explicit inline operator bool() const {return subpassCount;}
306306

307307
inline bool hasViewMasks() const {return viewMaskMSB>=0;}
308308
};

include/nbl/video/IGPUPipeline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class IGPUPipelineBase {
9090
.count = dataSize ? static_cast<uint32_t>(count) : 0,
9191
.dataSize = static_cast<uint32_t>(dataSize),
9292
};
93-
return *retval;
93+
return bool(*retval);
9494
}
9595

9696
const asset::IShader* shader = nullptr;

include/nbl/video/ILogicalDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
410410
//
411411
struct AccelerationStructureBuildSizes
412412
{
413-
inline operator bool() const { return accelerationStructureSize!=(~0ull); }
413+
explicit inline operator bool() const { return accelerationStructureSize!=(~0ull); }
414414

415415
size_t accelerationStructureSize = ~0ull;
416416
size_t updateScratchSize = ~0ull;

include/nbl/video/SPipelineCreationParams.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace nbl::video
1414
struct SSpecializationValidationResult
1515
{
1616
constexpr static inline uint32_t Invalid = ~0u;
17-
inline operator bool() const
17+
explicit inline operator bool() const
1818
{
1919
return count!=Invalid && dataSize!=Invalid;
2020
}

include/nbl/video/utilities/CAssetConverter.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,14 +1048,24 @@ class CAssetConverter : public core::IReferenceCounted
10481048
}
10491049

10501050
//
1051-
inline operator bool() const {return bool(m_converter);}
1051+
explicit inline operator bool() const {return bool(m_converter);}
10521052

10531053
// Until `convert` is called, the Buffers and Images are not filled with content and Acceleration Structures are not built, unless found in the `SInput::readCache`
10541054
// WARNING: The Acceleration Structure Pointer WILL CHANGE after calling `convert` if its patch dictates that it will be compacted! (since AS can't resize)
10551055
// TODO: we could also return per-object semaphore values when object is ready for use (would have to propagate two semaphores up through dependants)
10561056
template<asset::Asset AssetType>
10571057
std::span<const asset_cached_t<AssetType>> getGPUObjects() const {return std::get<vector_t<AssetType>>(m_gpuObjects);}
10581058

1059+
// after a successful conversion you can move the GPU objects over
1060+
template<asset::Asset AssetType>
1061+
bool moveGPUObjects(vector_t<AssetType>& out)
1062+
{
1063+
if (m_converter)
1064+
return false;
1065+
out = std::move(std::get<vector_t<AssetType>>(m_gpuObjects));
1066+
return true;
1067+
}
1068+
10591069
// If you ever need to look up the content hashes of the assets AT THE TIME you converted them
10601070
// REMEMBER it can have stale hashes (asset or its dependants mutated since hash computed),
10611071
// then you can get hash mismatches or plain wrong hashes.
@@ -1106,7 +1116,7 @@ class CAssetConverter : public core::IReferenceCounted
11061116

11071117
// we don't insert into the writeCache until conversions are successful
11081118
core::tuple_transform_t<staging_cache_t,supported_asset_types> m_stagingCaches;
1109-
// converted IShaders do not have any object that hold a smartptr into them, so we have to persist them in this vector to prevent m_stagingCacheds hold a raw dangling pointer into them
1119+
// converted IShaders do not have any object that hold a smartptr into them, so we have to persist them in this vector to prevent m_stagingCacheds hold a raw dangling pointer into them
11101120
core::vector<core::smart_refctd_ptr<asset::IShader>> m_shaders;
11111121

11121122
// need a more explicit list of GPU objects that need device-assisted conversion

0 commit comments

Comments
 (0)