// Copyright 2020-2024 The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

// Common Valid Usage
// Common to structs taking VkPipelineStageFlags2 and VkAccessFlags2 parameters to define scopes
// Set "stageMaskName" and "accessMaskName" attribute to the name of the stage and access mask to validate
  * [[VUID-{refpage}-{accessMaskName}-03900]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT,
ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03901]]
    If pname:{accessMaskName} includes ename:VK_ACCESS_2_INDEX_READ_BIT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT,
    ename:VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03902]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT,
    ename:VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03903]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_INPUT_ATTACHMENT_READ_BIT, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT,
    ename:VK_PIPELINE_STAGE_2_SUBPASS_SHADER_BIT_HUAWEI,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03904]]
    If pname:{accessMaskName} includes ename:VK_ACCESS_2_UNIFORM_READ_BIT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, or one of the
    etext:VK_PIPELINE_STAGE_*_SHADER_BIT stages
  * [[VUID-{refpage}-{accessMaskName}-03905]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_SHADER_SAMPLED_READ_BIT, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, or one of the
    etext:VK_PIPELINE_STAGE_*_SHADER_BIT stages
  * [[VUID-{refpage}-{accessMaskName}-03906]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_SHADER_STORAGE_READ_BIT, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, or one of the
    etext:VK_PIPELINE_STAGE_*_SHADER_BIT stages
  * [[VUID-{refpage}-{accessMaskName}-03907]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, or one of the
    etext:VK_PIPELINE_STAGE_*_SHADER_BIT stages
  * [[VUID-{refpage}-{accessMaskName}-07454]]
    If pname:{accessMaskName} includes ename:VK_ACCESS_2_SHADER_READ_BIT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
ifdef::VK_EXT_opacity_micromap[]
    ename:VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT,
endif::VK_EXT_opacity_micromap[]
    or one of the etext:VK_PIPELINE_STAGE_*_SHADER_BIT stages
  * [[VUID-{refpage}-{accessMaskName}-03909]]
    If pname:{accessMaskName} includes ename:VK_ACCESS_2_SHADER_WRITE_BIT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, or one of the
    etext:VK_PIPELINE_STAGE_*_SHADER_BIT stages
  * [[VUID-{refpage}-{accessMaskName}-03910]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03911]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, pname:{stageMaskName}
    must: include ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03912]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT,
    ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03913]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT,
    ename:VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03914]]
    If pname:{accessMaskName} includes ename:VK_ACCESS_2_TRANSFER_READ_BIT,
    pname:{stageMaskName} must: include ename:VK_PIPELINE_STAGE_2_COPY_BIT,
    ename:VK_PIPELINE_STAGE_2_BLIT_BIT,
    ename:VK_PIPELINE_STAGE_2_RESOLVE_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT,
ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
ifdef::VK_KHR_ray_tracing_maintenance1[]
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_COPY_BIT_KHR,
endif::VK_KHR_ray_tracing_maintenance1[]
    or ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03915]]
    If pname:{accessMaskName} includes ename:VK_ACCESS_2_TRANSFER_WRITE_BIT,
    pname:{stageMaskName} must: include ename:VK_PIPELINE_STAGE_2_COPY_BIT,
    ename:VK_PIPELINE_STAGE_2_BLIT_BIT,
    ename:VK_PIPELINE_STAGE_2_RESOLVE_BIT,
    ename:VK_PIPELINE_STAGE_2_CLEAR_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT,
ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
ifdef::VK_KHR_ray_tracing_maintenance1[]
    or ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_COPY_BIT_KHR,
endif::VK_KHR_ray_tracing_maintenance1[]
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03916]]
    If pname:{accessMaskName} includes ename:VK_ACCESS_2_HOST_READ_BIT,
    pname:{stageMaskName} must: include ename:VK_PIPELINE_STAGE_2_HOST_BIT
  * [[VUID-{refpage}-{accessMaskName}-03917]]
    If pname:{accessMaskName} includes ename:VK_ACCESS_2_HOST_WRITE_BIT,
    pname:{stageMaskName} must: include ename:VK_PIPELINE_STAGE_2_HOST_BIT
ifdef::VK_EXT_conditional_rendering[]
  * [[VUID-{refpage}-{accessMaskName}-03918]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_CONDITIONAL_RENDERING_READ_BIT_EXT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_CONDITIONAL_RENDERING_BIT_EXT,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
endif::VK_EXT_conditional_rendering[]
ifdef::VK_EXT_fragment_density_map[]
  * [[VUID-{refpage}-{accessMaskName}-03919]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_FRAGMENT_DENSITY_MAP_READ_BIT_EXT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_FRAGMENT_DENSITY_PROCESS_BIT_EXT,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
endif::VK_EXT_fragment_density_map[]
ifdef::VK_EXT_transform_feedback[]
  * [[VUID-{refpage}-{accessMaskName}-03920]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_TRANSFORM_FEEDBACK_WRITE_BIT_EXT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-04747]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT,
    ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03922]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
endif::VK_EXT_transform_feedback[]
ifdef::VK_NV_shading_rate_image[]
  * [[VUID-{refpage}-{accessMaskName}-03923]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_SHADING_RATE_IMAGE_READ_BIT_NV, pname:{stageMaskName}
    must: include ename:VK_PIPELINE_STAGE_2_SHADING_RATE_IMAGE_BIT_NV,
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
endif::VK_NV_shading_rate_image[]
ifdef::VK_HUAWEI_invocation_mask[]
  * [[VUID-{refpage}-{accessMaskName}-04994]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_INVOCATION_MASK_READ_BIT_HUAWEI, pname:{stageMaskName}
    must: include ename:VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI
endif::VK_HUAWEI_invocation_mask[]
ifdef::VK_NV_device_generated_commands[]
  * [[VUID-{refpage}-{accessMaskName}-03924]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_COMMAND_PREPROCESS_READ_BIT_NV, pname:{stageMaskName}
    must: include ename:VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-03925]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_COMMAND_PREPROCESS_WRITE_BIT_NV, pname:{stageMaskName}
    must: include ename:VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
endif::VK_NV_device_generated_commands[]
ifdef::VK_EXT_blend_operation_advanced[]
  * [[VUID-{refpage}-{accessMaskName}-03926]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT
    ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
endif::VK_EXT_blend_operation_advanced[]
ifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
  * [[VUID-{refpage}-{accessMaskName}-03927]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_KHR,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_COPY_BIT_KHR,
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, or one of the
    etext:VK_PIPELINE_STAGE_*_SHADER_BIT stages
  * [[VUID-{refpage}-{accessMaskName}-03928]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_KHR,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_COPY_BIT_KHR,
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR or
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
  * [[VUID-{refpage}-{accessMaskName}-06256]]
    If
ifdef::VK_KHR_ray_query[]
    the <<features-rayQuery, pname:rayQuery>> feature is not enabled and
endif::VK_KHR_ray_query[]
    pname:{accessMaskName} includes
    ename:VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_KHR,
    pname:{stageMaskName} must: not include any of the
    etext:VK_PIPELINE_STAGE_*_SHADER_BIT stages
ifdef::VK_KHR_ray_tracing_pipeline,VK_NV_ray_tracing[]
    except ename:VK_PIPELINE_STAGE_2_RAY_TRACING_SHADER_BIT_KHR
endif::VK_KHR_ray_tracing_pipeline,VK_NV_ray_tracing[]
ifdef::VK_KHR_ray_tracing_maintenance1[]
  * [[VUID-{refpage}-{accessMaskName}-07272]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_SHADER_BINDING_TABLE_READ_BIT_KHR,
    pname:{stageMaskName} must: include
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT or
    ename:VK_PIPELINE_STAGE_2_RAY_TRACING_SHADER_BIT_KHR
endif::VK_KHR_ray_tracing_maintenance1[]
endif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[]
ifdef::VK_KHR_video_decode_queue[]
  * [[VUID-{refpage}-{accessMaskName}-04858]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR
  * [[VUID-{refpage}-{accessMaskName}-04859]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR, pname:{stageMaskName}
    must: include ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR
endif::VK_KHR_video_decode_queue[]
ifdef::VK_KHR_video_encode_queue[]
  * [[VUID-{refpage}-{accessMaskName}-04860]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR
  * [[VUID-{refpage}-{accessMaskName}-04861]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_VIDEO_ENCODE_WRITE_BIT_KHR, pname:{stageMaskName}
    must: include ename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR
endif::VK_KHR_video_encode_queue[]
ifdef::VK_NV_optical_flow[]
  * [[VUID-{refpage}-{accessMaskName}-07455]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_OPTICAL_FLOW_READ_BIT_NV, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV
  * [[VUID-{refpage}-{accessMaskName}-07456]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_OPTICAL_FLOW_WRITE_BIT_NV, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV
endif::VK_NV_optical_flow[]
ifdef::VK_EXT_opacity_micromap[]
  * [[VUID-{refpage}-{accessMaskName}-07457]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_MICROMAP_WRITE_BIT_EXT, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT
  * [[VUID-{refpage}-{accessMaskName}-07458]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_MICROMAP_READ_BIT_EXT, pname:{stageMaskName} must:
    include ename:VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT or
    ename:VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
endif::VK_EXT_opacity_micromap[]
ifdef::VK_EXT_descriptor_buffer[]
  * [[VUID-{refpage}-{accessMaskName}-08118]]
    If pname:{accessMaskName} includes
    ename:VK_ACCESS_2_DESCRIPTOR_BUFFER_READ_BIT_EXT, pname:{stageMaskName}
    must: include ename:VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT,
    ename:VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, or one of
    etext:VK_PIPELINE_STAGE_*_SHADER_BIT stages
endif::VK_EXT_descriptor_buffer[]
// Common Valid Usage
