This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit bc968bc8b4047c1f95ef51f5e14773e9ac1c7b15
Author:     Lynne <[email protected]>
AuthorDate: Tue Feb 10 16:32:39 2026 +0100
Commit:     Lynne <[email protected]>
CommitDate: Thu Feb 19 19:42:33 2026 +0100

    vulkan/ffv1_enc: cache state probabilities
    
    4x speedup on AMD.
---
 libavcodec/ffv1enc_vulkan.c          |  3 ++-
 libavcodec/vulkan/ffv1_enc.comp.glsl | 18 ++++++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/libavcodec/ffv1enc_vulkan.c b/libavcodec/ffv1enc_vulkan.c
index 128f9ee902..eaf437279e 100644
--- a/libavcodec/ffv1enc_vulkan.c
+++ b/libavcodec/ffv1enc_vulkan.c
@@ -915,8 +915,9 @@ static int init_encode_shader(AVCodecContext *avctx, 
VkSpecializationInfo *sl)
     VulkanEncodeFFv1Context *fv = avctx->priv_data;
     FFVulkanShader *shd = &fv->enc;
 
+    uint32_t wg_x = fv->ctx.ac != AC_GOLOMB_RICE ? CONTEXT_SIZE : 1;
     ff_vk_shader_load(shd, VK_SHADER_STAGE_COMPUTE_BIT, sl,
-                      (uint32_t []) { 1, 1, 1 }, 0);
+                      (uint32_t []) { wg_x, 1, 1 }, 0);
 
     ff_vk_shader_add_push_const(shd, 0, sizeof(FFv1ShaderParams),
                                 VK_SHADER_STAGE_COMPUTE_BIT);
diff --git a/libavcodec/vulkan/ffv1_enc.comp.glsl 
b/libavcodec/vulkan/ffv1_enc.comp.glsl
index a690014e94..31ce832b52 100644
--- a/libavcodec/vulkan/ffv1_enc.comp.glsl
+++ b/libavcodec/vulkan/ffv1_enc.comp.glsl
@@ -44,8 +44,8 @@ layout (set = 1, binding = 2, scalar) buffer slice_state_buf {
     uint8_t slice_rc_state[];
 };
 
-#define WRITE(off, val) put_rac(slice_rc_state[state_off + off], val)
-void put_symbol(uint state_off, int v)
+#define WRITE(idx, val) put_rac(rc_state[idx], val)
+void put_symbol(int v)
 {
     bool is_nil = (v == 0);
     WRITE(0, is_nil);
@@ -68,6 +68,9 @@ void put_symbol(uint state_off, int v)
 void encode_line_pcm(in SliceContext sc, readonly uimage2D img,
                      ivec2 sp, int y, int p, int comp)
 {
+    if (gl_LocalInvocationID.x > 0)
+        return;
+
     int w = sc.slice_dim.x;
 
 #ifndef RGB
@@ -109,9 +112,16 @@ void encode_line(in SliceContext sc, readonly uimage2D 
img, uint state_off,
 
         d[1] = fold(d[1], bits);
 
-        uint context_off = state_off + CONTEXT_SIZE*d[0];
+        uint rc_off = state_off + CONTEXT_SIZE*d[0] + gl_LocalInvocationID.x;
+
+        rc_state[gl_LocalInvocationID.x] = slice_rc_state[rc_off];
+        barrier();
+
+        if (gl_LocalInvocationID.x == 0)
+            put_symbol(d[1]);
 
-        put_symbol(context_off, d[1]);
+        barrier();
+        slice_rc_state[rc_off] = rc_state[gl_LocalInvocationID.x];
     }
 }
 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to