aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2013-04-23 18:56:47 -0400
committerZack Rusin <[email protected]>2013-04-26 23:04:26 -0400
commit53d36d5fb09cda39c8d3646cbccbd343b34bfb54 (patch)
treed132cc677df63d4063163ca241a8dda2cbf21488 /src
parentd996622cfad484817c1038caded20032759ec93b (diff)
draw/so: Fix overflow calculations
We weren't taking the buffer offset, destination offset or the stride into consideration so we were frequently writing into an overflown buffer. Signed-off-by: Zack Rusin <[email protected]> Reviewed-by: José Fonseca <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_so_emit.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
index fc690179cbd..cdfd13c6421 100644
--- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
@@ -129,20 +129,25 @@ static void so_emit_prim(struct pt_so_emit *so,
for (i = 0; i < draw->so.num_targets; i++) {
struct draw_so_target *target = draw->so.targets[i];
- buffer_total_bytes[i] = target->internal_offset;
+ buffer_total_bytes[i] = target->internal_offset + target->target.buffer_offset;
}
/* check have we space to emit prim first - if not don't do anything */
for (i = 0; i < num_vertices; ++i) {
+ unsigned ob;
for (slot = 0; slot < state->num_outputs; ++slot) {
unsigned num_comps = state->output[slot].num_components;
int ob = state->output[slot].output_buffer;
+ unsigned dst_offset = state->output[slot].dst_offset * sizeof(float);
+ unsigned write_size = num_comps * sizeof(float);
- if ((buffer_total_bytes[ob] + num_comps * sizeof(float)) >
+ if ((buffer_total_bytes[ob] + write_size + dst_offset) >
draw->so.targets[ob]->target.buffer_size) {
return;
}
- buffer_total_bytes[ob] += num_comps * sizeof(float);
+ }
+ for (ob = 0; ob < draw->so.num_targets; ++ob) {
+ buffer_total_bytes[ob] += state->stride[ob] * sizeof(float);
}
}