r600g: fix up the rules for enabling SOURCE_FORMAT(EXPORT_NORM)
authorAlex Deucher <alexdeucher@gmail.com>
Thu, 5 May 2011 22:54:03 +0000 (18:54 -0400)
committerAlex Deucher <alexdeucher@gmail.com>
Thu, 5 May 2011 22:54:03 +0000 (18:54 -0400)
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 <alexdeucher@gmail.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_state.c

index d60c153b4821e93348bf0c27f67587b9e2d99bb8..9757811e8b6b37e82eaef1bf0c71541a64f6de84 100644 (file)
@@ -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;
index 90c5ba2b31e7b7c179e1b404cd0f70e156c28b5f..3f979cf170f0c53742db6cacbec58c2cd08693b1 100644 (file)
@@ -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,