diff options
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_validate.c | 32 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_validate.h | 5 |
2 files changed, 26 insertions, 11 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c index 0c61c906a3a..459dde526c3 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_validate.c +++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c @@ -37,6 +37,7 @@ #include "pipe/p_defines.h" #include "util/u_memory.h" #include "util/u_debug.h" +#include "util/u_hash_table.h" #include "pb_buffer.h" #include "pb_validate.h" @@ -63,9 +64,12 @@ struct pb_validate enum pipe_error pb_validate_add_buffer(struct pb_validate *vl, struct pb_buffer *buf, - enum pb_usage_flags flags) + enum pb_usage_flags flags, + struct util_hash_table *ht, + boolean *already_present) { assert(buf); + *already_present = FALSE; if (!buf) return PIPE_ERROR; @@ -73,15 +77,20 @@ pb_validate_add_buffer(struct pb_validate *vl, assert(!(flags & ~PB_USAGE_GPU_READ_WRITE)); flags &= PB_USAGE_GPU_READ_WRITE; - /* We only need to store one reference for each buffer, so avoid storing - * consecutive references for the same buffer. It might not be the most - * common pattern, but it is easy to implement. - */ - if(vl->used && vl->entries[vl->used - 1].buf == buf) { - vl->entries[vl->used - 1].flags |= flags; - return PIPE_OK; + if (ht) { + unsigned long entry_idx = (unsigned long) util_hash_table_get(ht, buf); + + if (entry_idx) { + struct pb_validate_entry *entry = &vl->entries[entry_idx - 1]; + + assert(entry->buf == buf); + entry->flags |= flags; + *already_present = TRUE; + + return PIPE_OK; + } } - + /* Grow the table */ if(vl->used == vl->size) { unsigned new_size; @@ -107,7 +116,10 @@ pb_validate_add_buffer(struct pb_validate *vl, pb_reference(&vl->entries[vl->used].buf, buf); vl->entries[vl->used].flags = flags; ++vl->used; - + + if (ht) + util_hash_table_set(ht, buf, (void *) (unsigned long) vl->used); + return PIPE_OK; } diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.h b/src/gallium/auxiliary/pipebuffer/pb_validate.h index ea364330eff..3196d5290fe 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_validate.h +++ b/src/gallium/auxiliary/pipebuffer/pb_validate.h @@ -46,6 +46,7 @@ extern "C" { struct pb_buffer; struct pipe_fence_handle; +struct util_hash_table; /** @@ -59,7 +60,9 @@ struct pb_validate; enum pipe_error pb_validate_add_buffer(struct pb_validate *vl, struct pb_buffer *buf, - enum pb_usage_flags flags); + enum pb_usage_flags flags, + struct util_hash_table *ht, + boolean *already_present); enum pipe_error pb_validate_foreach(struct pb_validate *vl, |