一旦管线被创建完成,可以使用一个命令把它绑定到命令缓冲区:
void vkCmdBindPipeline(
VkCommandBuffer commandBuffer,
VkPipelineBindPoint pipelineBindPoint,
VkPipeline pipeline);
-
commandBuffer
是管线将要绑定的命令缓冲区。 -
pipelineBindPoint
指定了绑定点,必须是如下的值之一。typedef enum VkPipelineBindPoint { VK_PIPELINE_BIND_POINT_GRAPHICS = 0, VK_PIPELINE_BIND_POINT_COMPUTE = 1, } VkPipelineBindPoint;
specifying whether
pipeline
will be bound as a compute (VK_PIPELINE_BIND_POINT_COMPUTE
) or graphics (VK_PIPELINE_BIND_POINT_GRAPHICS
) pipeline. There are separate bind points for each of graphics and compute, so binding one does not disturb the other. -
pipeline
是将被绑定的管线。
绑定完成后,该绑定影响命令缓冲区中稍后的图形和计算命令,直到新的管线被绑定到绑定点。 绑定到VK_PIPELINE_BIND_POINT_COMPUTE
的管线控制了vkCmdDispatch
and vkCmdDispatchIndirect
的行为。 绑定到VK_PIPELINE_BIND_POINT_GRAPHICS
的管线控制了vkCmdDraw
, vkCmdDrawIndexed
, vkCmdDrawIndirect
, and vkCmdDrawIndexedIndirect
的行为。 其他的命令不受管线状态的影响。
正确使用
-
若
pipelineBindPoint
是VK_PIPELINE_BIND_POINT_COMPUTE
,分配出commandBuffer
的VkCommandPool
必须支持计算操作。 -
若
pipelineBindPoint
是VK_PIPELINE_BIND_POINT_GRAPHICS
,分配出commandBuffer
的VkCommandPool
必须支持图像操作。 -
若
pipelineBindPoint
是VK_PIPELINE_BIND_POINT_COMPUTE
,pipeline
必须是计算管线。 -
若
pipelineBindPoint
是VK_PIPELINE_BIND_POINT_GRAPHICS
,pipeline
必须是图形管线。 -
若variable multisample rate 特征不受支持,
pipeline
就是图形管线,当前subpass没有附件,当转移到当前subpass后 这并不是第一次对图形管线调用这个函数,由此管线指定的采样数必须和前一个管线匹配。
Valid Usage (Implicit)
-
commandBuffer
must be a validVkCommandBuffer
handle -
pipelineBindPoint
must be a validVkPipelineBindPoint
value -
pipeline
must be a validVkPipeline
handle -
commandBuffer
must be in the recording state -
The
VkCommandPool
thatcommandBuffer
was allocated from must support graphics, or compute operations -
Both of
commandBuffer
, andpipeline
must have been created, allocated, or retrieved from the sameVkDevice
Host Synchronization
-
Host access to
commandBuffer
must be externally synchronized -
Host access to the
VkCommandPool
thatcommandBuffer
was allocated from must be externally synchronized
Command Properties
Command Buffer Levels | Render Pass Scope | Supported Queue Types | Pipeline Type |
---|---|---|---|
Primary | Both | Graphics |