Go to the documentation of this file.
35 .queue_flags = VK_QUEUE_COMPUTE_BIT,
59 const uint8_t *
src, uint32_t
size)
66 VkPhysicalDeviceLimits *limits = &
ctx->s.props.properties.limits;
77 VkImageCreateInfo create_info = {
78 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
79 .imageType = VK_IMAGE_TYPE_2D,
88 .tiling = VK_IMAGE_TILING_LINEAR,
89 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
90 .usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT,
91 .samples = VK_SAMPLE_COUNT_1_BIT,
92 .pQueueFamilyIndices = &
ctx->qf[0].idx,
93 .queueFamilyIndexCount = 1,
94 .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
97 if (create_info.extent.width >= limits->maxImageDimension2D ||
98 create_info.extent.height >= limits->maxImageDimension2D)
101 vk->CreateImage(
ctx->s.hwctx->act_dev, &create_info,
ctx->s.hwctx->alloc,
106 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
107 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
109 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
110 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
115 VkBindImageMemoryInfo bind_info = {
116 .sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO,
120 vk->BindImageMemory2(
ctx->s.hwctx->act_dev, 1, &bind_info);
122 VkHostImageLayoutTransitionInfo layout_change = {
123 .sType = VK_STRUCTURE_TYPE_HOST_IMAGE_LAYOUT_TRANSITION_INFO,
125 .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
126 .newLayout = VK_IMAGE_LAYOUT_GENERAL,
127 .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
128 .subresourceRange.layerCount = 1,
129 .subresourceRange.levelCount = 1,
131 vk->TransitionImageLayoutEXT(
ctx->s.hwctx->act_dev, 1, &layout_change);
133 VkMemoryToImageCopy copy_region = {
134 .sType = VK_STRUCTURE_TYPE_MEMORY_TO_IMAGE_COPY,
136 .imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
137 .imageSubresource.layerCount = 1,
138 .imageExtent = (VkExtent3D){ dpx->frame->width*dpx->components,
142 VkCopyMemoryToImageInfo copy_info = {
143 .sType = VK_STRUCTURE_TYPE_COPY_MEMORY_TO_IMAGE_INFO,
144 .flags = VK_HOST_IMAGE_COPY_MEMCPY_EXT,
146 .dstImageLayout = VK_IMAGE_LAYOUT_GENERAL,
148 .pRegions = ©_region,
150 vk->CopyMemoryToImageEXT(
ctx->s.hwctx->act_dev, ©_info);
152 vk->DestroyImage(
ctx->s.hwctx->act_dev,
temp,
ctx->s.hwctx->alloc);
178 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
179 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
227 VkImageMemoryBarrier2 img_bar[8];
235 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
236 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
247 for (
int i = 0;
i < 4;
i++) {
248 vkf->
layout[
i] = VK_IMAGE_LAYOUT_UNDEFINED;
249 vkf->
access[
i] = VK_ACCESS_2_NONE;
253 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
254 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
255 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
256 VK_IMAGE_LAYOUT_GENERAL,
257 VK_QUEUE_FAMILY_IGNORED);
259 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
260 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
261 .pImageMemoryBarriers = img_bar,
262 .imageMemoryBarrierCount = nb_img_bar,
270 VK_IMAGE_LAYOUT_GENERAL,
276 VK_FORMAT_UNDEFINED);
282 VK_FORMAT_UNDEFINED);
287 VK_FORMAT_UNDEFINED);
305 VK_SHADER_STAGE_COMPUTE_BIT,
308 vk->CmdDispatch(exec->
buf,
340 (uint32_t []) { 512, 1, 1 }, 0);
343 VK_SHADER_STAGE_COMPUTE_BIT);
348 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
349 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
354 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
355 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
358 .name =
"data_buf16",
359 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
360 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
363 .name =
"data_buf32",
364 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
365 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
445 .
p.
name =
"dpx_vulkan",
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
int ff_vk_decode_prepare_frame_sdr(FFVulkanDecodeContext *dec, AVFrame *pic, FFVulkanDecodePicture *vkpic, int is_current, enum FFVkShaderRepFormat rep_fmt, int alloc_dpb)
Software-defined decoder version of ff_vk_decode_prepare_frame.
uint8_t * data
The data buffer.
FFVulkanDecodeShared * shared_ctx
RefStruct is an API for creating reference-counted objects with minimal overhead.
void * hwaccel_picture_private
AVHWAccel p
The public AVHWAccel.
const unsigned char ff_dpx_unpack_comp_spv_data[]
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
#define SPEC_LIST_ADD(name, idx, val_bits, val)
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define FF_VK_EXT_HOST_IMAGE_COPY
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
static void vk_decode_dpx_uninit(FFVulkanDecodeShared *ctx)
#define AV_PIX_FMT_GBRP10
void ff_vk_shader_update_img_array(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, AVFrame *f, VkImageView *views, int set, int binding, VkImageLayout layout, VkSampler sampler)
Update a descriptor in a buffer with an image array.
void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags2 src_stage, VkPipelineStageFlags2 dst_stage, VkAccessFlagBits2 new_access, VkImageLayout new_layout, uint32_t new_qf)
#define HWACCEL_CAP_THREAD_SAFE
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
int ff_vk_host_map_buffer(FFVulkanContext *s, AVBufferRef **dst, uint8_t *src_data, const AVBufferRef *src_buf, VkBufferUsageFlags usage)
Maps a system RAM buffer into a Vulkan buffer.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
static int vk_dpx_decode_slice(AVCodecContext *avctx, const uint8_t *data, uint32_t size)
#define AV_PIX_FMT_GBRAP10
int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, VkSemaphore *dst, uint64_t *dst_val, AVFrame *f)
const FFVulkanDecodeDescriptor ff_vk_dec_dpx_desc
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps, int ref)
Execution dependency management.
#define AV_PIX_FMT_GRAY10
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
void ff_vk_decode_free_frame(AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture *vp)
Free a frame and its state.
static void vk_dpx_free_frame_priv(AVRefStructOpaque _hwctx, void *data)
struct AVCodecInternal * internal
Private context used for internal data.
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
int ff_vk_decode_uninit(AVCodecContext *avctx)
Free decoder.
int ff_vk_shader_link(FFVulkanContext *s, FFVulkanShader *shd, const char *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
#define SPEC_LIST_CREATE(name, max_length, max_size)
int ff_vk_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Initialize hw_frames_ctx with the parameters needed to decode the stream using the parameters from av...
int(* init)(AVBSFContext *ctx)
VkAccessFlagBits access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
void ff_vk_shader_update_push_const(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Update push constant in a shader.
const unsigned int ff_dpx_unpack_comp_spv_len
void * hwaccel_priv_data
hwaccel-specific private data
static int init_shader(AVCodecContext *avctx, FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd, int bits)
const unsigned int ff_dpx_copy_comp_spv_len
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
int ff_vk_shader_update_desc_buffer(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, int set, int bind, int elem, FFVkBuffer *buf, VkDeviceSize offset, VkDeviceSize len, VkFormat fmt)
Update a descriptor in a buffer with a buffer.
const char * name
Name of the hardware accelerated codec.
#define FF_VK_EXT_EXTERNAL_HOST_MEMORY
static void uninit(AVBSFContext *ctx)
static int unpack(const uint8_t *src, const uint8_t *src_end, uint8_t *dst, int width, int height)
Unpack buffer.
struct FFVulkanDecodePicture::@328 view
VkImageView out[AV_NUM_DATA_POINTERS]
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
#define i(width, name, range_min, range_max)
static int vk_decode_dpx_init(AVCodecContext *avctx)
const unsigned char ff_dpx_copy_comp_spv_data[]
AVBufferPool * frame_data_pool
const FFHWAccel ff_dpx_vulkan_hwaccel
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd)
Bind a shader.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
This struct describes a set or pool of "hardware" frames (i.e.
int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp, const uint8_t *data, size_t size, int add_startcode, uint32_t *nb_slices, const uint32_t **offsets)
Add slice data to frame.
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
enum AVPixelFormat pix_fmt
main external API structure.
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have update_thread_context() run it in the next thread. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. Use ff_thread_get_buffer()(or ff_progress_frame_get_buffer() in case you have inter-frame dependencies and use the ProgressFrame API) to allocate frame buffers. Call ff_progress_frame_report() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
int ff_vk_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
Synchronize the contexts between 2 threads.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
VkImageLayout layout[AV_NUM_DATA_POINTERS]
A reference to a data buffer.
static int ff_vk_count_images(AVVkFrame *f)
static int vk_dpx_end_frame(AVCodecContext *avctx)
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
int ff_vk_decode_init(AVCodecContext *avctx)
Initialize decoder.
static int host_upload_image(AVCodecContext *avctx, FFVulkanDecodeContext *dec, DPXDecContext *dpx, const uint8_t *src, uint32_t size)
int ff_vk_shader_load(FFVulkanShader *shd, VkPipelineStageFlags stage, VkSpecializationInfo *spec, uint32_t wg_size[3], uint32_t required_subgroup_size)
Initialize a shader object.
int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVBufferPool **buf_pool, AVBufferRef **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
Initialize a pool and create AVBufferRefs containing FFVkBuffer.
static int vk_dpx_start_frame(AVCodecContext *avctx, const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)