gallium/radeon: eliminate fast color clear before sharing
authorMarek Olšák <marek.olsak@amd.com>
Tue, 1 Mar 2016 20:50:25 +0000 (21:50 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 9 Mar 2016 14:02:27 +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_texture.c
src/gallium/drivers/radeonsi/si_blit.c

index 229fa5efa7841f040e53f316995f0b0e2803bd1c..ec2f2454b1cf7591b165a4b24085774d6e8aac87 100644 (file)
@@ -249,6 +249,17 @@ static void r600_texture_init_metadata(struct r600_texture *rtex,
        metadata->scanout = (surface->flags & RADEON_SURF_SCANOUT) != 0;
 }
 
+static void r600_eliminate_fast_color_clear(struct r600_common_screen *rscreen,
+                                     struct r600_texture *rtex)
+{
+       struct pipe_context *ctx = rscreen->aux_context;
+
+       pipe_mutex_lock(rscreen->aux_context_lock);
+       ctx->flush_resource(ctx, &rtex->resource.b.b);
+       ctx->flush(ctx, NULL, 0);
+       pipe_mutex_unlock(rscreen->aux_context_lock);
+}
+
 static boolean r600_texture_get_handle(struct pipe_screen* screen,
                                       struct pipe_resource *resource,
                                       struct winsys_handle *whandle,
@@ -271,6 +282,11 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen,
                res->external_usage = usage;
 
                if (resource->target != PIPE_BUFFER) {
+                       if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH)) {
+                               /* Eliminate fast clear (both CMASK and DCC) */
+                               r600_eliminate_fast_color_clear(rscreen, rtex);
+                       }
+
                        r600_texture_init_metadata(rtex, &metadata);
                        rscreen->ws->buffer_set_metadata(res->buf, &metadata);
                }
index 115877060ba50f30871b3aee85ae06ecdeb80ddf..53c67055a5ec78646509f9e18bd42456d2b7a27d 100644 (file)
@@ -761,7 +761,7 @@ static void si_flush_resource(struct pipe_context *ctx,
 
        assert(res->target != PIPE_BUFFER);
 
-       if (!rtex->is_depth && rtex->cmask.size) {
+       if (!rtex->is_depth && (rtex->cmask.size || rtex->dcc_buffer)) {
                si_blit_decompress_color(ctx, rtex, 0, res->last_level,
                                         0, util_max_layer(res, 0));
        }