History

vulkan_decode: adjust number of async contexts created

This caps the number of contexts we create based on thread count. This saves VRAM and filters out cases where more async is of lesser benefit.

Lynne committed 1 year ago

Commit e15e85b1 parent 44958021 file · +8 −2Browse files

Unified · Split

libavcodec/vulkan_decode.c+8−2
@@ -1122,6 +1122,7 @@ int ff_vk_decode_init(AVCodecContext *avctx) · 1121 unmodified lines
11221122 FFVulkanDecodeShared *ctx;
11231123 FFVulkanContext *s;
11241124 FFVulkanFunctions *vk;
1125+ int async_depth;
11251126 const VkVideoProfileInfoKHR *profile;
11261127 const FFVulkanDecodeDescriptor *vk_desc;
11271128 const VkPhysicalDeviceDriverProperties *driver_props;
@@ -1191,9 +1192,14 @@ int ff_vk_decode_init(AVCodecContext *avctx) · 63 unmodified lines
11911192 /* Create decode exec context for this specific main thread.
11921193 * 2 async contexts per thread was experimentally determined to be optimal
11931194 * for a majority of streams. */
1195+ async_depth = 2*ctx->qf->num;
1196+ /* We don't need more than 2 per thread context */
1197+ async_depth = FFMIN(async_depth, 2*avctx->thread_count);
1198+ /* Make sure there are enough async contexts for each thread */
1199+ async_depth = FFMAX(async_depth, avctx->thread_count);
1200+
11941201 err = ff_vk_exec_pool_init(s, ctx->qf, &ctx->exec_pool,
1195− FFMAX(2*ctx->qf->num, avctx->thread_count),
1196− 0, 0, 0, profile);
1202+ async_depth, 0, 0, 0, profile);
11971203 if (err < 0)
11981204 goto fail;
11991205

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t