From 0b280188735dfcc1360fe6f16e647fc641ccdcc4 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 19 Nov 2010 15:42:26 +0000 Subject: [PATCH] Move need_texture_combine_separate to cogl-pipeline need_texture_combine_separate is moved to cogl-pipeline.c and renamed to _cogl_pipeline_need_texture_combine_separate. The function is needed by both the ARBfp and GLSL codegen backends so it makes sense to share it. --- cogl/cogl-pipeline-arbfp.c | 75 +----------------------------------- cogl/cogl-pipeline-private.h | 4 ++ cogl/cogl-pipeline.c | 74 +++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 74 deletions(-) diff --git a/cogl/cogl-pipeline-arbfp.c b/cogl/cogl-pipeline-arbfp.c index b6b74917d..3e19f510a 100644 --- a/cogl/cogl-pipeline-arbfp.c +++ b/cogl/cogl-pipeline-arbfp.c @@ -284,79 +284,6 @@ _cogl_pipeline_backend_arbfp_start (CoglPipeline *pipeline, return TRUE; } -/* Determines if we need to handle the RGB and A texture combining - * separately or is the same function used for both channel masks and - * with the same arguments... - */ -static gboolean -need_texture_combine_separate (CoglPipelineLayer *combine_authority) -{ - CoglPipelineLayerBigState *big_state = combine_authority->big_state; - int n_args; - int i; - - if (big_state->texture_combine_rgb_func != - big_state->texture_combine_alpha_func) - return TRUE; - - n_args = _cogl_get_n_args_for_combine_func (big_state->texture_combine_rgb_func); - - for (i = 0; i < n_args; i++) - { - if (big_state->texture_combine_rgb_src[i] != - big_state->texture_combine_alpha_src[i]) - return TRUE; - - /* - * We can allow some variation of the source operands without - * needing a separation... - * - * "A = REPLACE (CONSTANT[A])" + either of the following... - * "RGB = REPLACE (CONSTANT[RGB])" - * "RGB = REPLACE (CONSTANT[A])" - * - * can be combined as: - * "RGBA = REPLACE (CONSTANT)" or - * "RGBA = REPLACE (CONSTANT[A])" or - * - * And "A = REPLACE (1-CONSTANT[A])" + either of the following... - * "RGB = REPLACE (1-CONSTANT)" or - * "RGB = REPLACE (1-CONSTANT[A])" - * - * can be combined as: - * "RGBA = REPLACE (1-CONSTANT)" or - * "RGBA = REPLACE (1-CONSTANT[A])" - */ - switch (big_state->texture_combine_alpha_op[i]) - { - case GL_SRC_ALPHA: - switch (big_state->texture_combine_rgb_op[i]) - { - case GL_SRC_COLOR: - case GL_SRC_ALPHA: - break; - default: - return FALSE; - } - break; - case GL_ONE_MINUS_SRC_ALPHA: - switch (big_state->texture_combine_rgb_op[i]) - { - case GL_ONE_MINUS_SRC_COLOR: - case GL_ONE_MINUS_SRC_ALPHA: - break; - default: - return FALSE; - } - break; - default: - return FALSE; /* impossible */ - } - } - - return FALSE; -} - static const char * gl_target_to_arbfp_string (GLenum gl_target) { @@ -784,7 +711,7 @@ _cogl_pipeline_backend_arbfp_add_layer (CoglPipeline *pipeline, if (!arbfp_program_state->source) return TRUE; - if (!need_texture_combine_separate (combine_authority)) + if (!_cogl_pipeline_need_texture_combine_separate (combine_authority)) { append_masked_combine (pipeline, layer, diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h index c155ca3bf..333601a31 100644 --- a/cogl/cogl-pipeline-private.h +++ b/cogl/cogl-pipeline-private.h @@ -956,6 +956,10 @@ _cogl_pipeline_foreach_layer_internal (CoglPipeline *pipeline, int _cogl_pipeline_layer_get_unit_index (CoglPipelineLayer *layer); +gboolean +_cogl_pipeline_need_texture_combine_separate + (CoglPipelineLayer *combine_authority); + CoglPipeline * _cogl_pipeline_find_codegen_authority (CoglPipeline *pipeline, CoglHandle user_program); diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index 7d887d0b1..f38450add 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -5656,6 +5656,80 @@ layers_codegen_would_differ (CoglPipelineLayer **pipeline0_layers, return FALSE; } +/* Determines if we need to handle the RGB and A texture combining + * separately or is the same function used for both channel masks and + * with the same arguments... + */ +gboolean +_cogl_pipeline_need_texture_combine_separate + (CoglPipelineLayer *combine_authority) +{ + CoglPipelineLayerBigState *big_state = combine_authority->big_state; + int n_args; + int i; + + if (big_state->texture_combine_rgb_func != + big_state->texture_combine_alpha_func) + return TRUE; + + n_args = _cogl_get_n_args_for_combine_func (big_state->texture_combine_rgb_func); + + for (i = 0; i < n_args; i++) + { + if (big_state->texture_combine_rgb_src[i] != + big_state->texture_combine_alpha_src[i]) + return TRUE; + + /* + * We can allow some variation of the source operands without + * needing a separation... + * + * "A = REPLACE (CONSTANT[A])" + either of the following... + * "RGB = REPLACE (CONSTANT[RGB])" + * "RGB = REPLACE (CONSTANT[A])" + * + * can be combined as: + * "RGBA = REPLACE (CONSTANT)" or + * "RGBA = REPLACE (CONSTANT[A])" or + * + * And "A = REPLACE (1-CONSTANT[A])" + either of the following... + * "RGB = REPLACE (1-CONSTANT)" or + * "RGB = REPLACE (1-CONSTANT[A])" + * + * can be combined as: + * "RGBA = REPLACE (1-CONSTANT)" or + * "RGBA = REPLACE (1-CONSTANT[A])" + */ + switch (big_state->texture_combine_alpha_op[i]) + { + case GL_SRC_ALPHA: + switch (big_state->texture_combine_rgb_op[i]) + { + case GL_SRC_COLOR: + case GL_SRC_ALPHA: + break; + default: + return FALSE; + } + break; + case GL_ONE_MINUS_SRC_ALPHA: + switch (big_state->texture_combine_rgb_op[i]) + { + case GL_ONE_MINUS_SRC_COLOR: + case GL_ONE_MINUS_SRC_ALPHA: + break; + default: + return FALSE; + } + break; + default: + return FALSE; /* impossible */ + } + } + + return FALSE; +} + /* This tries to find the oldest ancestor whos state would generate * the same shader program as the current pipeline. This is a simple * mechanism for reducing the number of programs we have to generate.