gallium/radeon: use r600_resource_reference
authorMarek Olšák <marek.olsak@amd.com>
Tue, 21 Jun 2016 19:13:00 +0000 (21:13 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 25 Jun 2016 21:13:42 +0000 (23:13 +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>
12 files changed:
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/drivers/radeon/r600_query.c
src/gallium/drivers/radeon/r600_streamout.c
src/gallium/drivers/radeon/r600_texture.c
src/gallium/drivers/radeon/radeon_video.c
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index 57721d92b8518598b5cd89350bde3f310dac3fd1..119c76bd4a963653fb9c036de6f1360f4e685309 100644 (file)
@@ -71,8 +71,8 @@ static void r600_destroy_context(struct pipe_context *context)
 
        r600_sb_context_destroy(rctx->sb_context);
 
-       pipe_resource_reference((struct pipe_resource**)&rctx->dummy_cmask, NULL);
-       pipe_resource_reference((struct pipe_resource**)&rctx->dummy_fmask, NULL);
+       r600_resource_reference(&rctx->dummy_cmask, NULL);
+       r600_resource_reference(&rctx->dummy_fmask, NULL);
 
        for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
                rctx->b.b.set_constant_buffer(&rctx->b.b, sh, R600_BUFFER_INFO_CONST_BUFFER, NULL);
index 9a1008e70c5ac06c33f455f39e184300895c85d8..ff098f185113f0b01ec42175c5abb5e639298087 100644 (file)
@@ -288,7 +288,7 @@ error:
 
 void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *shader)
 {
-       pipe_resource_reference((struct pipe_resource**)&shader->bo, NULL);
+       r600_resource_reference(&shader->bo, NULL);
        r600_bytecode_clear(&shader->shader.bc);
        r600_release_command_buffer(&shader->command_buffer);
 }
index 89a9f25b4258aecee149d3bc422b5296e41107cf..e805d332e3edeace89fc8d733c80ff9c72a6c85b 100644 (file)
@@ -967,10 +967,8 @@ static void r600_init_color_surface(struct r600_context *rctx,
        surf->cb_color_cmask = surf->cb_color_base;
        surf->cb_color_mask = 0;
 
-       pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_cmask,
-                               &rtex->resource.b.b);
-       pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_fmask,
-                               &rtex->resource.b.b);
+       r600_resource_reference(&surf->cb_buffer_cmask, &rtex->resource);
+       r600_resource_reference(&surf->cb_buffer_fmask, &rtex->resource);
 
        if (rtex->cmask.size) {
                surf->cb_color_cmask = rtex->cmask.offset >> 8;
@@ -1003,7 +1001,7 @@ static void r600_init_color_surface(struct r600_context *rctx,
                        struct pipe_transfer *transfer;
                        void *ptr;
 
-                       pipe_resource_reference((struct pipe_resource**)&rctx->dummy_cmask, NULL);
+                       r600_resource_reference(&rctx->dummy_cmask, NULL);
                        rctx->dummy_cmask = r600_buffer_create_helper(rscreen, cmask.size, cmask.alignment);
 
                        /* Set the contents to 0xCC. */
@@ -1011,19 +1009,17 @@ static void r600_init_color_surface(struct r600_context *rctx,
                        memset(ptr, 0xCC, cmask.size);
                        pipe_buffer_unmap(&rctx->b.b, transfer);
                }
-               pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_cmask,
-                                       &rctx->dummy_cmask->b.b);
+               r600_resource_reference(&surf->cb_buffer_cmask, rctx->dummy_cmask);
 
                /* FMASK. */
                if (!rctx->dummy_fmask ||
                    rctx->dummy_fmask->b.b.width0 < fmask.size ||
                    rctx->dummy_fmask->buf->alignment % fmask.alignment != 0) {
-                       pipe_resource_reference((struct pipe_resource**)&rctx->dummy_fmask, NULL);
+                       r600_resource_reference(&rctx->dummy_fmask, NULL);
                        rctx->dummy_fmask = r600_buffer_create_helper(rscreen, fmask.size, fmask.alignment);
 
                }
-               pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_fmask,
-                                       &rctx->dummy_fmask->b.b);
+               r600_resource_reference(&surf->cb_buffer_fmask, rctx->dummy_fmask);
 
                /* Init the registers. */
                color_info |= S_0280A0_TILE_MODE(V_0280A0_FRAG_ENABLE);
index ce644b78c81e6df5793600c2e83b76b5e382cd06..4b282d0bc9ba378d1fda6713a6431238dee1a4b1 100644 (file)
@@ -514,7 +514,7 @@ static void r600_bind_vertex_elements(struct pipe_context *ctx, void *state)
 static void r600_delete_vertex_elements(struct pipe_context *ctx, void *state)
 {
        struct r600_fetch_shader *shader = (struct r600_fetch_shader*)state;
-       pipe_resource_reference((struct pipe_resource**)&shader->buffer, NULL);
+       r600_resource_reference(&shader->buffer, NULL);
        FREE(shader);
 }
 
index a47aa78eacbec29821aee2a75bded05160b54f78..4b0cf42a1dfd888888a82bb8742792380ad5f99b 100644 (file)
@@ -374,7 +374,7 @@ static void *r600_buffer_transfer_map(struct pipe_context *ctx,
 
                        data = r600_buffer_map_sync_with_rings(rctx, staging, PIPE_TRANSFER_READ);
                        if (!data) {
-                               pipe_resource_reference((struct pipe_resource **)&staging, NULL);
+                               r600_resource_reference(&staging, NULL);
                                return NULL;
                        }
                        data += box->x % R600_MAP_BUFFER_ALIGNMENT;
@@ -444,7 +444,7 @@ static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
                r600_buffer_do_flush_region(ctx, transfer, &transfer->box);
 
        if (rtransfer->staging)
-               pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
+               r600_resource_reference(&rtransfer->staging, NULL);
 
        util_slab_free(&rctx->pool_transfers, transfer);
 }
index 2e06746b9eff90064905c087aa1d578e9d991d9b..5474dbf2dea92de83d49c5d017ad1d854a53f66f 100644 (file)
@@ -275,11 +275,11 @@ void r600_query_hw_destroy(struct r600_common_context *rctx,
        while (prev) {
                struct r600_query_buffer *qbuf = prev;
                prev = prev->previous;
-               pipe_resource_reference((struct pipe_resource**)&qbuf->buf, NULL);
+               r600_resource_reference(&qbuf->buf, NULL);
                FREE(qbuf);
        }
 
-       pipe_resource_reference((struct pipe_resource**)&query->buffer.buf, NULL);
+       r600_resource_reference(&query->buffer.buf, NULL);
        FREE(rquery);
 }
 
@@ -301,7 +301,7 @@ static struct r600_resource *r600_new_query_buffer(struct r600_common_context *c
 
        if (query->flags & R600_QUERY_HW_FLAG_PREDICATE) {
                if (!query->ops->prepare_buffer(ctx, query, buf)) {
-                       pipe_resource_reference((struct pipe_resource **)&buf, NULL);
+                       r600_resource_reference(&buf, NULL);
                        return NULL;
                }
        }
@@ -733,7 +733,7 @@ static void r600_query_hw_reset_buffers(struct r600_common_context *rctx,
        while (prev) {
                struct r600_query_buffer *qbuf = prev;
                prev = prev->previous;
-               pipe_resource_reference((struct pipe_resource**)&qbuf->buf, NULL);
+               r600_resource_reference(&qbuf->buf, NULL);
                FREE(qbuf);
        }
 
@@ -744,11 +744,11 @@ static void r600_query_hw_reset_buffers(struct r600_common_context *rctx,
                /* Obtain a new buffer if the current one can't be mapped without a stall. */
                if (r600_rings_is_buffer_referenced(rctx, query->buffer.buf->buf, RADEON_USAGE_READWRITE) ||
                    !rctx->ws->buffer_wait(query->buffer.buf->buf, 0, RADEON_USAGE_READWRITE)) {
-                       pipe_resource_reference((struct pipe_resource**)&query->buffer.buf, NULL);
+                       r600_resource_reference(&query->buffer.buf, NULL);
                        query->buffer.buf = r600_new_query_buffer(rctx, query);
                } else {
                        if (!query->ops->prepare_buffer(rctx, query, query->buffer.buf))
-                               pipe_resource_reference((struct pipe_resource**)&query->buffer.buf, NULL);
+                               r600_resource_reference(&query->buffer.buf, NULL);
                }
        }
 }
@@ -1132,7 +1132,7 @@ void r600_query_init_backend_mask(struct r600_common_context *ctx)
                }
        }
 
-       pipe_resource_reference((struct pipe_resource**)&buffer, NULL);
+       r600_resource_reference(&buffer, NULL);
 
        if (mask != 0) {
                ctx->backend_mask = mask;
index eb818464c90aea3cecba1e4a774bf317d64aa6cf..705eb13835dc8edb62436010d936a16a571bc78e 100644 (file)
@@ -70,7 +70,7 @@ static void r600_so_target_destroy(struct pipe_context *ctx,
 {
        struct r600_so_target *t = (struct r600_so_target*)target;
        pipe_resource_reference(&t->b.buffer, NULL);
-       pipe_resource_reference((struct pipe_resource**)&t->buf_filled_size, NULL);
+       r600_resource_reference(&t->buf_filled_size, NULL);
        FREE(t);
 }
 
index 32347f26edd0919986c930d4bf5d1db9100ecf28..6a8ea56933e3d49ed4898ef923c72ac9840165a4 100644 (file)
@@ -366,7 +366,7 @@ static void r600_texture_discard_cmask(struct r600_common_screen *rscreen,
                rtex->cb_color_info &= ~EG_S_028C70_FAST_CLEAR(1);
 
        if (rtex->cmask_buffer != &rtex->resource)
-           pipe_resource_reference((struct pipe_resource**)&rtex->cmask_buffer, NULL);
+           r600_resource_reference(&rtex->cmask_buffer, NULL);
 
        /* Notify all contexts about the change. */
        r600_dirty_all_framebuffer_states(rscreen);
@@ -559,9 +559,9 @@ static void r600_texture_destroy(struct pipe_screen *screen,
        if (rtex->flushed_depth_texture)
                pipe_resource_reference((struct pipe_resource **)&rtex->flushed_depth_texture, NULL);
 
-       pipe_resource_reference((struct pipe_resource**)&rtex->htile_buffer, NULL);
+       r600_resource_reference(&rtex->htile_buffer, NULL);
        if (rtex->cmask_buffer != &rtex->resource) {
-           pipe_resource_reference((struct pipe_resource**)&rtex->cmask_buffer, NULL);
+           r600_resource_reference(&rtex->cmask_buffer, NULL);
        }
        pb_reference(&resource->buf, NULL);
        FREE(rtex);
@@ -1511,7 +1511,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
        }
 
        if (!(map = r600_buffer_map_sync_with_rings(rctx, buf, usage))) {
-               pipe_resource_reference((struct pipe_resource**)&trans->staging, NULL);
+               r600_resource_reference(&trans->staging, NULL);
                FREE(trans);
                return NULL;
        }
@@ -1541,7 +1541,7 @@ static void r600_texture_transfer_unmap(struct pipe_context *ctx,
 
        if (rtransfer->staging) {
                rctx->num_alloc_tex_transfer_bytes += rtransfer->staging->buf->size;
-               pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
+               r600_resource_reference(&rtransfer->staging, NULL);
        }
 
        /* Heuristic for {upload, draw, upload, draw, ..}:
@@ -1635,8 +1635,8 @@ static void r600_surface_destroy(struct pipe_context *pipe,
                                 struct pipe_surface *surface)
 {
        struct r600_surface *surf = (struct r600_surface*)surface;
-       pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_fmask, NULL);
-       pipe_resource_reference((struct pipe_resource**)&surf->cb_buffer_cmask, NULL);
+       r600_resource_reference(&surf->cb_buffer_fmask, NULL);
+       r600_resource_reference(&surf->cb_buffer_cmask, NULL);
        pipe_resource_reference(&surface->texture, NULL);
        FREE(surface);
 }
index aba1404d1cb16caaeaebf322e9459fdb665d8915..5b29c78192f6e536521bfec7ee1c2b70597de5f0 100644 (file)
@@ -73,7 +73,7 @@ bool rvid_create_buffer(struct pipe_screen *screen, struct rvid_buffer *buffer,
 /* destroy a buffer */
 void rvid_destroy_buffer(struct rvid_buffer *buffer)
 {
-       pipe_resource_reference((struct pipe_resource **)&buffer->res, NULL);
+       r600_resource_reference(&buffer->res, NULL);
 }
 
 /* reallocate a buffer, preserving its content */
index f19e830c58012bcdf82b0eaaf5034c48df900e4e..323204e2ab2c90eb35a8bee66f33cc1f3596c79a 100644 (file)
@@ -208,9 +208,7 @@ static bool si_setup_compute_scratch_buffer(struct si_context *sctx,
                scratch_bo_size = sctx->compute_scratch_buffer->b.b.width0;
 
        if (scratch_bo_size < scratch_needed) {
-               pipe_resource_reference(
-                       (struct pipe_resource**)&sctx->compute_scratch_buffer,
-                       NULL);
+               r600_resource_reference(&sctx->compute_scratch_buffer, NULL);
 
                sctx->compute_scratch_buffer =
                                si_resource_create_custom(&sctx->screen->b.b,
@@ -361,7 +359,7 @@ static void si_upload_compute_input(struct si_context *sctx,
        radeon_emit(cs, S_008F04_BASE_ADDRESS_HI (kernel_args_va >> 32) |
                        S_008F04_STRIDE(0));
 
-       pipe_resource_reference((struct pipe_resource**)&input_buffer, NULL);
+       r600_resource_reference(&input_buffer, NULL);
 }
 
 static void si_setup_tgsi_grid(struct si_context *sctx,
index e95556bf11752d034965973e94a36a1e9c0ba9e3..78d14afe4066570afb2d6c3ba2da484f62f1b56d 100644 (file)
@@ -132,7 +132,7 @@ static void si_init_descriptors(struct si_descriptors *desc,
 
 static void si_release_descriptors(struct si_descriptors *desc)
 {
-       pipe_resource_reference((struct pipe_resource**)&desc->buffer, NULL);
+       r600_resource_reference(&desc->buffer, NULL);
        FREE(desc->list);
 }
 
index daef49d58b660f215b1bd39e236ffe2821231f9d..89490bd0c29bb81b32c21873ce5a7c8a54b20d3f 100644 (file)
@@ -1725,9 +1725,7 @@ static bool si_update_spi_tmpring_size(struct si_context *sctx)
        if (scratch_needed_size > 0) {
                if (scratch_needed_size > current_scratch_buffer_size) {
                        /* Create a bigger scratch buffer */
-                       pipe_resource_reference(
-                                       (struct pipe_resource**)&sctx->scratch_buffer,
-                                       NULL);
+                       r600_resource_reference(&sctx->scratch_buffer, NULL);
 
                        sctx->scratch_buffer =
                                        si_resource_create_custom(&sctx->screen->b.b,