This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 9f3a04d2f662d8a1ab8082695d63424406e8e3a2
Author:     Lynne <[email protected]>
AuthorDate: Fri Dec 19 23:49:43 2025 +0000
Commit:     Lynne <[email protected]>
CommitDate: Wed Dec 31 15:00:46 2025 +0100

    vulkan: use HOST_CACHED memory flag only if such a heap exists
    
    NVK does not offer such, so our code failed to allocate memory.
---
 libavcodec/ffv1enc_vulkan.c  | 5 ++---
 libavcodec/vulkan_encode.c   | 2 +-
 libavutil/hwcontext_vulkan.c | 2 +-
 libavutil/vulkan.c           | 4 ++++
 libavutil/vulkan.h           | 2 ++
 5 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavcodec/ffv1enc_vulkan.c b/libavcodec/ffv1enc_vulkan.c
index 86521af6c5..1dc6aa8e90 100644
--- a/libavcodec/ffv1enc_vulkan.c
+++ b/libavcodec/ffv1enc_vulkan.c
@@ -365,9 +365,8 @@ static int vulkan_encode_ffv1_submit_frame(AVCodecContext 
*avctx,
                                 NULL, maxsize,
                                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
                                 (maxsize < fv->max_heap_size ?
-                                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0x0) |
-                                (!(fv->s.extensions & 
FF_VK_EXT_EXTERNAL_HOST_MEMORY) ?
-                                 VK_MEMORY_PROPERTY_HOST_CACHED_BIT : 0x0)));
+                                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT :
+                                 fv->s.host_cached_flag)));
     out_data_buf = (FFVkBuffer *)fd->out_data_ref->data;
     ff_vk_exec_add_dep_buf(&fv->s, exec, &fd->out_data_ref, 1, 1);
 
diff --git a/libavcodec/vulkan_encode.c b/libavcodec/vulkan_encode.c
index c820b63666..a440646e4f 100644
--- a/libavcodec/vulkan_encode.c
+++ b/libavcodec/vulkan_encode.c
@@ -182,7 +182,7 @@ static int vulkan_encode_issue(AVCodecContext *avctx,
                                   VK_BUFFER_USAGE_VIDEO_ENCODE_DST_BIT_KHR,
                                   &ctx->profile_list, max_pkt_size,
                                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
-                                  VK_MEMORY_PROPERTY_HOST_CACHED_BIT);
+                                  ctx->s.host_cached_flag);
     if (err < 0)
         return err;
 
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 58a88889f3..a7b6d8d4ca 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -4348,7 +4348,7 @@ static int get_plane_buf(AVHWFramesContext *hwfc, 
AVBufferRef **dst,
     err = ff_vk_get_pooled_buffer(&p->vkctx, &fp->tmp, dst, buf_usage,
                                   NULL, buf_offset,
                                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
-                                  VK_MEMORY_PROPERTY_HOST_CACHED_BIT);
+                                  p->vkctx.host_cached_flag);
     if (err < 0)
         return err;
 
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 7858e002ed..d4ac1544d1 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -212,6 +212,10 @@ int ff_vk_load_props(FFVulkanContext *s)
     vk->GetPhysicalDeviceMemoryProperties(s->hwctx->phys_dev, &s->mprops);
     vk->GetPhysicalDeviceFeatures2(s->hwctx->phys_dev, &s->feats);
 
+    for (int i = 0; i < s->mprops.memoryTypeCount; i++)
+        s->host_cached_flag |= s->mprops.memoryTypes[i].propertyFlags &
+                               VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
+
     load_enabled_qfs(s);
 
     if (s->qf_props)
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index 29116bcb2c..d42bf514fe 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -301,6 +301,8 @@ typedef struct FFVulkanContext {
     VkPhysicalDeviceVulkan12Features feats_12;
     VkPhysicalDeviceFeatures2 feats;
 
+    VkMemoryPropertyFlagBits host_cached_flag;
+
     AVBufferRef           *device_ref;
     AVHWDeviceContext     *device;
     AVVulkanDeviceContext *hwctx;

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to