diff --git a/docs/conf.py b/docs/conf.py index af8b7e6f88b..6dd2bbf63e0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -235,6 +235,7 @@ hawkmoth_clang = [ '-I{}/src/gallium/include/'.format(mesa_root), '-I{}/src/intel/'.format(mesa_root), '-I{}/src/mesa/'.format(mesa_root), + '-I{}/src/vulkan/util'.format(mesa_root), '-I{}/src/'.format(mesa_build_root), '-DHAVE_STRUCT_TIMESPEC', '-DHAVE_PTHREAD', diff --git a/docs/vulkan/renderpass.rst b/docs/vulkan/renderpass.rst index b3722cdae3c..8a4310e71de 100644 --- a/docs/vulkan/renderpass.rst +++ b/docs/vulkan/renderpass.rst @@ -61,7 +61,7 @@ render pass clears with layout transitions, often from combining these transitions with clears is important for performance. .. c:autostruct:: VkRenderingAttachmentInitialLayoutInfoMESA - :file: src/vulkan/runtime/vk_render_pass.h + :file: src/vulkan/util/vk_internal_exts.h :members: Because render passes and subpass indices are also passed into diff --git a/src/vulkan/runtime/vk_meta.h b/src/vulkan/runtime/vk_meta.h index 6c633458e72..833114a6102 100644 --- a/src/vulkan/runtime/vk_meta.h +++ b/src/vulkan/runtime/vk_meta.h @@ -23,6 +23,7 @@ #ifndef VK_META_H #define VK_META_H +#include "vk_internal_exts.h" #include "vk_limits.h" #include "vk_object.h" @@ -46,9 +47,6 @@ struct vk_meta_rect { uint32_t layer; }; -#define VK_PRIMITIVE_TOPOLOGY_META_RECT_LIST_MESA (VkPrimitiveTopology)11 -#define VK_IMAGE_VIEW_CREATE_DRIVER_INTERNAL_BIT_MESA (VkImageViewCreateFlagBits)0x80000000 - struct vk_meta_copy_image_properties { union { struct { diff --git a/src/vulkan/runtime/vk_pipeline.h b/src/vulkan/runtime/vk_pipeline.h index a24db14ac30..ca520d9c74c 100644 --- a/src/vulkan/runtime/vk_pipeline.h +++ b/src/vulkan/runtime/vk_pipeline.h @@ -24,6 +24,7 @@ #ifndef VK_PIPELINE_H #define VK_PIPELINE_H +#include "vk_internal_exts.h" #include "vk_object.h" #include "vk_util.h" @@ -39,20 +40,6 @@ struct vk_device; extern "C" { #endif -#define VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_NIR_CREATE_INFO_MESA \ - (VkStructureType)1000290001 - -#define VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_NIR_CREATE_INFO_MESA_cast \ - VkPipelineShaderStageNirCreateInfoMESA - -static const VkPipelineCreateFlagBits2 VK_PIPELINE_CREATE_2_UNALIGNED_DISPATCH_BIT_MESA = 0x20000000000ull; - -typedef struct VkPipelineShaderStageNirCreateInfoMESA { - VkStructureType sType; - const void *pNext; - struct nir_shader *nir; -} VkPipelineShaderStageNirCreateInfoMESA; - bool vk_pipeline_shader_stage_is_null(const VkPipelineShaderStageCreateInfo *info); diff --git a/src/vulkan/runtime/vk_render_pass.h b/src/vulkan/runtime/vk_render_pass.h index 4cac6f33ae8..d1016d7bca4 100644 --- a/src/vulkan/runtime/vk_render_pass.h +++ b/src/vulkan/runtime/vk_render_pass.h @@ -23,6 +23,7 @@ #ifndef VK_RENDER_PASS_H #define VK_RENDER_PASS_H +#include "vk_internal_exts.h" #include "vk_limits.h" #include "vk_object.h" @@ -33,42 +34,6 @@ extern "C" { struct vk_command_buffer; struct vk_image; -/* Mesa-specific dynamic rendering flag to indicate that legacy RPs don't use - * input attachments with concurrent writes (aka. feedback loops). - */ -#define VK_RENDERING_INPUT_ATTACHMENT_NO_CONCURRENT_WRITES_BIT_MESA 0x80000000 - -/** - * Pseudo-extension struct that may be chained into VkRenderingAttachmentInfo - * to indicate an initial layout for the attachment. This is only allowed if - * all of the following conditions are met: - * - * 1. VkRenderingAttachmentInfo::loadOp == LOAD_OP_CLEAR - * - * 2. VkRenderingInfo::renderArea is the entire image view LOD - * - * 3. For 3D image attachments, VkRenderingInfo::viewMask == 0 AND - * VkRenderingInfo::layerCount references the entire bound image view - * OR VkRenderingInfo::viewMask is dense (no holes) and references the - * entire bound image view. (2D and 2D array images have no such - * requirement.) - * - * If this struct is included in the pNext chain of a - * VkRenderingAttachmentInfo, the driver is responsible for transitioning the - * bound region of the image from - * VkRenderingAttachmentInitialLayoutInfoMESA::initialLayout to - * VkRenderingAttachmentInfo::imageLayout prior to rendering. - */ -typedef struct VkRenderingAttachmentInitialLayoutInfoMESA { - VkStructureType sType; -#define VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INITIAL_LAYOUT_INFO_MESA (VkStructureType)1000044901 -#define VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INITIAL_LAYOUT_INFO_MESA_cast VkRenderingAttachmentInitialLayoutInfoMESA - const void* pNext; - - /** Initial layout of the attachment */ - VkImageLayout initialLayout; -} VkRenderingAttachmentInitialLayoutInfoMESA; - /***/ struct vk_subpass_attachment { /** VkAttachmentReference2::attachment */ diff --git a/src/vulkan/runtime/vk_shader.h b/src/vulkan/runtime/vk_shader.h index 93ef35d8c63..a2caea1c667 100644 --- a/src/vulkan/runtime/vk_shader.h +++ b/src/vulkan/runtime/vk_shader.h @@ -25,6 +25,7 @@ #define VK_SHADER_H #include "compiler/spirv/nir_spirv.h" +#include "vk_internal_exts.h" #include "vk_limits.h" #include "vk_pipeline_cache.h" @@ -49,9 +50,6 @@ struct vk_pipeline_robustness_state; int vk_shader_cmp_graphics_stages(mesa_shader_stage a, mesa_shader_stage b); int vk_shader_cmp_rt_stages(mesa_shader_stage a, mesa_shader_stage b); -#define VK_SHADER_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_MESA 0x1000 -#define VK_SHADER_CREATE_UNALIGNED_DISPATCH_BIT_MESA 0x2000 - #define MESA_VK_PIPELINE_RAY_TRACING_FLAGS ( \ VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_BUILT_IN_PRIMITIVES_BIT_KHR | \ VK_PIPELINE_CREATE_2_RAY_TRACING_ALLOW_SPHERES_AND_LINEAR_SWEPT_SPHERES_BIT_NV | \ diff --git a/src/vulkan/util/vk_internal_exts.h b/src/vulkan/util/vk_internal_exts.h new file mode 100644 index 00000000000..9acab6979e0 --- /dev/null +++ b/src/vulkan/util/vk_internal_exts.h @@ -0,0 +1,150 @@ +/* + * Copyright © 2025 Collabora Ltd + * SPDX-License-Identifier: MIT + */ + +/* + * This file contains a variety of mesa-internal extension structs and + * enumerants. These are not exposed to apps but are instead used for the + * runtime components (including meta and WSI) to communicate additional + * information to drivers beyond what is provided through the Vulkan spec + * itself. Care should be taken when adding anything here to avoid + * conflicting with existing Vulkan enums if at all possible. + */ + +#ifndef VK_INTERNAL_EXTS_H +#define VK_INTERNAL_EXTS_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define VK_PRIMITIVE_TOPOLOGY_META_RECT_LIST_MESA (VkPrimitiveTopology)11 +#define VK_IMAGE_VIEW_CREATE_DRIVER_INTERNAL_BIT_MESA \ + (VkImageViewCreateFlagBits)0x80000000 + + +/* This is always chained to VkImageCreateInfo when a wsi image is created. + * It indicates that the image can be transitioned to/from + * VK_IMAGE_LAYOUT_PRESENT_SRC_KHR. + */ +struct wsi_image_create_info { + VkStructureType sType; + const void *pNext; + bool scanout; + + /* if true, the image is a blit source */ + bool blit_src; +}; + +struct wsi_memory_allocate_info { + VkStructureType sType; + const void *pNext; + /** + * If set, then the driver needs to do implicit synchronization on this BO. + * + * For DRM drivers, this flag will only get set before linux 6.0, at which + * point DMA_BUF_IOCTL_IMPORT_SYNC_FILE was added. + */ + bool implicit_sync; +}; + +/* To be chained into VkSurfaceCapabilities2KHR */ +struct wsi_surface_supported_counters { + VkStructureType sType; + const void *pNext; + + VkSurfaceCounterFlagsEXT supported_surface_counters; + +}; + +/* This is guaranteed to not collide with anything because it's in the + * VK_KHR_swapchain namespace but not actually used by the extension. + */ +#define VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA \ + (VkStructureType)1000001002 +#define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA \ + (VkStructureType)1000001003 +#define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA \ + (VkStructureType)1000001005 + +#define VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA_cast \ + struct wsi_image_create_info +#define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA_cast \ + struct wsi_memory_allocate_info +#define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA_cast \ + struct wsi_surface_supported_counters + + +/* Mesa-specific dynamic rendering flag to indicate that legacy RPs don't use + * input attachments with concurrent writes (aka. feedback loops). + */ +#define VK_RENDERING_INPUT_ATTACHMENT_NO_CONCURRENT_WRITES_BIT_MESA 0x80000000 + + +/** + * Pseudo-extension struct that may be chained into VkRenderingAttachmentInfo + * to indicate an initial layout for the attachment. This is only allowed if + * all of the following conditions are met: + * + * 1. VkRenderingAttachmentInfo::loadOp == LOAD_OP_CLEAR + * + * 2. VkRenderingInfo::renderArea is the entire image view LOD + * + * 3. For 3D image attachments, VkRenderingInfo::viewMask == 0 AND + * VkRenderingInfo::layerCount references the entire bound image view + * OR VkRenderingInfo::viewMask is dense (no holes) and references the + * entire bound image view. (2D and 2D array images have no such + * requirement.) + * + * If this struct is included in the pNext chain of a + * VkRenderingAttachmentInfo, the driver is responsible for transitioning the + * bound region of the image from + * VkRenderingAttachmentInitialLayoutInfoMESA::initialLayout to + * VkRenderingAttachmentInfo::imageLayout prior to rendering. + */ +typedef struct VkRenderingAttachmentInitialLayoutInfoMESA { + VkStructureType sType; + const void* pNext; + + /** Initial layout of the attachment */ + VkImageLayout initialLayout; +} VkRenderingAttachmentInitialLayoutInfoMESA; + +#define VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INITIAL_LAYOUT_INFO_MESA \ + (VkStructureType)1000044901 +#define VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INITIAL_LAYOUT_INFO_MESA_cast \ + VkRenderingAttachmentInitialLayoutInfoMESA + + +struct nir_shader; + +typedef struct VkPipelineShaderStageNirCreateInfoMESA { + VkStructureType sType; + const void *pNext; + struct nir_shader *nir; +} VkPipelineShaderStageNirCreateInfoMESA; + +#define VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_NIR_CREATE_INFO_MESA \ + (VkStructureType)1000290001 + +#define VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_NIR_CREATE_INFO_MESA_cast \ + VkPipelineShaderStageNirCreateInfoMESA + + +static const VkPipelineCreateFlagBits2 + VK_PIPELINE_CREATE_2_UNALIGNED_DISPATCH_BIT_MESA = 0x20000000000ull; + + +#define VK_SHADER_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_MESA 0x1000 +#define VK_SHADER_CREATE_UNALIGNED_DISPATCH_BIT_MESA 0x2000 + +#ifdef __cplusplus +} +#endif + +#endif /* VK_INTERNAL_EXTS_H */ diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index 55df390ea86..0b9f9998a8b 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -29,6 +29,7 @@ #include "util/log.h" #include "vk_alloc.h" #include "vk_dispatch_table.h" +#include "vk_internal_exts.h" #include #include @@ -44,51 +45,6 @@ extern const struct vk_device_entrypoint_table wsi_device_entrypoints; #include -/* This is guaranteed to not collide with anything because it's in the - * VK_KHR_swapchain namespace but not actually used by the extension. - */ -#define VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA (VkStructureType)1000001002 -#define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA (VkStructureType)1000001003 -#define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA (VkStructureType)1000001005 - -#define VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA_cast struct wsi_image_create_info -#define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA_cast struct wsi_memory_allocate_info -#define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA_cast struct wsi_surface_supported_counters - -/* This is always chained to VkImageCreateInfo when a wsi image is created. - * It indicates that the image can be transitioned to/from - * VK_IMAGE_LAYOUT_PRESENT_SRC_KHR. - */ -struct wsi_image_create_info { - VkStructureType sType; - const void *pNext; - bool scanout; - - /* if true, the image is a blit source */ - bool blit_src; -}; - -struct wsi_memory_allocate_info { - VkStructureType sType; - const void *pNext; - /** - * If set, then the driver needs to do implicit synchronization on this BO. - * - * For DRM drivers, this flag will only get set before linux 6.0, at which - * point DMA_BUF_IOCTL_IMPORT_SYNC_FILE was added. - */ - bool implicit_sync; -}; - -/* To be chained into VkSurfaceCapabilities2KHR */ -struct wsi_surface_supported_counters { - VkStructureType sType; - const void *pNext; - - VkSurfaceCounterFlagsEXT supported_surface_counters; - -}; - struct wsi_interface; struct vk_instance; struct vk_queue;