summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-20 18:11:43 +0900
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-20 18:11:43 +0900
commit2170ec9048eab751828700728c1cc8264c860229 (patch)
treea9414e97bbc2ffaa790f47a82e2ab3e3ab329193 /src/gallium
parent5853b6c2fe10223738a15d294e2a1605ec076953 (diff)
pipebuffer: More detailed description of bufer over-/undereflows.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index affa6aa85c..d02e3500ff 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -109,7 +109,7 @@ static const uint8_t random_pattern[32] = {
static INLINE void
fill_random_pattern(uint8_t *dst, size_t size)
{
- unsigned i = 0;
+ size_t i = 0;
while(size--) {
*dst++ = random_pattern[i++];
i &= sizeof(random_pattern) - 1;
@@ -118,15 +118,21 @@ fill_random_pattern(uint8_t *dst, size_t size)
static INLINE boolean
-check_random_pattern(const uint8_t *dst, size_t size)
+check_random_pattern(const uint8_t *dst, size_t size,
+ size_t *min_ofs, size_t *max_ofs)
{
- unsigned i = 0;
- while(size--) {
- if(*dst++ != random_pattern[i++])
- return FALSE;
- i &= sizeof(random_pattern) - 1;
+ boolean result = TRUE;
+ size_t i;
+ *min_ofs = size;
+ *max_ofs = 0;
+ for(i = 0; i < size; ++i) {
+ if(*dst++ != random_pattern[i % sizeof(random_pattern)]) {
+ *min_ofs = MIN2(*min_ofs, i);
+ *max_ofs = MIN2(*max_ofs, i);
+ result = FALSE;
+ }
}
- return TRUE;
+ return result;
}
@@ -141,15 +147,28 @@ pb_debug_buffer_destroy(struct pb_buffer *_buf)
map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_READ);
assert(map);
if(map) {
- if(!check_random_pattern(map, buf->underflow_size)) {
- debug_error("buffer underflow detected\n");
- debug_assert(0);
+ boolean underflow, overflow;
+ size_t min_ofs, max_ofs;
+
+ underflow = !check_random_pattern(map, buf->underflow_size,
+ &min_ofs, &max_ofs);
+ if(underflow) {
+ debug_printf("buffer underflow (%u of %u bytes) detected\n",
+ buf->underflow_size - min_ofs,
+ buf->underflow_size);
}
- if(!check_random_pattern(map + buf->underflow_size + buf->base.base.size,
- buf->overflow_size)) {
- debug_error("buffer overflow detected\n");
- debug_assert(0);
+
+ overflow = !check_random_pattern(map + buf->underflow_size + buf->base.base.size,
+ buf->overflow_size,
+ &min_ofs, &max_ofs);
+ if(overflow) {
+ debug_printf("buffer overflow (%u of %u bytes) detected\n",
+ max_ofs,
+ buf->overflow_size);
}
+
+ debug_assert(!underflow && !overflow);
+
pb_unmap(buf->buffer);
}