FFmpeg
|
#include "pixdesc.h"
#include "bprint.h"
#include "hwcontext.h"
#include "vulkan_functions.h"
#include "hwcontext_vulkan.h"
#include "vulkan_loader.h"
Go to the source code of this file.
Data Structures | |
struct | FFVkSPIRVShader |
struct | FFVkSPIRVCompiler |
struct | FFVkSampler |
struct | FFVulkanDescriptorSetBinding |
struct | FFVkBuffer |
struct | FFVkQueueFamilyCtx |
struct | FFVulkanPipeline |
struct | FFVkQueueCtx |
struct | FFVkExecContext |
struct | FFVulkanContext |
Macros | |
#define | FF_VK_DEFAULT_USAGE_FLAGS |
#define | INDENT(N) INDENT_##N |
#define | INDENT_0 |
#define | INDENT_1 INDENT_0 " " |
#define | INDENT_2 INDENT_1 INDENT_1 |
#define | INDENT_3 INDENT_2 INDENT_1 |
#define | INDENT_4 INDENT_3 INDENT_1 |
#define | INDENT_5 INDENT_4 INDENT_1 |
#define | INDENT_6 INDENT_5 INDENT_1 |
#define | C(N, S) INDENT(N) #S "\n" |
#define | GLSLC(N, S) av_bprintf(&shd->src, C(N, S)) |
#define | GLSLA(...) av_bprintf(&shd->src, __VA_ARGS__) |
#define | GLSLF(N, S, ...) av_bprintf(&shd->src, C(N, S), __VA_ARGS__) |
#define | GLSLD(D) |
#define | RET(x) |
Functions | |
const char * | ff_vk_ret2str (VkResult res) |
Converts Vulkan return values to strings. More... | |
int | ff_vk_mt_is_np_rgb (enum AVPixelFormat pix_fmt) |
Returns 1 if the image is any sort of supported RGB. More... | |
const char * | ff_vk_shader_rep_fmt (enum AVPixelFormat pixfmt) |
Gets the glsl format string for a pixel format. More... | |
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. More... | |
void | ff_vk_qf_rotate (FFVkQueueFamilyCtx *qf) |
Rotate through the queues in a queue family. More... | |
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() More... | |
int | ff_vk_create_imageview (FFVulkanContext *s, FFVkExecContext *e, VkImageView *v, VkImage img, VkFormat fmt, const VkComponentMapping map) |
Create an imageview. More... | |
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. More... | |
FFVulkanPipeline * | ff_vk_create_pipeline (FFVulkanContext *s, FFVkQueueFamilyCtx *qf) |
Inits a pipeline. More... | |
FFVkSPIRVShader * | ff_vk_init_shader (FFVulkanPipeline *pl, const char *name, VkShaderStageFlags stage) |
Inits a shader for a specific pipeline. More... | |
void | ff_vk_set_compute_shader_sizes (FFVkSPIRVShader *shd, int local_size[3]) |
Writes the workgroup size for a shader. More... | |
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. More... | |
int | ff_vk_compile_shader (FFVulkanContext *s, FFVkSPIRVShader *shd, const char *entrypoint) |
Compiles the shader, entrypoint must be set to "main". More... | |
void | ff_vk_print_shader (void *ctx, FFVkSPIRVShader *shd, int prio) |
Pretty print shader, mainly used by shader compilers. More... | |
int | ff_vk_init_pipeline_layout (FFVulkanContext *s, FFVulkanPipeline *pl) |
Initializes the pipeline layout after all shaders and descriptor sets have been finished. More... | |
int | ff_vk_init_compute_pipeline (FFVulkanContext *s, FFVulkanPipeline *pl) |
Initializes a compute pipeline. More... | |
void | ff_vk_update_descriptor_set (FFVulkanContext *s, FFVulkanPipeline *pl, int set_id) |
Updates a descriptor set via the updaters defined. More... | |
int | ff_vk_create_exec_ctx (FFVulkanContext *s, FFVkExecContext **ctx, FFVkQueueFamilyCtx *qf) |
Init an execution context for command recording and queue submission. More... | |
int | ff_vk_start_exec_recording (FFVulkanContext *s, FFVkExecContext *e) |
Begin recording to the command buffer. More... | |
void | ff_vk_bind_pipeline_exec (FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl) |
Add a command to bind the completed pipeline and its descriptor sets. More... | |
void | ff_vk_update_push_exec (FFVulkanContext *s, FFVkExecContext *e, VkShaderStageFlagBits stage, int offset, size_t size, void *src) |
Updates push constants. More... | |
VkCommandBuffer | ff_vk_get_exec_buf (FFVkExecContext *e) |
Gets the command buffer to use for this submission from the exe context. More... | |
int | ff_vk_add_dep_exec_ctx (FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps) |
Adds a generic AVBufferRef as a queue depenency. More... | |
void | ff_vk_discard_exec_deps (FFVkExecContext *e) |
Discards all queue dependencies. More... | |
int | ff_vk_add_exec_dep (FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag) |
Adds a frame as a queue dependency. More... | |
int | ff_vk_submit_exec_queue (FFVulkanContext *s, FFVkExecContext *e) |
Submits a command buffer to the queue for execution. More... | |
int | ff_vk_create_buf (FFVulkanContext *s, FFVkBuffer *buf, size_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags) |
Create a VkBuffer with the specified parameters. More... | |
int | ff_vk_map_buffers (FFVulkanContext *s, FFVkBuffer *buf, uint8_t *mem[], int nb_buffers, int invalidate) |
Maps the buffer to userspace. More... | |
int | ff_vk_unmap_buffers (FFVulkanContext *s, FFVkBuffer *buf, int nb_buffers, int flush) |
Unmaps the buffer from userspace. More... | |
void | ff_vk_free_buf (FFVulkanContext *s, FFVkBuffer *buf) |
Frees a buffer. More... | |
void | ff_vk_uninit (FFVulkanContext *s) |
Frees the main Vulkan context. More... | |
Variables | |
const VkComponentMapping | ff_comp_identity_map |
#define FF_VK_DEFAULT_USAGE_FLAGS |
#define GLSLA | ( | ... | ) | av_bprintf(&shd->src, __VA_ARGS__) |
#define GLSLD | ( | D | ) |
#define RET | ( | x | ) |
const char* ff_vk_ret2str | ( | VkResult | res | ) |
Converts Vulkan return values to strings.
Definition at line 59 of file vulkan.c.
Referenced by ff_vk_add_descriptor_set(), ff_vk_compile_shader(), ff_vk_create_buf(), ff_vk_create_exec_ctx(), ff_vk_create_imageview(), ff_vk_init_compute_pipeline(), ff_vk_init_pipeline_layout(), ff_vk_init_sampler(), ff_vk_map_buffers(), ff_vk_start_exec_recording(), ff_vk_submit_exec_queue(), ff_vk_unmap_buffers(), and vk_alloc_mem().
int ff_vk_mt_is_np_rgb | ( | enum AVPixelFormat | pix_fmt | ) |
Returns 1 if the image is any sort of supported RGB.
Definition at line 709 of file vulkan.c.
Referenced by scale_vulkan_config_output().
const char* ff_vk_shader_rep_fmt | ( | enum AVPixelFormat | pixfmt | ) |
Gets the glsl format string for a pixel format.
Definition at line 721 of file vulkan.c.
Referenced by init_filter().
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.
If nb_queues == 0, use however many queues the queue family has.
Definition at line 96 of file vulkan.c.
Referenced by init_filter().
void ff_vk_qf_rotate | ( | FFVkQueueFamilyCtx * | qf | ) |
Rotate through the queues in a queue family.
Definition at line 132 of file vulkan.c.
Referenced by process_frames().
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 at line 670 of file vulkan.c.
Referenced by init_filter().
int ff_vk_create_imageview | ( | FFVulkanContext * | s, |
FFVkExecContext * | e, | ||
VkImageView * | v, | ||
VkImage | img, | ||
VkFormat | fmt, | ||
const VkComponentMapping | map | ||
) |
Create an imageview.
Guaranteed to remain alive until the queue submission has finished executing, and will be destroyed after that.
Definition at line 742 of file vulkan.c.
Referenced by process_frames().
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.
Must be called before the pipeline layout has been initialized.
Definition at line 364 of file vulkan.c.
Referenced by init_filter().
FFVulkanPipeline* ff_vk_create_pipeline | ( | FFVulkanContext * | s, |
FFVkQueueFamilyCtx * | qf | ||
) |
Inits a pipeline.
Everything in it will be auto-freed when calling ff_vk_filter_uninit().
Definition at line 1220 of file vulkan.c.
Referenced by init_filter().
FFVkSPIRVShader* ff_vk_init_shader | ( | FFVulkanPipeline * | pl, |
const char * | name, | ||
VkShaderStageFlags | stage | ||
) |
Inits a shader for a specific pipeline.
Will be auto-freed on uninit.
Definition at line 795 of file vulkan.c.
Referenced by init_filter().
void ff_vk_set_compute_shader_sizes | ( | FFVkSPIRVShader * | shd, |
int | local_size[3] | ||
) |
Writes the workgroup size for a shader.
Definition at line 816 of file vulkan.c.
Referenced by init_filter().
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 at line 923 of file vulkan.c.
Referenced by init_filter(), and init_gblur_pipeline().
int ff_vk_compile_shader | ( | FFVulkanContext * | s, |
FFVkSPIRVShader * | shd, | ||
const char * | entrypoint | ||
) |
Compiles the shader, entrypoint must be set to "main".
Definition at line 849 of file vulkan.c.
Referenced by init_filter(), and init_gblur_pipeline().
void ff_vk_print_shader | ( | void * | ctx, |
FFVkSPIRVShader * | shd, | ||
int | prio | ||
) |
Pretty print shader, mainly used by shader compilers.
Definition at line 827 of file vulkan.c.
Referenced by glslc_shader_compile(), and shdc_shader_compile().
int ff_vk_init_pipeline_layout | ( | FFVulkanContext * | s, |
FFVulkanPipeline * | pl | ||
) |
Initializes the pipeline layout after all shaders and descriptor sets have been finished.
Definition at line 1116 of file vulkan.c.
Referenced by init_filter(), and init_gblur_pipeline().
int ff_vk_init_compute_pipeline | ( | FFVulkanContext * | s, |
FFVulkanPipeline * | pl | ||
) |
Initializes a compute pipeline.
Will pick the first shader with the COMPUTE flag set.
Definition at line 1229 of file vulkan.c.
Referenced by init_filter(), and init_gblur_pipeline().
void ff_vk_update_descriptor_set | ( | FFVulkanContext * | s, |
FFVulkanPipeline * | pl, | ||
int | set_id | ||
) |
Updates a descriptor set via the updaters defined.
Can be called immediately after pipeline creation, but must be called at least once before queue submission.
Definition at line 1080 of file vulkan.c.
Referenced by init_filter(), init_gblur_pipeline(), and process_frames().
int ff_vk_create_exec_ctx | ( | FFVulkanContext * | s, |
FFVkExecContext ** | ctx, | ||
FFVkQueueFamilyCtx * | qf | ||
) |
Init an execution context for command recording and queue submission.
WIll be auto-freed on uninit.
Definition at line 385 of file vulkan.c.
Referenced by init_filter().
int ff_vk_start_exec_recording | ( | FFVulkanContext * | s, |
FFVkExecContext * | e | ||
) |
Begin recording to the command buffer.
Previous execution must have been completed, which ff_vk_submit_exec_queue() will ensure.
Definition at line 463 of file vulkan.c.
Referenced by process_frames().
void ff_vk_bind_pipeline_exec | ( | FFVulkanContext * | s, |
FFVkExecContext * | e, | ||
FFVulkanPipeline * | pl | ||
) |
Add a command to bind the completed pipeline and its descriptor sets.
Must be called after ff_vk_start_exec_recording() and before submission.
Definition at line 1264 of file vulkan.c.
Referenced by process_frames().
void ff_vk_update_push_exec | ( | FFVulkanContext * | s, |
FFVkExecContext * | e, | ||
VkShaderStageFlagBits | stage, | ||
int | offset, | ||
size_t | size, | ||
void * | src | ||
) |
Updates push constants.
Must be called after binding a pipeline if any push constants were defined.
Definition at line 1106 of file vulkan.c.
Referenced by process_frames().
VkCommandBuffer ff_vk_get_exec_buf | ( | FFVkExecContext * | e | ) |
Gets the command buffer to use for this submission from the exe context.
Definition at line 504 of file vulkan.c.
Referenced by process_frames().
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 at line 639 of file vulkan.c.
Referenced by ff_vk_create_imageview().
void ff_vk_discard_exec_deps | ( | FFVkExecContext * | e | ) |
Discards all queue dependencies.
Definition at line 447 of file vulkan.c.
Referenced by ff_vk_add_dep_exec_ctx(), ff_vk_add_exec_dep(), ff_vk_start_exec_recording(), and process_frames().
int ff_vk_add_exec_dep | ( | FFVulkanContext * | s, |
FFVkExecContext * | e, | ||
AVFrame * | frame, | ||
VkPipelineStageFlagBits | in_wait_dst_flag | ||
) |
Adds a frame as a queue dependency.
This also manages semaphore signalling. Must be called before submission.
Definition at line 509 of file vulkan.c.
Referenced by process_frames().
int ff_vk_submit_exec_queue | ( | FFVulkanContext * | s, |
FFVkExecContext * | e | ||
) |
Submits a command buffer to the queue for execution.
Will block until execution has finished in order to simplify resource management.
Definition at line 590 of file vulkan.c.
Referenced by process_frames().
int ff_vk_create_buf | ( | FFVulkanContext * | s, |
FFVkBuffer * | buf, | ||
size_t | size, | ||
VkBufferUsageFlags | usage, | ||
VkMemoryPropertyFlagBits | flags | ||
) |
Create a VkBuffer with the specified parameters.
Definition at line 193 of file vulkan.c.
Referenced by init_filter(), and init_gblur_pipeline().
int ff_vk_map_buffers | ( | FFVulkanContext * | s, |
FFVkBuffer * | buf, | ||
uint8_t * | mem[], | ||
int | nb_buffers, | ||
int | invalidate | ||
) |
Maps the buffer to userspace.
Set invalidate to 1 if reading the contents is necessary.
Definition at line 258 of file vulkan.c.
Referenced by init_filter(), and init_gblur_pipeline().
int ff_vk_unmap_buffers | ( | FFVulkanContext * | s, |
FFVkBuffer * | buf, | ||
int | nb_buffers, | ||
int | flush | ||
) |
Unmaps the buffer from userspace.
Set flush to 1 to write and sync.
Definition at line 307 of file vulkan.c.
Referenced by init_filter(), and init_gblur_pipeline().
void ff_vk_free_buf | ( | FFVulkanContext * | s, |
FFVkBuffer * | buf | ||
) |
Frees a buffer.
Definition at line 349 of file vulkan.c.
Referenced by gblur_vulkan_uninit(), overlay_vulkan_uninit(), and scale_vulkan_uninit().
void ff_vk_uninit | ( | FFVulkanContext * | s | ) |
Frees the main Vulkan context.
Definition at line 1379 of file vulkan.c.
Referenced by avgblur_vulkan_uninit(), chromaber_vulkan_uninit(), flip_vulkan_uninit(), gblur_vulkan_uninit(), libplacebo_uninit(), overlay_vulkan_uninit(), scale_vulkan_uninit(), transpose_vulkan_uninit(), and uninit().
const VkComponentMapping ff_comp_identity_map |
Definition at line 51 of file vulkan.c.
Referenced by process_frames().