gallium/radeon: check that handle usage doesn't change for a resource
authorMarek Olšák <marek.olsak@amd.com>
Wed, 24 Feb 2016 19:04:31 +0000 (20:04 +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_pipe_common.h
src/gallium/drivers/radeon/r600_texture.c

index 4cef5ef1adc0eb1bc99cae8031b6900638fdf0b7..3bbbfbbd528e3f5d65c37a9b283fd7086c8901eb 100644 (file)
@@ -169,6 +169,7 @@ struct r600_resource {
 
        /* Whether the resource has been exported via resource_get_handle. */
        bool                            is_shared;
+       unsigned                        external_usage; /* PIPE_HANDLE_USAGE_* */
 };
 
 struct r600_transfer {
index 558dc73d9d40d9e6c519ac3b954d4bad5131caed..5f49dd7df5d80284287351bd1e81a422c67a63f4 100644 (file)
@@ -261,11 +261,14 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen,
 
        if (!res->is_shared) {
                res->is_shared = true;
+               res->external_usage = usage;
 
                if (resource->target != PIPE_BUFFER) {
                        r600_texture_init_metadata(rtex, &metadata);
                        rscreen->ws->buffer_set_metadata(res->buf, &metadata);
                }
+       } else {
+               assert(res->external_usage == usage);
        }
 
        return rscreen->ws->buffer_get_handle(res->buf,