aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTopi Pohjolainen <[email protected]>2016-06-12 20:49:54 +0300
committerTopi Pohjolainen <[email protected]>2016-11-23 11:06:53 +0200
commit7c75fd9a5971d59e215ab2f04b4c06c3399d0211 (patch)
tree12b7a406812851e44ade86313e78996f3b7934b6 /src
parentf19e0967c993f5f60b4cc80e6bac00f1286494ab (diff)
i965/meta: Split conversion of color and setting it
And fix a mangled comment while at it. v2 (Ben): Return the converted color. Signed-off-by: Topi Pohjolainen <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_blorp.c7
-rw-r--r--src/mesa/drivers/dri/i965/brw_meta_util.c39
-rw-r--r--src/mesa/drivers/dri/i965/brw_meta_util.h9
3 files changed, 36 insertions, 19 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c
index 120b89ae6d6..56a30b4d552 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.c
+++ b/src/mesa/drivers/dri/i965/brw_blorp.c
@@ -817,12 +817,17 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,
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.
diff --git a/src/mesa/drivers/dri/i965/brw_meta_util.c b/src/mesa/drivers/dri/i965/brw_meta_util.c
index 499b6eacc0c..6d6b6923f14 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_util.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_util.c
@@ -372,13 +372,11 @@ brw_is_color_fast_clear_compatible(struct brw_context *brw,
/**
* 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;
@@ -410,7 +408,7 @@ brw_meta_set_fast_clear_color(struct brw_context *brw,
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++) {
@@ -419,24 +417,33 @@ brw_meta_set_fast_clear_color(struct brw_context *brw,
}
}
+ 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;
diff --git a/src/mesa/drivers/dri/i965/brw_meta_util.h b/src/mesa/drivers/dri/i965/brw_meta_util.h
index b9c4eac9c6c..93bc72cf258 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_util.h
+++ b/src/mesa/drivers/dri/i965/brw_meta_util.h
@@ -42,10 +42,15 @@ brw_meta_mirror_clip_and_scissor(const struct gl_context *ctx,
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,