4
* An object oriented GL/GLES Abstraction/Utility Layer
6
* Copyright (C) 2010 Intel Corporation.
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library. If not, see
20
* <http://www.gnu.org/licenses/>.
25
* Robert Bragg <robert@linux.intel.com>
28
#ifndef __COGL_PIPELINE_OPENGL_PRIVATE_H
29
#define __COGL_PIPELINE_OPENGL_PRIVATE_H
31
#include "cogl-pipeline-private.h"
32
#include "cogl-matrix-stack.h"
35
* cogl-pipeline.c owns the GPU's texture unit state so we have some
36
* private structures for describing the current state of a texture
37
* unit that we track in a per context array (ctx->texture_units) that
38
* grows according to the largest texture unit used so far...
40
* Roughly speaking the members in this structure are of two kinds:
41
* either they are a low level reflection of the state we send to
42
* OpenGL or they are for high level meta data assoicated with the
43
* texture unit when flushing CoglPipelineLayers that is typically
44
* used to optimize subsequent re-flushing of the same layer.
46
* The low level members are at the top, and the high level members
47
* start with the .layer member.
49
typedef struct _CoglTextureUnit
51
/* The base 0 texture unit index which can be used with
52
* glActiveTexture () */
55
/* The GL target currently glEnabled or 0 if nothing is
56
* enabled. This is only used by the fixed pipeline fragend */
57
GLenum enabled_gl_target;
59
/* The raw GL texture object name for which we called glBindTexture when
60
* we flushed the last layer. (NB: The CoglTexture associated
61
* with a layer may represent more than one GL texture) */
63
/* The target of the GL texture object. This is just used so that we
64
* can quickly determine the intended target to flush when
65
* dirty_gl_texture == TRUE */
68
/* Foreign textures are those not created or deleted by Cogl. If we ever
69
* call glBindTexture for a foreign texture then the next time we are
70
* asked to glBindTexture we can't try and optimize a redundant state
71
* change because we don't know if the original texture name was deleted
72
* and now we are being asked to bind a recycled name. */
75
/* We have many components in Cogl that need to temporarily bind arbitrary
76
* textures e.g. to query texture object parameters and since we don't
77
* want that to result in too much redundant reflushing of layer state
78
* when all that's needed is to re-bind the layer's gl_texture we use this
79
* to track when the unit->gl_texture state is out of sync with the GL
80
* texture object really bound too (GL_TEXTURE0+unit->index).
82
* XXX: as a further optimization cogl-pipeline.c uses a convention
83
* of always using texture unit 1 for these transient bindings so we
84
* can assume this is only ever TRUE for unit 1.
86
CoglBool dirty_gl_texture;
88
/* A matrix stack giving us the means to associate a texture
89
* transform matrix with the texture unit. */
90
CoglMatrixStack *matrix_stack;
93
* Higher level layer state associated with the unit...
96
/* The CoglPipelineLayer whos state was flushed to update this
99
* This will be set to NULL if the layer is modified or freed which
100
* means when we come to flush a layer; if this pointer is still
101
* valid and == to the layer being flushed we don't need to update
102
* any texture unit state. */
103
CoglPipelineLayer *layer;
105
/* To help minimize the state changes required we track the
106
* difference flags associated with the layer whos state was last
107
* flushed to update this texture unit.
109
* Note: we track this explicitly because .layer may get invalidated
110
* if that layer is modified or deleted. Even if the layer is
111
* invalidated though these flags can be used to optimize the state
112
* flush of the next layer
114
unsigned long layer_changes_since_flush;
116
/* Whenever a CoglTexture's internal GL texture storage changes
117
* cogl-pipeline.c is notified with a call to
118
* _cogl_pipeline_texture_storage_change_notify which inturn sets
119
* this to TRUE for each texture unit that it is currently bound
120
* too. When we later come to flush some pipeline state then we will
121
* always check this to potentially force an update of the texture
122
* state even if the pipeline hasn't changed. */
123
CoglBool texture_storage_changed;
128
_cogl_get_texture_unit (int index_);
131
_cogl_destroy_texture_units (void);
134
_cogl_set_active_texture_unit (int unit_index);
137
_cogl_bind_gl_texture_transient (GLenum gl_target,
139
CoglBool is_foreign);
142
_cogl_delete_gl_texture (GLuint gl_texture);
145
_cogl_pipeline_flush_gl_state (CoglPipeline *pipeline,
146
CoglFramebuffer *framebuffer,
147
CoglBool skip_gl_state,
148
int n_tex_coord_attribs);
150
#endif /* __COGL_PIPELINE_OPENGL_PRIVATE_H */