r600: allocate immed buffer resource for images.
authorDave Airlie <airlied@redhat.com>
Tue, 14 Nov 2017 23:47:03 +0000 (09:47 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 17 Nov 2017 01:31:40 +0000 (11:31 +1000)
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 <gw.fossdev@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/r600_buffer_common.c
src/gallium/drivers/r600/r600_pipe_common.h
src/gallium/drivers/r600/r600_texture.c

index a6e3b7fcf159b6aa96206c98487969fc7e603661..35a702341ab5e0c9645ac1b538c4a17053b57410 100644 (file)
@@ -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;
 }
index a6406cfdb2373314ab8db8ba536b9dc9b6c307b0..c8b971a5e47550f098abdc2eef16cc1ef6bdc228 100644 (file)
@@ -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,
index 3515d979d9ef5e25ec1457fea80f5ff39303f60d..ee6ed64b9f20784cb281eab7eec47289ff380427 100644 (file)
@@ -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)
 {