C Specification

Once shader objects have been created, they can be bound to the command buffer using the command:

// Provided by VK_EXT_shader_object
void vkCmdBindShadersEXT(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    stageCount,
    const VkShaderStageFlagBits*                pStages,
    const VkShaderEXT*                          pShaders);

Parameters

  • commandBuffer is the command buffer that the shader object will be bound to.

  • stageCount is the length of the pStages and pShaders arrays.

  • pStages is a pointer to an array of VkShaderStageFlagBits values specifying one stage per array index that is affected by the corresponding value in the pShaders array.

  • pShaders is a pointer to an array of VkShaderEXT handles and/or VK_NULL_HANDLE values describing the shader binding operations to be performed on each stage in pStages.

Description

When binding linked shaders, an application may bind them in any combination of one or more calls to vkCmdBindShadersEXT (i.e., shaders that were created linked together do not need to be bound in the same vkCmdBindShadersEXT call).

Any shader object bound to a particular stage may be unbound by setting its value in pShaders to VK_NULL_HANDLE. If pShaders is NULL, vkCmdBindShadersEXT behaves as if pShaders was an array of stageCount VK_NULL_HANDLE values (i.e., any shaders bound to the stages specified in pStages are unbound).

Valid Usage
  • VUID-vkCmdBindShadersEXT-None-08462
    The shaderObject feature must be enabled

  • VUID-vkCmdBindShadersEXT-pStages-08463
    Every element of pStages must be unique

  • VUID-vkCmdBindShadersEXT-pStages-08464
    pStages must not contain VK_SHADER_STAGE_ALL_GRAPHICS or VK_SHADER_STAGE_ALL

  • VUID-vkCmdBindShadersEXT-pStages-08465
    pStages must not contain VK_SHADER_STAGE_RAYGEN_BIT_KHR, VK_SHADER_STAGE_ANY_HIT_BIT_KHR, VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR, VK_SHADER_STAGE_MISS_BIT_KHR, VK_SHADER_STAGE_INTERSECTION_BIT_KHR, or VK_SHADER_STAGE_CALLABLE_BIT_KHR

  • VUID-vkCmdBindShadersEXT-pStages-08467
    pStages must not contain VK_SHADER_STAGE_SUBPASS_SHADING_BIT_HUAWEI

  • VUID-vkCmdBindShadersEXT-pStages-08468
    pStages must not contain VK_SHADER_STAGE_CLUSTER_CULLING_BIT_HUAWEI

  • VUID-vkCmdBindShadersEXT-pShaders-08469
    For each element of pStages, if pShaders is not NULL, and the element of the pShaders array with the same index is not VK_NULL_HANDLE, it must have been created with a stage equal to the corresponding element of pStages

  • VUID-vkCmdBindShadersEXT-pShaders-08470
    If pStages contains both VK_SHADER_STAGE_TASK_BIT_EXT and VK_SHADER_STAGE_VERTEX_BIT, and pShaders is not NULL, and the same index in pShaders as VK_SHADER_STAGE_TASK_BIT_EXT in pStages is not VK_NULL_HANDLE, the same index in pShaders as VK_SHADER_STAGE_VERTEX_BIT in pStages must be VK_NULL_HANDLE

  • VUID-vkCmdBindShadersEXT-pShaders-08471
    If pStages contains both VK_SHADER_STAGE_MESH_BIT_EXT and VK_SHADER_STAGE_VERTEX_BIT, and pShaders is not NULL, and the same index in pShaders as VK_SHADER_STAGE_MESH_BIT_EXT in pStages is not VK_NULL_HANDLE, the same index in pShaders as VK_SHADER_STAGE_VERTEX_BIT in pStages must be VK_NULL_HANDLE

  • VUID-vkCmdBindShadersEXT-pShaders-08474
    If the tessellationShader feature is not enabled, and pStages contains VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT or VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, and pShaders is not NULL, the same index or indices in pShaders must be VK_NULL_HANDLE

  • VUID-vkCmdBindShadersEXT-pShaders-08475
    If the geometryShader feature is not enabled, and pStages contains VK_SHADER_STAGE_GEOMETRY_BIT, and pShaders is not NULL, the same index in pShaders must be VK_NULL_HANDLE

  • VUID-vkCmdBindShadersEXT-pShaders-08490
    If the taskShader feature is not enabled, and pStages contains VK_SHADER_STAGE_TASK_BIT_EXT, and pShaders is not NULL, the same index in pShaders must be VK_NULL_HANDLE

  • VUID-vkCmdBindShadersEXT-pShaders-08491
    If the meshShader feature is not enabled, and pStages contains VK_SHADER_STAGE_MESH_BIT_EXT, and pShaders is not NULL, the same index in pShaders must be VK_NULL_HANDLE

  • VUID-vkCmdBindShadersEXT-pShaders-08476
    If pStages contains VK_SHADER_STAGE_COMPUTE_BIT, the VkCommandPool that commandBuffer was allocated from must support compute operations

  • VUID-vkCmdBindShadersEXT-pShaders-08477
    If pStages contains VK_SHADER_STAGE_VERTEX_BIT, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, VK_SHADER_STAGE_GEOMETRY_BIT, or VK_SHADER_STAGE_FRAGMENT_BIT, the VkCommandPool that commandBuffer was allocated from must support graphics operations

  • VUID-vkCmdBindShadersEXT-pShaders-08478
    If pStages contains VK_SHADER_STAGE_MESH_BIT_EXT or VK_SHADER_STAGE_TASK_BIT_EXT, the VkCommandPool that commandBuffer was allocated from must support graphics operations

Valid Usage (Implicit)
  • VUID-vkCmdBindShadersEXT-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdBindShadersEXT-pStages-parameter
    pStages must be a valid pointer to an array of stageCount valid VkShaderStageFlagBits values

  • VUID-vkCmdBindShadersEXT-pShaders-parameter
    If pShaders is not NULL, pShaders must be a valid pointer to an array of stageCount valid or VK_NULL_HANDLE VkShaderEXT handles

  • VUID-vkCmdBindShadersEXT-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdBindShadersEXT-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support graphics, or compute operations

  • VUID-vkCmdBindShadersEXT-videocoding
    This command must only be called outside of a video coding scope

  • VUID-vkCmdBindShadersEXT-stageCount-arraylength
    stageCount must be greater than 0

  • VUID-vkCmdBindShadersEXT-commonparent
    Both of commandBuffer, and the elements of pShaders that are valid handles of non-ignored parameters must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization
  • Host access to commandBuffer must be externally synchronized

  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized

Command Properties
Command Buffer Levels Render Pass Scope Video Coding Scope Supported Queue Types Command Type

Primary
Secondary

Both

Outside

Graphics
Compute

State

See Also

Document Notes

For more information, see the Vulkan Specification

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2024 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0