mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05: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
650df3f2eb
commit
99ae7b15f5
@ -68,9 +68,6 @@ _cogl_material_backend_glsl_start (CoglMaterial *material,
|
|||||||
if (!cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
|
if (!cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* FIXME: This will likely conflict with the GLES 2 backends use of
|
|
||||||
* glUseProgram.
|
|
||||||
*/
|
|
||||||
if (materials_difference & COGL_MATERIAL_STATE_USER_SHADER)
|
if (materials_difference & COGL_MATERIAL_STATE_USER_SHADER)
|
||||||
{
|
{
|
||||||
CoglMaterial *authority =
|
CoglMaterial *authority =
|
||||||
|
@ -145,7 +145,7 @@ void
|
|||||||
_cogl_delete_gl_texture (GLuint gl_texture);
|
_cogl_delete_gl_texture (GLuint gl_texture);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_gl_use_program_wrapper (GLuint program);
|
_cogl_gl_use_program_wrapper (CoglHandle program);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_material_flush_gl_state (CoglMaterial *material,
|
_cogl_material_flush_gl_state (CoglMaterial *material,
|
||||||
|
@ -282,21 +282,30 @@ _cogl_material_texture_storage_change_notify (CoglHandle texture)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_gl_use_program_wrapper (GLuint program)
|
_cogl_gl_use_program_wrapper (CoglHandle program_handle)
|
||||||
{
|
{
|
||||||
#ifdef COGL_MATERIAL_BACKEND_GLSL
|
#ifdef COGL_MATERIAL_BACKEND_GLSL
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_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;
|
return;
|
||||||
|
|
||||||
if (program)
|
if (gl_program != 0)
|
||||||
{
|
{
|
||||||
GLenum gl_error;
|
GLenum gl_error;
|
||||||
|
|
||||||
while ((gl_error = glGetError ()) != GL_NO_ERROR)
|
while ((gl_error = glGetError ()) != GL_NO_ERROR)
|
||||||
;
|
;
|
||||||
glUseProgram (program);
|
glUseProgram (gl_program);
|
||||||
if (glGetError () != GL_NO_ERROR)
|
if (glGetError () != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
GE (glUseProgram (0));
|
GE (glUseProgram (0));
|
||||||
@ -307,7 +316,12 @@ _cogl_gl_use_program_wrapper (GLuint program)
|
|||||||
else
|
else
|
||||||
GE (glUseProgram (0));
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,16 +346,8 @@ _cogl_use_program (CoglHandle program_handle, CoglMaterialProgramType type)
|
|||||||
#ifdef COGL_MATERIAL_BACKEND_GLSL
|
#ifdef COGL_MATERIAL_BACKEND_GLSL
|
||||||
case COGL_MATERIAL_PROGRAM_TYPE_GLSL:
|
case COGL_MATERIAL_PROGRAM_TYPE_GLSL:
|
||||||
{
|
{
|
||||||
/* The GLES2 backend currently manages its own codegen for
|
_cogl_gl_use_program_wrapper (program_handle);
|
||||||
* 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);
|
|
||||||
disable_arbfp ();
|
disable_arbfp ();
|
||||||
#endif
|
|
||||||
|
|
||||||
ctx->current_use_program_type = type;
|
ctx->current_use_program_type = type;
|
||||||
break;
|
break;
|
||||||
|
@ -169,7 +169,7 @@ cogl_program_uniform_1f (int uniform_no,
|
|||||||
|
|
||||||
g_return_if_fail (program != NULL);
|
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));
|
GE (glUniform1f (uniform_no, value));
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ cogl_program_uniform_1i (int uniform_no,
|
|||||||
|
|
||||||
g_return_if_fail (program != NULL);
|
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));
|
GE (glUniform1i (uniform_no, value));
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ cogl_program_uniform_float (int uniform_no,
|
|||||||
|
|
||||||
g_return_if_fail (program != NULL);
|
g_return_if_fail (program != NULL);
|
||||||
|
|
||||||
_cogl_gl_use_program_wrapper (program->gl_handle);
|
_cogl_gl_use_program_wrapper (program);
|
||||||
|
|
||||||
switch (size)
|
switch (size)
|
||||||
{
|
{
|
||||||
@ -240,7 +240,7 @@ cogl_program_uniform_int (int uniform_no,
|
|||||||
|
|
||||||
g_return_if_fail (program != NULL);
|
g_return_if_fail (program != NULL);
|
||||||
|
|
||||||
_cogl_gl_use_program_wrapper (program->gl_handle);
|
_cogl_gl_use_program_wrapper (program);
|
||||||
|
|
||||||
switch (size)
|
switch (size)
|
||||||
{
|
{
|
||||||
@ -276,7 +276,7 @@ cogl_program_uniform_matrix (int uniform_no,
|
|||||||
|
|
||||||
g_return_if_fail (program != NULL);
|
g_return_if_fail (program != NULL);
|
||||||
|
|
||||||
_cogl_gl_use_program_wrapper (program->gl_handle);
|
_cogl_gl_use_program_wrapper (program);
|
||||||
|
|
||||||
switch (size)
|
switch (size)
|
||||||
{
|
{
|
||||||
|
@ -127,9 +127,6 @@ cogl_program_use (CoglHandle handle)
|
|||||||
else if (handle == 0 && ctx->current_program != 0)
|
else if (handle == 0 && ctx->current_program != 0)
|
||||||
ctx->legacy_state_set--;
|
ctx->legacy_state_set--;
|
||||||
|
|
||||||
ctx->drv.gles2.settings.user_program = handle;
|
|
||||||
ctx->drv.gles2.settings_dirty = TRUE;
|
|
||||||
|
|
||||||
if (handle != COGL_INVALID_HANDLE)
|
if (handle != COGL_INVALID_HANDLE)
|
||||||
cogl_handle_ref (handle);
|
cogl_handle_ref (handle);
|
||||||
if (ctx->current_program != COGL_INVALID_HANDLE)
|
if (ctx->current_program != COGL_INVALID_HANDLE)
|
||||||
|
Loading…
Reference in New Issue
Block a user