[Mesa-dev] [PATCH v2 4/6] mesa/st: wire up Discard{Sub}Framebuffer

Rob Clark robdclark at gmail.com
Wed Dec 12 15:48:41 UTC 2018


Signed-off-by: Rob Clark <robdclark at gmail.com>
---
 src/mesa/state_tracker/st_cb_fbo.c | 39 ++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 8901a8680ef..6f46ca03f3c 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -758,6 +758,43 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
    }
 }
 
+static void
+st_discard_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+                       struct gl_renderbuffer_attachment *att)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_surface *psurf;
+
+   if (!att->Renderbuffer)
+      return;
+
+   psurf = st_renderbuffer(att->Renderbuffer)->surface;
+
+   if (st->pipe->invalidate_surface)
+      st->pipe->invalidate_surface(st->pipe, psurf, NULL);
+}
+
+static void
+st_discard_sub_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+                           struct gl_renderbuffer_attachment *att, GLint x,
+                           GLint y, GLsizei width, GLsizei height)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_surface *psurf;
+
+   if (!att->Renderbuffer)
+      return;
+
+   psurf = st_renderbuffer(att->Renderbuffer)->surface;
+
+   if (st->pipe->invalidate_surface) {
+      struct pipe_box region;
+
+      u_box_2d(x, y, width, height, &region);
+
+      st->pipe->invalidate_surface(st->pipe, psurf, &region);
+   }
+}
 
 /**
  * Called via glDrawBuffer.  We only provide this driver function so that we
@@ -936,6 +973,8 @@ st_init_fbo_functions(struct dd_function_table *functions)
    functions->RenderTexture = st_render_texture;
    functions->FinishRenderTexture = st_finish_render_texture;
    functions->ValidateFramebuffer = st_validate_framebuffer;
+   functions->DiscardFramebuffer = st_discard_framebuffer;
+   functions->DiscardSubFramebuffer = st_discard_sub_framebuffer;
 
    functions->DrawBufferAllocate = st_DrawBufferAllocate;
    functions->ReadBuffer = st_ReadBuffer;
-- 
2.19.2



More information about the mesa-dev mailing list