From: Dave Airlie Date: Tue, 14 Nov 2017 23:47:03 +0000 (+1000) Subject: r600: allocate immed buffer resource for images. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac4f175d79c85fd4910f99ef945069ff681bd7fd;p=mesa.git r600: allocate immed buffer resource for images. In order to image readback we have to execute a MEM_RAT instruction that needs a buffer to transfer the result into until the shader can fetch it. Tested-By: Gert Wollny Signed-off-by: Dave Airlie --- diff --git a/src/gallium/drivers/r600/r600_buffer_common.c b/src/gallium/drivers/r600/r600_buffer_common.c index a6e3b7fcf15..35a702341ab 100644 --- a/src/gallium/drivers/r600/r600_buffer_common.c +++ b/src/gallium/drivers/r600/r600_buffer_common.c @@ -251,6 +251,7 @@ static void r600_buffer_destroy(struct pipe_screen *screen, threaded_resource_deinit(buf); util_range_destroy(&rbuffer->valid_buffer_range); + pipe_resource_reference((struct pipe_resource**)&rbuffer->immed_buffer, NULL); pb_reference(&rbuffer->buf, NULL); FREE(rbuffer); } @@ -606,6 +607,7 @@ r600_alloc_buffer_struct(struct pipe_screen *screen, rbuffer->buf = NULL; rbuffer->bind_history = 0; + rbuffer->immed_buffer = NULL; util_range_init(&rbuffer->valid_buffer_range); return rbuffer; } diff --git a/src/gallium/drivers/r600/r600_pipe_common.h b/src/gallium/drivers/r600/r600_pipe_common.h index a6406cfdb23..c8b971a5e47 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.h +++ b/src/gallium/drivers/r600/r600_pipe_common.h @@ -171,6 +171,12 @@ struct r600_resource { /* Whether this resource is referenced by bindless handles. */ bool texture_handle_allocated; bool image_handle_allocated; + + /* + * EG/Cayman only - for RAT operations hw need an immediate buffer + * to store results in. + */ + struct r600_resource *immed_buffer; }; struct r600_transfer { @@ -773,6 +779,9 @@ void evergreen_do_fast_color_clear(struct r600_common_context *rctx, const union pipe_color_union *color); void r600_init_screen_texture_functions(struct r600_common_screen *rscreen); void r600_init_context_texture_functions(struct r600_common_context *rctx); +void eg_resource_alloc_immed(struct r600_common_screen *rscreen, + struct r600_resource *res, + unsigned immed_size); /* r600_viewport.c */ void evergreen_apply_scissor_bug_workaround(struct r600_common_context *rctx, diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c index 3515d979d9e..ee6ed64b9f2 100644 --- a/src/gallium/drivers/r600/r600_texture.c +++ b/src/gallium/drivers/r600/r600_texture.c @@ -559,6 +559,7 @@ static void r600_texture_destroy(struct pipe_screen *screen, struct r600_resource *resource = &rtex->resource; r600_texture_reference(&rtex->flushed_depth_texture, NULL); + pipe_resource_reference((struct pipe_resource**)&resource->immed_buffer, NULL); if (rtex->cmask_buffer != &rtex->resource) { r600_resource_reference(&rtex->cmask_buffer, NULL); @@ -718,6 +719,15 @@ static void r600_texture_alloc_cmask_separate(struct r600_common_screen *rscreen p_atomic_inc(&rscreen->compressed_colortex_counter); } +void eg_resource_alloc_immed(struct r600_common_screen *rscreen, + struct r600_resource *res, + unsigned immed_size) +{ + res->immed_buffer = (struct r600_resource *) + pipe_buffer_create(&rscreen->b, PIPE_BIND_CUSTOM, + PIPE_USAGE_DEFAULT, immed_size); +} + static void r600_texture_get_htile_size(struct r600_common_screen *rscreen, struct r600_texture *rtex) {