Only write alpha if useful

This commit is contained in:
Patrick Nicolas
2026-04-11 16:55:02 +02:00
parent 9bb39c4809
commit 1f6e237f21
4 changed files with 18 additions and 8 deletions
+8 -4
View File
@@ -37,6 +37,7 @@ layout(set = 0, binding = 1, std430) buffer restrict Config
uint y[2*MAX_DIM];
// output parameters
uint alpha_width;
bool alpha;
} ubo;
layout(set = 0, binding = 2) uniform writeonly restrict image2DArray luma;
@@ -125,9 +126,12 @@ void main()
// actual chroma
imageStore(chroma, ivec3(ix/2, iy/2, iz), vec4(sum.y, sum.z, 0, 0) / 4);
// alpha in luma
int offset = int(ubo.alpha_width * iz);
imageStore(luma, ivec3(offset + ix/2, iy/2, 2), vec4(sum.w, 0, 0, 0) / 4);
imageStore(chroma, ivec3(offset + ix/2, iy/2, 2), vec4(0.5, 0.5, 0, 0));
if (ubo.alpha)
{
// alpha in luma
int offset = int(ubo.alpha_width * iz);
imageStore(luma, ivec3(offset + ix/2, iy/2, 2), vec4(sum.w, 0, 0, 0) / 4);
imageStore(chroma, ivec3(offset + ix/2, iy/2, 2), vec4(0.5, 0.5, 0, 0));
}
}
}