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
11761176 }
11771177
11781178 typedef struct ImageViewCtx {
1179− VkImageView views[AV_NUM_DATA_POINTERS];
11801179 int nb_views;
1180+ VkImageView views[];
11811181 } ImageViewCtx;
11821182
11831183 static void destroy_imageviews(void *opaque, uint8_t *data)
@@ -1206,7 +1206,8 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, · 22 unmodified lines
12061206 const int nb_images = ff_vk_count_images(vkf);
12071207 const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format);
12081208
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);
12101211 if (!iv)
12111212 return AVERROR(ENOMEM);
12121213
@@ -1243,7 +1244,7 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, · 30 unmodified lines
12431244 iv->nb_views++;
12441245 }
12451246
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);
12471248 if (!buf) {
12481249 err = AVERROR(ENOMEM);
12491250 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