summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2013-05-08 23:48:20 -0400
committerZack Rusin <[email protected]>2013-05-14 03:09:32 -0400
commit29853ab7b8656cee9b92a53bec43f6e9f1e49691 (patch)
tree6b4ac7f1accc0358717fe98d6e8b1c5b982baafb /src/mesa
parent386327c48f88b052449afa4f41b1090d3fdb5ce9 (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/mesa')
-rw-r--r--src/mesa/state_tracker/st_draw_feedback.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index cdad2d966a7..ecd4661a284 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -175,7 +175,8 @@ st_feedback_draw_vbo(struct gl_context *ctx,
map = pipe_buffer_map(pipe, vbuffers[attr].buffer,
PIPE_TRANSFER_READ,
&vb_transfer[attr]);
- draw_set_mapped_vertex_buffer(draw, attr, map);
+ draw_set_mapped_vertex_buffer(draw, attr, map,
+ vbuffers[attr].buffer->width0);
}
else {
vbuffers[attr].buffer = NULL;
@@ -183,7 +184,8 @@ st_feedback_draw_vbo(struct gl_context *ctx,
vbuffers[attr].buffer_offset = 0;
velements[attr].src_offset = 0;
- draw_set_mapped_vertex_buffer(draw, attr, vbuffers[attr].user_buffer);
+ draw_set_mapped_vertex_buffer(draw, attr, vbuffers[attr].user_buffer,
+ ~0);
}
/* common-case setup */
@@ -260,7 +262,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
for (attr = 0; attr < vp->num_inputs; attr++) {
if (vb_transfer[attr])
pipe_buffer_unmap(pipe, vb_transfer[attr]);
- draw_set_mapped_vertex_buffer(draw, attr, NULL);
+ draw_set_mapped_vertex_buffer(draw, attr, NULL, 0);
pipe_resource_reference(&vbuffers[attr].buffer, NULL);
}
draw_set_vertex_buffers(draw, 0, vp->num_inputs, NULL);