mesa: Fix a crash in update_texture_state() for external texture type
authorAbdiel Janulgue <abdiel.janulgue@linux.intel.com>
Fri, 12 Oct 2012 08:51:03 +0000 (11:51 +0300)
committerBrian Paul <brianp@vmware.com>
Mon, 15 Oct 2012 13:49:14 +0000 (07:49 -0600)
NOTE: This is a candidate for the stable branch.

Signed-off-by: Abdiel <abdiel.janulgue@intel.com>
Signed-off-by: Brian Paul <brianp@vmware.com>
src/mesa/main/texobj.c
src/mesa/main/texstate.c

index 513f3bb0567d396176b40d5c0610aa1dd094f66e..224d8a825dc753ab17cf0379ede6f8ba9a443f89 100644 (file)
@@ -769,6 +769,9 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
          target = GL_TEXTURE_BUFFER;
          break;
       case TEXTURE_EXTERNAL_INDEX:
+         dims = 2;
+         target = GL_TEXTURE_EXTERNAL_OES;
+         break;
       default:
          /* no-op */
          return NULL;
index 1fd09e98538c3cdc8ccf727f7e03324c88d9ec4c..0e5ba44ed49620f30cf597919ad9f5cd25dfc062 100644 (file)
@@ -600,6 +600,13 @@ update_texture_state( struct gl_context *ctx )
 
             texTarget = (gl_texture_index) (ffs(enabledTargets) - 1);
             texObj = _mesa_get_fallback_texture(ctx, texTarget);
+            
+            assert(texObj);
+            if (!texObj) {
+               /* invalid fallback texture: don't enable the texture unit */
+               continue;
+            }
+
             _mesa_reference_texobj(&texUnit->_Current, texObj);
             texUnit->_ReallyEnabled = 1 << texTarget;
          }