summaryrefslogtreecommitdiff
path: root/cogl/cogl-gles2-context-private.h
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2012-08-08 14:37:59 +0100
committerRobert Bragg <robert@linux.intel.com>2012-08-15 13:44:22 +0100
commit77edc1f204ebfea1a612e0feb0601c3d9f53858e (patch)
tree66f277606451ac1a9127d7a713fcbe4763381e26 /cogl/cogl-gles2-context-private.h
parentd12399b8239615621d62c80ee13da48b44a7c08a (diff)
downloadcogl-77edc1f204ebfea1a612e0feb0601c3d9f53858e.tar.gz
cogl-gles2-context: Keep track of extra data per texture object
This patch adds a hash table mapping texture object IDs to a struct so that we can keep track of some of the state for each texture object. Currently it will just track the width and height of the texture 2D target. Additionally it will now try to delete any texture objects that have data created for them by the GLES2 context so that it won't leak them. It only tracks objects that get data set on them, not all objects that are bound because it is possible to use the GLES2 context with foreign textures via cogl_gles2_texture_get_handle() and we don't want to delete those. In order to keep track of the currently bound texture object it also needs to track the active texture unit. Note that this state tracking will probably go wrong if GL throws an error for invalid state. For example if glActiveTexture is called with an invalid texture unit then GL will ignore the binding but Cogl will assume it is valid and the state tracking will get out of sync. Perhaps it would be good if Cogl could detect the errors but this is difficult to do without consuming them. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit d8c72bb56cf3598fc57d629edc618f1bfa79f125)
Diffstat (limited to 'cogl/cogl-gles2-context-private.h')
-rw-r--r--cogl/cogl-gles2-context-private.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/cogl/cogl-gles2-context-private.h b/cogl/cogl-gles2-context-private.h
index 1325ad45..f9485481 100644
--- a/cogl/cogl-gles2-context-private.h
+++ b/cogl/cogl-gles2-context-private.h
@@ -105,6 +105,26 @@ typedef struct
CoglGLES2Context *context;
} CoglGLES2ProgramData;
+/* State tracked for each texture unit */
+typedef struct
+{
+ /* The currently bound texture for the GL_TEXTURE_2D */
+ GLuint current_texture_2d;
+} CoglGLES2TextureUnitData;
+
+/* State tracked for each texture object */
+typedef struct
+{
+ /* GL's ID for this object */
+ GLuint object_id;
+
+ GLenum target;
+
+ /* The details for texture when it has a 2D target */
+ int width, height;
+ GLenum format;
+} CoglGLES2TextureObjectData;
+
struct _CoglGLES2Context
{
CoglObject _parent;
@@ -165,6 +185,18 @@ struct _CoglGLES2Context
* results of glReadPixels read from a CoglOffscreen */
int pack_alignment;
+ /* A hash table of CoglGLES2TextureObjects indexed by the texture
+ * object ID so that we can track some state */
+ GHashTable *texture_object_map;
+
+ /* Array of CoglGLES2TextureUnits to keep track of state for each
+ * texture unit */
+ GArray *texture_units;
+
+ /* The currently active texture unit indexed from 0 (not from
+ * GL_TEXTURE0) */
+ int current_texture_unit;
+
void *winsys;
};