From 9600ad8a63eab76d613dfe24e8525f385e495893 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Tue, 23 Apr 2019 01:42:58 -0400 Subject: [PATCH] Skip GL_PROGRAM_POINT_SIZE for ES contexts --- mojoshader_opengl.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/mojoshader_opengl.c b/mojoshader_opengl.c index c2cee910..75b986c7 100644 --- a/mojoshader_opengl.c +++ b/mojoshader_opengl.c @@ -279,6 +279,7 @@ struct MOJOSHADER_glContext void (*profilePushSampler)(GLint loc, GLuint sampler); int (*profileMustPushConstantArrays)(void); int (*profileMustPushSamplers)(void); + void (*profileToggleProgramPointSize)(int enable); }; @@ -919,6 +920,20 @@ static void impl_ARB1_PushSampler(GLint loc, GLuint sampler) #endif // SUPPORT_PROFILE_ARB1 +#if SUPPORT_PROFILE_GLSL || SUPPORT_PROFILE_ARB1 + +static void impl_REAL_ToggleProgramPointSize(int enable) +{ + toggle_gl_state(GL_PROGRAM_POINT_SIZE, enable); +} // impl_REAL_ToggleProgramPointSize + +static void impl_NOOP_ToggleProgramPointSize(int enable) +{ + // No-op, this profile's GL context forces this to always be on +} // impl_NOOP_ToggleProgramPointSize + +#endif // SUPPORT_PROFILE_GLSL || SUPPORT_PROFILE_ARB1 + const char *MOJOSHADER_glGetError(void) { @@ -1463,6 +1478,10 @@ MOJOSHADER_glContext *MOJOSHADER_glCreateContext(const char *profile, ctx->profilePushSampler = impl_GLSL_PushSampler; ctx->profileMustPushConstantArrays = impl_GLSL_MustPushConstantArrays; ctx->profileMustPushSamplers = impl_GLSL_MustPushSamplers; + if (strcmp(profile, MOJOSHADER_PROFILE_GLSLES) == 0) + ctx->profileToggleProgramPointSize = impl_NOOP_ToggleProgramPointSize; + else + ctx->profileToggleProgramPointSize = impl_REAL_ToggleProgramPointSize; } // if #endif @@ -1488,6 +1507,7 @@ MOJOSHADER_glContext *MOJOSHADER_glCreateContext(const char *profile, ctx->profilePushSampler = impl_ARB1_PushSampler; ctx->profileMustPushConstantArrays = impl_ARB1_MustPushConstantArrays; ctx->profileMustPushSamplers = impl_ARB1_MustPushSamplers; + ctx->profileToggleProgramPointSize = impl_REAL_ToggleProgramPointSize; } // if #endif @@ -1507,6 +1527,7 @@ MOJOSHADER_glContext *MOJOSHADER_glCreateContext(const char *profile, assert(ctx->profilePushSampler != NULL); assert(ctx->profileMustPushConstantArrays != NULL); assert(ctx->profileMustPushSamplers != NULL); + assert(ctx->profileToggleProgramPointSize != NULL); retval = ctx; ctx = current_ctx; @@ -2402,10 +2423,7 @@ void MOJOSHADER_glProgramReady(void) if (program->uses_pointsize != ctx->pointsize_enabled) { - if (program->uses_pointsize) - ctx->glEnable(GL_PROGRAM_POINT_SIZE); - else - ctx->glDisable(GL_PROGRAM_POINT_SIZE); + ctx->profileToggleProgramPointSize(program->uses_pointsize); ctx->pointsize_enabled = program->uses_pointsize; } // if