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
This commit is contained in:
Adam Jackson 2020-01-10 16:14:36 -05:00 committed by Georges Basile Stavracas Neto
parent 35f21c5bc0
commit 282eab45f7
5 changed files with 8 additions and 52 deletions

View File

@ -2799,13 +2799,6 @@ _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;
return state;

View File

@ -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.
*/

View File

@ -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)

View File

@ -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,10 +637,6 @@ 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]);
}

View File

@ -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,