Skip to content

Commit 73fcc8c

Browse files
more DLL symbol fixes, also add some more logging
1 parent c6d7ea0 commit 73fcc8c

File tree

4 files changed

+112
-114
lines changed

4 files changed

+112
-114
lines changed

include/nbl/asset/ICPUBuffer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ class ICPUBuffer : public asset::IBuffer, public asset::IAsset
117117
}
118118

119119
void* data;
120-
};
120+
};
121121

122-
template<
123-
typename Allocator = _NBL_DEFAULT_ALLOCATOR_METATYPE<uint8_t>,
124-
bool = std::is_same<Allocator, core::null_allocator<typename Allocator::value_type> >::value
125-
>
126-
class CCustomAllocatorCPUBuffer;
122+
template<
123+
typename Allocator = _NBL_DEFAULT_ALLOCATOR_METATYPE<uint8_t>,
124+
bool = std::is_same<Allocator, core::null_allocator<typename Allocator::value_type> >::value
125+
>
126+
class CCustomAllocatorCPUBuffer;
127127

128128
using CDummyCPUBuffer = CCustomAllocatorCPUBuffer<core::null_allocator<uint8_t>, true>;
129129

include/nbl/asset/ICPUDescriptorSet.h

Lines changed: 101 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (C) 2018-2022 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4-
54
#ifndef _NBL_ASSET_I_CPU_DESCRIPTOR_SET_H_INCLUDED_
65
#define _NBL_ASSET_I_CPU_DESCRIPTOR_SET_H_INCLUDED_
76

@@ -25,115 +24,115 @@ namespace nbl::asset
2524
@see IDescriptorSet
2625
*/
2726

28-
class ICPUDescriptorSet final : public IDescriptorSet<ICPUDescriptorSetLayout>, public IAsset
27+
class NBL_API2 ICPUDescriptorSet final : public IDescriptorSet<ICPUDescriptorSetLayout>, public IAsset
2928
{
30-
using base_t = IDescriptorSet<ICPUDescriptorSetLayout>;
31-
32-
public:
33-
//! Contructor preallocating memory for SDescriptorInfos which user can fill later (using non-const getDescriptorInfos()).
34-
//! @see getDescriptorInfos()
35-
ICPUDescriptorSet(core::smart_refctd_ptr<ICPUDescriptorSetLayout>&& _layout) : base_t(std::move(_layout)), IAsset()
36-
{
37-
for (uint32_t t = 0u; t < static_cast<uint32_t>(IDescriptor::E_TYPE::ET_COUNT); ++t)
29+
using base_t = IDescriptorSet<ICPUDescriptorSetLayout>;
30+
31+
public:
32+
//! Contructor preallocating memory for SDescriptorInfos which user can fill later (using non-const getDescriptorInfos()).
33+
//! @see getDescriptorInfos()
34+
inline ICPUDescriptorSet(core::smart_refctd_ptr<ICPUDescriptorSetLayout>&& _layout) : base_t(std::move(_layout)), IAsset()
35+
{
36+
for (uint32_t t = 0u; t < static_cast<uint32_t>(IDescriptor::E_TYPE::ET_COUNT); ++t)
37+
{
38+
const auto type = static_cast<IDescriptor::E_TYPE>(t);
39+
const uint32_t count = m_layout->getTotalDescriptorCount(type);
40+
if (count == 0u)
41+
continue;
42+
43+
m_descriptorInfos[t] = core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<ICPUDescriptorSet::SDescriptorInfo>>(count);
44+
}
45+
}
46+
47+
_NBL_STATIC_INLINE_CONSTEXPR auto AssetType = ET_DESCRIPTOR_SET;
48+
inline E_TYPE getAssetType() const override { return AssetType; }
49+
50+
inline ICPUDescriptorSetLayout* getLayout()
3851
{
39-
const auto type = static_cast<IDescriptor::E_TYPE>(t);
40-
const uint32_t count = m_layout->getTotalDescriptorCount(type);
41-
if (count == 0u)
42-
continue;
52+
assert(!isImmutable_debug());
53+
return m_layout.get();
54+
}
55+
56+
inline const ICPUDescriptorSetLayout* getLayout() const { return m_layout.get(); }
4357

44-
m_descriptorInfos[t] = core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<ICPUDescriptorSet::SDescriptorInfo>>(count);
58+
inline bool canBeRestoredFrom(const IAsset* _other) const override
59+
{
60+
auto* other = static_cast<const ICPUDescriptorSet*>(_other);
61+
return m_layout->canBeRestoredFrom(other->m_layout.get());
4562
}
46-
}
47-
48-
_NBL_STATIC_INLINE_CONSTEXPR auto AssetType = ET_DESCRIPTOR_SET;
49-
inline E_TYPE getAssetType() const override { return AssetType; }
50-
51-
inline ICPUDescriptorSetLayout* getLayout()
52-
{
53-
assert(!isImmutable_debug());
54-
return m_layout.get();
55-
}
56-
57-
inline const ICPUDescriptorSetLayout* getLayout() const { return m_layout.get(); }
58-
59-
inline bool canBeRestoredFrom(const IAsset* _other) const override
60-
{
61-
auto* other = static_cast<const ICPUDescriptorSet*>(_other);
62-
return m_layout->canBeRestoredFrom(other->m_layout.get());
63-
}
64-
65-
inline size_t conservativeSizeEstimate() const override
66-
{
67-
assert(!"Invalid code path.");
68-
return 0xdeadbeefull;
69-
}
70-
71-
inline core::SRange<SDescriptorInfo> getDescriptorInfoStorage(const IDescriptor::E_TYPE type) const
72-
{
73-
// TODO: @Hazardu
74-
// Cannot do the mutability check here because it requires the function to be non-const, but the function cannot be non-const because it's called
75-
// from const functions in the asset converter.
76-
// Relevant comments/conversations:
77-
// https://github.com/Devsh-Graphics-Programming/Nabla/pull/345#discussion_r1054258384
78-
// https://github.com/Devsh-Graphics-Programming/Nabla/pull/345#discussion_r1056289599
79-
//
80-
// assert(!isImmutable_debug());
81-
if (!m_descriptorInfos[static_cast<uint32_t>(type)])
82-
return { nullptr, nullptr };
83-
else
84-
return { m_descriptorInfos[static_cast<uint32_t>(type)]->begin(), m_descriptorInfos[static_cast<uint32_t>(type)]->end() };
85-
}
86-
87-
core::SRange<SDescriptorInfo> getDescriptorInfos(const ICPUDescriptorSetLayout::CBindingRedirect::binding_number_t binding, IDescriptor::E_TYPE type = IDescriptor::E_TYPE::ET_COUNT);
88-
89-
core::SRange<const SDescriptorInfo> getDescriptorInfos(const ICPUDescriptorSetLayout::CBindingRedirect::binding_number_t binding, IDescriptor::E_TYPE type = IDescriptor::E_TYPE::ET_COUNT) const;
90-
91-
core::smart_refctd_ptr<IAsset> clone(uint32_t _depth = ~0u) const override;
92-
93-
void convertToDummyObject(uint32_t referenceLevelsBelowToConvert = 0u) override;
94-
95-
protected:
96-
void restoreFromDummy_impl(IAsset* _other, uint32_t _levelsBelow) override;
97-
98-
bool isAnyDependencyDummy_impl(uint32_t _levelsBelow) const override;
99-
100-
virtual ~ICPUDescriptorSet() = default;
101-
102-
private:
103-
static inline IDescriptor::E_CATEGORY getCategoryFromType(const IDescriptor::E_TYPE type)
104-
{
105-
auto category = IDescriptor::E_CATEGORY::EC_COUNT;
106-
switch (type)
63+
64+
inline size_t conservativeSizeEstimate() const override
10765
{
108-
case IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER: [[fallthrough]];
109-
case IDescriptor::E_TYPE::ET_STORAGE_IMAGE: [[fallthrough]];
110-
case IDescriptor::E_TYPE::ET_INPUT_ATTACHMENT:
111-
category = IDescriptor::E_CATEGORY::EC_IMAGE;
112-
break;
113-
114-
case IDescriptor::E_TYPE::ET_UNIFORM_BUFFER: [[fallthrough]];
115-
case IDescriptor::E_TYPE::ET_UNIFORM_BUFFER_DYNAMIC: [[fallthrough]];
116-
case IDescriptor::E_TYPE::ET_STORAGE_BUFFER: [[fallthrough]];
117-
case IDescriptor::E_TYPE::ET_STORAGE_BUFFER_DYNAMIC:
118-
category = IDescriptor::E_CATEGORY::EC_BUFFER;
119-
break;
120-
121-
case IDescriptor::E_TYPE::ET_UNIFORM_TEXEL_BUFFER:
122-
case IDescriptor::E_TYPE::ET_STORAGE_TEXEL_BUFFER:
123-
category = IDescriptor::E_CATEGORY::EC_BUFFER_VIEW;
124-
break;
125-
126-
case IDescriptor::E_TYPE::ET_ACCELERATION_STRUCTURE:
127-
category = IDescriptor::E_CATEGORY::EC_ACCELERATION_STRUCTURE;
128-
break;
129-
130-
default:
13166
assert(!"Invalid code path.");
67+
return 0xdeadbeefull;
68+
}
69+
70+
inline core::SRange<SDescriptorInfo> getDescriptorInfoStorage(const IDescriptor::E_TYPE type) const
71+
{
72+
// TODO: @Hazardu
73+
// Cannot do the mutability check here because it requires the function to be non-const, but the function cannot be non-const because it's called
74+
// from const functions in the asset converter.
75+
// Relevant comments/conversations:
76+
// https://github.com/Devsh-Graphics-Programming/Nabla/pull/345#discussion_r1054258384
77+
// https://github.com/Devsh-Graphics-Programming/Nabla/pull/345#discussion_r1056289599
78+
//
79+
// assert(!isImmutable_debug());
80+
if (!m_descriptorInfos[static_cast<uint32_t>(type)])
81+
return { nullptr, nullptr };
82+
else
83+
return { m_descriptorInfos[static_cast<uint32_t>(type)]->begin(), m_descriptorInfos[static_cast<uint32_t>(type)]->end() };
84+
}
85+
86+
core::SRange<SDescriptorInfo> getDescriptorInfos(const ICPUDescriptorSetLayout::CBindingRedirect::binding_number_t binding, IDescriptor::E_TYPE type = IDescriptor::E_TYPE::ET_COUNT);
87+
88+
core::SRange<const SDescriptorInfo> getDescriptorInfos(const ICPUDescriptorSetLayout::CBindingRedirect::binding_number_t binding, IDescriptor::E_TYPE type = IDescriptor::E_TYPE::ET_COUNT) const;
89+
90+
core::smart_refctd_ptr<IAsset> clone(uint32_t _depth = ~0u) const override;
91+
92+
void convertToDummyObject(uint32_t referenceLevelsBelowToConvert = 0u) override;
93+
94+
protected:
95+
void restoreFromDummy_impl(IAsset* _other, uint32_t _levelsBelow) override;
96+
97+
bool isAnyDependencyDummy_impl(uint32_t _levelsBelow) const override;
98+
99+
virtual ~ICPUDescriptorSet() = default;
100+
101+
private:
102+
static inline IDescriptor::E_CATEGORY getCategoryFromType(const IDescriptor::E_TYPE type)
103+
{
104+
auto category = IDescriptor::E_CATEGORY::EC_COUNT;
105+
switch (type)
106+
{
107+
case IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER: [[fallthrough]];
108+
case IDescriptor::E_TYPE::ET_STORAGE_IMAGE: [[fallthrough]];
109+
case IDescriptor::E_TYPE::ET_INPUT_ATTACHMENT:
110+
category = IDescriptor::E_CATEGORY::EC_IMAGE;
111+
break;
112+
113+
case IDescriptor::E_TYPE::ET_UNIFORM_BUFFER: [[fallthrough]];
114+
case IDescriptor::E_TYPE::ET_UNIFORM_BUFFER_DYNAMIC: [[fallthrough]];
115+
case IDescriptor::E_TYPE::ET_STORAGE_BUFFER: [[fallthrough]];
116+
case IDescriptor::E_TYPE::ET_STORAGE_BUFFER_DYNAMIC:
117+
category = IDescriptor::E_CATEGORY::EC_BUFFER;
118+
break;
119+
120+
case IDescriptor::E_TYPE::ET_UNIFORM_TEXEL_BUFFER:
121+
case IDescriptor::E_TYPE::ET_STORAGE_TEXEL_BUFFER:
122+
category = IDescriptor::E_CATEGORY::EC_BUFFER_VIEW;
123+
break;
124+
125+
case IDescriptor::E_TYPE::ET_ACCELERATION_STRUCTURE:
126+
category = IDescriptor::E_CATEGORY::EC_ACCELERATION_STRUCTURE;
127+
break;
128+
129+
default:
130+
assert(!"Invalid code path.");
131+
}
132+
return category;
132133
}
133-
return category;
134-
}
135134

136-
core::smart_refctd_dynamic_array<ICPUDescriptorSet::SDescriptorInfo> m_descriptorInfos[static_cast<uint32_t>(IDescriptor::E_TYPE::ET_COUNT)];
135+
core::smart_refctd_dynamic_array<ICPUDescriptorSet::SDescriptorInfo> m_descriptorInfos[static_cast<uint32_t>(IDescriptor::E_TYPE::ET_COUNT)];
137136
};
138137

139138
}

include/nbl/video/IGPUCommandBuffer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class NBL_API2 IGPUCommandBuffer :
143143

144144
inline bool validate_updateBuffer(IGPUBuffer* dstBuffer, size_t dstOffset, size_t dataSize, const void* pData)
145145
{
146+
if (!dstBuffer)
147+
return false;
146148
if (!this->isCompatibleDevicewise(dstBuffer))
147149
return false;
148150
if ((dstOffset & 0x03ull) != 0ull)

src/nbl/video/IGPUCommandBuffer.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,6 @@ bool IGPUCommandBuffer::bindComputePipeline(const compute_pipeline_t* pipeline)
304304
if (!this->isCompatibleDevicewise(pipeline))
305305
return false;
306306

307-
if (pipeline->getAPIType() != getAPIType())
308-
return false;
309-
310307
if (!m_cmdpool->m_commandListPool.emplace<IGPUCommandPool::CBindComputePipelineCmd>(m_commandList, core::smart_refctd_ptr<const IGPUComputePipeline>(pipeline)))
311308
return false;
312309

@@ -320,11 +317,11 @@ bool IGPUCommandBuffer::updateBuffer(buffer_t* dstBuffer, size_t dstOffset, size
320317
if (!checkStateBeforeRecording())
321318
return false;
322319

323-
if (!dstBuffer || dstBuffer->getAPIType() != getAPIType())
324-
return false;
325-
326320
if (!validate_updateBuffer(dstBuffer, dstOffset, dataSize, pData))
321+
{
322+
m_logger.log("Invalid arguments see `IGPUCommandBuffer::validate_updateBuffer`.", system::ILogger::ELL_ERROR);
327323
return false;
324+
}
328325

329326
if (!m_cmdpool->m_commandListPool.emplace<IGPUCommandPool::CUpdateBufferCmd>(m_commandList, core::smart_refctd_ptr<const IGPUBuffer>(dstBuffer)))
330327
return false;

0 commit comments

Comments
 (0)