From: Marek Olšák Date: Wed, 15 Feb 2017 00:47:25 +0000 (+0100) Subject: gallium/u_suballoc: use clear_buffer if available X-Git-Tag: upstream/17.1.0~2146 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=edf6bcf6c633c74f7df6a716ae9ac0d7de054766;p=platform%2Fupstream%2Fmesa.git gallium/u_suballoc: use clear_buffer if available Reviewed-by: Nicolai Hähnle --- diff --git a/src/gallium/auxiliary/util/u_suballoc.c b/src/gallium/auxiliary/util/u_suballoc.c index 5aaddbc..8c463c9 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); + } } }