Vulkan规范:第九章 9.1 ~9.5

来源:互联网 发布:对付淘宝无良卖家 编辑:程序博客网 时间:2024/05/16 09:02

9.3. 管线的销毁

可调用如下命令来销毁一个图形或者计算管线:

void vkDestroyPipeline(    VkDevice                                    device,    VkPipeline                                  pipeline,    const VkAllocationCallbacks*                pAllocator);
  • device 是需要销毁管线的逻辑设备。

  • pipeline 是需要被销毁的管线的handle。

  • pAllocator 控制了CPU端内存分配,如 Memory Allocation 一章所描述。

正确使用
  • All submitted commands that refer to pipeline must have completed execution

  • If VkAllocationCallbacks were provided when pipeline was created, a compatible set of callbacks must be provided here

  • If no VkAllocationCallbacks were provided when pipeline was created, pAllocator must be NULL

Valid Usage (Implicit)
  • device must be a valid VkDevice handle

  • If pipeline is not VK_NULL_HANDLEpipeline must be a valid VkPipeline handle

  • If pAllocator is not NULLpAllocator must be a pointer to a valid VkAllocationCallbacks structure

  • If pipeline is a valid handle, it must have been created, allocated, or retrieved from device

Host Synchronization
  • Host access to pipeline must be externally synchronized

9.4. 多管线的创建

可传递一个数组的VkGraphicsPipelineCreateInfo或者VkComputePipelineCreateInfovkCreateGraphicsPipelines 和 vkCreateComputePipelines命令。应用程序可以在单个调用中成组的创建相似的管线,Vulkan实现被鼓励寻求在组创建的机会中重用资源。

当一个应用程序尝试在单个命令中创建多个管线,也还是有可能一些子集会创建失败。 这种情况下,在输出的pPipelines对应入口点将被赋值为VK_NULL_HANDLE。 如果任何管线创建失败(例如,因为内存错误),vkCreate*Pipelines 命令将会返回一个错误码。 Vulkan实现将尝试创建所有的管线,那些失败的只返回VK_NULL_HANDLE 。

9.5. 管线衍生(Pipeline Derivatives)

一个管线衍生是父管线创建的一个子管线,父子管线拥有很大的共同性。 衍生管线的设计目标是用父管线当作起始点来创建管线会更加便宜,而且和父子管线之间切换或绑定会更加高效(CPU和GPU端都如此)。

设置Vk*PipelineCreateInfo的flag为VK_PIPELINE_CREATE_DERIVATIVE_BIT来创建衍生管线。 如果这个标志位被设置了,那么basePipelineHandle 或者basePipelineIndex 成员之一必须有有效的handle/索引来表示父管线。 如果使用了basePipelineHandle,那么父管线必须已经被创建好了。 如果使用了basePipelineIndex,那么可在同一个命令中创建父管线。 对于basePipelineHandle来说,VK_NULL_HANDLE表示一个无效的handle, 对于basePipelineIndex来说, -1 表示一个无效的索引。 如果使用了basePipelineIndex,基管线必须在数组中更早出现。 基管线必须带有VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT这个标志位被创建。