freedreno: add resource seqno
authorRob Clark <robdclark@gmail.com>
Fri, 12 Oct 2018 13:24:21 +0000 (09:24 -0400)
committerRob Clark <robdclark@gmail.com>
Wed, 17 Oct 2018 16:44:48 +0000 (12:44 -0400)
Intended to be something more compact than a 64b pointer, which could be
used as a key into hashtables.  Prep work for texture state objects.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/freedreno_resource.c
src/gallium/drivers/freedreno/freedreno_resource.h
src/gallium/drivers/freedreno/freedreno_screen.h
src/gallium/drivers/freedreno/freedreno_texture.c

index 4b23b6458576dcc91b6642fd719b85f1e849dcf4..759ae7d28ae6f4f4926178265c8dbf7747bbb154 100644 (file)
@@ -108,6 +108,7 @@ realloc_bo(struct fd_resource *rsc, uint32_t size)
                fd_bo_del(rsc->bo);
 
        rsc->bo = fd_bo_new(screen->dev, size, flags);
+       rsc->seqno = p_atomic_inc_return(&screen->rsc_seqno);
        util_range_set_empty(&rsc->valid_buffer_range);
        fd_bc_invalidate_resource(rsc, true);
 }
@@ -193,6 +194,7 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc,
        /* TODO valid_buffer_range?? */
        swap(rsc->bo,        shadow->bo);
        swap(rsc->write_batch,   shadow->write_batch);
+       rsc->seqno = p_atomic_inc_return(&ctx->screen->rsc_seqno);
 
        /* at this point, the newly created shadow buffer is not referenced
         * by any batches, but the existing rsc (probably) is.  We need to
index c833beb835c1712c54dd07f0ed213f59f3a3655c..09abb512d7eeae93db0007225f51bd8142811bd5 100644 (file)
@@ -95,6 +95,9 @@ struct fd_resource {
         */
        uint32_t bc_batch_mask;
 
+       /* Sequence # incremented each time bo changes: */
+       uint16_t seqno;
+
        unsigned tile_mode : 2;
        unsigned preferred_tile_mode : 2;
 
index 19ba81523e1bd3466ee2d9ff06660c00a0793fda..b0b0e4f0d747d050e7403f9cadf31c6770e059ad 100644 (file)
@@ -95,6 +95,8 @@ struct fd_screen {
        struct fd_batch_cache batch_cache;
 
        bool reorder;
+
+       uint16_t rsc_seqno;
 };
 
 static inline struct fd_screen *
index 7c2057885b2480415a8b1c5290974534ea16837a..d92298d2ea50625c8119d5b8872455a4aa1bb5c9 100644 (file)
@@ -117,9 +117,10 @@ fd_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
 void
 fd_texture_init(struct pipe_context *pctx)
 {
-       pctx->delete_sampler_state = fd_sampler_state_delete;
-
-       pctx->sampler_view_destroy = fd_sampler_view_destroy;
+       if (!pctx->delete_sampler_state)
+               pctx->delete_sampler_state = fd_sampler_state_delete;
+       if (!pctx->sampler_view_destroy)
+               pctx->sampler_view_destroy = fd_sampler_view_destroy;
 }
 
 /* helper for setting up border-color buffer for a3xx/a4xx: */