summaryrefslogtreecommitdiff
path: root/cogl
diff options
context:
space:
mode:
authorJonas Ã…dahl <jadahl@gmail.com>2020-10-20 10:04:04 +0200
committerRobert Mader <robert.mader@posteo.de>2021-01-30 09:11:46 +0000
commit392ffaeeb48ef35a7e6fcb02caf5af803399a5ee (patch)
tree5cb320d7d08b6d0c82643c0d283a9280e96b888f /cogl
parentb7c6865225afbd8c30861e2f840df44d24a6983e (diff)
downloadmutter-392ffaeeb48ef35a7e6fcb02caf5af803399a5ee.tar.gz
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>
Diffstat (limited to 'cogl')
-rw-r--r--cogl/cogl/cogl-driver.h4
-rw-r--r--cogl/cogl/cogl-framebuffer-driver.c7
-rw-r--r--cogl/cogl/cogl-framebuffer-driver.h7
-rw-r--r--cogl/cogl/cogl-framebuffer.c3
-rw-r--r--cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h4
-rw-r--r--cogl/cogl/driver/gl/cogl-framebuffer-gl.c38
-rw-r--r--cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c28
-rw-r--r--cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.c28
-rw-r--r--cogl/cogl/driver/gl/gl/cogl-driver-gl.c1
-rw-r--r--cogl/cogl/driver/gl/gles/cogl-driver-gles.c1
-rw-r--r--cogl/cogl/driver/nop/cogl-driver-nop.c1
-rw-r--r--cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h4
-rw-r--r--cogl/cogl/driver/nop/cogl-framebuffer-nop.c6
-rw-r--r--cogl/cogl/driver/nop/cogl-nop-framebuffer.c7
14 files changed, 78 insertions, 61 deletions
diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h
index 6d79e3a75..aa30f3d34 100644
--- a/cogl/cogl/cogl-driver.h
+++ b/cogl/cogl/cogl-driver.h
@@ -86,10 +86,6 @@ struct _CoglDriverVtable
CoglFramebufferState state);
void
- (* framebuffer_discard_buffers) (CoglFramebuffer *framebuffer,
- unsigned long buffers);
-
- void
(* framebuffer_draw_attributes) (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
CoglVerticesMode mode,
diff --git a/cogl/cogl/cogl-framebuffer-driver.c b/cogl/cogl/cogl-framebuffer-driver.c
index 4e9c92707..1e71f0c03 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 416db1098..3c88c489d 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 9e0739d36..6c5ffa516 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 9e2205cdf..d6e2fd417 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
@@ -52,10 +52,6 @@ struct _CoglGlFramebufferClass
};
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 d2040a5ab..b0d48fc16 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -329,44 +329,6 @@ cogl_gl_framebuffer_flush (CoglFramebufferDriver *driver)
}
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,
CoglVerticesMode mode,
diff --git a/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c b/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c
index 9b698f39c..4788bb9be 100644
--- a/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c
+++ b/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.c
@@ -156,6 +156,33 @@ cogl_gl_framebuffer_back_query_bits (CoglFramebufferDriver *driver,
}
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 368e04b6f..0a9bbd680 100644
--- a/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.c
+++ b/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.c
@@ -174,6 +174,33 @@ cogl_gl_framebuffer_fbo_query_bits (CoglFramebufferDriver *driver,
}
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 d4e56c4c9..ef44dceda 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 7a031ae41..c573884fb 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 96afa3bd0..55961e3a9 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 7efe883de..404985dd1 100644
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
+++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
@@ -38,10 +38,6 @@
#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,
CoglVerticesMode mode,
diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
index 757ce268c..54811afbc 100644
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
+++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
@@ -36,12 +36,6 @@
#include <string.h>
void
-_cogl_framebuffer_nop_discard_buffers (CoglFramebuffer *framebuffer,
- unsigned long buffers)
-{
-}
-
-void
_cogl_framebuffer_nop_draw_attributes (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
CoglVerticesMode mode,
diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
index 39df6833a..cea5ab906 100644
--- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
+++ b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
@@ -65,6 +65,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;
}