FFmpeg
vulkan_filter.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) Lynne
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "vulkan_filter.h"
23 
25  AVBufferRef *frames_ref,
26  int width, int height, enum AVPixelFormat sw_format)
27 {
28  int err;
29  AVHWFramesContext *frames_ctx;
30  AVHWDeviceContext *device_ctx;
31  AVVulkanFramesContext *vk_frames;
32  AVVulkanDeviceContext *vk_dev;
33  AVBufferRef *device_ref = avctx->hw_device_ctx;
34 
35  /* Check if context is reusable as-is */
36  if (frames_ref) {
37  int no_storage = 0;
39  const VkFormat *sub = av_vkfmt_from_pixfmt(sw_format);
40 
41  frames_ctx = (AVHWFramesContext *)frames_ref->data;
42  device_ctx = (AVHWDeviceContext *)frames_ctx->device_ref->data;
43  vk_frames = frames_ctx->hwctx;
44  vk_dev = device_ctx->hwctx;
45 
46  /* Width and height mismatch */
47  if (width != frames_ctx->width ||
48  height != frames_ctx->height)
49  goto skip;
50 
51  /* Format mismatch */
52  if (sw_format != frames_ctx->sw_format)
53  goto skip;
54 
55  /* Unusual tiling mismatch. Don't let linear through either. */
56  if (vk_frames->tiling != VK_IMAGE_TILING_OPTIMAL)
57  goto skip;
58 
59  /* Usage mismatch */
60  if ((vk_frames->usage & (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT)) !=
61  (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT))
62  goto skip;
63 
66  err = ff_vk_load_functions(device_ctx, &s->vkfn, s->extensions, 1, 1);
67  if (err < 0)
68  return err;
69  vk = &s->vkfn;
70 
71  /* Check if the subformats can do storage */
72  for (int i = 0; sub[i] != VK_FORMAT_UNDEFINED; i++) {
73  VkFormatProperties2 prop = {
74  .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2,
75  };
76  vk->GetPhysicalDeviceFormatProperties2(vk_dev->phys_dev, sub[i],
77  &prop);
78 
79  if (vk_frames->tiling == VK_IMAGE_TILING_LINEAR) {
80  no_storage |= !(prop.formatProperties.linearTilingFeatures &
81  VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT);
82  } else {
83  no_storage |= !(prop.formatProperties.optimalTilingFeatures &
84  VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT);
85  }
86  }
87 
88  /* Check if it's usable */
89  if (no_storage) {
90 skip:
91  device_ref = frames_ctx->device_ref;
92  frames_ref = NULL;
93  } else {
94  frames_ref = av_buffer_ref(frames_ref);
95  if (!frames_ref)
96  return AVERROR(ENOMEM);
97  }
98  }
99 
100  if (!frames_ref) {
101  if (!device_ref) {
102  av_log(avctx, AV_LOG_ERROR,
103  "Vulkan filtering requires a device context!\n");
104  return AVERROR(EINVAL);
105  }
106 
107  frames_ref = av_hwframe_ctx_alloc(device_ref);
108 
109  frames_ctx = (AVHWFramesContext *)frames_ref->data;
110  frames_ctx->format = AV_PIX_FMT_VULKAN;
111  frames_ctx->sw_format = sw_format;
112  frames_ctx->width = width;
113  frames_ctx->height = height;
114 
115  vk_frames = frames_ctx->hwctx;
116  vk_frames->tiling = VK_IMAGE_TILING_OPTIMAL;
117  vk_frames->usage = VK_IMAGE_USAGE_SAMPLED_BIT |
118  VK_IMAGE_USAGE_STORAGE_BIT |
119  VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
120  VK_IMAGE_USAGE_TRANSFER_DST_BIT;
121 
122  err = av_hwframe_ctx_init(frames_ref);
123  if (err < 0) {
124  av_buffer_unref(&frames_ref);
125  return err;
126  }
127 
128  device_ctx = (AVHWDeviceContext *)frames_ctx->device_ref->data;
129  vk_dev = device_ctx->hwctx;
130  }
131 
132  s->extensions = ff_vk_extensions_to_mask(vk_dev->enabled_dev_extensions,
133  vk_dev->nb_enabled_dev_extensions);
134 
135  /**
136  * libplacebo does not use descriptor buffers.
137  */
138  if (!(s->extensions & FF_VK_EXT_DESCRIPTOR_BUFFER) &&
139  strcmp(avctx->filter->name, "libplacebo")) {
140  av_log(avctx, AV_LOG_ERROR, "Vulkan filtering requires that "
141  "the %s extension is supported!\n",
142  VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME);
143  av_buffer_unref(&frames_ref);
144  return AVERROR(EINVAL);
145  }
146 
147  err = ff_vk_load_functions(device_ctx, &s->vkfn, s->extensions, 1, 1);
148  if (err < 0) {
149  av_buffer_unref(&frames_ref);
150  return err;
151  }
152 
153  s->frames_ref = frames_ref;
154  s->frames = frames_ctx;
155  s->hwfc = vk_frames;
156  s->device = device_ctx;
157  s->hwctx = device_ctx->hwctx;
158 
159  err = ff_vk_load_props(s);
160  if (err < 0)
161  av_buffer_unref(&s->frames_ref);
162 
163  return err;
164 }
165 
167 {
168  AVHWFramesContext *input_frames;
169  AVFilterContext *avctx = inlink->dst;
170  FFVulkanContext *s = inlink->dst->priv;
171 
172  if (!inlink->hw_frames_ctx) {
173  av_log(inlink->dst, AV_LOG_ERROR, "Vulkan filtering requires a "
174  "hardware frames context on the input.\n");
175  return AVERROR(EINVAL);
176  }
177 
178  input_frames = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
179  if (input_frames->format != AV_PIX_FMT_VULKAN)
180  return AVERROR(EINVAL);
181 
182  /* Extract the device and default output format from the first input. */
183  if (avctx->inputs[0] != inlink)
184  return 0;
185 
186  /* Save the ref, without reffing it */
187  s->input_frames_ref = inlink->hw_frames_ctx;
188 
189  /* Defaults */
190  s->input_format = input_frames->sw_format;
191  s->output_format = input_frames->sw_format;
192  s->output_width = inlink->w;
193  s->output_height = inlink->h;
194 
195  return 0;
196 }
197 
199 {
200  int err;
201  FFVulkanContext *s = outlink->src->priv;
202 
203  av_buffer_unref(&outlink->hw_frames_ctx);
204 
205  err = ff_vk_filter_init_context(outlink->src, s, s->input_frames_ref,
206  s->output_width, s->output_height,
207  s->output_format);
208  if (err < 0)
209  return err;
210 
211  outlink->hw_frames_ctx = av_buffer_ref(s->frames_ref);
212  if (!outlink->hw_frames_ctx)
213  return AVERROR(ENOMEM);
214 
215  outlink->w = s->output_width;
216  outlink->h = s->output_height;
217 
218  return err;
219 }
220 
222 {
223  FFVulkanContext *s = avctx->priv;
224 
225  s->output_format = AV_PIX_FMT_NONE;
226 
227  return 0;
228 }
229 
231  FFVulkanPipeline *pl, AVFrame *out_f, AVFrame *in_f,
232  VkSampler sampler, void *push_src, size_t push_size)
233 {
234  int err = 0;
235  FFVulkanFunctions *vk = &vkctx->vkfn;
236  VkImageView in_views[AV_NUM_DATA_POINTERS];
237  VkImageView out_views[AV_NUM_DATA_POINTERS];
238  VkImageMemoryBarrier2 img_bar[37];
239  int nb_img_bar = 0;
240 
241  /* Update descriptors and init the exec context */
242  FFVkExecContext *exec = ff_vk_exec_get(e);
243  ff_vk_exec_start(vkctx, exec);
244 
245  ff_vk_exec_bind_pipeline(vkctx, exec, pl);
246 
247  if (push_src)
248  ff_vk_update_push_exec(vkctx, exec, pl, VK_SHADER_STAGE_COMPUTE_BIT,
249  0, push_size, push_src);
250 
251  if (in_f) {
252  RET(ff_vk_exec_add_dep_frame(vkctx, exec, in_f,
253  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
254  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
255  RET(ff_vk_create_imageviews(vkctx, exec, in_views, in_f));
256  ff_vk_update_descriptor_img_array(vkctx, pl, exec, in_f, in_views, 0, 0,
257  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
258  sampler);
259  ff_vk_frame_barrier(vkctx, exec, in_f, img_bar, &nb_img_bar,
260  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
261  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
262  VK_ACCESS_SHADER_READ_BIT,
263  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
264  VK_QUEUE_FAMILY_IGNORED);
265  }
266 
267  RET(ff_vk_exec_add_dep_frame(vkctx, exec, out_f,
268  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
269  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
270  RET(ff_vk_create_imageviews(vkctx, exec, out_views, out_f));
271  ff_vk_update_descriptor_img_array(vkctx, pl, exec, out_f, out_views, 0, !!in_f,
272  VK_IMAGE_LAYOUT_GENERAL,
273  VK_NULL_HANDLE);
274  ff_vk_frame_barrier(vkctx, exec, out_f, img_bar, &nb_img_bar,
275  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
276  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
277  VK_ACCESS_SHADER_WRITE_BIT,
278  VK_IMAGE_LAYOUT_GENERAL,
279  VK_QUEUE_FAMILY_IGNORED);
280 
281  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
282  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
283  .pImageMemoryBarriers = img_bar,
284  .imageMemoryBarrierCount = nb_img_bar,
285  });
286 
287  vk->CmdDispatch(exec->buf,
288  FFALIGN(vkctx->output_width, pl->wg_size[0])/pl->wg_size[0],
289  FFALIGN(vkctx->output_height, pl->wg_size[1])/pl->wg_size[1],
290  pl->wg_size[2]);
291 
292  return ff_vk_exec_submit(vkctx, exec);
293 fail:
294  ff_vk_exec_discard_deps(vkctx, exec);
295  return err;
296 }
297 
299  FFVulkanPipeline *pls[2],
300  AVFrame *out, AVFrame *tmp, AVFrame *in,
301  VkSampler sampler, void *push_src, size_t push_size)
302 {
303  int err = 0;
304  FFVulkanFunctions *vk = &vkctx->vkfn;
305  VkImageView in_views[AV_NUM_DATA_POINTERS];
306  VkImageView tmp_views[AV_NUM_DATA_POINTERS];
307  VkImageView out_views[AV_NUM_DATA_POINTERS];
308  VkImageMemoryBarrier2 img_bar[37];
309  int nb_img_bar = 0;
310 
311  /* Update descriptors and init the exec context */
312  FFVkExecContext *exec = ff_vk_exec_get(e);
313  ff_vk_exec_start(vkctx, exec);
314 
315  RET(ff_vk_exec_add_dep_frame(vkctx, exec, in,
316  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
317  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
318  RET(ff_vk_exec_add_dep_frame(vkctx, exec, tmp,
319  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
320  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
321  RET(ff_vk_exec_add_dep_frame(vkctx, exec, out,
322  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
323  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
324 
325  RET(ff_vk_create_imageviews(vkctx, exec, in_views, in));
326  RET(ff_vk_create_imageviews(vkctx, exec, tmp_views, tmp));
327  RET(ff_vk_create_imageviews(vkctx, exec, out_views, out));
328 
329  ff_vk_frame_barrier(vkctx, exec, in, img_bar, &nb_img_bar,
330  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
331  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
332  VK_ACCESS_SHADER_READ_BIT,
333  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
334  VK_QUEUE_FAMILY_IGNORED);
335  ff_vk_frame_barrier(vkctx, exec, tmp, img_bar, &nb_img_bar,
336  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
337  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
338  VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
339  VK_IMAGE_LAYOUT_GENERAL,
340  VK_QUEUE_FAMILY_IGNORED);
341  ff_vk_frame_barrier(vkctx, exec, out, img_bar, &nb_img_bar,
342  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
343  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
344  VK_ACCESS_SHADER_WRITE_BIT,
345  VK_IMAGE_LAYOUT_GENERAL,
346  VK_QUEUE_FAMILY_IGNORED);
347 
348  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
349  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
350  .pImageMemoryBarriers = img_bar,
351  .imageMemoryBarrierCount = nb_img_bar,
352  });
353 
354  for (int i = 0; i < 2; i++) {
355  FFVulkanPipeline *pl = pls[i];
356  AVFrame *src_f = !i ? in : tmp;
357  AVFrame *dst_f = !i ? tmp : out;
358  VkImageView *src_views = !i ? in_views : tmp_views;
359  VkImageView *dst_views = !i ? tmp_views : out_views;
360 
361  ff_vk_exec_bind_pipeline(vkctx, exec, pl);
362 
363  if (push_src)
364  ff_vk_update_push_exec(vkctx, exec, pl, VK_SHADER_STAGE_COMPUTE_BIT,
365  0, push_size, push_src);
366 
367  ff_vk_update_descriptor_img_array(vkctx, pl, exec, src_f, src_views, 0, 0,
368  !i ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL :
369  VK_IMAGE_LAYOUT_GENERAL,
370  sampler);
371  ff_vk_update_descriptor_img_array(vkctx, pl, exec, dst_f, dst_views, 0, 1,
372  VK_IMAGE_LAYOUT_GENERAL,
373  VK_NULL_HANDLE);
374 
375  vk->CmdDispatch(exec->buf,
376  FFALIGN(vkctx->output_width, pl->wg_size[0])/pl->wg_size[0],
377  FFALIGN(vkctx->output_height, pl->wg_size[1])/pl->wg_size[1],
378  pl->wg_size[2]);
379  }
380 
381  return ff_vk_exec_submit(vkctx, exec);
382 fail:
383  ff_vk_exec_discard_deps(vkctx, exec);
384  return err;
385 }
386 
388  FFVulkanPipeline *pl,
389  AVFrame *out, AVFrame *in[], int nb_in,
390  VkSampler sampler, void *push_src, size_t push_size)
391 {
392  int err = 0;
393  FFVulkanFunctions *vk = &vkctx->vkfn;
394  VkImageView in_views[16][AV_NUM_DATA_POINTERS];
395  VkImageView out_views[AV_NUM_DATA_POINTERS];
396  VkImageMemoryBarrier2 img_bar[128];
397  int nb_img_bar = 0;
398 
399  /* Update descriptors and init the exec context */
400  FFVkExecContext *exec = ff_vk_exec_get(e);
401  ff_vk_exec_start(vkctx, exec);
402 
403  /* Inputs */
404  for (int i = 0; i < nb_in; i++) {
405  RET(ff_vk_exec_add_dep_frame(vkctx, exec, in[i],
406  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
407  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
408  RET(ff_vk_create_imageviews(vkctx, exec, in_views[i], in[i]));
409 
410  ff_vk_frame_barrier(vkctx, exec, in[i], img_bar, &nb_img_bar,
411  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
412  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
413  VK_ACCESS_SHADER_READ_BIT,
414  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
415  VK_QUEUE_FAMILY_IGNORED);
416  }
417 
418  /* Output */
419  RET(ff_vk_exec_add_dep_frame(vkctx, exec, out,
420  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
421  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
422  RET(ff_vk_create_imageviews(vkctx, exec, out_views, out));
423  ff_vk_frame_barrier(vkctx, exec, out, img_bar, &nb_img_bar,
424  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
425  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
426  VK_ACCESS_SHADER_WRITE_BIT,
427  VK_IMAGE_LAYOUT_GENERAL,
428  VK_QUEUE_FAMILY_IGNORED);
429 
430  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
431  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
432  .pImageMemoryBarriers = img_bar,
433  .imageMemoryBarrierCount = nb_img_bar,
434  });
435 
436  ff_vk_exec_bind_pipeline(vkctx, exec, pl);
437 
438  if (push_src)
439  ff_vk_update_push_exec(vkctx, exec, pl, VK_SHADER_STAGE_COMPUTE_BIT,
440  0, push_size, push_src);
441 
442  for (int i = 0; i < nb_in; i++)
443  ff_vk_update_descriptor_img_array(vkctx, pl, exec, in[i], in_views[i], 0, i,
444  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
445  sampler);
446 
447  ff_vk_update_descriptor_img_array(vkctx, pl, exec, out, out_views, 0, nb_in,
448  VK_IMAGE_LAYOUT_GENERAL,
449  VK_NULL_HANDLE);
450 
451  vk->CmdDispatch(exec->buf,
452  FFALIGN(vkctx->output_width, pl->wg_size[0])/pl->wg_size[0],
453  FFALIGN(vkctx->output_height, pl->wg_size[1])/pl->wg_size[1],
454  pl->wg_size[2]);
455 
456  return ff_vk_exec_submit(vkctx, exec);
457 fail:
458  ff_vk_exec_discard_deps(vkctx, exec);
459  return err;
460 }
vulkan_loader.h
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:85
ff_vk_load_props
int ff_vk_load_props(FFVulkanContext *s)
Loads props/mprops/driver_props.
Definition: vulkan.c:85
AVVulkanDeviceContext::phys_dev
VkPhysicalDevice phys_dev
Physical device.
Definition: hwcontext_vulkan.h:65
ff_vk_exec_get
FFVkExecContext * ff_vk_exec_get(FFVkExecPool *pool)
Retrieve an execution pool.
Definition: vulkan.c:496
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
ff_vk_update_descriptor_img_array
void ff_vk_update_descriptor_img_array(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, AVFrame *f, VkImageView *views, int set, int binding, VkImageLayout layout, VkSampler sampler)
Definition: vulkan.c:1726
FFVulkanContext::output_height
int output_height
Definition: vulkan.h:265
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
out
FILE * out
Definition: movenc.c:54
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:197
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:322
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:375
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:221
av_hwframe_ctx_alloc
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:248
ff_vk_filter_process_Nin
int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pl, AVFrame *out, AVFrame *in[], int nb_in, VkSampler sampler, void *push_src, size_t push_size)
Up to 16 inputs, one output.
Definition: vulkan_filter.c:387
FF_VK_EXT_DESCRIPTOR_BUFFER
@ FF_VK_EXT_DESCRIPTOR_BUFFER
Definition: vulkan_functions.h:40
AVFilterContext::hw_device_ctx
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
Definition: avfilter.h:469
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:217
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
ff_vk_exec_add_dep_frame
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
Definition: vulkan.c:598
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:422
fail
#define fail()
Definition: checkasm.h:179
FFVulkanPipeline::wg_size
int wg_size[3]
Definition: vulkan.h:143
vulkan_filter.h
ff_vk_filter_init_context
int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s, AVBufferRef *frames_ref, int width, int height, enum AVPixelFormat sw_format)
Can be called manually, if not using ff_vk_filter_config_output.
Definition: vulkan_filter.c:24
AVVulkanFramesContext
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
Definition: hwcontext_vulkan.h:176
ff_vk_filter_process_2pass
int ff_vk_filter_process_2pass(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pls[2], AVFrame *out, AVFrame *tmp, AVFrame *in, VkSampler sampler, void *push_src, size_t push_size)
Submit a compute shader with a single in and single out with 2 stages.
Definition: vulkan_filter.c:298
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AVHWFramesContext::height
int height
Definition: hwcontext.h:217
FFVulkanContext::output_width
int output_width
Definition: vulkan.h:264
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_vk_load_functions
static int ff_vk_load_functions(AVHWDeviceContext *ctx, FFVulkanFunctions *vk, uint64_t extensions_mask, int has_inst, int has_dev)
Function loader.
Definition: vulkan_loader.h:91
ff_vk_exec_bind_pipeline
void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl)
Definition: vulkan.c:1821
if
if(ret)
Definition: filter_design.txt:179
AVVulkanDeviceContext
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_vulkan.h:44
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:210
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AVVulkanDeviceContext::nb_enabled_dev_extensions
int nb_enabled_dev_extensions
Definition: hwcontext_vulkan.h:99
AVHWFramesContext::device_ref
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition: hwcontext.h:126
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:415
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:198
AVVulkanFramesContext::usage
VkImageUsageFlagBits usage
Defines extra usage of output frames.
Definition: hwcontext_vulkan.h:195
FFVulkanContext
Definition: vulkan.h:228
FFVulkanPipeline
Definition: vulkan.h:131
AV_NUM_DATA_POINTERS
#define AV_NUM_DATA_POINTERS
Definition: frame.h:376
height
#define height
FFVkExecContext
Definition: vulkan.h:152
ff_vk_update_push_exec
void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Definition: vulkan.c:1739
ff_vk_filter_process_simple
int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pl, AVFrame *out_f, AVFrame *in_f, VkSampler sampler, void *push_src, size_t push_size)
Submit a compute shader with a zero/one input and single out for execution.
Definition: vulkan_filter.c:230
av_vkfmt_from_pixfmt
const VkFormat * av_vkfmt_from_pixfmt(enum AVPixelFormat p)
Returns the optimal per-plane Vulkan format for a given sw_format, one for each plane.
Definition: hwcontext_stub.c:30
ff_vk_exec_start
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition: vulkan.c:512
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
VkFormat
enum VkFormat VkFormat
Definition: hwcontext_stub.c:25
ff_vk_frame_barrier
void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags src_stage, VkPipelineStageFlags dst_stage, VkAccessFlagBits new_access, VkImageLayout new_layout, uint32_t new_qf)
Definition: vulkan.c:1303
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:115
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:231
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:150
FFVkExecPool
Definition: vulkan.h:210
FFVkExecContext::buf
VkCommandBuffer buf
Definition: vulkan.h:164
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AVVulkanFramesContext::tiling
VkImageTiling tiling
Controls the tiling of allocated frames.
Definition: hwcontext_vulkan.h:185
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
AVVulkanDeviceContext::enabled_dev_extensions
const char *const * enabled_dev_extensions
Enabled device extensions.
Definition: hwcontext_vulkan.h:98
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:166
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
ff_vk_exec_discard_deps
void ff_vk_exec_discard_deps(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:548
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
ff_vk_exec_submit
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:723
ff_vk_extensions_to_mask
static uint64_t ff_vk_extensions_to_mask(const char *const *extensions, int nb_extensions)
Definition: vulkan_loader.h:36
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_vk_create_imageviews
int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, VkImageView views[AV_NUM_DATA_POINTERS], AVFrame *f)
Create an imageview and add it as a dependency to an execution.
Definition: vulkan.c:1230
AVFilterContext::filter
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:410
RET
#define RET(x)
Definition: vulkan.h:67
FFVulkanFunctions
Definition: vulkan_functions.h:226
skip
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
Definition: bitstream_template.h:375