1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

vulkan: add support for the atomic float ops extension

This commit is contained in:
Lynne 2023-04-13 12:18:12 +02:00
parent 88e2cca3db
commit dfff3877b7
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
5 changed files with 33 additions and 1 deletions

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 },