From f914779c75b01f344ff8d63f572abc71179f44d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 24 Feb 2016 17:32:53 +0100 Subject: [PATCH] gallium/radeon: set texture metadata only once MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Michel Dänzer Reviewed-by: Nicolai Hähnle --- src/gallium/drivers/radeon/r600_buffer_common.c | 1 + src/gallium/drivers/radeon/r600_pipe_common.h | 3 +++ src/gallium/drivers/radeon/r600_texture.c | 7 +++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c index 81409ced827..439a3cb30c0 100644 --- a/src/gallium/drivers/radeon/r600_buffer_common.c +++ b/src/gallium/drivers/radeon/r600_buffer_common.c @@ -455,6 +455,7 @@ r600_alloc_buffer_struct(struct pipe_screen *screen, rbuffer->b.vtbl = &r600_buffer_vtbl; rbuffer->buf = NULL; rbuffer->TC_L2_dirty = false; + rbuffer->is_shared = false; util_range_init(&rbuffer->valid_buffer_range); return rbuffer; } diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index b77b1321d73..4cef5ef1adc 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -166,6 +166,9 @@ struct r600_resource { * use TC L2. */ bool TC_L2_dirty; + + /* Whether the resource has been exported via resource_get_handle. */ + bool is_shared; }; struct r600_transfer { diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c index 377dd3de578..5e77080eed2 100644 --- a/src/gallium/drivers/radeon/r600_texture.c +++ b/src/gallium/drivers/radeon/r600_texture.c @@ -259,8 +259,11 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen, struct r600_texture *rtex = (struct r600_texture*)resource; struct radeon_bo_metadata metadata; - r600_texture_init_metadata(rtex, &metadata); - rscreen->ws->buffer_set_metadata(res->buf, &metadata); + if (!res->is_shared) { + res->is_shared = true; + r600_texture_init_metadata(rtex, &metadata); + rscreen->ws->buffer_set_metadata(res->buf, &metadata); + } return rscreen->ws->buffer_get_handle(res->buf, rtex->surface.level[0].pitch_bytes, -- 2.30.2