diff options
author | Brian Paul <[email protected]> | 2011-04-04 17:24:09 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2011-04-04 17:42:43 -0600 |
commit | 6cab07685fa48174b310e52b26151a8fb8a8e6dc (patch) | |
tree | 2975999a01ba63fb6a27e9d7e08412f2ba53d588 /src/mesa/state_tracker | |
parent | e397b3a7c051b70a574e34096b70fc98e4e84b2c (diff) |
st/mesa: fix zero-sized user vertex buffer bug
Commit 4c4ab5668cd6df573db7b065f0493fb80ac70ab8 didn't properly
handle the stride==0 case.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=35961
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_draw.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 40afa436292..0eab4f73058 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -406,26 +406,36 @@ setup_non_interleaved_attribs(struct gl_context *ctx, } else { /* wrap user data */ + uint bytes; + void *ptr; + if (arrays[mesaAttr]->Ptr) { - uint divisor = arrays[mesaAttr]->InstanceDivisor; - uint length = (divisor ? num_instances / divisor : max_index) + 1; - vbuffer[attr].buffer = - pipe_user_buffer_create(pipe->screen, - (void *) arrays[mesaAttr]->Ptr, - stride * length, - PIPE_BIND_VERTEX_BUFFER); + if (stride == 0) { + bytes = _mesa_sizeof_type(arrays[mesaAttr]->Type) + * arrays[mesaAttr]->Size; + } + else { + uint divisor = arrays[mesaAttr]->InstanceDivisor; + uint length = (divisor ? num_instances / divisor : max_index) + 1; + bytes = stride * length; + } + + ptr = (void *) arrays[mesaAttr]->Ptr; } else { /* no array, use ctx->Current.Attrib[] value */ - uint bytes = sizeof(ctx->Current.Attrib[0]); - vbuffer[attr].buffer = - pipe_user_buffer_create(pipe->screen, - (void *) ctx->Current.Attrib[mesaAttr], - bytes, - PIPE_BIND_VERTEX_BUFFER); + bytes = sizeof(ctx->Current.Attrib[0]); + ptr = (void *) ctx->Current.Attrib[mesaAttr]; stride = 0; } + assert(ptr); + assert(bytes); + + vbuffer[attr].buffer = + pipe_user_buffer_create(pipe->screen, ptr, bytes, + PIPE_BIND_VERTEX_BUFFER); + vbuffer[attr].buffer_offset = 0; /* Track user vertex buffers. */ |