Compute pipelines consist of a single static compute shader stage and the pipeline layout.
The compute pipeline represents a compute shader and is created by calling
vkCreateComputePipelines with module and pName selecting
an entry point from a shader module, where that entry point defines a valid
compute shader, in the VkPipelineShaderStageCreateInfo structure
contained within the VkComputePipelineCreateInfo structure.
To create compute pipelines, call:
VkResult vkCreateComputePipelines(
VkDevice device,
VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkComputePipelineCreateInfo* pCreateInfos,
const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipelines);
device is the logical device that creates the compute pipelines.
pipelineCache is either VK_NULL_HANDLE, indicating that
pipeline caching is disabled; or the handle of a valid
pipeline cache object, in which case use of that
cache is enabled for the duration of the command.
createInfoCount is the length of the pCreateInfos and
pPipelines arrays.
pCreateInfos is an array of VkComputePipelineCreateInfo
structures.
pAllocator controls host memory allocation as described in the
Memory Allocation chapter.
pPipelines is a pointer to an array in which the resulting compute
pipeline objects are returned.
| editing-note | |
|---|---|
TODO (Jon) - Should we say something like “the i’th element of the
|
The VkComputePipelineCreateInfo structure is defined as:
typedef struct VkComputePipelineCreateInfo {
VkStructureType sType;
const void* pNext;
VkPipelineCreateFlags flags;
VkPipelineShaderStageCreateInfo stage;
VkPipelineLayout layout;
VkPipeline basePipelineHandle;
int32_t basePipelineIndex;
} VkComputePipelineCreateInfo;
sType is the type of this structure.
pNext is NULL or a pointer to an extension-specific structure.
flags provides options for pipeline creation, and is of type
VkPipelineCreateFlagBits.
stage is a VkPipelineShaderStageCreateInfo describing the
compute shader.
layout is the description of binding locations used by both the
pipeline and descriptor sets used with the pipeline.
basePipelineHandle is a pipeline to derive from
basePipelineIndex is an index into the pCreateInfos
parameter to use as a pipeline to derive from
The parameters basePipelineHandle and basePipelineIndex are
described in more detail in Pipeline Derivatives.
stage points to a structure of type
VkPipelineShaderStageCreateInfo.
The VkPipelineShaderStageCreateInfo structure is defined as:
typedef struct VkPipelineShaderStageCreateInfo {
VkStructureType sType;
const void* pNext;
VkPipelineShaderStageCreateFlags flags;
VkShaderStageFlagBits stage;
VkShaderModule module;
const char* pName;
const VkSpecializationInfo* pSpecializationInfo;
} VkPipelineShaderStageCreateInfo;
sType is the type of this structure.
pNext is NULL or a pointer to an extension-specific structure.
flags is reserved for future use.
stage names a single pipeline stage.
Bits which can be set include:
typedef enum VkShaderStageFlagBits {
VK_SHADER_STAGE_VERTEX_BIT = 0x00000001,
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x00000002,
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004,
VK_SHADER_STAGE_GEOMETRY_BIT = 0x00000008,
VK_SHADER_STAGE_FRAGMENT_BIT = 0x00000010,
VK_SHADER_STAGE_COMPUTE_BIT = 0x00000020,
VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F,
VK_SHADER_STAGE_ALL = 0x7FFFFFFF,
} VkShaderStageFlagBits;
module is a VkShaderModule object that contains the shader
for this stage.
pName is a pointer to a null-terminated UTF-8 string specifying
the entry point name of the shader for this stage.
pSpecializationInfo is a pointer to VkSpecializationInfo, as
described in Specialization Constants, and can be NULL.