Mesa (master): graw: Ensure new members are zeroed.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Fri Oct 26 15:03:08 UTC 2012


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

Author: José Fonseca <jfonseca at vmware.com>
Date:   Fri Oct 26 15:04:46 2012 +0100

graw: Ensure new members are zeroed.

Several new state members were added, and they were not being zeroed,
causing random crashes.

---

 src/gallium/targets/graw-null/graw_util.c |    3 +++
 src/gallium/tests/graw/fs-fragcoord.c     |    1 +
 src/gallium/tests/graw/fs-frontface.c     |    1 +
 src/gallium/tests/graw/fs-test.c          |    1 +
 src/gallium/tests/graw/fs-write-z.c       |    1 +
 src/gallium/tests/graw/gs-test.c          |    2 ++
 src/gallium/tests/graw/quad-sample.c      |    1 +
 src/gallium/tests/graw/quad-tex.c         |    1 +
 src/gallium/tests/graw/shader-leak.c      |    1 +
 src/gallium/tests/graw/tex-srgb.c         |    1 +
 src/gallium/tests/graw/tex-swizzle.c      |    1 +
 src/gallium/tests/graw/tri-gs.c           |    1 +
 src/gallium/tests/graw/tri-instanced.c    |    1 +
 src/gallium/tests/graw/tri.c              |    1 +
 src/gallium/tests/graw/vs-test.c          |    2 ++
 15 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/gallium/targets/graw-null/graw_util.c b/src/gallium/targets/graw-null/graw_util.c
index 09cba89..07693e8 100644
--- a/src/gallium/targets/graw-null/graw_util.c
+++ b/src/gallium/targets/graw-null/graw_util.c
@@ -21,6 +21,7 @@ graw_parse_geometry_shader(struct pipe_context *pipe,
    if (!tgsi_text_translate(text, tokens, Elements(tokens)))
       return NULL;
 
+   memset(&state, 0, sizeof state);
    state.tokens = tokens;
    return pipe->create_gs_state(pipe, &state);
 }
@@ -35,6 +36,7 @@ graw_parse_vertex_shader(struct pipe_context *pipe,
    if (!tgsi_text_translate(text, tokens, Elements(tokens)))
       return NULL;
 
+   memset(&state, 0, sizeof state);
    state.tokens = tokens;
    return pipe->create_vs_state(pipe, &state);
 }
@@ -49,6 +51,7 @@ graw_parse_fragment_shader(struct pipe_context *pipe,
    if (!tgsi_text_translate(text, tokens, Elements(tokens)))
       return NULL;
 
+   memset(&state, 0, sizeof state);
    state.tokens = tokens;
    return pipe->create_fs_state(pipe, &state);
 }
diff --git a/src/gallium/tests/graw/fs-fragcoord.c b/src/gallium/tests/graw/fs-fragcoord.c
index 893170f..eac9627 100644
--- a/src/gallium/tests/graw/fs-fragcoord.c
+++ b/src/gallium/tests/graw/fs-fragcoord.c
@@ -64,6 +64,7 @@ set_vertices(void)
    handle = info.ctx->create_vertex_elements_state(info.ctx, 2, ve);
    info.ctx->bind_vertex_elements_state(info.ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/fs-frontface.c b/src/gallium/tests/graw/fs-frontface.c
index d46ce55..5f9d8d2 100644
--- a/src/gallium/tests/graw/fs-frontface.c
+++ b/src/gallium/tests/graw/fs-frontface.c
@@ -86,6 +86,7 @@ set_vertices(void)
    handle = info.ctx->create_vertex_elements_state(info.ctx, 2, ve);
    info.ctx->bind_vertex_elements_state(info.ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/fs-test.c b/src/gallium/tests/graw/fs-test.c
index 04b5732..f310344 100644
--- a/src/gallium/tests/graw/fs-test.c
+++ b/src/gallium/tests/graw/fs-test.c
@@ -213,6 +213,7 @@ static void set_vertices( void )
    handle = ctx->create_vertex_elements_state(ctx, 3, ve);
    ctx->bind_vertex_elements_state(ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/fs-write-z.c b/src/gallium/tests/graw/fs-write-z.c
index 3eee2b2..0bcecd7 100644
--- a/src/gallium/tests/graw/fs-write-z.c
+++ b/src/gallium/tests/graw/fs-write-z.c
@@ -90,6 +90,7 @@ set_vertices(void)
    handle = info.ctx->create_vertex_elements_state(info.ctx, 2, ve);
    info.ctx->bind_vertex_elements_state(info.ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/gs-test.c b/src/gallium/tests/graw/gs-test.c
index 21ec7b7..e9b0829 100644
--- a/src/gallium/tests/graw/gs-test.c
+++ b/src/gallium/tests/graw/gs-test.c
@@ -248,6 +248,8 @@ static void set_vertices( void )
    handle = ctx->create_vertex_elements_state(ctx, 4, ve);
    ctx->bind_vertex_elements_state(ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
+
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
    if (draw_strip) {
diff --git a/src/gallium/tests/graw/quad-sample.c b/src/gallium/tests/graw/quad-sample.c
index 6f4b9f6..ca6fe3e 100644
--- a/src/gallium/tests/graw/quad-sample.c
+++ b/src/gallium/tests/graw/quad-sample.c
@@ -97,6 +97,7 @@ static void set_vertices( void )
    handle = ctx->create_vertex_elements_state(ctx, 2, ve);
    ctx->bind_vertex_elements_state(ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/quad-tex.c b/src/gallium/tests/graw/quad-tex.c
index dc3a737..02d78ad 100644
--- a/src/gallium/tests/graw/quad-tex.c
+++ b/src/gallium/tests/graw/quad-tex.c
@@ -53,6 +53,7 @@ static void set_vertices( void )
    handle = info.ctx->create_vertex_elements_state(info.ctx, 2, ve);
    info.ctx->bind_vertex_elements_state(info.ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/shader-leak.c b/src/gallium/tests/graw/shader-leak.c
index f24490e..6100af3 100644
--- a/src/gallium/tests/graw/shader-leak.c
+++ b/src/gallium/tests/graw/shader-leak.c
@@ -87,6 +87,7 @@ static void set_vertices( void )
    handle = ctx->create_vertex_elements_state(ctx, 2, ve);
    ctx->bind_vertex_elements_state(ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/tex-srgb.c b/src/gallium/tests/graw/tex-srgb.c
index ea07b8d..af3e1c3 100644
--- a/src/gallium/tests/graw/tex-srgb.c
+++ b/src/gallium/tests/graw/tex-srgb.c
@@ -69,6 +69,7 @@ set_vertices(struct vertex *verts, unsigned num_verts)
    handle = info.ctx->create_vertex_elements_state(info.ctx, 2, ve);
    info.ctx->bind_vertex_elements_state(info.ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/tex-swizzle.c b/src/gallium/tests/graw/tex-swizzle.c
index 0709447..7dc35eb 100644
--- a/src/gallium/tests/graw/tex-swizzle.c
+++ b/src/gallium/tests/graw/tex-swizzle.c
@@ -51,6 +51,7 @@ static void set_vertices(void)
    handle = info.ctx->create_vertex_elements_state(info.ctx, 2, ve);
    info.ctx->bind_vertex_elements_state(info.ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/tri-gs.c b/src/gallium/tests/graw/tri-gs.c
index 7406fbc..be1f035 100644
--- a/src/gallium/tests/graw/tri-gs.c
+++ b/src/gallium/tests/graw/tri-gs.c
@@ -88,6 +88,7 @@ static void set_vertices( void )
    handle = ctx->create_vertex_elements_state(ctx, 2, ve);
    ctx->bind_vertex_elements_state(ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/tri-instanced.c b/src/gallium/tests/graw/tri-instanced.c
index d3de15c..ce81c9c 100644
--- a/src/gallium/tests/graw/tri-instanced.c
+++ b/src/gallium/tests/graw/tri-instanced.c
@@ -130,6 +130,7 @@ static void set_vertices( void )
    handle = ctx->create_vertex_elements_state(ctx, 3, ve);
    ctx->bind_vertex_elements_state(ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    /* vertex data */
    vbuf[0].stride = sizeof( struct vertex );
diff --git a/src/gallium/tests/graw/tri.c b/src/gallium/tests/graw/tri.c
index f6b2aa9..7b6507e 100644
--- a/src/gallium/tests/graw/tri.c
+++ b/src/gallium/tests/graw/tri.c
@@ -52,6 +52,7 @@ static void set_vertices( void )
    handle = info.ctx->create_vertex_elements_state(info.ctx, 2, ve);
    info.ctx->bind_vertex_elements_state(info.ctx, handle);
 
+   memset(&vbuf, 0, sizeof vbuf);
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
diff --git a/src/gallium/tests/graw/vs-test.c b/src/gallium/tests/graw/vs-test.c
index 6c6f065..7fb97d8 100644
--- a/src/gallium/tests/graw/vs-test.c
+++ b/src/gallium/tests/graw/vs-test.c
@@ -170,6 +170,8 @@ static void set_vertices( void )
       }
    }
 
+   memset(&vbuf, 0, sizeof vbuf);
+
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
    vbuf.buffer = pipe_buffer_create_with_data(ctx,




More information about the mesa-commit mailing list