KDGpu::BindGroupPool
Module: Public API
Memory pool for allocating bind groups (descriptor sets) More...
#include <KDGpu/bind_group_pool.h>
Public Functions
Friends
Detailed Description
| class KDGpu::BindGroupPool;
|
Memory pool for allocating bind groups (descriptor sets)
See:
Vulkan equivalent:VkDescriptorPool
BindGroupPool (known as descriptor pool in Vulkan) is a memory pool from which bind groups (descriptor sets) are allocated. It pre-allocates GPU memory for a certain number of descriptors of various types, providing efficient allocation and deallocation of bind groups.
Key features:
- Pre-allocated memory for descriptor sets
- Configurable resource limits (uniform buffers, samplers, storage buffers, etc.)
- Efficient allocation and reset operations
- Track allocated bind group count
- Optional: KDGpu can manage a default pool for you
Lifetime: Pools are created by Device and typically live for the entire rendering session. All bind groups allocated from a pool become invalid when the pool is destroyed or reset.
Basic pool creation:
| KDGpu::BindGroupPool pool = device.createBindGroupPool(KDGpu::BindGroupPoolOptions{});
|
Filename: kdgpu_doc_snippets.cpp
Using pool with bind groups:
| KDGpu::BindGroupPool pool2 = device.createBindGroupPool(KDGpu::BindGroupPoolOptions{});
KDGpu::BindGroup bindGroup1 = device.createBindGroup(KDGpu::BindGroupOptions{
.layout = layout,
});
KDGpu::BindGroup bindGroup2 = device.createBindGroup(KDGpu::BindGroupOptions{
.layout = layout,
});
// ... allocate up to 100 bind groups
|
Filename: kdgpu_doc_snippets.cpp
Resetting pool:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 | // Allocate and use bind groups for frame N
for (int i = 0; i < 10; ++i) {
KDGpu::BindGroup bg = device.createBindGroup(KDGpu::BindGroupOptions{
.layout = layout,
});
// ... use bind group ...
}
// Frame complete, reset pool for next frame
pool.reset();
// Allocate bind groups for frame N+1 (reuses memory)
for (int i = 0; i < 15; ++i) {
KDGpu::BindGroup bg = device.createBindGroup(KDGpu::BindGroupOptions{
.layout = layout,
});
// ... use bind group ...
}
|
Filename: kdgpu_doc_snippets.cpp
Per-frame pooling strategy:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | struct PerFrameResources {
KDGpu::BindGroupPool pool;
// ... other per-frame resources ...
};
// std::array<PerFrameResources, 3> frameResources; // Triple buffering
// void renderFrame(uint32_t frameIndex, KDGpu::Device &device, KDGpu::BindGroupLayout &layout)
// {
// auto &frame = frameResources[frameIndex];
// frame.pool.clear(); // Clear previous frame's allocations
//
// // Allocate bind groups for this frame
// KDGpu::BindGroup bindGroup = device.createBindGroup(KDGpu::BindGroupOptions{.layout = layout.handle()});
// // ... render ...
// }
|
Filename: kdgpu_doc_snippets.cpp
Pool capacity limits:
| KDGpu::BindGroupPool smallPool = device.createBindGroupPool(KDGpu::BindGroupPoolOptions{});
for (int i = 0; i < 10; ++i) {
KDGpu::BindGroup bg = device.createBindGroup(KDGpu::BindGroupOptions{
.layout = layout,
}); // OK
}
// This may fail or reallocate a larger pool (implementation-dependent)
// KDGpu::BindGroup bg11 = device.createBindGroup(KDGpu::BindGroupOptions{.layout = layout.handle()});
|
Filename: kdgpu_doc_snippets.cpp
Public Functions Documentation
function BindGroupPool
function ~BindGroupPool
function BindGroupPool
| BindGroupPool(
BindGroupPool && other
)
|
function operator=
| BindGroupPool & operator=(
BindGroupPool && other
)
|
function BindGroupPool
| BindGroupPool(
const BindGroupPool &
) =delete
|
function operator=
| BindGroupPool & operator=(
const BindGroupPool &
) =delete
|
function handle
| inline const Handle< BindGroupPool_t > & handle() const
|
function isValid
| inline bool isValid() const
|
function operator Handle< BindGroupPool_t >
| inline operator Handle< BindGroupPool_t >() const
|
function reset
function allocatedBindGroupCount
| uint16_t allocatedBindGroupCount() const
|
function maxBindGroupCount
| uint16_t maxBindGroupCount() const
|
Friends
friend Device
| friend class Device(
Device
);
|
friend operator==
| friend KDGPU_EXPORT bool operator==(
const BindGroupPool & a,
const BindGroupPool & b
);
|
Updated on 2026-03-31 at 00:02:07 +0000