From: Marek Olšák Date: Tue, 21 Jun 2016 19:13:00 +0000 (+0200) Subject: gallium/radeon: use r600_resource_reference X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d5383a7d3114aa5f81a704ff84f58de6b41f94bd;p=mesa.git gallium/radeon: use r600_resource_reference Reviewed-by: Alex Deucher Reviewed-by: Vedran Miletić Reviewed-by: Nicolai Hähnle --- diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 57721d92b85..119c76bd4a9 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -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); diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 9a1008e70c5..ff098f18511 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -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); } diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index 89a9f25b425..e805d332e3e 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -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); diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index ce644b78c81..4b282d0bc9b 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -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); } diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c index a47aa78eacb..4b0cf42a1df 100644 --- a/src/gallium/drivers/radeon/r600_buffer_common.c +++ b/src/gallium/drivers/radeon/r600_buffer_common.c @@ -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); } diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c index 2e06746b9ef..5474dbf2dea 100644 --- a/src/gallium/drivers/radeon/r600_query.c +++ b/src/gallium/drivers/radeon/r600_query.c @@ -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; diff --git a/src/gallium/drivers/radeon/r600_streamout.c b/src/gallium/drivers/radeon/r600_streamout.c index eb818464c90..705eb13835d 100644 --- a/src/gallium/drivers/radeon/r600_streamout.c +++ b/src/gallium/drivers/radeon/r600_streamout.c @@ -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); } diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c index 32347f26edd..6a8ea56933e 100644 --- a/src/gallium/drivers/radeon/r600_texture.c +++ b/src/gallium/drivers/radeon/r600_texture.c @@ -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); } diff --git a/src/gallium/drivers/radeon/radeon_video.c b/src/gallium/drivers/radeon/radeon_video.c index aba1404d1cb..5b29c78192f 100644 --- a/src/gallium/drivers/radeon/radeon_video.c +++ b/src/gallium/drivers/radeon/radeon_video.c @@ -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 */ diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index f19e830c580..323204e2ab2 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -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, diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index e95556bf117..78d14afe406 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -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); } diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index daef49d58b6..89490bd0c29 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -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,