<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 19, 2016 at 2:29 PM, Ben Widawsky <span dir="ltr"><<a href="mailto:benjamin.widawsky@intel.com" target="_blank">benjamin.widawsky@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 16-10-11 22:26:33, Topi Pohjolainen wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
And fix a mangled comment while at it.<br>
<br>
Signed-off-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com" target="_blank">topi.pohjolainen@intel.com</a>><br>
CC: Ben Widawsky <<a href="mailto:benjamin.widawsky@intel.com" target="_blank">benjamin.widawsky@intel.com</a>><br>
CC: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com" target="_blank">jason.ekstrand@intel.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_<wbr>blorp.c | 7 +++-<br>
src/mesa/drivers/dri/i965/brw_<wbr>meta_util.c | 56 +++++++++++++++++-------------<wbr>-<br>
src/mesa/drivers/dri/i965/brw_<wbr>meta_util.h | 10 ++++--<br>
3 files changed, 45 insertions(+), 28 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c b/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
index b6c27982..f301192 100644<br>
--- a/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
+++ b/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
@@ -809,12 +809,17 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
brw, irb->mt);<br>
<br>
if (can_fast_clear) {<br>
+ union gl_color_union override_color;<br>
+ brw_meta_convert_fast_clear_co<wbr>lor(brw, irb->mt, &ctx->Color.ClearColor,<br>
+ &override_color);<br>
+<br>
/* Record the clear color in the miptree so that it will be<br>
* programmed in SURFACE_STATE by later rendering and resolve<br>
* operations.<br>
*/<br>
const bool color_updated = brw_meta_set_fast_clear_color(<br>
- brw, irb->mt, &ctx->Color.ClearColor);<br>
+ brw, &irb->mt->gen9_fast_clear_colo<wbr>r,<br>
+ &override_color);<br>
<br>
/* If the buffer is already in INTEL_FAST_CLEAR_STATE_CLEAR, and the<br>
* buffer isn't compressed, the clear is redundant and can be skipped.<br>
diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.c b/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.c<br>
index 499b6ea..1badea1 100644<br>
--- a/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.c<br>
+++ b/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.c<br>
@@ -372,15 +372,14 @@ brw_is_color_fast_clear_compat<wbr>ible(struct brw_context *brw,<br>
/**<br>
* Convert the given color to a bitfield suitable for ORing into DWORD 7 of<br>
* SURFACE_STATE (DWORD 12-15 on SKL+).<br>
- *<br>
- * Returned boolean tells if the given color differs from the stored.<br>
*/<br>
-bool<br>
-brw_meta_set_fast_clear_color<wbr>(struct brw_context *brw,<br>
- struct intel_mipmap_tree *mt,<br>
- const union gl_color_union *color)<br>
+void<br>
+brw_meta_convert_fast_clear_c<wbr>olor(const struct brw_context *brw,<br>
+ const struct intel_mipmap_tree *mt,<br>
+ const union gl_color_union *color,<br>
+ union gl_color_union *override_color)<br>
</blockquote>
<br></div></div>
I think it makes a lot more sense to return the color, my suggestion would be<br>
(but whatever you like)...<br>
union gl_color_union<br>
brw_meta_convert_fast_clear_co<wbr>lor(const struct brw_context *brw,<br>
uint32_t format<br>
const union gl_color_union *color)<br></blockquote><div><br></div><div>Seems reasonable.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
{<br>
- union gl_color_union override_color = *color;<br>
+ *override_color = *color;<br>
<br>
/* The sampler doesn't look at the format of the surface when the fast<br>
* clear color is used so we need to implement luminance, intensity and<br>
@@ -388,55 +387,62 @@ brw_meta_set_fast_clear_color(<wbr>struct brw_context *brw,<br>
*/<br>
switch (_mesa_get_format_base_format(<wbr>mt->format)) {<br>
case GL_INTENSITY:<br>
- override_color.ui[3] = override_color.ui[0];<br>
+ override_color->ui[3] = override_color->ui[0];<br>
/* flow through */<br>
case GL_LUMINANCE:<br>
case GL_LUMINANCE_ALPHA:<br>
- override_color.ui[1] = override_color.ui[0];<br>
- override_color.ui[2] = override_color.ui[0];<br>
+ override_color->ui[1] = override_color->ui[0];<br>
+ override_color->ui[2] = override_color->ui[0];<br>
break;<br>
default:<br>
for (int i = 0; i < 3; i++) {<br>
if (!_mesa_format_has_color_compo<wbr>nent(mt->format, i))<br>
- override_color.ui[i] = 0;<br>
+ override_color->ui[i] = 0;<br>
}<br>
break;<br>
}<br>
<br>
if (!_mesa_format_has_color_compo<wbr>nent(mt->format, 3)) {<br>
if (_mesa_is_format_integer_color<wbr>(mt->format))<br>
- override_color.ui[3] = 1;<br>
+ override_color->ui[3] = 1;<br>
else<br>
- override_color.f[3] = 1.0f;<br>
+ override_color->f[3] = 1.0f;<br>
}<br>
<br>
- /* Handle linear→SRGB conversion */<br>
+ /* Handle linear to SRGB conversion */<br>
if (brw->ctx.Color.sRGBEnabled &&<br>
_mesa_get_srgb_format_linear(<wbr>mt->format) != mt->format) {<br>
for (int i = 0; i < 3; i++) {<br>
- override_color.f[i] =<br>
- util_format_linear_to_srgb_flo<wbr>at(override_color.f[i]);<br>
+ override_color->f[i] =<br>
+ util_format_linear_to_srgb_flo<wbr>at(override_color->f[i]);<br>
}<br>
}<br>
+}<br>
<br>
+/* Returned boolean tells if the given color differs from the current. */<br>
+bool<br>
+brw_meta_set_fast_clear_color<wbr>(struct brw_context *brw,<br>
+ union gl_color_union *curr_color,<br>
+ const union gl_color_union *new_color)<br>
+{<br></blockquote></div></div></blockquote><div><br></div><div>Ugh... I really hate that this function even exists. Why are we storing clear color as "the bits you shove in the hardware" and not as 4 ints/floats????? In any case, I've got plans to fix it eventually so don't worry about it. Rant over.<br><br></div><div>This patch is<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
bool updated;<br>
+<br>
if (brw->gen >= 9) {<br>
- updated = memcmp(&mt->gen9_fast_clear_co<wbr>lor, &override_color,<br>
- sizeof(mt->gen9_fast_clear_co<wbr>lor));<br>
- mt->gen9_fast_clear_color = override_color;<br>
+ updated = memcmp(curr_color, new_color, sizeof(*curr_color));<br>
+ *curr_color = *new_color;<br>
} else {<br>
- const uint32_t old_color_value = mt->fast_clear_color_value;<br>
+ const uint32_t old_color_value = *(uint32_t *)curr_color;<br>
+ uint32_t adjusted = 0;<br>
<br>
- mt->fast_clear_color_value = 0;<br>
for (int i = 0; i < 4; i++) {<br>
/* Testing for non-0 works for integer and float colors */<br>
- if (override_color.f[i] != 0.0f) {<br>
- mt->fast_clear_color_value |=<br>
- 1 << (GEN7_SURFACE_CLEAR_COLOR_SHIF<wbr>T + (3 - i));<br>
+ if (new_color->f[i] != 0.0f) {<br>
+ adjusted |= 1 << (GEN7_SURFACE_CLEAR_COLOR_SHIF<wbr>T + (3 - i));<br>
}<br>
}<br>
<br>
- updated = (old_color_value != mt->fast_clear_color_value);<br>
+ updated = (old_color_value != adjusted);<br>
+ *(uint32_t *)curr_color = adjusted;<br>
}<br>
</blockquote>
<br></div></div>
Pretty sure you can remove the mt->fast_clear_color_value field after this<br>
change.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
return updated;<br>
diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.h b/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.h<br>
index b9c4eac..c0e3100 100644<br>
--- a/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.h<br>
+++ b/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.h<br>
@@ -42,10 +42,16 @@ brw_meta_mirror_clip_and_sciss<wbr>or(const struct gl_context *ctx,<br>
GLfloat *dstX1, GLfloat *dstY1,<br>
bool *mirror_x, bool *mirror_y);<br>
<br>
+void<br>
+brw_meta_convert_fast_clear_c<wbr>olor(const struct brw_context *brw,<br>
+ const struct intel_mipmap_tree *mt,<br>
+ const union gl_color_union *color,<br>
+ union gl_color_union *override_color);<br>
+<br>
bool<br>
brw_meta_set_fast_clear_color(<wbr>struct brw_context *brw,<br>
- struct intel_mipmap_tree *mt,<br>
- const union gl_color_union *color);<br>
+ union gl_color_union *curr_color,<br>
+ const union gl_color_union *new_color);<br>
<br>
bool<br>
brw_is_color_fast_clear_compat<wbr>ible(struct brw_context *brw,<br>
</blockquote>
<br></span>
I don't see any other problems<br>
<br>
Reviewed-by: Ben Widawsky <<a href="mailto:ben@bwidawsk.net" target="_blank">ben@bwidawsk.net</a>><span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Ben Widawsky, Intel Open Source Technology Center</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>