[gtk+/wip/baedert/gl: 5/11] gl driver: Remove vao API
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/gl: 5/11] gl driver: Remove vao API
- Date: Fri, 29 Dec 2017 04:59:44 +0000 (UTC)
commit 352590cf9f2cc6d9d096652905c56f2704037e35
Author: Timm Bäder <mail baedert org>
Date: Thu Dec 28 21:12:03 2017 +0100
gl driver: Remove vao API
Unused.
gsk/gl/gskgldriver.c | 243 +------------------------------------------
gsk/gl/gskgldriverprivate.h | 15 ---
2 files changed, 2 insertions(+), 256 deletions(-)
---
diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c
index 999b3af..91e48e0 100644
--- a/gsk/gl/gskgldriver.c
+++ b/gsk/gl/gskgldriver.c
@@ -22,17 +22,6 @@ typedef struct {
} Texture;
typedef struct {
- GLuint vao_id;
- GLuint buffer_id;
- GLuint position_id;
- GLuint uv_id;
- GskQuadVertex *quads;
- int n_quads;
- guint in_use : 1;
- guint permanent : 1;
-} Vao;
-
-typedef struct {
GLuint fbo_id;
GLuint depth_stencil_id;
} Fbo;
@@ -52,11 +41,9 @@ struct _GskGLDriver
Fbo default_fbo;
GHashTable *textures;
- GHashTable *vaos;
const Texture *bound_source_texture;
const Texture *bound_mask_texture;
- const Vao *bound_vao;
const Fbo *bound_fbo;
int max_texture_size;
@@ -105,23 +92,6 @@ fbo_clear (gpointer data)
glDeleteFramebuffers (1, &f->fbo_id);
}
-static Vao *
-vao_new (void)
-{
- return g_slice_new0 (Vao);
-}
-
-static void
-vao_free (gpointer data)
-{
- Vao *v = data;
-
- g_free (v->quads);
- glDeleteBuffers (1, &v->buffer_id);
- glDeleteVertexArrays (1, &v->vao_id);
- g_slice_free (Vao, v);
-}
-
static void
gsk_gl_driver_finalize (GObject *gobject)
{
@@ -130,7 +100,6 @@ gsk_gl_driver_finalize (GObject *gobject)
gdk_gl_context_make_current (self->gl_context);
g_clear_pointer (&self->textures, g_hash_table_unref);
- g_clear_pointer (&self->vaos, g_hash_table_unref);
g_clear_object (&self->profiler);
if (self->gl_context == gdk_gl_context_get_current ())
@@ -200,7 +169,6 @@ static void
gsk_gl_driver_init (GskGLDriver *self)
{
self->textures = g_hash_table_new_full (NULL, NULL, NULL, texture_free);
- self->vaos = g_hash_table_new_full (NULL, NULL, NULL, vao_free);
self->max_texture_size = -1;
@@ -270,7 +238,6 @@ gsk_gl_driver_end_frame (GskGLDriver *self)
self->bound_source_texture = NULL;
self->bound_mask_texture = NULL;
- self->bound_vao = NULL;
self->bound_fbo = NULL;
self->default_fbo.fbo_id = 0;
@@ -283,9 +250,8 @@ gsk_gl_driver_end_frame (GskGLDriver *self)
gsk_profiler_counter_get (self->profiler, self->counters.reused_textures),
gsk_profiler_counter_get (self->profiler, self->counters.surface_uploads)));
GSK_NOTE (OPENGL,
- g_print ("*** Frame end: textures=%d, vaos=%d\n",
- g_hash_table_size (self->textures),
- g_hash_table_size (self->vaos)));
+ g_print ("*** Frame end: textures=%d\n",
+ g_hash_table_size (self->textures)));
self->in_frame = FALSE;
}
@@ -324,32 +290,6 @@ gsk_gl_driver_collect_textures (GskGLDriver *driver)
}
int
-gsk_gl_driver_collect_vaos (GskGLDriver *driver)
-{
- GHashTableIter iter;
- gpointer value_p = NULL;
- int old_size;
-
- g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), 0);
- g_return_val_if_fail (!driver->in_frame, 0);
-
- old_size = g_hash_table_size (driver->vaos);
-
- g_hash_table_iter_init (&iter, driver->vaos);
- while (g_hash_table_iter_next (&iter, NULL, &value_p))
- {
- Vao *v = value_p;
-
- if (v->in_use)
- v->in_use = FALSE;
- else
- g_hash_table_iter_remove (&iter);
- }
-
- return old_size - g_hash_table_size (driver->vaos);
-}
-
-int
gsk_gl_driver_get_max_texture_size (GskGLDriver *driver)
{
if (driver->max_texture_size < 0)
@@ -375,18 +315,6 @@ gsk_gl_driver_get_texture (GskGLDriver *driver,
return NULL;
}
-static Vao *
-gsk_gl_driver_get_vao (GskGLDriver *driver,
- int vao_id)
-{
- Vao *v;
-
- if (g_hash_table_lookup_extended (driver->vaos, GINT_TO_POINTER (vao_id), NULL, (gpointer *) &v))
- return v;
-
- return NULL;
-}
-
static Fbo *
gsk_gl_driver_get_fbo (GskGLDriver *driver,
int texture_id)
@@ -542,133 +470,6 @@ gsk_gl_driver_create_texture (GskGLDriver *driver,
return t->texture_id;
}
-static Vao *
-find_vao (GHashTable *vaos,
- int position_id,
- int uv_id,
- int n_quads,
- GskQuadVertex *quads)
-{
- GHashTableIter iter;
- gpointer value_p = NULL;
-
- g_hash_table_iter_init (&iter, vaos);
- while (g_hash_table_iter_next (&iter, NULL, &value_p))
- {
- Vao *v = value_p;
-
- if (v->position_id != position_id || v->uv_id != uv_id)
- continue;
-
- if (v->n_quads != n_quads)
- continue;
-
- if (memcmp (v->quads, quads, sizeof (GskQuadVertex) * n_quads) == 0)
- return v;
- }
-
- return NULL;
-}
-
-void
-gsk_gl_driver_create_permanent_vao_for_quad (GskGLDriver *driver,
- int n_vertices,
- const GskQuadVertex *quads,
- int *out_vao_id,
- int *out_vao_buffer_id)
-{
- GLuint vao_id, buffer_id;
-
- glGenVertexArrays (1, &vao_id);
- glBindVertexArray (vao_id);
-
- glGenBuffers (1, &buffer_id);
- glBindBuffer (GL_ARRAY_BUFFER, buffer_id);
- glBufferData (GL_ARRAY_BUFFER, sizeof (GskQuadVertex) * n_vertices, quads, GL_STATIC_DRAW);
-
- glBindBuffer (GL_ARRAY_BUFFER, 0);
- glBindVertexArray (0);
-
- *out_vao_id = buffer_id;
- *out_vao_buffer_id = vao_id;
-}
-
-int
-gsk_gl_driver_create_vao_for_quad (GskGLDriver *driver,
- int position_id,
- int uv_id,
- int n_vertices,
- GskQuadVertex *quads)
-
-{
- GLuint vao_id, buffer_id;
- Vao *v;
-
- g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), -1);
- g_return_val_if_fail (driver->in_frame, -1);
-
- v = find_vao (driver->vaos, position_id, uv_id, n_vertices, quads);
- if (v != NULL && !v->in_use)
- {
- GSK_NOTE (OPENGL, g_print ("Reusing VAO(%d)\n", v->vao_id));
- v->in_use = TRUE;
- return v->vao_id;
- }
-
- glGenVertexArrays (1, &vao_id);
- glBindVertexArray (vao_id);
-
- glGenBuffers (1, &buffer_id);
- glBindBuffer (GL_ARRAY_BUFFER, buffer_id);
- glBufferData (GL_ARRAY_BUFFER, sizeof (GskQuadVertex) * n_vertices, quads, GL_STATIC_DRAW);
-
- if (position_id != -1)
- {
- glEnableVertexAttribArray (position_id);
- glVertexAttribPointer (position_id, 2, GL_FLOAT, GL_FALSE,
- sizeof (GskQuadVertex),
- (void *) G_STRUCT_OFFSET (GskQuadVertex, position));
- }
-
- if (uv_id != -1)
- {
- glEnableVertexAttribArray (uv_id);
- glVertexAttribPointer (uv_id, 2, GL_FLOAT, GL_FALSE,
- sizeof (GskQuadVertex),
- (void *) G_STRUCT_OFFSET (GskQuadVertex, uv));
- }
-
- glBindBuffer (GL_ARRAY_BUFFER, 0);
- glBindVertexArray (0);
-
- v = vao_new ();
- v->vao_id = vao_id;
- v->buffer_id = buffer_id;
- v->position_id = position_id;
- v->uv_id = uv_id;
- v->n_quads = n_vertices;
- v->quads = g_memdup (quads, sizeof (GskQuadVertex) * n_vertices);
- v->in_use = TRUE;
- g_hash_table_insert (driver->vaos, GINT_TO_POINTER (vao_id), v);
-
-#ifdef G_ENABLE_DEBUG
- if (GSK_DEBUG_CHECK (OPENGL))
- {
- int i;
- g_print ("New VAO(%d) for quad[%d] : {\n", v->vao_id, n_vertices);
- for (i = 0; i < n_vertices; i++)
- {
- g_print (" { x:%.2f, y:%.2f } { u:%.2f, v:%.2f }\n",
- quads[i].position[0], quads[i].position[1],
- quads[i].uv[0], quads[i].uv[1]);
- }
- g_print ("}\n");
- }
-#endif
-
- return vao_id;
-}
-
int
gsk_gl_driver_create_render_target (GskGLDriver *driver,
int texture_id,
@@ -782,37 +583,6 @@ gsk_gl_driver_bind_mask_texture (GskGLDriver *driver,
}
}
-void
-gsk_gl_driver_bind_vao (GskGLDriver *driver,
- int vao_id)
-{
- Vao *v;
-
- g_return_if_fail (GSK_IS_GL_DRIVER (driver));
- g_return_if_fail (driver->in_frame);
-
- v = gsk_gl_driver_get_vao (driver, vao_id);
- if (v == NULL)
- {
- g_critical ("No VAO %d found.", vao_id);
- return;
- }
-
- if (driver->bound_vao != v)
- {
- glBindVertexArray (v->vao_id);
- glBindBuffer (GL_ARRAY_BUFFER, v->buffer_id);
-
- if (v->position_id != -1)
- glEnableVertexAttribArray (v->position_id);
-
- if (v->uv_id != -1)
- glEnableVertexAttribArray (v->uv_id);
-
- driver->bound_vao = v;
- }
-}
-
gboolean
gsk_gl_driver_bind_render_target (GskGLDriver *driver,
int texture_id)
@@ -864,15 +634,6 @@ gsk_gl_driver_destroy_texture (GskGLDriver *driver,
g_hash_table_remove (driver->textures, GINT_TO_POINTER (texture_id));
}
-void
-gsk_gl_driver_destroy_vao (GskGLDriver *driver,
- int vao_id)
-{
- g_return_if_fail (GSK_IS_GL_DRIVER (driver));
-
- g_hash_table_remove (driver->vaos, GINT_TO_POINTER (vao_id));
-}
-
static void
gsk_gl_driver_set_texture_parameters (GskGLDriver *driver,
int min_filter,
diff --git a/gsk/gl/gskgldriverprivate.h b/gsk/gl/gskgldriverprivate.h
index f5f9986..35cf1ce 100644
--- a/gsk/gl/gskgldriverprivate.h
+++ b/gsk/gl/gskgldriverprivate.h
@@ -33,16 +33,6 @@ int gsk_gl_driver_create_permanent_texture (GskGLDriver *driver
int gsk_gl_driver_create_texture (GskGLDriver *driver,
float width,
float height);
-int gsk_gl_driver_create_vao_for_quad (GskGLDriver *driver,
- int position_id,
- int uv_id,
- int n_vertices,
- GskQuadVertex *vertices);
-void gsk_gl_driver_create_permanent_vao_for_quad (GskGLDriver *driver,
- int n_vertices,
- const GskQuadVertex *quads,
- int *out_vao_id,
- int *out_vao_buffer_id);
int gsk_gl_driver_create_render_target (GskGLDriver *driver,
int texture_id,
gboolean add_depth_buffer,
@@ -52,8 +42,6 @@ void gsk_gl_driver_bind_source_texture (GskGLDriver *driver
int texture_id);
void gsk_gl_driver_bind_mask_texture (GskGLDriver *driver,
int texture_id);
-void gsk_gl_driver_bind_vao (GskGLDriver *driver,
- int vao_id);
gboolean gsk_gl_driver_bind_render_target (GskGLDriver *driver,
int texture_id);
@@ -67,11 +55,8 @@ void gsk_gl_driver_init_texture_with_surface (GskGLDriver *driver
void gsk_gl_driver_destroy_texture (GskGLDriver *driver,
int texture_id);
-void gsk_gl_driver_destroy_vao (GskGLDriver *driver,
- int vao_id);
int gsk_gl_driver_collect_textures (GskGLDriver *driver);
-int gsk_gl_driver_collect_vaos (GskGLDriver *driver);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]