[FFmpeg-devel] [PATCH] avcodec/vc2enc: Initial vulkan VC2 encoder
Michael Niedermayer
michael at niedermayer.cc
Sat Oct 26 00:44:03 EEST 2024
On Thu, Oct 24, 2024 at 02:03:27AM +0300, IndecisiveTurtle wrote:
> Implements a Vulkan based dirac encoder. Supports Haar and Legall wavelets and should work with all wavelet depths.
>
> Performance wise, encoding a 1080p 1-minute video is performed in about 2.5 minutes with the cpu encoder running on my Ryzen 5 4600H, while it takes about 30 seconds on my NVIDIA GTX 1650
>
> Haar shader has a subgroup optimized variant that applies when configured wavelet depth allows it
>
> lavapipe seems to be bugged for some reason, after a bunch of debugging I'm not quite sure if it's a bug here or in lavapipe. But people probably dont want to use this with a software implementation anyway.
> ---
> libavcodec/Makefile | 5 +-
> libavcodec/allcodecs.c | 1 +
> libavcodec/vc2enc.c | 501 +--------------
> libavcodec/vc2enc_common.c | 368 +++++++++++
> libavcodec/vc2enc_common.h | 279 ++++++++
> libavcodec/vc2enc_vulkan.c | 781 +++++++++++++++++++++++
> libavcodec/vulkan/dwt_haar.comp | 76 +++
> libavcodec/vulkan/dwt_haar_subgroup.comp | 94 +++
> libavcodec/vulkan/dwt_hor_legall.comp | 61 ++
> libavcodec/vulkan/dwt_legall.comp | 74 +++
> libavcodec/vulkan/dwt_upload.comp | 45 ++
> libavcodec/vulkan/dwt_ver_legall.comp | 55 ++
> libavcodec/vulkan/encode.comp | 256 ++++++++
> libavcodec/vulkan/slice_sizes.comp | 184 ++++++
> 14 files changed, 2279 insertions(+), 501 deletions(-)
> create mode 100644 libavcodec/vc2enc_common.c
> create mode 100644 libavcodec/vc2enc_common.h
> create mode 100644 libavcodec/vc2enc_vulkan.c
> create mode 100644 libavcodec/vulkan/dwt_haar.comp
> create mode 100644 libavcodec/vulkan/dwt_haar_subgroup.comp
> create mode 100644 libavcodec/vulkan/dwt_hor_legall.comp
> create mode 100644 libavcodec/vulkan/dwt_legall.comp
> create mode 100644 libavcodec/vulkan/dwt_upload.comp
> create mode 100644 libavcodec/vulkan/dwt_ver_legall.comp
> create mode 100644 libavcodec/vulkan/encode.comp
> create mode 100644 libavcodec/vulkan/slice_sizes.comp
breaks build
CC libavcodec/vc2enc.o
In file included from ./libavutil/vulkan_functions.h:26,
from ./libavutil/vulkan.h:30,
from libavcodec/vc2enc_common.h:31,
from libavcodec/vc2enc.c:32:
./libavutil/hwcontext_vulkan.h:44:5: error: unknown type name ‘VkVideoCodecOperationFlagBitsKHR’
44 | VkVideoCodecOperationFlagBitsKHR video_caps;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./libavutil/vulkan.h:30,
from libavcodec/vc2enc_common.h:31,
from libavcodec/vc2enc.c:32:
./libavutil/vulkan_functions.h:260:5: error: unknown type name ‘PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR’
260 | PFN_vk##name name;
| ^~~~~~
./libavutil/vulkan_functions.h:85:5: note: in expansion of macro ‘PFN_DEF’
85 | MACRO(1, 0, FF_VK_EXT_VIDEO_QUEUE, GetPhysicalDeviceVideoCapabilitiesKHR) \
| ^~~~~
./libavutil/vulkan_functions.h:264:5: note: in expansion of macro ‘FN_LIST’
264 | FN_LIST(PFN_DEF)
| ^~~~~~~
...
In file included from libavcodec/vc2enc_common.h:31,
from libavcodec/vc2enc.c:32:
./libavutil/vulkan.h:95:5: error: unknown type name ‘VkPipelineStageFlags2’
95 | VkPipelineStageFlags2 stage;
| ^~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:96:5: error: unknown type name ‘VkAccessFlags2’
96 | VkAccessFlags2 access;
| ^~~~~~~~~~~~~~
./libavutil/vulkan.h:137:5: error: unknown type name ‘VkSemaphoreSubmitInfo’
137 | VkSemaphoreSubmitInfo *sem_wait;
| ^~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:141:5: error: unknown type name ‘VkSemaphoreSubmitInfo’
141 | VkSemaphoreSubmitInfo *sem_sig;
| ^~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:194:5: error: unknown type name ‘VkPipelineShaderStageRequiredSubgroupSizeCreateInfo’
194 | VkPipelineShaderStageRequiredSubgroupSizeCreateInfo subgroup_info;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:197:5: error: unknown type name ‘VkShaderEXT’
197 | VkShaderEXT object;
| ^~~~~~~~~~~
./libavutil/vulkan.h:234:5: error: unknown type name ‘VkDescriptorBufferBindingInfoEXT’
234 | VkDescriptorBufferBindingInfoEXT *desc_bind;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:273:5: error: unknown type name ‘VkPhysicalDeviceDescriptorBufferPropertiesEXT’
273 | VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:274:5: error: unknown type name ‘VkPhysicalDeviceSubgroupSizeControlProperties’
274 | VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:275:5: error: unknown type name ‘VkPhysicalDeviceCooperativeMatrixPropertiesKHR’
275 | VkPhysicalDeviceCooperativeMatrixPropertiesKHR coop_matrix_props;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:276:5: error: unknown type name ‘VkPhysicalDeviceOpticalFlowPropertiesNV’
276 | VkPhysicalDeviceOpticalFlowPropertiesNV optical_flow_props;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:277:5: error: unknown type name ‘VkQueueFamilyQueryResultStatusPropertiesKHR’
277 | VkQueueFamilyQueryResultStatusPropertiesKHR *query_props;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:278:5: error: unknown type name ‘VkQueueFamilyVideoPropertiesKHR’
278 | VkQueueFamilyVideoPropertiesKHR *video_props;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:282:5: error: unknown type name ‘VkCooperativeMatrixPropertiesKHR’
282 | VkCooperativeMatrixPropertiesKHR *coop_mat_props;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:285:5: error: unknown type name ‘VkPhysicalDeviceShaderAtomicFloatFeaturesEXT’
285 | VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_feats;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libavutil/vulkan.h:433:33: error: unknown type name ‘VkPipelineStageFlagBits2’; did you mean ‘VkPipelineStageFlagBits’?
433 | VkPipelineStageFlagBits2 stage,
| ^~~~~~~~~~~~~~~~~~~~~~~~
| VkPipelineStageFlagBits
./libavutil/vulkan.h:436:30: error: unknown type name ‘VkPipelineStageFlagBits2’; did you mean ‘VkPipelineStageFlagBits’?
436 | VkPipelineStageFlagBits2 wait_stage,
| ^~~~~~~~~~~~~~~~~~~~~~~~
| VkPipelineStageFlagBits
./libavutil/vulkan.h:437:30: error: unknown type name ‘VkPipelineStageFlagBits2’; did you mean ‘VkPipelineStageFlagBits’?
437 | VkPipelineStageFlagBits2 signal_stage);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| VkPipelineStageFlagBits
./libavutil/vulkan.h:439:30: error: unknown type name ‘VkImageMemoryBarrier2’; did you mean ‘VkImageMemoryBarrier’?
439 | VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar);
| ^~~~~~~~~~~~~~~~~~~~~
| VkImageMemoryBarrier
./libavutil/vulkan.h:453:40: error: unknown type name ‘VkImageMemoryBarrier2’; did you mean ‘VkImageMemoryBarrier’?
453 | AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar,
| ^~~~~~~~~~~~~~~~~~~~~
| VkImageMemoryBarrier
make: *** [ffbuild/common.mak:81: libavcodec/vc2enc.o] Error 1
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241025/7390c1d9/attachment.sig>
More information about the ffmpeg-devel
mailing list