Skip to content

Commit 6b0389a

Browse files
authored
bugfix: resolve build issues for linux (#479)
* bugfix: resolve build issues for linux Signed-off-by: Michael Pollind <mpollind@gmail.com> * address comments Signed-off-by: Michael Pollind <mpollind@gmail.com> * address comments Signed-off-by: Michael Pollind <mpollind@gmail.com> * make delete protected Signed-off-by: Michael Pollind <mpollind@gmail.com> * try to address comments Signed-off-by: Michael Pollind <mpollind@gmail.com> * workaround using destroying_delete_t Signed-off-by: Michael Pollind <mpollind@gmail.com> * revert delete Signed-off-by: Michael Pollind <mpollind@gmail.com> * moved delete to protected Signed-off-by: Michael Pollind <mpollind@gmail.com> --------- Signed-off-by: Michael Pollind <mpollind@gmail.com>
1 parent 6dc8448 commit 6b0389a

File tree

5 files changed

+52
-23
lines changed

5 files changed

+52
-23
lines changed

include/nbl/asset/IDescriptorSetLayout.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ class IDescriptorSetLayout : public virtual core::IReferenceCounted
346346
protected:
347347
IDescriptorSetLayout(const SBinding* const _begin, const SBinding* const _end)
348348
{
349-
core::vector<CBindingRedirect::SBuildInfo> buildInfo_descriptors[static_cast<uint32_t>(asset::IDescriptor::E_TYPE::ET_COUNT)];
350-
core::vector<CBindingRedirect::SBuildInfo> buildInfo_immutableSamplers;
351-
core::vector<CBindingRedirect::SBuildInfo> buildInfo_mutableSamplers;
349+
core::vector<typename CBindingRedirect::SBuildInfo> buildInfo_descriptors[static_cast<uint32_t>(asset::IDescriptor::E_TYPE::ET_COUNT)];
350+
core::vector<typename CBindingRedirect::SBuildInfo> buildInfo_immutableSamplers;
351+
core::vector<typename CBindingRedirect::SBuildInfo> buildInfo_mutableSamplers;
352352

353353
for (auto b = _begin; b != _end; ++b)
354354
{
@@ -376,7 +376,7 @@ class IDescriptorSetLayout : public virtual core::IReferenceCounted
376376
{
377377
if (b->type == IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER && b->samplers)
378378
{
379-
const auto localOffset = m_immutableSamplerRedirect.getStorageOffset(CBindingRedirect::binding_number_t(b->binding)).data;
379+
const auto localOffset = m_immutableSamplerRedirect.getStorageOffset(typename CBindingRedirect::binding_number_t(b->binding)).data;
380380
assert(localOffset != m_immutableSamplerRedirect.Invalid);
381381

382382
auto* dst = m_samplers->begin() + localOffset;

include/nbl/asset/metadata/IRenderpassIndependentPipelineMetadata.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
#include "nbl/asset/ICPUImageView.h"
1313
#include "nbl/asset/ICPURenderpassIndependentPipeline.h"
14+
#include "nbl/asset/IDescriptor.h"
15+
#include "nbl/core/util/to_underlying.h"
1416

1517
#include <compare>
1618

@@ -103,16 +105,15 @@ class IRenderpassIndependentPipelineMetadata : public core::Interface
103105

104106
auto operator<=>(const PushConstant&) const = default;
105107
};
106-
107-
enum E_TYPE
108+
enum class E_TYPE: uint8_t
108109
{
109-
ET_COMBINED_IMAGE_SAMPLER = IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER,
110-
ET_STORAGE_IMAGE = IDescriptor::E_TYPE::ET_STORAGE_IMAGE,
111-
ET_UNIFORM_TEXEL_BUFFER = IDescriptor::E_TYPE::ET_UNIFORM_TEXEL_BUFFER,
112-
ET_STORAGE_TEXEL_BUFFER = IDescriptor::E_TYPE::ET_STORAGE_TEXEL_BUFFER,
113-
ET_UNIFORM_BUFFER = IDescriptor::E_TYPE::ET_UNIFORM_BUFFER,
114-
ET_STORAGE_BUFFER = IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
115-
ET_INPUT_ATTACHMENT = IDescriptor::E_TYPE::ET_INPUT_ATTACHMENT,
110+
ET_COMBINED_IMAGE_SAMPLER = nbl::core::to_underlying(IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER),
111+
ET_STORAGE_IMAGE = nbl::core::to_underlying(IDescriptor::E_TYPE::ET_STORAGE_IMAGE),
112+
ET_UNIFORM_TEXEL_BUFFER = nbl::core::to_underlying(IDescriptor::E_TYPE::ET_UNIFORM_TEXEL_BUFFER),
113+
ET_STORAGE_TEXEL_BUFFER = nbl::core::to_underlying(IDescriptor::E_TYPE::ET_STORAGE_TEXEL_BUFFER),
114+
ET_UNIFORM_BUFFER = nbl::core::to_underlying(IDescriptor::E_TYPE::ET_UNIFORM_BUFFER),
115+
ET_STORAGE_BUFFER = nbl::core::to_underlying(IDescriptor::E_TYPE::ET_STORAGE_BUFFER),
116+
ET_INPUT_ATTACHMENT = nbl::core::to_underlying(IDescriptor::E_TYPE::ET_INPUT_ATTACHMENT),
116117
ET_PUSH_CONSTANT = 11
117118
};
118119
E_TYPE type;

include/nbl/core/util/to_underlying.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
5+
#ifndef _NBL_CORE_C_TO_UNDERLYING_H_INCLUDED_
6+
#define _NBL_CORE_C_TO_UNDERLYING_H_INCLUDED_
7+
8+
namespace nbl::core
9+
{
10+
#if defined(__cpp_lib_to_underlying)
11+
using to_underlying = std::to_underlying;
12+
#else
13+
template<typename E>
14+
constexpr auto to_underlying(E e) -> typename std::underlying_type<E>::type
15+
{
16+
return static_cast<typename std::underlying_type<E>::type>(e);
17+
}
18+
#endif
19+
}
20+
21+
#endif

include/nbl/video/IGPUCommandPool.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,16 @@ class IGPUCommandPool : public core::IReferenceCounted, public IBackendObject
3939
friend class CCommandSegment;
4040

4141
public:
42-
virtual ~ICommand() {}
42+
virtual ~ICommand() = default;
4343

4444
// static void* operator new(std::size_t size) = delete;
4545
static void* operator new[](std::size_t size) = delete;
4646
// static void* operator new(std::size_t size, std::align_val_t al) = delete;
4747
static void* operator new[](std::size_t size, std::align_val_t al) = delete;
4848

49-
// static void operator delete (void* ptr) = delete;
5049
static void operator delete[](void* ptr) = delete;
51-
static void operator delete (void* ptr, std::align_val_t al) = delete;
5250
static void operator delete[](void* ptr, std::align_val_t al) = delete;
53-
static void operator delete (void* ptr, std::size_t sz) = delete;
5451
static void operator delete[](void* ptr, std::size_t sz) = delete;
55-
static void operator delete (void* ptr, std::size_t sz, std::align_val_t al) = delete;
5652
static void operator delete[](void* ptr, std::size_t sz, std::align_val_t al) = delete;
5753

5854
inline uint32_t getSize() const { return m_size; }
@@ -64,7 +60,16 @@ class IGPUCommandPool : public core::IReferenceCounted, public IBackendObject
6460
assert(m_size % alignof(ICommand) == 0);
6561
}
6662

63+
void operator delete(ICommand* ptr, std::destroying_delete_t) { ptr->~ICommand(); }
64+
void operator delete( ICommand* ptr, std::destroying_delete_t,
65+
std::align_val_t al ) { ptr->~ICommand(); }
66+
void operator delete( ICommand* ptr, std::destroying_delete_t, std::size_t sz ) { ptr->~ICommand(); }
67+
void operator delete( ICommand* ptr, std::destroying_delete_t,
68+
std::size_t sz, std::align_val_t al ) { ptr->~ICommand(); }
69+
70+
6771
private:
72+
6873
friend CCommandSegment;
6974

7075
const uint32_t m_size;
@@ -88,6 +93,10 @@ class IGPUCommandPool : public core::IReferenceCounted, public IBackendObject
8893
{
8994
struct header_t
9095
{
96+
public:
97+
template<typename... Args>
98+
inline header_t(Args&&... args) : commandAllocator(std::forward<Args>(args)...) {}
99+
91100
core::LinearAddressAllocator<uint32_t> commandAllocator;
92101
CCommandSegment* next = nullptr;
93102

@@ -98,12 +107,10 @@ class IGPUCommandPool : public core::IReferenceCounted, public IBackendObject
98107
public:
99108
static inline constexpr uint32_t STORAGE_SIZE = COMMAND_SEGMENT_SIZE - core::roundUp(sizeof(header_t), alignof(ICommand));
100109

101-
CCommandSegment(CCommandSegment* prev)
110+
CCommandSegment(CCommandSegment* prev):
111+
m_header(nullptr, 0u, 0u, alignof(ICommand), STORAGE_SIZE)
102112
{
103113
static_assert(alignof(ICommand) == COMMAND_SEGMENT_ALIGNMENT);
104-
m_header.commandAllocator = core::LinearAddressAllocator<uint32_t>(nullptr, 0u, 0u, alignof(ICommand), STORAGE_SIZE);
105-
m_header.next = nullptr;
106-
107114
wipeNextCommandSize();
108115

109116
if (prev)

src/nbl/asset/interchange/IRenderpassIndependentPipelineLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void IRenderpassIndependentPipelineLoader::initialize()
4747
{
4848
auto& semantic = (m_basicViewParamsSemantics->end()-i-1u)[0];
4949
semantic.type = types[i];
50-
semantic.descriptorSection.type = IRenderpassIndependentPipelineMetadata::ShaderInput::ET_UNIFORM_BUFFER;
50+
semantic.descriptorSection.type = IRenderpassIndependentPipelineMetadata::ShaderInput::E_TYPE::ET_UNIFORM_BUFFER;
5151
semantic.descriptorSection.uniformBufferObject.binding = ds1layout->getDescriptorRedirect(IDescriptor::E_TYPE::ET_UNIFORM_BUFFER).getBinding(asset::ICPUDescriptorSetLayout::CBindingRedirect::storage_range_index_t{ 0 }).data;
5252
semantic.descriptorSection.uniformBufferObject.set = 1u;
5353
semantic.descriptorSection.uniformBufferObject.relByteoffset = relOffsets[i];

0 commit comments

Comments
 (0)