diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index 104f0fe5477..99f33e6be10 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -1297,8 +1297,8 @@ static void r600_compute_global_transfer_unmap(struct pipe_context *ctx, assert (!"This function should not be called"); } -static void r600_compute_global_buffer_destroy(struct pipe_screen *screen, - struct pipe_resource *res) +void r600_compute_global_buffer_destroy(struct pipe_screen *screen, + struct pipe_resource *res) { struct r600_resource_global* buffer = NULL; struct r600_screen* rscreen = NULL; @@ -1317,7 +1317,7 @@ static void r600_compute_global_buffer_destroy(struct pipe_screen *screen, static const struct u_resource_vtbl r600_global_buffer_vtbl = { - r600_compute_global_buffer_destroy, /* resource_destroy */ + NULL, /* resource_destroy */ r600_compute_global_transfer_map, /* transfer_map */ r600_compute_global_transfer_unmap, /* transfer_unmap */ }; diff --git a/src/gallium/drivers/r600/evergreen_compute.h b/src/gallium/drivers/r600/evergreen_compute.h index 3c178870d91..e1e00276b93 100644 --- a/src/gallium/drivers/r600/evergreen_compute.h +++ b/src/gallium/drivers/r600/evergreen_compute.h @@ -44,5 +44,7 @@ void evergreen_emit_cs_shader(struct r600_context *rctx, struct r600_atom * atom struct r600_resource* r600_compute_buffer_alloc_vram(struct r600_screen *screen, unsigned size); struct pipe_resource *r600_compute_global_buffer_create(struct pipe_screen *screen, const struct pipe_resource *templ); +void r600_compute_global_buffer_destroy(struct pipe_screen *screen, + struct pipe_resource *res); #endif diff --git a/src/gallium/drivers/r600/r600_buffer_common.c b/src/gallium/drivers/r600/r600_buffer_common.c index 70fa6cd2148..148dfeedd5b 100644 --- a/src/gallium/drivers/r600/r600_buffer_common.c +++ b/src/gallium/drivers/r600/r600_buffer_common.c @@ -222,8 +222,7 @@ bool r600_alloc_resource(struct r600_common_screen *rscreen, return true; } -static void r600_buffer_destroy(struct pipe_screen *screen, - struct pipe_resource *buf) +void r600_buffer_destroy(struct pipe_screen *screen, struct pipe_resource *buf) { struct r600_resource *rbuffer = r600_resource(buf); @@ -564,7 +563,7 @@ void r600_buffer_subdata(struct pipe_context *ctx, static const struct u_resource_vtbl r600_buffer_vtbl = { - r600_buffer_destroy, /* resource_destroy */ + NULL, /* resource_destroy */ r600_buffer_transfer_map, /* transfer_map */ r600_buffer_transfer_unmap, /* transfer_unmap */ }; diff --git a/src/gallium/drivers/r600/r600_pipe_common.c b/src/gallium/drivers/r600/r600_pipe_common.c index ab232e29dd3..639de602c46 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.c +++ b/src/gallium/drivers/r600/r600_pipe_common.c @@ -26,6 +26,7 @@ #include "r600_pipe_common.h" #include "r600_cs.h" +#include "evergreen_compute.h" #include "tgsi/tgsi_parse.h" #include "util/list.h" #include "util/u_draw_quad.h" @@ -1183,6 +1184,19 @@ r600_get_compiler_options(struct pipe_screen *screen, extern bool r600_lower_to_scalar_instr_filter(const nir_instr *instr, const void *); +static void r600_resource_destroy(struct pipe_screen *screen, + struct pipe_resource *res) +{ + if (res->target == PIPE_BUFFER) { + if (r600_resource(res)->compute_global_bo) + r600_compute_global_buffer_destroy(screen, res); + else + r600_buffer_destroy(screen, res); + } else { + r600_texture_destroy(screen, res); + } +} + bool r600_common_screen_init(struct r600_common_screen *rscreen, struct radeon_winsys *ws) { @@ -1219,7 +1233,7 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen, rscreen->b.get_compiler_options = r600_get_compiler_options; rscreen->b.fence_finish = r600_fence_finish; rscreen->b.fence_reference = r600_fence_reference; - rscreen->b.resource_destroy = u_resource_destroy_vtbl; + rscreen->b.resource_destroy = r600_resource_destroy; rscreen->b.resource_from_user_memory = r600_buffer_from_user_memory; rscreen->b.query_memory_info = r600_query_memory_info; diff --git a/src/gallium/drivers/r600/r600_pipe_common.h b/src/gallium/drivers/r600/r600_pipe_common.h index f50beb4028f..0c1c74c182f 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.h +++ b/src/gallium/drivers/r600/r600_pipe_common.h @@ -641,6 +641,7 @@ void r600_init_resource_fields(struct r600_common_screen *rscreen, uint64_t size, unsigned alignment); bool r600_alloc_resource(struct r600_common_screen *rscreen, struct r600_resource *res); +void r600_buffer_destroy(struct pipe_screen *screen, struct pipe_resource *buf); void r600_buffer_flush_region(struct pipe_context *ctx, struct pipe_transfer *transfer, const struct pipe_box *rel_box); @@ -743,6 +744,7 @@ bool r600_prepare_for_dma_blit(struct r600_common_context *rctx, struct r600_texture *rsrc, unsigned src_level, const struct pipe_box *src_box); +void r600_texture_destroy(struct pipe_screen *screen, struct pipe_resource *ptex); void r600_texture_get_fmask_info(struct r600_common_screen *rscreen, struct r600_texture *rtex, unsigned nr_samples, diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c index ffd6ecd0ad0..bd8ab3d96bb 100644 --- a/src/gallium/drivers/r600/r600_texture.c +++ b/src/gallium/drivers/r600/r600_texture.c @@ -574,8 +574,7 @@ static bool r600_texture_get_handle(struct pipe_screen* screen, return rscreen->ws->buffer_get_handle(rscreen->ws, res->buf, whandle); } -static void r600_texture_destroy(struct pipe_screen *screen, - struct pipe_resource *ptex) +void r600_texture_destroy(struct pipe_screen *screen, struct pipe_resource *ptex) { struct r600_texture *rtex = (struct r600_texture*)ptex; struct r600_resource *resource = &rtex->resource; @@ -1521,7 +1520,7 @@ static void r600_texture_transfer_unmap(struct pipe_context *ctx, static const struct u_resource_vtbl r600_texture_vtbl = { - r600_texture_destroy, /* resource_destroy */ + NULL, /* resource_destroy */ r600_texture_transfer_map, /* transfer_map */ r600_texture_transfer_unmap, /* transfer_unmap */ };