<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue., Jul. 2, 2019, 09:50 Boris Brezillon, <<a href="mailto:boris.brezillon@collabora.com">boris.brezillon@collabora.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Daniel Stone <<a href="mailto:daniels@collabora.com" target="_blank" rel="noreferrer">daniels@collabora.com</a>><br>
<br>
Add a pipe_screen->set_damage_region() hook to propagate<br>
set-damage-region requests to the driver, it's then up to the driver to<br>
decide what to do with this piece of information.<br>
<br>
If the hook is left unassigned, the buffer-damage extension is<br>
considered unsupported.<br>
<br>
Signed-off-by: Daniel Stone <<a href="mailto:daniels@collabora.com" target="_blank" rel="noreferrer">daniels@collabora.com</a>><br>
Signed-off-by: Boris Brezillon <<a href="mailto:boris.brezillon@collabora.com" target="_blank" rel="noreferrer">boris.brezillon@collabora.com</a>><br>
Reviewed-by: Alyssa Rosenzweig <<a href="mailto:alyssa.rosenzweig@collabora.com" target="_blank" rel="noreferrer">alyssa.rosenzweig@collabora.com</a>><br>
---<br>
Changes in v5:<br>
* Add Alyssa's R-b<br>
---<br>
 src/gallium/include/pipe/p_screen.h   |  7 +++++++<br>
 src/gallium/state_trackers/dri/dri2.c | 22 ++++++++++++++++++++++<br>
 2 files changed, 29 insertions(+)<br>
<br>
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h<br>
index 3f9bad470950..8df12ee4f865 100644<br>
--- a/src/gallium/include/pipe/p_screen.h<br>
+++ b/src/gallium/include/pipe/p_screen.h<br>
@@ -464,6 +464,13 @@ struct pipe_screen {<br>
    bool (*is_parallel_shader_compilation_finished)(struct pipe_screen *screen,<br>
                                                    void *shader,<br>
                                                    unsigned shader_type);<br>
+<br>
+   /**<br>
+    * Set damage region.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Can you expand the comment to describe rects? The format of rects is not obvious.</div><div dir="auto"><br></div><div dir="auto">Marek</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    */<br>
+   void (*set_damage_region)(struct pipe_screen *screen,<br>
+                             struct pipe_resource *resource,<br>
+                             unsigned int nrects, int *rects);<br>
 };<br>
<br>
<br>
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c<br>
index 5a7ec878bab0..1a86cd244d21 100644<br>
--- a/src/gallium/state_trackers/dri/dri2.c<br>
+++ b/src/gallium/state_trackers/dri/dri2.c<br>
@@ -1807,6 +1807,23 @@ static const __DRI2interopExtension dri2InteropExtension = {<br>
    .export_object = dri2_interop_export_object<br>
 };<br>
<br>
+/**<br>
+ * \brief the DRI2bufferDamageExtension set_damage_region method<br>
+ */<br>
+static void<br>
+dri2_set_damage_region(__DRIdrawable *dPriv, unsigned int nrects, int *rects)<br>
+{<br>
+   struct dri_drawable *drawable = dri_drawable(dPriv);<br>
+   struct pipe_resource *resource = drawable->textures[ST_ATTACHMENT_BACK_LEFT];<br>
+   struct pipe_screen *screen = resource->screen;<br>
+<br>
+   screen->set_damage_region(screen, resource, nrects, rects);<br>
+}<br>
+<br>
+static __DRI2bufferDamageExtension dri2BufferDamageExtension = {<br>
+   .base = { __DRI2_BUFFER_DAMAGE, 1 },<br>
+};<br>
+<br>
 /**<br>
  * \brief the DRI2ConfigQueryExtension configQueryb method<br>
  */<br>
@@ -1908,6 +1925,7 @@ static const __DRIextension *dri_screen_extensions[] = {<br>
    &dri2GalliumConfigQueryExtension.base,<br>
    &dri2ThrottleExtension.base,<br>
    &dri2FenceExtension.base,<br>
+   &dri2BufferDamageExtension.base,<br>
    &dri2InteropExtension.base,<br>
    &dri2NoErrorExtension.base,<br>
    &driBlobExtension.base,<br>
@@ -1923,6 +1941,7 @@ static const __DRIextension *dri_robust_screen_extensions[] = {<br>
    &dri2ThrottleExtension.base,<br>
    &dri2FenceExtension.base,<br>
    &dri2InteropExtension.base,<br>
+   &dri2BufferDamageExtension.base,<br>
    &dri2Robustness.base,<br>
    &dri2NoErrorExtension.base,<br>
    &driBlobExtension.base,<br>
@@ -1983,6 +2002,9 @@ dri2_init_screen(__DRIscreen * sPriv)<br>
       }<br>
    }<br>
<br>
+   if (pscreen->set_damage_region)<br>
+      dri2BufferDamageExtension.set_damage_region = dri2_set_damage_region;<br>
+<br>
    if (pscreen->get_param(pscreen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) {<br>
       sPriv->extensions = dri_robust_screen_extensions;<br>
       screen->has_reset_status_query = true;<br>
-- <br>
2.21.0<br>
<br>
</blockquote></div></div></div>