diff options
author | Zack Rusin <[email protected]> | 2013-05-08 23:48:20 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2013-05-14 03:09:32 -0400 |
commit | 29853ab7b8656cee9b92a53bec43f6e9f1e49691 (patch) | |
tree | 6b4ac7f1accc0358717fe98d6e8b1c5b982baafb /src/gallium/drivers/llvmpipe | |
parent | 386327c48f88b052449afa4f41b1090d3fdb5ce9 (diff) |
draw: don't crash on vertex buffer overflow
We would crash when stride was bigger than the size of the buffer.
The correct behavior is to just fetch zero's in this case.
Unfortunatly with user_buffer's there's no way to validate the size
because currently we're just not getting it. Adjust the draw interface
to pass the size along the mapped buffer, which works perfectly
for buffer backed vertex_buffers and, in future, it will allow
us to plumb user_buffer sizes through the same interface.
Signed-off-by: Zack Rusin <[email protected]>
Reviewed-by: José Fonseca <[email protected]>
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_draw_arrays.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index fc947b110d0..63c22c31304 100644 --- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c +++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c @@ -68,13 +68,15 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) */ for (i = 0; i < lp->num_vertex_buffers; i++) { const void *buf = lp->vertex_buffer[i].user_buffer; + size_t size = ~0; if (!buf) { if (!lp->vertex_buffer[i].buffer) { continue; } buf = llvmpipe_resource_data(lp->vertex_buffer[i].buffer); + size = lp->vertex_buffer[i].buffer->width0; } - draw_set_mapped_vertex_buffer(draw, i, buf); + draw_set_mapped_vertex_buffer(draw, i, buf, size); } /* Map index buffer, if present */ @@ -121,7 +123,7 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) * unmap vertex/index buffers */ for (i = 0; i < lp->num_vertex_buffers; i++) { - draw_set_mapped_vertex_buffer(draw, i, NULL); + draw_set_mapped_vertex_buffer(draw, i, NULL, 0); } if (mapped_indices) { draw_set_indexes(draw, NULL, 0); |