From edf6bcf6c633c74f7df6a716ae9ac0d7de054766 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 15 Feb 2017 01:47:25 +0100 Subject: [PATCH] gallium/u_suballoc: use clear_buffer if available MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- src/gallium/auxiliary/util/u_suballoc.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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); + } } } -- 2.7.4