From: Marek Olšák <marek.ol...@amd.com>

For coherency with the current context.
---
 src/gallium/drivers/radeon/r600_texture.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_texture.c 
b/src/gallium/drivers/radeon/r600_texture.c
index e7be768..912d123 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -333,29 +333,34 @@ static void r600_texture_init_metadata(struct 
r600_texture *rtex,
        metadata->num_banks = surface->num_banks;
        metadata->stride = surface->level[0].pitch_bytes;
        metadata->scanout = (surface->flags & RADEON_SURF_SCANOUT) != 0;
 }
 
 static void r600_dirty_all_framebuffer_states(struct r600_common_screen 
*rscreen)
 {
        p_atomic_inc(&rscreen->dirty_fb_counter);
 }
 
-static void r600_eliminate_fast_color_clear(struct r600_common_screen *rscreen,
-                                     struct r600_texture *rtex)
+static void r600_eliminate_fast_color_clear(struct r600_common_context *rctx,
+                                           struct r600_texture *rtex)
 {
-       struct pipe_context *ctx = rscreen->aux_context;
+       struct r600_common_screen *rscreen = rctx->screen;
+       struct pipe_context *ctx = &rctx->b;
+
+       if (ctx == rscreen->aux_context)
+               pipe_mutex_lock(rscreen->aux_context_lock);
 
-       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);
+
+       if (ctx == rscreen->aux_context)
+               pipe_mutex_unlock(rscreen->aux_context_lock);
 }
 
 static void r600_texture_discard_cmask(struct r600_common_screen *rscreen,
                                       struct r600_texture *rtex)
 {
        if (!rtex->cmask.size)
                return;
 
        assert(rtex->resource.b.b.nr_samples <= 1);
 
@@ -538,21 +543,21 @@ static boolean r600_texture_get_handle(struct 
pipe_screen* screen,
                 * access.
                 */
                if (usage & PIPE_HANDLE_USAGE_WRITE && rtex->dcc_offset) {
                        if (r600_texture_disable_dcc(rctx, rtex))
                                update_metadata = true;
                }
 
                if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH) &&
                    rtex->cmask.size) {
                        /* Eliminate fast clear (both CMASK and DCC) */
-                       r600_eliminate_fast_color_clear(rscreen, rtex);
+                       r600_eliminate_fast_color_clear(rctx, rtex);
 
                        /* Disable CMASK if flush_resource isn't going
                         * to be called.
                         */
                        r600_texture_discard_cmask(rscreen, rtex);
                }
 
                /* Set metadata. */
                if (!res->is_shared || update_metadata) {
                        r600_texture_init_metadata(rtex, &metadata);
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to