From: Christian König Date: Tue, 24 Jul 2012 16:47:19 +0000 (+0200) Subject: radeonsi: rename r600_resource to si_resource X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe41287ffa8cb35421cadfb16d4cc27c5fcb8b76;p=mesa.git radeonsi: rename r600_resource to si_resource Also split it into seperate header and add some helper functions. Signed-off-by: Christian König Reviewed-by: Alex Deucher Reviewed-by: Michel Dänzer --- diff --git a/src/gallium/drivers/radeonsi/r600.h b/src/gallium/drivers/radeonsi/r600.h index 6ff0bf82cfb..f22d920f504 100644 --- a/src/gallium/drivers/radeonsi/r600.h +++ b/src/gallium/drivers/radeonsi/r600.h @@ -30,6 +30,8 @@ #include "util/u_double_list.h" #include "util/u_transfer.h" +#include "radeonsi_resource.h" + #define R600_ERR(fmt, args...) \ fprintf(stderr, "EE %s:%d %s - "fmt, __FILE__, __LINE__, __func__, ##args) @@ -55,17 +57,6 @@ struct r600_tiling_info { unsigned group_bytes; }; -struct r600_resource { - struct u_resource b; - - /* Winsys objects. */ - struct pb_buffer *buf; - struct radeon_winsys_cs_handle *cs_buf; - - /* Resource state. */ - unsigned domains; -}; - /* R600/R700 STATES */ struct r600_query { union { @@ -85,7 +76,7 @@ struct r600_query { /* The buffer where query results are stored. It's used as a ring, * data blocks for current query are stored sequentially from * results_start to results_end, with wrapping on the buffer end */ - struct r600_resource *buffer; + struct si_resource *buffer; /* The number of dwords for begin_query or end_query. */ unsigned num_cs_dw; /* linked list of queries */ @@ -96,7 +87,7 @@ struct r600_so_target { struct pipe_stream_output_target b; /* The buffer where BUFFER_FILLED_SIZE is stored. */ - struct r600_resource *filled_size; + struct si_resource *filled_size; unsigned stride; unsigned so_index; }; @@ -113,7 +104,7 @@ struct r600_draw { uint32_t indices_bo_offset; unsigned db_render_override; unsigned db_render_control; - struct r600_resource *indices; + struct si_resource *indices; }; struct r600_context; @@ -133,7 +124,7 @@ void r600_context_queries_suspend(struct r600_context *ctx); void r600_context_queries_resume(struct r600_context *ctx); void r600_query_predication(struct r600_context *ctx, struct r600_query *query, int operation, int flag_wait); -void r600_context_emit_fence(struct r600_context *ctx, struct r600_resource *fence, +void r600_context_emit_fence(struct r600_context *ctx, struct si_resource *fence, unsigned offset, unsigned value); void r600_context_streamout_begin(struct r600_context *ctx); diff --git a/src/gallium/drivers/radeonsi/r600_buffer.c b/src/gallium/drivers/radeonsi/r600_buffer.c index 15bff912e13..76de9410e40 100644 --- a/src/gallium/drivers/radeonsi/r600_buffer.c +++ b/src/gallium/drivers/radeonsi/r600_buffer.c @@ -40,7 +40,7 @@ static void r600_buffer_destroy(struct pipe_screen *screen, struct pipe_resource *buf) { struct r600_screen *rscreen = (struct r600_screen*)screen; - struct r600_resource *rbuffer = r600_resource(buf); + struct si_resource *rbuffer = si_resource(buf); pb_reference(&rbuffer->buf, NULL); FREE(rbuffer); @@ -72,7 +72,7 @@ static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx, static void *r600_buffer_transfer_map(struct pipe_context *pipe, struct pipe_transfer *transfer) { - struct r600_resource *rbuffer = r600_resource(transfer->resource); + struct si_resource *rbuffer = si_resource(transfer->resource); struct r600_context *rctx = (struct r600_context*)pipe; uint8_t *data; @@ -115,7 +115,7 @@ static const struct u_resource_vtbl r600_buffer_vtbl = }; bool r600_init_resource(struct r600_screen *rscreen, - struct r600_resource *res, + struct si_resource *res, unsigned size, unsigned alignment, unsigned bind, unsigned usage) { @@ -160,11 +160,11 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen, const struct pipe_resource *templ) { struct r600_screen *rscreen = (struct r600_screen*)screen; - struct r600_resource *rbuffer; + struct si_resource *rbuffer; /* XXX We probably want a different alignment for buffers and textures. */ unsigned alignment = 4096; - rbuffer = MALLOC_STRUCT(r600_resource); + rbuffer = MALLOC_STRUCT(si_resource); rbuffer->b.b = *templ; pipe_reference_init(&rbuffer->b.b.reference, 1); @@ -185,7 +185,7 @@ void r600_upload_index_buffer(struct r600_context *rctx, ib->user_buffer, &ib->offset, &ib->buffer); } -void r600_upload_const_buffer(struct r600_context *rctx, struct r600_resource **rbuffer, +void r600_upload_const_buffer(struct r600_context *rctx, struct si_resource **rbuffer, const uint8_t *ptr, unsigned size, uint32_t *const_offset) { diff --git a/src/gallium/drivers/radeonsi/r600_hw_context.c b/src/gallium/drivers/radeonsi/r600_hw_context.c index 664a6d08c21..a9be2ad26ea 100644 --- a/src/gallium/drivers/radeonsi/r600_hw_context.c +++ b/src/gallium/drivers/radeonsi/r600_hw_context.c @@ -36,7 +36,7 @@ void r600_get_backend_mask(struct r600_context *ctx) { struct radeon_winsys_cs *cs = ctx->cs; - struct r600_resource *buffer; + struct si_resource *buffer; uint32_t *results; unsigned num_backends = ctx->screen->info.r600_num_backends; unsigned i, mask = 0; @@ -66,9 +66,9 @@ void r600_get_backend_mask(struct r600_context *ctx) /* otherwise backup path for older kernels */ /* create buffer for event data */ - buffer = (struct r600_resource*) - pipe_buffer_create(&ctx->screen->screen, PIPE_BIND_CUSTOM, - PIPE_USAGE_STAGING, ctx->max_db*16); + buffer = si_resource_create_custom(&ctx->screen->screen, + PIPE_USAGE_STAGING, + ctx->max_db*16); if (!buffer) goto err; @@ -102,7 +102,7 @@ void r600_get_backend_mask(struct r600_context *ctx) } } - pipe_resource_reference((struct pipe_resource**)&buffer, NULL); + si_resource_reference(&buffer, NULL); if (mask != 0) { ctx->backend_mask = mask; @@ -256,7 +256,7 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags) si_pm4_reset_emitted(ctx); } -void r600_context_emit_fence(struct r600_context *ctx, struct r600_resource *fence_bo, unsigned offset, unsigned value) +void r600_context_emit_fence(struct r600_context *ctx, struct si_resource *fence_bo, unsigned offset, unsigned value) { struct radeon_winsys_cs *cs = ctx->cs; uint64_t va; @@ -594,8 +594,9 @@ struct r600_query *r600_context_query_create(struct r600_context *ctx, unsigned * being written by the gpu, hence staging is probably a good * usage pattern. */ - query->buffer = (struct r600_resource*) - pipe_buffer_create(&ctx->screen->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_STAGING, buffer_size); + query->buffer = si_resource_create_custom(&ctx->screen->screen, + PIPE_USAGE_STAGING, + buffer_size); if (!query->buffer) { FREE(query); return NULL; @@ -605,7 +606,7 @@ struct r600_query *r600_context_query_create(struct r600_context *ctx, unsigned void r600_context_query_destroy(struct r600_context *ctx, struct r600_query *query) { - pipe_resource_reference((struct pipe_resource**)&query->buffer, NULL); + si_resource_reference(&query->buffer, NULL); free(query); } @@ -709,7 +710,7 @@ void r600_context_streamout_begin(struct r600_context *ctx) cs->buf[cs->cdw++] = PKT3(PKT3_NOP, 0, 0); cs->buf[cs->cdw++] = - r600_context_bo_reloc(ctx, r600_resource(t[i]->b.buffer), + r600_context_bo_reloc(ctx, si_resource(t[i]->b.buffer), RADEON_USAGE_WRITE); if (ctx->streamout_append_bitmask & (1 << i)) { @@ -831,7 +832,7 @@ void r600_context_draw_opaque_count(struct r600_context *ctx, struct r600_so_tar cs->buf[cs->cdw++] = t->b.buffer_offset >> 2; cs->buf[cs->cdw++] = PKT3(PKT3_NOP, 0, 0); - cs->buf[cs->cdw++] = r600_context_bo_reloc(ctx, (struct r600_resource*)t->b.buffer, + cs->buf[cs->cdw++] = r600_context_bo_reloc(ctx, (struct si_resource*)t->b.buffer, RADEON_USAGE_WRITE); cs->buf[cs->cdw++] = PKT3(PKT3_WAIT_REG_MEM, 5, 0); diff --git a/src/gallium/drivers/radeonsi/r600_hw_context_priv.h b/src/gallium/drivers/radeonsi/r600_hw_context_priv.h index 01dddb65437..610f8b1708c 100644 --- a/src/gallium/drivers/radeonsi/r600_hw_context_priv.h +++ b/src/gallium/drivers/radeonsi/r600_hw_context_priv.h @@ -47,7 +47,7 @@ void evergreen_flush_vgt_streamout(struct r600_context *ctx); void evergreen_set_streamout_enable(struct r600_context *ctx, unsigned buffer_enable_bit); -static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct r600_resource *rbo, +static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct si_resource *rbo, enum radeon_bo_usage usage) { assert(usage); diff --git a/src/gallium/drivers/radeonsi/r600_resource.h b/src/gallium/drivers/radeonsi/r600_resource.h index 314fb239b83..b4427a165de 100644 --- a/src/gallium/drivers/radeonsi/r600_resource.h +++ b/src/gallium/drivers/radeonsi/r600_resource.h @@ -39,7 +39,7 @@ struct r600_transfer { }; struct r600_resource_texture { - struct r600_resource resource; + struct si_resource resource; /* If this resource is a depth-stencil buffer on evergreen, this contains * the depth part of the format. There is a separate stencil resource @@ -77,11 +77,6 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen, const struct pipe_resource *base, struct winsys_handle *whandle); -static INLINE struct r600_resource *r600_resource(struct pipe_resource *r) -{ - return (struct r600_resource*)r; -} - int r600_texture_depth_flush(struct pipe_context *ctx, struct pipe_resource *texture, boolean just_create); /* r600_texture.c texture transfer functions. */ @@ -99,7 +94,7 @@ void r600_texture_transfer_unmap(struct pipe_context *ctx, struct r600_context; -void r600_upload_const_buffer(struct r600_context *rctx, struct r600_resource **rbuffer, +void r600_upload_const_buffer(struct r600_context *rctx, struct si_resource **rbuffer, const uint8_t *ptr, unsigned size, uint32_t *const_offset); diff --git a/src/gallium/drivers/radeonsi/r600_texture.c b/src/gallium/drivers/radeonsi/r600_texture.c index 8a62d68ff86..38ff36df1e9 100644 --- a/src/gallium/drivers/radeonsi/r600_texture.c +++ b/src/gallium/drivers/radeonsi/r600_texture.c @@ -456,7 +456,7 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen, struct winsys_handle *whandle) { struct r600_resource_texture *rtex = (struct r600_resource_texture*)ptex; - struct r600_resource *resource = &rtex->resource; + struct si_resource *resource = &rtex->resource; struct radeon_surface *surface = &rtex->surface; struct r600_screen *rscreen = (struct r600_screen*)screen; @@ -480,13 +480,13 @@ static void r600_texture_destroy(struct pipe_screen *screen, struct pipe_resource *ptex) { struct r600_resource_texture *rtex = (struct r600_resource_texture*)ptex; - struct r600_resource *resource = &rtex->resource; + struct si_resource *resource = &rtex->resource; if (rtex->flushed_depth_texture) - pipe_resource_reference((struct pipe_resource **)&rtex->flushed_depth_texture, NULL); + si_resource_reference(&rtex->flushed_depth_texture, NULL); if (rtex->stencil) - pipe_resource_reference((struct pipe_resource **)&rtex->stencil, NULL); + si_resource_reference(&rtex->stencil, NULL); pb_reference(&resource->buf, NULL); FREE(rtex); @@ -515,7 +515,7 @@ r600_texture_create_object(struct pipe_screen *screen, struct radeon_surface *surface) { struct r600_resource_texture *rtex; - struct r600_resource *resource; + struct si_resource *resource; struct r600_screen *rscreen = (struct r600_screen*)screen; int r; @@ -563,7 +563,7 @@ r600_texture_create_object(struct pipe_screen *screen, base_align = rtex->surface.bo_alignment; if (!r600_init_resource(rscreen, resource, rtex->size, base_align, base->bind, base->usage)) { - pipe_resource_reference((struct pipe_resource**)&rtex->stencil, NULL); + si_resource_reference(&rtex->stencil, NULL); FREE(rtex); return NULL; } @@ -877,14 +877,14 @@ void* r600_texture_transfer_map(struct pipe_context *ctx, char *map; if (rtransfer->staging_texture) { - buf = ((struct r600_resource *)rtransfer->staging_texture)->cs_buf; + buf = si_resource(rtransfer->staging_texture)->cs_buf; } else { struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource; if (rtex->flushed_depth_texture) - buf = ((struct r600_resource *)rtex->flushed_depth_texture)->cs_buf; + buf = si_resource(rtex->flushed_depth_texture)->cs_buf; else - buf = ((struct r600_resource *)transfer->resource)->cs_buf; + buf = si_resource(transfer->resource)->cs_buf; offset = rtransfer->offset + transfer->box.y / util_format_get_blockheight(format) * transfer->stride + @@ -906,14 +906,14 @@ void r600_texture_transfer_unmap(struct pipe_context *ctx, struct radeon_winsys_cs_handle *buf; if (rtransfer->staging_texture) { - buf = ((struct r600_resource *)rtransfer->staging_texture)->cs_buf; + buf = si_resource(rtransfer->staging_texture)->cs_buf; } else { struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource; if (rtex->flushed_depth_texture) { - buf = ((struct r600_resource *)rtex->flushed_depth_texture)->cs_buf; + buf = si_resource(rtex->flushed_depth_texture)->cs_buf; } else { - buf = ((struct r600_resource *)transfer->resource)->cs_buf; + buf = si_resource(transfer->resource)->cs_buf; } } rctx->ws->buffer_unmap(buf); diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c b/src/gallium/drivers/radeonsi/radeonsi_pipe.c index 874356a8edd..3c5eaf7d61c 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c +++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c @@ -61,9 +61,9 @@ static struct r600_fence *r600_create_fence(struct r600_context *rctx) if (!rscreen->fences.bo) { /* Create the shared buffer object */ - rscreen->fences.bo = (struct r600_resource*) - pipe_buffer_create(&rscreen->screen, PIPE_BIND_CUSTOM, - PIPE_USAGE_STAGING, 4096); + rscreen->fences.bo = si_resource_create_custom(&rscreen->screen, + PIPE_USAGE_STAGING, + 4096); if (!rscreen->fences.bo) { R600_ERR("r600: failed to create bo for fence objects\n"); goto out; @@ -119,9 +119,8 @@ static struct r600_fence *r600_create_fence(struct r600_context *rctx) r600_context_emit_fence(rctx, rscreen->fences.bo, fence->index, 1); /* Create a dummy BO so that fence_finish without a timeout can sleep waiting for completion */ - fence->sleep_bo = (struct r600_resource*) - pipe_buffer_create(&rctx->screen->screen, PIPE_BIND_CUSTOM, - PIPE_USAGE_STAGING, 1); + fence->sleep_bo = si_resource_create_custom(&rctx->screen->screen, PIPE_USAGE_STAGING, 1); + /* Add the fence as a dummy relocation. */ r600_context_bo_reloc(rctx, fence->sleep_bo, RADEON_USAGE_READWRITE); @@ -495,7 +494,7 @@ static void r600_destroy_screen(struct pipe_screen* pscreen) } rscreen->ws->buffer_unmap(rscreen->fences.bo->cs_buf); - pipe_resource_reference((struct pipe_resource**)&rscreen->fences.bo, NULL); + si_resource_reference(&rscreen->fences.bo, NULL); } pipe_mutex_destroy(rscreen->fences.mutex); @@ -513,7 +512,7 @@ static void r600_fence_reference(struct pipe_screen *pscreen, if (pipe_reference(&(*oldf)->reference, &newf->reference)) { struct r600_screen *rscreen = (struct r600_screen *)pscreen; pipe_mutex_lock(rscreen->fences.mutex); - pipe_resource_reference((struct pipe_resource**)&(*oldf)->sleep_bo, NULL); + si_resource_reference(&(*oldf)->sleep_bo, NULL); LIST_ADDTAIL(&(*oldf)->head, &rscreen->fences.pool); pipe_mutex_unlock(rscreen->fences.mutex); } diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h index f67c33364f2..bde468c64fe 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h +++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h @@ -75,7 +75,7 @@ struct r600_atom_surface_sync { }; struct r600_pipe_fences { - struct r600_resource *bo; + struct si_resource *bo; unsigned *data; unsigned next_index; /* linked list of preallocated blocks */ @@ -120,7 +120,7 @@ struct r600_textures_info { struct r600_fence { struct pipe_reference reference; unsigned index; /* in the shared bo */ - struct r600_resource *sleep_bo; + struct si_resource *sleep_bo; struct list_head head; }; @@ -239,7 +239,7 @@ void r600_flush_depth_textures(struct r600_context *rctx); /* r600_buffer.c */ bool r600_init_resource(struct r600_screen *rscreen, - struct r600_resource *res, + struct si_resource *res, unsigned size, unsigned alignment, unsigned bind, unsigned usage); struct pipe_resource *r600_buffer_create(struct pipe_screen *screen, @@ -323,7 +323,7 @@ static INLINE unsigned r600_pack_float_12p4(float x) static INLINE uint64_t r600_resource_va(struct pipe_screen *screen, struct pipe_resource *resource) { struct r600_screen *rscreen = (struct r600_screen*)screen; - struct r600_resource *rresource = (struct r600_resource*)resource; + struct si_resource *rresource = (struct si_resource*)resource; return rscreen->ws->buffer_get_virtual_address(rresource->cs_buf); } diff --git a/src/gallium/drivers/radeonsi/radeonsi_pm4.c b/src/gallium/drivers/radeonsi/radeonsi_pm4.c index 488e1ccfd34..0aad78fdcb4 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_pm4.c +++ b/src/gallium/drivers/radeonsi/radeonsi_pm4.c @@ -69,14 +69,13 @@ void si_pm4_set_reg(struct si_pm4_state *state, unsigned reg, uint32_t val) } void si_pm4_add_bo(struct si_pm4_state *state, - struct r600_resource *bo, + struct si_resource *bo, enum radeon_bo_usage usage) { unsigned idx = state->nbo++; assert(idx < SI_PM4_MAX_BO); - pipe_resource_reference((struct pipe_resource**)&state->bo[idx], - (struct pipe_resource*)bo); + si_resource_reference(&state->bo[idx], bo); state->bo_usage[idx] = usage; } @@ -120,8 +119,7 @@ void si_pm4_free_state(struct r600_context *rctx, } for (int i = 0; i < state->nbo; ++i) { - pipe_resource_reference((struct pipe_resource**)&state->bo[idx], - NULL); + si_resource_reference(&state->bo[idx], NULL); } FREE(state); } diff --git a/src/gallium/drivers/radeonsi/radeonsi_pm4.h b/src/gallium/drivers/radeonsi/radeonsi_pm4.h index e6148b4c20c..18e51831e8f 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_pm4.h +++ b/src/gallium/drivers/radeonsi/radeonsi_pm4.h @@ -51,13 +51,13 @@ struct si_pm4_state /* BO's referenced by this state */ unsigned nbo; - struct r600_resource *bo[SI_PM4_MAX_BO]; + struct si_resource *bo[SI_PM4_MAX_BO]; enum radeon_bo_usage bo_usage[SI_PM4_MAX_BO]; }; void si_pm4_set_reg(struct si_pm4_state *state, unsigned reg, uint32_t val); void si_pm4_add_bo(struct si_pm4_state *state, - struct r600_resource *bo, + struct si_resource *bo, enum radeon_bo_usage usage); void si_pm4_inval_shader_cache(struct si_pm4_state *state); diff --git a/src/gallium/drivers/radeonsi/radeonsi_resource.h b/src/gallium/drivers/radeonsi/radeonsi_resource.h new file mode 100644 index 00000000000..9f4b4c136cf --- /dev/null +++ b/src/gallium/drivers/radeonsi/radeonsi_resource.h @@ -0,0 +1,67 @@ +/* + * Copyright 2012 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Christian König + */ + +#ifndef RADEONSI_RESOURCE_H +#define RADEONSI_RESOURCE_H + +#include "../../winsys/radeon/drm/radeon_winsys.h" +#include "util/u_transfer.h" +#include "util/u_inlines.h" + +struct si_resource { + struct u_resource b; + + /* Winsys objects. */ + struct pb_buffer *buf; + struct radeon_winsys_cs_handle *cs_buf; + + /* Resource state. */ + unsigned domains; +}; + +static INLINE void +si_resource_reference(struct si_resource **ptr, struct si_resource *res) +{ + pipe_resource_reference((struct pipe_resource **)ptr, + (struct pipe_resource *)res); +} + +static INLINE struct si_resource * +si_resource(struct pipe_resource *r) +{ + return (struct si_resource*)r; +} + +static INLINE struct si_resource * +si_resource_create_custom(struct pipe_screen *screen, + unsigned usage, unsigned size) +{ + assert(size); + return si_resource(pipe_buffer_create(screen, + PIPE_BIND_CUSTOM, usage, size)); +} + +#endif diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c index cc6003544e3..70081370b3e 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_shader.c +++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c @@ -611,8 +611,7 @@ int si_pipe_shader_create( if (shader->bo == NULL) { uint32_t *ptr; - shader->bo = (struct r600_resource*) - pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, inst_byte_count); + shader->bo = si_resource_create_custom(ctx->screen, PIPE_USAGE_IMMUTABLE, inst_byte_count); if (shader->bo == NULL) { return -ENOMEM; } @@ -634,7 +633,7 @@ int si_pipe_shader_create( void si_pipe_shader_destroy(struct pipe_context *ctx, struct si_pipe_shader *shader) { - pipe_resource_reference((struct pipe_resource**)&shader->bo, NULL); + si_resource_reference(&shader->bo, NULL); memset(&shader->shader,0,sizeof(struct si_shader)); } diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 79665d68845..297d7912def 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -1914,7 +1914,7 @@ static void si_set_ps_sampler_view(struct pipe_context *ctx, unsigned count, struct r600_context *rctx = (struct r600_context *)ctx; struct si_pipe_sampler_view **resource = (struct si_pipe_sampler_view **)views; struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state); - struct r600_resource *bo; + struct si_resource *bo; int i; int has_depth = 0; uint64_t va; @@ -1925,9 +1925,8 @@ static void si_set_ps_sampler_view(struct pipe_context *ctx, unsigned count, si_pm4_inval_texture_cache(pm4); - bo = (struct r600_resource*) - pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, - count * sizeof(resource[0]->state)); + bo = si_resource_create_custom(ctx->screen, PIPE_USAGE_IMMUTABLE, + count * sizeof(resource[0]->state)); ptr = rctx->ws->buffer_map(bo->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE); for (i = 0; i < count; i++, ptr += sizeof(resource[0]->state)) { @@ -1976,7 +1975,7 @@ static void si_bind_ps_sampler(struct pipe_context *ctx, unsigned count, void ** struct r600_context *rctx = (struct r600_context *)ctx; struct si_pipe_sampler_state **rstates = (struct si_pipe_sampler_state **)states; struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state); - struct r600_resource *bo; + struct si_resource *bo; uint64_t va; char *ptr; int i; @@ -1986,9 +1985,8 @@ static void si_bind_ps_sampler(struct pipe_context *ctx, unsigned count, void ** si_pm4_inval_texture_cache(pm4); - bo = (struct r600_resource*) - pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, - count * sizeof(rstates[0]->val)); + bo = si_resource_create_custom(ctx->screen, PIPE_USAGE_IMMUTABLE, + count * sizeof(rstates[0]->val)); ptr = rctx->ws->buffer_map(bo->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE); for (i = 0; i < count; i++, ptr += sizeof(rstates[0]->val)) { @@ -2025,7 +2023,7 @@ static void si_set_constant_buffer(struct pipe_context *ctx, uint shader, uint i struct pipe_constant_buffer *cb) { struct r600_context *rctx = (struct r600_context *)ctx; - struct r600_resource *rbuffer = cb ? r600_resource(cb->buffer) : NULL; + struct si_resource *rbuffer = cb ? si_resource(cb->buffer) : NULL; struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state); uint64_t va_offset; uint32_t offset; @@ -2068,7 +2066,7 @@ static void si_set_constant_buffer(struct pipe_context *ctx, uint shader, uint i } if (cb->buffer != &rbuffer->b.b) - pipe_resource_reference((struct pipe_resource**)&rbuffer, NULL); + si_resource_reference(&rbuffer, NULL); } /* @@ -2154,8 +2152,7 @@ si_create_so_target(struct pipe_context *ctx, t->b.buffer_offset = buffer_offset; t->b.buffer_size = buffer_size; - t->filled_size = (struct r600_resource*) - pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_STATIC, 4); + t->filled_size = si_resource_create_custom(ctx->screen, PIPE_USAGE_STATIC, 4); ptr = rctx->ws->buffer_map(t->filled_size->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE); memset(ptr, 0, t->filled_size->buf->size); rctx->ws->buffer_unmap(t->filled_size->cs_buf); @@ -2168,7 +2165,7 @@ static void si_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->filled_size, NULL); + si_resource_reference(&t->filled_size, NULL); FREE(t); } diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 771de125e93..0eecf2f5eab 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -90,7 +90,7 @@ struct si_shader { struct si_pipe_shader { struct si_shader shader; struct si_pm4_state *pm4; - struct r600_resource *bo; + struct si_resource *bo; struct si_vertex_element vertex_elements; struct tgsi_token *tokens; unsigned num_sgprs; diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index 1648cce40a9..c49091d845b 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -383,7 +383,7 @@ static void si_update_derived_state(struct r600_context *rctx) static void si_vertex_buffer_update(struct r600_context *rctx) { struct pipe_context *ctx = &rctx->context; - struct r600_resource *rbuffer, *t_list_buffer; + struct si_resource *rbuffer, *t_list_buffer; struct pipe_vertex_buffer *vertex_buffer; struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state); unsigned i, count, offset; @@ -396,9 +396,8 @@ static void si_vertex_buffer_update(struct r600_context *rctx) count = rctx->nr_vertex_buffers; assert(count <= 256 / 4); - t_list_buffer = (struct r600_resource*) - pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, - PIPE_USAGE_IMMUTABLE, 4 * 4 * count); + t_list_buffer = si_resource_create_custom(ctx->screen, PIPE_USAGE_IMMUTABLE, + 4 * 4 * count); if (t_list_buffer == NULL) { FREE(pm4); return; @@ -416,7 +415,7 @@ static void si_vertex_buffer_update(struct r600_context *rctx) /* bind vertex buffer once */ vertex_buffer = &rctx->vertex_buffer[i]; - rbuffer = (struct r600_resource*)vertex_buffer->buffer; + rbuffer = (struct si_resource*)vertex_buffer->buffer; offset = 0; if (vertex_buffer == NULL || rbuffer == NULL) continue; @@ -516,7 +515,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo) rdraw.vgt_index_type = V_028A7C_VGT_INDEX_16 | (R600_BIG_ENDIAN ? V_028A7C_VGT_DMA_SWAP_16_BIT : 0); } - rdraw.indices = (struct r600_resource*)ib.buffer; + rdraw.indices = (struct si_resource*)ib.buffer; rdraw.indices_bo_offset = ib.offset; rdraw.vgt_draw_initiator = V_0287F0_DI_SRC_SEL_DMA; } else {