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 #if VK_USE_64_BIT_PTR_DEFINES == 1
126  void **desc_staging;
127 #else
128  uint64_t *desc_staging;
129 #endif
130  VkDescriptorSetLayoutBinding **desc_binding;
131  VkDescriptorUpdateTemplate *desc_template;
137 
138  /* Temporary, used to store data in between initialization stages */
139  VkDescriptorUpdateTemplateCreateInfo *desc_template_info;
140  VkDescriptorPoolSize *pool_size_desc;
142 
143 typedef struct FFVkQueueCtx {
144  VkFence fence;
145  VkQueue queue;
146 
147  /* Buffer dependencies */
151 
152  /* Frame dependencies */
156 } FFVkQueueCtx;
157 
158 typedef struct FFVkExecContext {
160 
161  VkCommandPool pool;
162  VkCommandBuffer *bufs;
164 
166  int *nb_deps;
168 
170 
171  VkSemaphore *sem_wait;
172  int sem_wait_alloc; /* Allocated sem_wait */
174 
175  uint64_t *sem_wait_val;
177 
178  VkPipelineStageFlagBits *sem_wait_dst;
179  int sem_wait_dst_alloc; /* Allocated sem_wait_dst */
180 
181  VkSemaphore *sem_sig;
182  int sem_sig_alloc; /* Allocated sem_sig */
184 
185  uint64_t *sem_sig_val;
187 
188  uint64_t **sem_sig_val_dst;
191 
192 typedef struct FFVulkanContext {
193  const AVClass *class; /* Filters and encoders use this */
194 
197  VkPhysicalDeviceProperties props;
198  VkPhysicalDeviceMemoryProperties mprops;
199 
203 
207 
209 
210  /* Properties */
215 
216  /* Samplers */
219 
220  /* Exec contexts */
223 
224  /* Pipelines (each can have 1 shader of each type) */
227 
228  void *scratch; /* Scratch memory used only in functions */
229  unsigned int scratch_size;
231 
232 /* Identity mapping - r = r, b = b, g = g, a = a */
233 extern const VkComponentMapping ff_comp_identity_map;
234 
235 /**
236  * Converts Vulkan return values to strings
237  */
238 const char *ff_vk_ret2str(VkResult res);
239 
240 /**
241  * Returns 1 if the image is any sort of supported RGB
242  */
244 
245 /**
246  * Gets the glsl format string for a pixel format
247  */
248 const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt);
249 
250 /**
251  * Initialize a queue family with a specific number of queues.
252  * If nb_queues == 0, use however many queues the queue family has.
253  */
255  VkQueueFlagBits dev_family, int nb_queues);
256 
257 /**
258  * Rotate through the queues in a queue family.
259  */
261 
262 /**
263  * Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
264  */
265 FFVkSampler *ff_vk_init_sampler(FFVulkanContext *s, int unnorm_coords,
266  VkFilter filt);
267 
268 /**
269  * Create an imageview.
270  * Guaranteed to remain alive until the queue submission has finished executing,
271  * and will be destroyed after that.
272  */
274  VkImageView *v, VkImage img, VkFormat fmt,
275  const VkComponentMapping map);
276 
277 /**
278  * Define a push constant for a given stage into a pipeline.
279  * Must be called before the pipeline layout has been initialized.
280  */
282  VkShaderStageFlagBits stage);
283 
284 /**
285  * Inits a pipeline. Everything in it will be auto-freed when calling
286  * ff_vk_filter_uninit().
287  */
289 
290 /**
291  * Inits a shader for a specific pipeline. Will be auto-freed on uninit.
292  */
294  VkShaderStageFlags stage);
295 
296 /**
297  * Writes the workgroup size for a shader.
298  */
299 void ff_vk_set_compute_shader_sizes(FFVkSPIRVShader *shd, int local_size[3]);
300 
301 /**
302  * Adds a descriptor set to the shader and registers them in the pipeline.
303  */
306  int num, int only_print_to_shader);
307 
308 /**
309  * Compiles the shader, entrypoint must be set to "main".
310  */
312  const char *entrypoint);
313 
314 /**
315  * Pretty print shader, mainly used by shader compilers.
316  */
317 void ff_vk_print_shader(void *ctx, FFVkSPIRVShader *shd, int prio);
318 
319 /**
320  * Initializes the pipeline layout after all shaders and descriptor sets have
321  * been finished.
322  */
324 
325 /**
326  * Initializes a compute pipeline. Will pick the first shader with the
327  * COMPUTE flag set.
328  */
330 
331 /**
332  * Updates a descriptor set via the updaters defined.
333  * Can be called immediately after pipeline creation, but must be called
334  * at least once before queue submission.
335  */
337  int set_id);
338 
339 /**
340  * Init an execution context for command recording and queue submission.
341  * WIll be auto-freed on uninit.
342  */
344  FFVkQueueFamilyCtx *qf);
345 
346 /**
347  * Begin recording to the command buffer. Previous execution must have been
348  * completed, which ff_vk_submit_exec_queue() will ensure.
349  */
351 
352 /**
353  * Add a command to bind the completed pipeline and its descriptor sets.
354  * Must be called after ff_vk_start_exec_recording() and before submission.
355  */
357  FFVulkanPipeline *pl);
358 
359 /**
360  * Updates push constants.
361  * Must be called after binding a pipeline if any push constants were defined.
362  */
364  VkShaderStageFlagBits stage, int offset,
365  size_t size, void *src);
366 
367 /**
368  * Gets the command buffer to use for this submission from the exe context.
369  */
370 VkCommandBuffer ff_vk_get_exec_buf(FFVkExecContext *e);
371 
372 /**
373  * Adds a generic AVBufferRef as a queue depenency.
374  */
376  AVBufferRef **deps, int nb_deps);
377 
378 /**
379  * Discards all queue dependencies
380  */
382 
383 /**
384  * Adds a frame as a queue dependency. This also manages semaphore signalling.
385  * Must be called before submission.
386  */
388  VkPipelineStageFlagBits in_wait_dst_flag);
389 
390 /**
391  * Submits a command buffer to the queue for execution.
392  * Will block until execution has finished in order to simplify resource
393  * management.
394  */
396 
397 /**
398  * Create a VkBuffer with the specified parameters.
399  */
401  VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags);
402 
403 /**
404  * Maps the buffer to userspace. Set invalidate to 1 if reading the contents
405  * is necessary.
406  */
407 int ff_vk_map_buffers(FFVulkanContext *s, FFVkBuffer *buf, uint8_t *mem[],
408  int nb_buffers, int invalidate);
409 
410 /**
411  * Unmaps the buffer from userspace. Set flush to 1 to write and sync.
412  */
413 int ff_vk_unmap_buffers(FFVulkanContext *s, FFVkBuffer *buf, int nb_buffers,
414  int flush);
415 
416 /**
417  * Frees a buffer.
418  */
420 
421 /**
422  * Frees the main Vulkan context.
423  */
425 
426 #endif /* AVUTIL_VULKAN_H */
FFVkExecContext::queues
FFVkQueueCtx * queues
Definition: vulkan.h:163
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:179
FFVulkanContext::hwfc
AVVulkanFramesContext * hwfc
Definition: vulkan.h:206
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:171
FFVulkanContext::output_height
int output_height
Definition: vulkan.h:212
FFVulkanPipeline::shaders_num
int shaders_num
Definition: vulkan.h:115
FFVkExecContext::qf
FFVkQueueFamilyCtx * qf
Definition: vulkan.h:159
FFVulkanPipeline::pipeline_layout
VkPipelineLayout pipeline_layout
Definition: vulkan.h:110
FFVulkanContext::device_ref
AVBufferRef * device_ref
Definition: vulkan.h:200
FFVulkanContext::pipelines_num
int pipelines_num
Definition: vulkan.h:226
FFVkExecContext::sem_sig
VkSemaphore * sem_sig
Definition: vulkan.h:181
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:150
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
FFVkExecContext::bound_pl
FFVulkanPipeline * bound_pl
Definition: vulkan.h:169
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:165
FFVkExecContext::sem_wait_dst
VkPipelineStageFlagBits * sem_wait_dst
Definition: vulkan.h:178
FFVulkanContext::samplers
FFVkSampler ** samplers
Definition: vulkan.h:217
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:228
FFVulkanPipeline::shaders
FFVkSPIRVShader ** shaders
Definition: vulkan.h:114
FFVkExecContext::sem_sig_val_dst_alloc
int sem_sig_val_dst_alloc
Definition: vulkan.h:189
FFVulkanContext::frames_ref
AVBufferRef * frames_ref
Definition: vulkan.h:204
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
FFVulkanPipeline::desc_staging
uint64_t * desc_staging
Definition: vulkan.h:128
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:218
FFVkQueueFamilyCtx::actual_queues
int actual_queues
Definition: vulkan.h:101
FFVkQueueCtx::queue
VkQueue queue
Definition: vulkan.h:145
FFVulkanDescriptorSetBinding::elems
uint32_t elems
Definition: vulkan.h:85
FFVulkanContext::output_width
int output_width
Definition: vulkan.h:211
FFVulkanContext::exec_ctx
FFVkExecContext ** exec_ctx
Definition: vulkan.h:221
FFVkQueueCtx::frame_deps
AVFrame ** frame_deps
Definition: vulkan.h:153
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:182
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:167
FFVulkanPipeline::desc_template
VkDescriptorUpdateTemplate * desc_template
Definition: vulkan.h:131
FFVulkanContext::pipelines
FFVulkanPipeline ** pipelines
Definition: vulkan.h:225
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FFVkExecContext::sem_sig_val
uint64_t * sem_sig_val
Definition: vulkan.h:185
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:139
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:143
FFVkSPIRVCompiler::priv
void * priv
Definition: vulkan.h:66
FFVkExecContext::sem_wait_alloc
int sem_wait_alloc
Definition: vulkan.h:172
FFVkExecContext::sem_sig_cnt
int sem_sig_cnt
Definition: vulkan.h:183
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:186
FFVulkanContext
Definition: vulkan.h:192
FFVulkanPipeline::desc_binding
VkDescriptorSetLayoutBinding ** desc_binding
Definition: vulkan.h:130
FFVulkanPipeline
Definition: vulkan.h:104
FFVulkanContext::device
AVHWDeviceContext * device
Definition: vulkan.h:201
usage
const char * usage
Definition: floatimg_cmp.c:60
FFVkQueueCtx::fence
VkFence fence
Definition: vulkan.h:144
FFVulkanPipeline::desc_layout_num
int desc_layout_num
Definition: vulkan.h:133
FFVkExecContext::pool
VkCommandPool pool
Definition: vulkan.h:161
FFVulkanPipeline::total_descriptor_sets
int total_descriptor_sets
Definition: vulkan.h:135
FFVulkanDescriptorSetBinding
Definition: vulkan.h:78
FFVulkanContext::spirv_compiler
FFVkSPIRVCompiler * spirv_compiler
Definition: vulkan.h:208
size
int size
Definition: twinvq_data.h:10344
FFVulkanContext::props
VkPhysicalDeviceProperties props
Definition: vulkan.h:197
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:213
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:158
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:173
FFVkSPIRVCompiler
Definition: vulkan.h:65
FFVkQueueCtx::nb_buf_deps
int nb_buf_deps
Definition: vulkan.h:149
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:140
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:196
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan.h:70
FFVulkanContext::mprops
VkPhysicalDeviceMemoryProperties mprops
Definition: vulkan.h:198
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:132
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:195
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:214
FFVkQueueCtx::frame_deps_alloc_size
int frame_deps_alloc_size
Definition: vulkan.h:155
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:202
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:367
FFVulkanPipeline::descriptor_sets_num
int descriptor_sets_num
Definition: vulkan.h:134
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
FFVkExecContext::bufs
VkCommandBuffer * bufs
Definition: vulkan.h:162
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:175
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:136
FFVulkanContext::frames
AVHWFramesContext * frames
Definition: vulkan.h:205
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:154
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:166
FFVkExecContext::sem_sig_val_dst
uint64_t ** sem_sig_val_dst
Definition: vulkan.h:188
int
int
Definition: ffmpeg_filter.c:156
FFVkExecContext::sem_wait_val_alloc
int sem_wait_val_alloc
Definition: vulkan.h:176
FFVkQueueCtx::buf_deps
AVBufferRef ** buf_deps
Definition: vulkan.h:148
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:229
FFVulkanContext::exec_ctx_num
int exec_ctx_num
Definition: vulkan.h:222
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