From: Alex Deucher Date: Thu, 5 May 2011 22:54:03 +0000 (-0400) Subject: r600g: fix up the rules for enabling SOURCE_FORMAT(EXPORT_NORM) X-Git-Tag: 062012170305~5920 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5939bc03bc15b9b1131463ffad04a7b2d987074d;p=profile%2Fivi%2Fmesa.git r600g: fix up the rules for enabling SOURCE_FORMAT(EXPORT_NORM) Setting SOURCE_FORMAT to EXPORT_NORM is an optimization. Leaving SOURCE_FORMAT at 0 will work in all cases, but is less efficient. The conditions for the setting the EXPORT_NORM optimization are as follows: R600/RV6xx: BLEND_CLAMP is enabled BLEND_FLOAT32 is disabled 11-bit or smaller UNORM/SNORM/SRGB R7xx/evergreen: 11-bit or smaller UNORM/SNORM/SRGB 16-bit or smaller FLOAT Signed-off-by: Alex Deucher --- diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index d60c153..9757811 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -710,14 +710,20 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state S_028C70_ENDIAN(endian); - /* we can only set the export size if any thing is snorm/unorm component is > 11 bits, - if we aren't a float, sint or uint */ + /* EXPORT_NORM is an optimzation that can be enabled for better + * performance in certain cases. + * EXPORT_NORM can be enabled if: + * - 11-bit or smaller UNORM/SNORM/SRGB + * - 16-bit or smaller FLOAT + */ /* FIXME: This should probably be the same for all CBs if we want * useful alpha tests. */ if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS && - desc->channel[i].size < 12 && desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT && - ntype != V_028C70_NUMBER_UINT && ntype != V_028C70_NUMBER_SINT) { - color_info |= S_028C70_SOURCE_FORMAT(V_028C70_EXPORT_4C_16BPC); + ((desc->channel[i].size < 12 && + desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT && + ntype != V_028C70_NUMBER_UINT && ntype != V_028C70_NUMBER_SINT) || + (desc->channel[i].size < 17 && + desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT))) { rctx->export_16bpc = true; } else { rctx->export_16bpc = false; diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index 90c5ba2..3f979cf 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -770,11 +770,36 @@ static void r600_cb(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta S_0280A0_NUMBER_TYPE(ntype) | S_0280A0_ENDIAN(endian); - /* on R600 this can't be set if BLEND_CLAMP isn't set, - if BLEND_FLOAT32 is set of > 11 bits in a UNORM or SNORM */ - if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS && - desc->channel[i].size < 12) - color_info |= S_0280A0_SOURCE_FORMAT(V_0280A0_EXPORT_NORM); + /* EXPORT_NORM is an optimzation that can be enabled for better + * performance in certain cases + */ + if (rctx->family < CHIP_RV770) { + /* EXPORT_NORM can be enabled if: + * - 11-bit or smaller UNORM/SNORM/SRGB + * - BLEND_CLAMP is enabled + * - BLEND_FLOAT32 is disabled + */ + if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS && + (desc->channel[i].size < 12 && + desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT && + ntype != V_0280A0_NUMBER_UINT && + ntype != V_0280A0_NUMBER_SINT) && + G_0280A0_BLEND_CLAMP(color_info) && + !G_0280A0_BLEND_FLOAT32(color_info)) + color_info |= S_0280A0_SOURCE_FORMAT(V_0280A0_EXPORT_NORM); + } else { + /* EXPORT_NORM can be enabled if: + * - 11-bit or smaller UNORM/SNORM/SRGB + * - 16-bit or smaller FLOAT + */ + if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS && + ((desc->channel[i].size < 12 && + desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT && + ntype != V_0280A0_NUMBER_UINT && ntype != V_0280A0_NUMBER_SINT) || + (desc->channel[i].size < 17 && + desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT))) + color_info |= S_0280A0_SOURCE_FORMAT(V_0280A0_EXPORT_NORM); + } r600_pipe_state_add_reg(rstate, R_028040_CB_COLOR0_BASE + cb * 4,