From 745fc95659bd19908f5bd85f73c92e4a92e28f85 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 8 Feb 2022 15:31:20 -0600 Subject: [PATCH] zink: Re-interpret formats when using vkCmdClearColorImage() vkCmdClearColorImage() doesn't take a view format so it always uses the underlying format of the image. If there's texture views going on, we need to manually mangle the colors into the image format. Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/drivers/zink/zink_clear.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_clear.c b/src/gallium/drivers/zink/zink_clear.c index 77f294f5279..6b6db04c3ca 100644 --- a/src/gallium/drivers/zink/zink_clear.c +++ b/src/gallium/drivers/zink/zink_clear.c @@ -555,8 +555,13 @@ fb_clears_apply_internal(struct zink_context *ctx, struct pipe_resource *pres, i else { struct pipe_surface *psurf = ctx->fb_state.cbufs[i]; struct zink_framebuffer_clear_data *clear = zink_fb_clear_element(fb_clear, 0); - union pipe_color_union color; - zink_fb_clear_util_unpack_clear_color(clear, psurf->format, &color); + union pipe_color_union color = clear->color.color; + + if (psurf->format != psurf->texture->format) { + uint32_t data[4]; + util_format_pack_rgba(psurf->format, data, color.ui, 1); + util_format_unpack_rgba(pres->format, color.ui, data, 1); + } clear_color_no_rp(ctx, res, &color, psurf->u.tex.level, psurf->u.tex.first_layer,