FFmpeg
vulkan.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVUTIL_VULKAN_H
20 #define AVUTIL_VULKAN_H
21 
22 #define VK_NO_PROTOTYPES
23 
24 #include <stdatomic.h>
25 
26 #include "thread.h"
27 #include "pixdesc.h"
28 #include "bprint.h"
29 #include "hwcontext.h"
30 #include "vulkan_functions.h"
31 #include "hwcontext_vulkan.h"
32 #include "vulkan_loader.h"
33 
34 /* GLSL management macros */
35 #define INDENT(N) INDENT_##N
36 #define INDENT_0
37 #define INDENT_1 INDENT_0 " "
38 #define INDENT_2 INDENT_1 INDENT_1
39 #define INDENT_3 INDENT_2 INDENT_1
40 #define INDENT_4 INDENT_3 INDENT_1
41 #define INDENT_5 INDENT_4 INDENT_1
42 #define INDENT_6 INDENT_5 INDENT_1
43 #define C(N, S) INDENT(N) #S "\n"
44 
45 #define GLSLC(N, S) \
46  do { \
47  av_bprintf(&shd->src, C(N, S)); \
48  } while (0)
49 
50 #define GLSLA(...) \
51  do { \
52  av_bprintf(&shd->src, __VA_ARGS__); \
53  } while (0)
54 
55 #define GLSLF(N, S, ...) \
56  do { \
57  av_bprintf(&shd->src, C(N, S), __VA_ARGS__); \
58  } while (0)
59 
60 #define GLSLD(D) \
61  do { \
62  av_bprintf(&shd->src, "\n"); \
63  av_bprint_append_data(&shd->src, D, strlen(D)); \
64  av_bprintf(&shd->src, "\n"); \
65  } while (0)
66 
67 /* Helper, pretty much every Vulkan return value needs to be checked */
68 #define RET(x) \
69  do { \
70  if ((err = (x)) < 0) \
71  goto fail; \
72  } while (0)
73 
74 #define DUP_SAMPLER(x) { x, x, x, x }
75 
76 typedef struct FFVkSPIRVShader {
77  const char *name; /* Name for id/debugging purposes */
78  AVBPrint src;
79  int local_size[3]; /* Compute shader workgroup sizes */
80  VkPipelineShaderStageCreateInfo shader;
81  VkPipelineShaderStageRequiredSubgroupSizeCreateInfo subgroup_info;
83 
85  const char *name;
86  VkDescriptorType type;
87  const char *mem_layout; /* Storage images (rgba8, etc.) and buffers (std430, etc.) */
88  const char *mem_quali; /* readonly, writeonly, etc. */
89  const char *buf_content; /* For buffers */
90  uint32_t dimensions; /* Needed for e.g. sampler%iD */
91  uint32_t elems; /* 0 - scalar, 1 or more - vector */
92  VkShaderStageFlags stages;
93  VkSampler samplers[4]; /* Sampler to use for all elems */
95 
96 typedef struct FFVkBuffer {
97  VkBuffer buf;
98  VkDeviceMemory mem;
99  VkMemoryPropertyFlagBits flags;
100  size_t size;
101  VkDeviceAddress address;
102 
103  /* Local use only */
104  VkPipelineStageFlags2 stage;
105  VkAccessFlags2 access;
106 
107  /* Only valid when allocated via ff_vk_get_pooled_buffer with HOST_VISIBLE */
108  uint8_t *mapped_mem;
109 } FFVkBuffer;
110 
111 typedef struct FFVkQueueFamilyCtx {
115 
116 typedef struct FFVulkanDescriptorSet {
117  VkDescriptorSetLayout layout;
119  uint8_t *desc_mem;
120  VkDeviceSize layout_size;
121  VkDeviceSize aligned_size; /* descriptorBufferOffsetAlignment */
122  VkDeviceSize total_size; /* Once registered to an exec context */
123  VkBufferUsageFlags usage;
124 
125  VkDescriptorSetLayoutBinding *binding;
126  VkDeviceSize *binding_offset;
128 
131 
132 typedef struct FFVulkanPipeline {
133  VkPipelineBindPoint bind_point;
134 
135  /* Contexts */
136  VkPipelineLayout pipeline_layout;
137  VkPipeline pipeline;
138 
139  /* Push consts */
140  VkPushConstantRange *push_consts;
142 
143  /* Workgroup */
144  int wg_size[3];
145 
146  /* Descriptors */
148  VkDescriptorBufferBindingInfoEXT *desc_bind;
152 
153 typedef struct FFVkExecContext {
154  uint32_t idx;
155  const struct FFVkExecPool *parent;
158 
159  /* Queue for the execution context */
160  VkQueue queue;
161  int qf;
162  int qi;
163 
164  /* Command buffer for the context */
165  VkCommandBuffer buf;
166 
167  /* Fence for the command buffer */
168  VkFence fence;
169 
170  void *query_data;
172 
173  /* Buffer dependencies */
176  unsigned int buf_deps_alloc_size;
177 
178  /* Frame dependencies */
180  unsigned int frame_deps_alloc_size;
182 
183  VkSemaphoreSubmitInfo *sem_wait;
184  unsigned int sem_wait_alloc;
186 
187  VkSemaphoreSubmitInfo *sem_sig;
188  unsigned int sem_sig_alloc;
190 
191  uint64_t **sem_sig_val_dst;
192  unsigned int sem_sig_val_dst_alloc;
194 
195  uint8_t *frame_locked;
197 
198  VkAccessFlagBits *access_dst;
199  unsigned int access_dst_alloc;
200 
201  VkImageLayout *layout_dst;
202  unsigned int layout_dst_alloc;
203 
204  uint32_t *queue_family_dst;
206 
207  uint8_t *frame_update;
210 
211 typedef struct FFVkExecPool {
214 
215  VkCommandPool cmd_buf_pool;
216  VkCommandBuffer *cmd_bufs;
218 
219  VkQueryPool query_pool;
220  void *query_data;
226  size_t qd_size;
227 } FFVkExecPool;
228 
229 typedef struct FFVulkanContext {
230  const AVClass *class; /* Filters and encoders use this */
231 
234  VkPhysicalDeviceProperties2 props;
235  VkPhysicalDeviceDriverProperties driver_props;
236  VkPhysicalDeviceMemoryProperties mprops;
237  VkPhysicalDeviceExternalMemoryHostPropertiesEXT hprops;
238  VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props;
239  VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props;
240  VkPhysicalDeviceCooperativeMatrixPropertiesKHR coop_matrix_props;
241  VkQueueFamilyQueryResultStatusPropertiesKHR *query_props;
242  VkQueueFamilyVideoPropertiesKHR *video_props;
243  VkQueueFamilyProperties2 *qf_props;
245 
246  VkCooperativeMatrixPropertiesKHR *coop_mat_props;
248 
249  VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_feats;
250  VkPhysicalDeviceVulkan12Features feats_12;
251  VkPhysicalDeviceFeatures2 feats;
252 
255 
260 
261  uint32_t qfs[5];
262  int nb_qfs;
263 
264  /* Properties */
270 
271 static inline int ff_vk_count_images(AVVkFrame *f)
272 {
273  int cnt = 0;
274  while (f->img[cnt])
275  cnt++;
276 
277  return cnt;
278 }
279 
280 static inline const void *ff_vk_find_struct(const void *chain, VkStructureType stype)
281 {
282  const VkBaseInStructure *in = chain;
283  while (in) {
284  if (in->sType == stype)
285  return in;
286 
287  in = in->pNext;
288  }
289 
290  return NULL;
291 }
292 
293 /* Identity mapping - r = r, b = b, g = g, a = a */
294 extern const VkComponentMapping ff_comp_identity_map;
295 
296 /**
297  * Converts Vulkan return values to strings
298  */
299 const char *ff_vk_ret2str(VkResult res);
300 
301 /**
302  * Returns 1 if pixfmt is a usable RGB format.
303  */
305 
306 /**
307  * Returns the format to use for images in shaders.
308  */
309 const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt);
310 
311 /**
312  * Loads props/mprops/driver_props
313  */
315 
316 /**
317  * Chooses a QF and loads it into a context.
318  */
320  VkQueueFlagBits dev_family);
321 
322 /**
323  * Allocates/frees an execution pool.
324  * ff_vk_exec_pool_init_desc() MUST be called if ff_vk_exec_descriptor_set_add()
325  * has been called.
326  */
328  FFVkExecPool *pool, int nb_contexts,
329  int nb_queries, VkQueryType query_type, int query_64bit,
330  const void *query_create_pnext);
332 
333 /**
334  * Retrieve an execution pool. Threadsafe.
335  */
337 
338 /**
339  * Performs nb_queries queries and returns their results and statuses.
340  * Execution must have been waited on to produce valid results.
341  */
343  void **data, int64_t *status);
344 
345 /**
346  * Start/submit/wait an execution.
347  * ff_vk_exec_start() always waits on a submission, so using ff_vk_exec_wait()
348  * is not necessary (unless using it is just better).
349  */
353 
354 /**
355  * Execution dependency management.
356  * Can attach buffers to executions that will only be unref'd once the
357  * buffer has finished executing.
358  * Adding a frame dep will *lock the frame*, until either the dependencies
359  * are discarded, the execution is submitted, or a failure happens.
360  * update_frame will update the frame's properties before it is unlocked,
361  * only if submission was successful.
362  */
364  AVBufferRef **deps, int nb_deps, int ref);
366  VkPipelineStageFlagBits2 wait_stage,
367  VkPipelineStageFlagBits2 signal_stage);
369  VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar);
371  VkSemaphore *dst, uint64_t *dst_val,
372  AVFrame *f);
374 
375 /**
376  * Create an imageview and add it as a dependency to an execution.
377  */
379  VkImageView views[AV_NUM_DATA_POINTERS],
380  AVFrame *f);
381 
383  AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar,
384  VkPipelineStageFlags src_stage,
385  VkPipelineStageFlags dst_stage,
386  VkAccessFlagBits new_access,
387  VkImageLayout new_layout,
388  uint32_t new_qf);
389 
390 /**
391  * Memory/buffer/image allocation helpers.
392  */
393 int ff_vk_alloc_mem(FFVulkanContext *s, VkMemoryRequirements *req,
394  VkMemoryPropertyFlagBits req_flags, void *alloc_extension,
395  VkMemoryPropertyFlagBits *mem_flags, VkDeviceMemory *mem);
397  void *pNext, void *alloc_pNext,
398  VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags);
400  void *pNext, void *alloc_pNext,
401  VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags);
402 
403 /**
404  * Buffer management code.
405  */
406 int ff_vk_map_buffers(FFVulkanContext *s, FFVkBuffer **buf, uint8_t *mem[],
407  int nb_buffers, int invalidate);
408 int ff_vk_unmap_buffers(FFVulkanContext *s, FFVkBuffer **buf, int nb_buffers,
409  int flush);
410 
411 static inline int ff_vk_map_buffer(FFVulkanContext *s, FFVkBuffer *buf, uint8_t **mem,
412  int invalidate)
413 {
414  return ff_vk_map_buffers(s, (FFVkBuffer *[]){ buf }, mem,
415  1, invalidate);
416 }
417 
418 static inline int ff_vk_unmap_buffer(FFVulkanContext *s, FFVkBuffer *buf, int flush)
419 {
420  return ff_vk_unmap_buffers(s, (FFVkBuffer *[]){ buf }, 1, flush);
421 }
422 
424 
425 /** Initialize a pool and create AVBufferRefs containing FFVkBuffer.
426  * Threadsafe to use. Buffers are automatically mapped on creation if
427  * VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT is set in mem_props. Users should
428  * synchronize access themselvesd. Mainly meant for device-local buffers. */
430  AVBufferRef **buf, VkBufferUsageFlags usage,
431  void *create_pNext, size_t size,
432  VkMemoryPropertyFlagBits mem_props);
433 
434 /**
435  * Create a sampler.
436  */
437 int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler,
438  int unnorm_coords, VkFilter filt);
439 
440 /**
441  * Shader management.
442  */
443 int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name,
444  VkShaderStageFlags stage, uint32_t required_subgroup_size);
445 void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z);
446 void ff_vk_shader_print(void *ctx, FFVkSPIRVShader *shd, int prio);
448  uint8_t *spirv, size_t spirv_size, const char *entrypoint);
450 
451 /**
452  * Add/update push constants for execution.
453  */
455  VkShaderStageFlagBits stage);
457  FFVulkanPipeline *pl,
458  VkShaderStageFlagBits stage,
459  int offset, size_t size, void *src);
460 
461 /**
462  * Add descriptor to a pipeline. Must be called before pipeline init.
463  */
465  FFVkSPIRVShader *shd,
467  int read_only, int print_to_shader_only);
468 
469 /* Initialize/free a pipeline. */
471  FFVkSPIRVShader *shd);
473 
474 /**
475  * Register a pipeline with an exec pool.
476  * Pool may be NULL if all descriptor sets are read-only.
477  */
479  FFVulkanPipeline *pl);
480 
481 /* Bind pipeline */
483  FFVulkanPipeline *pl);
484 
485 /* Update sampler/image/buffer descriptors. e may be NULL for read-only descriptors. */
487  FFVkExecContext *e, int set, int bind, int offs,
488  VkSampler *sampler);
490  FFVkExecContext *e, int set, int bind, int offs,
491  VkImageView view, VkImageLayout layout, VkSampler sampler);
493  FFVkExecContext *e, int set, int bind, int offs,
494  VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt);
495 
498  VkImageView *views, int set, int binding,
499  VkImageLayout layout, VkSampler sampler);
500 
501 /**
502  * Frees main context.
503  */
505 
506 #endif /* AVUTIL_VULKAN_H */
vulkan_loader.h
FFVulkanPipeline::bind_point
VkPipelineBindPoint bind_point
Definition: vulkan.h:133
pthread_mutex_t
_fmutex pthread_mutex_t
Definition: os2threads.h:53
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
FFVulkanContext::hwfc
AVVulkanFramesContext * hwfc
Definition: vulkan.h:259
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:1897
FFVulkanContext::output_height
int output_height
Definition: vulkan.h:266
FFVkExecContext::frame_deps_alloc_size
unsigned int frame_deps_alloc_size
Definition: vulkan.h:180
ff_vk_load_props
int ff_vk_load_props(FFVulkanContext *s)
Loads props/mprops/driver_props.
Definition: vulkan.c:86
FFVkExecPool::idx
atomic_int_least64_t idx
Definition: vulkan.h:213
AVBufferPool
The buffer pool.
Definition: buffer_internal.h:88
FFVulkanPipeline::pipeline_layout
VkPipelineLayout pipeline_layout
Definition: vulkan.h:136
FFVkExecPool::contexts
FFVkExecContext * contexts
Definition: vulkan.h:212
thread.h
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:1751
FFVkExecContext::qf
int qf
Definition: vulkan.h:161
FFVkBuffer::access
VkAccessFlags2 access
Definition: vulkan.h:105
FFVulkanDescriptorSet::aligned_size
VkDeviceSize aligned_size
Definition: vulkan.h:121
ff_vk_add_push_constant
int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
Definition: vulkan.c:1143
FFVkBuffer::stage
VkPipelineStageFlags2 stage
Definition: vulkan.h:104
ff_vk_create_avbuf
int ff_vk_create_avbuf(FFVulkanContext *s, AVBufferRef **ref, size_t size, void *pNext, void *alloc_pNext, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
Definition: vulkan.c:943
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
pixdesc.h
FFVulkanDescriptorSetBinding::stages
VkShaderStageFlags stages
Definition: vulkan.h:92
ff_vk_pipeline_descriptor_set_add
int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int read_only, int print_to_shader_only)
Add descriptor to a pipeline.
Definition: vulkan.c:1463
FFVkExecContext::sem_sig_alloc
unsigned int sem_sig_alloc
Definition: vulkan.h:188
data
const char data[16]
Definition: mxf.c:148
ff_vk_exec_submit
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:724
ff_vk_exec_update_frame
void ff_vk_exec_update_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar)
Definition: vulkan.c:679
FFVkBuffer::address
VkDeviceAddress address
Definition: vulkan.h:101
FFVkExecContext::sem_wait
VkSemaphoreSubmitInfo * sem_wait
Definition: vulkan.h:183
FFVulkanDescriptorSetBinding::buf_content
const char * buf_content
Definition: vulkan.h:89
FFVkExecPool::query_pool
VkQueryPool query_pool
Definition: vulkan.h:219
FFVulkanDescriptorSet::desc_mem
uint8_t * desc_mem
Definition: vulkan.h:119
FFVulkanContext::tot_nb_qfs
int tot_nb_qfs
Definition: vulkan.h:244
FFVkBuffer::buf
VkBuffer buf
Definition: vulkan.h:97
ff_vk_set_descriptor_sampler
int ff_vk_set_descriptor_sampler(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkSampler *sampler)
Definition: vulkan.c:1634
FFVkExecContext::lock
pthread_mutex_t lock
Definition: vulkan.h:156
ff_vk_exec_mirror_sem_value
int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, VkSemaphore *dst, uint64_t *dst_val, AVFrame *f)
Definition: vulkan.c:698
FFVkExecContext::frame_update_alloc_size
unsigned int frame_update_alloc_size
Definition: vulkan.h:208
FFVulkanDescriptorSet::nb_bindings
int nb_bindings
Definition: vulkan.h:127
FFVulkanContext::feats
VkPhysicalDeviceFeatures2 feats
Definition: vulkan.h:251
ff_vk_find_struct
static const void * ff_vk_find_struct(const void *chain, VkStructureType stype)
Definition: vulkan.h:280
FFVulkanPipeline::wg_size
int wg_size[3]
Definition: vulkan.h:144
FFVulkanDescriptorSet::layout_size
VkDeviceSize layout_size
Definition: vulkan.h:120
FFVulkanDescriptorSet::read_only
int read_only
Definition: vulkan.h:129
AVVulkanFramesContext
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
Definition: hwcontext_vulkan.h:176
FFVulkanPipeline::pipeline
VkPipeline pipeline
Definition: vulkan.h:137
ff_vk_pipeline_free
void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl)
Definition: vulkan.c:1868
ff_vk_shader_create
int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, uint8_t *spirv, size_t spirv_size, const char *entrypoint)
Definition: vulkan.c:1413
FFVkExecPool::query_64bit
int query_64bit
Definition: vulkan.h:223
FFVulkanContext::subgroup_props
VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props
Definition: vulkan.h:239
FFVulkanDescriptorSet::layout
VkDescriptorSetLayout layout
Definition: vulkan.h:117
ff_vk_exec_pool_init
int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, FFVkExecPool *pool, int nb_contexts, int nb_queries, VkQueryType query_type, int query_64bit, const void *query_create_pnext)
Allocates/frees an execution pool.
Definition: vulkan.c:296
FFVulkanContext::frames_ref
AVBufferRef * frames_ref
Definition: vulkan.h:257
FFVulkanContext::atomic_float_feats
VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_feats
Definition: vulkan.h:249
FFVkExecPool::query_statuses
int query_statuses
Definition: vulkan.h:222
ff_vk_unmap_buffers
int ff_vk_unmap_buffers(FFVulkanContext *s, FFVkBuffer **buf, int nb_buffers, int flush)
Definition: vulkan.c:1017
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
FFVulkanDescriptorSet::binding
VkDescriptorSetLayoutBinding * binding
Definition: vulkan.h:125
ff_vk_shader_rep_fmt
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Returns the format to use for images in shaders.
Definition: vulkan.c:1207
FFVulkanDescriptorSetBinding::type
VkDescriptorType type
Definition: vulkan.h:86
FFVulkanPipeline::nb_descriptor_sets
int nb_descriptor_sets
Definition: vulkan.h:150
ff_vk_shader_init
int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, VkShaderStageFlags stage, uint32_t required_subgroup_size)
Shader management.
Definition: vulkan.c:1345
ff_vk_qf_init
int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family)
Chooses a QF and loads it into a context.
Definition: vulkan.c:225
FFVulkanDescriptorSetBinding::samplers
VkSampler samplers[4]
Definition: vulkan.h:93
FFVkExecContext::frame_deps
AVFrame ** frame_deps
Definition: vulkan.h:179
set
static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v)
Definition: swresample.c:59
ff_vk_exec_get_query
VkResult ff_vk_exec_get_query(FFVulkanContext *s, FFVkExecContext *e, void **data, int64_t *status)
Performs nb_queries queries and returns their results and statuses.
Definition: vulkan.c:447
FFVkExecContext::queue_family_dst
uint32_t * queue_family_dst
Definition: vulkan.h:204
FFVulkanDescriptorSetBinding::elems
uint32_t elems
Definition: vulkan.h:91
FFVulkanContext::output_width
int output_width
Definition: vulkan.h:265
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:1231
s
#define s(width, name)
Definition: cbs_vp9.c:198
FFVulkanContext::driver_props
VkPhysicalDeviceDriverProperties driver_props
Definition: vulkan.h:235
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
FFVkExecContext::fence
VkFence fence
Definition: vulkan.h:168
FFVulkanDescriptorSet::buf
FFVkBuffer buf
Definition: vulkan.h:118
FFVkExecContext::nb_buf_deps
int nb_buf_deps
Definition: vulkan.h:175
ff_vk_get_pooled_buffer
int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVBufferPool **buf_pool, AVBufferRef **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
Initialize a pool and create AVBufferRefs containing FFVkBuffer.
Definition: vulkan.c:1091
ctx
AVFormatContext * ctx
Definition: movenc.c:48
ff_vk_unmap_buffer
static int ff_vk_unmap_buffer(FFVulkanContext *s, FFVkBuffer *buf, int flush)
Definition: vulkan.h:418
ff_vk_shader_set_compute_sizes
void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z)
Definition: vulkan.c:1371
FFVulkanDescriptorSetBinding::mem_layout
const char * mem_layout
Definition: vulkan.h:87
FFVkExecContext::frame_update
uint8_t * frame_update
Definition: vulkan.h:207
FFVkExecContext::query_idx
int query_idx
Definition: vulkan.h:171
FFVkExecPool::query_status_stride
int query_status_stride
Definition: vulkan.h:224
FFVkExecContext::parent
const struct FFVkExecPool * parent
Definition: vulkan.h:155
ff_vk_exec_get
FFVkExecContext * ff_vk_exec_get(FFVkExecPool *pool)
Retrieve an execution pool.
Definition: vulkan.c:497
AVVulkanDeviceContext
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_vulkan.h:44
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
FFVkExecContext::sem_sig_val_dst_alloc
unsigned int sem_sig_val_dst_alloc
Definition: vulkan.h:192
NULL
#define NULL
Definition: coverity.c:32
ff_vk_init_compute_pipeline
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
Definition: vulkan.c:1809
ff_vk_exec_pool_free
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Definition: vulkan.c:256
FFVkExecContext::access_dst_alloc
unsigned int access_dst_alloc
Definition: vulkan.h:199
FFVkExecContext::sem_sig_cnt
int sem_sig_cnt
Definition: vulkan.h:189
FFVulkanDescriptorSetBinding::dimensions
uint32_t dimensions
Definition: vulkan.h:90
FFVulkanContext::coop_matrix_props
VkPhysicalDeviceCooperativeMatrixPropertiesKHR coop_matrix_props
Definition: vulkan.h:240
FFVulkanContext::qf_props
VkQueueFamilyProperties2 * qf_props
Definition: vulkan.h:243
hwcontext_vulkan.h
FFVkExecContext::qi
int qi
Definition: vulkan.h:162
FFVkExecContext::had_submission
int had_submission
Definition: vulkan.h:157
FFVkBuffer::size
size_t size
Definition: vulkan.h:100
FFVkExecPool::nb_queries
int nb_queries
Definition: vulkan.h:225
FFVkBuffer::mapped_mem
uint8_t * mapped_mem
Definition: vulkan.h:108
FFVulkanContext
Definition: vulkan.h:229
ff_vk_count_images
static int ff_vk_count_images(AVVkFrame *f)
Definition: vulkan.h:271
FFVulkanPipeline
Definition: vulkan.h:132
FFVkExecContext::query_data
void * query_data
Definition: vulkan.h:170
ff_vk_exec_add_dep_buf
int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps, int ref)
Execution dependency management.
Definition: vulkan.c:575
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
Definition: vulkan.c:1404
FFVulkanContext::device
AVHWDeviceContext * device
Definition: vulkan.h:253
usage
const char * usage
Definition: floatimg_cmp.c:60
ff_vk_exec_start
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition: vulkan.c:513
f
f
Definition: af_crystalizer.c:121
FFVkExecContext::layout_dst
VkImageLayout * layout_dst
Definition: vulkan.h:201
FFVkExecContext::queue_family_dst_alloc
unsigned int queue_family_dst_alloc
Definition: vulkan.h:205
FFVulkanDescriptorSetBinding
Definition: vulkan.h:84
ff_vk_map_buffers
int ff_vk_map_buffers(FFVulkanContext *s, FFVkBuffer **buf, uint8_t *mem[], int nb_buffers, int invalidate)
Buffer management code.
Definition: vulkan.c:970
AVVkFrame
Definition: hwcontext_vulkan.h:265
ff_vk_alloc_mem
int ff_vk_alloc_mem(FFVulkanContext *s, VkMemoryRequirements *req, VkMemoryPropertyFlagBits req_flags, void *alloc_extension, VkMemoryPropertyFlagBits *mem_flags, VkDeviceMemory *mem)
Memory/buffer/image allocation helpers.
Definition: vulkan.c:790
size
int size
Definition: twinvq_data.h:10344
AV_NUM_DATA_POINTERS
#define AV_NUM_DATA_POINTERS
Definition: frame.h:341
FFVkExecContext::nb_frame_deps
int nb_frame_deps
Definition: vulkan.h:181
FFVkQueueFamilyCtx
Definition: vulkan.h:111
ff_vk_free_buf
void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf)
Definition: vulkan.c:1055
FFVkExecContext::sem_sig_val_dst_cnt
int sem_sig_val_dst_cnt
Definition: vulkan.h:193
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:599
FFVulkanContext::output_format
enum AVPixelFormat output_format
Definition: vulkan.h:267
FFVkBuffer::flags
VkMemoryPropertyFlagBits flags
Definition: vulkan.h:99
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
FFVkExecContext
Definition: vulkan.h:153
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:85
ff_comp_identity_map
const VkComponentMapping ff_comp_identity_map
Definition: vulkan.c:26
FFVulkanContext::input_frames_ref
AVBufferRef * input_frames_ref
Definition: vulkan.h:256
FFVkExecContext::sem_wait_cnt
int sem_wait_cnt
Definition: vulkan.h:185
layout
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 layout
Definition: filter_design.txt:18
FFVkExecContext::queue
VkQueue queue
Definition: vulkan.h:160
bprint.h
ff_vk_ret2str
const char * ff_vk_ret2str(VkResult res)
Converts Vulkan return values to strings.
Definition: vulkan.c:34
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:1764
FFVulkanPipeline::push_consts
VkPushConstantRange * push_consts
Definition: vulkan.h:140
ff_vk_set_descriptor_image
int ff_vk_set_descriptor_image(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkImageView view, VkImageLayout layout, VkSampler sampler)
Definition: vulkan.c:1661
FFVkSPIRVShader::shader
VkPipelineShaderStageCreateInfo shader
Definition: vulkan.h:80
VkFormat
enum VkFormat VkFormat
Definition: hwcontext_stub.c:25
FFVkExecContext::layout_dst_alloc
unsigned int layout_dst_alloc
Definition: vulkan.h:202
FFVkBuffer::mem
VkDeviceMemory mem
Definition: vulkan.h:98
FFVulkanContext::hprops
VkPhysicalDeviceExternalMemoryHostPropertiesEXT hprops
Definition: vulkan.h:237
FFVkSPIRVShader::src
AVBPrint src
Definition: vulkan.h:78
FFVulkanContext::props
VkPhysicalDeviceProperties2 props
Definition: vulkan.h:234
FFVkExecContext::frame_locked_alloc_size
unsigned int frame_locked_alloc_size
Definition: vulkan.h:196
len
int len
Definition: vorbis_enc_data.h:426
filt
static const int8_t filt[NUMTAPS *2]
Definition: af_earwax.c:39
FFVulkanContext::extensions
FFVulkanExtensions extensions
Definition: vulkan.h:233
FFVulkanContext::nb_qfs
int nb_qfs
Definition: vulkan.h:262
FFVulkanContext::mprops
VkPhysicalDeviceMemoryProperties mprops
Definition: vulkan.h:236
FFVulkanDescriptorSet::binding_offset
VkDeviceSize * binding_offset
Definition: vulkan.h:126
FFVkExecContext::sem_wait_alloc
unsigned int sem_wait_alloc
Definition: vulkan.h:184
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
atomic_int_least64_t
intptr_t atomic_int_least64_t
Definition: stdatomic.h:68
FFVulkanContext::desc_buf_props
VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props
Definition: vulkan.h:238
FFVulkanPipeline::push_consts_num
int push_consts_num
Definition: vulkan.h:141
pixfmt
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:365
ff_vk_map_buffer
static int ff_vk_map_buffer(FFVulkanContext *s, FFVkBuffer *buf, uint8_t **mem, int invalidate)
Definition: vulkan.h:411
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:232
FFVkExecPool
Definition: vulkan.h:211
FFVkExecContext::frame_locked
uint8_t * frame_locked
Definition: vulkan.h:195
ff_vk_exec_wait
void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:504
FFVkExecPool::query_data
void * query_data
Definition: vulkan.h:220
FFVkExecContext::sem_sig
VkSemaphoreSubmitInfo * sem_sig
Definition: vulkan.h:187
ff_vk_mt_is_np_rgb
int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
Returns 1 if pixfmt is a usable RGB format.
Definition: vulkan.c:1195
FFVkExecContext::buf
VkCommandBuffer buf
Definition: vulkan.h:165
FFVulkanContext::input_format
enum AVPixelFormat input_format
Definition: vulkan.h:268
FFVkQueueFamilyCtx::nb_queues
int nb_queues
Definition: vulkan.h:113
status
ov_status_e status
Definition: dnn_backend_openvino.c:119
FFVulkanContext::coop_mat_props_nb
uint32_t coop_mat_props_nb
Definition: vulkan.h:247
FFVkSPIRVShader
Definition: vulkan.h:76
vulkan_functions.h
FFVulkanPipeline::desc_set
FFVulkanDescriptorSet * desc_set
Definition: vulkan.h:147
FFVulkanContext::video_props
VkQueueFamilyVideoPropertiesKHR * video_props
Definition: vulkan.h:242
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
ff_vk_exec_discard_deps
void ff_vk_exec_discard_deps(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:549
FFVulkanDescriptorSet::total_size
VkDeviceSize total_size
Definition: vulkan.h:122
FFVulkanDescriptorSet::usage
VkBufferUsageFlags usage
Definition: vulkan.h:123
FFVkSPIRVShader::subgroup_info
VkPipelineShaderStageRequiredSubgroupSizeCreateInfo subgroup_info
Definition: vulkan.h:81
desc
const char * desc
Definition: libsvtav1.c:83
ff_vk_exec_pipeline_register
int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanPipeline *pl)
Register a pipeline with an exec pool.
Definition: vulkan.c:1577
FFVulkanContext::hwctx
AVVulkanDeviceContext * hwctx
Definition: vulkan.h:254
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:367
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
FFVkExecPool::cmd_bufs
VkCommandBuffer * cmd_bufs
Definition: vulkan.h:216
FFVkSPIRVShader::name
const char * name
Definition: vulkan.h:77
FFVulkanContext::feats_12
VkPhysicalDeviceVulkan12Features feats_12
Definition: vulkan.h:250
FFVulkanExtensions
FFVulkanExtensions
Definition: vulkan_functions.h:29
FFVkSPIRVShader::local_size
int local_size[3]
Definition: vulkan.h:79
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
FFVkExecContext::buf_deps_alloc_size
unsigned int buf_deps_alloc_size
Definition: vulkan.h:176
FFVkExecContext::buf_deps
AVBufferRef ** buf_deps
Definition: vulkan.h:174
FFVkBuffer
Definition: vulkan.h:96
FFVulkanContext::qfs
uint32_t qfs[5]
Definition: vulkan.h:261
ff_vk_set_descriptor_buffer
int ff_vk_set_descriptor_buffer(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt)
Definition: vulkan.c:1706
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
hwcontext.h
FFVkExecPool::qd_size
size_t qd_size
Definition: vulkan.h:226
FFVulkanContext::frames
AVHWFramesContext * frames
Definition: vulkan.h:258
FFVulkanDescriptorSet
Definition: vulkan.h:116
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:1304
ff_vk_shader_print
void ff_vk_shader_print(void *ctx, FFVkSPIRVShader *shd, int prio)
Definition: vulkan.c:1382
FFVulkanPipeline::desc_bind
VkDescriptorBufferBindingInfoEXT * desc_bind
Definition: vulkan.h:148
FFVkExecPool::query_results
int query_results
Definition: vulkan.h:221
ff_vk_init_sampler
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
Definition: vulkan.c:1163
FFVkExecContext::sem_sig_val_dst
uint64_t ** sem_sig_val_dst
Definition: vulkan.h:191
FFVulkanContext::query_props
VkQueueFamilyQueryResultStatusPropertiesKHR * query_props
Definition: vulkan.h:241
ff_vk_create_buf
int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, size_t size, void *pNext, void *alloc_pNext, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
Definition: vulkan.c:848
FFVulkanDescriptorSetBinding::mem_quali
const char * mem_quali
Definition: vulkan.h:88
FFVulkanFunctions
Definition: vulkan_functions.h:226
FFVkExecPool::pool_size
int pool_size
Definition: vulkan.h:217
FFVkExecPool::cmd_buf_pool
VkCommandPool cmd_buf_pool
Definition: vulkan.h:215
FFVulkanContext::coop_mat_props
VkCooperativeMatrixPropertiesKHR * coop_mat_props
Definition: vulkan.h:246
FFVkExecContext::idx
uint32_t idx
Definition: vulkan.h:154
FFVulkanPipeline::bound_buffer_indices
uint32_t * bound_buffer_indices
Definition: vulkan.h:149
FFVkQueueFamilyCtx::queue_family
int queue_family
Definition: vulkan.h:112
ff_vk_exec_bind_pipeline
void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl)
Definition: vulkan.c:1846
FFVkExecContext::access_dst
VkAccessFlagBits * access_dst
Definition: vulkan.h:198