Module: Mesa
Branch: master
Commit: 03b1f8ba205d3eff59784faf805272a4d7aa4b18
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=03b1f8ba205d3eff59784faf805272a4d7aa4b18

Author: Lucas Stach <l.st...@pengutronix.de>
Date:   Tue Sep 26 18:27:55 2017 +0200

etnaviv: fix bogus flush requests in transfer handling

The logic to decide if we need to flush the GPU command stream was broken
and hard to reason about. Fix and clarify this.

Fixes the data sync subtests from piglit arb_vertex_buffer_object.

Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
Reviewed-by: Wladimir J. van der Laan <laa...@gmail.com>

---

 src/gallium/drivers/etnaviv/etnaviv_transfer.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
index ee5cda5e8e..08ec1987d8 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
@@ -243,11 +243,16 @@ etna_transfer_map(struct pipe_context *pctx, struct 
pipe_resource *prsc,
 
    struct etna_resource_level *res_level = &rsc->levels[level];
 
-   /* Always sync if we have the temporary resource.  The PIPE_TRANSFER_READ
-    * case could be optimised if we knew whether the resource has outstanding
-    * rendering. */
-   if ((usage & PIPE_TRANSFER_READ || trans->rsc) &&
-       rsc->status & ETNA_PENDING_WRITE)
+   /*
+    * Always flush if we have the temporary resource and have a copy to this
+    * outstanding. Otherwise infer flush requirement from resource access and
+    * current GPU usage (reads must wait for GPU writes, writes must have
+    * exclusive access to the buffer).
+    */
+   if ((trans->rsc && (etna_resource(trans->rsc)->status & 
ETNA_PENDING_WRITE)) ||
+       (!trans->rsc &&
+        (((usage & PIPE_TRANSFER_READ) && (rsc->status & ETNA_PENDING_WRITE)) 
||
+        ((usage & PIPE_TRANSFER_WRITE) && rsc->status))))
       pctx->flush(pctx, NULL, 0);
 
    /* XXX we don't handle PIPE_TRANSFER_FLUSH_EXPLICIT; this flag can be 
ignored

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to