OSDN Git Service

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 4b23b64..759ae7d 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 c833beb..09abb51 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 19ba815..b0b0e4f 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 7c20578..d92298d 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: */