// Copyright 2019-2021 The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

// Common Valid Usage
// Common to all drawing commands
include::draw_dispatch_common.txt[]
  * [[VUID-{refpage}-renderPass-02684]]
    The current render pass must: be <<renderpass-compatibility,compatible>>
    with the pname:renderPass member of the
    sname:VkGraphicsPipelineCreateInfo structure specified when creating the
    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
  * [[VUID-{refpage}-subpass-02685]]
    The subpass index of the current render pass must: be equal to the
    pname:subpass member of the sname:VkGraphicsPipelineCreateInfo structure
    specified when creating the sname:VkPipeline bound to
    ename:VK_PIPELINE_BIND_POINT_GRAPHICS
  * [[VUID-{refpage}-None-02686]]
    Every input attachment used by the current subpass must: be bound to the
    pipeline via a descriptor set
  * [[VUID-{refpage}-None-04584]]
    Image subresources used as attachments in the current render pass must:
    not be accessed in any way other than as an attachment by this command,
    except for cases involving read-only access to depth/stencil attachments
    as described in the <<renderpass-attachment-nonattachment, Render Pass>>
    chapter
ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
  * [[VUID-{refpage}-maxMultiviewInstanceIndex-02688]]
    If the draw is recorded in a render pass instance with multiview
    enabled, the maximum instance index must: be less than or equal to
    slink:VkPhysicalDeviceMultiviewProperties::pname:maxMultiviewInstanceIndex
endif::VK_VERSION_1_1,VK_KHR_multiview[]
ifdef::VK_EXT_sample_locations[]
  * [[VUID-{refpage}-sampleLocationsEnable-02689]]
    If the bound graphics pipeline was created with
    slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable
    set to ename:VK_TRUE and the current subpass has a depth/stencil
    attachment, then that attachment must: have been created with the
    ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set
endif::VK_EXT_sample_locations[]
ifdef::VK_EXT_extended_dynamic_state[]
  * [[VUID-{refpage}-viewportCount-03417]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT dynamic state enabled,
    but not the ename:VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT dynamic state
    enabled, then flink:vkCmdSetViewportWithCountEXT must: have been called
    in the current command buffer prior to this drawing command, and the
    pname:viewportCount parameter of fname:vkCmdSetViewportWithCountEXT
    must: match the
    sname:VkPipelineViewportStateCreateInfo::pname:scissorCount of the
    pipeline
  * [[VUID-{refpage}-scissorCount-03418]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT dynamic state enabled, but
    not the ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT dynamic state
    enabled, then flink:vkCmdSetScissorWithCountEXT must: have been called
    in the current command buffer prior to this drawing command, and the
    pname:scissorCount parameter of fname:vkCmdSetScissorWithCountEXT must:
    match the sname:VkPipelineViewportStateCreateInfo::pname:viewportCount
    of the pipeline
  * [[VUID-{refpage}-viewportCount-03419]]
    If the bound graphics pipeline state was created with both the
    ename:VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and
    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT dynamic states enabled
    then both flink:vkCmdSetViewportWithCountEXT and
    flink:vkCmdSetScissorWithCountEXT must: have been called in the current
    command buffer prior to this drawing command, and the
    pname:viewportCount parameter of fname:vkCmdSetViewportWithCountEXT
    must: match the pname:scissorCount parameter of
    fname:vkCmdSetScissorWithCountEXT
ifdef::VK_NV_clip_space_w_scaling[]
  * [[VUID-{refpage}-viewportCount-04137]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT dynamic state enabled,
    but not the ename:VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV dynamic state
    enabled, then the bound graphics pipeline must: have been created with
    slink:VkPipelineViewportWScalingStateCreateInfoNV::pname:viewportCount
    greater or equal to the pname:viewportCount parameter in the last call
    to flink:vkCmdSetViewportWithCountEXT
  * [[VUID-{refpage}-viewportCount-04138]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and
    ename:VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV dynamic states enabled then
    the pname:viewportCount parameter in the last call to
    flink:vkCmdSetViewportWScalingNV must: be greater than or equal to the
    pname:viewportCount parameter in the last call to
    flink:vkCmdSetViewportWithCountEXT
endif::VK_NV_clip_space_w_scaling[]
ifdef::VK_NV_shading_rate_image[]
  * [[VUID-{refpage}-viewportCount-04139]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT dynamic state enabled,
    but not the ename:VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV
    dynamic state enabled, then the bound graphics pipeline must: have been
    created with
    slink:VkPipelineViewportShadingRateImageStateCreateInfoNV::pname:viewportCount
    greater or equal to the pname:viewportCount parameter in the last call
    to flink:vkCmdSetViewportWithCountEXT
  * [[VUID-{refpage}-viewportCount-04140]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and
    ename:VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV dynamic states
    enabled then the pname:viewportCount parameter in the last call to
    flink:vkCmdSetViewportShadingRatePaletteNV must: be greater than or
    equal to the pname:viewportCount parameter in the last call to
    flink:vkCmdSetViewportWithCountEXT
endif::VK_NV_shading_rate_image[]
ifdef::VK_NV_viewport_swizzle[]
  * [[VUID-{refpage}-VkPipelineVieportCreateInfo-04141]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT dynamic state enabled and
    an instance of slink:VkPipelineViewportSwizzleStateCreateInfoNV chained
    from pname:VkPipelineVieportCreateInfo, then the bound graphics pipeline
    must: have been created with
    slink:VkPipelineViewportSwizzleStateCreateInfoNV::pname:viewportCount
    greater or equal to the pname:viewportCount parameter in the last call
    to flink:vkCmdSetViewportWithCountEXT
endif::VK_NV_viewport_swizzle[]
ifdef::VK_NV_scissor_exclusive[]
  * [[VUID-{refpage}-VkPipelineVieportCreateInfo-04142]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT dynamic state enabled and
    an instance of slink:VkPipelineViewportExclusiveScissorStateCreateInfoNV
    chained from pname:VkPipelineVieportCreateInfo, then the bound graphics
    pipeline must: have been created with
    slink:VkPipelineViewportExclusiveScissorStateCreateInfoNV::pname:exclusiveScissorCount
    greater or equal to the pname:viewportCount parameter in the last call
    to flink:vkCmdSetViewportWithCountEXT
endif::VK_NV_scissor_exclusive[]
  * [[VUID-{refpage}-primitiveTopology-03420]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT dynamic state enabled then
    flink:vkCmdSetPrimitiveTopologyEXT must: have been called in the current
    command buffer prior to this drawing command, and the
    pname:primitiveTopology parameter of fname:vkCmdSetPrimitiveTopologyEXT
    must: be of the same <<drawing-primitive-topology-class, topology
    class>> as the pipeline
    slink:VkPipelineInputAssemblyStateCreateInfo::pname:topology state
endif::VK_EXT_extended_dynamic_state[]
ifdef::VK_EXT_extended_dynamic_state2[]
  * [[VUID-{refpage}-None-04875]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT dynamic state enabled
    then flink:vkCmdSetPatchControlPointsEXT must: have been called in the
    current command buffer prior to this drawing command
  * [[VUID-{refpage}-None-04876]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT dynamic state
    enabled then flink:vkCmdSetRasterizerDiscardEnableEXT must: have been
    called in the current command buffer prior to this drawing command
  * [[VUID-{refpage}-None-04877]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT dynamic state enabled then
    flink:vkCmdSetDepthBiasEnableEXT must: have been called in the current
    command buffer prior to this drawing command
  * [[VUID-{refpage}-logicOp-04878]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_LOGIC_OP_EXT dynamic state enabled then
    flink:vkCmdSetLogicOpEXT must: have been called in the current command
    buffer prior to this drawing command and the pname:logicOp must: be a
    valid elink:VkLogicOp value
  * [[VUID-{refpage}-None-04879]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT dynamic state
    enabled then flink:vkCmdSetPrimitiveRestartEnableEXT must: have been
    called in the current command buffer prior to this drawing command
endif::VK_EXT_extended_dynamic_state2[]
ifdef::VK_KHR_fragment_shading_rate+VK_EXT_extended_dynamic_state[]
  * [[VUID-{refpage}-primitiveFragmentShadingRateWithMultipleViewports-04552]]
    If the <<limits-primitiveFragmentShadingRateWithMultipleViewports,
    pname:primitiveFragmentShadingRateWithMultipleViewports>> limit is not
    supported, the bound graphics pipeline was created with the
    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT dynamic state enabled,
    and any of the shader stages of the bound graphics pipeline write to the
    code:PrimitiveShadingRateKHR built-in, then
    flink:vkCmdSetViewportWithCountEXT must: have been called in the current
    command buffer prior to this drawing command, and the
    pname:viewportCount parameter of fname:vkCmdSetViewportWithCountEXT
    must: be `1`
endif::VK_KHR_fragment_shading_rate+VK_EXT_extended_dynamic_state[]
  * [[VUID-{refpage}-blendEnable-04727]]
    If rasterization is not disabled in the bound graphics pipeline, then
    for each color attachment in the subpass, if the corresponding image
    view's <<resources-image-view-format-features,format features>> do not
    contain ename:VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT, then the
    pname:blendEnable member of the corresponding element of the
    pname:pAttachments member of pname:pColorBlendState must: be
    ename:VK_FALSE
  * [[VUID-{refpage}-rasterizationSamples-04740]]
    If rasterization is not disabled in the bound graphics pipeline, and
    neither the `<<VK_AMD_mixed_attachment_samples>>` nor the
    `<<VK_NV_framebuffer_mixed_samples>>` extensions are enabled, then
    slink:VkPipelineMultisampleStateCreateInfo::pname:rasterizationSamples
    must: be the same as the current subpass color and/or depth/stencil
    attachments
ifdef::VK_EXT_extended_dynamic_state[]
ifdef::VK_EXT_vertex_input_dynamic_state[]
  * [[VUID-{refpage}-None-04912]]
    If the bound graphics pipeline was created with both the
    ename:VK_DYNAMIC_STATE_VERTEX_INPUT_EXT and
    ename:VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT dynamic states
    enabled, then flink:vkCmdSetVertexInputEXT must: have been called in the
    current command buffer prior to this draw command
  * [[VUID-{refpage}-pStrides-04913]]
    If the bound graphics pipeline was created with the
    ename:VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT dynamic state
    enabled, but not the ename:VK_DYNAMIC_STATE_VERTEX_INPUT_EXT dynamic
    state enabled, then flink:vkCmdBindVertexBuffers2EXT must: have been
    called in the current command buffer prior to this draw command, and the
    pname:pStrides parameter of flink:vkCmdBindVertexBuffers2EXT must: not
    be `NULL`
endif::VK_EXT_vertex_input_dynamic_state[]
ifndef::VK_EXT_vertex_input_dynamic_state[]
  * [[VUID-{refpage}-pStrides-04884]]
    If the bound graphics pipeline was created with the
    ename:VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT dynamic state
    enabled, then flink:vkCmdBindVertexBuffers2EXT must: have been called in
    the current command buffer prior to this drawing command, and the
    pname:pStrides parameter of flink:vkCmdBindVertexBuffers2EXT must: not
    be `NULL`
endif::VK_EXT_vertex_input_dynamic_state[]
endif::VK_EXT_extended_dynamic_state[]
ifdef::VK_EXT_vertex_input_dynamic_state[]
  * [[VUID-{refpage}-None-04914]]
    If the bound graphics pipeline state was created with the
    ename:VK_DYNAMIC_STATE_VERTEX_INPUT_EXT dynamic state enabled, then
    flink:vkCmdSetVertexInputEXT must: have been called in the current
    command buffer prior to this draw command
endif::VK_EXT_vertex_input_dynamic_state[]
// Common Valid Usage
