From de3218664a03ee116ca58db571f90a6914299a81 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 15 Sep 2011 12:34:43 +0100 Subject: [PATCH] r600g: set number type correctly for color buffers. If we get a scaled type assume its a real integer type (as textures are). Also fixup the blend bypass and blend clamp flags on evergreen as per the docs. Signed-off-by: Dave Airlie --- src/gallium/drivers/r600/evergreen_state.c | 34 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index 32fd74c..0e7e635 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -1297,6 +1297,7 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state const struct util_format_description *desc; struct r600_bo *bo[3]; int i; + unsigned blend_clamp = 0, blend_bypass = 0; surf = (struct r600_surface *)state->cbufs[cb]; rtex = (struct r600_resource_texture*)state->cbufs[cb]->texture; @@ -1325,11 +1326,20 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state break; } } - ntype = V_028C70_NUMBER_UNORM; if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) ntype = V_028C70_NUMBER_SRGB; - else if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) - ntype = V_028C70_NUMBER_SNORM; + else if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) { + if (desc->channel[i].normalized) + ntype = V_028C70_NUMBER_SNORM; + else + ntype = V_028C70_NUMBER_SINT; + } else if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) { + if (desc->channel[i].normalized) + ntype = V_028C70_NUMBER_UNORM; + else + ntype = V_028C70_NUMBER_UINT; + } else + ntype = V_028C70_NUMBER_UNORM; format = r600_translate_colorformat(surf->base.format); swap = r600_translate_colorswap(surf->base.format); @@ -1343,14 +1353,28 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state if ((format == FMT_32_32_32_32 || format == FMT_16_16_16_16) && rtex->force_int_type) ntype = V_028C70_NUMBER_UINT; + /* blend clamp should be set for all NORM/SRGB types */ + if (ntype == V_028C70_NUMBER_UNORM || ntype == V_028C70_NUMBER_SNORM || + ntype == V_028C70_NUMBER_SRGB) + blend_clamp = 1; + + /* set blend bypass according to docs if SINT/UINT or + 8/24 COLOR variants */ + if (ntype == V_028C70_NUMBER_UINT || ntype == V_028C70_NUMBER_SINT || + format == V_028C70_COLOR_8_24 || format == V_028C70_COLOR_24_8 || + format == V_028C70_COLOR_X24_8_32_FLOAT) { + blend_clamp = 0; + blend_bypass = 1; + } + color_info = S_028C70_FORMAT(format) | S_028C70_COMP_SWAP(swap) | S_028C70_ARRAY_MODE(rtex->array_mode[level]) | - S_028C70_BLEND_CLAMP(1) | + S_028C70_BLEND_CLAMP(blend_clamp) | + S_028C70_BLEND_BYPASS(blend_bypass) | S_028C70_NUMBER_TYPE(ntype) | S_028C70_ENDIAN(endian); - /* EXPORT_NORM is an optimzation that can be enabled for better * performance in certain cases. * EXPORT_NORM can be enabled if: -- 2.7.4