cogl: Move COGL_DEBUG=show-source into cogl-shader.c

The code to display the source when the show-source debug option is
given has been moved to _cogl_shader_set_source_with_boilerplate so
that it will show both user shaders and generated shaders. It also
shows the code with the full boilerplate. To make it the same for
ARBfp, cogl_shader_compile_real now also dumps user ARBfp shaders.
This commit is contained in:
Neil Roberts 2010-12-02 22:19:44 +00:00
parent 8764a0d487
commit 3c5fa0cf90
3 changed files with 23 additions and 10 deletions

View File

@ -790,11 +790,6 @@ _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline,
g_string_append (glsl_shader_state->source, "}\n"); g_string_append (glsl_shader_state->source, "}\n");
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_SHOW_SOURCE))
g_message ("pipeline fragment shader:\n%s%s",
glsl_shader_state->header->str,
glsl_shader_state->source->str);
GE_RET( shader, glCreateShader (GL_FRAGMENT_SHADER) ); GE_RET( shader, glCreateShader (GL_FRAGMENT_SHADER) );
lengths[0] = glsl_shader_state->header->len; lengths[0] = glsl_shader_state->header->len;

View File

@ -303,11 +303,6 @@ _cogl_pipeline_vertend_glsl_end (CoglPipeline *pipeline,
" cogl_color_out = cogl_color_in;\n" " cogl_color_out = cogl_color_in;\n"
"}\n"); "}\n");
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_SHOW_SOURCE))
g_message ("pipeline vertex shader:\n%s%s",
priv->header->str,
priv->source->str);
GE_RET( shader, glCreateShader (GL_VERTEX_SHADER) ); GE_RET( shader, glCreateShader (GL_VERTEX_SHADER) );
lengths[0] = priv->header->len; lengths[0] = priv->header->len;

View File

@ -257,6 +257,26 @@ _cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle,
} }
count += count_in; count += count_in;
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_SHOW_SOURCE))
{
GString *buf = g_string_new (NULL);
int i;
g_string_append_printf (buf,
"%s shader:\n",
shader_gl_type == GL_VERTEX_SHADER ?
"vertex" : "fragment");
for (i = 0; i < count; i++)
if (lengths[i] != -1)
g_string_append_len (buf, strings[i], lengths[i]);
else
g_string_append (buf, strings[i]);
g_message ("%s", buf->str);
g_string_free (buf, TRUE);
}
GE( glShaderSource (shader_gl_handle, count, GE( glShaderSource (shader_gl_handle, count,
(const char **) strings, lengths) ); (const char **) strings, lengths) );
@ -287,6 +307,9 @@ _cogl_shader_compile_real (CoglHandle handle,
GE (glBindProgram (GL_FRAGMENT_PROGRAM_ARB, shader->gl_handle)); GE (glBindProgram (GL_FRAGMENT_PROGRAM_ARB, shader->gl_handle));
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_SHOW_SOURCE))
g_message ("user ARBfp program:\n%s", shader->source);
#ifdef COGL_GL_DEBUG #ifdef COGL_GL_DEBUG
while ((gl_error = glGetError ()) != GL_NO_ERROR) while ((gl_error = glGetError ()) != GL_NO_ERROR)
; ;