Mesa (master): i965: Prevent using a zero sized (or of unknown type) vertex array

Chris Wilson ickle at kemper.freedesktop.org
Fri Mar 4 10:00:33 UTC 2011


Module: Mesa
Branch: master
Commit: b93684f5f311f89c965960ab42bfea71a397b180
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b93684f5f311f89c965960ab42bfea71a397b180

Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Mar  3 11:25:30 2011 +0000

i965: Prevent using a zero sized (or of unknown type) vertex array

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

---

 src/mesa/drivers/dri/i965/brw_draw_upload.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 185f1ff..351ae07 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -208,7 +208,7 @@ static GLuint get_surface_type( GLenum type, GLuint size,
       case GL_UNSIGNED_SHORT: return ushort_types_scale[size];
       case GL_UNSIGNED_BYTE: return ubyte_types_scale[size];
       default: assert(0); return 0;
-      }      
+      }
    }
 }
 
@@ -225,11 +225,11 @@ static GLuint get_size( GLenum type )
    case GL_UNSIGNED_INT: return sizeof(GLuint);
    case GL_UNSIGNED_SHORT: return sizeof(GLushort);
    case GL_UNSIGNED_BYTE: return sizeof(GLubyte);
-   default: return 0;
-   }      
+   default: assert(0); return 0;
+   }
 }
 
-static GLuint get_index_type(GLenum type) 
+static GLuint get_index_type(GLenum type)
 {
    switch (type) {
    case GL_UNSIGNED_BYTE:  return BRW_INDEX_BYTE;
@@ -295,7 +295,8 @@ static void brw_prepare_vertices(struct brw_context *brw)
       struct brw_vertex_element *input = &brw->vb.inputs[i];
 
       vs_inputs &= ~(1 << i);
-      brw->vb.enabled[brw->vb.nr_enabled++] = input;
+      if (input->glarray->Size && get_size(input->glarray->Type))
+         brw->vb.enabled[brw->vb.nr_enabled++] = input;
    }
 
    if (brw->vb.nr_enabled == 0)




More information about the mesa-commit mailing list