diff options
author | Lynne <dev@lynne.ee> | 2025-06-27 03:05:13 +0900 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2025-06-27 03:09:27 +0900 |
commit | bd75fad85f37da92f83a4b36126d18112fce5b72 (patch) | |
tree | 256101f3e88c7bebcfa29eb763930b1c5b0c4091 /libavutil/hwcontext_vulkan.c | |
parent | f744584f7160db99c1003ef938c53d26eb427b00 (diff) | |
download | ffmpeg-bd75fad85f37da92f83a4b36126d18112fce5b72.tar.gz |
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.
Diffstat (limited to 'libavutil/hwcontext_vulkan.c')
-rw-r--r-- | libavutil/hwcontext_vulkan.c | 16 |
1 files 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); |