From de8f69c7874bdb69ba09a3e296daff36b11fce5b Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Tue, 24 Oct 2023 02:10:21 +0200 Subject: [PATCH] cogl: Clean up HAVE_COGL_GL(ES2) checks These were leftovers from times when GL(ES) 1.x was still supported. As we require HAVE_COGL_GL and/or HAVE_COGL_GLES2 to be defined, all cases for checking both are now redundant. Part-of: --- cogl/cogl/cogl-pipeline-private.h | 2 - cogl/cogl/cogl-pipeline-state.c | 44 ++++++++----------- cogl/cogl/cogl-pipeline.c | 2 - cogl/cogl/cogl-renderer.c | 2 +- cogl/cogl/driver/gl/cogl-buffer-gl.c | 6 --- .../driver/gl/cogl-pipeline-fragend-glsl.c | 7 --- cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 6 --- 7 files changed, 20 insertions(+), 49 deletions(-) diff --git a/cogl/cogl/cogl-pipeline-private.h b/cogl/cogl/cogl-pipeline-private.h index 9ebc02b9d..24ca31440 100644 --- a/cogl/cogl/cogl-pipeline-private.h +++ b/cogl/cogl/cogl-pipeline-private.h @@ -181,13 +181,11 @@ typedef struct typedef struct { /* Determines how this pipeline is blended with other primitives */ -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) GLenum blend_equation_rgb; GLenum blend_equation_alpha; GLint blend_src_factor_alpha; GLint blend_dst_factor_alpha; CoglColor blend_constant; -#endif GLint blend_src_factor_rgb; GLint blend_dst_factor_rgb; } CoglPipelineBlendState; diff --git a/cogl/cogl/cogl-pipeline-state.c b/cogl/cogl/cogl-pipeline-state.c index 5f27cc9b7..900855080 100644 --- a/cogl/cogl/cogl-pipeline-state.c +++ b/cogl/cogl/cogl-pipeline-state.c @@ -547,7 +547,6 @@ arg_to_gl_blend_factor (CoglBlendStringArgument *arg) return GL_DST_ALPHA; } } -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) else if (arg->factor.source.info->type == COGL_BLEND_STRING_COLOR_SOURCE_CONSTANT) { @@ -566,7 +565,6 @@ arg_to_gl_blend_factor (CoglBlendStringArgument *arg) return GL_CONSTANT_ALPHA; } } -#endif g_warning ("Unable to determine valid blend factor from blend string\n"); return GL_ONE; @@ -679,38 +677,34 @@ void cogl_pipeline_set_blend_constant (CoglPipeline *pipeline, const CoglColor *constant_color) { + CoglPipelineState state = COGL_PIPELINE_STATE_BLEND; + CoglPipeline *authority; + CoglPipelineBlendState *blend_state; + _COGL_GET_CONTEXT (ctx, NO_RETVAL); g_return_if_fail (cogl_is_pipeline (pipeline)); -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) - { - CoglPipelineState state = COGL_PIPELINE_STATE_BLEND; - CoglPipeline *authority; - CoglPipelineBlendState *blend_state; + authority = _cogl_pipeline_get_authority (pipeline, state); - authority = _cogl_pipeline_get_authority (pipeline, state); + blend_state = &authority->big_state->blend_state; + if (cogl_color_equal (constant_color, &blend_state->blend_constant)) + return; - blend_state = &authority->big_state->blend_state; - if (cogl_color_equal (constant_color, &blend_state->blend_constant)) - return; + /* - Flush journal primitives referencing the current state. + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being + * changed, then initialize that state from the current authority. + */ + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - /* - Flush journal primitives referencing the current state. - * - Make sure the pipeline has no dependants so it may be modified. - * - If the pipeline isn't currently an authority for the state being - * changed, then initialize that state from the current authority. - */ - _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); + blend_state = &pipeline->big_state->blend_state; + blend_state->blend_constant = *constant_color; - blend_state = &pipeline->big_state->blend_state; - blend_state->blend_constant = *constant_color; + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_blend_state_equal); - _cogl_pipeline_update_authority (pipeline, authority, state, - _cogl_pipeline_blend_state_equal); - - pipeline->dirty_real_blend_enable = TRUE; - } -#endif + pipeline->dirty_real_blend_enable = TRUE; } CoglHandle diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index 22c8d955f..6409d9a2c 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -123,14 +123,12 @@ _cogl_pipeline_init_default_pipeline (void) alpha_state->alpha_func_reference = 0.0; /* Not the same as the GL default, but seems saner... */ -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) blend_state->blend_equation_rgb = GL_FUNC_ADD; blend_state->blend_equation_alpha = GL_FUNC_ADD; blend_state->blend_src_factor_alpha = GL_ONE; blend_state->blend_dst_factor_alpha = GL_ONE_MINUS_SRC_ALPHA; cogl_color_init_from_4ub (&blend_state->blend_constant, 0x00, 0x00, 0x00, 0x00); -#endif blend_state->blend_src_factor_rgb = GL_ONE; blend_state->blend_dst_factor_rgb = GL_ONE_MINUS_SRC_ALPHA; diff --git a/cogl/cogl/cogl-renderer.c b/cogl/cogl/cogl-renderer.c index a8b54e77d..3b1b08d67 100644 --- a/cogl/cogl/cogl-renderer.c +++ b/cogl/cogl/cogl-renderer.c @@ -63,7 +63,7 @@ extern const CoglTextureDriver _cogl_texture_driver_gl; extern const CoglDriverVtable _cogl_driver_gl; #endif -#if defined (HAVE_COGL_GLES2) +#ifdef HAVE_COGL_GLES2 extern const CoglTextureDriver _cogl_texture_driver_gles; extern const CoglDriverVtable _cogl_driver_gles; #endif diff --git a/cogl/cogl/driver/gl/cogl-buffer-gl.c b/cogl/cogl/driver/gl/cogl-buffer-gl.c index a9f858320..a9aa0911b 100644 --- a/cogl/cogl/driver/gl/cogl-buffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-buffer-gl.c @@ -100,14 +100,8 @@ update_hints_to_gl_enum (CoglBuffer *buffer) return GL_STATIC_DRAW; case COGL_BUFFER_UPDATE_HINT_DYNAMIC: return GL_DYNAMIC_DRAW; - case COGL_BUFFER_UPDATE_HINT_STREAM: - /* OpenGL ES 1.1 only knows about STATIC_DRAW and DYNAMIC_DRAW */ -#if defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2) return GL_STREAM_DRAW; -#else - return GL_DYNAMIC_DRAW; -#endif } g_assert_not_reached (); diff --git a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c index b0d35f396..4d46fb13b 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c @@ -903,11 +903,6 @@ _cogl_pipeline_fragend_glsl_add_layer (CoglPipeline *pipeline, return TRUE; } -/* GLES2 and GL3 don't have alpha testing so we need to implement it - in the shader */ - -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) - static void add_alpha_test_snippet (CoglPipeline *pipeline, CoglPipelineFragendShaderState *shader_state) @@ -968,8 +963,6 @@ add_alpha_test_snippet (CoglPipeline *pipeline, " _cogl_alpha_test_ref)\n discard;\n"); } -#endif /* HAVE_COGL_GLES2 */ - static gboolean _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline, unsigned long pipelines_difference) diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index e987cd23b..6fc6fa684 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -237,8 +237,6 @@ _cogl_pipeline_texture_storage_change_notify (CoglTexture *texture) } } -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) - static gboolean blend_factor_uses_constant (GLenum blend_factor) { @@ -248,8 +246,6 @@ blend_factor_uses_constant (GLenum blend_factor) blend_factor == GL_ONE_MINUS_CONSTANT_ALPHA); } -#endif - static void flush_depth_state (CoglContext *ctx, CoglDepthState *depth_state) @@ -319,7 +315,6 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state ( CoglPipelineBlendState *blend_state = &authority->big_state->blend_state; -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) if (blend_factor_uses_constant (blend_state->blend_src_factor_rgb) || blend_factor_uses_constant (blend_state ->blend_src_factor_alpha) || @@ -347,7 +342,6 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state ( blend_state->blend_src_factor_alpha, blend_state->blend_dst_factor_alpha)); } -#endif if (pipelines_difference & COGL_PIPELINE_STATE_DEPTH) {