[FFmpeg-cvslog] hwcontext_vulkan: check for memory size before choosing type
Lynne
git at videolan.org
Thu Nov 26 00:15:27 EET 2020
ffmpeg | branch: master | Lynne <dev at lynne.ee> | Tue Nov 24 23:36:08 2020 +0100| [9cf1811d3d1df429bd882090dcab32e3449777f4] | committer: Lynne
hwcontext_vulkan: check for memory size before choosing type
It makes allocation a bit more robust in case some weird device with
weird drivers which segments memory in weird ways appears.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9cf1811d3d1df429bd882090dcab32e3449777f4
---
libavutil/hwcontext_vulkan.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 7156952339..d13e6a26ba 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1270,12 +1270,18 @@ static int alloc_mem(AVHWDeviceContext *ctx, VkMemoryRequirements *req,
/* The vulkan spec requires memory types to be sorted in the "optimal"
* order, so the first matching type we find will be the best/fastest one */
for (int i = 0; i < p->mprops.memoryTypeCount; i++) {
+ const VkMemoryType *type = &p->mprops.memoryTypes[i];
+
/* The memory type must be supported by the requirements (bitfield) */
if (!(req->memoryTypeBits & (1 << i)))
continue;
/* The memory type flags must include our properties */
- if ((p->mprops.memoryTypes[i].propertyFlags & req_flags) != req_flags)
+ if ((type->propertyFlags & req_flags) != req_flags)
+ continue;
+
+ /* The memory type must be large enough */
+ if (req->size > p->mprops.memoryHeaps[type->heapIndex].size)
continue;
/* Found a suitable memory type */
More information about the ffmpeg-cvslog
mailing list