[FFmpeg-devel] [PATCH] vulkan_decode: remove yuv sampler for DPB images
Benjamin Cheng
ben at bcheng.me
Fri Oct 11 18:45:38 EEST 2024
The YCbCr sampler is only required for multi-plane images if the image
is created with SAMPLED usage, and the image view is created with
aspectMask = COLOR. For DPB images, it is expected that some
implementations will have opaque DPBs (i.e. they do not support
SAMPLED/TRANSFER/STORAGE usages).
Since ffmpeg doesn't use DPB images in a shader anyways, the SAMPLED
usage was not necessary.
A run with this change did not introduce any new validation errors on
RADV.
---
libavcodec/vulkan_decode.c | 3 +--
libavcodec/vulkan_video.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index 7d7295e05e..12472b5cb4 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -1191,8 +1191,7 @@ int ff_vk_decode_init(AVCodecContext *avctx)
VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
dpb_hwfc->format[0] = s->hwfc->format[0];
dpb_hwfc->tiling = VK_IMAGE_TILING_OPTIMAL;
- dpb_hwfc->usage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
- VK_IMAGE_USAGE_SAMPLED_BIT; /* Shuts validator up. */
+ dpb_hwfc->usage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
if (ctx->common.layered_dpb)
dpb_hwfc->nb_layers = ctx->caps.maxDpbSlots;
diff --git a/libavcodec/vulkan_video.c b/libavcodec/vulkan_video.c
index 3a04d60d68..2acbbfa05e 100644
--- a/libavcodec/vulkan_video.c
+++ b/libavcodec/vulkan_video.c
@@ -292,7 +292,7 @@ int ff_vk_create_view(FFVulkanContext *s, FFVkVideoCommon *common,
};
VkImageViewCreateInfo img_view_create_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
- .pNext = &yuv_sampler_info,
+ .pNext = common->layered_dpb && is_dpb ? NULL : &yuv_sampler_info,
.viewType = common->layered_dpb && is_dpb ?
VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D,
.format = vkf,
--
2.47.0
More information about the ffmpeg-devel
mailing list