gallium/radeon: set texture metadata only once
authorMarek Olšák <marek.olsak@amd.com>
Wed, 24 Feb 2016 16:32:53 +0000 (17:32 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 9 Mar 2016 14:02:26 +0000 (15:02 +0100)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_texture.c

index 81409ced8273c157bacfa2a996e826fdcbc1c46a..439a3cb30c0023c41421c5474be96697a54fdab6 100644 (file)
@@ -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;
 }
index b77b1321d73aef6fc4c55a6bc6d833b94e25a803..4cef5ef1adc0eb1bc99cae8031b6900638fdf0b7 100644 (file)
@@ -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 {
index 377dd3de57846def5443b2a9249f4dfdbbc87f34..5e77080eed21757d1b18af0e61c4ab35f8bc29d7 100644 (file)
@@ -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,