diff mbox series

[FFmpeg-devel,V2,06/10] libavutil/hwcontext_vulkan: Add one_memory flag to make vulkan compatible with vaapi device.

Message ID 20210831072430.303090-6-wenbin.chen@intel.com
State New
Headers show
Series [FFmpeg-devel,V2,01/10] libavfilter/vulkan: Fix problem when device have queue_count greater than 1
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Wenbin Chen Aug. 31, 2021, 7:24 a.m. UTC
Vaapi can import external surface, but all the planes of the external
frames should be in the same drm object. A new flag is introduced and
vulkan can choose to allocate planes in one memory according this flag.
This flag will be enabled when the vulkan device is derived from vaapi
device, so that this change will not affect current vulkan behaviour.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavutil/hwcontext_vulkan.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 9a29267aed..6417f59d4a 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -211,6 +211,9 @@  typedef struct VulkanDevicePriv {
     /* Settings */
     int use_linear_images;
 
+    /* map all planes to one memory */
+    int use_one_memory;
+
     /* Nvidia */
     int dev_is_nvidia;
 } VulkanDevicePriv;
@@ -1321,6 +1324,11 @@  static int vulkan_device_create_internal(AVHWDeviceContext *ctx,
     if (opt_d)
         p->use_linear_images = strtol(opt_d->value, NULL, 10);
 
+    opt_d = av_dict_get(opts, "one_memory", NULL, 0);
+    if (opt_d)
+        p->use_one_memory = strtol(opt_d->value, NULL, 10);
+
+
     hwctx->enabled_dev_extensions = dev_info.ppEnabledExtensionNames;
     hwctx->nb_enabled_dev_extensions = dev_info.enabledExtensionCount;
 
@@ -1443,8 +1451,10 @@  static int vulkan_device_derive(AVHWDeviceContext *ctx,
             return AVERROR_EXTERNAL;
         }
 
-        if (strstr(vendor, "Intel"))
+        if (strstr(vendor, "Intel")) {
+            av_dict_set_int(&opts, "one_memory", 1, 0);
             dev_select.vendor_id = 0x8086;
+        }
         if (strstr(vendor, "AMD"))
             dev_select.vendor_id = 0x1002;