diff options
author | Marek Olšák <[email protected]> | 2017-02-15 01:47:25 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-02-18 01:22:08 +0100 |
commit | edf6bcf6c633c74f7df6a716ae9ac0d7de054766 (patch) | |
tree | e0e5aa400181b205c3947de49dc842edd82c4b3d /src/gallium/auxiliary/util/u_suballoc.c | |
parent | 02cd8b20d10e4fdc635897056f1bdfb9049d864d (diff) |
gallium/u_suballoc: use clear_buffer if available
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util/u_suballoc.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_suballoc.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/gallium/auxiliary/util/u_suballoc.c b/src/gallium/auxiliary/util/u_suballoc.c index 5aaddbcb55c..8c463c9fdd0 100644 --- a/src/gallium/auxiliary/util/u_suballoc.c +++ b/src/gallium/auxiliary/util/u_suballoc.c @@ -105,13 +105,20 @@ u_suballocator_alloc(struct u_suballocator *allocator, unsigned size, /* Clear the memory if needed. */ if (allocator->zero_buffer_memory) { - struct pipe_transfer *transfer = NULL; - void *ptr; - - ptr = pipe_buffer_map(allocator->pipe, allocator->buffer, - PIPE_TRANSFER_WRITE, &transfer); - memset(ptr, 0, allocator->size); - pipe_buffer_unmap(allocator->pipe, transfer); + struct pipe_context *pipe = allocator->pipe; + + if (pipe->clear_buffer) { + unsigned clear_value = 0; + + pipe->clear_buffer(pipe, allocator->buffer, 0, allocator->size, + &clear_value, 4); + } else { + struct pipe_transfer *transfer = NULL; + void *ptr = pipe_buffer_map(pipe, allocator->buffer, + PIPE_TRANSFER_WRITE, &transfer); + memset(ptr, 0, allocator->size); + pipe_buffer_unmap(pipe, transfer); + } } } |