mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
cogl-program: gles2: bind programs lazily as for GL
This makes the gles2 cogl_program_use consistent with the GL version by not binding the program immediately and instead leaving it to cogl-material.c to bind the program when actually drawing something.
This commit is contained in:
parent
4a9321b60c
commit
10c5cb1800
@ -68,9 +68,6 @@ _cogl_material_backend_glsl_start (CoglMaterial *material,
|
||||
if (!cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: This will likely conflict with the GLES 2 backends use of
|
||||
* glUseProgram.
|
||||
*/
|
||||
if (materials_difference & COGL_MATERIAL_STATE_USER_SHADER)
|
||||
{
|
||||
CoglMaterial *authority =
|
||||
|
@ -145,7 +145,7 @@ void
|
||||
_cogl_delete_gl_texture (GLuint gl_texture);
|
||||
|
||||
void
|
||||
_cogl_gl_use_program_wrapper (GLuint program);
|
||||
_cogl_gl_use_program_wrapper (CoglHandle program);
|
||||
|
||||
void
|
||||
_cogl_material_flush_gl_state (CoglMaterial *material,
|
||||
|
@ -282,21 +282,30 @@ _cogl_material_texture_storage_change_notify (CoglHandle texture)
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_gl_use_program_wrapper (GLuint program)
|
||||
_cogl_gl_use_program_wrapper (CoglHandle program_handle)
|
||||
{
|
||||
#ifdef COGL_MATERIAL_BACKEND_GLSL
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (ctx->current_gl_program == program)
|
||||
#ifndef HAVE_COGL_GLES2
|
||||
CoglProgram *program = (CoglProgram *)program_handle;
|
||||
GLuint gl_program;
|
||||
|
||||
if (program_handle != COGL_INVALID_HANDLE)
|
||||
gl_program = program->gl_handle;
|
||||
else
|
||||
gl_program = 0;
|
||||
|
||||
if (ctx->current_gl_program == gl_program)
|
||||
return;
|
||||
|
||||
if (program)
|
||||
if (gl_program != 0)
|
||||
{
|
||||
GLenum gl_error;
|
||||
|
||||
while ((gl_error = glGetError ()) != GL_NO_ERROR)
|
||||
;
|
||||
glUseProgram (program);
|
||||
glUseProgram (gl_program);
|
||||
if (glGetError () != GL_NO_ERROR)
|
||||
{
|
||||
GE (glUseProgram (0));
|
||||
@ -307,7 +316,12 @@ _cogl_gl_use_program_wrapper (GLuint program)
|
||||
else
|
||||
GE (glUseProgram (0));
|
||||
|
||||
ctx->current_gl_program = program;
|
||||
ctx->current_gl_program = gl_program;
|
||||
#else /* HAVE_COGL_GLES2 */
|
||||
ctx->drv.gles2.settings.user_program = program_handle;
|
||||
ctx->drv.gles2.settings_dirty = TRUE;
|
||||
#endif /* HAVE_COGL_GLES2 */
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -332,16 +346,8 @@ _cogl_use_program (CoglHandle program_handle, CoglMaterialProgramType type)
|
||||
#ifdef COGL_MATERIAL_BACKEND_GLSL
|
||||
case COGL_MATERIAL_PROGRAM_TYPE_GLSL:
|
||||
{
|
||||
/* The GLES2 backend currently manages its own codegen for
|
||||
* fixed function API fallbacks and manages its own shader
|
||||
* state. */
|
||||
#ifndef HAVE_COGL_GLES2
|
||||
CoglProgram *program =
|
||||
_cogl_program_pointer_from_handle (program_handle);
|
||||
|
||||
_cogl_gl_use_program_wrapper (program->gl_handle);
|
||||
_cogl_gl_use_program_wrapper (program_handle);
|
||||
disable_arbfp ();
|
||||
#endif
|
||||
|
||||
ctx->current_use_program_type = type;
|
||||
break;
|
||||
|
@ -169,7 +169,7 @@ cogl_program_uniform_1f (int uniform_no,
|
||||
|
||||
g_return_if_fail (program != NULL);
|
||||
|
||||
_cogl_gl_use_program_wrapper (program->gl_handle);
|
||||
_cogl_gl_use_program_wrapper (program);
|
||||
|
||||
GE (glUniform1f (uniform_no, value));
|
||||
}
|
||||
@ -186,7 +186,7 @@ cogl_program_uniform_1i (int uniform_no,
|
||||
|
||||
g_return_if_fail (program != NULL);
|
||||
|
||||
_cogl_gl_use_program_wrapper (program->gl_handle);
|
||||
_cogl_gl_use_program_wrapper (program);
|
||||
|
||||
GE (glUniform1i (uniform_no, value));
|
||||
}
|
||||
@ -205,7 +205,7 @@ cogl_program_uniform_float (int uniform_no,
|
||||
|
||||
g_return_if_fail (program != NULL);
|
||||
|
||||
_cogl_gl_use_program_wrapper (program->gl_handle);
|
||||
_cogl_gl_use_program_wrapper (program);
|
||||
|
||||
switch (size)
|
||||
{
|
||||
@ -240,7 +240,7 @@ cogl_program_uniform_int (int uniform_no,
|
||||
|
||||
g_return_if_fail (program != NULL);
|
||||
|
||||
_cogl_gl_use_program_wrapper (program->gl_handle);
|
||||
_cogl_gl_use_program_wrapper (program);
|
||||
|
||||
switch (size)
|
||||
{
|
||||
@ -276,7 +276,7 @@ cogl_program_uniform_matrix (int uniform_no,
|
||||
|
||||
g_return_if_fail (program != NULL);
|
||||
|
||||
_cogl_gl_use_program_wrapper (program->gl_handle);
|
||||
_cogl_gl_use_program_wrapper (program);
|
||||
|
||||
switch (size)
|
||||
{
|
||||
|
@ -127,9 +127,6 @@ cogl_program_use (CoglHandle handle)
|
||||
else if (handle == 0 && ctx->current_program != 0)
|
||||
ctx->legacy_state_set--;
|
||||
|
||||
ctx->drv.gles2.settings.user_program = handle;
|
||||
ctx->drv.gles2.settings_dirty = TRUE;
|
||||
|
||||
if (handle != COGL_INVALID_HANDLE)
|
||||
cogl_handle_ref (handle);
|
||||
if (ctx->current_program != COGL_INVALID_HANDLE)
|
||||
|
Loading…
Reference in New Issue
Block a user