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 #include "pixdesc.h"
23 #include "bprint.h"
24 #include "hwcontext.h"
25 #include "vulkan_functions.h"
26 #include "hwcontext_vulkan.h"
27 #include "vulkan_loader.h"
28 
29 #define FF_VK_DEFAULT_USAGE_FLAGS (VK_IMAGE_USAGE_SAMPLED_BIT | \
30  VK_IMAGE_USAGE_STORAGE_BIT | \
31  VK_IMAGE_USAGE_TRANSFER_SRC_BIT | \
32  VK_IMAGE_USAGE_TRANSFER_DST_BIT)
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 #define GLSLC(N, S) av_bprintf(&shd->src, C(N, S))
45 #define GLSLA(...) av_bprintf(&shd->src, __VA_ARGS__)
46 #define GLSLF(N, S, ...) av_bprintf(&shd->src, C(N, S), __VA_ARGS__)
47 #define GLSLD(D) GLSLC(0, ); \
48  av_bprint_append_data(&shd->src, D, strlen(D)); \
49  GLSLC(0, )
50 
51 /* Helper, pretty much every Vulkan return value needs to be checked */
52 #define RET(x) \
53  do { \
54  if ((err = (x)) < 0) \
55  goto fail; \
56  } while (0)
57 
58 typedef struct FFVkSPIRVShader {
59  const char *name; /* Name for id/debugging purposes */
60  AVBPrint src;
61  int local_size[3]; /* Compute shader workgroup sizes */
62  VkPipelineShaderStageCreateInfo shader;
64 
65 typedef struct FFVkSPIRVCompiler {
66  void *priv;
67  int (*compile_shader)(struct FFVkSPIRVCompiler *ctx, void *avctx,
68  struct FFVkSPIRVShader *shd, uint8_t **data,
69  size_t *size, const char *entrypoint, void **opaque);
70  void (*free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque);
71  void (*uninit)(struct FFVkSPIRVCompiler **ctx);
73 
74 typedef struct FFVkSampler {
75  VkSampler sampler[4];
76 } FFVkSampler;
77 
79  const char *name;
80  VkDescriptorType type;
81  const char *mem_layout; /* Storage images (rgba8, etc.) and buffers (std430, etc.) */
82  const char *mem_quali; /* readonly, writeonly, etc. */
83  const char *buf_content; /* For buffers */
84  uint32_t dimensions; /* Needed for e.g. sampler%iD */
85  uint32_t elems; /* 0 - scalar, 1 or more - vector */
86  VkShaderStageFlags stages;
87  FFVkSampler *sampler; /* Sampler to use for all elems */
88  void *updater; /* Pointer to VkDescriptor*Info */
90 
91 typedef struct FFVkBuffer {
92  VkBuffer buf;
93  VkDeviceMemory mem;
94  VkMemoryPropertyFlagBits flags;
95 } FFVkBuffer;
96 
97 typedef struct FFVkQueueFamilyCtx {
99  int nb_queues;
103 
104 typedef struct FFVulkanPipeline {
106 
107  VkPipelineBindPoint bind_point;
108 
109  /* Contexts */
110  VkPipelineLayout pipeline_layout;
111  VkPipeline pipeline;
112 
113  /* Shaders */
116 
117  /* Push consts */
118  VkPushConstantRange *push_consts;
120 
121  /* Descriptors */
122  VkDescriptorSetLayout *desc_layout;
123  VkDescriptorPool desc_pool;
124  VkDescriptorSet *desc_set;
125  void **desc_staging;
126  VkDescriptorSetLayoutBinding **desc_binding;
127  VkDescriptorUpdateTemplate *desc_template;
133 
134  /* Temporary, used to store data in between initialization stages */
135  VkDescriptorUpdateTemplateCreateInfo *desc_template_info;
136  VkDescriptorPoolSize *pool_size_desc;
138 
139 typedef struct FFVkQueueCtx {
140  VkFence fence;
141  VkQueue queue;
142 
143  /* Buffer dependencies */
147 
148  /* Frame dependencies */
152 } FFVkQueueCtx;
153 
154 typedef struct FFVkExecContext {
156 
157  VkCommandPool pool;
158  VkCommandBuffer *bufs;
160 
162  int *nb_deps;
164 
166 
167  VkSemaphore *sem_wait;
168  int sem_wait_alloc; /* Allocated sem_wait */
170 
171  uint64_t *sem_wait_val;
173 
174  VkPipelineStageFlagBits *sem_wait_dst;
175  int sem_wait_dst_alloc; /* Allocated sem_wait_dst */
176 
177  VkSemaphore *sem_sig;
178  int sem_sig_alloc; /* Allocated sem_sig */
180 
181  uint64_t *sem_sig_val;
183 
184  uint64_t **sem_sig_val_dst;
187 
188 typedef struct FFVulkanContext {
189  const AVClass *class; /* Filters and encoders use this */
190 
193  VkPhysicalDeviceProperties props;
194  VkPhysicalDeviceMemoryProperties mprops;
195 
199 
203 
205 
206  /* Properties */
211 
212  /* Samplers */
215 
216  /* Exec contexts */
219 
220  /* Pipelines (each can have 1 shader of each type) */
223 
224  void *scratch; /* Scratch memory used only in functions */
225  unsigned int scratch_size;
227 
228 /* Identity mapping - r = r, b = b, g = g, a = a */
229 extern const VkComponentMapping ff_comp_identity_map;
230 
231 /**
232  * Converts Vulkan return values to strings
233  */
234 const char *ff_vk_ret2str(VkResult res);
235 
236 /**
237  * Returns 1 if the image is any sort of supported RGB
238  */
240 
241 /**
242  * Gets the glsl format string for a pixel format
243  */
244 const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt);
245 
246 /**
247  * Initialize a queue family with a specific number of queues.
248  * If nb_queues == 0, use however many queues the queue family has.
249  */
251  VkQueueFlagBits dev_family, int nb_queues);
252 
253 /**
254  * Rotate through the queues in a queue family.
255  */
257 
258 /**
259  * Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
260  */
261 FFVkSampler *ff_vk_init_sampler(FFVulkanContext *s, int unnorm_coords,
262  VkFilter filt);
263 
264 /**
265  * Create an imageview.
266  * Guaranteed to remain alive until the queue submission has finished executing,
267  * and will be destroyed after that.
268  */
270  VkImageView *v, VkImage img, VkFormat fmt,
271  const VkComponentMapping map);
272 
273 /**
274  * Define a push constant for a given stage into a pipeline.
275  * Must be called before the pipeline layout has been initialized.
276  */
278  VkShaderStageFlagBits stage);
279 
280 /**
281  * Inits a pipeline. Everything in it will be auto-freed when calling
282  * ff_vk_filter_uninit().
283  */
285 
286 /**
287  * Inits a shader for a specific pipeline. Will be auto-freed on uninit.
288  */
290  VkShaderStageFlags stage);
291 
292 /**
293  * Writes the workgroup size for a shader.
294  */
295 void ff_vk_set_compute_shader_sizes(FFVkSPIRVShader *shd, int local_size[3]);
296 
297 /**
298  * Adds a descriptor set to the shader and registers them in the pipeline.
299  */
302  int num, int only_print_to_shader);
303 
304 /**
305  * Compiles the shader, entrypoint must be set to "main".
306  */
308  const char *entrypoint);
309 
310 /**
311  * Pretty print shader, mainly used by shader compilers.
312  */
313 void ff_vk_print_shader(void *ctx, FFVkSPIRVShader *shd, int prio);
314 
315 /**
316  * Initializes the pipeline layout after all shaders and descriptor sets have
317  * been finished.
318  */
320 
321 /**
322  * Initializes a compute pipeline. Will pick the first shader with the
323  * COMPUTE flag set.
324  */
326 
327 /**
328  * Updates a descriptor set via the updaters defined.
329  * Can be called immediately after pipeline creation, but must be called
330  * at least once before queue submission.
331  */
333  int set_id);
334 
335 /**
336  * Init an execution context for command recording and queue submission.
337  * WIll be auto-freed on uninit.
338  */
340  FFVkQueueFamilyCtx *qf);
341 
342 /**
343  * Begin recording to the command buffer. Previous execution must have been
344  * completed, which ff_vk_submit_exec_queue() will ensure.
345  */
347 
348 /**
349  * Add a command to bind the completed pipeline and its descriptor sets.
350  * Must be called after ff_vk_start_exec_recording() and before submission.
351  */
353  FFVulkanPipeline *pl);
354 
355 /**
356  * Updates push constants.
357  * Must be called after binding a pipeline if any push constants were defined.
358  */
360  VkShaderStageFlagBits stage, int offset,
361  size_t size, void *src);
362 
363 /**
364  * Gets the command buffer to use for this submission from the exe context.
365  */
366 VkCommandBuffer ff_vk_get_exec_buf(FFVkExecContext *e);
367 
368 /**
369  * Adds a generic AVBufferRef as a queue depenency.
370  */
372  AVBufferRef **deps, int nb_deps);
373 
374 /**
375  * Discards all queue dependencies
376  */
378 
379 /**
380  * Adds a frame as a queue dependency. This also manages semaphore signalling.
381  * Must be called before submission.
382  */
384  VkPipelineStageFlagBits in_wait_dst_flag);
385 
386 /**
387  * Submits a command buffer to the queue for execution.
388  * Will block until execution has finished in order to simplify resource
389  * management.
390  */
392 
393 /**
394  * Create a VkBuffer with the specified parameters.
395  */
397  VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags);
398 
399 /**
400  * Maps the buffer to userspace. Set invalidate to 1 if reading the contents
401  * is necessary.
402  */
403 int ff_vk_map_buffers(FFVulkanContext *s, FFVkBuffer *buf, uint8_t *mem[],
404  int nb_buffers, int invalidate);
405 
406 /**
407  * Unmaps the buffer from userspace. Set flush to 1 to write and sync.
408  */
409 int ff_vk_unmap_buffers(FFVulkanContext *s, FFVkBuffer *buf, int nb_buffers,
410  int flush);
411 
412 /**
413  * Frees a buffer.
414  */
416 
417 /**
418  * Frees the main Vulkan context.
419  */
421 
422 #endif /* AVUTIL_VULKAN_H */
FFVkExecContext::queues
FFVkQueueCtx * queues
Definition: vulkan.h:159
vulkan_loader.h
FFVulkanPipeline::bind_point
VkPipelineBindPoint bind_point
Definition: vulkan.h:107
ff_vk_map_buffers
int ff_vk_map_buffers(FFVulkanContext *s, FFVkBuffer *buf, uint8_t *mem[], int nb_buffers, int invalidate)
Maps the buffer to userspace.
Definition: vulkan.c:258
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
FFVkExecContext::sem_wait_dst_alloc
int sem_wait_dst_alloc
Definition: vulkan.h:175
FFVulkanContext::hwfc
AVVulkanFramesContext * hwfc
Definition: vulkan.h:202
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees the main Vulkan context.
Definition: vulkan.c:1379
FFVkExecContext::sem_wait
VkSemaphore * sem_wait
Definition: vulkan.h:167
FFVulkanContext::output_height
int output_height
Definition: vulkan.h:208
FFVulkanPipeline::shaders_num
int shaders_num
Definition: vulkan.h:115
FFVkExecContext::qf
FFVkQueueFamilyCtx * qf
Definition: vulkan.h:155
FFVulkanPipeline::pipeline_layout
VkPipelineLayout pipeline_layout
Definition: vulkan.h:110
FFVulkanContext::device_ref
AVBufferRef * device_ref
Definition: vulkan.h:196
FFVulkanContext::pipelines_num
int pipelines_num
Definition: vulkan.h:222
FFVkExecContext::sem_sig
VkSemaphore * sem_sig
Definition: vulkan.h:177
ff_vk_add_dep_exec_ctx
int ff_vk_add_dep_exec_ctx(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps)
Adds a generic AVBufferRef as a queue depenency.
Definition: vulkan.c:639
ff_vk_create_imageview
int ff_vk_create_imageview(FFVulkanContext *s, FFVkExecContext *e, VkImageView *v, VkImage img, VkFormat fmt, const VkComponentMapping map)
Create an imageview.
Definition: vulkan.c:742
ff_vk_print_shader
void ff_vk_print_shader(void *ctx, FFVkSPIRVShader *shd, int prio)
Pretty print shader, mainly used by shader compilers.
Definition: vulkan.c:827
ff_vk_add_push_constant
int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Define a push constant for a given stage into a pipeline.
Definition: vulkan.c:364
ff_vk_create_buf
int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, size_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
Create a VkBuffer with the specified parameters.
Definition: vulkan.c:193
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
pixdesc.h
FFVulkanDescriptorSetBinding::stages
VkShaderStageFlags stages
Definition: vulkan.h:86
ff_vk_bind_pipeline_exec
void ff_vk_bind_pipeline_exec(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl)
Add a command to bind the completed pipeline and its descriptor sets.
Definition: vulkan.c:1264
data
const char data[16]
Definition: mxf.c:146
FFVkQueueCtx::buf_deps_alloc_size
int buf_deps_alloc_size
Definition: vulkan.h:146
FFVkSPIRVCompiler::uninit
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
Definition: vulkan.h:71
FFVulkanPipeline::desc_pool
VkDescriptorPool desc_pool
Definition: vulkan.h:123
FFVulkanDescriptorSetBinding::buf_content
const char * buf_content
Definition: vulkan.h:83
FFVulkanPipeline::desc_staging
void ** desc_staging
Definition: vulkan.h:125
FFVkExecContext::bound_pl
FFVulkanPipeline * bound_pl
Definition: vulkan.h:165
ff_vk_start_exec_recording
int ff_vk_start_exec_recording(FFVulkanContext *s, FFVkExecContext *e)
Begin recording to the command buffer.
Definition: vulkan.c:463
FFVkSampler
Definition: vulkan.h:74
FFVkBuffer::buf
VkBuffer buf
Definition: vulkan.h:92
FFVkExecContext::deps
AVBufferRef *** deps
Definition: vulkan.h:161
FFVkExecContext::sem_wait_dst
VkPipelineStageFlagBits * sem_wait_dst
Definition: vulkan.h:174
FFVulkanContext::samplers
FFVkSampler ** samplers
Definition: vulkan.h:213
AVVulkanFramesContext
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
Definition: hwcontext_vulkan.h:157
FFVulkanPipeline::pipeline
VkPipeline pipeline
Definition: vulkan.h:111
ff_vk_get_exec_buf
VkCommandBuffer ff_vk_get_exec_buf(FFVkExecContext *e)
Gets the command buffer to use for this submission from the exe context.
Definition: vulkan.c:504
FFVulkanContext::scratch
void * scratch
Definition: vulkan.h:224
FFVulkanPipeline::shaders
FFVkSPIRVShader ** shaders
Definition: vulkan.h:114
FFVkExecContext::sem_sig_val_dst_alloc
int sem_sig_val_dst_alloc
Definition: vulkan.h:185
FFVulkanContext::frames_ref
AVBufferRef * frames_ref
Definition: vulkan.h:200
ff_vk_update_descriptor_set
void ff_vk_update_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, int set_id)
Updates a descriptor set via the updaters defined.
Definition: vulkan.c:1080
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
ff_vk_shader_rep_fmt
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Gets the glsl format string for a pixel format.
Definition: vulkan.c:721
FFVulkanDescriptorSetBinding::type
VkDescriptorType type
Definition: vulkan.h:80
FFVulkanContext::samplers_num
int samplers_num
Definition: vulkan.h:214
FFVkQueueFamilyCtx::actual_queues
int actual_queues
Definition: vulkan.h:101
FFVkQueueCtx::queue
VkQueue queue
Definition: vulkan.h:141
FFVulkanDescriptorSetBinding::elems
uint32_t elems
Definition: vulkan.h:85
FFVulkanContext::output_width
int output_width
Definition: vulkan.h:207
FFVulkanContext::exec_ctx
FFVkExecContext ** exec_ctx
Definition: vulkan.h:217
FFVkQueueCtx::frame_deps
AVFrame ** frame_deps
Definition: vulkan.h:149
ff_vk_create_exec_ctx
int ff_vk_create_exec_ctx(FFVulkanContext *s, FFVkExecContext **ctx, FFVkQueueFamilyCtx *qf)
Init an execution context for command recording and queue submission.
Definition: vulkan.c:385
s
#define s(width, name)
Definition: cbs_vp9.c:256
FFVkExecContext::sem_sig_alloc
int sem_sig_alloc
Definition: vulkan.h:178
ff_vk_qf_rotate
void ff_vk_qf_rotate(FFVkQueueFamilyCtx *qf)
Rotate through the queues in a queue family.
Definition: vulkan.c:132
ff_vk_init_pipeline_layout
int ff_vk_init_pipeline_layout(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes the pipeline layout after all shaders and descriptor sets have been finished.
Definition: vulkan.c:1116
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
FFVkExecContext::dep_alloc_size
int * dep_alloc_size
Definition: vulkan.h:163
FFVulkanPipeline::desc_template
VkDescriptorUpdateTemplate * desc_template
Definition: vulkan.h:127
FFVulkanContext::pipelines
FFVulkanPipeline ** pipelines
Definition: vulkan.h:221
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FFVkExecContext::sem_sig_val
uint64_t * sem_sig_val
Definition: vulkan.h:181
FFVulkanDescriptorSetBinding::mem_layout
const char * mem_layout
Definition: vulkan.h:81
FFVkSPIRVCompiler::compile_shader
int(* compile_shader)(struct FFVkSPIRVCompiler *ctx, void *avctx, struct FFVkSPIRVShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
Definition: vulkan.h:67
FFVulkanPipeline::desc_template_info
VkDescriptorUpdateTemplateCreateInfo * desc_template_info
Definition: vulkan.h:135
FFVkSampler::sampler
VkSampler sampler[4]
Definition: vulkan.h:75
AVVulkanDeviceContext
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_vulkan.h:42
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
FFVkQueueCtx
Definition: vulkan.h:139
FFVkSPIRVCompiler::priv
void * priv
Definition: vulkan.h:66
FFVkExecContext::sem_wait_alloc
int sem_wait_alloc
Definition: vulkan.h:168
FFVkExecContext::sem_sig_cnt
int sem_sig_cnt
Definition: vulkan.h:179
FFVulkanDescriptorSetBinding::dimensions
uint32_t dimensions
Definition: vulkan.h:84
hwcontext_vulkan.h
FFVulkanDescriptorSetBinding::updater
void * updater
Definition: vulkan.h:88
FFVkExecContext::sem_sig_val_alloc
int sem_sig_val_alloc
Definition: vulkan.h:182
FFVulkanContext
Definition: vulkan.h:188
FFVulkanPipeline::desc_binding
VkDescriptorSetLayoutBinding ** desc_binding
Definition: vulkan.h:126
FFVulkanPipeline
Definition: vulkan.h:104
FFVulkanContext::device
AVHWDeviceContext * device
Definition: vulkan.h:197
usage
const char * usage
Definition: floatimg_cmp.c:60
FFVkQueueCtx::fence
VkFence fence
Definition: vulkan.h:140
FFVulkanPipeline::desc_layout_num
int desc_layout_num
Definition: vulkan.h:129
FFVkExecContext::pool
VkCommandPool pool
Definition: vulkan.h:157
FFVulkanPipeline::total_descriptor_sets
int total_descriptor_sets
Definition: vulkan.h:131
FFVulkanDescriptorSetBinding
Definition: vulkan.h:78
FFVulkanContext::spirv_compiler
FFVkSPIRVCompiler * spirv_compiler
Definition: vulkan.h:204
size
int size
Definition: twinvq_data.h:10344
FFVulkanContext::props
VkPhysicalDeviceProperties props
Definition: vulkan.h:193
FFVkQueueFamilyCtx
Definition: vulkan.h:97
ff_vk_free_buf
void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf)
Frees a buffer.
Definition: vulkan.c:349
FFVulkanContext::output_format
enum AVPixelFormat output_format
Definition: vulkan.h:209
ff_vk_init_shader
FFVkSPIRVShader * ff_vk_init_shader(FFVulkanPipeline *pl, const char *name, VkShaderStageFlags stage)
Inits a shader for a specific pipeline.
Definition: vulkan.c:795
FFVkBuffer::flags
VkMemoryPropertyFlagBits flags
Definition: vulkan.h:94
img
#define img
Definition: vf_colormatrix.c:116
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:154
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:79
FFVulkanPipeline::desc_set
VkDescriptorSet * desc_set
Definition: vulkan.h:124
ff_comp_identity_map
const VkComponentMapping ff_comp_identity_map
Definition: vulkan.c:51
FFVkExecContext::sem_wait_cnt
int sem_wait_cnt
Definition: vulkan.h:169
FFVkSPIRVCompiler
Definition: vulkan.h:65
FFVkQueueCtx::nb_buf_deps
int nb_buf_deps
Definition: vulkan.h:145
ff_vk_submit_exec_queue
int ff_vk_submit_exec_queue(FFVulkanContext *s, FFVkExecContext *e)
Submits a command buffer to the queue for execution.
Definition: vulkan.c:590
bprint.h
ff_vk_set_compute_shader_sizes
void ff_vk_set_compute_shader_sizes(FFVkSPIRVShader *shd, int local_size[3])
Writes the workgroup size for a shader.
Definition: vulkan.c:816
ff_vk_ret2str
const char * ff_vk_ret2str(VkResult res)
Converts Vulkan return values to strings.
Definition: vulkan.c:59
FFVulkanPipeline::pool_size_desc
VkDescriptorPoolSize * pool_size_desc
Definition: vulkan.h:136
FFVulkanPipeline::push_consts
VkPushConstantRange * push_consts
Definition: vulkan.h:118
FFVkSPIRVShader::shader
VkPipelineShaderStageCreateInfo shader
Definition: vulkan.h:62
VkFormat
enum VkFormat VkFormat
Definition: hwcontext_stub.c:25
FFVulkanPipeline::qf
FFVkQueueFamilyCtx * qf
Definition: vulkan.h:105
ff_vk_qf_init
void ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family, int nb_queues)
Initialize a queue family with a specific number of queues.
Definition: vulkan.c:96
FFVkBuffer::mem
VkDeviceMemory mem
Definition: vulkan.h:93
FFVkSPIRVShader::src
AVBPrint src
Definition: vulkan.h:60
filt
static const int8_t filt[NUMTAPS *2]
Definition: af_earwax.c:39
FFVulkanContext::extensions
FFVulkanExtensions extensions
Definition: vulkan.h:192
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan.h:70
FFVulkanContext::mprops
VkPhysicalDeviceMemoryProperties mprops
Definition: vulkan.h:194
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
FFVulkanPipeline::desc_set_initialized
int * desc_set_initialized
Definition: vulkan.h:128
FFVulkanPipeline::push_consts_num
int push_consts_num
Definition: vulkan.h:119
pixfmt
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:365
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:191
ff_vk_unmap_buffers
int ff_vk_unmap_buffers(FFVulkanContext *s, FFVkBuffer *buf, int nb_buffers, int flush)
Unmaps the buffer from userspace.
Definition: vulkan.c:307
ff_vk_mt_is_np_rgb
int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
Returns 1 if the image is any sort of supported RGB.
Definition: vulkan.c:709
ff_vk_create_pipeline
FFVulkanPipeline * ff_vk_create_pipeline(FFVulkanContext *s, FFVkQueueFamilyCtx *qf)
Inits a pipeline.
Definition: vulkan.c:1220
FFVulkanContext::input_format
enum AVPixelFormat input_format
Definition: vulkan.h:210
FFVkQueueCtx::frame_deps_alloc_size
int frame_deps_alloc_size
Definition: vulkan.h:151
FFVkQueueFamilyCtx::nb_queues
int nb_queues
Definition: vulkan.h:99
ff_vk_init_sampler
FFVkSampler * ff_vk_init_sampler(FFVulkanContext *s, int unnorm_coords, VkFilter filt)
Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
Definition: vulkan.c:670
FFVkQueueFamilyCtx::cur_queue
int cur_queue
Definition: vulkan.h:100
FFVkSPIRVShader
Definition: vulkan.h:58
vulkan_functions.h
ff_vk_init_compute_pipeline
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes a compute pipeline.
Definition: vulkan.c:1229
FFVulkanDescriptorSetBinding::sampler
FFVkSampler * sampler
Definition: vulkan.h:87
desc
const char * desc
Definition: libsvtav1.c:83
FFVulkanContext::hwctx
AVVulkanDeviceContext * hwctx
Definition: vulkan.h:198
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:367
FFVulkanPipeline::descriptor_sets_num
int descriptor_sets_num
Definition: vulkan.h:130
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
FFVkExecContext::bufs
VkCommandBuffer * bufs
Definition: vulkan.h:158
ff_vk_update_push_exec
void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Updates push constants.
Definition: vulkan.c:1106
FFVkSPIRVShader::name
const char * name
Definition: vulkan.h:59
FFVulkanExtensions
FFVulkanExtensions
Definition: vulkan_functions.h:29
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
FFVkSPIRVShader::local_size
int local_size[3]
Definition: vulkan.h:61
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
FFVkBuffer
Definition: vulkan.h:91
ff_vk_compile_shader
int ff_vk_compile_shader(FFVulkanContext *s, FFVkSPIRVShader *shd, const char *entrypoint)
Compiles the shader, entrypoint must be set to "main".
Definition: vulkan.c:849
FFVkExecContext::sem_wait_val
uint64_t * sem_wait_val
Definition: vulkan.h:171
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
hwcontext.h
FFVulkanPipeline::pool_size_desc_num
int pool_size_desc_num
Definition: vulkan.h:132
FFVulkanContext::frames
AVHWFramesContext * frames
Definition: vulkan.h:201
ff_vk_add_descriptor_set
int ff_vk_add_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int num, int only_print_to_shader)
Adds a descriptor set to the shader and registers them in the pipeline.
Definition: vulkan.c:923
FFVkQueueCtx::nb_frame_deps
int nb_frame_deps
Definition: vulkan.h:150
ff_vk_discard_exec_deps
void ff_vk_discard_exec_deps(FFVkExecContext *e)
Discards all queue dependencies.
Definition: vulkan.c:447
FFVkExecContext::nb_deps
int * nb_deps
Definition: vulkan.h:162
FFVkExecContext::sem_sig_val_dst
uint64_t ** sem_sig_val_dst
Definition: vulkan.h:184
int
int
Definition: ffmpeg_filter.c:156
FFVkExecContext::sem_wait_val_alloc
int sem_wait_val_alloc
Definition: vulkan.h:172
FFVkQueueCtx::buf_deps
AVBufferRef ** buf_deps
Definition: vulkan.h:144
FFVulkanPipeline::desc_layout
VkDescriptorSetLayout * desc_layout
Definition: vulkan.h:122
FFVulkanDescriptorSetBinding::mem_quali
const char * mem_quali
Definition: vulkan.h:82
FFVulkanFunctions
Definition: vulkan_functions.h:175
FFVulkanContext::scratch_size
unsigned int scratch_size
Definition: vulkan.h:225
FFVulkanContext::exec_ctx_num
int exec_ctx_num
Definition: vulkan.h:218
ff_vk_add_exec_dep
int ff_vk_add_exec_dep(FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag)
Adds a frame as a queue dependency.
Definition: vulkan.c:509
FFVkQueueFamilyCtx::queue_family
int queue_family
Definition: vulkan.h:98