diff options
author | Vadim Girlin <[email protected]> | 2011-07-04 18:30:42 +0400 |
---|---|---|
committer | Alex Deucher <[email protected]> | 2011-07-05 15:57:11 -0400 |
commit | 6bde225b8b5791588837295b3b89ac132095a6f7 (patch) | |
tree | 67516d19894c1b919c6d78afe6f08a39d6cc2cc6 /src/gallium/winsys/r600 | |
parent | 971e1b743eeaa4f1fc5af4c0a3af78422aaa7b24 (diff) |
r600g: fix buffer overflow check in r600_query_begin
Diffstat (limited to 'src/gallium/winsys/r600')
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_hw_context.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c index 81e26f61158..633cd35f7a7 100644 --- a/src/gallium/winsys/r600/drm/r600_hw_context.c +++ b/src/gallium/winsys/r600/drm/r600_hw_context.c @@ -1725,7 +1725,7 @@ static boolean r600_query_result(struct r600_context *ctx, struct r600_query *qu void r600_query_begin(struct r600_context *ctx, struct r600_query *query) { - unsigned required_space; + unsigned required_space, required_buffer; int num_backends = r600_get_num_backends(ctx->radeon); /* query request needs 6/8 dwords for begin + 6/8 dwords for end */ @@ -1739,8 +1739,11 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query) r600_context_flush(ctx); } + required_buffer = query->num_results + + 4 * (query->type == PIPE_QUERY_OCCLUSION_COUNTER ? ctx->max_db : 1); + /* if query buffer is full force a flush */ - if (query->num_results*4 >= query->buffer_size - 16) { + if (required_buffer*4 > query->buffer_size) { if (!(query->state & R600_QUERY_STATE_FLUSHED)) r600_context_flush(ctx); r600_query_result(ctx, query, TRUE); |