From: Jason Ekstrand Date: Tue, 23 May 2017 04:27:50 +0000 (-0700) Subject: i965/blorp: Refactor do_single_blorp_clear X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=076defba7a4a89972d34084fefa6227344280f77;p=mesa.git i965/blorp: Refactor do_single_blorp_clear Previously, we had two checks for can_fast_clear and a tiny bit of shared code in between. This commit pulls all of the fast clear code together and duplicates the tiny bit that declares some surface structs and calls blorp_surf_for_miptree. The duplication is no real loss and we're about to change the two in slightly different ways. Reviewed-by: Topi Pohjolainen Reviewed-by: Chad Versace --- diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c index 67b9fde3026..c3bdc6d4396 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp.c +++ b/src/mesa/drivers/dri/i965/brw_blorp.c @@ -778,9 +778,6 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb, can_fast_clear = false; const unsigned logical_layer = irb_logical_mt_layer(irb); - const enum intel_fast_clear_state fast_clear_state = - intel_miptree_get_fast_clear_state(irb->mt, irb->mt_level, - logical_layer); /* Surface state can only record one fast clear color value. Therefore * unless different levels/layers agree on the color it can be used to @@ -790,7 +787,13 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb, if (irb->layer_count > 1 || irb->mt_level || irb->mt_layer) can_fast_clear = false; + unsigned level = irb->mt_level; + const unsigned num_layers = fb->MaxNumLayers ? irb->layer_count : 1; + if (can_fast_clear) { + const enum intel_fast_clear_state fast_clear_state = + intel_miptree_get_fast_clear_state(irb->mt, irb->mt_level, + logical_layer); union isl_color_value clear_color = brw_meta_convert_fast_clear_color(brw, irb->mt, &ctx->Color.ClearColor); @@ -818,24 +821,19 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb, return false; } } - } - - const unsigned num_layers = fb->MaxNumLayers ? irb->layer_count : 1; - - /* We can't setup the blorp_surf until we've allocated the MCS above */ - struct isl_surf isl_tmp[2]; - struct blorp_surf surf; - unsigned level = irb->mt_level; - blorp_surf_for_miptree(brw, &surf, irb->mt, true, - (1 << ISL_AUX_USAGE_MCS) | - (1 << ISL_AUX_USAGE_CCS_E) | - (1 << ISL_AUX_USAGE_CCS_D), - &level, logical_layer, num_layers, isl_tmp); - if (can_fast_clear) { DBG("%s (fast) to mt %p level %d layers %d+%d\n", __FUNCTION__, irb->mt, irb->mt_level, irb->mt_layer, num_layers); + /* We can't setup the blorp_surf until we've allocated the MCS above */ + struct isl_surf isl_tmp[2]; + struct blorp_surf surf; + blorp_surf_for_miptree(brw, &surf, irb->mt, true, + (1 << ISL_AUX_USAGE_MCS) | + (1 << ISL_AUX_USAGE_CCS_E) | + (1 << ISL_AUX_USAGE_CCS_D), + &level, logical_layer, num_layers, isl_tmp); + /* Ivybrigde PRM Vol 2, Part 1, "11.7 MCS Buffer for Render Target(s)": * * "Any transition from any value in {Clear, Render, Resolve} to a @@ -875,6 +873,14 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb, DBG("%s (slow) to mt %p level %d layer %d+%d\n", __FUNCTION__, irb->mt, irb->mt_level, irb->mt_layer, num_layers); + struct isl_surf isl_tmp[2]; + struct blorp_surf surf; + blorp_surf_for_miptree(brw, &surf, irb->mt, true, + (1 << ISL_AUX_USAGE_MCS) | + (1 << ISL_AUX_USAGE_CCS_E) | + (1 << ISL_AUX_USAGE_CCS_D), + &level, logical_layer, num_layers, isl_tmp); + union isl_color_value clear_color; memcpy(clear_color.f32, ctx->Color.ClearColor.f, sizeof(float) * 4);