[mutter] cogl/framebuffer: Move discard_buffers() to driver sub types
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cogl/framebuffer: Move discard_buffers() to driver sub types
- Date: Sat, 30 Jan 2021 09:39:50 +0000 (UTC)
commit 392ffaeeb48ef35a7e6fcb02caf5af803399a5ee
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Oct 20 10:04:04 2020 +0200
cogl/framebuffer: Move discard_buffers() to driver sub types
It was implemented slightly different depending on whether it was for a
surface or FBO, so move it to their corresponding GL driver types.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
cogl/cogl/cogl-driver.h | 4 ---
cogl/cogl/cogl-framebuffer-driver.c | 7 ++++
cogl/cogl/cogl-framebuffer-driver.h | 7 ++++
cogl/cogl/cogl-framebuffer.c | 3 +-
cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h | 4 ---
cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 38 ----------------------
cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c | 28 ++++++++++++++++
cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.c | 28 ++++++++++++++++
cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 1 -
cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 1 -
cogl/cogl/driver/nop/cogl-driver-nop.c | 1 -
.../cogl/driver/nop/cogl-framebuffer-nop-private.h | 4 ---
cogl/cogl/driver/nop/cogl-framebuffer-nop.c | 6 ----
cogl/cogl/driver/nop/cogl-nop-framebuffer.c | 7 ++++
14 files changed, 78 insertions(+), 61 deletions(-)
---
diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h
index 6d79e3a752..aa30f3d343 100644
--- a/cogl/cogl/cogl-driver.h
+++ b/cogl/cogl/cogl-driver.h
@@ -85,10 +85,6 @@ struct _CoglDriverVtable
CoglFramebuffer *read_buffer,
CoglFramebufferState state);
- void
- (* framebuffer_discard_buffers) (CoglFramebuffer *framebuffer,
- unsigned long buffers);
-
void
(* framebuffer_draw_attributes) (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
diff --git a/cogl/cogl/cogl-framebuffer-driver.c b/cogl/cogl/cogl-framebuffer-driver.c
index 4e9c92707e..1e71f0c03e 100644
--- a/cogl/cogl/cogl-framebuffer-driver.c
+++ b/cogl/cogl/cogl-framebuffer-driver.c
@@ -93,6 +93,13 @@ cogl_framebuffer_driver_flush (CoglFramebufferDriver *driver)
COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->flush (driver);
}
+void
+cogl_framebuffer_driver_discard_buffers (CoglFramebufferDriver *driver,
+ unsigned long buffers)
+{
+ COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->discard_buffers (driver, buffers);
+}
+
static void
cogl_framebuffer_driver_get_property (GObject *object,
guint prop_id,
diff --git a/cogl/cogl/cogl-framebuffer-driver.h b/cogl/cogl/cogl-framebuffer-driver.h
index 416db10987..3c88c489d5 100644
--- a/cogl/cogl/cogl-framebuffer-driver.h
+++ b/cogl/cogl/cogl-framebuffer-driver.h
@@ -55,6 +55,9 @@ struct _CoglFramebufferDriverClass
void (* finish) (CoglFramebufferDriver *driver);
void (* flush) (CoglFramebufferDriver *driver);
+
+ void (* discard_buffers) (CoglFramebufferDriver *driver,
+ unsigned long buffers);
};
CoglFramebuffer *
@@ -78,4 +81,8 @@ cogl_framebuffer_driver_finish (CoglFramebufferDriver *driver);
void
cogl_framebuffer_driver_flush (CoglFramebufferDriver *driver);
+void
+cogl_framebuffer_driver_discard_buffers (CoglFramebufferDriver *driver,
+ unsigned long buffers);
+
#endif /* COGL_FRAMEBUFFER_DRIVER_H */
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
index 9e0739d36f..6c5ffa516f 100644
--- a/cogl/cogl/cogl-framebuffer.c
+++ b/cogl/cogl/cogl-framebuffer.c
@@ -1695,11 +1695,10 @@ cogl_framebuffer_discard_buffers (CoglFramebuffer *framebuffer,
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
- CoglContext *ctx = priv->context;
g_return_if_fail (buffers & COGL_BUFFER_BIT_COLOR);
- ctx->driver_vtable->framebuffer_discard_buffers (framebuffer, buffers);
+ cogl_framebuffer_driver_discard_buffers (priv->driver, buffers);
}
void
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
index 9e2205cdf2..d6e2fd4171 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
@@ -51,10 +51,6 @@ struct _CoglGlFramebufferClass
GLenum target);
};
-void
-_cogl_framebuffer_gl_discard_buffers (CoglFramebuffer *framebuffer,
- unsigned long buffers);
-
void
cogl_gl_framebuffer_bind (CoglGlFramebuffer *gl_framebuffer,
GLenum target);
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
index d2040a5abc..b0d48fc16c 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -328,44 +328,6 @@ cogl_gl_framebuffer_flush (CoglFramebufferDriver *driver)
GE (ctx, glFlush ());
}
-void
-_cogl_framebuffer_gl_discard_buffers (CoglFramebuffer *framebuffer,
- unsigned long buffers)
-{
- CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
-
- if (ctx->glDiscardFramebuffer)
- {
- GLenum attachments[3];
- int i = 0;
-
- if (COGL_IS_ONSCREEN (framebuffer))
- {
- if (buffers & COGL_BUFFER_BIT_COLOR)
- attachments[i++] = GL_COLOR;
- if (buffers & COGL_BUFFER_BIT_DEPTH)
- attachments[i++] = GL_DEPTH;
- if (buffers & COGL_BUFFER_BIT_STENCIL)
- attachments[i++] = GL_STENCIL;
- }
- else
- {
- if (buffers & COGL_BUFFER_BIT_COLOR)
- attachments[i++] = GL_COLOR_ATTACHMENT0;
- if (buffers & COGL_BUFFER_BIT_DEPTH)
- attachments[i++] = GL_DEPTH_ATTACHMENT;
- if (buffers & COGL_BUFFER_BIT_STENCIL)
- attachments[i++] = GL_STENCIL_ATTACHMENT;
- }
-
- cogl_context_flush_framebuffer_state (ctx,
- framebuffer,
- framebuffer,
- COGL_FRAMEBUFFER_STATE_BIND);
- GE (ctx, glDiscardFramebuffer (GL_FRAMEBUFFER, i, attachments));
- }
-}
-
void
_cogl_framebuffer_gl_draw_attributes (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
diff --git a/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c b/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c
index 9b698f39c2..4788bb9be8 100644
--- a/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c
+++ b/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c
@@ -155,6 +155,33 @@ cogl_gl_framebuffer_back_query_bits (CoglFramebufferDriver *driver,
*bits = gl_framebuffer_back->bits;
}
+static void
+cogl_gl_framebuffer_back_discard_buffers (CoglFramebufferDriver *driver,
+ unsigned long buffers)
+{
+ CoglFramebuffer *framebuffer =
+ cogl_framebuffer_driver_get_framebuffer (driver);
+ CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
+ GLenum attachments[3];
+ int i = 0;
+
+ if (!ctx->glDiscardFramebuffer)
+ return;
+
+ if (buffers & COGL_BUFFER_BIT_COLOR)
+ attachments[i++] = GL_COLOR;
+ if (buffers & COGL_BUFFER_BIT_DEPTH)
+ attachments[i++] = GL_DEPTH;
+ if (buffers & COGL_BUFFER_BIT_STENCIL)
+ attachments[i++] = GL_STENCIL;
+
+ cogl_context_flush_framebuffer_state (ctx,
+ framebuffer,
+ framebuffer,
+ COGL_FRAMEBUFFER_STATE_BIND);
+ GE (ctx, glDiscardFramebuffer (GL_FRAMEBUFFER, i, attachments));
+}
+
static void
cogl_gl_framebuffer_back_bind (CoglGlFramebuffer *gl_framebuffer,
GLenum target)
@@ -232,6 +259,7 @@ cogl_gl_framebuffer_back_class_init (CoglGlFramebufferBackClass *klass)
COGL_GL_FRAMEBUFFER_CLASS (klass);
driver_class->query_bits = cogl_gl_framebuffer_back_query_bits;
+ driver_class->discard_buffers = cogl_gl_framebuffer_back_discard_buffers;
gl_framebuffer_class->bind = cogl_gl_framebuffer_back_bind;
}
diff --git a/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.c b/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.c
index 368e04b6fb..0a9bbd680b 100644
--- a/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.c
+++ b/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.c
@@ -173,6 +173,33 @@ cogl_gl_framebuffer_fbo_query_bits (CoglFramebufferDriver *driver,
*bits = gl_framebuffer_fbo->bits;
}
+static void
+cogl_gl_framebuffer_fbo_discard_buffers (CoglFramebufferDriver *driver,
+ unsigned long buffers)
+{
+ CoglFramebuffer *framebuffer =
+ cogl_framebuffer_driver_get_framebuffer (driver);
+ CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
+ GLenum attachments[3];
+ int i = 0;
+
+ if (!ctx->glDiscardFramebuffer)
+ return;
+
+ if (buffers & COGL_BUFFER_BIT_COLOR)
+ attachments[i++] = GL_COLOR_ATTACHMENT0;
+ if (buffers & COGL_BUFFER_BIT_DEPTH)
+ attachments[i++] = GL_DEPTH_ATTACHMENT;
+ if (buffers & COGL_BUFFER_BIT_STENCIL)
+ attachments[i++] = GL_STENCIL_ATTACHMENT;
+
+ cogl_context_flush_framebuffer_state (ctx,
+ framebuffer,
+ framebuffer,
+ COGL_FRAMEBUFFER_STATE_BIND);
+ GE (ctx, glDiscardFramebuffer (GL_FRAMEBUFFER, i, attachments));
+}
+
static void
cogl_gl_framebuffer_fbo_bind (CoglGlFramebuffer *gl_framebuffer,
GLenum target)
@@ -606,6 +633,7 @@ cogl_gl_framebuffer_fbo_class_init (CoglGlFramebufferFboClass *klass)
object_class->dispose = cogl_gl_framebuffer_fbo_dispose;
driver_class->query_bits = cogl_gl_framebuffer_fbo_query_bits;
+ driver_class->discard_buffers = cogl_gl_framebuffer_fbo_discard_buffers;
gl_framebuffer_class->bind = cogl_gl_framebuffer_fbo_bind;
}
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index d4e56c4c97..ef44dceda8 100644
--- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -571,7 +571,6 @@ _cogl_driver_gl =
_cogl_driver_update_features,
_cogl_driver_gl_create_framebuffer_driver,
_cogl_driver_gl_flush_framebuffer_state,
- _cogl_framebuffer_gl_discard_buffers,
_cogl_framebuffer_gl_draw_attributes,
_cogl_framebuffer_gl_draw_indexed_attributes,
_cogl_framebuffer_gl_read_pixels_into_bitmap,
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index 7a031ae419..c573884fb3 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -459,7 +459,6 @@ _cogl_driver_gles =
_cogl_driver_update_features,
_cogl_driver_gl_create_framebuffer_driver,
_cogl_driver_gl_flush_framebuffer_state,
- _cogl_framebuffer_gl_discard_buffers,
_cogl_framebuffer_gl_draw_attributes,
_cogl_framebuffer_gl_draw_indexed_attributes,
_cogl_framebuffer_gl_read_pixels_into_bitmap,
diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c
index 96afa3bd0d..55961e3a96 100644
--- a/cogl/cogl/driver/nop/cogl-driver-nop.c
+++ b/cogl/cogl/driver/nop/cogl-driver-nop.c
@@ -99,7 +99,6 @@ _cogl_driver_nop =
_cogl_driver_update_features,
_cogl_driver_nop_create_framebuffer_driver,
_cogl_driver_nop_flush_framebuffer_state,
- _cogl_framebuffer_nop_discard_buffers,
_cogl_framebuffer_nop_draw_attributes,
_cogl_framebuffer_nop_draw_indexed_attributes,
_cogl_framebuffer_nop_read_pixels_into_bitmap,
diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
index 7efe883de5..404985dd1d 100644
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
+++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
@@ -37,10 +37,6 @@
#include "cogl-types.h"
#include "cogl-context-private.h"
-void
-_cogl_framebuffer_nop_discard_buffers (CoglFramebuffer *framebuffer,
- unsigned long buffers);
-
void
_cogl_framebuffer_nop_draw_attributes (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
index 757ce268cb..54811afbcf 100644
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
+++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
@@ -35,12 +35,6 @@
#include <glib.h>
#include <string.h>
-void
-_cogl_framebuffer_nop_discard_buffers (CoglFramebuffer *framebuffer,
- unsigned long buffers)
-{
-}
-
void
_cogl_framebuffer_nop_draw_attributes (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
index 39df6833a2..cea5ab9061 100644
--- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
+++ b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
@@ -64,6 +64,12 @@ cogl_nop_framebuffer_flush (CoglFramebufferDriver *driver)
{
}
+static void
+cogl_nop_framebuffer_discard_buffers (CoglFramebufferDriver *driver,
+ unsigned long buffers)
+{
+}
+
static void
cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer)
{
@@ -79,4 +85,5 @@ cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass)
driver_class->clear = cogl_nop_framebuffer_clear;
driver_class->finish = cogl_nop_framebuffer_finish;
driver_class->flush = cogl_nop_framebuffer_flush;
+ driver_class->discard_buffers = cogl_nop_framebuffer_discard_buffers;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]