1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

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.
This commit is contained in:
Lynne
2025-06-27 03:05:13 +09:00
parent f744584f71
commit bd75fad85f

View File

@ -1666,16 +1666,12 @@ static void vulkan_device_uninit(AVHWDeviceContext *ctx)
static int vulkan_device_has_rebar(AVHWDeviceContext *ctx) static int vulkan_device_has_rebar(AVHWDeviceContext *ctx)
{ {
VulkanDevicePriv *p = ctx->hwctx; VulkanDevicePriv *p = ctx->hwctx;
AVVulkanDeviceContext *hwctx = &p->p;
FFVulkanFunctions *vk = &p->vkctx.vkfn;
VkPhysicalDeviceMemoryProperties mprops;
VkDeviceSize max_vram = 0, max_visible_vram = 0; VkDeviceSize max_vram = 0, max_visible_vram = 0;
/* Get device memory properties */ /* Get device memory properties */
vk->GetPhysicalDeviceMemoryProperties(hwctx->phys_dev, &mprops); for (int i = 0; i < p->mprops.memoryTypeCount; i++) {
for (int i = 0; i < mprops.memoryTypeCount; i++) { const VkMemoryType type = p->mprops.memoryTypes[i];
const VkMemoryType type = mprops.memoryTypes[i]; const VkMemoryHeap heap = p->mprops.memoryHeaps[type.heapIndex];
const VkMemoryHeap heap = mprops.memoryHeaps[type.heapIndex];
if (!(type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) if (!(type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT))
continue; continue;
max_vram = FFMAX(max_vram, heap.size); max_vram = FFMAX(max_vram, heap.size);
@ -2019,6 +2015,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (!hwctx->unlock_queue) if (!hwctx->unlock_queue)
hwctx->unlock_queue = 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.device = ctx;
p->vkctx.hwctx = hwctx; 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->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); 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 */ /* Only use host image transfers if ReBAR is enabled */
p->disable_host_transfer = !vulkan_device_has_rebar(ctx); p->disable_host_transfer = !vulkan_device_has_rebar(ctx);