[Mesa-dev] [PATCH 1/2] i965: Don't include missing components in the fast clear color
Neil Roberts
neil at linux.intel.com
Wed Nov 4 06:52:06 PST 2015
It seems that if you have a surface format with less than 4 components
then the sampler still reports the fast color clear value for the
components that are missing. So for example if you clear a GL_RED
surface to 1,1,1,1 then the sampling instructions will return 1,1,1,1
instead of 1,0,0,1. Normally this doesn't matter because fast color
clears are only available on Gen7+ and for that hardware we also
always set the texture swizzle to force the missing components to zero
or one. However if the blorp blitter is used then the swizzle is not
programmed in the surface state so it doesn't work. To avoid this
situation this patch makes it just force the surface's clear color to
0 or 1 for any missing components of the surface's format.
---
src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
index 69fe7b4..ed26a44 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
@@ -361,13 +361,20 @@ is_color_fast_clear_compatible(struct brw_context *brw,
* SURFACE_STATE.
*/
static uint32_t
-compute_fast_clear_color_bits(const union gl_color_union *color)
+compute_fast_clear_color_bits(mesa_format format,
+ const union gl_color_union *color)
{
uint32_t bits = 0;
for (int i = 0; i < 4; i++) {
- /* Testing for non-0 works for integer and float colors */
- if (color->f[i] != 0.0f)
+ /* Testing for non-0 works for integer and float colors. If the
+ * component doesn't exist in the format then force the color to 0 for
+ * the RGB components and 1 for the alpha.
+ */
+ if (_mesa_format_has_color_component(format, i) ?
+ (color->f[i] != 0.0f) :
+ (i == 3)) {
bits |= 1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i));
+ }
}
return bits;
}
@@ -505,7 +512,8 @@ brw_meta_fast_clear(struct brw_context *brw, struct gl_framebuffer *fb,
switch (clear_type) {
case FAST_CLEAR:
irb->mt->fast_clear_color_value =
- compute_fast_clear_color_bits(&ctx->Color.ClearColor);
+ compute_fast_clear_color_bits(irb->mt->format,
+ &ctx->Color.ClearColor);
irb->need_downsample = true;
/* If the buffer is already in INTEL_FAST_CLEAR_STATE_CLEAR, the
--
1.9.3
More information about the mesa-dev
mailing list