From 0ac622accf9ed9457e3d8a81fa8e6e3ef0a4befc Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 3 Dec 2013 11:40:23 -0800 Subject: [PATCH] i965/blorp: Refactor code for computing fast clear align/scaledown factors. This will make it easier to add fast color clear support to MSAA buffers, since they have different alignment and scaling requirements. Reviewed-by: Chad Versace Reviewed-by: Anuj Phogat Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp index e9d851871e6..fa6e6d514d4 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp @@ -257,6 +257,11 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct brw_context *brw, memset(push_consts, 0xff, 4*sizeof(float)); fast_clear_op = GEN7_FAST_CLEAR_OP_FAST_CLEAR; + /* Figure out what the clear rectangle needs to be aligned to, and how + * much it needs to be scaled down. + */ + unsigned x_align, y_align, x_scaledown, y_scaledown; + /* From the Ivy Bridge PRM, Vol2 Part1 11.7 "MCS Buffer for Render * Target(s)", beneath the "Fast Color Clear" bullet (p327): * @@ -272,23 +277,10 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct brw_context *brw, * alignment size returned by intel_get_non_msrt_mcs_alignment(), but * with X alignment multiplied by 16 and Y alignment multiplied by 32. */ - unsigned x_align, y_align; intel_get_non_msrt_mcs_alignment(brw, irb->mt, &x_align, &y_align); x_align *= 16; y_align *= 32; - /* From BSpec: 3D-Media-GPGPU Engine > 3D Pipeline > Pixel > Pixel - * Backend > MCS Buffer for Render Target(s) [DevIVB+] > Table "Color - * Clear of Non-MultiSampled Render Target Restrictions": - * - * Clear rectangle must be aligned to two times the number of pixels in - * the table shown below due to 16x16 hashing across the slice. - */ - x0 = ROUND_DOWN_TO(x0, 2 * x_align); - y0 = ROUND_DOWN_TO(y0, 2 * y_align); - x1 = ALIGN(x1, 2 * x_align); - y1 = ALIGN(y1, 2 * y_align); - /* From the Ivy Bridge PRM, Vol2 Part1 11.7 "MCS Buffer for Render * Target(s)", beneath the "Fast Color Clear" bullet (p327): * @@ -300,12 +292,24 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct brw_context *brw, * The X and Y scale down factors in the table that follows are each * equal to half the alignment value computed above. */ - unsigned x_scaledown = x_align / 2; - unsigned y_scaledown = y_align / 2; - x0 /= x_scaledown; - y0 /= y_scaledown; - x1 /= x_scaledown; - y1 /= y_scaledown; + x_scaledown = x_align / 2; + y_scaledown = y_align / 2; + + /* From BSpec: 3D-Media-GPGPU Engine > 3D Pipeline > Pixel > Pixel + * Backend > MCS Buffer for Render Target(s) [DevIVB+] > Table "Color + * Clear of Non-MultiSampled Render Target Restrictions": + * + * Clear rectangle must be aligned to two times the number of pixels in + * the table shown below due to 16x16 hashing across the slice. + */ + x_align *= 2; + y_align *= 2; + + /* Do the alignment and scaledown. */ + x0 = ROUND_DOWN_TO(x0, x_align) / x_scaledown; + y0 = ROUND_DOWN_TO(y0, y_align) / y_scaledown; + x1 = ALIGN(x1, x_align) / x_scaledown; + y1 = ALIGN(y1, y_align) / y_scaledown; } } -- 2.30.2