From 91332e455a530b86f897874919da29efa563fdf3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 26 Oct 2012 15:04:46 +0100 Subject: [PATCH] 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(+) diff --git a/src/gallium/targets/graw-null/graw_util.c b/src/gallium/targets/graw-null/graw_util.c index 09cba895d2a..07693e85f6a 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 893170fe597..eac9627e860 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 d46ce554069..5f9d8d2d910 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 04b57323d8a..f31034406f6 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 3eee2b2ab4e..0bcecd7436a 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 21ec7b7b0b5..e9b0829e6ce 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 6f4b9f6e7e8..ca6fe3ec9f2 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 dc3a73796e7..02d78ad1fa8 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 f24490e349f..6100af3192c 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 ea07b8d692d..af3e1c36f15 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 0709447f33e..7dc35eb43a3 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 7406fbc8956..be1f0352029 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 d3de15c32c0..ce81c9c0217 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 f6b2aa96c9d..7b6507eab11 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 6c6f065af53..7fb97d84948 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, -- 2.30.2