On 02/15/2012 07:01 PM, Eric Anholt wrote:
There are three reasons left for this function flagging it:
Re-computing completeness (and therefore the number of levels),
binding a new current texture object, or you're doing some sort of
fixed function (and nobody cares).  For other cases, like rebinding a
shader, we no longer trigger the driver recomputing every piece of
texture state.

Improves a VS state change microbenchmark by 14.8284% +/- 1.02% (n=10)
on gen7.  On the other hand, it causes GPU hangs on nexuiz.  Any clue
why this might be insufficient?

If you're asking: "why do we have to recompute texture state when binding a different fragment shader?"

One case is if fragment shader A calls texture2D() while shader B calls textureCube(). Depending on the shader, the _Current texture object would be different.


---
  src/mesa/main/texstate.c |   34 ++++++++++++++++++++++++++--------
  1 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 2dbf530..86b8b3d 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -577,7 +577,6 @@ update_texture_state( struct gl_context *ctx )
      */

     /* TODO: only set this if there are actual changes */
-   ctx->NewState |= _NEW_TEXTURE;

     /*
      * Update texture unit state.
@@ -588,6 +587,7 @@ update_texture_state( struct gl_context *ctx )
        GLbitfield enabledFragTargets = 0x0;
        GLbitfield enabledTargets = 0x0;
        GLuint texIndex;
+      struct gl_texture_object *oldObj = texUnit->_Current;

        /* Get the bitmask of texture target enables.
         * enableBits will be a mask of the TEXTURE_*_BIT flags indicating
@@ -609,10 +609,18 @@ update_texture_state( struct gl_context *ctx )

        enabledTargets = enabledVertTargets | enabledFragTargets;

+      /* This is not flagged with _NEW_TEXTURE, because the test for changing 
of
+       * the _Current texture object will cover every case where _ReallyEnabled
+       * could have changed.
+       */
        texUnit->_ReallyEnabled = 0x0;

        if (enabledTargets == 0x0) {
           /* neither vertex nor fragment processing uses this unit */
+        if (texUnit->_ReallyEnabled) {
+           ctx->NewState |= _NEW_TEXTURE;
+           texUnit->_ReallyEnabled = 0x0;
+        }
           continue;
        }

@@ -626,6 +634,10 @@ update_texture_state( struct gl_context *ctx )
           if (enabledTargets&  (1<<  texIndex)) {
              struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
              if (!texObj->_Complete) {
+              /* While _Complete is only consumed by us, this call also updates
+                 _MaxLevel, which drivers do need to see.
+               */

_Complete is also used by the gallium state tracker.


+              ctx->NewState |= _NEW_TEXTURE;
                 _mesa_test_texobj_completeness(ctx, texObj);
              }
              if (texObj->_Complete) {
@@ -652,22 +664,26 @@ update_texture_state( struct gl_context *ctx )
              _mesa_reference_texobj(&texUnit->_Current, texObj);
              texUnit->_ReallyEnabled = 1<<  texTarget;
           }
-         else {
-            /* fixed-function: texture unit is really disabled */
-            continue;
-         }
        }
+
+      if (oldObj != texUnit->_Current)
+        ctx->NewState |= _NEW_TEXTURE;
     }


     /* Determine which texture coordinate sets are actually needed */
     if (fprog) {
        const GLuint coordMask = (1<<  MAX_TEXTURE_COORD_UNITS) - 1;
+      GLuint new_coord_units = ((fprog->InputsRead>>  FRAG_ATTRIB_TEX0)&
+                               coordMask);
        /* Note that this gets consumed by update_ffvs_texture_state(). */
-      ctx->Texture._EnabledCoordUnits
-         = (fprog->InputsRead>>  FRAG_ATTRIB_TEX0)&  coordMask;
+      if (ctx->Texture._EnabledCoordUnits != new_coord_units) {
+        ctx->NewState |= _NEW_TEXTURE;
+        ctx->Texture._EnabledCoordUnits = new_coord_units;
+      }
     }
     else {
+      ctx->NewState |= _NEW_TEXTURE;
        update_fffs_texture_state(ctx);
     }

@@ -675,8 +691,10 @@ update_texture_state( struct gl_context *ctx )
      * program.  Those state flags are only used in the case of fixed function
      * vertex shading, in the tnl pipeline or ff_vertex_shader.
      */
-   if (!vprog)
+   if (!vprog) {
+      ctx->NewState |= _NEW_TEXTURE;
        update_ffvs_texture_state(ctx);
+   }
  }



_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to