vulkan_filter: require storage images properly, set usage flags explicitly

This caused images to be created without a storage usage, which broke
at least lavapipe.
This commit is contained in:
Lynne 2024-08-31 23:28:41 +00:00
parent c41ef7f2ff
commit eb5088d28c
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
1 changed files with 10 additions and 1 deletions

View File

@ -68,7 +68,8 @@ int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s,
vk = &s->vkfn; vk = &s->vkfn;
/* Usage mismatch */ /* Usage mismatch */
usage_req = VK_IMAGE_USAGE_SAMPLED_BIT; usage_req = VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_STORAGE_BIT;
/* If format supports hardware encoding, make sure /* If format supports hardware encoding, make sure
* the context includes it. */ * the context includes it. */
@ -106,9 +107,11 @@ int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s,
/* Check if it's usable */ /* Check if it's usable */
if (no_storage) { if (no_storage) {
skip: skip:
av_log(avctx, AV_LOG_VERBOSE, "Cannot reuse context, creating a new one\n");
device_ref = frames_ctx->device_ref; device_ref = frames_ctx->device_ref;
frames_ref = NULL; frames_ref = NULL;
} else { } else {
av_log(avctx, AV_LOG_VERBOSE, "Reusing existing frames context\n");
frames_ref = av_buffer_ref(frames_ref); frames_ref = av_buffer_ref(frames_ref);
if (!frames_ref) if (!frames_ref)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -130,6 +133,12 @@ skip:
frames_ctx->width = width; frames_ctx->width = width;
frames_ctx->height = height; frames_ctx->height = height;
vk_frames = frames_ctx->hwctx;
vk_frames->tiling = VK_IMAGE_TILING_OPTIMAL;
vk_frames->usage = VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_STORAGE_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
err = av_hwframe_ctx_init(frames_ref); err = av_hwframe_ctx_init(frames_ref);
if (err < 0) { if (err < 0) {
av_buffer_unref(&frames_ref); av_buffer_unref(&frames_ref);