Skip to content

KDGpu::PipelineLayout

Module: Public API

Defines the interface between pipeline and shader resources. More...

#include <KDGpu/pipeline_layout.h>

Public Functions

Name
PipelineLayout()
~PipelineLayout()
PipelineLayout(PipelineLayout && other)
PipelineLayout & operator=(PipelineLayout && other)
PipelineLayout(const PipelineLayout & ) =delete
PipelineLayout & operator=(const PipelineLayout & ) =delete
const Handle< PipelineLayout_t > & handle() const
bool isValid() const
operator Handle< PipelineLayout_t >() const

Friends

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

Detailed Description

1
class KDGpu::PipelineLayout;

Defines the interface between pipeline and shader resources.

Vulkan equivalent:VkPipelineLayout

PipelineLayout describes the complete shader interface: which descriptor sets can be bound and what push constant ranges are available. It must be compatible with both the pipeline and the bind groups used.

Key features:

  • Specify bind group layouts (descriptor sets)
  • Define push constant ranges
  • Must match shader declarations
  • Reusable across compatible pipelines

Lifetime: PipelineLayouts are created by Device and must remain valid while referenced by pipelines. They use RAII and clean up automatically.

Usage

Creating a basic pipeline layout:

1
2
3
4
5
6
    KDGpu::BindGroupLayout bindGroupLayout = device.createBindGroupLayout(KDGpu::BindGroupLayoutOptions{
            /* ... */
    });
    KDGpu::PipelineLayout layoutSimple = device.createPipelineLayout(KDGpu::PipelineLayoutOptions{
            .bindGroupLayouts = { bindGroupLayout },
    });

Filename: kdgpu_doc_snippets.cpp

Pipeline layout with push constants:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
    const KDGpu::PushConstantRange myPushConstantRange = {
        .offset = 0,
        .size = sizeof(glm::mat4),
        .shaderStages = KDGpu::ShaderStageFlags(KDGpu::ShaderStageFlagBits::VertexBit),
    };

    KDGpu::PipelineLayout layoutPush = device.createPipelineLayout(KDGpu::PipelineLayoutOptions{
            .bindGroupLayouts = { bindGroupLayout.handle() },
            .pushConstantRanges = {
                    myPushConstantRange },
    });

    // Usage in render pass:
    glm::mat4 modelMatrix = glm::mat4(1.0f);
    renderPass.pushConstant(myPushConstantRange, &modelMatrix);

Filename: kdgpu_doc_snippets.cpp

Multiple bind group layouts:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
    KDGpu::BindGroupLayout set0Layout = device.createBindGroupLayout(KDGpu::BindGroupLayoutOptions{
            /* ... */
    });
    KDGpu::BindGroupLayout set1Layout = device.createBindGroupLayout(KDGpu::BindGroupLayoutOptions{
            /* ... */
    });
    KDGpu::BindGroupLayout set2Layout = device.createBindGroupLayout(KDGpu::BindGroupLayoutOptions{
            /* ... */
    });
    KDGpu::PipelineLayout layoutMulti = device.createPipelineLayout(KDGpu::PipelineLayoutOptions{
            .bindGroupLayouts = {
                    set0Layout, // Set 0: per-frame uniforms
                    set1Layout, // Set 1: per-material textures
                    set2Layout, // Set 2: per-object data
            },
    });

Filename: kdgpu_doc_snippets.cpp

PipelineLayout compatibility:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
    // Layouts are compatible if:
    // 1. They have the same number of descriptor sets
    // 2. Each set has compatible bind group layouts

    KDGpu::PipelineLayout layoutCompat1 = device.createPipelineLayout(KDGpu::PipelineLayoutOptions{
            .bindGroupLayouts = { set0Layout, set1Layout },
    });

    KDGpu::PipelineLayout layoutCompat2 = device.createPipelineLayout(KDGpu::PipelineLayoutOptions{
            .bindGroupLayouts = { set0Layout, set1Layout },
    });

    // These layouts are compatible - bind groups from layout1 can be used with pipeline created from layout2

Filename: kdgpu_doc_snippets.cpp

Sharing layouts between pipelines:

1
2
    // Partial bind group updates example
    // Note: Requires actual renderPass from beginRenderPass()

Filename: kdgpu_doc_snippets.cpp

Vulkan mapping:

  • PipelineLayout creation -> vkCreatePipelineLayout()
  • Used in VkGraphicsPipelineCreateInfo and VkComputePipelineCreateInfo
  • Used in vkCmdBindDescriptorSets()

See also:

PipelineLayoutOptions, BindGroupLayout, GraphicsPipeline, ComputePipeline, BindGroup, Device

KDGpu API Overview

KDGpu to Vulkan API Mapping

Public Functions Documentation

function PipelineLayout

1
PipelineLayout()

function ~PipelineLayout

1
~PipelineLayout()

function PipelineLayout

1
2
3
PipelineLayout(
    PipelineLayout && other
)

function operator=

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

function PipelineLayout

1
2
3
PipelineLayout(
    const PipelineLayout & 
) =delete

function operator=

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

function handle

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

function isValid

1
inline bool isValid() const

function operator Handle< PipelineLayout_t >

1
inline operator Handle< PipelineLayout_t >() const

Friends

friend Device

1
2
3
friend class Device(
    Device 
);

friend operator==

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

    const PipelineLayout & b
);

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