radeonsi: fix buffer invalidation of unbound texture buffer objects
authorMarek Olšák <marek.olsak@amd.com>
Mon, 11 Aug 2014 13:06:23 +0000 (15:06 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 14 Aug 2014 18:45:03 +0000 (20:45 +0200)
This maintains a list of all TBOs in a pipe_context.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state.c

index c877797b83cf927325f979dffcac1b9319de42d6..0e95f485e52a3a33ddf210535d33891bbbf29fef 100644 (file)
@@ -914,6 +914,7 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource
        uint64_t old_va = rbuffer->gpu_address;
        unsigned num_elems = sctx->vertex_elements ?
                                       sctx->vertex_elements->count : 0;
+       struct si_pipe_sampler_view *view;
 
        /* Reallocate the buffer in the same pipe_resource. */
        r600_init_resource(&sctx->screen->b, rbuffer, rbuffer->b.b.width0,
@@ -1000,7 +1001,13 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource
                }
        }
 
-       /* Texture buffers. */
+       /* Texture buffers - update virtual addresses in sampler view descriptors. */
+       LIST_FOR_EACH_ENTRY(view, &sctx->b.texture_buffers, list) {
+               if (view->base.texture == buf) {
+                       si_desc_reset_buffer_offset(ctx, view->state, old_va, buf);
+               }
+       }
+       /* Texture buffers - update bindings. */
        for (shader = 0; shader < SI_NUM_SHADERS; shader++) {
                struct si_sampler_views *views = &sctx->samplers[shader].views;
                bool found = false;
@@ -1009,10 +1016,6 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource
                while (mask) {
                        unsigned i = u_bit_scan(&mask);
                        if (views->views[i]->texture == buf) {
-                               /* This updates the sampler view directly. */
-                               si_desc_reset_buffer_offset(ctx, views->desc_data[i],
-                                                           old_va, buf);
-
                                r600_context_bo_reloc(&sctx->b, &sctx->b.rings.gfx,
                                                      rbuffer, RADEON_USAGE_READ,
                                                      RADEON_PRIO_SHADER_BUFFER_RO);
index 7b6c8600718ece67ec014996d76d018e5ab895e2..10f7e23c360cae30070b4072b81b9f03d54eea50 100644 (file)
@@ -47,6 +47,7 @@ struct si_screen {
 
 struct si_pipe_sampler_view {
        struct pipe_sampler_view        base;
+       struct list_head                list;
        struct r600_resource            *resource;
        uint32_t                        state[8];
        uint32_t                        fmask_state[8];
index 6e9a60a62c6669bfd66bda645f21b318eeac466c..d22c112f9f4f885ca3abb93089f8e40f4b6ce4cc 100644 (file)
@@ -2358,6 +2358,7 @@ static struct pipe_sampler_view *si_create_sampler_view(struct pipe_context *ctx
                                                        struct pipe_resource *texture,
                                                        const struct pipe_sampler_view *state)
 {
+       struct si_context *sctx = (struct si_context*)ctx;
        struct si_pipe_sampler_view *view = CALLOC_STRUCT(si_pipe_sampler_view);
        struct r600_texture *tmp = (struct r600_texture*)texture;
        const struct util_format_description *desc;
@@ -2402,6 +2403,8 @@ static struct pipe_sampler_view *si_create_sampler_view(struct pipe_context *ctx
                                 S_008F0C_DST_SEL_W(si_map_swizzle(desc->swizzle[3])) |
                                 S_008F0C_NUM_FORMAT(num_format) |
                                 S_008F0C_DATA_FORMAT(format);
+
+               LIST_ADDTAIL(&view->list, &sctx->b.texture_buffers);
                return &view->base;
        }
 
@@ -2606,10 +2609,13 @@ static struct pipe_sampler_view *si_create_sampler_view(struct pipe_context *ctx
 static void si_sampler_view_destroy(struct pipe_context *ctx,
                                    struct pipe_sampler_view *state)
 {
-       struct r600_pipe_sampler_view *resource = (struct r600_pipe_sampler_view *)state;
+       struct si_pipe_sampler_view *view = (struct si_pipe_sampler_view *)state;
+
+       if (view->resource->b.b.target == PIPE_BUFFER)
+               LIST_DELINIT(&view->list);
 
        pipe_resource_reference(&state->texture, NULL);
-       FREE(resource);
+       FREE(view);
 }
 
 static bool wrap_mode_uses_border_color(unsigned wrap, bool linear_filter)