gallium/radeon: add and use r600_texture_reference
authorMarek Olšák <marek.olsak@amd.com>
Tue, 21 Jun 2016 19:17:44 +0000 (21:17 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 29 Jun 2016 18:12:00 +0000 (20:12 +0200)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Vedran Miletić <vedran@miletic.net>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/r600/r600_uvd.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_texture.c
src/gallium/drivers/radeonsi/si_uvd.c

index 628ba2a4fe195f50f21d4ccb23c36f3bb38113fa..f1b1ca8113c8674c5e6eaa906b20005b23e1ac75 100644 (file)
@@ -131,7 +131,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
 
 error:
        for (i = 0; i < VL_NUM_COMPONENTS; ++i)
-               pipe_resource_reference((struct pipe_resource **)&resources[i], NULL);
+               r600_texture_reference(&resources[i], NULL);
 
        return NULL;
 }
index 1a892ab91e35711cb457816dacb2584dea915b11..6b701b6cdd4be32af2080e5889be616ff86618e8 100644 (file)
@@ -483,8 +483,7 @@ void r600_common_context_cleanup(struct r600_common_context *rctx)
                                rctx->b.destroy_query(&rctx->b,
                                                      rctx->dcc_stats[i].ps_stats[j]);
 
-               pipe_resource_reference((struct pipe_resource**)
-                                       &rctx->dcc_stats[i].tex, NULL);
+               r600_texture_reference(&rctx->dcc_stats[i].tex, NULL);
        }
 
        if (rctx->gfx.cs)
index 5fee6582165c8060ed0f8ab551015344517a9524..203d863f26786e28466c8a81a4f53a95ba600296 100644 (file)
@@ -794,6 +794,12 @@ r600_resource_reference(struct r600_resource **ptr, struct r600_resource *res)
                                (struct pipe_resource *)res);
 }
 
+static inline void
+r600_texture_reference(struct r600_texture **ptr, struct r600_texture *res)
+{
+       pipe_resource_reference((struct pipe_resource **)ptr, &res->resource.b.b);
+}
+
 static inline bool r600_get_strmout_en(struct r600_common_context *rctx)
 {
        return rctx->streamout.streamout_enabled ||
index 13ade4417b15e62b4602bbd83b8251b0b3bf5300..d7ff2f77c336568c33cde00b34ed3da90810f567 100644 (file)
@@ -479,7 +479,7 @@ static void r600_degrade_tile_mode_to_linear(struct r600_common_context *rctx,
        assert(!rtex->dcc_offset);
        assert(!rtex->is_depth);
 
-       pipe_resource_reference((struct pipe_resource**)&new_tex, NULL);
+       r600_texture_reference(&new_tex, NULL);
 
        r600_dirty_all_framebuffer_states(rctx->screen);
        p_atomic_inc(&rctx->screen->dirty_tex_descriptor_counter);
@@ -561,7 +561,7 @@ static void r600_texture_destroy(struct pipe_screen *screen,
        struct r600_resource *resource = &rtex->resource;
 
        if (rtex->flushed_depth_texture)
-               pipe_resource_reference((struct pipe_resource **)&rtex->flushed_depth_texture, NULL);
+               r600_texture_reference(&rtex->flushed_depth_texture, NULL);
 
        r600_resource_reference(&rtex->htile_buffer, NULL);
        if (rtex->cmask_buffer != &rtex->resource) {
@@ -1759,14 +1759,12 @@ static unsigned vi_get_context_dcc_stats_index(struct r600_common_context *rctx,
                                rctx->dcc_stats[oldest_slot].ps_stats[i] = NULL;
                        }
 
-               pipe_resource_reference((struct pipe_resource**)
-                                       &rctx->dcc_stats[oldest_slot].tex, NULL);
+               r600_texture_reference(&rctx->dcc_stats[oldest_slot].tex, NULL);
                empty_slot = oldest_slot;
        }
 
        /* Add the texture to the new slot. */
-       pipe_resource_reference((struct pipe_resource**)&rctx->dcc_stats[empty_slot].tex,
-                               &tex->resource.b.b);
+       r600_texture_reference(&rctx->dcc_stats[empty_slot].tex, tex);
        rctx->dcc_stats[empty_slot].last_use_timestamp = os_time_get();
        return empty_slot;
 }
index 8c3e5fd865d9376dbe42c435c298cd75ce11e99c..0d5bc378b2b1f4e264c17cc9efe2dbf199ab9a18 100644 (file)
@@ -113,7 +113,7 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
 
 error:
        for (i = 0; i < VL_NUM_COMPONENTS; ++i)
-               pipe_resource_reference((struct pipe_resource **)&resources[i], NULL);
+               r600_texture_reference(&resources[i], NULL);
 
        return NULL;
 }