brw, irb->mt);
if (can_fast_clear) {
+ union gl_color_union override_color =
+ brw_meta_convert_fast_clear_color(brw, irb->mt,
+ &ctx->Color.ClearColor);
+
/* Record the clear color in the miptree so that it will be
* programmed in SURFACE_STATE by later rendering and resolve
* operations.
*/
const bool color_updated = brw_meta_set_fast_clear_color(
- brw, irb->mt, &ctx->Color.ClearColor);
+ brw, &irb->mt->gen9_fast_clear_color,
+ &override_color);
/* If the buffer is already in INTEL_FAST_CLEAR_STATE_CLEAR, the clear
* is redundant and can be skipped.
/**
* Convert the given color to a bitfield suitable for ORing into DWORD 7 of
* SURFACE_STATE (DWORD 12-15 on SKL+).
- *
- * Returned boolean tells if the given color differs from the stored.
*/
-bool
-brw_meta_set_fast_clear_color(struct brw_context *brw,
- struct intel_mipmap_tree *mt,
- const union gl_color_union *color)
+union gl_color_union
+brw_meta_convert_fast_clear_color(const struct brw_context *brw,
+ const struct intel_mipmap_tree *mt,
+ const union gl_color_union *color)
{
union gl_color_union override_color = *color;
override_color.f[3] = 1.0f;
}
- /* Handle linear→SRGB conversion */
+ /* Handle linear to SRGB conversion */
if (brw->ctx.Color.sRGBEnabled &&
_mesa_get_srgb_format_linear(mt->format) != mt->format) {
for (int i = 0; i < 3; i++) {
}
}
+ return override_color;
+}
+
+/* Returned boolean tells if the given color differs from the current. */
+bool
+brw_meta_set_fast_clear_color(struct brw_context *brw,
+ union gl_color_union *curr_color,
+ const union gl_color_union *new_color)
+{
bool updated;
+
if (brw->gen >= 9) {
- updated = memcmp(&mt->gen9_fast_clear_color, &override_color,
- sizeof(mt->gen9_fast_clear_color));
- mt->gen9_fast_clear_color = override_color;
+ updated = memcmp(curr_color, new_color, sizeof(*curr_color));
+ *curr_color = *new_color;
} else {
- const uint32_t old_color_value = mt->fast_clear_color_value;
+ const uint32_t old_color_value = *(uint32_t *)curr_color;
+ uint32_t adjusted = 0;
- mt->fast_clear_color_value = 0;
for (int i = 0; i < 4; i++) {
/* Testing for non-0 works for integer and float colors */
- if (override_color.f[i] != 0.0f) {
- mt->fast_clear_color_value |=
- 1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i));
+ if (new_color->f[i] != 0.0f) {
+ adjusted |= 1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i));
}
}
- updated = (old_color_value != mt->fast_clear_color_value);
+ updated = (old_color_value != adjusted);
+ *(uint32_t *)curr_color = adjusted;
}
return updated;
GLfloat *dstX1, GLfloat *dstY1,
bool *mirror_x, bool *mirror_y);
+union gl_color_union
+brw_meta_convert_fast_clear_color(const struct brw_context *brw,
+ const struct intel_mipmap_tree *mt,
+ const union gl_color_union *color);
+
bool
brw_meta_set_fast_clear_color(struct brw_context *brw,
- struct intel_mipmap_tree *mt,
- const union gl_color_union *color);
+ union gl_color_union *curr_color,
+ const union gl_color_union *new_color);
bool
brw_is_color_fast_clear_compatible(struct brw_context *brw,