Commit fabe1eb1a5 for ffmpeg
commit fabe1eb1a5d8de87326bd1d049467ef650b5131d
Author: Niklas Haas <git@haasn.dev>
Date: Wed Oct 21 02:38:47 2026 +0200
swscale/vulkan/ops: define clear constants at the point of use
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
diff --git a/libswscale/vulkan/ops.c b/libswscale/vulkan/ops.c
index 614fa29fda..6ea6d71fdc 100644
--- a/libswscale/vulkan/ops.c
+++ b/libswscale/vulkan/ops.c
@@ -430,6 +430,15 @@ static int const_zero(const SPIRVIDs *id, SwsPixelType type)
return ff_sws_pixel_type_is_int(type) ? id->u32_cid[0] : id->f32_0;
}
+static int const_pixel(SPICtx *spi, const SPIRVIDs *id, SwsPixelType type,
+ AVRational64 val)
+{
+ if (!ff_sws_pixel_type_is_int(type))
+ return spi_OpConstantFloat(spi, id->f32_type, (float) val.num / val.den);
+ av_assert0(val.den == 1);
+ return spi_OpConstantUInt(spi, id->u32_type, val.num);
+}
+
/* Arithmetic on operands of the given pixel type */
static int emit_mul(SPICtx *spi, SwsPixelType type, int res_type, int a, int b)
{
@@ -541,20 +550,6 @@ static void define_shader_consts(SwsContext *sws, const SwsOpList *ops,
OpIDs *oid = &id->op[n];
SwsPixelType type_in = ff_sws_op_input_type(op);
switch (op->op) {
- case SWS_OP_CLEAR:
- for (int i = 0; i < 4; i++) {
- if (!SWS_COMP_TEST(op->clear.mask, i))
- continue;
- AVRational64 cv = op->clear.value[i];
- if (op->clear.type[i] == SWS_PIXEL_F32) {
- float q = (float)cv.num/cv.den;
- oid->comp[i] = spi_OpConstantFloat(spi, f32_type, q);
- } else {
- av_assert0(cv.den == 1);
- oid->comp[i] = spi_OpConstantUInt(spi, u32_type, cv.num);
- }
- }
- break;
case SWS_OP_PACK:
case SWS_OP_UNPACK: {
uint64_t mask[4];
@@ -1194,7 +1189,9 @@ static int emit_shader(SwsContext *sws, VulkanPriv *p, FFVulkanOpsCtx *s,
for (int i = 0; i < 4; i++) {
if (!SWS_COMP_TEST(op->clear.mask, i))
continue;
- data = spi_OpCompositeInsert(spi, type_v, oid->comp[i], data, i);
+ int val = const_pixel(spi, id, op->clear.type[i],
+ op->clear.value[i]);
+ data = spi_OpCompositeInsert(spi, type_v, val, data, i);
}
break;
case SWS_OP_SWIZZLE: