summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-01-26 16:04:47 -0700
committerBrian <[email protected]>2008-01-26 16:04:47 -0700
commit9ef61b98087603617702043c07633282148883e3 (patch)
tree008d73d6d3df437d8c7a9b2dd4b627cd4b3b5d47
parent856db7dee69083733a1d6e02a33bec4189387f60 (diff)
gallium: fix a few segfaults/assertions that can happen during context init
-rw-r--r--src/mesa/pipe/draw/draw_vertex_fetch.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c
index 1a9e38158d9..fb64723a193 100644
--- a/src/mesa/pipe/draw/draw_vertex_fetch.c
+++ b/src/mesa/pipe/draw/draw_vertex_fetch.c
@@ -79,7 +79,7 @@ FETCH_ATTRIB( R8G8B8A8_UNORM, 4, CVT_8_UNORM )
-static fetch_func get_fetch_func( unsigned format )
+static fetch_func get_fetch_func( enum pipe_format format )
{
switch (format) {
case PIPE_FORMAT_R32G32B32A32_FLOAT:
@@ -102,6 +102,8 @@ static fetch_func get_fetch_func( unsigned format )
return fetch_A8R8G8B8_UNORM;
case PIPE_FORMAT_R8G8B8A8_UNORM:
return fetch_R8G8B8A8_UNORM;
+ case 0:
+ return NULL;
default:
/* Lots of missing cases! */
assert(0);
@@ -127,13 +129,17 @@ transpose_4x4( float *out, const float *in )
void draw_update_vertex_fetch( struct draw_context *draw )
{
- //unsigned nr_attrs = draw->vertex_element_count;
- unsigned nr_attrs = draw->vertex_shader->state->num_inputs;
- unsigned i;
+ unsigned nr_attrs, i;
+
+ /* this may happend during context init */
+ if (!draw->vertex_shader)
+ return;
+
+ nr_attrs = draw->vertex_shader->state->num_inputs;
for (i = 0; i < nr_attrs; i++) {
unsigned buf = draw->vertex_element[i].vertex_buffer_index;
- unsigned format = draw->vertex_element[i].src_format;
+ enum pipe_format format = draw->vertex_element[i].src_format;
draw->vertex_fetch.src_ptr[i] = (const ubyte *) draw->user.vbuffer[buf] +
draw->vertex_buffer[buf].buffer_offset +