Commit 1a4b2499 authored by Eric Anholt's avatar Eric Anholt

glamor: Apply debug labels to our shaders.

This will help tools like fips, apitrace, or INTEL_DEBUG=shader_time
provide useful information about the shaders in use.
Signed-off-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarMarkus Wick <markus@selfnet.de>
parent d07d2c3c
......@@ -372,6 +372,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
}
}
glamor_priv->has_khr_debug = glamor_gl_has_extension("GL_KHR_debug");
glamor_priv->has_pack_invert =
glamor_gl_has_extension("GL_MESA_pack_invert");
glamor_priv->has_fbo_blit =
......
......@@ -83,9 +83,10 @@ glamor_compile_glsl_prog(GLenum type, const char *source)
}
void
glamor_link_glsl_prog(GLint prog)
glamor_link_glsl_prog(ScreenPtr screen, GLint prog, const char *format, ...)
{
GLint ok;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
glLinkProgram(prog);
glGetProgramiv(prog, GL_LINK_STATUS, &ok);
......@@ -100,6 +101,17 @@ glamor_link_glsl_prog(GLint prog)
ErrorF("Failed to link: %s\n", info);
FatalError("GLSL link failure\n");
}
if (glamor_priv->has_khr_debug) {
char *label;
va_list va;
va_start(va, format);
XNFvasprintf(&label, format, va);
glObjectLabel(GL_PROGRAM, prog, -1, label);
free(label);
va_end(va);
}
}
Bool
......@@ -256,13 +268,15 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(glamor_priv->finish_access_prog[0],
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glamor_link_glsl_prog(glamor_priv->finish_access_prog[0]);
glamor_link_glsl_prog(screen, glamor_priv->finish_access_prog[0],
"finish access 0");
glBindAttribLocation(glamor_priv->finish_access_prog[1],
GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(glamor_priv->finish_access_prog[1],
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glamor_link_glsl_prog(glamor_priv->finish_access_prog[1]);
glamor_link_glsl_prog(screen, glamor_priv->finish_access_prog[1],
"finish access 1");
glamor_priv->finish_access_revert[0] =
glGetUniformLocation(glamor_priv->finish_access_prog[0], "revert");
......
......@@ -165,7 +165,7 @@ glamor_init_solid_shader(ScreenPtr screen)
glBindAttribLocation(glamor_priv->solid_prog,
GLAMOR_VERTEX_POS, "v_position");
glamor_link_glsl_prog(glamor_priv->solid_prog);
glamor_link_glsl_prog(screen, glamor_priv->solid_prog, "solid");
glamor_priv->solid_color_uniform_location =
glGetUniformLocation(glamor_priv->solid_prog, "color");
......
......@@ -377,7 +377,7 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
glamor_link_glsl_prog(gradient_prog);
glamor_link_glsl_prog(screen, gradient_prog, "radial gradient");
glUseProgram(0);
......@@ -590,7 +590,7 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
glamor_link_glsl_prog(gradient_prog);
glamor_link_glsl_prog(screen, gradient_prog, "linear gradient");
glUseProgram(0);
......
......@@ -214,6 +214,7 @@ typedef struct glamor_screen_private {
int has_pack_invert;
int has_fbo_blit;
int has_buffer_storage;
int has_khr_debug;
int max_fbo_size;
struct xorg_list
......@@ -594,7 +595,8 @@ Bool glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
unsigned long fg_pixel, unsigned long bg_pixel,
int stipple_x, int stipple_y);
GLint glamor_compile_glsl_prog(GLenum type, const char *source);
void glamor_link_glsl_prog(GLint prog);
void glamor_link_glsl_prog(ScreenPtr screen, GLint prog,
const char *format, ...) _X_ATTRIBUTE_PRINTF(3,4);
void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
unsigned long fg_pixel, GLfloat *color);
......
......@@ -332,7 +332,7 @@ glamor_create_composite_shader(ScreenPtr screen, struct shader_key *key,
glBindAttribLocation(prog, GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glBindAttribLocation(prog, GLAMOR_VERTEX_MASK, "v_texcoord1");
glamor_link_glsl_prog(prog);
glamor_link_glsl_prog(screen, prog, "composite");
shader->prog = prog;
......
......@@ -73,7 +73,7 @@ glamor_init_tile_shader(ScreenPtr screen)
GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(glamor_priv->tile_prog,
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glamor_link_glsl_prog(glamor_priv->tile_prog);
glamor_link_glsl_prog(screen, glamor_priv->tile_prog, "tile");
sampler_uniform_location =
glGetUniformLocation(glamor_priv->tile_prog, "sampler");
......
......@@ -1357,7 +1357,7 @@ glamor_init_trapezoid_shader(ScreenPtr screen)
glBindAttribLocation(glamor_priv->trapezoid_prog,
GLAMOR_VERTEX_RIGHT_PARAM, "v_right_param");
glamor_link_glsl_prog(glamor_priv->trapezoid_prog);
glamor_link_glsl_prog(screen, glamor_priv->trapezoid_prog, "trapezoid");
glUseProgram(0);
......
......@@ -109,7 +109,7 @@ glamor_init_xv_shader(ScreenPtr screen)
GLAMOR_VERTEX_POS, "v_position");
glBindAttribLocation(glamor_priv->xv_prog,
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glamor_link_glsl_prog(glamor_priv->xv_prog);
glamor_link_glsl_prog(screen, glamor_priv->xv_prog, "xv");
glamor_put_context(glamor_priv);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment