#include <vulkan/vulkan.h>
+#include "pixfmt.h"
+#include "frame.h"
+
/**
* @file
* API-specific header for AV_HWDEVICE_TYPE_VULKAN.
* Custom memory allocator, else NULL
*/
const VkAllocationCallbacks *alloc;
+
/**
* Vulkan instance. Must be at least version 1.1.
*/
VkInstance inst;
+
/**
* Physical device
*/
VkPhysicalDevice phys_dev;
+
/**
* Active device
*/
VkDevice act_dev;
+
/**
- * Queue family index for graphics
- * @note av_hwdevice_create() will set all 3 queue indices if unset
- * If there is no dedicated queue for compute or transfer operations,
- * they will be set to the graphics queue index which can handle both.
- */
- int queue_family_index;
- /**
- * Queue family index for transfer ops only
- */
- int queue_family_tx_index;
- /**
- * Queue family index for compute ops
+ * This structure should be set to the set of features that present and enabled
+ * during device creation. When a device is created by FFmpeg, it will default to
+ * enabling all that are present of the shaderImageGatherExtended,
+ * fragmentStoresAndAtomics, shaderInt64 and vertexPipelineStoresAndAtomics features.
*/
- int queue_family_comp_index;
+ VkPhysicalDeviceFeatures2 device_features;
+
/**
- * Enabled instance extensions. By default, VK_KHR_surface is enabled if found.
+ * Enabled instance extensions.
* If supplying your own device context, set this to an array of strings, with
* each entry containing the specified Vulkan extension string to enable.
* Duplicates are possible and accepted.
*/
const char * const *enabled_inst_extensions;
int nb_enabled_inst_extensions;
+
/**
* Enabled device extensions. By default, VK_KHR_external_memory_fd,
- * VK_EXT_external_memory_dma_buf, VK_EXT_image_drm_format_modifier and
- * VK_KHR_external_semaphore_fd are enabled if found.
+ * VK_EXT_external_memory_dma_buf, VK_EXT_image_drm_format_modifier,
+ * VK_KHR_external_semaphore_fd and VK_EXT_external_memory_host are enabled if found.
* If supplying your own device context, these fields takes the same format as
* the above fields, with the same conditions that duplicates are possible
* and accepted, and that NULL and 0 respectively means no extensions are enabled.
*/
const char * const *enabled_dev_extensions;
int nb_enabled_dev_extensions;
+
+ /**
+ * Queue family index for graphics
+ * @note av_hwdevice_create() will set all 3 queue indices if unset
+ * If there is no dedicated queue for compute or transfer operations,
+ * they will be set to the graphics queue index which can handle both.
+ * nb_graphics_queues indicates how many queues were enabled for the
+ * graphics queue (must be at least 1)
+ */
+ int queue_family_index;
+ int nb_graphics_queues;
+
+ /**
+ * Queue family index to use for transfer operations, and the amount of queues
+ * enabled. In case there is no dedicated transfer queue, nb_tx_queues
+ * must be 0 and queue_family_tx_index must be the same as either the graphics
+ * queue or the compute queue, if available.
+ */
+ int queue_family_tx_index;
+ int nb_tx_queues;
+
+ /**
+ * Queue family index for compute ops, and the amount of queues enabled.
+ * In case there are no dedicated compute queues, nb_comp_queues must be
+ * 0 and its queue family index must be set to the graphics queue.
+ */
+ int queue_family_comp_index;
+ int nb_comp_queues;
} AVVulkanDeviceContext;
/**
*/
typedef struct AVVulkanFramesContext {
/**
- * Controls the tiling of output frames.
+ * Controls the tiling of allocated frames.
*/
VkImageTiling tiling;
+
/**
- * Defines extra usage of output frames. This is bitwise OR'd with the
- * standard usage flags (SAMPLED, STORAGE, TRANSFER_SRC and TRANSFER_DST).
+ * Defines extra usage of output frames. If left as 0, the following bits
+ * are set: TRANSFER_SRC, TRANSFER_DST. SAMPLED and STORAGE.
*/
VkImageUsageFlagBits usage;
+
/**
- * Extension data for image creation. By default, if the extension is
- * available, this will be chained to a VkImageFormatListCreateInfoKHR.
+ * Extension data for image creation.
*/
void *create_pnext;
+
/**
* Extension data for memory allocation. Must have as many entries as
* the number of planes of the sw_format.
* This will be chained to VkExportMemoryAllocateInfo, which is used
- * to make all pool images exportable to other APIs.
+ * to make all pool images exportable to other APIs if the necessary
+ * extensions are present in enabled_dev_extensions.
*/
void *alloc_pnext[AV_NUM_DATA_POINTERS];
} AVVulkanFramesContext;
VkImage img[AV_NUM_DATA_POINTERS];
/**
- * Same tiling must be used for all images.
+ * The same tiling must be used for all images in the frame.
*/
VkImageTiling tiling;
VkImageLayout layout[AV_NUM_DATA_POINTERS];
/**
- * Per-image semaphores. Must not be freed manually. Must be waited on
+ * Synchronization semaphores. Must not be freed manually. Must be waited on
* and signalled at every queue submission.
+ * Could be less than the amount of images: either one per VkDeviceMemory
+ * or one for the entire frame. All others will be set to VK_NULL_HANDLE.
*/
VkSemaphore sem[AV_NUM_DATA_POINTERS];
/**
* Returns the format of each image up to the number of planes for a given sw_format.
+ * Returns NULL on unsupported formats.
*/
const VkFormat *av_vkfmt_from_pixfmt(enum AVPixelFormat p);