Skip to content

Add vk::compute_pipeline for compute shader support. #35

@SpinnerX

Description

@SpinnerX

Constructing a vk::compute_pipeline is quite similar to constructing vk::pipeline graphics pipeline.

Though there are differences in specification for creating the compute pipeline including additional API's.

Comparing vk::pipeline and vk::compute_pipeline.

vk::pipeline Configuration

The graphics pipeline require there to to specify the pipeline for rendering. These different stages are used for managing the pixels that are being rendered through this pipeline.

For setting up the graphics pipeline in the raw C API for Vulkan is as follows:

typedef struct VkGraphicsPipelineCreateInfo {
    VkStructureType                                  sType;
    const void*                                      pNext;
    VkPipelineCreateFlags                            flags;
    uint32_t                                         stageCount;
    const VkPipelineShaderStageCreateInfo*           pStages;
    const VkPipelineVertexInputStateCreateInfo*      pVertexInputState;
    const VkPipelineInputAssemblyStateCreateInfo*    pInputAssemblyState;
    const VkPipelineTessellationStateCreateInfo*     pTessellationState;
    const VkPipelineViewportStateCreateInfo*         pViewportState;
    const VkPipelineRasterizationStateCreateInfo*    pRasterizationState;
    const VkPipelineMultisampleStateCreateInfo*      pMultisampleState;
    const VkPipelineDepthStencilStateCreateInfo*     pDepthStencilState;
    const VkPipelineColorBlendStateCreateInfo*       pColorBlendState;
    const VkPipelineDynamicStateCreateInfo*          pDynamicState;
    VkPipelineLayout                                 layout;
    VkRenderPass                                     renderPass;
    uint32_t                                         subpass;
    VkPipeline                                       basePipelineHandle;
    int32_t                                          basePipelineIndex;
} VkGraphicsPipelineCreateInfo;

vk::compute_pipeline

As for configuring the compute pipeline. The configuration struct is much simpler and we want to focus on the parameters that do not need to be set by the user.

The configuration for the compute pipeline is simpler. Where the compute pipeline allows to configure a pipeline this particular compute pipeline can be derived from.

Here is what the configuration parameters struct as follows:

typedef struct VkComputePipelineCreateInfo {
    VkStructureType                    sType;
    const void*                        pNext;
    VkPipelineCreateFlags              flags;
    VkPipelineShaderStageCreateInfo    stage;
    VkPipelineLayout                   layout;
    VkPipeline                         basePipelineHandle;
    int32_t                            basePipelineIndex;
} VkComputePipelineCreateInfo;

Expected Behavior

The expected behavior is being able to easily configure a vk::compute_pipeline object with a vk::compute_pipeline_params.

Example Usage:

vk::compute_pipeline_params comp_params = {
    .shader_modules = geometry_resource.handles(),
    .vertex_attributes = geometry_resource.vertex_attributes(),
    .vertex_bind_attributes = geometry_resource.vertex_bind_attributes(),
};

vk::compute_pipeline computing_pipeline(logical_device, comp_params);

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔋internalImplementing standalone tasks or perform code migration.
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions