Skip to content

Commit

Permalink
Big hack to make fast clears work on SKL
Browse files Browse the repository at this point in the history
For whatever reason it seems that certain formats require the clear
color to be programmed as a normalized integer rather than a float.
This doesn't seem to be mentioned in the specs and I've just
discovered this by trial and error.

I can't work out what is going on with MESA_FORMAT_R8G8B8X8_SRGB so
I've just disabled it. R8G8B8A8_SRGB works fine.
  • Loading branch information
bpeel committed Nov 12, 2015
1 parent da7edcb commit 2c7b2dd
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
Expand Up @@ -416,6 +416,36 @@ set_fast_clear_color(struct brw_context *brw,
}

if (brw->gen >= 9) {
/* BEGIN HACK
*
* By experimentation it seems that some formats expect a normalised
* integer value rather than a float.
*
* TODO: Find out why!
*/
int max = 0;

switch (mt->format) {
case MESA_FORMAT_R8G8B8X8_UNORM:
case MESA_FORMAT_L_UNORM8:
case MESA_FORMAT_I_UNORM8:
max = 255;
break;
case MESA_FORMAT_RGBX_UNORM16:
case MESA_FORMAT_I_UNORM16:
case MESA_FORMAT_L_UNORM16:
max = 65535;
break;
default:
goto no_hack;
}

for (int i = 0; i < 4; i++)
override_color.ui[i] = roundf(override_color.f[i] * max);

no_hack:
/* END HACK */

mt->gen9_fast_clear_color = override_color;
} else {
mt->fast_clear_color_value = 0;
Expand Down Expand Up @@ -586,6 +616,9 @@ brw_meta_fast_clear(struct brw_context *brw, struct gl_framebuffer *fb,
if (!is_color_fast_clear_compatible(brw, format, &ctx->Color.ClearColor))
clear_type = REP_CLEAR;

if (brw->gen >= 9 && irb->mt->format == MESA_FORMAT_R8G8B8X8_SRGB)
clear_type = REP_CLEAR;

/* From the SNB PRM (Vol4_Part1):
*
* "Replicated data (Message Type = 111) is only supported when
Expand Down

0 comments on commit 2c7b2dd

Please sign in to comment.