From a232afdbfbaac156e981f55b8bdeb305026cde84 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 2 May 2013 23:38:28 -0400 Subject: [PATCH] draw/pt: adjust overflow calculations MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit gallium lies. buffer_size is not actually buffer_size but available size, which is 'buffer_size - buffer_offset' so by adding buffer offset we'd incorrectly compute overflow. Signed-off-by: Zack Rusin Reviewed-by: José Fonseca --- src/gallium/auxiliary/draw/draw_pt_so_emit.c | 3 +-- src/gallium/include/pipe/p_state.h | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c index 9b557733ddd..d624a990bc6 100644 --- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c @@ -131,8 +131,7 @@ 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]; if (target) { - buffer_total_bytes[i] = target->internal_offset + - target->target.buffer_offset; + buffer_total_bytes[i] = target->internal_offset; } else { buffer_total_bytes[i] = 0; } diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 28249d2261a..262078d09b3 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -465,6 +465,13 @@ struct pipe_constant_buffer { * have been written. The internal offset can be stored on the device * and the CPU actually doesn't have to query it. * + * Note that the buffer_size variable is actually specifying the available + * space in the buffer, not the size of the attached buffer. + * In other words in majority of cases buffer_size would simply be + * 'buffer->width0 - buffer_offset', so buffer_size refers to the size + * of the buffer left, after accounting for buffer offset, for stream output + * to write to. + * * Use PIPE_QUERY_SO_STATISTICS to know how many primitives have * actually been written. */ -- 2.11.0