<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Reviewed-by: Tim Rowley <<a href="mailto:timothy.o.rowley@intel.com" class="">timothy.o.rowley@intel.com</a>>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Jun 20, 2017, at 11:42 AM, George Kyriazis <<a href="mailto:george.kyriazis@intel.com" class="">george.kyriazis@intel.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Consider the following RT attachment order:<br class="">
1. Attach surfaces attachments 0 & 1, and render with them<br class="">
2. Detach 0 & 1<br class="">
3. Re-attach 0 & 1 to different surfaces<br class="">
4. Render with the new attachment<br class="">
<br class="">
The definition of a tile being resolved is that local changes have been<br class="">
flushed out to the surface, hence there is no need to reload the tile before<br class="">
it's written to.  For an invalid tile, the tile has to be reloaded from<br class="">
the surface before rendering.<br class="">
<br class="">
Stage (2) was marking hot tiles for attachements 0 & 1 as RESOLVED,<br class="">
which means that the hot tiles can be written out to memory with no<br class="">
need to read them back in (they are "clean").  They need to be marked as<br class="">
resolved here, because a surface may be destroyed after a detach, and we<br class="">
don't want to have un-resolved tiles that may force a readback from a<br class="">
NULL (destroyed) surface.  (Part of a destroy is detach all attachments first)<br class="">
<br class="">
Stage (3), during the no att -> att transition, we  need to realize that the<br class="">
"new" surface tiles need to be fetched fresh from the new surface, instead<br class="">
of using the resolved tiles, that belong to a stale attachment.<br class="">
<br class="">
This is done by marking the hot tiles as invalid in stage (3), when we realize<br class="">
that a new attachment is being made, so that they are re-fetched during<br class="">
rendering in stage (4).<br class="">
<br class="">
Also note that hot tiles are indexed by attachment.<br class="">
<br class="">
- Fixes VTK dual depth-peeling tests.<br class="">
- No piglit changes<br class="">
---<br class="">
src/gallium/drivers/swr/swr_draw.cpp   | 19 +++++++++++++++++++<br class="">
src/gallium/drivers/swr/swr_resource.h |  4 ++++<br class="">
src/gallium/drivers/swr/swr_state.cpp  |  5 +++++<br class="">
3 files changed, 28 insertions(+)<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp<br class="">
index 03c82a7..ac300e2 100644<br class="">
--- a/src/gallium/drivers/swr/swr_draw.cpp<br class="">
+++ b/src/gallium/drivers/swr/swr_draw.cpp<br class="">
@@ -215,6 +215,25 @@ swr_finish(struct pipe_context *pipe)<br class="">
   swr_fence_reference(pipe->screen, &fence, NULL);<br class="">
}<br class="">
<br class="">
+/*<br class="">
+ * Invalidate tiles so they can be reloaded back when needed<br class="">
+ */<br class="">
+void<br class="">
+swr_invalidate_render_target(struct pipe_context *pipe,<br class="">
+                             uint32_t attachment,<br class="">
+                             uint16_t width, uint16_t height)<br class="">
+{<br class="">
+   struct swr_context *ctx = swr_context(pipe);<br class="">
+<br class="">
+   /* grab the rect from the passed in arguments */<br class="">
+   swr_update_draw_context(ctx);<br class="">
+   SWR_RECT full_rect =<br class="">
+      {0, 0, (int32_t)width, (int32_t)height};<br class="">
+   SwrInvalidateTiles(ctx->swrContext,<br class="">
+                      1 << attachment,<br class="">
+                      full_rect);<br class="">
+}<br class="">
+<br class="">
<br class="">
/*<br class="">
 * Store SWR HotTiles back to renderTarget surface.<br class="">
diff --git a/src/gallium/drivers/swr/swr_resource.h b/src/gallium/drivers/swr/swr_resource.h<br class="">
index ae9954c..4effd46 100644<br class="">
--- a/src/gallium/drivers/swr/swr_resource.h<br class="">
+++ b/src/gallium/drivers/swr/swr_resource.h<br class="">
@@ -96,6 +96,10 @@ swr_resource_data(struct pipe_resource *resource)<br class="">
}<br class="">
<br class="">
<br class="">
+void swr_invalidate_render_target(struct pipe_context *pipe,<br class="">
+                                  uint32_t attachment,<br class="">
+                                  uint16_t width, uint16_t height);<br class="">
+<br class="">
void swr_store_render_target(struct pipe_context *pipe,<br class="">
                             uint32_t attachment,<br class="">
                             enum SWR_TILE_STATE post_tile_state);<br class="">
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp<br class="">
index 08549e5..deae4e6 100644<br class="">
--- a/src/gallium/drivers/swr/swr_state.cpp<br class="">
+++ b/src/gallium/drivers/swr/swr_state.cpp<br class="">
@@ -933,6 +933,11 @@ swr_change_rt(struct swr_context *ctx,<br class="">
       * INVALID so they are reloaded from surface. */<br class="">
      swr_store_render_target(&ctx->pipe, attachment, SWR_TILE_INVALID);<br class="">
      need_fence = true;<br class="">
+   } else {<br class="">
+      /* if no previous attachment, invalidate tiles that may be marked<br class="">
+       * RESOLVED because of an old attachment */<br class="">
+      swr_invalidate_render_target(&ctx->pipe, attachment, sf->width, sf->height);<br class="">
+      /* no need to set fence here */<br class="">
   }<br class="">
<br class="">
   /* Make new attachment */<br class="">
-- <br class="">
2.7.4<br class="">
<br class="">
_______________________________________________<br class="">
mesa-dev mailing list<br class="">
<a href="mailto:mesa-dev@lists.freedesktop.org" class="">mesa-dev@lists.freedesktop.org</a><br class="">
https://lists.freedesktop.org/mailman/listinfo/mesa-dev<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>