static void _cogl_pipeline_fragend_fixed_start (CoglPipeline *pipeline, int n_layers, unsigned long pipelines_difference) { _cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED); }
static gboolean _cogl_pipeline_fragend_fixed_start (CoglPipeline *pipeline, int n_layers, unsigned long pipelines_difference, int n_tex_coord_attribs) { CoglHandle user_program; _COGL_GET_CONTEXT (ctx, FALSE); if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED))) return FALSE; if (ctx->driver == COGL_DRIVER_GLES2) return FALSE; /* Fragment snippets are only supported in the GLSL fragend */ if (_cogl_pipeline_has_fragment_snippets (pipeline)) return FALSE; /* If there is a user program with a fragment shader then the appropriate backend for that language should handle it. We can still use the fixed fragment backend if the program only contains a vertex shader */ user_program = cogl_pipeline_get_user_program (pipeline); if (user_program != COGL_INVALID_HANDLE && _cogl_program_has_fragment_shader (user_program)) return FALSE; _cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED); return TRUE; }
static CoglBool _cogl_pipeline_fragend_arbfp_end (CoglPipeline *pipeline, unsigned long pipelines_difference) { CoglPipelineShaderState *shader_state = get_shader_state (pipeline); GLuint gl_program; UpdateConstantsState state; _COGL_GET_CONTEXT (ctx, FALSE); if (shader_state->source) { GLenum gl_error; COGL_STATIC_COUNTER (fragend_arbfp_compile_counter, "arbfp compile counter", "Increments each time a new ARBfp " "program is compiled", 0 /* no application private data */); COGL_COUNTER_INC (_cogl_uprof_context, fragend_arbfp_compile_counter); g_string_append (shader_state->source, "MOV result.color,output;\n"); g_string_append (shader_state->source, "END\n"); if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE))) g_message ("pipeline program:\n%s", shader_state->source->str); GE (ctx, glGenPrograms (1, &shader_state->gl_program)); GE (ctx, glBindProgram (GL_FRAGMENT_PROGRAM_ARB, shader_state->gl_program)); while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR) ; ctx->glProgramString (GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, shader_state->source->len, shader_state->source->str); if (ctx->glGetError () != GL_NO_ERROR) { g_warning ("\n%s\n%s", shader_state->source->str, ctx->glGetString (GL_PROGRAM_ERROR_STRING_ARB)); } shader_state->source = NULL; } gl_program = shader_state->gl_program; GE (ctx, glBindProgram (GL_FRAGMENT_PROGRAM_ARB, gl_program)); _cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_ARBFP); state.unit = 0; state.shader_state = shader_state; /* If this arbfp program was last used with a different pipeline * then we need to ensure we update all program.local params */ state.update_all = pipeline != shader_state->last_used_for_pipeline; cogl_pipeline_foreach_layer (pipeline, update_constants_cb, &state); /* We need to track what pipeline used this arbfp program last since * we will need to update program.local params when switching * between different pipelines. */ shader_state->last_used_for_pipeline = pipeline; return TRUE; }