etnaviv: Check that resource has a valid TS in etna_resource_needs_flush
authorWladimir J. van der Laan <laanwj@gmail.com>
Tue, 14 Nov 2017 09:21:20 +0000 (10:21 +0100)
committerChristian Gmeiner <christian.gmeiner@gmail.com>
Wed, 15 Nov 2017 22:27:09 +0000 (23:27 +0100)
Resources only need a resolve-to-itself if their TS is valid for any
level, not just if it happens to be allocated.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
src/gallium/drivers/etnaviv/etnaviv_resource.c
src/gallium/drivers/etnaviv/etnaviv_resource.h

index 0a82807b40105907778eab6051d55f865ac0839c..1fb73c493944dfd84804d5a3d209b17b5c553c13 100644 (file)
@@ -629,6 +629,19 @@ etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc,
    rsc->pending_ctx = ctx;
 }
 
+bool
+etna_resource_has_valid_ts(struct etna_resource *rsc)
+{
+   if (!rsc->ts_bo)
+      return false;
+
+   for (int level = 0; level <= rsc->base.last_level; level++)
+      if (rsc->levels[level].ts_valid)
+         return true;
+
+   return false;
+}
+
 void
 etna_resource_screen_init(struct pipe_screen *pscreen)
 {
index 0b135e2373b6e12c284564c73615430e3b1c1d3d..11ccf8f7bcbe2b5663106849fb2050b97f25c683 100644 (file)
@@ -103,11 +103,15 @@ etna_resource_older(struct etna_resource *a, struct etna_resource *b)
    return (int)(a->seqno - b->seqno) < 0;
 }
 
+/* returns TRUE if a resource has a TS, and it is valid for at least one level */
+bool
+etna_resource_has_valid_ts(struct etna_resource *res);
+
 /* returns TRUE if the resource needs a resolve to itself */
 static inline bool
 etna_resource_needs_flush(struct etna_resource *res)
 {
-   return res->ts_bo && ((int)(res->seqno - res->flush_seqno) > 0);
+   return etna_resource_has_valid_ts(res) && ((int)(res->seqno - res->flush_seqno) > 0);
 }
 
 /* is the resource only used on the sampler? */