1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

hwcontext_vulkan: add support for VK_EXT_shader_object

We'd like to use it eventually, and its already covered by
the minimum version of the headers we require.
This commit is contained in:
Lynne 2024-07-24 12:58:34 +02:00
parent 12f868cab5
commit 55adcb4fc5
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
3 changed files with 19 additions and 3 deletions

View File

@ -93,6 +93,7 @@ typedef struct VulkanDevicePriv {
VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_features; VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_features;
VkPhysicalDeviceCooperativeMatrixFeaturesKHR coop_matrix_features; VkPhysicalDeviceCooperativeMatrixFeaturesKHR coop_matrix_features;
VkPhysicalDeviceOpticalFlowFeaturesNV optical_flow_features; VkPhysicalDeviceOpticalFlowFeaturesNV optical_flow_features;
VkPhysicalDeviceShaderObjectFeaturesEXT shader_object_features;
/* Queues */ /* Queues */
pthread_mutex_t **qf_mutex; pthread_mutex_t **qf_mutex;
@ -421,6 +422,7 @@ static const VulkanOptExtension optional_device_exts[] = {
{ VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME, FF_VK_EXT_ATOMIC_FLOAT }, { VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME, FF_VK_EXT_ATOMIC_FLOAT },
{ VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME, FF_VK_EXT_COOP_MATRIX }, { VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME, FF_VK_EXT_COOP_MATRIX },
{ VK_NV_OPTICAL_FLOW_EXTENSION_NAME, FF_VK_EXT_OPTICAL_FLOW }, { VK_NV_OPTICAL_FLOW_EXTENSION_NAME, FF_VK_EXT_OPTICAL_FLOW },
{ VK_EXT_SHADER_OBJECT_EXTENSION_NAME, FF_VK_EXT_SHADER_OBJECT },
/* Imports/exports */ /* Imports/exports */
{ VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_FD_MEMORY }, { VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_FD_MEMORY },
@ -1312,9 +1314,13 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx,
VkPhysicalDeviceTimelineSemaphoreFeatures timeline_features = { VkPhysicalDeviceTimelineSemaphoreFeatures timeline_features = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES,
}; };
VkPhysicalDeviceShaderObjectFeaturesEXT shader_object_features = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT,
.pNext = &timeline_features,
};
VkPhysicalDeviceOpticalFlowFeaturesNV optical_flow_features = { VkPhysicalDeviceOpticalFlowFeaturesNV optical_flow_features = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV, .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV,
.pNext = &timeline_features, .pNext = &shader_object_features,
}; };
VkPhysicalDeviceCooperativeMatrixFeaturesKHR coop_matrix_features = { VkPhysicalDeviceCooperativeMatrixFeaturesKHR coop_matrix_features = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR, .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR,
@ -1364,7 +1370,9 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx,
p->coop_matrix_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR; p->coop_matrix_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR;
p->coop_matrix_features.pNext = &p->optical_flow_features; p->coop_matrix_features.pNext = &p->optical_flow_features;
p->optical_flow_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV; p->optical_flow_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV;
p->optical_flow_features.pNext = NULL; p->optical_flow_features.pNext = &p->shader_object_features;
p->shader_object_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT;
p->shader_object_features.pNext = NULL;
ctx->free = vulkan_device_free; ctx->free = vulkan_device_free;
@ -1432,6 +1440,8 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx,
p->optical_flow_features.opticalFlow = optical_flow_features.opticalFlow; p->optical_flow_features.opticalFlow = optical_flow_features.opticalFlow;
p->shader_object_features.shaderObject = shader_object_features.shaderObject;
dev_info.pNext = &hwctx->device_features; dev_info.pNext = &hwctx->device_features;
/* Setup queue family */ /* Setup queue family */

View File

@ -47,6 +47,7 @@ typedef enum FFVulkanExtensions {
FF_VK_EXT_ATOMIC_FLOAT = 1ULL << 15, /* VK_EXT_shader_atomic_float */ FF_VK_EXT_ATOMIC_FLOAT = 1ULL << 15, /* VK_EXT_shader_atomic_float */
FF_VK_EXT_COOP_MATRIX = 1ULL << 16, /* VK_KHR_cooperative_matrix */ FF_VK_EXT_COOP_MATRIX = 1ULL << 16, /* VK_KHR_cooperative_matrix */
FF_VK_EXT_OPTICAL_FLOW = 1ULL << 17, /* VK_NV_optical_flow */ FF_VK_EXT_OPTICAL_FLOW = 1ULL << 17, /* VK_NV_optical_flow */
FF_VK_EXT_SHADER_OBJECT = 1ULL << 18, /* VK_EXT_shader_object */
FF_VK_EXT_NO_FLAG = 1ULL << 31, FF_VK_EXT_NO_FLAG = 1ULL << 31,
} FFVulkanExtensions; } FFVulkanExtensions;
@ -219,7 +220,11 @@ typedef enum FFVulkanExtensions {
\ \
/* Shaders */ \ /* Shaders */ \
MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateShaderModule) \ MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateShaderModule) \
MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyShaderModule) MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyShaderModule) \
MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT, CmdBindShadersEXT) \
MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT, CreateShadersEXT) \
MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT, DestroyShaderEXT) \
MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT, GetShaderBinaryDataEXT)
/* Macro containing every win32 specific function that we utilize in our codebase */ /* Macro containing every win32 specific function that we utilize in our codebase */
#define FN_LIST_WIN32(MACRO) \ #define FN_LIST_WIN32(MACRO) \

View File

@ -50,6 +50,7 @@ static inline uint64_t ff_vk_extensions_to_mask(const char * const *extensions,
{ VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME, FF_VK_EXT_ATOMIC_FLOAT }, { VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME, FF_VK_EXT_ATOMIC_FLOAT },
{ VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME, FF_VK_EXT_COOP_MATRIX }, { VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME, FF_VK_EXT_COOP_MATRIX },
{ VK_NV_OPTICAL_FLOW_EXTENSION_NAME, FF_VK_EXT_OPTICAL_FLOW }, { VK_NV_OPTICAL_FLOW_EXTENSION_NAME, FF_VK_EXT_OPTICAL_FLOW },
{ VK_EXT_SHADER_OBJECT_EXTENSION_NAME, FF_VK_EXT_SHADER_OBJECT },
#ifdef _WIN32 #ifdef _WIN32
{ VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_WIN32_MEMORY }, { 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 }, { VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_WIN32_SEM },