1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

lavfi: add Vulkan filtering framework

This commit adds a Vulkan filtering infrastructure for libavfilter.
It attempts to abstract as much as possible of the Vulkan API from filters.

The way the hwcontext and the framework are designed permits for parallel,
non-CPU-blocking filtering throughout, with the exception of up/downloading
and mapping.
This commit is contained in:
Lynne 2019-10-27 14:44:00 +00:00
parent 88d2ccbe93
commit 6fca61bbc9
6 changed files with 1864 additions and 5 deletions

13
configure vendored
View File

@ -236,6 +236,7 @@ External library support:
--enable-libfontconfig enable libfontconfig, useful for drawtext filter [no]
--enable-libfreetype enable libfreetype, needed for drawtext filter [no]
--enable-libfribidi enable libfribidi, improves drawtext filter [no]
--enable-libglslang enable GLSL->SPIRV compilation via libglslang [no]
--enable-libgme enable Game Music Emu via libgme [no]
--enable-libgsm enable GSM de/encoding via libgsm [no]
--enable-libiec61883 enable iec61883 via libiec61883 [no]
@ -1550,11 +1551,11 @@ require_cc(){
}
require_cpp(){
name="$1"
headers="$2"
classes="$3"
shift 3
check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
log require_cpp "$@"
name_version="$1"
name="${1%% *}"
shift
check_lib_cpp "$name" "$@" || die "ERROR: $name_version not found"
}
require_headers(){
@ -1771,6 +1772,7 @@ EXTERNAL_LIBRARY_LIST="
libfontconfig
libfreetype
libfribidi
libglslang
libgme
libgsm
libiec61883
@ -6261,6 +6263,7 @@ enabled fontconfig && enable libfontconfig
enabled libfontconfig && require_pkg_config libfontconfig fontconfig "fontconfig/fontconfig.h" FcInit
enabled libfreetype && require_pkg_config libfreetype freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType
enabled libfribidi && require_pkg_config libfribidi fribidi fribidi.h fribidi_version_info
enabled libglslang && require_cpp libglslang glslang/SPIRV/GlslangToSpv.h "glslang::TIntermediate*" -lglslang -lOSDependent -lHLSL -lOGLCompiler -lSPVRemapper -lSPIRV -lSPIRV-Tools -lSPIRV-Tools-opt -lpthread -lstdc++
enabled libgme && { check_pkg_config libgme libgme gme/gme.h gme_new_emu ||
require libgme gme/gme.h gme_new_emu -lgme -lstdc++; }
enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do

View File

@ -510,6 +510,8 @@ SKIPHEADERS-$(CONFIG_QSVVPP) += qsvvpp.h
SKIPHEADERS-$(CONFIG_OPENCL) += opencl.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_vpp.h
OBJS-$(CONFIG_LIBGLSLANG) += glslang.o
TOOLS = graph2dot
TESTPROGS = drawutils filtfmts formats integral

243
libavfilter/glslang.cpp Normal file
View File

@ -0,0 +1,243 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <pthread.h>
extern "C" {
#include "libavutil/mem.h"
#include "libavutil/avassert.h"
}
#include <glslang/Include/ResourceLimits.h>
#include <glslang/Include/revision.h>
#include <glslang/Public/ShaderLang.h>
#include <glslang/SPIRV/GlslangToSpv.h>
#include "glslang.h"
using namespace glslang;
static pthread_mutex_t glslang_mutex = PTHREAD_MUTEX_INITIALIZER;
static int glslang_refcount = 0;
/* We require Vulkan 1.1 */
#define GLSL_VERSION EShTargetVulkan_1_1
/* Vulkan 1.1 implementations require SPIR-V 1.3 to be implemented */
#define SPIRV_VERSION EShTargetSpv_1_3
// Taken from glslang's examples, which apparently generally bases the choices
// on OpenGL specification limits
static const TBuiltInResource DefaultTBuiltInResource = {
/* .MaxLights = */ 32,
/* .MaxClipPlanes = */ 6,
/* .MaxTextureUnits = */ 32,
/* .MaxTextureCoords = */ 32,
/* .MaxVertexAttribs = */ 64,
/* .MaxVertexUniformComponents = */ 4096,
/* .MaxVaryingFloats = */ 64,
/* .MaxVertexTextureImageUnits = */ 32,
/* .MaxCombinedTextureImageUnits = */ 80,
/* .MaxTextureImageUnits = */ 32,
/* .MaxFragmentUniformComponents = */ 4096,
/* .MaxDrawBuffers = */ 32,
/* .MaxVertexUniformVectors = */ 128,
/* .MaxVaryingVectors = */ 8,
/* .MaxFragmentUniformVectors = */ 16,
/* .MaxVertexOutputVectors = */ 16,
/* .MaxFragmentInputVectors = */ 15,
/* .MinProgramTexelOffset = */ -8,
/* .MaxProgramTexelOffset = */ 7,
/* .MaxClipDistances = */ 8,
/* .MaxComputeWorkGroupCountX = */ 65535,
/* .MaxComputeWorkGroupCountY = */ 65535,
/* .MaxComputeWorkGroupCountZ = */ 65535,
/* .MaxComputeWorkGroupSizeX = */ 1024,
/* .MaxComputeWorkGroupSizeY = */ 1024,
/* .MaxComputeWorkGroupSizeZ = */ 64,
/* .MaxComputeUniformComponents = */ 1024,
/* .MaxComputeTextureImageUnits = */ 16,
/* .MaxComputeImageUniforms = */ 8,
/* .MaxComputeAtomicCounters = */ 8,
/* .MaxComputeAtomicCounterBuffers = */ 1,
/* .MaxVaryingComponents = */ 60,
/* .MaxVertexOutputComponents = */ 64,
/* .MaxGeometryInputComponents = */ 64,
/* .MaxGeometryOutputComponents = */ 128,
/* .MaxFragmentInputComponents = */ 128,
/* .MaxImageUnits = */ 8,
/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 8,
/* .MaxCombinedShaderOutputResources = */ 8,
/* .MaxImageSamples = */ 0,
/* .MaxVertexImageUniforms = */ 0,
/* .MaxTessControlImageUniforms = */ 0,
/* .MaxTessEvaluationImageUniforms = */ 0,
/* .MaxGeometryImageUniforms = */ 0,
/* .MaxFragmentImageUniforms = */ 8,
/* .MaxCombinedImageUniforms = */ 8,
/* .MaxGeometryTextureImageUnits = */ 16,
/* .MaxGeometryOutputVertices = */ 256,
/* .MaxGeometryTotalOutputComponents = */ 1024,
/* .MaxGeometryUniformComponents = */ 1024,
/* .MaxGeometryVaryingComponents = */ 64,
/* .MaxTessControlInputComponents = */ 128,
/* .MaxTessControlOutputComponents = */ 128,
/* .MaxTessControlTextureImageUnits = */ 16,
/* .MaxTessControlUniformComponents = */ 1024,
/* .MaxTessControlTotalOutputComponents = */ 4096,
/* .MaxTessEvaluationInputComponents = */ 128,
/* .MaxTessEvaluationOutputComponents = */ 128,
/* .MaxTessEvaluationTextureImageUnits = */ 16,
/* .MaxTessEvaluationUniformComponents = */ 1024,
/* .MaxTessPatchComponents = */ 120,
/* .MaxPatchVertices = */ 32,
/* .MaxTessGenLevel = */ 64,
/* .MaxViewports = */ 16,
/* .MaxVertexAtomicCounters = */ 0,
/* .MaxTessControlAtomicCounters = */ 0,
/* .MaxTessEvaluationAtomicCounters = */ 0,
/* .MaxGeometryAtomicCounters = */ 0,
/* .MaxFragmentAtomicCounters = */ 8,
/* .MaxCombinedAtomicCounters = */ 8,
/* .MaxAtomicCounterBindings = */ 1,
/* .MaxVertexAtomicCounterBuffers = */ 0,
/* .MaxTessControlAtomicCounterBuffers = */ 0,
/* .MaxTessEvaluationAtomicCounterBuffers = */ 0,
/* .MaxGeometryAtomicCounterBuffers = */ 0,
/* .MaxFragmentAtomicCounterBuffers = */ 1,
/* .MaxCombinedAtomicCounterBuffers = */ 1,
/* .MaxAtomicCounterBufferSize = */ 16384,
/* .MaxTransformFeedbackBuffers = */ 4,
/* .MaxTransformFeedbackInterleavedComponents = */ 64,
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 4,
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
/* .maxMeshWorkGroupSizeY_NV = */ 1,
/* .maxMeshWorkGroupSizeZ_NV = */ 1,
/* .maxTaskWorkGroupSizeX_NV = */ 32,
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
.limits = {
/* .nonInductiveForLoops = */ 1,
/* .whileLoops = */ 1,
/* .doWhileLoops = */ 1,
/* .generalUniformIndexing = */ 1,
/* .generalAttributeMatrixVectorIndexing = */ 1,
/* .generalVaryingIndexing = */ 1,
/* .generalSamplerIndexing = */ 1,
/* .generalVariableIndexing = */ 1,
/* .generalConstantMatrixVectorIndexing = */ 1,
}
};
GLSlangResult *glslang_compile(const char *glsl, enum GLSlangStage stage)
{
GLSlangResult *res = (GLSlangResult *)av_mallocz(sizeof(*res));
if (!res)
return NULL;
static const EShLanguage lang[] = {
[GLSLANG_VERTEX] = EShLangVertex,
[GLSLANG_FRAGMENT] = EShLangFragment,
[GLSLANG_COMPUTE] = EShLangCompute,
};
assert(glslang_refcount);
TShader *shader = new TShader(lang[stage]);
if (!shader) {
res->rval = AVERROR(ENOMEM);
return res;
}
shader->setEnvClient(EShClientVulkan, GLSL_VERSION);
shader->setEnvTarget(EShTargetSpv, SPIRV_VERSION);
shader->setStrings(&glsl, 1);
if (!shader->parse(&DefaultTBuiltInResource, GLSL_VERSION, true, EShMsgDefault)) {
res->error_msg = av_strdup(shader->getInfoLog());
res->rval = AVERROR_EXTERNAL;
delete shader;
return res;
}
TProgram *prog = new TProgram();
if (!prog) {
res->rval = AVERROR(ENOMEM);
delete shader;
return res;
}
prog->addShader(shader);
if (!prog->link(EShMsgDefault)) {
res->error_msg = av_strdup(prog->getInfoLog());
res->rval = AVERROR_EXTERNAL;
delete shader;
delete prog;
return res;
}
std::vector<unsigned int> spirv; /* Result */
SpvOptions options; /* Options - by default all optimizations are off */
options.generateDebugInfo = false; /* Makes sense for files but not here */
options.disassemble = false; /* Will print disassembly on compilation */
options.validate = false; /* Validates the generated SPIRV, unneeded */
options.disableOptimizer = false; /* For debugging */
options.optimizeSize = true; /* Its faster */
GlslangToSpv(*prog->getIntermediate(lang[stage]), spirv, NULL, &options);
res->size = spirv.size()*sizeof(unsigned int);
res->data = av_memdup(spirv.data(), res->size);
if (!res->data) {
res->rval = AVERROR(ENOMEM);
delete shader;
delete prog;
return res;
}
delete shader;
delete prog;
return res;
}
int glslang_init(void)
{
int ret = 0;
pthread_mutex_lock(&glslang_mutex);
if (glslang_refcount++ == 0)
ret = !InitializeProcess();
pthread_mutex_unlock(&glslang_mutex);
return ret;
}
void glslang_uninit(void)
{
pthread_mutex_lock(&glslang_mutex);
av_assert0(glslang_refcount > 0);
if (--glslang_refcount == 0)
FinalizeProcess();
pthread_mutex_unlock(&glslang_mutex);
}

52
libavfilter/glslang.h Normal file
View File

@ -0,0 +1,52 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVFILTER_GLSLANG_H
#define AVFILTER_GLSLANG_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
int glslang_init(void);
void glslang_uninit(void);
typedef struct GLSlangResult {
int rval;
char *error_msg;
void *data; /* Shader data or NULL */
size_t size;
} GLSlangResult;
enum GLSlangStage {
GLSLANG_VERTEX,
GLSLANG_FRAGMENT,
GLSLANG_COMPUTE,
};
/* Compile GLSL into a SPIRV stream, if possible */
GLSlangResult *glslang_compile(const char *glsl, enum GLSlangStage stage);
#ifdef __cplusplus
}
#endif
#endif /* AVFILTER_GLSLANG_H */

1236
libavfilter/vulkan.c Normal file

File diff suppressed because it is too large Load Diff

323
libavfilter/vulkan.h Normal file
View File

@ -0,0 +1,323 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVFILTER_VULKAN_H
#define AVFILTER_VULKAN_H
#include "avfilter.h"
#include "libavutil/pixdesc.h"
#include "libavutil/bprint.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_vulkan.h"
/* GLSL management macros */
#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) GLSLC(0, ); \
av_bprint_append_data(&shd->src, D, strlen(D)); \
GLSLC(0, )
/* Helper, pretty much every Vulkan return value needs to be checked */
#define RET(x) \
do { \
if ((err = (x)) < 0) \
goto fail; \
} while (0)
/* Useful for attaching immutable samplers to arrays */
#define DUP_SAMPLER_ARRAY4(x) (VkSampler []){ x, x, x, x, }
typedef struct SPIRVShader {
const char *name; /* Name for id/debugging purposes */
AVBPrint src;
int local_size[3]; /* Compute shader workgroup sizes */
VkPipelineShaderStageCreateInfo shader;
} SPIRVShader;
typedef struct VulkanDescriptorSetBinding {
const char *name;
VkDescriptorType type;
const char *mem_layout; /* Storage images (rgba8, etc.) and buffers (std430, etc.) */
const char *mem_quali; /* readonly, writeonly, etc. */
const char *buf_content; /* For buffers */
uint32_t dimensions; /* Needed for e.g. sampler%iD */
uint32_t elems; /* 0 - scalar, 1 or more - vector */
VkShaderStageFlags stages;
const VkSampler *samplers; /* Immutable samplers, length - #elems */
void *updater; /* Pointer to VkDescriptor*Info */
} VulkanDescriptorSetBinding;
typedef struct FFVkBuffer {
VkBuffer buf;
VkDeviceMemory mem;
VkMemoryPropertyFlagBits flags;
} FFVkBuffer;
typedef struct VulkanPipeline {
VkPipelineBindPoint bind_point;
/* Contexts */
VkPipelineLayout pipeline_layout;
VkPipeline pipeline;
/* Shaders */
SPIRVShader **shaders;
int shaders_num;
/* Push consts */
VkPushConstantRange *push_consts;
int push_consts_num;
/* Descriptors */
VkDescriptorSetLayout *desc_layout;
VkDescriptorPool desc_pool;
VkDescriptorSet *desc_set;
VkDescriptorUpdateTemplate *desc_template;
int descriptor_sets_num;
int pool_size_desc_num;
/* Temporary, used to store data in between initialization stages */
VkDescriptorUpdateTemplateCreateInfo *desc_template_info;
VkDescriptorPoolSize *pool_size_desc;
} VulkanPipeline;
typedef struct FFVkExecContext {
VkCommandPool pool;
VkCommandBuffer buf;
VkQueue queue;
VkFence fence;
VulkanPipeline *bound_pl;
VkSemaphore *sem_wait;
int sem_wait_alloc; /* Allocated sem_wait */
int sem_wait_cnt;
VkPipelineStageFlagBits *sem_wait_dst;
int sem_wait_dst_alloc; /* Allocated sem_wait_dst */
VkSemaphore *sem_sig;
int sem_sig_alloc; /* Allocated sem_sig */
int sem_sig_cnt;
} FFVkExecContext;
typedef struct VulkanFilterContext {
const AVClass *class;
AVBufferRef *device_ref;
AVBufferRef *frames_ref; /* For in-place filtering */
AVHWDeviceContext *device;
AVVulkanDeviceContext *hwctx;
/* Properties */
int output_width;
int output_height;
enum AVPixelFormat output_format;
enum AVPixelFormat input_format;
/* Samplers */
VkSampler **samplers;
int samplers_num;
/* Exec contexts */
FFVkExecContext **exec_ctx;
int exec_ctx_num;
/* Pipelines (each can have 1 shader of each type) */
VulkanPipeline **pipelines;
int pipelines_num;
void *scratch; /* Scratch memory used only in functions */
unsigned int scratch_size;
} VulkanFilterContext;
/* Identity mapping - r = r, b = b, g = g, a = a */
extern const VkComponentMapping ff_comp_identity_map;
/**
* General lavfi IO functions
*/
int ff_vk_filter_query_formats (AVFilterContext *avctx);
int ff_vk_filter_init (AVFilterContext *avctx);
int ff_vk_filter_config_input (AVFilterLink *inlink);
int ff_vk_filter_config_output (AVFilterLink *outlink);
int ff_vk_filter_config_output_inplace(AVFilterLink *outlink);
void ff_vk_filter_uninit (AVFilterContext *avctx);
/**
* Converts Vulkan return values to strings
*/
const char *ff_vk_ret2str(VkResult res);
/**
* Gets the glsl format string for a pixel format
*/
const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt);
/**
* Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
*/
VkSampler *ff_vk_init_sampler(AVFilterContext *avctx, int unnorm_coords,
VkFilter filt);
/**
* Create an imageview.
*/
int ff_vk_create_imageview(AVFilterContext *avctx, VkImageView *v, VkImage img,
VkFormat fmt, const VkComponentMapping map);
/**
* Destroy an imageview. Command buffer must have completed executing, which
* ff_vk_submit_exec_queue() will ensure
*/
void ff_vk_destroy_imageview(AVFilterContext *avctx, VkImageView *v);
/**
* Define a push constant for a given stage into a pipeline.
* Must be called before the pipeline layout has been initialized.
*/
int ff_vk_add_push_constant(AVFilterContext *avctx, VulkanPipeline *pl,
int offset, int size, VkShaderStageFlagBits stage);
/**
* Inits a pipeline. Everything in it will be auto-freed when calling
* ff_vk_filter_uninit().
*/
VulkanPipeline *ff_vk_create_pipeline(AVFilterContext *avctx);
/**
* Inits a shader for a specific pipeline. Will be auto-freed on uninit.
*/
SPIRVShader *ff_vk_init_shader(AVFilterContext *avctx, VulkanPipeline *pl,
const char *name, VkShaderStageFlags stage);
/**
* Writes the workgroup size for a shader.
*/
void ff_vk_set_compute_shader_sizes(AVFilterContext *avctx, SPIRVShader *shd,
int local_size[3]);
/**
* Adds a descriptor set to the shader and registers them in the pipeline.
*/
int ff_vk_add_descriptor_set(AVFilterContext *avctx, VulkanPipeline *pl,
SPIRVShader *shd, VulkanDescriptorSetBinding *desc,
int num, int only_print_to_shader);
/**
* Compiles the shader, entrypoint must be set to "main".
*/
int ff_vk_compile_shader(AVFilterContext *avctx, SPIRVShader *shd,
const char *entrypoint);
/**
* Initializes the pipeline layout after all shaders and descriptor sets have
* been finished.
*/
int ff_vk_init_pipeline_layout(AVFilterContext *avctx, VulkanPipeline *pl);
/**
* Initializes a compute pipeline. Will pick the first shader with the
* COMPUTE flag set.
*/
int ff_vk_init_compute_pipeline(AVFilterContext *avctx, VulkanPipeline *pl);
/**
* 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.
*/
void ff_vk_update_descriptor_set(AVFilterContext *avctx, VulkanPipeline *pl,
int set_id);
/**
* Init an execution context for command recording and queue submission.
* WIll be auto-freed on uninit.
*/
int ff_vk_create_exec_ctx(AVFilterContext *avctx, FFVkExecContext **ctx, int queue);
/**
* Begin recording to the command buffer. Previous execution must have been
* completed, which ff_vk_submit_exec_queue() will ensure.
*/
int ff_vk_start_exec_recording(AVFilterContext *avctx, FFVkExecContext *e);
/**
* Add a command to bind the completed pipeline and its descriptor sets.
* Must be called after ff_vk_start_exec_recording() and before submission.
*/
void ff_vk_bind_pipeline_exec(AVFilterContext *avctx, FFVkExecContext *e,
VulkanPipeline *pl);
/**
* Updates push constants.
* Must be called after binding a pipeline if any push constants were defined.
*/
void ff_vk_update_push_exec(AVFilterContext *avctx, FFVkExecContext *e,
VkShaderStageFlagBits stage, int offset,
size_t size, void *src);
/**
* Adds a frame as a queue dependency. This manages semaphore signalling.
* Must be called before submission.
*/
int ff_vk_add_exec_dep(AVFilterContext *avctx, FFVkExecContext *e,
AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag);
/**
* Submits a command buffer to the queue for execution.
* Will block until execution has finished in order to simplify resource
* management.
*/
int ff_vk_submit_exec_queue(AVFilterContext *avctx, FFVkExecContext *e);
/**
* Create a VkBuffer with the specified parameters.
*/
int ff_vk_create_buf(AVFilterContext *avctx, FFVkBuffer *buf, size_t size,
VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags);
/**
* Maps the buffer to userspace. Set invalidate to 1 if reading the contents
* is necessary.
*/
int ff_vk_map_buffers(AVFilterContext *avctx, FFVkBuffer *buf, uint8_t *mem[],
int nb_buffers, int invalidate);
/**
* Unmaps the buffer from userspace. Set flush to 1 to write and sync.
*/
int ff_vk_unmap_buffers(AVFilterContext *avctx, FFVkBuffer *buf, int nb_buffers,
int flush);
/**
* Frees a buffer.
*/
void ff_vk_free_buf(AVFilterContext *avctx, FFVkBuffer *buf);
#endif /* AVFILTER_VULKAN_H */