From 282eab45f79549da2ec9f536c583e2c5fafea75f Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 10 Jan 2020 16:14:36 -0500 Subject: [PATCH] cogl: Stop using glPointSize in big-GL Just pass it in to the vertex shader like in GLES, it's one less thing to vary between drivers. mutter is, shall we say, not a heavy user of point primitives, so any performance impact (it might be measurable, who knows) is not an issue. Again, the feature flag remains to be cleaned up in a future commit. https://gitlab.gnome.org/GNOME/mutter/merge_requests/995 --- cogl/cogl/cogl-pipeline.c | 9 +------- cogl/cogl/cogl-private.h | 1 - cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 18 --------------- .../driver/gl/cogl-pipeline-vertend-glsl.c | 22 ++----------------- cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 10 ++++----- 5 files changed, 8 insertions(+), 52 deletions(-) diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index f90046d76..5f6f6695f 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -2799,14 +2799,7 @@ _cogl_pipeline_get_state_for_vertex_codegen (CoglContext *context) COGL_PIPELINE_STATE_USER_SHADER | COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE | COGL_PIPELINE_STATE_VERTEX_SNIPPETS); - - /* If we don't have the builtin point size uniform then we'll add - * one in the GLSL but we'll only do this if the point size is - * non-zero. Whether or not the point size is zero is represented by - * COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE */ - if (!_cogl_has_private_feature - (context, COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM)) - state |= COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE; + state |= COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE; return state; } diff --git a/cogl/cogl/cogl-private.h b/cogl/cogl/cogl-private.h index e13300920..f4378d92e 100644 --- a/cogl/cogl/cogl-private.h +++ b/cogl/cogl/cogl-private.h @@ -63,7 +63,6 @@ typedef enum * events. Otherwise a dirty event will be queued when the onscreen * is first allocated or when it is shown or resized */ COGL_PRIVATE_FEATURE_DIRTY_EVENTS, - COGL_PRIVATE_FEATURE_ENABLE_PROGRAM_POINT_SIZE, /* This feature allows for explicitly selecting a GL-based backend, * as opposed to nop or (in the future) Vulkan. */ diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index 386f4aaaf..850610230 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -64,9 +64,6 @@ #ifndef GL_CLAMP_TO_BORDER #define GL_CLAMP_TO_BORDER 0x812d #endif -#ifndef GL_PROGRAM_POINT_SIZE -#define GL_PROGRAM_POINT_SIZE 0x8642 -#endif static void texture_unit_init (CoglContext *ctx, @@ -456,21 +453,6 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state ( } } -#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) diff --git a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c index e7fbc2cbe..c69f50ae8 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c @@ -305,8 +305,7 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline, if (cogl_pipeline_get_per_vertex_point_size (pipeline)) g_string_append (shader_state->header, "attribute float cogl_point_size_in;\n"); - else if (!_cogl_has_private_feature - (ctx, COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM)) + else { /* There is no builtin uniform for the point size on GLES2 so we need to copy it from the custom uniform in the vertex shader @@ -541,19 +540,6 @@ _cogl_pipeline_vertend_glsl_end (CoglPipeline *pipeline, shader_state->gl_shader = shader; } -#ifdef HAVE_COGL_GL - if (_cogl_has_private_feature - (ctx, COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM) && - (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) ); - } -#endif /* HAVE_COGL_GL */ - return TRUE; } @@ -651,11 +637,7 @@ UNIT_TEST (check_point_size_shader, * size */ if (shader_states[0]) { - if (_cogl_has_private_feature - (test_ctx, COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM)) - g_assert (shader_states[0] == shader_states[1]); - else - g_assert (shader_states[0] != shader_states[1]); + g_assert (shader_states[0] != shader_states[1]); } /* The second and third pipelines should always have the same shader diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index 04304aa59..8b3ff64e2 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -80,6 +80,11 @@ _cogl_driver_gl_context_init (CoglContext *context, if (context->driver == COGL_DRIVER_GL) GE (context, glEnable (GL_POINT_SPRITE)); + /* There's no enable for this in GLES2, it's always on */ + if (context->driver == COGL_DRIVER_GL || + context->driver == COGL_DRIVER_GL3) + GE (context, glEnable (GL_PROGRAM_POINT_SIZE) ); + return TRUE; } @@ -489,9 +494,6 @@ _cogl_driver_update_features (CoglContext *ctx, COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE, TRUE); - COGL_FLAGS_SET (private_features, - COGL_PRIVATE_FEATURE_ENABLE_PROGRAM_POINT_SIZE, TRUE); - if (ctx->driver == COGL_DRIVER_GL) { /* Features which are not available in GL 3 */ @@ -504,8 +506,6 @@ _cogl_driver_update_features (CoglContext *ctx, COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_ANY_GL, TRUE); COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_FORMAT_CONVERSION, TRUE); - COGL_FLAGS_SET (private_features, - COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM, TRUE); COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_QUERY_TEXTURE_PARAMETERS, TRUE); COGL_FLAGS_SET (private_features,