[Mesa-dev] [PATCH 2/6] mesa: wire up InvalidateSubFramebuffer

Rob Clark robdclark at gmail.com
Tue Dec 11 22:50:04 UTC 2018


Signed-off-by: Rob Clark <robdclark at gmail.com>
---
 src/mesa/main/dd.h       |  3 +++
 src/mesa/main/fbobject.c | 34 +++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 1214eeaa474..c7112677223 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -786,6 +786,9 @@ struct dd_function_table {
                            GLbitfield mask, GLenum filter);
    void (*DiscardFramebuffer)(struct gl_context *ctx, struct gl_framebuffer *fb,
                               struct gl_renderbuffer_attachment *att);
+   void (*DiscardSubFramebuffer)(struct gl_context *ctx, struct gl_framebuffer *fb,
+                                 struct gl_renderbuffer_attachment *att, GLint x,
+                                 GLint y, GLsizei width, GLsizei height);
 
    /**
     * \name Functions for GL_ARB_sample_locations
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f931e8f76b1..8ef5eb747c0 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -4699,12 +4699,41 @@ discard_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
    }
 }
 
+static void
+discard_sub_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+                        GLsizei numAttachments, const GLenum *attachments,
+                        GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   GLint i;
+
+   if (!ctx->Driver.DiscardSubFramebuffer)
+      return;
+
+   for (i = 0; i < numAttachments; i++) {
+      struct gl_renderbuffer_attachment *att =
+            get_fb_attachment(ctx, fb, attachments[i]);
+
+      if (!att)
+         continue;
+
+      ctx->Driver.DiscardSubFramebuffer(ctx, fb, att, x, y, width, height);
+   }
+}
+
 void GLAPIENTRY
 _mesa_InvalidateSubFramebuffer_no_error(GLenum target, GLsizei numAttachments,
                                         const GLenum *attachments, GLint x,
                                         GLint y, GLsizei width, GLsizei height)
 {
-   /* no-op */
+   struct gl_framebuffer *fb;
+   GET_CURRENT_CONTEXT(ctx);
+
+   fb = get_framebuffer_target(ctx, target);
+   if (!fb)
+      return;
+
+   discard_sub_framebuffer(ctx, fb, numAttachments, attachments,
+                           x, y, width, height);
 }
 
 
@@ -4727,6 +4756,9 @@ _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
    invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
                                   x, y, width, height,
                                   "glInvalidateSubFramebuffer");
+
+   discard_sub_framebuffer(ctx, fb, numAttachments, attachments,
+                           x, y, width, height);
 }
 
 
-- 
2.19.2



More information about the mesa-dev mailing list