Skip to content

Commit 1fbbc06

Browse files
committed
replace StreamingTransientDataBufferST with GeneralpurposeAddressAllocator host allocator + LinearAddressAllocatorST sub-allocator combo & use allocator type traits to handle them, update examples_tests submodule, leave some TODO comments
1 parent 421f86c commit 1fbbc06

File tree

3 files changed

+182
-116
lines changed

3 files changed

+182
-116
lines changed

examples_tests

include/nbl/ext/ImGui/ImGui.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ class UI final : public core::IReferenceCounted
1111
public:
1212
struct MDI
1313
{
14-
using COMPOSE_T = nbl::video::StreamingTransientDataBufferST<nbl::core::allocator<uint8_t>>;
14+
using COMPOSE_T = nbl::video::IGPUBuffer; //! composes memory available for the allocator which allocates submemory ranges
15+
using ALLOCATOR_TRAITS_T = nbl::core::address_allocator_traits<nbl::core::GeneralpurposeAddressAllocator<uint32_t>>; //! traits for MDI buffer allocator - requests memory range from the compose memory
16+
using SUBALLOCATOR_TRAITS_T = nbl::core::address_allocator_traits<nbl::core::LinearAddressAllocatorST<uint32_t>>; //! traits for MDI buffer suballocator - fills the data given the mdi allocator memory request
1517

1618
enum E_BUFFER_CONTENT : uint8_t
1719
{
@@ -23,7 +25,8 @@ class UI final : public core::IReferenceCounted
2325
EBC_COUNT,
2426
};
2527

26-
nbl::core::smart_refctd_ptr<typename COMPOSE_T> streamingTDBufferST; //! composed buffer layout is [EBC_DRAW_INDIRECT_STRUCTURES] [EBC_ELEMENT_STRUCTURES] [EBC_INDEX_BUFFERS] [EBC_VERTEX_BUFFERS]
28+
typename ALLOCATOR_TRAITS_T::allocator_type allocator; //! mdi buffer allocator
29+
nbl::core::smart_refctd_ptr<typename COMPOSE_T> buffer; //! streaming mdi buffer
2730

2831
static constexpr auto MDI_BUFFER_REQUIRED_ALLOCATE_FLAGS = nbl::core::bitflag<nbl::video::IDeviceMemoryAllocation::E_MEMORY_ALLOCATE_FLAGS>(nbl::video::IDeviceMemoryAllocation::EMAF_DEVICE_ADDRESS_BIT); //! required flags
2932
static constexpr auto MDI_BUFFER_REQUIRED_USAGE_FLAGS = nbl::core::bitflag(nbl::asset::IBuffer::EUF_INDIRECT_BUFFER_BIT) | nbl::asset::IBuffer::EUF_INDEX_BUFFER_BIT | nbl::asset::IBuffer::EUF_VERTEX_BUFFER_BIT | nbl::asset::IBuffer::EUF_SHADER_DEVICE_ADDRESS_BIT; //! required flags
@@ -58,7 +61,7 @@ class UI final : public core::IReferenceCounted
5861
uint32_t subpassIx = 0u; //! optional, default value used if not provided
5962
S_RESOURCE_PARAMETERS resources; //! optional, default parameters used if not provided
6063
nbl::video::IGPUPipelineCache* const pipelineCache = nullptr; //! optional, no cache used if not provided
61-
typename MDI::COMPOSE_T* const streamingMDIBuffer = nullptr; //! optional, default MDI buffer allocated if not provided
64+
typename MDI::COMPOSE_T* const streamingBuffer = nullptr; //! optional, default MDI buffer allocated if not provided
6265
};
6366

6467
//! parameters which may change every frame, used with the .update call to interact with ImGuiIO; we require a very *required* minimum - if you need to cover more IO options simply get the IO with ImGui::GetIO() to customize them (they all have default values you can change before calling the .update)
@@ -109,7 +112,10 @@ class UI final : public core::IReferenceCounted
109112
inline nbl::video::IGPUImageView* getFontAtlasView() { return m_fontAtlasTexture.get(); }
110113

111114
//! mdi streaming buffer
112-
inline typename MDI::COMPOSE_T* getStreamingBuffer() { return m_mdi.streamingTDBufferST.get(); }
115+
inline typename MDI::COMPOSE_T* getStreamingBuffer() { return m_mdi.buffer.get(); }
116+
117+
//! mdi buffer allocator
118+
inline typename MDI::ALLOCATOR_TRAITS_T::allocator_type* getStreamingAllocator() { return &m_mdi.allocator; }
113119

114120
//! ImGUI context, you are supposed to cast it, eg. reinterpret_cast<ImGuiContext*>(this->getContext());
115121
void* getContext();

0 commit comments

Comments
 (0)