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

Git pushed a commit to branch master
in repository ffmpeg.

commit dbe29df93becaeb4eca3f78daeeee8566858baa6
Author:     Niklas Haas <[email protected]>
AuthorDate: Tue Oct 20 02:18:36 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Tue Oct 20 19:50:40 2026 +0000

    swscale/vulkan/ops: factor out bit-exact linear op count
    
    Move the count of arithmetic instructions emitted by
    insert_bitexact_linear() into a helper, and assert that it matches the
    number of IDs actually allocated, since the NoContraction decorations
    are reserved and written based on this count.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/vulkan/ops.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/libswscale/vulkan/ops.c b/libswscale/vulkan/ops.c
index ebf4d74516..18aa671ed5 100644
--- a/libswscale/vulkan/ops.c
+++ b/libswscale/vulkan/ops.c
@@ -389,6 +389,22 @@ typedef struct SPIRVIDs {
     int field_i32;
 } SPIRVIDs;
 
+/* Number of arithmetic instructions emitted by insert_bitexact_linear() */
+static int bitexact_linear_nb_ops(const SwsLinearOp *lin)
+{
+    int nb_ops = 0;
+    for (int j = 0; j < 4; j++) {
+        nb_ops += !!lin->m[j][0].num;
+        nb_ops += lin->m[j][0].num && lin->m[j][4].num;
+        for (int i = 1; i < 4; i++) {
+            nb_ops += !!lin->m[j][i].num;
+            nb_ops += lin->m[j][i].num &&
+                      (lin->m[j][0].num || lin->m[j][4].num);
+        }
+    }
+    return nb_ops;
+}
+
 /* Section 1: Function to define all shader header data, and decorations */
 static void define_shader_header(SwsContext *sws, FFVulkanShader *shd,
                                  const SwsOpList *ops, SPICtx *spi, SPIRVIDs 
*id)
@@ -470,17 +486,7 @@ static void define_shader_header(SwsContext *sws, 
FFVulkanShader *shd,
         if (op->op != SWS_OP_LINEAR)
             continue;
 
-        int nb_ops = 0;
-        for (int j = 0; j < 4; j++) {
-            nb_ops += !!op->lin.m[j][0].num;
-            nb_ops += op->lin.m[j][0].num && op->lin.m[j][4].num;
-            for (int i = 1; i < 4; i++) {
-                nb_ops += !!op->lin.m[j][i].num;
-                nb_ops += op->lin.m[j][i].num &&
-                          (op->lin.m[j][0].num || op->lin.m[j][4].num);
-            }
-        }
-
+        const int nb_ops = bitexact_linear_nb_ops(&op->lin);
         LinearIDs *lin = &id->op[n].lin;
         lin->deco_off = spi_reserve(spi, nb_ops*4*3);
         lin->nb_deco  = nb_ops;
@@ -769,6 +775,7 @@ static int insert_bitexact_linear(const SwsOp *op, SPICtx 
*spi, SPIRVIDs *id,
     for (int i = 0; i < lin->nb_deco; i++)
         spi_OpDecorate(spi, spi->id + i, SpvDecorationNoContraction);
     spi->off = off;
+    const int first_id = spi->id;
 
     int res[4];
     for (int j = 0; j < 4; j++) {
@@ -793,6 +800,9 @@ static int insert_bitexact_linear(const SwsOp *op, SPICtx 
*spi, SPIRVIDs *id,
         }
     }
 
+    /* The decorations above assume one ID per arithmetic op */
+    av_assert0(spi->id - first_id == lin->nb_deco);
+
     return spi_OpCompositeConstruct(spi, type_v,
                                     res[0], res[1], res[2], res[3]);
 }

-- 
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