<div dir="ltr"><div>Can you please call it invalidate_subresource and inline relevant pipe_surface variables inside the parameters?</div><div><br></div><div>Thanks,</div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 12, 2018 at 10:48 AM Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">A new API to implement glInvalidateFramebuffer() and friends.  It is<br>
similar to invalidate_resource() but can be used to invalidate a<br>
specific layer/level, so it is suitable to use for user FBOs in addition<br>
to window system framebuffer.<br>
<br>
Signed-off-by: Rob Clark <<a href="mailto:robdclark@gmail.com" target="_blank">robdclark@gmail.com</a>><br>
---<br>
 src/gallium/docs/source/context.rst  | 18 ++++++++++++++++++<br>
 src/gallium/include/pipe/p_context.h | 18 ++++++++++++++++++<br>
 2 files changed, 36 insertions(+)<br>
<br>
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst<br>
index 20d0df79312..9f3cd49ee31 100644<br>
--- a/src/gallium/docs/source/context.rst<br>
+++ b/src/gallium/docs/source/context.rst<br>
@@ -740,7 +740,25 @@ of the buffer is not a multiple of the page size, changing the commit state of<br>
 the last (partial) page requires a box that ends at the end of the buffer<br>
 (i.e., box->x + box->width == buffer->width0).<br>
<br>
+.. _invalidate_surface:<br>
<br>
+invalidate_surface<br>
+%%%%%%%%%%%%%%%%%%<br>
+<br>
+This optional function marks a surface, or a portion of a surface, as invalid,<br>
+for example to implement glInvalidateFramebuffer() (and friends).  It is<br>
+useful in particular for tiler GPUs, as a way to avoid unnecessary transfers<br>
+between system memory and tile buffer.<br>
+<br>
+For example, invalidating a surface after rendering, but before flush, can<br>
+be used to avoid tile to system memory transfer (for example, if zs can be<br>
+discarded).  And an invalidate after flush before rendering can be used to<br>
+avoid a system memory to tile buffer transfer.<br>
+<br>
+Invalidating a partial surface can also be used to avoid unnecessary transfer<br>
+from system memory to tile buffer in the case of a scissored clear (which is<br>
+implemented via ->draw_vbo() by the state tracker) by invalidating the<br>
+scissored region.<br>
<br>
 .. _pipe_transfer:<br>
<br>
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h<br>
index e07b76d4f03..4dfc87faff6 100644<br>
--- a/src/gallium/include/pipe/p_context.h<br>
+++ b/src/gallium/include/pipe/p_context.h<br>
@@ -803,6 +803,24 @@ struct pipe_context {<br>
    void (*invalidate_resource)(struct pipe_context *ctx,<br>
                                struct pipe_resource *resource);<br>
<br>
+   /**<br>
+    * Like ->invalidate_resource, but can invalidate a specific layer and level<br>
+    * of a resource, and optionally a specific sub-region of the resource (if<br>
+    * region is not NULL).<br>
+    *<br>
+    * If the backing surf->texture has just a single layer and level (like<br>
+    * window system buffers), and region is NULL, it is equivalent to<br>
+    * ->invalidate_resource().<br>
+    *<br>
+    * \param ctx    pipe context<br>
+    * \param surf   surface to invalidate<br>
+    * \param region NULL to invalidate whole surface, otherwise specifies which<br>
+    *               portion of the surface is invalidated<br>
+    */<br>
+   void (*invalidate_surface)(struct pipe_context *ctx,<br>
+                              struct pipe_surface *surf,<br>
+                              const struct pipe_box *region);<br>
+<br>
    /**<br>
     * Return information about unexpected device resets.<br>
     */<br>
-- <br>
2.19.2<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>