iris: Fix fast-clears of swizzled alpha formats
Resources with alpha formats that are mapped to R are fast-cleared with
the wrong clear color.
When such resources with are cleared via iris_clear_texture,
isl_color_value_unpack places channel data in the R channel.
convert_fast_clear_color then overwrites the channel with 0.
To avoid zeroing the clear color, move convert_fast_clear_color to the
other callers of clear_color: iris_clear and iris_clear_render_target.
Enables iris to pass the "A" case of the fcc-clear-tex piglit test.
v2. Rename convert_fast_clear_color to convert_clear_color. (Ken)
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3670
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7345>
diff --git a/src/gallium/drivers/iris/iris_clear.c b/src/gallium/drivers/iris/iris_clear.c
index cd4b84d..c2009ba 100644
--- a/src/gallium/drivers/iris/iris_clear.c
+++ b/src/gallium/drivers/iris/iris_clear.c
@@ -135,14 +135,12 @@
}
static union isl_color_value
-convert_fast_clear_color(struct iris_context *ice,
- struct iris_resource *res,
- const union isl_color_value color)
+convert_clear_color(enum pipe_format format,
+ const union pipe_color_union *color)
{
- union isl_color_value override_color = color;
- struct pipe_resource *p_res = (void *) res;
+ /* pipe_color_union and isl_color_value are interchangeable */
+ union isl_color_value override_color = *(union isl_color_value *)color;
- const enum pipe_format format = p_res->format;
const struct util_format_description *desc =
util_format_description(format);
unsigned colormask = util_format_colormask(desc);
@@ -214,8 +212,6 @@
struct iris_batch *batch = &ice->batches[IRIS_BATCH_RENDER];
struct pipe_resource *p_res = (void *) res;
- color = convert_fast_clear_color(ice, res, color);
-
bool color_changed = !!memcmp(&res->aux.clear_color, &color,
sizeof(color));
@@ -694,9 +690,6 @@
}
if (buffers & PIPE_CLEAR_COLOR) {
- /* pipe_color_union and isl_color_value are interchangeable */
- union isl_color_value *color = (void *) p_color;
-
for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
if (buffers & (PIPE_CLEAR_COLOR0 << i)) {
struct pipe_surface *psurf = cso_fb->cbufs[i];
@@ -706,7 +699,7 @@
clear_color(ice, psurf->texture, psurf->u.tex.level, &box,
true, isurf->view.format, isurf->view.swizzle,
- *color);
+ convert_clear_color(psurf->format, p_color));
}
}
}
@@ -804,12 +797,10 @@
.depth = psurf->u.tex.last_layer - psurf->u.tex.first_layer + 1
};
- /* pipe_color_union and isl_color_value are interchangeable */
- union isl_color_value *color = (void *) p_color;
-
clear_color(ice, psurf->texture, psurf->u.tex.level, &box,
render_condition_enabled,
- isurf->view.format, isurf->view.swizzle, *color);
+ isurf->view.format, isurf->view.swizzle,
+ convert_clear_color(psurf->format, p_color));
}
/**