MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_vk_create_imageviews

Function ff_vk_create_imageviews

libavutil/vulkan.c:1956–2037  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1954}
1955
1956int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e,
1957 VkImageView views[AV_NUM_DATA_POINTERS],
1958 AVFrame *f, enum FFVkShaderRepFormat rep_fmt)
1959{
1960 int err;
1961 VkResult ret;
1962 AVBufferRef *buf;
1963 FFVulkanFunctions *vk = &s->vkfn;
1964 AVHWFramesContext *hwfc = (AVHWFramesContext *)f->hw_frames_ctx->data;
1965 AVVulkanFramesContext *vkfc = hwfc->hwctx;
1966 const VkFormat *rep_fmts = av_vkfmt_from_pixfmt(hwfc->sw_format);
1967 AVVkFrame *vkf = (AVVkFrame *)f->data[0];
1968 const int nb_images = ff_vk_count_images(vkf);
1969 const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format);
1970
1971 ImageViewCtx *iv;
1972 const size_t buf_size = sizeof(*iv) + nb_planes*sizeof(VkImageView);
1973 iv = av_mallocz(buf_size);
1974 if (!iv)
1975 return AVERROR(ENOMEM);
1976
1977 for (int i = 0; i < nb_planes; i++) {
1978 VkImageViewUsageCreateInfo view_usage_info = {
1979 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
1980 .usage = vkfc->usage &
1981 (~(VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR |
1982 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR)),
1983 };
1984 VkImageViewCreateInfo view_create_info = {
1985 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1986 .pNext = &view_usage_info,
1987 .image = vkf->img[FFMIN(i, nb_images - 1)],
1988 .viewType = VK_IMAGE_VIEW_TYPE_2D,
1989 .format = map_fmt_to_rep(rep_fmts[i], rep_fmt),
1990 .components = ff_comp_identity_map,
1991 .subresourceRange = {
1992 .aspectMask = ff_vk_aspect_flag(f, i),
1993 .levelCount = 1,
1994 .layerCount = 1,
1995 },
1996 };
1997 if (view_create_info.format == VK_FORMAT_UNDEFINED) {
1998 av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation "
1999 "of format %i and mode %i\n",
2000 rep_fmts[i], rep_fmt);
2001 err = AVERROR(EINVAL);
2002 goto fail;
2003 }
2004
2005 ret = vk->CreateImageView(s->hwctx->act_dev, &view_create_info,
2006 s->hwctx->alloc, &iv->views[i]);
2007 if (ret != VK_SUCCESS) {
2008 av_log(s, AV_LOG_ERROR, "Failed to create imageview: %s\n",
2009 ff_vk_ret2str(ret));
2010 err = AVERROR_EXTERNAL;
2011 goto fail;
2012 }
2013

Callers 10

vk_ffv1_end_frameFunction · 0.85
processFunction · 0.85
ff_vk_filter_process_NinFunction · 0.85

Calls 12

ff_vk_count_imagesFunction · 0.85
av_pix_fmt_count_planesFunction · 0.85
map_fmt_to_repFunction · 0.85
ff_vk_aspect_flagFunction · 0.85
av_logFunction · 0.85
ff_vk_ret2strFunction · 0.85
av_buffer_createFunction · 0.85
ff_vk_exec_add_dep_bufFunction · 0.85
av_buffer_unrefFunction · 0.85
av_vkfmt_from_pixfmtFunction · 0.70
av_malloczFunction · 0.70
av_freeFunction · 0.70

Tested by

no test coverage detected