summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert.bragg@intel.com>2014-03-19 03:53:53 +0000
committerRobert Bragg <robert.bragg@intel.com>2014-03-24 19:37:23 +0000
commit1afe016680d6fd839b938098ab57b344b39f87a4 (patch)
tree3b70a731b82122af3dc7b5c3034c4c6fd9f563bd
parent7475ef62fd5bdfcf484144434837f6f2ffc71a2f (diff)
downloadcogl-1afe016680d6fd839b938098ab57b344b39f87a4.tar.gz
Remove support for GL's legacy fixed function apis
This removes the GL fixed function vertend, fragend and progend since we don't have any need to support non programmable GPUs and since it reduces the number of code paths we maintain. This adds "nop" backends so that for now, we continue to keep support internally for selecting pipeline backends at runtime.
-rw-r--r--cogl/Makefile.am1
-rw-r--r--cogl/Makefile.sources15
-rw-r--r--cogl/cogl-context-private.h17
-rw-r--r--cogl/cogl-context.c34
-rw-r--r--cogl/cogl-debug-options.h5
-rw-r--r--cogl/cogl-debug.c5
-rw-r--r--cogl/cogl-debug.h1
-rw-r--r--cogl/cogl-matrix-stack-private.h13
-rw-r--r--cogl/cogl-matrix-stack.c121
-rw-r--r--cogl/cogl-pipeline-private.h44
-rw-r--r--cogl/cogl-pipeline.c65
-rw-r--r--cogl/cogl-private.h3
-rw-r--r--cogl/cogl-renderer.c1
-rw-r--r--cogl/cogl-texture-3d.c26
-rw-r--r--cogl/driver/gl/cogl-attribute-gl.c223
-rw-r--r--cogl/driver/gl/cogl-clip-stack-gl.c224
-rw-r--r--cogl/driver/gl/cogl-pipeline-fragend-fixed.c381
-rw-r--r--cogl/driver/gl/cogl-pipeline-fragend-glsl.c5
-rw-r--r--cogl/driver/gl/cogl-pipeline-opengl-private.h3
-rw-r--r--cogl/driver/gl/cogl-pipeline-opengl.c532
-rw-r--r--cogl/driver/gl/cogl-pipeline-progend-fixed.c107
-rw-r--r--cogl/driver/gl/cogl-pipeline-progend-glsl.c73
-rw-r--r--cogl/driver/gl/gl/cogl-driver-gl.c9
-rw-r--r--cogl/driver/nop/cogl-pipeline-fragend-nop-private.h (renamed from cogl/driver/gl/cogl-pipeline-vertend-fixed-private.h)14
-rw-r--r--cogl/driver/nop/cogl-pipeline-fragend-nop.c70
-rw-r--r--cogl/driver/nop/cogl-pipeline-progend-nop-private.h (renamed from cogl/driver/gl/cogl-pipeline-progend-fixed-private.h)14
-rw-r--r--cogl/driver/nop/cogl-pipeline-progend-nop.c57
-rw-r--r--cogl/driver/nop/cogl-pipeline-vertend-nop-private.h (renamed from cogl/driver/gl/cogl-pipeline-fragend-fixed-private.h)14
-rw-r--r--cogl/driver/nop/cogl-pipeline-vertend-nop.c (renamed from cogl/driver/gl/cogl-pipeline-vertend-fixed.c)56
-rwxr-xr-xtests/run-tests.sh13
30 files changed, 439 insertions, 1707 deletions
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index ff1990b8..dd8f78e2 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -19,6 +19,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(srcdir)/winsys \
+ -I$(srcdir)/driver/nop \
-I$(srcdir)/driver/gl \
-I$(srcdir)/driver/gl/gl \
-I$(srcdir)/driver/gl/gles \
diff --git a/cogl/Makefile.sources b/cogl/Makefile.sources
index 7855c41a..5bdfd8f6 100644
--- a/cogl/Makefile.sources
+++ b/cogl/Makefile.sources
@@ -60,7 +60,14 @@ cogl_driver_sources = \
driver/nop/cogl-clip-stack-nop-private.h \
driver/nop/cogl-clip-stack-nop.c \
driver/nop/cogl-texture-2d-nop-private.h \
- driver/nop/cogl-texture-2d-nop.c
+ driver/nop/cogl-texture-2d-nop.c \
+ driver/nop/cogl-pipeline-fragend-nop.c \
+ driver/nop/cogl-pipeline-fragend-nop-private.h \
+ driver/nop/cogl-pipeline-vertend-nop.c \
+ driver/nop/cogl-pipeline-vertend-nop-private.h \
+ driver/nop/cogl-pipeline-progend-nop.c \
+ driver/nop/cogl-pipeline-progend-nop-private.h
+
# gl driver sources
cogl_gl_prototypes_h = \
@@ -88,14 +95,8 @@ cogl_driver_sources += \
driver/gl/cogl-pipeline-opengl-private.h \
driver/gl/cogl-pipeline-fragend-glsl.c \
driver/gl/cogl-pipeline-fragend-glsl-private.h \
- driver/gl/cogl-pipeline-fragend-fixed.c \
- driver/gl/cogl-pipeline-fragend-fixed-private.h \
driver/gl/cogl-pipeline-vertend-glsl.c \
driver/gl/cogl-pipeline-vertend-glsl-private.h \
- driver/gl/cogl-pipeline-vertend-fixed.c \
- driver/gl/cogl-pipeline-vertend-fixed-private.h \
- driver/gl/cogl-pipeline-progend-fixed.c \
- driver/gl/cogl-pipeline-progend-fixed-private.h \
driver/gl/cogl-pipeline-progend-glsl.c \
driver/gl/cogl-pipeline-progend-glsl-private.h
diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h
index 489eae06..f65c197e 100644
--- a/cogl/cogl-context-private.h
+++ b/cogl/cogl-context-private.h
@@ -112,15 +112,10 @@ struct _CoglContext
UArray *attribute_name_index_map;
int n_attribute_names;
- CoglBitmask enabled_builtin_attributes;
- CoglBitmask enabled_texcoord_attributes;
CoglBitmask enabled_custom_attributes;
- /* These are temporary bitmasks that are used when disabling
- * builtin,texcoord and custom attribute arrays. They are here just
- * to avoid allocating new ones each time */
- CoglBitmask enable_builtin_attributes_tmp;
- CoglBitmask enable_texcoord_attributes_tmp;
+ /* A temporary bitmask that is used when enabling/disabling
+ * custom attribute arrays */
CoglBitmask enable_custom_attributes_tmp;
CoglBitmask changed_bits_tmp;
@@ -128,10 +123,6 @@ struct _CoglContext
CoglMatrix identity_matrix;
CoglMatrix y_flip_matrix;
- /* Value that was last used when calling glMatrixMode to avoid
- calling it multiple times */
- CoglMatrixMode flushed_matrix_mode;
-
/* The matrix stack entries that should be flushed during the next
* pipeline state flush */
CoglMatrixEntry *current_projection_entry;
@@ -225,9 +216,7 @@ struct _CoglContext
GLint max_texture_units;
GLint max_activateable_texture_units;
- CoglPipelineProgramType current_fragment_program_type;
- CoglPipelineProgramType current_vertex_program_type;
- GLuint current_gl_program;
+ GLuint current_gl_program;
CoglBool current_gl_dither_enabled;
CoglColorMask current_gl_color_mask;
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 550cc4bb..bf436f5a 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -268,8 +268,6 @@ cogl_context_new (CoglDisplay *display,
cogl_matrix_init_identity (&context->y_flip_matrix);
cogl_matrix_scale (&context->y_flip_matrix, 1, -1, 1);
- context->flushed_matrix_mode = COGL_MATRIX_MODELVIEW;
-
context->texture_units =
u_array_new (FALSE, FALSE, sizeof (CoglTextureUnit));
@@ -308,10 +306,6 @@ cogl_context_new (CoglDisplay *display,
context->current_pipeline_changes_since_flush = 0;
context->current_pipeline_with_color_attrib = FALSE;
- _cogl_bitmask_init (&context->enabled_builtin_attributes);
- _cogl_bitmask_init (&context->enable_builtin_attributes_tmp);
- _cogl_bitmask_init (&context->enabled_texcoord_attributes);
- _cogl_bitmask_init (&context->enable_texcoord_attributes_tmp);
_cogl_bitmask_init (&context->enabled_custom_attributes);
_cogl_bitmask_init (&context->enable_custom_attributes_tmp);
_cogl_bitmask_init (&context->changed_bits_tmp);
@@ -319,8 +313,6 @@ cogl_context_new (CoglDisplay *display,
context->max_texture_units = -1;
context->max_activateable_texture_units = -1;
- context->current_fragment_program_type = COGL_PIPELINE_PROGRAM_TYPE_FIXED;
- context->current_vertex_program_type = COGL_PIPELINE_PROGRAM_TYPE_FIXED;
context->current_gl_program = 0;
context->current_gl_dither_enabled = TRUE;
@@ -349,17 +341,6 @@ cogl_context_new (CoglDisplay *display,
context->blit_texture_pipeline = NULL;
#if defined (HAVE_COGL_GL)
- if (_cogl_has_private_feature (context, COGL_PRIVATE_FEATURE_ALPHA_TEST))
- {
- /* The default for GL_ALPHA_TEST is to always pass which is equivalent to
- * the test being disabled therefore we assume that for all drivers there
- * will be no performance impact if we always leave the test enabled which
- * makes things a bit simpler for us. Under GLES2 the alpha test is
- * implemented in the fragment shader so there is no enable for it
- */
- GE (context, glEnable (GL_ALPHA_TEST));
- }
-
if ((context->driver == COGL_DRIVER_GL3))
{
GLuint vertex_array;
@@ -428,17 +409,6 @@ cogl_context_new (CoglDisplay *display,
context->buffer_map_fallback_array = u_byte_array_new ();
context->buffer_map_fallback_in_use = FALSE;
- /* As far as I can tell, GL_POINT_SPRITE doesn't have any effect
- unless GL_COORD_REPLACE is enabled for an individual layer.
- Therefore it seems like it should be ok to just leave it enabled
- all the time instead of having to have a set property on each
- pipeline to track whether any layers have point sprite coords
- enabled. We don't need to do this for GL3 or GLES2 because point
- sprites are handled using a builtin varying in the shader. */
- if (_cogl_has_private_feature (context, COGL_PRIVATE_FEATURE_GL_FIXED) &&
- cogl_has_feature (context, COGL_FEATURE_ID_POINT_SPRITE))
- GE (context, glEnable (GL_POINT_SPRITE));
-
_cogl_list_init (&context->fences);
context->atlas_set = cogl_atlas_set_new (context);
@@ -500,10 +470,6 @@ _cogl_context_free (CoglContext *context)
if (context->current_clip_stack_valid)
_cogl_clip_stack_unref (context->current_clip_stack);
- _cogl_bitmask_destroy (&context->enabled_builtin_attributes);
- _cogl_bitmask_destroy (&context->enable_builtin_attributes_tmp);
- _cogl_bitmask_destroy (&context->enabled_texcoord_attributes);
- _cogl_bitmask_destroy (&context->enable_texcoord_attributes_tmp);
_cogl_bitmask_destroy (&context->enabled_custom_attributes);
_cogl_bitmask_destroy (&context->enable_custom_attributes_tmp);
_cogl_bitmask_destroy (&context->changed_bits_tmp);
diff --git a/cogl/cogl-debug-options.h b/cogl/cogl-debug-options.h
index d04654f5..11147525 100644
--- a/cogl/cogl-debug-options.h
+++ b/cogl/cogl-debug-options.h
@@ -130,11 +130,6 @@ OPT (DISABLE_TEXTURING,
"disable-texturing",
N_("Disable texturing"),
N_("Disable texturing any primitives"))
-OPT (DISABLE_FIXED,
- N_("Root Cause"),
- "disable-fixed",
- N_("Disable fixed"),
- N_("Disable use of the fixed function pipeline backend"))
OPT (DISABLE_GLSL,
N_("Root Cause"),
"disable-glsl",
diff --git a/cogl/cogl-debug.c b/cogl/cogl-debug.c
index 3e103059..fe705ee3 100644
--- a/cogl/cogl-debug.c
+++ b/cogl/cogl-debug.c
@@ -28,9 +28,7 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include <config.h>
#include <stdlib.h>
@@ -78,7 +76,6 @@ static const UDebugKey cogl_behavioural_debug_keys[] = {
{ "disable-atlas", COGL_DEBUG_DISABLE_ATLAS },
{ "disable-shared-atlas", COGL_DEBUG_DISABLE_SHARED_ATLAS },
{ "disable-texturing", COGL_DEBUG_DISABLE_TEXTURING},
- { "disable-fixed", COGL_DEBUG_DISABLE_FIXED},
{ "disable-glsl", COGL_DEBUG_DISABLE_GLSL},
{ "disable-blending", COGL_DEBUG_DISABLE_BLENDING},
{ "disable-npot-textures", COGL_DEBUG_DISABLE_NPOT_TEXTURES},
diff --git a/cogl/cogl-debug.h b/cogl/cogl-debug.h
index 0b86c195..e94d2f16 100644
--- a/cogl/cogl-debug.h
+++ b/cogl/cogl-debug.h
@@ -60,7 +60,6 @@ typedef enum {
COGL_DEBUG_DISABLE_SHARED_ATLAS,
COGL_DEBUG_OPENGL,
COGL_DEBUG_DISABLE_TEXTURING,
- COGL_DEBUG_DISABLE_FIXED,
COGL_DEBUG_DISABLE_GLSL,
COGL_DEBUG_SHOW_SOURCE,
COGL_DEBUG_DISABLE_BLENDING,
diff --git a/cogl/cogl-matrix-stack-private.h b/cogl/cogl-matrix-stack-private.h
index b2584183..7b99a23f 100644
--- a/cogl/cogl-matrix-stack-private.h
+++ b/cogl/cogl-matrix-stack-private.h
@@ -173,19 +173,6 @@ typedef struct _CoglMatrixEntryCache
void
_cogl_matrix_entry_identity_init (CoglMatrixEntry *entry);
-typedef enum {
- COGL_MATRIX_MODELVIEW,
- COGL_MATRIX_PROJECTION,
- COGL_MATRIX_TEXTURE
-} CoglMatrixMode;
-
-void
-_cogl_matrix_entry_flush_to_gl_builtins (CoglContext *ctx,
- CoglMatrixEntry *entry,
- CoglMatrixMode mode,
- CoglFramebuffer *framebuffer,
- CoglBool disable_flip);
-
void
_cogl_matrix_entry_cache_init (CoglMatrixEntryCache *cache);
diff --git a/cogl/cogl-matrix-stack.c b/cogl/cogl-matrix-stack.c
index 7f45158b..2cd131c2 100644
--- a/cogl/cogl-matrix-stack.c
+++ b/cogl/cogl-matrix-stack.c
@@ -815,127 +815,6 @@ cogl_matrix_entry_is_identity (CoglMatrixEntry *entry)
return entry ? entry->op == COGL_MATRIX_OP_LOAD_IDENTITY : FALSE;
}
-static void
-_cogl_matrix_flush_to_gl_builtin (CoglContext *ctx,
- CoglBool is_identity,
- CoglMatrix *matrix,
- CoglMatrixMode mode)
-{
- u_assert (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED));
-
-#if defined (HAVE_COGL_GL)
- if (ctx->flushed_matrix_mode != mode)
- {
- GLenum gl_mode = 0;
-
- switch (mode)
- {
- case COGL_MATRIX_MODELVIEW:
- gl_mode = GL_MODELVIEW;
- break;
-
- case COGL_MATRIX_PROJECTION:
- gl_mode = GL_PROJECTION;
- break;
-
- case COGL_MATRIX_TEXTURE:
- gl_mode = GL_TEXTURE;
- break;
- }
-
- GE (ctx, glMatrixMode (gl_mode));
- ctx->flushed_matrix_mode = mode;
- }
-
- if (is_identity)
- GE (ctx, glLoadIdentity ());
- else
- GE (ctx, glLoadMatrixf (cogl_matrix_get_array (matrix)));
-#endif
-}
-
-void
-_cogl_matrix_entry_flush_to_gl_builtins (CoglContext *ctx,
- CoglMatrixEntry *entry,
- CoglMatrixMode mode,
- CoglFramebuffer *framebuffer,
- CoglBool disable_flip)
-{
- u_assert (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED));
-
-#if defined (HAVE_COGL_GL)
- {
- CoglBool needs_flip;
- CoglMatrixEntryCache *cache;
-
- if (mode == COGL_MATRIX_PROJECTION)
- {
- /* Because Cogl defines texture coordinates to have a top left
- * origin and because offscreen framebuffers may be used for
- * rendering to textures we always render upside down to
- * offscreen buffers. Also for some backends we need to render
- * onscreen buffers upside-down too.
- */
- if (disable_flip)
- needs_flip = FALSE;
- else
- needs_flip = cogl_is_offscreen (framebuffer);
-
- cache = &ctx->builtin_flushed_projection;
- }
- else
- {
- needs_flip = FALSE;
-
- if (mode == COGL_MATRIX_MODELVIEW)
- cache = &ctx->builtin_flushed_modelview;
- else
- cache = NULL;
- }
-
- /* We don't need to do anything if the state is the same */
- if (!cache ||
- _cogl_matrix_entry_cache_maybe_update (cache, entry, needs_flip))
- {
- CoglBool is_identity;
- CoglMatrix matrix;
-
- if (entry->op == COGL_MATRIX_OP_LOAD_IDENTITY)
- is_identity = TRUE;
- else
- {
- is_identity = FALSE;
- cogl_matrix_entry_get (entry, &matrix);
- }
-
- if (needs_flip)
- {
- CoglMatrix flipped_matrix;
-
- cogl_matrix_multiply (&flipped_matrix,
- &ctx->y_flip_matrix,
- is_identity ?
- &ctx->identity_matrix :
- &matrix);
-
- _cogl_matrix_flush_to_gl_builtin (ctx,
- /* not identity */
- FALSE,
- &flipped_matrix,
- mode);
- }
- else
- {
- _cogl_matrix_flush_to_gl_builtin (ctx,
- is_identity,
- &matrix,
- mode);
- }
- }
- }
-#endif
-}
-
CoglBool
cogl_matrix_entry_equal (CoglMatrixEntry *entry0,
CoglMatrixEntry *entry1)
diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h
index c6d80948..0a4b7e19 100644
--- a/cogl/cogl-pipeline-private.h
+++ b/cogl/cogl-pipeline-private.h
@@ -49,40 +49,18 @@
#include <ulib.h>
-#ifdef HAVE_COGL_GL
+#define COGL_PIPELINE_PROGEND_GLSL 0
+#define COGL_PIPELINE_PROGEND_NOP 1
+#define COGL_PIPELINE_N_PROGENDS 2
-#define COGL_PIPELINE_PROGEND_FIXED 0
-#define COGL_PIPELINE_PROGEND_GLSL 1
-#define COGL_PIPELINE_N_PROGENDS 2
-
-#define COGL_PIPELINE_VERTEND_FIXED 0
-#define COGL_PIPELINE_VERTEND_GLSL 1
+#define COGL_PIPELINE_VERTEND_GLSL 0
+#define COGL_PIPELINE_VERTEND_NOP 1
#define COGL_PIPELINE_N_VERTENDS 2
-#define COGL_PIPELINE_FRAGEND_FIXED 0
-#define COGL_PIPELINE_FRAGEND_GLSL 1
+#define COGL_PIPELINE_FRAGEND_GLSL 0
+#define COGL_PIPELINE_FRAGEND_NOP 1
#define COGL_PIPELINE_N_FRAGENDS 2
-#else /* HAVE_COGL_GL */
-
-#ifdef HAVE_COGL_GLES2
-
-#define COGL_PIPELINE_PROGEND_GLSL 0
-#define COGL_PIPELINE_VERTEND_GLSL 0
-#define COGL_PIPELINE_FRAGEND_GLSL 0
-
-#define COGL_PIPELINE_N_PROGENDS 1
-#define COGL_PIPELINE_N_VERTENDS 1
-#define COGL_PIPELINE_N_FRAGENDS 1
-
-#else /* HAVE_COGL_GLES2 */
-
-#error No drivers defined
-
-#endif /* HAVE_COGL_GLES2 */
-
-#endif /* HAVE_COGL_GL */
-
#define COGL_PIPELINE_PROGEND_DEFAULT 0
#define COGL_PIPELINE_PROGEND_UNDEFINED 3
@@ -501,7 +479,7 @@ typedef struct
typedef enum
{
COGL_PIPELINE_PROGRAM_TYPE_GLSL = 1,
- COGL_PIPELINE_PROGRAM_TYPE_FIXED
+ COGL_PIPELINE_PROGRAM_TYPE_NOP
} CoglPipelineProgramType;
extern const CoglPipelineFragend *
@@ -635,12 +613,6 @@ typedef struct _CoglPipelineFlushOptions
CoglTexture *layer0_override_texture;
} CoglPipelineFlushOptions;
-void
-_cogl_use_fragment_program (GLuint gl_program, CoglPipelineProgramType type);
-
-void
-_cogl_use_vertex_program (GLuint gl_program, CoglPipelineProgramType type);
-
unsigned int
_cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func);
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 96b74e49..76acf66c 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -31,9 +31,7 @@
* Robert Bragg <robert@linux.intel.com>
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include <config.h>
#include "cogl-debug.h"
#include "cogl-context-private.h"
@@ -66,25 +64,25 @@ const CoglPipelineVertend *_cogl_pipeline_vertends[COGL_PIPELINE_N_VERTENDS];
const CoglPipelineProgend *
_cogl_pipeline_progends[MAX (COGL_PIPELINE_N_PROGENDS, 1)];
-#ifdef COGL_PIPELINE_FRAGEND_GLSL
-#include "cogl-pipeline-fragend-glsl-private.h"
+#ifdef COGL_PIPELINE_PROGEND_GLSL
+#include "cogl-pipeline-progend-glsl-private.h"
#endif
-#ifdef COGL_PIPELINE_FRAGEND_FIXED
-#include "cogl-pipeline-fragend-fixed-private.h"
+#ifdef COGL_PIPELINE_PROGEND_NOP
+#include "cogl-pipeline-progend-nop-private.h"
#endif
#ifdef COGL_PIPELINE_VERTEND_GLSL
#include "cogl-pipeline-vertend-glsl-private.h"
#endif
-#ifdef COGL_PIPELINE_VERTEND_FIXED
-#include "cogl-pipeline-vertend-fixed-private.h"
+#ifdef COGL_PIPELINE_VERTEND_NOP
+#include "cogl-pipeline-vertend-nop-private.h"
#endif
-#ifdef COGL_PIPELINE_PROGEND_FIXED
-#include "cogl-pipeline-progend-fixed-private.h"
+#ifdef COGL_PIPELINE_FRAGEND_GLSL
+#include "cogl-pipeline-fragend-glsl-private.h"
#endif
-#ifdef COGL_PIPELINE_PROGEND_GLSL
-#include "cogl-pipeline-progend-glsl-private.h"
+#ifdef COGL_PIPELINE_FRAGEND_NOP
+#include "cogl-pipeline-fragend-nop-private.h"
#endif
COGL_OBJECT_DEFINE (Pipeline, pipeline);
@@ -113,30 +111,31 @@ _cogl_pipeline_init_default_pipeline (void)
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* Take this opportunity to setup the backends... */
-#ifdef COGL_PIPELINE_FRAGEND_GLSL
- _cogl_pipeline_fragends[COGL_PIPELINE_FRAGEND_GLSL] =
- &_cogl_pipeline_glsl_fragend;
-#endif
-#ifdef COGL_PIPELINE_FRAGEND_FIXED
- _cogl_pipeline_fragends[COGL_PIPELINE_FRAGEND_FIXED] =
- &_cogl_pipeline_fixed_fragend;
-#endif
-#ifdef COGL_PIPELINE_PROGEND_FIXED
- _cogl_pipeline_progends[COGL_PIPELINE_PROGEND_FIXED] =
- &_cogl_pipeline_fixed_progend;
-#endif
#ifdef COGL_PIPELINE_PROGEND_GLSL
_cogl_pipeline_progends[COGL_PIPELINE_PROGEND_GLSL] =
&_cogl_pipeline_glsl_progend;
#endif
+#ifdef COGL_PIPELINE_PROGEND_NOP
+ _cogl_pipeline_progends[COGL_PIPELINE_PROGEND_NOP] =
+ &_cogl_pipeline_nop_progend;
+#endif
#ifdef COGL_PIPELINE_VERTEND_GLSL
_cogl_pipeline_vertends[COGL_PIPELINE_VERTEND_GLSL] =
&_cogl_pipeline_glsl_vertend;
#endif
-#ifdef COGL_PIPELINE_VERTEND_FIXED
- _cogl_pipeline_vertends[COGL_PIPELINE_VERTEND_FIXED] =
- &_cogl_pipeline_fixed_vertend;
+#ifdef COGL_PIPELINE_VERTEND_NOP
+ _cogl_pipeline_vertends[COGL_PIPELINE_VERTEND_NOP] =
+ &_cogl_pipeline_nop_vertend;
+#endif
+
+#ifdef COGL_PIPELINE_FRAGEND_GLSL
+ _cogl_pipeline_fragends[COGL_PIPELINE_FRAGEND_GLSL] =
+ &_cogl_pipeline_glsl_fragend;
+#endif
+#ifdef COGL_PIPELINE_FRAGEND_NOP
+ _cogl_pipeline_fragends[COGL_PIPELINE_FRAGEND_NOP] =
+ &_cogl_pipeline_nop_fragend;
#endif
_cogl_pipeline_node_init (COGL_NODE (pipeline));
@@ -2864,13 +2863,9 @@ _cogl_pipeline_get_layer_state_for_fragment_codegen (CoglContext *context)
CoglPipelineState
_cogl_pipeline_get_state_for_fragment_codegen (CoglContext *context)
{
- CoglPipelineState state = (COGL_PIPELINE_STATE_LAYERS |
- COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS);
-
- if (!_cogl_has_private_feature (context, COGL_PRIVATE_FEATURE_ALPHA_TEST))
- state |= COGL_PIPELINE_STATE_ALPHA_FUNC;
-
- return state;
+ return (COGL_PIPELINE_STATE_LAYERS |
+ COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS |
+ COGL_PIPELINE_STATE_ALPHA_FUNC);
}
int
diff --git a/cogl/cogl-private.h b/cogl/cogl-private.h
index 85a1b8b2..552ede74 100644
--- a/cogl/cogl-private.h
+++ b/cogl/cogl-private.h
@@ -43,7 +43,6 @@ typedef enum
COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE,
COGL_PRIVATE_FEATURE_MESA_PACK_INVERT,
COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT,
- COGL_PRIVATE_FEATURE_FOUR_CLIP_PLANES,
COGL_PRIVATE_FEATURE_PBOS,
COGL_PRIVATE_FEATURE_VBOS,
COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL,
@@ -52,7 +51,6 @@ typedef enum
COGL_PRIVATE_FEATURE_UNPACK_SUBIMAGE,
COGL_PRIVATE_FEATURE_SAMPLER_OBJECTS,
COGL_PRIVATE_FEATURE_READ_PIXELS_ANY_FORMAT,
- COGL_PRIVATE_FEATURE_ALPHA_TEST,
COGL_PRIVATE_FEATURE_FORMAT_CONVERSION,
COGL_PRIVATE_FEATURE_QUADS,
COGL_PRIVATE_FEATURE_BLEND_CONSTANT,
@@ -72,7 +70,6 @@ typedef enum
* driver being used and instead check for broad opengl feature
* sets that can be shared by several GL apis */
COGL_PRIVATE_FEATURE_ANY_GL,
- COGL_PRIVATE_FEATURE_GL_FIXED,
COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
COGL_PRIVATE_FEATURE_GL_EMBEDDED,
COGL_PRIVATE_FEATURE_GL_WEB,
diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c
index 097d6f20..264ba264 100644
--- a/cogl/cogl-renderer.c
+++ b/cogl/cogl-renderer.c
@@ -130,7 +130,6 @@ static CoglDriverDescription _cogl_drivers[] =
"gl",
0,
{ COGL_PRIVATE_FEATURE_ANY_GL,
- COGL_PRIVATE_FEATURE_GL_FIXED,
COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
-1 },
&_cogl_driver_gl,
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index 25e48e6a..d2cc260a 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -634,32 +634,6 @@ _cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
GL_GENERATE_MIPMAP and reuploading the first pixel */
if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
_cogl_texture_gl_generate_mipmaps (tex);
-#if defined (HAVE_COGL_GL)
- else if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED))
- {
- _cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
- tex_3d->gl_texture,
- FALSE);
-
- GE( ctx, glTexParameteri (GL_TEXTURE_3D,
- GL_GENERATE_MIPMAP,
- GL_TRUE) );
- GE( ctx, glTexSubImage3D (GL_TEXTURE_3D,
- 0, /* level */
- 0, /* xoffset */
- 0, /* yoffset */
- 0, /* zoffset */
- 1, /* width */
- 1, /* height */
- 1, /* depth */
- tex_3d->first_pixel.gl_format,
- tex_3d->first_pixel.gl_type,
- tex_3d->first_pixel.data) );
- GE( ctx, glTexParameteri (GL_TEXTURE_3D,
- GL_GENERATE_MIPMAP,
- GL_FALSE) );
- }
-#endif
tex_3d->mipmaps_dirty = FALSE;
}
diff --git a/cogl/driver/gl/cogl-attribute-gl.c b/cogl/driver/gl/cogl-attribute-gl.c
index 114e6874..2ce8fca7 100644
--- a/cogl/driver/gl/cogl-attribute-gl.c
+++ b/cogl/driver/gl/cogl-attribute-gl.c
@@ -57,69 +57,6 @@ typedef struct _ForeachChangedBitState
} ForeachChangedBitState;
static CoglBool
-toggle_builtin_attribute_enabled_cb (int bit_num, void *user_data)
-{
- ForeachChangedBitState *state = user_data;
- CoglContext *context = state->context;
-
- _COGL_RETURN_VAL_IF_FAIL (_cogl_has_private_feature
- (context, COGL_PRIVATE_FEATURE_GL_FIXED),
- FALSE);
-
-#if defined (HAVE_COGL_GL)
- {
- CoglBool enabled = _cogl_bitmask_get (state->new_bits, bit_num);
- GLenum cap;
-
- switch (bit_num)
- {
- case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
- cap = GL_COLOR_ARRAY;
- break;
- case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
- cap = GL_VERTEX_ARRAY;
- break;
- case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
- cap = GL_NORMAL_ARRAY;
- break;
- }
- if (enabled)
- GE (context, glEnableClientState (cap));
- else
- GE (context, glDisableClientState (cap));
- }
-#endif
-
- return TRUE;
-}
-
-static CoglBool
-toggle_texcood_attribute_enabled_cb (int bit_num, void *user_data)
-{
- ForeachChangedBitState *state = user_data;
- CoglContext *context = state->context;
-
- _COGL_RETURN_VAL_IF_FAIL (_cogl_has_private_feature
- (context, COGL_PRIVATE_FEATURE_GL_FIXED),
- FALSE);
-
-#if defined (HAVE_COGL_GL)
- {
- CoglBool enabled = _cogl_bitmask_get (state->new_bits, bit_num);
-
- GE( context, glClientActiveTexture (GL_TEXTURE0 + bit_num) );
-
- if (enabled)
- GE( context, glEnableClientState (GL_TEXTURE_COORD_ARRAY) );
- else
- GE( context, glDisableClientState (GL_TEXTURE_COORD_ARRAY) );
- }
-#endif
-
- return TRUE;
-}
-
-static CoglBool
toggle_custom_attribute_enabled_cb (int bit_num, void *user_data)
{
ForeachChangedBitState *state = user_data;
@@ -157,8 +94,6 @@ foreach_changed_bit_and_save (CoglContext *context,
_cogl_bitmask_set_bits (current_bits, new_bits);
}
-#ifdef COGL_PIPELINE_PROGEND_GLSL
-
static void
setup_generic_buffered_attribute (CoglContext *context,
CoglPipeline *pipeline,
@@ -230,136 +165,6 @@ setup_generic_const_attribute (CoglContext *context,
}
}
-#endif /* COGL_PIPELINE_PROGEND_GLSL */
-
-static void
-setup_legacy_buffered_attribute (CoglContext *ctx,
- CoglPipeline *pipeline,
- CoglAttribute *attribute,
- uint8_t *base)
-{
- switch (attribute->name_state->name_id)
- {
- case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
- _cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp,
- COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY, TRUE);
- GE (ctx, glColorPointer (attribute->d.buffered.n_components,
- attribute->d.buffered.type,
- attribute->d.buffered.stride,
- base + attribute->d.buffered.offset));
- break;
- case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
- _cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp,
- COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY, TRUE);
- GE (ctx, glNormalPointer (attribute->d.buffered.type,
- attribute->d.buffered.stride,
- base + attribute->d.buffered.offset));
- break;
- case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
- {
- int layer_number = attribute->name_state->layer_number;
- const CoglPipelineGetLayerFlags flags =
- COGL_PIPELINE_GET_LAYER_NO_CREATE;
- CoglPipelineLayer *layer =
- _cogl_pipeline_get_layer_with_flags (pipeline, layer_number, flags);
-
- if (layer)
- {
- int unit = _cogl_pipeline_layer_get_unit_index (layer);
-
- _cogl_bitmask_set (&ctx->enable_texcoord_attributes_tmp,
- unit,
- TRUE);
-
- GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit));
- GE (ctx, glTexCoordPointer (attribute->d.buffered.n_components,
- attribute->d.buffered.type,
- attribute->d.buffered.stride,
- base + attribute->d.buffered.offset));
- }
- break;
- }
- case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
- _cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp,
- COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY, TRUE);
- GE (ctx, glVertexPointer (attribute->d.buffered.n_components,
- attribute->d.buffered.type,
- attribute->d.buffered.stride,
- base + attribute->d.buffered.offset));
- break;
- case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
-#ifdef COGL_PIPELINE_PROGEND_GLSL
- if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE))
- setup_generic_buffered_attribute (ctx, pipeline, attribute, base);
-#endif
- break;
- default:
- u_warn_if_reached ();
- }
-}
-
-static void
-setup_legacy_const_attribute (CoglContext *ctx,
- CoglPipeline *pipeline,
- CoglAttribute *attribute)
-{
-#ifdef COGL_PIPELINE_PROGEND_GLSL
- if (attribute->name_state->name_id == COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY)
- {
- if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE))
- setup_generic_const_attribute (ctx, pipeline, attribute);
- }
- else
-#endif
- {
- float vector[4] = { 0, 0, 0, 1 };
- float *boxed = attribute->d.constant.boxed.v.float_value;
- int n_components = attribute->d.constant.boxed.size;
- int i;
-
- for (i = 0; i < n_components; i++)
- vector[i] = boxed[i];
-
- switch (attribute->name_state->name_id)
- {
- case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
- GE (ctx, glColor4f (vector[0], vector[1], vector[2], vector[3]));
- break;
- case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
- GE (ctx, glNormal3f (vector[0], vector[1], vector[2]));
- break;
- case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
- {
- int layer_number = attribute->name_state->layer_number;
- const CoglPipelineGetLayerFlags flags =
- COGL_PIPELINE_GET_LAYER_NO_CREATE;
- CoglPipelineLayer *layer =
- _cogl_pipeline_get_layer_with_flags (pipeline,
- layer_number,
- flags);
-
- if (layer)
- {
- int unit = _cogl_pipeline_layer_get_unit_index (layer);
-
- GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit));
-
- GE (ctx, glMultiTexCoord4f (vector[0],
- vector[1],
- vector[2],
- vector[3]));
- }
- break;
- }
- case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
- GE (ctx, glVertex4f (vector[0], vector[1], vector[2], vector[3]));
- break;
- default:
- u_warn_if_reached ();
- }
- }
-}
-
static void
apply_attribute_enable_updates (CoglContext *context,
CoglPipeline *pipeline)
@@ -367,22 +172,8 @@ apply_attribute_enable_updates (CoglContext *context,
ForeachChangedBitState changed_bits_state;
changed_bits_state.context = context;
- changed_bits_state.new_bits = &context->enable_builtin_attributes_tmp;
changed_bits_state.pipeline = pipeline;
- foreach_changed_bit_and_save (context,
- &context->enabled_builtin_attributes,
- &context->enable_builtin_attributes_tmp,
- toggle_builtin_attribute_enabled_cb,
- &changed_bits_state);
-
- changed_bits_state.new_bits = &context->enable_texcoord_attributes_tmp;
- foreach_changed_bit_and_save (context,
- &context->enabled_texcoord_attributes,
- &context->enable_texcoord_attributes_tmp,
- toggle_texcood_attribute_enabled_cb,
- &changed_bits_state);
-
changed_bits_state.new_bits = &context->enable_custom_attributes_tmp;
foreach_changed_bit_and_save (context,
&context->enabled_custom_attributes,
@@ -473,8 +264,6 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
with_color_attrib,
unknown_color_alpha);
- _cogl_bitmask_clear_all (&ctx->enable_builtin_attributes_tmp);
- _cogl_bitmask_clear_all (&ctx->enable_texcoord_attributes_tmp);
_cogl_bitmask_clear_all (&ctx->enable_custom_attributes_tmp);
/* Bind the attribute pointers. We need to do this after the
@@ -503,20 +292,12 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER,
NULL);
- if (pipeline->progend == COGL_PIPELINE_PROGEND_GLSL)
- setup_generic_buffered_attribute (ctx, pipeline, attribute, base);
- else
- setup_legacy_buffered_attribute (ctx, pipeline, attribute, base);
+ setup_generic_buffered_attribute (ctx, pipeline, attribute, base);
_cogl_buffer_gl_unbind (buffer);
}
else
- {
- if (pipeline->progend == COGL_PIPELINE_PROGEND_GLSL)
- setup_generic_const_attribute (ctx, pipeline, attribute);
- else
- setup_legacy_const_attribute (ctx, pipeline, attribute);
- }
+ setup_generic_const_attribute (ctx, pipeline, attribute);
}
apply_attribute_enable_updates (ctx, pipeline);
diff --git a/cogl/driver/gl/cogl-clip-stack-gl.c b/cogl/driver/gl/cogl-clip-stack-gl.c
index bc123730..fcbb088e 100644
--- a/cogl/driver/gl/cogl-clip-stack-gl.c
+++ b/cogl/driver/gl/cogl-clip-stack-gl.c
@@ -43,160 +43,6 @@
#include "cogl-clip-stack-gl-private.h"
#include "cogl-primitive-private.h"
-#ifndef GL_CLIP_PLANE0
-#define GL_CLIP_PLANE0 0x3000
-#define GL_CLIP_PLANE1 0x3001
-#define GL_CLIP_PLANE2 0x3002
-#define GL_CLIP_PLANE3 0x3003
-#define GL_CLIP_PLANE4 0x3004
-#define GL_CLIP_PLANE5 0x3005
-#endif
-
-static void
-project_vertex (const CoglMatrix *modelview_projection,
- float *vertex)
-{
- int i;
-
- cogl_matrix_transform_point (modelview_projection,
- &vertex[0], &vertex[1],
- &vertex[2], &vertex[3]);
-
- /* Convert from homogenized coordinates */
- for (i = 0; i < 4; i++)
- vertex[i] /= vertex[3];
-}
-
-static void
-set_clip_plane (CoglFramebuffer *framebuffer,
- int plane_num,
- const float *vertex_a,
- const float *vertex_b)
-{
- CoglContext *ctx = framebuffer->context;
- float planef[4];
- double planed[4];
- float angle;
- CoglMatrixStack *modelview_stack =
- _cogl_framebuffer_get_modelview_stack (framebuffer);
- CoglMatrixStack *projection_stack =
- _cogl_framebuffer_get_projection_stack (framebuffer);
- CoglMatrix inverse_projection;
-
- cogl_matrix_stack_get_inverse (projection_stack, &inverse_projection);
-
- /* Calculate the angle between the axes and the line crossing the
- two points */
- angle = atan2f (vertex_b[1] - vertex_a[1],
- vertex_b[0] - vertex_a[0]) * (180.0/G_PI);
-
- cogl_matrix_stack_push (modelview_stack);
-
- /* Load the inverse of the projection matrix so we can specify the plane
- * in screen coordinates */
- cogl_matrix_stack_set (modelview_stack, &inverse_projection);
-
- /* Rotate about point a */
- cogl_matrix_stack_translate (modelview_stack,
- vertex_a[0], vertex_a[1], vertex_a[2]);
- /* Rotate the plane by the calculated angle so that it will connect
- the two points */
- cogl_matrix_stack_rotate (modelview_stack, angle, 0.0f, 0.0f, 1.0f);
- cogl_matrix_stack_translate (modelview_stack,
- -vertex_a[0], -vertex_a[1], -vertex_a[2]);
-
- /* Clip planes can only be used when a fixed function backend is in
- use so we know we can directly push this matrix to the builtin
- state */
- _cogl_matrix_entry_flush_to_gl_builtins (ctx,
- modelview_stack->last_entry,
- COGL_MATRIX_MODELVIEW,
- framebuffer,
- FALSE /* don't disable flip */);
-
- planef[0] = 0;
- planef[1] = -1.0;
- planef[2] = 0;
- planef[3] = vertex_a[1];
-
- switch (ctx->driver)
- {
- default:
- u_assert_not_reached ();
- break;
-
- case COGL_DRIVER_GL:
- case COGL_DRIVER_GL3:
- planed[0] = planef[0];
- planed[1] = planef[1];
- planed[2] = planef[2];
- planed[3] = planef[3];
- GE( ctx, glClipPlane (plane_num, planed) );
- break;
- }
-
- cogl_matrix_stack_pop (modelview_stack);
-}
-
-static void
-set_clip_planes (CoglFramebuffer *framebuffer,
- CoglMatrixEntry *modelview_entry,
- float x_1,
- float y_1,
- float x_2,
- float y_2)
-{
- CoglMatrix modelview_matrix;
- CoglMatrixStack *projection_stack =
- _cogl_framebuffer_get_projection_stack (framebuffer);
- CoglMatrix projection_matrix;
- CoglMatrix modelview_projection;
- float signed_area;
-
- float vertex_tl[4] = { x_1, y_1, 0, 1.0 };
- float vertex_tr[4] = { x_2, y_1, 0, 1.0 };
- float vertex_bl[4] = { x_1, y_2, 0, 1.0 };
- float vertex_br[4] = { x_2, y_2, 0, 1.0 };
-
- cogl_matrix_stack_get (projection_stack, &projection_matrix);
- cogl_matrix_entry_get (modelview_entry, &modelview_matrix);
-
- cogl_matrix_multiply (&modelview_projection,
- &projection_matrix,
- &modelview_matrix);
-
- project_vertex (&modelview_projection, vertex_tl);
- project_vertex (&modelview_projection, vertex_tr);
- project_vertex (&modelview_projection, vertex_bl);
- project_vertex (&modelview_projection, vertex_br);
-
- /* Calculate the signed area of the polygon formed by the four
- vertices so that we can know its orientation */
- signed_area = (vertex_tl[0] * (vertex_tr[1] - vertex_bl[1])
- + vertex_tr[0] * (vertex_br[1] - vertex_tl[1])
- + vertex_br[0] * (vertex_bl[1] - vertex_tr[1])
- + vertex_bl[0] * (vertex_tl[1] - vertex_br[1]));
-
- /* Set the clip planes to form lines between all of the vertices
- using the same orientation as we calculated */
- if (signed_area > 0.0f)
- {
- /* counter-clockwise */
- set_clip_plane (framebuffer, GL_CLIP_PLANE0, vertex_tl, vertex_bl);
- set_clip_plane (framebuffer, GL_CLIP_PLANE1, vertex_bl, vertex_br);
- set_clip_plane (framebuffer, GL_CLIP_PLANE2, vertex_br, vertex_tr);
- set_clip_plane (framebuffer, GL_CLIP_PLANE3, vertex_tr, vertex_tl);
- }
- else
- {
- /* clockwise */
- set_clip_plane (framebuffer, GL_CLIP_PLANE0, vertex_tl, vertex_tr);
- set_clip_plane (framebuffer, GL_CLIP_PLANE1, vertex_tr, vertex_br);
- set_clip_plane (framebuffer, GL_CLIP_PLANE2, vertex_br, vertex_bl);
- set_clip_plane (framebuffer, GL_CLIP_PLANE3, vertex_bl, vertex_tl);
- }
-}
-
static void
add_stencil_clip_rectangle (CoglFramebuffer *framebuffer,
CoglMatrixEntry *modelview_entry,
@@ -399,31 +245,11 @@ add_stencil_clip_primitive (CoglFramebuffer *framebuffer,
primitive);
}
-static void
-enable_clip_planes (CoglContext *ctx)
-{
- GE( ctx, glEnable (GL_CLIP_PLANE0) );
- GE( ctx, glEnable (GL_CLIP_PLANE1) );
- GE( ctx, glEnable (GL_CLIP_PLANE2) );
- GE( ctx, glEnable (GL_CLIP_PLANE3) );
-}
-
-static void
-disable_clip_planes (CoglContext *ctx)
-{
- GE( ctx, glDisable (GL_CLIP_PLANE3) );
- GE( ctx, glDisable (GL_CLIP_PLANE2) );
- GE( ctx, glDisable (GL_CLIP_PLANE1) );
- GE( ctx, glDisable (GL_CLIP_PLANE0) );
-}
-
void
_cogl_clip_stack_gl_flush (CoglClipStack *stack,
CoglFramebuffer *framebuffer)
{
CoglContext *ctx = framebuffer->context;
- int has_clip_planes;
- CoglBool using_clip_planes = FALSE;
CoglBool using_stencil_buffer = FALSE;
int scissor_x0;
int scissor_y0;
@@ -450,11 +276,6 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack,
ctx->current_clip_stack_valid = TRUE;
ctx->current_clip_stack = _cogl_clip_stack_ref (stack);
- has_clip_planes =
- _cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_FOUR_CLIP_PLANES);
-
- if (has_clip_planes)
- disable_clip_planes (ctx);
GE( ctx, glDisable (GL_STENCIL_TEST) );
/* If the stack is empty then there's nothing else to do
@@ -571,36 +392,16 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack,
rectangle was entirely described by its scissor bounds */
if (!rect->can_be_scissor)
{
- /* If we support clip planes and we haven't already used
- them then use that instead */
- if (has_clip_planes)
- {
- COGL_NOTE (CLIPPING,
- "Adding clip planes clip for rectangle");
-
- set_clip_planes (framebuffer,
- rect->matrix_entry,
- rect->x0,
- rect->y0,
- rect->x1,
- rect->y1);
- using_clip_planes = TRUE;
- /* We can't use clip planes a second time */
- has_clip_planes = FALSE;
- }
- else
- {
- COGL_NOTE (CLIPPING, "Adding stencil clip for rectangle");
-
- add_stencil_clip_rectangle (framebuffer,
- rect->matrix_entry,
- rect->x0,
- rect->y0,
- rect->x1,
- rect->y1,
- !using_stencil_buffer);
- using_stencil_buffer = TRUE;
- }
+ COGL_NOTE (CLIPPING, "Adding stencil clip for rectangle");
+
+ add_stencil_clip_rectangle (framebuffer,
+ rect->matrix_entry,
+ rect->x0,
+ rect->y0,
+ rect->x1,
+ rect->y1,
+ !using_stencil_buffer);
+ using_stencil_buffer = TRUE;
}
break;
}
@@ -611,9 +412,4 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack,
* box */
}
}
-
- /* Enabling clip planes is delayed to now so that they won't affect
- setting up the stencil buffer */
- if (using_clip_planes)
- enable_clip_planes (ctx);
}
diff --git a/cogl/driver/gl/cogl-pipeline-fragend-fixed.c b/cogl/driver/gl/cogl-pipeline-fragend-fixed.c
deleted file mode 100644
index bbe31357..00000000
--- a/cogl/driver/gl/cogl-pipeline-fragend-fixed.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Cogl
- *
- * A Low-Level GPU Graphics and Utilities API
- *
- * Copyright (C) 2008,2009,2010 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- *
- *
- * Authors:
- * Robert Bragg <robert@linux.intel.com>
- */
-
-#include <config.h>
-
-#include "cogl-context-private.h"
-#include "cogl-util-gl-private.h"
-#include "cogl-pipeline-private.h"
-#include "cogl-pipeline-state-private.h"
-#include "cogl-pipeline-opengl-private.h"
-
-#ifdef COGL_PIPELINE_FRAGEND_FIXED
-
-#include "cogl-context-private.h"
-#include "cogl-object-private.h"
-
-#include "cogl-texture-private.h"
-#include "cogl-blend-string.h"
-#include "cogl-profile.h"
-
-#include <ulib.h>
-#include <string.h>
-
-#ifndef GL_TEXTURE_RECTANGLE_ARB
-#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
-#endif
-
-const CoglPipelineFragend _cogl_pipeline_fixed_fragend;
-
-static void
-_cogl_disable_texture_unit (int unit_index)
-{
- CoglTextureUnit *unit;
-
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- unit = &u_array_index (ctx->texture_units, CoglTextureUnit, unit_index);
-
- if (unit->enabled_gl_target)
- {
- _cogl_set_active_texture_unit (unit_index);
- GE (ctx, glDisable (unit->enabled_gl_target));
- unit->enabled_gl_target = 0;
- }
-}
-
-static int
-get_max_texture_units (void)
-{
- _COGL_GET_CONTEXT (ctx, 0);
-
- /* This function is called quite often so we cache the value to
- avoid too many GL calls */
- if (ctx->max_texture_units == -1)
- {
- ctx->max_texture_units = 1;
- GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_UNITS,
- &ctx->max_texture_units));
- }
-
- return ctx->max_texture_units;
-}
-
-static void
-_cogl_pipeline_fragend_fixed_start (CoglPipeline *pipeline,
- int n_layers,
- unsigned long pipelines_difference)
-{
- _cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED);
-}
-
-static void
-translate_sources (CoglPipeline *pipeline,
- int n_sources,
- CoglPipelineCombineSource *source_in,
- GLenum *source_out)
-{
- int i;
-
- /* The texture source numbers specified in the layer combine are the
- layer numbers so we need to map these to unit indices */
-
- for (i = 0; i < n_sources; i++)
- switch (source_in[i])
- {
- case COGL_PIPELINE_COMBINE_SOURCE_TEXTURE:
- source_out[i] = GL_TEXTURE;
- break;
-
- case COGL_PIPELINE_COMBINE_SOURCE_CONSTANT:
- source_out[i] = GL_CONSTANT;
- break;
-
- case COGL_PIPELINE_COMBINE_SOURCE_PRIMARY_COLOR:
- source_out[i] = GL_PRIMARY_COLOR;
- break;
-
- case COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS:
- source_out[i] = GL_PREVIOUS;
- break;
-
- default:
- {
- int layer_num = source_in[i] - COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0;
- CoglPipelineGetLayerFlags flags = COGL_PIPELINE_GET_LAYER_NO_CREATE;
- CoglPipelineLayer *layer =
- _cogl_pipeline_get_layer_with_flags (pipeline, layer_num, flags);
-
- if (layer == NULL)
- {
- static CoglBool warning_seen = FALSE;
- if (!warning_seen)
- {
- u_warning ("The application is trying to use a texture "
- "combine with a layer number that does not exist");
- warning_seen = TRUE;
- }
- source_out[i] = GL_PREVIOUS;
- }
- else
- source_out[i] = (_cogl_pipeline_layer_get_unit_index (layer) +
- GL_TEXTURE0);
- }
- }
-}
-
-static CoglBool
-_cogl_pipeline_fragend_fixed_add_layer (CoglPipeline *pipeline,
- CoglPipelineLayer *layer,
- unsigned long layers_difference)
-{
- CoglTextureUnit *unit =
- _cogl_get_texture_unit (_cogl_pipeline_layer_get_unit_index (layer));
- int unit_index = unit->index;
- int n_rgb_func_args;
- int n_alpha_func_args;
-
- _COGL_GET_CONTEXT (ctx, FALSE);
-
- /* XXX: Beware that since we are changing the active texture unit we
- * must make sure we don't call into other Cogl components that may
- * temporarily bind texture objects to query/modify parameters since
- * they will end up binding texture unit 1. See
- * _cogl_bind_gl_texture_transient for more details.
- */
- _cogl_set_active_texture_unit (unit_index);
-
- if (U_UNLIKELY (unit_index >= get_max_texture_units ()))
- {
- _cogl_disable_texture_unit (unit_index);
- /* TODO: although this isn't considered an error that
- * warrants falling back to a different backend we
- * should print a warning here. */
- return TRUE;
- }
-
- /* Handle enabling or disabling the right texture type */
- if (layers_difference & COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE)
- {
- CoglTextureType texture_type =
- _cogl_pipeline_layer_get_texture_type (layer);
- GLenum gl_target;
-
- switch (texture_type)
- {
- case COGL_TEXTURE_TYPE_2D:
- gl_target = GL_TEXTURE_2D;
- break;
-
- case COGL_TEXTURE_TYPE_3D:
- gl_target = GL_TEXTURE_3D;
- break;
-
- case COGL_TEXTURE_TYPE_RECTANGLE:
- gl_target = GL_TEXTURE_RECTANGLE_ARB;
- break;
- }
-
- _cogl_set_active_texture_unit (unit_index);
-
- /* The common GL code handles binding the right texture so we
- just need to handle enabling and disabling it */
-
- if (unit->enabled_gl_target != gl_target)
- {
- /* Disable the previous target if it's still enabled */
- if (unit->enabled_gl_target)
- GE (ctx, glDisable (unit->enabled_gl_target));
-
- /* Enable the new target */
- if (!U_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)))
- {
- GE (ctx, glEnable (gl_target));
- unit->enabled_gl_target = gl_target;
- }
- }
- }
- else
- {
- /* Even though there may be no difference between the last flushed
- * texture state and the current layers texture state it may be that the
- * texture unit has been disabled for some time so we need to assert that
- * it's enabled now.
- */
- if (!U_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)) &&
- unit->enabled_gl_target == 0)
- {
- _cogl_set_active_texture_unit (unit_index);
- GE (ctx, glEnable (unit->gl_target));
- unit->enabled_gl_target = unit->gl_target;
- }
- }
-
- if (layers_difference & COGL_PIPELINE_LAYER_STATE_COMBINE)
- {
- CoglPipelineLayer *authority =
- _cogl_pipeline_layer_get_authority (layer,
- COGL_PIPELINE_LAYER_STATE_COMBINE);
- CoglPipelineLayerBigState *big_state = authority->big_state;
- GLenum sources[3];
-
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE));
-
- /* Set the combiner functions... */
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV,
- GL_COMBINE_RGB,
- big_state->texture_combine_rgb_func));
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV,
- GL_COMBINE_ALPHA,
- big_state->texture_combine_alpha_func));
-
- /*
- * Setup the function arguments...
- */
-
- /* For the RGB components... */
- n_rgb_func_args =
- _cogl_get_n_args_for_combine_func (big_state->texture_combine_rgb_func);
-
- translate_sources (pipeline,
- n_rgb_func_args,
- big_state->texture_combine_rgb_src,
- sources);
-
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_RGB,
- sources[0]));
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB,
- big_state->texture_combine_rgb_op[0]));
- if (n_rgb_func_args > 1)
- {
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_RGB,
- sources[1]));
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB,
- big_state->texture_combine_rgb_op[1]));
- }
- if (n_rgb_func_args > 2)
- {
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC2_RGB,
- sources[2]));
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_RGB,
- big_state->texture_combine_rgb_op[2]));
- }
-
- /* For the Alpha component */
- n_alpha_func_args =
- _cogl_get_n_args_for_combine_func (big_state->texture_combine_alpha_func);
-
- translate_sources (pipeline,
- n_alpha_func_args,
- big_state->texture_combine_alpha_src,
- sources);
-
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_ALPHA,
- sources[0]));
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA,
- big_state->texture_combine_alpha_op[0]));
- if (n_alpha_func_args > 1)
- {
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_ALPHA,
- sources[1]));
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA,
- big_state->texture_combine_alpha_op[1]));
- }
- if (n_alpha_func_args > 2)
- {
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC2_ALPHA,
- sources[2]));
- GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA,
- big_state->texture_combine_alpha_op[2]));
- }
- }
-
- if (layers_difference & COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT)
- {
- CoglPipelineLayer *authority =
- _cogl_pipeline_layer_get_authority
- (layer, COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT);
- CoglPipelineLayerBigState *big_state = authority->big_state;
-
- GE (ctx, glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR,
- big_state->texture_combine_constant));
- }
-
- return TRUE;
-}
-
-static CoglBool
-get_highest_unit_index_cb (CoglPipelineLayer *layer,
- void *user_data)
-{
- int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
- int *highest_index = user_data;
-
- *highest_index = unit_index;
-
- return TRUE;
-}
-
-static CoglBool
-_cogl_pipeline_fragend_fixed_end (CoglPipeline *pipeline,
- unsigned long pipelines_difference)
-{
- int highest_unit_index = -1;
- int i;
-
- _COGL_GET_CONTEXT (ctx, FALSE);
-
- _cogl_pipeline_foreach_layer_internal (pipeline,
- get_highest_unit_index_cb,
- &highest_unit_index);
-
- /* Disable additional texture units that may have previously been in use.. */
- for (i = highest_unit_index + 1; i < ctx->texture_units->len; i++)
- _cogl_disable_texture_unit (i);
-
- return TRUE;
-}
-
-const CoglPipelineFragend _cogl_pipeline_fixed_fragend =
-{
- _cogl_pipeline_fragend_fixed_start,
- _cogl_pipeline_fragend_fixed_add_layer,
- NULL, /* passthrough */
- _cogl_pipeline_fragend_fixed_end,
- NULL, /* pipeline_change_notify */
- NULL, /* pipeline_set_parent_notify */
- NULL, /* layer_change_notify */
-};
-
-#endif /* COGL_PIPELINE_FRAGEND_FIXED */
-
diff --git a/cogl/driver/gl/cogl-pipeline-fragend-glsl.c b/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
index db05154f..502ab616 100644
--- a/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
+++ b/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
@@ -1030,10 +1030,7 @@ _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline,
u_string_append (shader_state->source,
" cogl_color_out = cogl_color_in;\n");
-#if defined(HAVE_COGL_GLES2) || defined (HAVE_COGL_GL)
- if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_ALPHA_TEST))
- add_alpha_test_snippet (pipeline, shader_state);
-#endif
+ add_alpha_test_snippet (pipeline, shader_state);
/* Close the function surrounding the generated fragment processing */
u_string_append (shader_state->source, "}\n");
diff --git a/cogl/driver/gl/cogl-pipeline-opengl-private.h b/cogl/driver/gl/cogl-pipeline-opengl-private.h
index b8a7e171..06da5006 100644
--- a/cogl/driver/gl/cogl-pipeline-opengl-private.h
+++ b/cogl/driver/gl/cogl-pipeline-opengl-private.h
@@ -154,5 +154,8 @@ _cogl_pipeline_flush_gl_state (CoglContext *context,
CoglBool skip_gl_state,
CoglBool unknown_color_alpha);
+void
+_cogl_gl_use_program (CoglContext *context, GLuint gl_program);
+
#endif /* __COGL_PIPELINE_OPENGL_PRIVATE_H */
diff --git a/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/driver/gl/cogl-pipeline-opengl.c
index 81260fbc..ade94d19 100644
--- a/cogl/driver/gl/cogl-pipeline-opengl.c
+++ b/cogl/driver/gl/cogl-pipeline-opengl.c
@@ -246,11 +246,9 @@ _cogl_pipeline_texture_storage_change_notify (CoglTexture *texture)
}
}
-static void
-set_glsl_program (GLuint gl_program)
+void
+_cogl_gl_use_program (CoglContext *ctx, GLuint gl_program)
{
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
if (ctx->current_gl_program != gl_program)
{
GLenum gl_error;
@@ -268,104 +266,6 @@ set_glsl_program (GLuint gl_program)
}
}
-void
-_cogl_use_fragment_program (GLuint gl_program, CoglPipelineProgramType type)
-{
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- /* If we're changing program type... */
- if (type != ctx->current_fragment_program_type)
- {
- /* ... disable the old type */
- switch (ctx->current_fragment_program_type)
- {
- case COGL_PIPELINE_PROGRAM_TYPE_GLSL:
- /* If the program contains a vertex shader then we shouldn't
- disable it */
- if (ctx->current_vertex_program_type !=
- COGL_PIPELINE_PROGRAM_TYPE_GLSL)
- set_glsl_program (0);
- break;
-
- case COGL_PIPELINE_PROGRAM_TYPE_FIXED:
- /* don't need to to anything */
- break;
- }
-
- /* ... and enable the new type */
- switch (type)
- {
- case COGL_PIPELINE_PROGRAM_TYPE_GLSL:
- case COGL_PIPELINE_PROGRAM_TYPE_FIXED:
- /* don't need to to anything */
- break;
- }
- }
-
- if (type == COGL_PIPELINE_PROGRAM_TYPE_GLSL)
- {
-#ifdef COGL_PIPELINE_FRAGEND_GLSL
- set_glsl_program (gl_program);
-
-#else
-
- u_warning ("Unexpected use of GLSL fragend!");
-
-#endif /* COGL_PIPELINE_FRAGEND_GLSL */
- }
-
- ctx->current_fragment_program_type = type;
-}
-
-void
-_cogl_use_vertex_program (GLuint gl_program, CoglPipelineProgramType type)
-{
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- /* If we're changing program type... */
- if (type != ctx->current_vertex_program_type)
- {
- /* ... disable the old type */
- switch (ctx->current_vertex_program_type)
- {
- case COGL_PIPELINE_PROGRAM_TYPE_GLSL:
- /* If the program contains a fragment shader then we shouldn't
- disable it */
- if (ctx->current_fragment_program_type !=
- COGL_PIPELINE_PROGRAM_TYPE_GLSL)
- set_glsl_program (0);
- break;
-
- case COGL_PIPELINE_PROGRAM_TYPE_FIXED:
- /* don't need to to anything */
- break;
- }
-
- /* ... and enable the new type */
- switch (type)
- {
- case COGL_PIPELINE_PROGRAM_TYPE_GLSL:
- case COGL_PIPELINE_PROGRAM_TYPE_FIXED:
- /* don't need to to anything */
- break;
- }
- }
-
- if (type == COGL_PIPELINE_PROGRAM_TYPE_GLSL)
- {
-#ifdef COGL_PIPELINE_VERTEND_GLSL
- set_glsl_program (gl_program);
-
-#else
-
- u_warning ("Unexpected use of GLSL vertend!");
-
-#endif /* COGL_PIPELINE_VERTEND_GLSL */
- }
-
- ctx->current_vertex_program_type = type;
-}
-
#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL)
static CoglBool
@@ -458,213 +358,9 @@ UNIT_TEST (check_gl_blend_enable,
u_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0);
}
-static void
-_cogl_pipeline_flush_color_blend_alpha_depth_state (
- CoglPipeline *pipeline,
- unsigned long pipelines_difference,
- CoglBool with_color_attrib)
-{
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- /* On GLES2 we'll flush the color later */
- if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED) &&
- !with_color_attrib)
- {
- if ((pipelines_difference & COGL_PIPELINE_STATE_COLOR) ||
- /* Assume if we were previously told to skip the color, then
- * the current color needs updating... */
- ctx->current_pipeline_with_color_attrib)
- {
- CoglPipeline *authority =
- _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR);
- GE (ctx, glColor4ub (cogl_color_get_red_byte (&authority->color),
- cogl_color_get_green_byte (&authority->color),
- cogl_color_get_blue_byte (&authority->color),
- cogl_color_get_alpha_byte (&authority->color)));
- }
- }
-
- if (pipelines_difference & COGL_PIPELINE_STATE_BLEND)
- {
- CoglPipeline *authority =
- _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_BLEND);
- CoglPipelineBlendState *blend_state =
- &authority->big_state->blend_state;
-
- if (blend_factor_uses_constant (blend_state->blend_src_factor_rgb) ||
- blend_factor_uses_constant (blend_state
- ->blend_src_factor_alpha) ||
- blend_factor_uses_constant (blend_state->blend_dst_factor_rgb) ||
- blend_factor_uses_constant (blend_state->blend_dst_factor_alpha))
- {
- float red =
- cogl_color_get_red_float (&blend_state->blend_constant);
- float green =
- cogl_color_get_green_float (&blend_state->blend_constant);
- float blue =
- cogl_color_get_blue_float (&blend_state->blend_constant);
- float alpha =
- cogl_color_get_alpha_float (&blend_state->blend_constant);
-
-
- GE (ctx, glBlendColor (red, green, blue, alpha));
- }
-
- if (ctx->glBlendEquationSeparate &&
- blend_state->blend_equation_rgb !=
- blend_state->blend_equation_alpha)
- GE (ctx,
- glBlendEquationSeparate (blend_state->blend_equation_rgb,
- blend_state->blend_equation_alpha));
- else
- GE (ctx, glBlendEquation (blend_state->blend_equation_rgb));
-
- if (ctx->glBlendFuncSeparate &&
- (blend_state->blend_src_factor_rgb !=
- blend_state->blend_src_factor_alpha ||
- (blend_state->blend_dst_factor_rgb !=
- blend_state->blend_dst_factor_alpha)))
- GE (ctx, glBlendFuncSeparate (blend_state->blend_src_factor_rgb,
- blend_state->blend_dst_factor_rgb,
- blend_state->blend_src_factor_alpha,
- blend_state->blend_dst_factor_alpha));
- else
- GE (ctx, glBlendFunc (blend_state->blend_src_factor_rgb,
- blend_state->blend_dst_factor_rgb));
- }
-
-#if defined (HAVE_COGL_GL)
-
- if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_ALPHA_TEST))
- {
- /* Under GLES2 the alpha function is implemented as part of the
- fragment shader */
- if (pipelines_difference & (COGL_PIPELINE_STATE_ALPHA_FUNC |
- COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE))
- {
- CoglPipeline *authority =
- _cogl_pipeline_get_authority (pipeline,
- COGL_PIPELINE_STATE_ALPHA_FUNC);
- CoglPipelineAlphaFuncState *alpha_state =
- &authority->big_state->alpha_state;
-
- /* NB: Currently the Cogl defines are compatible with the GL ones: */
- GE (ctx, glAlphaFunc (alpha_state->alpha_func,
- alpha_state->alpha_func_reference));
- }
- }
-
-#endif
-
- if (pipelines_difference & COGL_PIPELINE_STATE_DEPTH)
- {
- CoglPipeline *authority =
- _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH);
- CoglDepthState *depth_state = &authority->big_state->depth_state;
-
- flush_depth_state (ctx, depth_state);
- }
-
- if (pipelines_difference & COGL_PIPELINE_STATE_LOGIC_OPS)
- {
- CoglPipeline *authority =
- _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LOGIC_OPS);
- CoglPipelineLogicOpsState *logic_ops_state = &authority->big_state->logic_ops_state;
- CoglColorMask color_mask = logic_ops_state->color_mask;
-
- if (ctx->current_draw_buffer)
- color_mask &= ctx->current_draw_buffer->color_mask;
-
- GE (ctx, glColorMask (!!(color_mask & COGL_COLOR_MASK_RED),
- !!(color_mask & COGL_COLOR_MASK_GREEN),
- !!(color_mask & COGL_COLOR_MASK_BLUE),
- !!(color_mask & COGL_COLOR_MASK_ALPHA)));
- ctx->current_gl_color_mask = color_mask;
- }
-
- if (pipelines_difference & COGL_PIPELINE_STATE_CULL_FACE)
- {
- CoglPipeline *authority =
- _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_CULL_FACE);
- CoglPipelineCullFaceState *cull_face_state
- = &authority->big_state->cull_face_state;
-
- if (cull_face_state->mode == COGL_PIPELINE_CULL_FACE_MODE_NONE)
- GE( ctx, glDisable (GL_CULL_FACE) );
- else
- {
- CoglBool invert_winding;
-
- GE( ctx, glEnable (GL_CULL_FACE) );
-
- switch (cull_face_state->mode)
- {
- case COGL_PIPELINE_CULL_FACE_MODE_NONE:
- u_assert_not_reached ();
-
- case COGL_PIPELINE_CULL_FACE_MODE_FRONT:
- GE( ctx, glCullFace (GL_FRONT) );
- break;
-
- case COGL_PIPELINE_CULL_FACE_MODE_BACK:
- GE( ctx, glCullFace (GL_BACK) );
- break;
-
- case COGL_PIPELINE_CULL_FACE_MODE_BOTH:
- GE( ctx, glCullFace (GL_FRONT_AND_BACK) );
- break;
- }
-
- /* If we are painting to an offscreen framebuffer then we
- need to invert the winding of the front face because
- everything is painted upside down */
- invert_winding = cogl_is_offscreen (ctx->current_draw_buffer);
-
- switch (cull_face_state->front_winding)
- {
- case COGL_WINDING_CLOCKWISE:
- GE( ctx, glFrontFace (invert_winding ? GL_CCW : GL_CW) );
- break;
-
- case COGL_WINDING_COUNTER_CLOCKWISE:
- GE( ctx, glFrontFace (invert_winding ? GL_CW : GL_CCW) );
- break;
- }
- }
- }
-
-#ifdef HAVE_COGL_GL
- if (_cogl_has_private_feature
- (ctx, COGL_PRIVATE_FEATURE_ENABLE_PROGRAM_POINT_SIZE) &&
- (pipelines_difference & COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE))
- {
- unsigned long state = COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE;
- CoglPipeline *authority = _cogl_pipeline_get_authority (pipeline, state);
-
- if (authority->big_state->per_vertex_point_size)
- GE( ctx, glEnable (GL_PROGRAM_POINT_SIZE) );
- else
- GE( ctx, glDisable (GL_PROGRAM_POINT_SIZE) );
- }
-#endif
-
- if (pipeline->real_blend_enable != ctx->gl_blend_enable_cache)
- {
- if (pipeline->real_blend_enable)
- GE (ctx, glEnable (GL_BLEND));
- else
- GE (ctx, glDisable (GL_BLEND));
- /* XXX: we shouldn't update any other blend state if blending
- * is disabled! */
- ctx->gl_blend_enable_cache = pipeline->real_blend_enable;
- }
-}
-
static int
-get_max_activateable_texture_units (void)
+get_max_activateable_texture_units (CoglContext *ctx)
{
- _COGL_GET_CONTEXT (ctx, 0);
-
if (U_UNLIKELY (ctx->max_activateable_texture_units == -1))
{
GLint values[3];
@@ -694,8 +390,7 @@ get_max_activateable_texture_units (void)
#endif /* HAVE_COGL_GL */
#ifdef HAVE_COGL_GLES2
- if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_EMBEDDED) &&
- _cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE))
+ if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_EMBEDDED))
{
GE (ctx, glGetIntegerv (GL_MAX_VERTEX_ATTRIBS, values + n_values));
/* Two of the vertex attribs need to be used for the position
@@ -707,20 +402,6 @@ get_max_activateable_texture_units (void)
}
#endif
-#if defined (HAVE_COGL_GL)
- if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED))
- {
- /* GL_MAX_TEXTURE_UNITS defines the number of units that are
- usable from the fixed function pipeline, therefore it isn't
- available in GLES2. These are also tied to the number of
- texture coordinates that can be uploaded so it should be less
- than that available from the shader extensions */
- GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_UNITS,
- values + n_values++));
-
- }
-#endif
-
u_assert (n_values <= U_N_ELEMENTS (values) &&
n_values > 0);
@@ -736,6 +417,7 @@ get_max_activateable_texture_units (void)
typedef struct
{
+ CoglContext *ctx;
int i;
unsigned long *layer_differences;
} CoglPipelineFlushLayerState;
@@ -744,17 +426,16 @@ static CoglBool
flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
{
CoglPipelineFlushLayerState *flush_state = user_data;
- int unit_index = flush_state->i;
- CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index);
- unsigned long layers_difference =
+ CoglContext *ctx = flush_state->ctx;
+ int unit_index = flush_state->i;
+ CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index);
+ unsigned long layers_difference =
flush_state->layer_differences[unit_index];
- _COGL_GET_CONTEXT (ctx, FALSE);
-
/* There may not be enough texture units so we can bail out if
* that's the case...
*/
- if (U_UNLIKELY (unit_index >= get_max_activateable_texture_units ()))
+ if (U_UNLIKELY (unit_index >= get_max_activateable_texture_units (ctx)))
{
static CoglBool shown_warning = FALSE;
@@ -847,27 +528,6 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
GE( ctx, glBindSampler (unit_index, sampler_state->sampler_object) );
}
- /* FIXME: If using GLSL the progend we will use gl_PointCoord
- * instead of us needing to replace the texture coordinates but at
- * this point we can't currently tell if we are using the fixed or
- * glsl progend.
- */
-#if defined (HAVE_COGL_GL)
- if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED) &&
- (layers_difference & COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS))
- {
- CoglPipelineState change = COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS;
- CoglPipelineLayer *authority =
- _cogl_pipeline_layer_get_authority (layer, change);
- CoglPipelineLayerBigState *big_state = authority->big_state;
-
- _cogl_set_active_texture_unit (unit_index);
-
- GE (ctx, glTexEnvi (GL_POINT_SPRITE, GL_COORD_REPLACE,
- big_state->point_sprite_coords));
- }
-#endif
-
cogl_object_ref (layer);
if (unit->layer != NULL)
cogl_object_unref (unit->layer);
@@ -881,19 +541,167 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
}
static void
-_cogl_pipeline_flush_common_gl_state (CoglPipeline *pipeline,
- unsigned long pipelines_difference,
+_cogl_pipeline_flush_common_gl_state (CoglContext *ctx,
+ CoglPipeline *pipeline,
+ unsigned long pipelines_difference,
unsigned long *layer_differences,
- CoglBool with_color_attrib)
+ CoglBool with_color_attrib)
{
CoglPipelineFlushLayerState state;
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+ if (pipelines_difference & COGL_PIPELINE_STATE_BLEND)
+ {
+ CoglPipeline *authority =
+ _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_BLEND);
+ CoglPipelineBlendState *blend_state =
+ &authority->big_state->blend_state;
+
+ if (blend_factor_uses_constant (blend_state->blend_src_factor_rgb) ||
+ blend_factor_uses_constant (blend_state
+ ->blend_src_factor_alpha) ||
+ blend_factor_uses_constant (blend_state->blend_dst_factor_rgb) ||
+ blend_factor_uses_constant (blend_state->blend_dst_factor_alpha))
+ {
+ float red =
+ cogl_color_get_red_float (&blend_state->blend_constant);
+ float green =
+ cogl_color_get_green_float (&blend_state->blend_constant);
+ float blue =
+ cogl_color_get_blue_float (&blend_state->blend_constant);
+ float alpha =
+ cogl_color_get_alpha_float (&blend_state->blend_constant);
+
+
+ GE (ctx, glBlendColor (red, green, blue, alpha));
+ }
+
+ if (ctx->glBlendEquationSeparate &&
+ blend_state->blend_equation_rgb !=
+ blend_state->blend_equation_alpha)
+ GE (ctx,
+ glBlendEquationSeparate (blend_state->blend_equation_rgb,
+ blend_state->blend_equation_alpha));
+ else
+ GE (ctx, glBlendEquation (blend_state->blend_equation_rgb));
+
+ if (ctx->glBlendFuncSeparate &&
+ (blend_state->blend_src_factor_rgb !=
+ blend_state->blend_src_factor_alpha ||
+ (blend_state->blend_dst_factor_rgb !=
+ blend_state->blend_dst_factor_alpha)))
+ GE (ctx, glBlendFuncSeparate (blend_state->blend_src_factor_rgb,
+ blend_state->blend_dst_factor_rgb,
+ blend_state->blend_src_factor_alpha,
+ blend_state->blend_dst_factor_alpha));
+ else
+ GE (ctx, glBlendFunc (blend_state->blend_src_factor_rgb,
+ blend_state->blend_dst_factor_rgb));
+ }
+
+ if (pipelines_difference & COGL_PIPELINE_STATE_DEPTH)
+ {
+ CoglPipeline *authority =
+ _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH);
+ CoglDepthState *depth_state = &authority->big_state->depth_state;
- _cogl_pipeline_flush_color_blend_alpha_depth_state (pipeline,
- pipelines_difference,
- with_color_attrib);
+ flush_depth_state (ctx, depth_state);
+ }
+ if (pipelines_difference & COGL_PIPELINE_STATE_LOGIC_OPS)
+ {
+ CoglPipeline *authority =
+ _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LOGIC_OPS);
+ CoglPipelineLogicOpsState *logic_ops_state = &authority->big_state->logic_ops_state;
+ CoglColorMask color_mask = logic_ops_state->color_mask;
+
+ if (ctx->current_draw_buffer)
+ color_mask &= ctx->current_draw_buffer->color_mask;
+
+ GE (ctx, glColorMask (!!(color_mask & COGL_COLOR_MASK_RED),
+ !!(color_mask & COGL_COLOR_MASK_GREEN),
+ !!(color_mask & COGL_COLOR_MASK_BLUE),
+ !!(color_mask & COGL_COLOR_MASK_ALPHA)));
+ ctx->current_gl_color_mask = color_mask;
+ }
+
+ if (pipelines_difference & COGL_PIPELINE_STATE_CULL_FACE)
+ {
+ CoglPipeline *authority =
+ _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_CULL_FACE);
+ CoglPipelineCullFaceState *cull_face_state
+ = &authority->big_state->cull_face_state;
+
+ if (cull_face_state->mode == COGL_PIPELINE_CULL_FACE_MODE_NONE)
+ GE( ctx, glDisable (GL_CULL_FACE) );
+ else
+ {
+ CoglBool invert_winding;
+
+ GE( ctx, glEnable (GL_CULL_FACE) );
+
+ switch (cull_face_state->mode)
+ {
+ case COGL_PIPELINE_CULL_FACE_MODE_NONE:
+ u_assert_not_reached ();
+
+ case COGL_PIPELINE_CULL_FACE_MODE_FRONT:
+ GE( ctx, glCullFace (GL_FRONT) );
+ break;
+
+ case COGL_PIPELINE_CULL_FACE_MODE_BACK:
+ GE( ctx, glCullFace (GL_BACK) );
+ break;
+
+ case COGL_PIPELINE_CULL_FACE_MODE_BOTH:
+ GE( ctx, glCullFace (GL_FRONT_AND_BACK) );
+ break;
+ }
+
+ /* If we are painting to an offscreen framebuffer then we
+ need to invert the winding of the front face because
+ everything is painted upside down */
+ invert_winding = cogl_is_offscreen (ctx->current_draw_buffer);
+
+ switch (cull_face_state->front_winding)
+ {
+ case COGL_WINDING_CLOCKWISE:
+ GE( ctx, glFrontFace (invert_winding ? GL_CCW : GL_CW) );
+ break;
+
+ case COGL_WINDING_COUNTER_CLOCKWISE:
+ GE( ctx, glFrontFace (invert_winding ? GL_CW : GL_CCW) );
+ break;
+ }
+ }
+ }
+
+#ifdef HAVE_COGL_GL
+ if (_cogl_has_private_feature
+ (ctx, COGL_PRIVATE_FEATURE_ENABLE_PROGRAM_POINT_SIZE) &&
+ (pipelines_difference & COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE))
+ {
+ unsigned long state = COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE;
+ CoglPipeline *authority = _cogl_pipeline_get_authority (pipeline, state);
+
+ if (authority->big_state->per_vertex_point_size)
+ GE( ctx, glEnable (GL_PROGRAM_POINT_SIZE) );
+ else
+ GE( ctx, glDisable (GL_PROGRAM_POINT_SIZE) );
+ }
+#endif
+
+ if (pipeline->real_blend_enable != ctx->gl_blend_enable_cache)
+ {
+ if (pipeline->real_blend_enable)
+ GE (ctx, glEnable (GL_BLEND));
+ else
+ GE (ctx, glDisable (GL_BLEND));
+ /* XXX: we shouldn't update any other blend state if blending
+ * is disabled! */
+ ctx->gl_blend_enable_cache = pipeline->real_blend_enable;
+ }
+
+ state.ctx = ctx;
state.i = 0;
state.layer_differences = layer_differences;
_cogl_pipeline_foreach_layer_internal (pipeline,
@@ -1252,7 +1060,8 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx,
* all state of the layers corresponding texture unit to be
* updated.
*/
- _cogl_pipeline_flush_common_gl_state (pipeline,
+ _cogl_pipeline_flush_common_gl_state (ctx,
+ pipeline,
pipelines_difference,
layer_differences,
with_color_attrib);
@@ -1344,12 +1153,9 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx,
break;
}
-#ifdef COGL_ENABLE_DEBUG
- /* XXX: Since the GLSL progend should be able to handle all features
- * we should only hit this case if glsl was disabled for debugging
- * and we tried to flush a pipeline that requires GLSL. */
+ /* Since the NOP progend will claim to handle anything we should
+ * never fall through without finding a suitable progend */
g_assert (i != COGL_PIPELINE_N_PROGENDS);
-#endif
/* FIXME: This reference is actually resulting in lots of
* copy-on-write reparenting because one-shot pipelines end up
diff --git a/cogl/driver/gl/cogl-pipeline-progend-fixed.c b/cogl/driver/gl/cogl-pipeline-progend-fixed.c
deleted file mode 100644
index f56e11f5..00000000
--- a/cogl/driver/gl/cogl-pipeline-progend-fixed.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Cogl
- *
- * A Low-Level GPU Graphics and Utilities API
- *
- * Copyright (C) 2011 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- *
- *
- * Authors:
- * Neil Roberts <neil@linux.intel.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "cogl-pipeline-private.h"
-#include "cogl-pipeline-state-private.h"
-
-#ifdef COGL_PIPELINE_PROGEND_FIXED
-
-#include "cogl-context.h"
-#include "cogl-context-private.h"
-#include "cogl-framebuffer-private.h"
-
-static CoglBool
-_cogl_pipeline_progend_fixed_start (CoglPipeline *pipeline)
-{
- _COGL_GET_CONTEXT (ctx, FALSE);
-
- if (U_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED)))
- return FALSE;
-
- if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED))
- return FALSE;
-
- /* Vertex snippets are only supported in the GLSL fragend */
- if (_cogl_pipeline_has_vertex_snippets (pipeline))
- return FALSE;
-
- /* Fragment snippets are only supported in the GLSL fragend */
- if (_cogl_pipeline_has_fragment_snippets (pipeline))
- return FALSE;
-
- /* The fixed progend can't handle the per-vertex point size
- * attribute */
- if (cogl_pipeline_get_per_vertex_point_size (pipeline))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-_cogl_pipeline_progend_fixed_pre_paint (CoglPipeline *pipeline,
- CoglFramebuffer *framebuffer)
-{
- CoglContext *ctx = framebuffer->context;
-
- if (ctx->current_projection_entry)
- _cogl_matrix_entry_flush_to_gl_builtins (ctx,
- ctx->current_projection_entry,
- COGL_MATRIX_PROJECTION,
- framebuffer,
- FALSE /* enable flip */);
- if (ctx->current_modelview_entry)
- _cogl_matrix_entry_flush_to_gl_builtins (ctx,
- ctx->current_modelview_entry,
- COGL_MATRIX_MODELVIEW,
- framebuffer,
- FALSE /* enable flip */);
-}
-
-const CoglPipelineProgend _cogl_pipeline_fixed_progend =
- {
- COGL_PIPELINE_VERTEND_FIXED,
- COGL_PIPELINE_FRAGEND_FIXED,
- _cogl_pipeline_progend_fixed_start,
- NULL, /* end */
- NULL, /* pre_change_notify */
- NULL, /* layer_pre_change_notify */
- _cogl_pipeline_progend_fixed_pre_paint
- };
-
-#endif /* COGL_PIPELINE_PROGEND_FIXED */
diff --git a/cogl/driver/gl/cogl-pipeline-progend-glsl.c b/cogl/driver/gl/cogl-pipeline-progend-glsl.c
index 9e88fe47..1c8b1507 100644
--- a/cogl/driver/gl/cogl-pipeline-progend-glsl.c
+++ b/cogl/driver/gl/cogl-pipeline-progend-glsl.c
@@ -60,11 +60,13 @@
required when building for drivers missing some fixed function
state that we use */
-typedef void (* UpdateUniformFunc) (CoglPipeline *pipeline,
+typedef void (* UpdateUniformFunc) (CoglContext *ctx,
+ CoglPipeline *pipeline,
int uniform_location,
void *getter_func);
-static void update_float_uniform (CoglPipeline *pipeline,
+static void update_float_uniform (CoglContext *ctx,
+ CoglPipeline *pipeline,
int uniform_location,
void *getter_func);
@@ -89,7 +91,8 @@ static BuiltinUniformData builtin_uniforms[] =
{ "_cogl_alpha_test_ref",
cogl_pipeline_get_alpha_test_reference, update_float_uniform,
COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE,
- COGL_PRIVATE_FEATURE_ALPHA_TEST }
+ COGL_N_PRIVATE_FEATURES } /* XXX: used as a non-existent "feature"
+ * that will never be found. */
};
const CoglPipelineProgend _cogl_pipeline_glsl_progend;
@@ -103,6 +106,8 @@ typedef struct _UnitState
typedef struct
{
+ CoglContext *ctx;
+
unsigned int ref_count;
GLuint program;
@@ -228,12 +233,14 @@ clear_flushed_matrix_stacks (CoglPipelineProgramState *program_state)
}
static CoglPipelineProgramState *
-program_state_new (int n_layers,
+program_state_new (CoglContext *ctx,
+ int n_layers,
CoglPipelineCacheEntry *cache_entry)
{
CoglPipelineProgramState *program_state;
program_state = u_slice_new (CoglPipelineProgramState);
+ program_state->ctx = ctx;
program_state->ref_count = 1;
program_state->program = 0;
program_state->unit_state = u_new (UnitState, n_layers);
@@ -252,8 +259,6 @@ destroy_program_state (void *user_data,
{
CoglPipelineProgramState *program_state = user_data;
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
/* If the program state was last used for this pipeline then clear
it so that if same address gets used again for a new pipeline
then we won't think it's the same pipeline and avoid updating the
@@ -267,6 +272,8 @@ destroy_program_state (void *user_data,
if (--program_state->ref_count == 0)
{
+ CoglContext *ctx = program_state->ctx;
+
clear_attribute_cache (program_state);
_cogl_matrix_entry_cache_destroy (&program_state->projection_cache);
@@ -315,12 +322,10 @@ dirty_program_state (CoglPipeline *pipeline)
}
static void
-link_program (GLint gl_program)
+link_program (CoglContext *ctx, GLint gl_program)
{
GLint link_status;
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
GE( ctx, glLinkProgram (gl_program) );
GE( ctx, glGetProgramiv (gl_program, GL_LINK_STATUS, &link_status) );
@@ -347,6 +352,7 @@ link_program (GLint gl_program)
typedef struct
{
+ CoglContext *ctx;
int unit;
GLuint gl_program;
CoglBool update_all;
@@ -359,12 +365,11 @@ get_uniform_cb (CoglPipeline *pipeline,
void *user_data)
{
UpdateUniformsState *state = user_data;
+ CoglContext *ctx = state->ctx;
CoglPipelineProgramState *program_state = state->program_state;
UnitState *unit_state = &program_state->unit_state[state->unit];
GLint uniform_location;
- _COGL_GET_CONTEXT (ctx, FALSE);
-
/* We can reuse the source buffer to create the uniform name because
the program has now been linked */
u_string_set_size (ctx->codegen_source_buffer, 0);
@@ -403,11 +408,10 @@ update_constants_cb (CoglPipeline *pipeline,
void *user_data)
{
UpdateUniformsState *state = user_data;
+ CoglContext *ctx = state->ctx;
CoglPipelineProgramState *program_state = state->program_state;
UnitState *unit_state = &program_state->unit_state[state->unit++];
- _COGL_GET_CONTEXT (ctx, FALSE);
-
if (unit_state->combine_constant_uniform != -1 &&
(state->update_all || unit_state->dirty_combine_constant))
{
@@ -435,14 +439,19 @@ update_builtin_uniforms (CoglContext *context,
return;
for (i = 0; i < U_N_ELEMENTS (builtin_uniforms); i++)
- if (!_cogl_has_private_feature (context,
- builtin_uniforms[i].feature_replacement) &&
- (program_state->dirty_builtin_uniforms & (1 << i)) &&
- program_state->builtin_uniform_locations[i] != -1)
- builtin_uniforms[i].update_func (pipeline,
- program_state
- ->builtin_uniform_locations[i],
- builtin_uniforms[i].getter_func);
+ {
+ if (!_cogl_has_private_feature (context,
+ builtin_uniforms[i].feature_replacement) &&
+ (program_state->dirty_builtin_uniforms & (1 << i)) &&
+ program_state->builtin_uniform_locations[i] != -1)
+ {
+ builtin_uniforms[i].update_func (context,
+ pipeline,
+ program_state
+ ->builtin_uniform_locations[i],
+ builtin_uniforms[i].getter_func);
+ }
+ }
program_state->dirty_builtin_uniforms = 0;
}
@@ -516,7 +525,8 @@ flush_uniform_cb (int uniform_num, void *user_data)
}
static void
-_cogl_pipeline_progend_glsl_flush_uniforms (CoglPipeline *pipeline,
+_cogl_pipeline_progend_glsl_flush_uniforms (CoglContext *ctx,
+ CoglPipeline *pipeline,
CoglPipelineProgramState *
program_state,
GLuint gl_program,
@@ -526,8 +536,6 @@ _cogl_pipeline_progend_glsl_flush_uniforms (CoglPipeline *pipeline,
FlushUniformsClosure data;
int n_uniform_longs;
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
if (pipeline->differences & COGL_PIPELINE_STATE_UNIFORMS)
uniforms_state = &pipeline->big_state->uniforms_state;
else
@@ -668,7 +676,8 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
program_state->ref_count++;
else
program_state
- = program_state_new (cogl_pipeline_get_n_layers (authority),
+ = program_state_new (ctx,
+ cogl_pipeline_get_n_layers (authority),
cache_entry);
set_program_state (authority, program_state);
@@ -702,16 +711,16 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
GE( ctx, glBindAttribLocation (program_state->program,
0, "cogl_position_in"));
- link_program (program_state->program);
+ link_program (ctx, program_state->program);
program_changed = TRUE;
}
gl_program = program_state->program;
- _cogl_use_fragment_program (gl_program, COGL_PIPELINE_PROGRAM_TYPE_GLSL);
- _cogl_use_vertex_program (gl_program, COGL_PIPELINE_PROGRAM_TYPE_GLSL);
+ _cogl_gl_use_program (ctx, gl_program);
+ state.ctx = ctx;
state.unit = 0;
state.gl_program = gl_program;
state.program_state = program_state;
@@ -768,7 +777,8 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
update_builtin_uniforms (ctx, pipeline, gl_program, program_state);
- _cogl_pipeline_progend_glsl_flush_uniforms (pipeline,
+ _cogl_pipeline_progend_glsl_flush_uniforms (ctx,
+ pipeline,
program_state,
gl_program,
program_changed);
@@ -964,15 +974,14 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline,
}
static void
-update_float_uniform (CoglPipeline *pipeline,
+update_float_uniform (CoglContext *ctx,
+ CoglPipeline *pipeline,
int uniform_location,
void *getter_func)
{
float (* float_getter_func) (CoglPipeline *) = getter_func;
float value;
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
value = float_getter_func (pipeline);
GE( ctx, glUniform1f (uniform_location, value) );
}
diff --git a/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/driver/gl/gl/cogl-driver-gl.c
index 3ec109bc..fb79a616 100644
--- a/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -591,19 +591,10 @@ _cogl_driver_update_features (CoglContext *ctx,
if (ctx->driver == COGL_DRIVER_GL)
{
- int max_clip_planes = 0;
-
/* Features which are not available in GL 3 */
- COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_GL_FIXED, TRUE);
- COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_ALPHA_TEST, TRUE);
COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_QUADS, TRUE);
COGL_FLAGS_SET (private_features,
COGL_PRIVATE_FEATURE_ALPHA_TEXTURES, TRUE);
-
- GE( ctx, glGetIntegerv (GL_MAX_CLIP_PLANES, &max_clip_planes) );
- if (max_clip_planes >= 4)
- COGL_FLAGS_SET (private_features,
- COGL_PRIVATE_FEATURE_FOUR_CLIP_PLANES, TRUE);
}
COGL_FLAGS_SET (private_features,
diff --git a/cogl/driver/gl/cogl-pipeline-vertend-fixed-private.h b/cogl/driver/nop/cogl-pipeline-fragend-nop-private.h
index a6860eaf..2e52b767 100644
--- a/cogl/driver/gl/cogl-pipeline-vertend-fixed-private.h
+++ b/cogl/driver/nop/cogl-pipeline-fragend-nop-private.h
@@ -3,7 +3,7 @@
*
* A Low-Level GPU Graphics and Utilities API
*
- * Copyright (C) 2010 Intel Corporation.
+ * Copyright (C) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -25,18 +25,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
- *
- *
- * Authors:
- * Neil Roberts <neil@linux.intel.com>
*/
-#ifndef __COGL_PIPELINE_VERTEND_FIXED_PRIVATE_H
-#define __COGL_PIPELINE_VERTEND_FIXED_PRIVATE_H
+#ifndef __COGL_PIPELINE_FRAGEND_NOP_PRIVATE_H
+#define __COGL_PIPELINE_FRAGEND_NOP_PRIVATE_H
#include "cogl-pipeline-private.h"
-extern const CoglPipelineVertend _cogl_pipeline_fixed_vertend;
+extern const CoglPipelineFragend _cogl_pipeline_nop_fragend;
-#endif /* __COGL_PIPELINE_VERTEND_FIXED_PRIVATE_H */
+#endif /* __COGL_PIPELINE_FRAGEND_NOP_PRIVATE_H */
diff --git a/cogl/driver/nop/cogl-pipeline-fragend-nop.c b/cogl/driver/nop/cogl-pipeline-fragend-nop.c
new file mode 100644
index 00000000..99bf8705
--- /dev/null
+++ b/cogl/driver/nop/cogl-pipeline-fragend-nop.c
@@ -0,0 +1,70 @@
+/*
+ * Cogl
+ *
+ * A Low-Level GPU Graphics and Utilities API
+ *
+ * Copyright (C) 2014 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <config.h>
+
+#include "cogl-pipeline-private.h"
+
+#include <ulib.h>
+
+const CoglPipelineFragend _cogl_pipeline_nop_fragend;
+
+static void
+_cogl_pipeline_fragend_nop_start (CoglPipeline *pipeline,
+ int n_layers,
+ unsigned long pipelines_difference)
+{
+}
+
+static CoglBool
+_cogl_pipeline_fragend_nop_add_layer (CoglPipeline *pipeline,
+ CoglPipelineLayer *layer,
+ unsigned long layers_difference)
+{
+ return TRUE;
+}
+
+static CoglBool
+_cogl_pipeline_fragend_nop_end (CoglPipeline *pipeline,
+ unsigned long pipelines_difference)
+{
+ return TRUE;
+}
+
+const CoglPipelineFragend _cogl_pipeline_nop_fragend =
+{
+ _cogl_pipeline_fragend_nop_start,
+ _cogl_pipeline_fragend_nop_add_layer,
+ NULL, /* passthrough */
+ _cogl_pipeline_fragend_nop_end,
+ NULL, /* pipeline_change_notify */
+ NULL, /* pipeline_set_parent_notify */
+ NULL, /* layer_change_notify */
+};
+
diff --git a/cogl/driver/gl/cogl-pipeline-progend-fixed-private.h b/cogl/driver/nop/cogl-pipeline-progend-nop-private.h
index 578cb43f..1249d407 100644
--- a/cogl/driver/gl/cogl-pipeline-progend-fixed-private.h
+++ b/cogl/driver/nop/cogl-pipeline-progend-nop-private.h
@@ -3,7 +3,7 @@
*
* A Low-Level GPU Graphics and Utilities API
*
- * Copyright (C) 2011 Intel Corporation.
+ * Copyright (C) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -25,18 +25,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
- *
- *
- * Authors:
- * Neil Roberts <neil@linux.intel.com>
*/
-#ifndef __COGL_PIPELINE_PROGEND_FIXED_PRIVATE_H
-#define __COGL_PIPELINE_PROGEND_FIXED_PRIVATE_H
+#ifndef __COGL_PIPELINE_PROGEND_NOP_PRIVATE_H
+#define __COGL_PIPELINE_PROGEND_NOP_PRIVATE_H
#include "cogl-pipeline-private.h"
-extern const CoglPipelineProgend _cogl_pipeline_fixed_progend;
+extern const CoglPipelineProgend _cogl_pipeline_nop_progend;
-#endif /* __COGL_PIPELINE_PROGEND_FIXED_PRIVATE_H */
+#endif /* __COGL_PIPELINE_PROGEND_NOP_PRIVATE_H */
diff --git a/cogl/driver/nop/cogl-pipeline-progend-nop.c b/cogl/driver/nop/cogl-pipeline-progend-nop.c
new file mode 100644
index 00000000..1a28bd6b
--- /dev/null
+++ b/cogl/driver/nop/cogl-pipeline-progend-nop.c
@@ -0,0 +1,57 @@
+/*
+ * Cogl
+ *
+ * A Low-Level GPU Graphics and Utilities API
+ *
+ * Copyright (C) 2014 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <config.h>
+
+#include "cogl-pipeline-private.h"
+#include "cogl-framebuffer-private.h"
+
+static CoglBool
+_cogl_pipeline_progend_nop_start (CoglPipeline *pipeline)
+{
+ return TRUE;
+}
+
+static void
+_cogl_pipeline_progend_nop_pre_paint (CoglPipeline *pipeline,
+ CoglFramebuffer *framebuffer)
+{
+}
+
+const CoglPipelineProgend _cogl_pipeline_nop_progend =
+ {
+ COGL_PIPELINE_VERTEND_NOP,
+ COGL_PIPELINE_FRAGEND_NOP,
+ _cogl_pipeline_progend_nop_start,
+ NULL, /* end */
+ NULL, /* pre_change_notify */
+ NULL, /* layer_pre_change_notify */
+ _cogl_pipeline_progend_nop_pre_paint
+ };
+
diff --git a/cogl/driver/gl/cogl-pipeline-fragend-fixed-private.h b/cogl/driver/nop/cogl-pipeline-vertend-nop-private.h
index 75e28939..b7289d4b 100644
--- a/cogl/driver/gl/cogl-pipeline-fragend-fixed-private.h
+++ b/cogl/driver/nop/cogl-pipeline-vertend-nop-private.h
@@ -3,7 +3,7 @@
*
* A Low-Level GPU Graphics and Utilities API
*
- * Copyright (C) 2010 Intel Corporation.
+ * Copyright (C) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -25,18 +25,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
- *
- *
- * Authors:
- * Robert Bragg <robert@linux.intel.com>
*/
-#ifndef __COGL_PIPELINE_FRAGEND_FIXED_PRIVATE_H
-#define __COGL_PIPELINE_FRAGEND_FIXED_PRIVATE_H
+#ifndef __COGL_PIPELINE_VERTEND_NOP_PRIVATE_H
+#define __COGL_PIPELINE_VERTEND_NOP_PRIVATE_H
#include "cogl-pipeline-private.h"
-extern const CoglPipelineFragend _cogl_pipeline_fixed_fragend;
+extern const CoglPipelineVertend _cogl_pipeline_nop_vertend;
-#endif /* __COGL_PIPELINE_FRAGEND_FIXED_PRIVATE_H */
+#endif /* __COGL_PIPELINE_VERTEND_NOP_PRIVATE_H */
diff --git a/cogl/driver/gl/cogl-pipeline-vertend-fixed.c b/cogl/driver/nop/cogl-pipeline-vertend-nop.c
index 90e5f460..a87d0c41 100644
--- a/cogl/driver/gl/cogl-pipeline-vertend-fixed.c
+++ b/cogl/driver/nop/cogl-pipeline-vertend-nop.c
@@ -3,7 +3,7 @@
*
* A Low-Level GPU Graphics and Utilities API
*
- * Copyright (C) 2008,2009,2010 Intel Corporation.
+ * Copyright (C) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -25,73 +25,49 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
- *
- *
- * Authors:
- * Neil Roberts <neil@linux.intel.com>
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include <config.h>
#include "cogl-context-private.h"
-#include "cogl-util-gl-private.h"
#include "cogl-pipeline-private.h"
#include "cogl-pipeline-state-private.h"
-#include "cogl-pipeline-opengl-private.h"
#include "cogl-framebuffer-private.h"
-#ifdef COGL_PIPELINE_VERTEND_FIXED
-
#include "cogl-context-private.h"
#include "cogl-object-private.h"
-const CoglPipelineVertend _cogl_pipeline_fixed_vertend;
+const CoglPipelineVertend _cogl_pipeline_nop_vertend;
static void
-_cogl_pipeline_vertend_fixed_start (CoglPipeline *pipeline,
- int n_layers,
- unsigned long pipelines_difference)
+_cogl_pipeline_vertend_nop_start (CoglPipeline *pipeline,
+ int n_layers,
+ unsigned long pipelines_difference)
{
- _cogl_use_vertex_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED);
}
static CoglBool
-_cogl_pipeline_vertend_fixed_add_layer (CoglPipeline *pipeline,
- CoglPipelineLayer *layer,
- unsigned long layers_difference,
- CoglFramebuffer *framebuffer)
+_cogl_pipeline_vertend_nop_add_layer (CoglPipeline *pipeline,
+ CoglPipelineLayer *layer,
+ unsigned long layers_difference,
+ CoglFramebuffer *framebuffer)
{
return TRUE;
}
static CoglBool
-_cogl_pipeline_vertend_fixed_end (CoglPipeline *pipeline,
- unsigned long pipelines_difference)
+_cogl_pipeline_vertend_nop_end (CoglPipeline *pipeline,
+ unsigned long pipelines_difference)
{
- _COGL_GET_CONTEXT (ctx, FALSE);
-
- if (pipelines_difference & COGL_PIPELINE_STATE_POINT_SIZE)
- {
- CoglPipeline *authority =
- _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE);
-
- if (authority->big_state->point_size > 0.0f)
- GE( ctx, glPointSize (authority->big_state->point_size) );
- }
-
return TRUE;
}
-const CoglPipelineVertend _cogl_pipeline_fixed_vertend =
+const CoglPipelineVertend _cogl_pipeline_nop_vertend =
{
- _cogl_pipeline_vertend_fixed_start,
- _cogl_pipeline_vertend_fixed_add_layer,
- _cogl_pipeline_vertend_fixed_end,
+ _cogl_pipeline_vertend_nop_start,
+ _cogl_pipeline_vertend_nop_add_layer,
+ _cogl_pipeline_vertend_nop_end,
NULL, /* pipeline_change_notify */
NULL /* layer_change_notify */
};
-#endif /* COGL_PIPELINE_VERTEND_FIXED */
-
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index 180de357..2225c669 100755
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -88,7 +88,7 @@ printf $TITLE_FORMAT "Test"
if test $HAVE_GL -eq 1; then
GL_FORMAT=" %6s %8s %7s %6s %6s"
- printf "$GL_FORMAT" "GL+FF" "GL+GLSL" "GL-NPT" "GL3"
+ printf "$GL_FORMAT" "GL" "GL-NPT" "GL3"
fi
if test $HAVE_GLES2 -eq 1; then
GLES2_FORMAT=" %6s %7s"
@@ -104,12 +104,8 @@ do
if test $HAVE_GL -eq 1; then
export COGL_DRIVER=gl
- export COGL_DEBUG=disable-glsl
- run_test $test gl_ff
-
- export COGL_DRIVER=gl
- export COGL_DEBUG=disable-fixed
- run_test $test gl_glsl
+ export COGL_DEBUG=
+ run_test $test gl
export COGL_DRIVER=gl
export COGL_DEBUG=disable-npot-textures
@@ -133,8 +129,7 @@ do
printf $TITLE_FORMAT "$test:"
if test $HAVE_GL -eq 1; then
printf "$GL_FORMAT" \
- "`get_status $gl_ff_result`" \
- "`get_status $gl_glsl_result`" \
+ "`get_status $gl_result`" \
"`get_status $gl_npot_result`" \
"`get_status $gl3_result`"
fi