Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
05ce6473
Unverified
Commit
05ce6473
authored
Feb 17, 2023
by
Lynne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi: add lavfi-only Vulkan infrastructure
parent
51b7fe81
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
473 additions
and
124 deletions
+473
-124
Makefile
libavfilter/Makefile
+6
-0
vulkan_filter.c
libavfilter/vulkan_filter.c
+371
-109
vulkan_filter.h
libavfilter/vulkan_filter.h
+35
-4
vulkan_glslang.c
libavfilter/vulkan_glslang.c
+11
-8
vulkan_shaderc.c
libavfilter/vulkan_shaderc.c
+5
-3
vulkan_spirv.h
libavfilter/vulkan_spirv.h
+45
-0
No files found.
libavfilter/Makefile
View file @
05ce6473
...
...
@@ -623,6 +623,10 @@ OBJS-$(CONFIG_AVSYNCTEST_FILTER) += src_avsynctest.o
OBJS-$(CONFIG_AMOVIE_FILTER)
+=
src_movie.o
OBJS-$(CONFIG_MOVIE_FILTER)
+=
src_movie.o
# vulkan libs
OBJS-$(CONFIG_LIBGLSLANG)
+=
vulkan_glslang.o
OBJS-$(CONFIG_LIBSHADERC)
+=
vulkan_shaderc.o
# Objects duplicated from other libraries for shared builds
SHLIBOBJS
+=
log2_tab.o
...
...
@@ -636,6 +640,8 @@ SKIPHEADERS-$(CONFIG_QSVVPP) += qsvvpp.h stack_internal.h
SKIPHEADERS-$(CONFIG_OPENCL)
+=
opencl.h
SKIPHEADERS-$(CONFIG_VAAPI)
+=
vaapi_vpp.h
stack_internal.h
SKIPHEADERS-$(CONFIG_VULKAN)
+=
vulkan.h
vulkan_filter.h
SKIPHEADERS-$(CONFIG_LIBSHADERC)
+=
vulkan_spirv.h
SKIPHEADERS-$(CONFIG_LIBGLSLANG)
+=
vulkan_spirv.h
TOOLS
=
graph2dot
TESTPROGS
=
drawutils filtfmts formats integral
...
...
libavfilter/vulkan_filter.c
View file @
05ce6473
This diff is collapsed.
Click to expand it.
libavfilter/vulkan_filter.h
View file @
05ce6473
/*
* Copyright (c) Lynne
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
...
...
@@ -26,9 +28,38 @@
/**
* General lavfi IO functions
*/
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
);
int
ff_vk_filter_init
(
AVFilterContext
*
avctx
);
int
ff_vk_filter_config_input
(
AVFilterLink
*
inlink
);
int
ff_vk_filter_config_output
(
AVFilterLink
*
outlink
);
/**
* Can be called manually, if not using ff_vk_filter_config_output.
*/
int
ff_vk_filter_init_context
(
AVFilterContext
*
avctx
,
FFVulkanContext
*
s
,
AVBufferRef
*
frames_ref
,
int
width
,
int
height
,
enum
AVPixelFormat
sw_format
);
/**
* Submit a compute shader with a zero/one input and single out for execution.
*/
int
ff_vk_filter_process_simple
(
FFVulkanContext
*
vkctx
,
FFVkExecPool
*
e
,
FFVulkanPipeline
*
pl
,
AVFrame
*
out_f
,
AVFrame
*
in_f
,
VkSampler
sampler
,
void
*
push_src
,
size_t
push_size
);
/**
* Submit a compute shader with a single in and single out with 2 stages.
*/
int
ff_vk_filter_process_2pass
(
FFVulkanContext
*
vkctx
,
FFVkExecPool
*
e
,
FFVulkanPipeline
*
pls
[
2
],
AVFrame
*
out
,
AVFrame
*
tmp
,
AVFrame
*
in
,
VkSampler
sampler
,
void
*
push_src
,
size_t
push_size
);
/**
* Up to 16 inputs, one output
*/
int
ff_vk_filter_process_Nin
(
FFVulkanContext
*
vkctx
,
FFVkExecPool
*
e
,
FFVulkanPipeline
*
pl
,
AVFrame
*
out
,
AVFrame
*
in
[],
int
nb_in
,
VkSampler
sampler
,
void
*
push_src
,
size_t
push_size
);
#endif
/* AVFILTER_VULKAN_FILTER_H */
libav
util
/vulkan_glslang.c
→
libav
filter
/vulkan_glslang.c
View file @
05ce6473
...
...
@@ -21,8 +21,9 @@
#include <glslang/build_info.h>
#include <glslang/Include/glslang_c_interface.h>
#include "mem.h"
#include "avassert.h"
#include "vulkan_spirv.h"
#include "libavutil/mem.h"
#include "libavutil/avassert.h"
static
pthread_mutex_t
glslc_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
int
glslc_refcount
=
0
;
...
...
@@ -176,11 +177,13 @@ static int glslc_shader_compile(FFVkSPIRVCompiler *ctx, void *avctx,
av_assert0
(
glslc_refcount
);
*
opaque
=
NULL
;
if
(
!
(
glslc_shader
=
glslang_shader_create
(
&
glslc_input
)))
return
AVERROR
(
ENOMEM
);
if
(
!
glslang_shader_preprocess
(
glslc_shader
,
&
glslc_input
))
{
ff_vk_
print_shader
(
avctx
,
shd
,
AV_LOG_WARNING
);
ff_vk_
shader_print
(
avctx
,
shd
,
AV_LOG_WARNING
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Unable to preprocess shader: %s (%s)!
\n
"
,
glslang_shader_get_info_log
(
glslc_shader
),
glslang_shader_get_info_debug_log
(
glslc_shader
));
...
...
@@ -189,7 +192,7 @@ static int glslc_shader_compile(FFVkSPIRVCompiler *ctx, void *avctx,
}
if
(
!
glslang_shader_parse
(
glslc_shader
,
&
glslc_input
))
{
ff_vk_
print_shader
(
avctx
,
shd
,
AV_LOG_WARNING
);
ff_vk_
shader_print
(
avctx
,
shd
,
AV_LOG_WARNING
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Unable to parse shader: %s (%s)!
\n
"
,
glslang_shader_get_info_log
(
glslc_shader
),
glslang_shader_get_info_debug_log
(
glslc_shader
));
...
...
@@ -206,7 +209,7 @@ static int glslc_shader_compile(FFVkSPIRVCompiler *ctx, void *avctx,
if
(
!
glslang_program_link
(
glslc_program
,
GLSLANG_MSG_SPV_RULES_BIT
|
GLSLANG_MSG_VULKAN_RULES_BIT
))
{
ff_vk_
print_shader
(
avctx
,
shd
,
AV_LOG_WARNING
);
ff_vk_
shader_print
(
avctx
,
shd
,
AV_LOG_WARNING
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Unable to link shader: %s (%s)!
\n
"
,
glslang_program_get_info_log
(
glslc_program
),
glslang_program_get_info_debug_log
(
glslc_program
));
...
...
@@ -219,10 +222,10 @@ static int glslc_shader_compile(FFVkSPIRVCompiler *ctx, void *avctx,
messages
=
glslang_program_SPIRV_get_messages
(
glslc_program
);
if
(
messages
)
{
ff_vk_
print_shader
(
avctx
,
shd
,
AV_LOG_WARNING
);
ff_vk_
shader_print
(
avctx
,
shd
,
AV_LOG_WARNING
);
av_log
(
avctx
,
AV_LOG_WARNING
,
"%s
\n
"
,
messages
);
}
else
{
ff_vk_
print_shader
(
avctx
,
shd
,
AV_LOG_VERBOSE
);
ff_vk_
shader_print
(
avctx
,
shd
,
AV_LOG_VERBOSE
);
}
glslang_shader_delete
(
glslc_shader
);
...
...
@@ -257,7 +260,7 @@ static void glslc_uninit(FFVkSPIRVCompiler **ctx)
av_freep
(
ctx
);
}
static
FFVkSPIRVCompiler
*
ff_vk_glslang_init
(
void
)
FFVkSPIRVCompiler
*
ff_vk_glslang_init
(
void
)
{
FFVkSPIRVCompiler
*
ret
=
av_mallocz
(
sizeof
(
*
ret
));
if
(
!
ret
)
...
...
libav
util
/vulkan_shaderc.c
→
libav
filter
/vulkan_shaderc.c
View file @
05ce6473
...
...
@@ -18,7 +18,8 @@
#include <shaderc/shaderc.h>
#include "mem.h"
#include "libavutil/mem.h"
#include "vulkan_spirv.h"
static
int
shdc_shader_compile
(
FFVkSPIRVCompiler
*
ctx
,
void
*
avctx
,
FFVkSPIRVShader
*
shd
,
uint8_t
**
data
,
...
...
@@ -43,6 +44,7 @@ static int shdc_shader_compile(FFVkSPIRVCompiler *ctx, void *avctx,
};
shaderc_compile_options_t
opts
=
shaderc_compile_options_initialize
();
*
opaque
=
NULL
;
if
(
!
opts
)
return
AVERROR
(
ENOMEM
);
...
...
@@ -65,7 +67,7 @@ static int shdc_shader_compile(FFVkSPIRVCompiler *ctx, void *avctx,
loglevel
=
err
?
AV_LOG_ERROR
:
warn
?
AV_LOG_WARNING
:
AV_LOG_VERBOSE
;
ff_vk_
print_shader
(
avctx
,
shd
,
loglevel
);
ff_vk_
shader_print
(
avctx
,
shd
,
loglevel
);
if
(
message
&&
(
err
||
warn
))
av_log
(
avctx
,
loglevel
,
"%s
\n
"
,
message
);
status
=
ret
<
FF_ARRAY_ELEMS
(
shdc_result
)
?
shdc_result
[
ret
]
:
"unknown"
;
...
...
@@ -104,7 +106,7 @@ static void shdc_uninit(FFVkSPIRVCompiler **ctx)
av_freep
(
ctx
);
}
static
FFVkSPIRVCompiler
*
ff_vk_shaderc_init
(
void
)
FFVkSPIRVCompiler
*
ff_vk_shaderc_init
(
void
)
{
FFVkSPIRVCompiler
*
ret
=
av_mallocz
(
sizeof
(
*
ret
));
if
(
!
ret
)
...
...
libavfilter/vulkan_spirv.h
0 → 100644
View file @
05ce6473
/*
* 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_SPIRV_H
#define AVFILTER_VULKAN_SPIRV_H
#include "libavutil/vulkan.h"
#include "vulkan.h"
#include "config.h"
typedef
struct
FFVkSPIRVCompiler
{
void
*
priv
;
int
(
*
compile_shader
)(
struct
FFVkSPIRVCompiler
*
ctx
,
void
*
avctx
,
struct
FFVkSPIRVShader
*
shd
,
uint8_t
**
data
,
size_t
*
size
,
const
char
*
entrypoint
,
void
**
opaque
);
void
(
*
free_shader
)(
struct
FFVkSPIRVCompiler
*
ctx
,
void
**
opaque
);
void
(
*
uninit
)(
struct
FFVkSPIRVCompiler
**
ctx
);
}
FFVkSPIRVCompiler
;
#if CONFIG_LIBGLSLANG
FFVkSPIRVCompiler
*
ff_vk_glslang_init
(
void
);
#define ff_vk_spirv_init ff_vk_glslang_init
#endif
#if CONFIG_LIBSHADERC
FFVkSPIRVCompiler
*
ff_vk_shaderc_init
(
void
);
#define ff_vk_spirv_init ff_vk_shaderc_init
#endif
#endif
/* AVFILTER_VULKAN_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment