[FFmpeg-cvslog] hwcontext_vulkan: fix issues with importing a device
Lynne
git at videolan.org
Thu Jun 26 21:09:41 EEST 2025
ffmpeg | branch: master | Lynne <dev at lynne.ee> | Fri Jun 27 03:05:13 2025 +0900| [bd75fad85f37da92f83a4b36126d18112fce5b72] | committer: Lynne
hwcontext_vulkan: fix issues with importing a device
The previous fix just used a local variable for the memory properties,
which did not fix this issue.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bd75fad85f37da92f83a4b36126d18112fce5b72
---
libavutil/hwcontext_vulkan.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 547fbe184f..894bc3dae1 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1666,16 +1666,12 @@ static void vulkan_device_uninit(AVHWDeviceContext *ctx)
static int vulkan_device_has_rebar(AVHWDeviceContext *ctx)
{
VulkanDevicePriv *p = ctx->hwctx;
- AVVulkanDeviceContext *hwctx = &p->p;
- FFVulkanFunctions *vk = &p->vkctx.vkfn;
- VkPhysicalDeviceMemoryProperties mprops;
VkDeviceSize max_vram = 0, max_visible_vram = 0;
/* Get device memory properties */
- vk->GetPhysicalDeviceMemoryProperties(hwctx->phys_dev, &mprops);
- for (int i = 0; i < mprops.memoryTypeCount; i++) {
- const VkMemoryType type = mprops.memoryTypes[i];
- const VkMemoryHeap heap = mprops.memoryHeaps[type.heapIndex];
+ for (int i = 0; i < p->mprops.memoryTypeCount; i++) {
+ const VkMemoryType type = p->mprops.memoryTypes[i];
+ const VkMemoryHeap heap = p->mprops.memoryHeaps[type.heapIndex];
if (!(type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT))
continue;
max_vram = FFMAX(max_vram, heap.size);
@@ -2019,6 +2015,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (!hwctx->unlock_queue)
hwctx->unlock_queue = unlock_queue;
+ /* Re-query device capabilities, in case the device was created externally */
+ vk->GetPhysicalDeviceMemoryProperties(hwctx->phys_dev, &p->mprops);
+
p->vkctx.device = ctx;
p->vkctx.hwctx = hwctx;
@@ -2026,6 +2025,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
p->compute_qf = ff_vk_qf_find(&p->vkctx, VK_QUEUE_COMPUTE_BIT, 0);
p->transfer_qf = ff_vk_qf_find(&p->vkctx, VK_QUEUE_TRANSFER_BIT, 0);
+ /* Re-query device capabilities, in case the device was created externally */
+ vk->GetPhysicalDeviceMemoryProperties(hwctx->phys_dev, &p->mprops);
+
/* Only use host image transfers if ReBAR is enabled */
p->disable_host_transfer = !vulkan_device_has_rebar(ctx);
More information about the ffmpeg-cvslog
mailing list