Skip to content

KDGpu::BindGroupPool

Module: Public API

Memory pool for allocating bind groups (descriptor sets) More...

#include <KDGpu/bind_group_pool.h>

Public Functions

Name
BindGroupPool()
~BindGroupPool()
BindGroupPool(BindGroupPool && other)
BindGroupPool & operator=(BindGroupPool && other)
BindGroupPool(const BindGroupPool & ) =delete
BindGroupPool & operator=(const BindGroupPool & ) =delete
const Handle< BindGroupPool_t > & handle() const
bool isValid() const
operator Handle< BindGroupPool_t >() const
void reset()
uint16_t allocatedBindGroupCount() const
uint16_t maxBindGroupCount() const

Friends

Name
class Device
KDGPU_EXPORT bool operator==(const BindGroupPool & a, const BindGroupPool & b)

Detailed Description

1
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:

1
    KDGpu::BindGroupPool pool = device.createBindGroupPool(KDGpu::BindGroupPoolOptions{});

Filename: kdgpu_doc_snippets.cpp

Using pool with bind groups:

1
2
3
4
5
6
7
8
9
    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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    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

1
BindGroupPool()

function ~BindGroupPool

1
~BindGroupPool()

function BindGroupPool

1
2
3
BindGroupPool(
    BindGroupPool && other
)

function operator=

1
2
3
BindGroupPool & operator=(
    BindGroupPool && other
)

function BindGroupPool

1
2
3
BindGroupPool(
    const BindGroupPool & 
) =delete

function operator=

1
2
3
BindGroupPool & operator=(
    const BindGroupPool & 
) =delete

function handle

1
inline const Handle< BindGroupPool_t > & handle() const

function isValid

1
inline bool isValid() const

function operator Handle< BindGroupPool_t >

1
inline operator Handle< BindGroupPool_t >() const

function reset

1
void reset()

function allocatedBindGroupCount

1
uint16_t allocatedBindGroupCount() const

function maxBindGroupCount

1
uint16_t maxBindGroupCount() const

Friends

friend Device

1
2
3
friend class Device(
    Device 
);

friend operator==

1
2
3
4
5
friend KDGPU_EXPORT bool operator==(
    const BindGroupPool & a,

    const BindGroupPool & b
);

Updated on 2026-03-31 at 00:02:07 +0000