History

vulkan: flexibly allocate temporary imageviews

No reason to allocate 16 when 3 will do.

Lynne committed 2 years ago

Commit c4048011 parent 14451021 file · +4 −3Browse files

Unified · Split

libavutil/vulkan.c+4−3
@@ -1176,8 +1176,8 @@ const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt) · 1175 unmodified lines
1176}1176}
1177 1177
1178typedef struct ImageViewCtx {1178typedef struct ImageViewCtx {
1179 VkImageView views[AV_NUM_DATA_POINTERS];
1180 int nb_views;1179 int nb_views;
1180 VkImageView views[];
1181} ImageViewCtx;1181} ImageViewCtx;
1182 1182
1183static void destroy_imageviews(void *opaque, uint8_t *data)1183static void destroy_imageviews(void *opaque, uint8_t *data)
@@ -1206,7 +1206,8 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, · 22 unmodified lines
1206 const int nb_images = ff_vk_count_images(vkf);1206 const int nb_images = ff_vk_count_images(vkf);
1207 const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format);1207 const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format);
1208 1208
1209 ImageViewCtx *iv = av_mallocz(sizeof(*iv));1209 const size_t buf_size = sizeof(int) + nb_planes*sizeof(VkImageView);
1210 ImageViewCtx *iv = av_mallocz(buf_size);
1210 if (!iv)1211 if (!iv)
1211 return AVERROR(ENOMEM);1212 return AVERROR(ENOMEM);
1212 1213
@@ -1243,7 +1244,7 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, · 30 unmodified lines
1243 iv->nb_views++;1244 iv->nb_views++;
1244 }1245 }
1245 1246
1246 buf = av_buffer_create((uint8_t *)iv, sizeof(*iv), destroy_imageviews, s, 0);1247 buf = av_buffer_create((uint8_t *)iv, buf_size, destroy_imageviews, s, 0);
1247 if (!buf) {1248 if (!buf) {
1248 err = AVERROR(ENOMEM);1249 err = AVERROR(ENOMEM);
1249 goto fail;1250 goto fail;

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