diff options
author | Lynne <dev@lynne.ee> | 2023-04-13 12:18:12 +0200 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2023-05-29 00:42:01 +0200 |
commit | dfff3877b70b3d4493312efdea6d00ded0458f49 (patch) | |
tree | 47c4cbb737378afbbe8e4d3a0e6536dc5a9acf6e | |
parent | 88e2cca3dbd1f509982778804ba2463058bb729a (diff) | |
download | ffmpeg-dfff3877b70b3d4493312efdea6d00ded0458f49.tar.gz |
vulkan: add support for the atomic float ops extension
-rw-r--r-- | libavutil/hwcontext_vulkan.c | 15 | ||||
-rw-r--r-- | libavutil/vulkan.c | 13 | ||||
-rw-r--r-- | libavutil/vulkan.h | 4 | ||||
-rw-r--r-- | libavutil/vulkan_functions.h | 1 | ||||
-rw-r--r-- | libavutil/vulkan_loader.h | 1 |
5 files changed, 33 insertions, 1 deletions
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index ef7b00376a..e8241638d9 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -96,6 +96,7 @@ typedef struct VulkanDevicePriv { VkPhysicalDeviceVulkan12Features device_features_1_2; VkPhysicalDeviceVulkan13Features device_features_1_3; VkPhysicalDeviceDescriptorBufferFeaturesEXT desc_buf_features; + VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_features; /* Queues */ pthread_mutex_t **qf_mutex; @@ -401,6 +402,7 @@ static const VulkanOptExtension optional_device_exts[] = { { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, FF_VK_EXT_NO_FLAG }, { VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME, FF_VK_EXT_DESCRIPTOR_BUFFER, }, { VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME, FF_VK_EXT_DEVICE_DRM }, + { VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME, FF_VK_EXT_ATOMIC_FLOAT }, /* Imports/exports */ { VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_FD_MEMORY }, @@ -1195,9 +1197,13 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, VkPhysicalDeviceTimelineSemaphoreFeatures timeline_features = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, }; + VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_features = { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT, + .pNext = &timeline_features, + }; VkPhysicalDeviceDescriptorBufferFeaturesEXT desc_buf_features = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT, - .pNext = &timeline_features, + .pNext = &atomic_float_features, }; VkPhysicalDeviceVulkan13Features dev_features_1_3 = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES, @@ -1229,6 +1235,10 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, p->device_features_1_3.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; p->device_features_1_3.pNext = &p->desc_buf_features; p->desc_buf_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT; + p->desc_buf_features.pNext = &p->atomic_float_features; + p->atomic_float_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT; + p->atomic_float_features.pNext = NULL; + ctx->free = vulkan_device_free; /* Create an instance if not given one */ @@ -1286,6 +1296,9 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, p->desc_buf_features.descriptorBuffer = desc_buf_features.descriptorBuffer; p->desc_buf_features.descriptorBufferPushDescriptors = desc_buf_features.descriptorBufferPushDescriptors; + p->atomic_float_features.shaderBufferFloat32Atomics = atomic_float_features.shaderBufferFloat32Atomics; + p->atomic_float_features.shaderBufferFloat32AtomicAdd = atomic_float_features.shaderBufferFloat32AtomicAdd; + dev_info.pNext = &hwctx->device_features; /* Setup queue family */ diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 8a1233662f..31e0df494b 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -107,8 +107,21 @@ int ff_vk_load_props(FFVulkanContext *s) .pNext = &s->driver_props, }; + s->atomic_float_feats = (VkPhysicalDeviceShaderAtomicFloatFeaturesEXT) { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT, + }; + s->feats_12 = (VkPhysicalDeviceVulkan12Features) { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, + .pNext = &s->atomic_float_feats, + }; + s->feats = (VkPhysicalDeviceFeatures2) { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, + .pNext = &s->feats_12, + }; + vk->GetPhysicalDeviceProperties2(s->hwctx->phys_dev, &s->props); vk->GetPhysicalDeviceMemoryProperties(s->hwctx->phys_dev, &s->mprops); + vk->GetPhysicalDeviceFeatures2(s->hwctx->phys_dev, &s->feats); if (s->qf_props) return 0; diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index ec03ba8b71..58da720a1c 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -240,6 +240,10 @@ typedef struct FFVulkanContext { VkQueueFamilyProperties2 *qf_props; int tot_nb_qfs; + VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_feats; + VkPhysicalDeviceVulkan12Features feats_12; + VkPhysicalDeviceFeatures2 feats; + AVHWDeviceContext *device; AVVulkanDeviceContext *hwctx; diff --git a/libavutil/vulkan_functions.h b/libavutil/vulkan_functions.h index 2028c76122..32f466a933 100644 --- a/libavutil/vulkan_functions.h +++ b/libavutil/vulkan_functions.h @@ -44,6 +44,7 @@ typedef enum FFVulkanExtensions { FF_VK_EXT_VIDEO_DECODE_H264 = 1ULL << 12, /* VK_EXT_video_decode_h264 */ FF_VK_EXT_VIDEO_DECODE_H265 = 1ULL << 13, /* VK_EXT_video_decode_h265 */ FF_VK_EXT_VIDEO_DECODE_AV1 = 1ULL << 14, /* VK_MESA_video_decode_av1 */ + FF_VK_EXT_ATOMIC_FLOAT = 1ULL << 15, /* VK_EXT_shader_atomic_float */ FF_VK_EXT_NO_FLAG = 1ULL << 31, } FFVulkanExtensions; diff --git a/libavutil/vulkan_loader.h b/libavutil/vulkan_loader.h index 580100e2c3..c45c674eaf 100644 --- a/libavutil/vulkan_loader.h +++ b/libavutil/vulkan_loader.h @@ -45,6 +45,7 @@ static inline uint64_t ff_vk_extensions_to_mask(const char * const *extensions, { VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_HOST_MEMORY }, { VK_EXT_DEBUG_UTILS_EXTENSION_NAME, FF_VK_EXT_DEBUG_UTILS }, { VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME, FF_VK_EXT_DEVICE_DRM }, + { VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME, FF_VK_EXT_ATOMIC_FLOAT }, #ifdef _WIN32 { VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_WIN32_MEMORY }, { VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_WIN32_SEM }, |