[PATCH] meta: do fallback when texture is enabled for DrawPixels

Yuanhan Liu yuanhan.liu at linux.intel.com
Fri May 4 07:23:37 PDT 2012


If there are already some texture unit enabled, a fallback is needed,
or the original texture stuff would not work.

A much better way is to use multi-texture to handle this case: like
treat the pixels as texture 1 and the original texture as texture 2.
I haven't do much inverstigation on that way, but fallback is definitely
a much simpler and straight way.

This would fix oglc mipsel test case.

v2: Roland: do fallback also for active fragment shader
            no need to fallback for stencil buffer

v3: Roland: check texture fallback just for color format

Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
 src/mesa/drivers/common/meta.c |   45 +++++++++++++++++++++++++-----------=
---
 1 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.=
c
index 95336fc..3d22462 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2206,28 +2206,41 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
     */
    fallback =3D GL_FALSE;
    if (ctx->_ImageTransferState ||
+       ctx->FragmentProgram._Enabled ||
        ctx->Fog.Enabled) {
       fallback =3D GL_TRUE;
    }

    if (_mesa_is_color_format(format)) {
-      /* use more compact format when possible */
-      /* XXX disable special case for GL_LUMINANCE for now to work around
-       * apparent i965 driver bug (see bug #23670).
+      /*
+       * If there are already some texture unit enabled, a fallback is nee=
ded,
+       * or the original texture stuff would not work
+       *
+       * FIXME: we may use multi-texture to handle this case. But fallback=
 is
+       * definitely a much simple and straight way.
        */
-      if (/*format =3D=3D GL_LUMINANCE ||*/ format =3D=3D GL_LUMINANCE_ALP=
HA)
-         texIntFormat =3D format;
-      else
-         texIntFormat =3D GL_RGBA;
-
-      /* If we're not supposed to clamp the resulting color, then just
-       * promote our texture to fully float.  We could do better by
-       * just going for the matching set of channels, in floating
-       * point.
-       */
-      if (ctx->Color.ClampFragmentColor !=3D GL_TRUE &&
-	  ctx->Extensions.ARB_texture_float)
-	 texIntFormat =3D GL_RGBA32F;
+      if (ctx->Texture._EnabledUnits) {
+         fallback =3D GL_TRUE;
+      }
+      else {
+         /* use more compact format when possible */
+         /* XXX disable special case for GL_LUMINANCE for now to work arou=
nd
+          * apparent i965 driver bug (see bug #23670).
+          */
+         if (/*format =3D=3D GL_LUMINANCE ||*/ format =3D=3D GL_LUMINANCE_=
ALPHA)
+            texIntFormat =3D format;
+         else
+            texIntFormat =3D GL_RGBA;
+
+         /* If we're not supposed to clamp the resulting color, then just
+          * promote our texture to fully float.  We could do better by
+          * just going for the matching set of channels, in floating
+          * point.
+          */
+         if (ctx->Color.ClampFragmentColor !=3D GL_TRUE &&
+            ctx->Extensions.ARB_texture_float)
+            texIntFormat =3D GL_RGBA32F;
+         }
    }
    else if (_mesa_is_stencil_format(format)) {
       if (ctx->Extensions.ARB_fragment_program &&
--=20
1.7.3.1


More information about the mesa-dev mailing list