Skip to content

Commit a4307f4

Browse files
author
devsh
committed
fix a nasty possible threading bug with IDeferredOperation and a bunch of typos
1 parent 8f43fef commit a4307f4

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

include/nbl/asset/ICPUAccelerationStructure.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ class ICPUBottomLevelAccelerationStructure final : public IBottomLevelAccelerati
9090
inline std::span<AABBs<asset::ICPUBuffer>> getAABBGeometries()
9191
{
9292
if (!isMutable() || !m_AABBGeoms)
93-
return {nullptr,nullptr};
93+
return {};
9494
return {m_AABBGeoms->data(),m_AABBGeoms->size()};
9595
}
9696
inline std::span<const AABBs<asset::ICPUBuffer>> getAABBGeometries() const
9797
{
9898
if (!m_AABBGeoms)
99-
return {nullptr,nullptr};
99+
return {};
100100
return {m_AABBGeoms->data(),m_AABBGeoms->size()};
101101
}
102102
inline bool setGeometries(core::smart_refctd_dynamic_array<AABBs<ICPUBuffer>>&& geometries, core::smart_refctd_dynamic_array<uint32_t>&& ranges)

include/nbl/asset/IDescriptorSetLayout.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ class IDescriptorSetLayoutBase : public virtual core::IReferenceCounted // TODO:
150150
// Weird functions for exceptional situations
151151
inline storage_range_index_t findBindingStorageIndex(const storage_offset_t offset) const
152152
{
153-
const auto found = std::upper_bound(m_storageOffsets, m_storageOffsets+m_count, offset, [](storage_range_index_t a, storage_range_index_t b) -> bool {return a.data < b.data; });
154-
const auto ix = m_storageOffsets - found;
153+
const auto found = std::upper_bound(m_storageOffsets,m_storageOffsets+m_count,offset,[](storage_offset_t a, storage_offset_t b)->bool{return a.data<b.data;});
154+
const auto ix = m_storageOffsets-found;
155155
if (ix>=m_count)
156156
return {};
157157
return storage_range_index_t(ix);

include/nbl/video/IDeferredOperation.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ class IDeferredOperation : public IBackendObject
3030
{
3131
const auto retval = execute_impl();
3232
if (retval==STATUS::COMPLETED || retval==STATUS::_ERROR)
33+
{
34+
std::lock_guard lock(vectorLock);
3335
m_resourceTracking.clear();
36+
}
3437
return retval;
3538
}
3639

@@ -66,6 +69,7 @@ class IDeferredOperation : public IBackendObject
6669
private:
6770
friend class ILogicalDevice;
6871
// when we improve allocators, etc. we'll stop using STL containers here
72+
std::mutex vectorLock;
6973
core::vector<core::smart_refctd_ptr<const IReferenceCounted>> m_resourceTracking;
7074
};
7175

include/nbl/video/ILogicalDevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
4646

4747

4848
//! Basic getters
49+
inline system::ILogger* getLogger() const {return m_logger.get();}
50+
4951
inline const IPhysicalDevice* getPhysicalDevice() const { return m_physicalDevice; }
5052

5153
inline const SPhysicalDeviceFeatures& getEnabledFeatures() const { return m_enabledFeatures; }

0 commit comments

Comments
 (0)