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

Git pushed a commit to branch master
in repository ffmpeg.

commit 92f292807e9194b32175c416fc2ec8727797c1d1
Author:     Lynne <[email protected]>
AuthorDate: Tue Aug 18 11:31:24 2026 +0900
Commit:     Lynne <[email protected]>
CommitDate: Tue Aug 18 13:22:54 2026 +0900

    vulkan: properly align the GET_BITS_SMEM cache refills
    
    The issue is that init_get_bits is not guaranteed to be called with
    an aligned address, so LOAD64 tried to align the offset for SMEM
    loading, but only aligned to a 4-byte alignment, whilst FILL_SMEM
    requires 16 byte alignment.
    Fix it by just loading with FILL_SMEM from an aligned position,
    then throwing away the padding data at the start.
---
 libavcodec/vulkan/common.glsl | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/libavcodec/vulkan/common.glsl b/libavcodec/vulkan/common.glsl
index 989c4899ca..c8057ba7ae 100644
--- a/libavcodec/vulkan/common.glsl
+++ b/libavcodec/vulkan/common.glsl
@@ -249,7 +249,7 @@ struct GetBitContext {
     uint64_t bits;
     int bits_valid;
 #ifdef GET_BITS_SMEM
-    int cur_smem_pos;
+    uint cur_smem_pos;
 #endif
 };
 
@@ -275,34 +275,35 @@ struct GetBitContext {
 #else /* GET_BITS_SMEM */
 shared u32vec4 
gb_storage[gl_WorkGroupSize.x*gl_WorkGroupSize.y*gl_WorkGroupSize.z*GET_BITS_SMEM];
 
-#define FILL_SMEM()                                                            
 \
+/* Requires a line-aligned address; LOAD64() absorbs the origin's offset,
+ * so refills land on line boundaries. */
+#define FILL_SMEM(addr)                                                        
 \
     {                                                                          
 \
-        u32vec4buf ptr = u32vec4buf(gb.buf);                                   
 \
+        u32vec4buf ptr = u32vec4buf(addr);                                     
 \
         [[unroll]]                                                             
 \
         for (uint i = 0; i < GET_BITS_SMEM; ++i)                               
 \
             gb_storage[gl_LocalInvocationIndex * GET_BITS_SMEM + i] = 
ptr[i].v; \
-        gb.cur_smem_pos = 0;                                                   
 \
     }
 
 #define LOAD64()                                              \
     {                                                         \
         gb.bits = 0;                                          \
         gb.bits_valid = 0;                                    \
-        u8buf ptr = u8buf(gb.buf);                            \
-        uint prefix = (4 - uint(gb.buf)) & 3;                 \
-        for (uint i = 0; i < prefix; ++i) {                   \
-            gb.bits |= uint64_t(ptr[i].v) << (56 - i * 8);    \
-            gb.bits_valid += 8;                               \
-            gb.buf += 1;                                      \
-        }                                                     \
-        FILL_SMEM();                                          \
+        uint offset = uint(gb.buf) & 15;                      \
+        gb.buf -= offset & 3;                                 \
+        FILL_SMEM(gb.buf - (offset & ~3u));                   \
+        gb.cur_smem_pos = offset >> 2;                        \
         RELOAD32();                                           \
+        gb.bits <<= (offset & 3) << 3;                        \
+        gb.bits_valid -= int((offset & 3) << 3);              \
     }
 
 #define RELOAD32()                                                             
                     \
     {                                                                          
                     \
-        if (gb.cur_smem_pos >= 4*GET_BITS_SMEM)                                
                     \
-            FILL_SMEM();                                                       
                     \
+        if (gb.cur_smem_pos >= 4*GET_BITS_SMEM) {                              
                     \
+            FILL_SMEM(gb.buf);                                                 
                     \
+            gb.cur_smem_pos = 0;                                               
                     \
+        }                                                                      
                     \
         u32vec4 vec = gb_storage[gl_LocalInvocationIndex * GET_BITS_SMEM + 
(gb.cur_smem_pos >> 2)]; \
         uint v = vec[gb.cur_smem_pos & 3];                                     
                     \
         gb.buf += 4;                                                           
                     \

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to