vulkan_prores: initialize only the necessary shaders on init

This commit is contained in:
Lynne
2025-11-23 20:10:11 +01:00
parent a160e4a9e2
commit 0c20edaa7a

View File

@@ -42,7 +42,7 @@ typedef struct ProResRAWVulkanDecodePicture {
} ProResRAWVulkanDecodePicture; } ProResRAWVulkanDecodePicture;
typedef struct ProResRAWVulkanDecodeContext { typedef struct ProResRAWVulkanDecodeContext {
FFVulkanShader decode[2]; FFVulkanShader decode;
AVBufferPool *tile_data_pool; AVBufferPool *tile_data_pool;
@@ -187,7 +187,7 @@ static int vk_prores_raw_end_frame(AVCodecContext *avctx)
}); });
nb_img_bar = 0; nb_img_bar = 0;
FFVulkanShader *decode_shader = &prv->decode[prr->version]; FFVulkanShader *decode_shader = &prv->decode;
ff_vk_shader_update_img_array(&ctx->s, exec, decode_shader, ff_vk_shader_update_img_array(&ctx->s, exec, decode_shader,
prr->frame, vp->view.out, prr->frame, vp->view.out,
0, 0, 0, 0,
@@ -346,8 +346,7 @@ static void vk_decode_prores_raw_uninit(FFVulkanDecodeShared *ctx)
{ {
ProResRAWVulkanDecodeContext *fv = ctx->sd_ctx; ProResRAWVulkanDecodeContext *fv = ctx->sd_ctx;
ff_vk_shader_free(&ctx->s, &fv->decode[0]); ff_vk_shader_free(&ctx->s, &fv->decode);
ff_vk_shader_free(&ctx->s, &fv->decode[1]);
ff_vk_free_buf(&ctx->s, &fv->uniform_buf); ff_vk_free_buf(&ctx->s, &fv->uniform_buf);
@@ -359,8 +358,8 @@ static void vk_decode_prores_raw_uninit(FFVulkanDecodeShared *ctx)
static int vk_decode_prores_raw_init(AVCodecContext *avctx) static int vk_decode_prores_raw_init(AVCodecContext *avctx)
{ {
int err; int err;
ProResRAWContext *prr = avctx->priv_data;
FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data; FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
ProResRAWContext *prr = avctx->priv_data;
FFVkSPIRVCompiler *spv = ff_vk_spirv_init(); FFVkSPIRVCompiler *spv = ff_vk_spirv_init();
if (!spv) { if (!spv) {
@@ -382,8 +381,8 @@ static int vk_decode_prores_raw_init(AVCodecContext *avctx)
ctx->sd_ctx_free = &vk_decode_prores_raw_uninit; ctx->sd_ctx_free = &vk_decode_prores_raw_uninit;
/* Setup decode shader */ /* Setup decode shader */
RET(init_decode_shader(prr, &ctx->s, &ctx->exec_pool, spv, &prv->decode[0], 0)); RET(init_decode_shader(prr, &ctx->s, &ctx->exec_pool, spv, &prv->decode,
RET(init_decode_shader(prr, &ctx->s, &ctx->exec_pool, spv, &prv->decode[1], 1)); prr->version));
/* Size in bytes of each codebook table */ /* Size in bytes of each codebook table */
size_t cb_size[5] = { size_t cb_size[5] = {
@@ -447,24 +446,22 @@ static int vk_decode_prores_raw_init(AVCodecContext *avctx)
RET(ff_vk_unmap_buffer(&ctx->s, &prv->uniform_buf, 1)); RET(ff_vk_unmap_buffer(&ctx->s, &prv->uniform_buf, 1));
/* Done; update descriptors */ /* Done; update descriptors */
for (int i = 0; i < 2; i++) {
RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0], RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
&prv->decode[i], 1, 0, 0, &prv->decode, 1, 0, 0,
&prv->uniform_buf, &prv->uniform_buf,
0, 64*sizeof(float), 0, 64*sizeof(float),
VK_FORMAT_UNDEFINED)); VK_FORMAT_UNDEFINED));
RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0], RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
&prv->decode[i], 1, 1, 0, &prv->decode, 1, 1, 0,
&prv->uniform_buf, &prv->uniform_buf,
64*sizeof(float), 64*sizeof(uint8_t), 64*sizeof(float), 64*sizeof(uint8_t),
VK_FORMAT_UNDEFINED)); VK_FORMAT_UNDEFINED));
for (int j = 0; j < 4; j++) for (int j = 0; j < 4; j++)
RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0], RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
&prv->decode[i], 1, 2 + j, 0, &prv->decode, 1, 2 + j, 0,
&prv->uniform_buf, &prv->uniform_buf,
cb_offset[j], cb_size[j], cb_offset[j], cb_size[j],
VK_FORMAT_UNDEFINED)); VK_FORMAT_UNDEFINED));
}
fail: fail:
spv->uninit(&spv); spv->uninit(&spv);