vrend,stringbuf: Add line numbers to shader dumps

This helps a lot locating errors in the shaders.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Gert Wollny 6 years ago committed by Dave Airlie
parent e00dea22c8
commit 4efd580f48
  1. 2
      src/vrend_renderer.c
  2. 14
      src/vrend_strbuf.h

@ -834,7 +834,7 @@ static void vrend_shader_dump(struct vrend_shader *shader)
{
const char *prefix = pipe_shader_to_prefix(shader->sel->type);
vrend_printf("%s: %d GLSL:\n", prefix, shader->id);
strarray_dump(&shader->glsl_strings);
strarray_dump_with_line_numbers(&shader->glsl_strings);
vrend_printf("\n");
}

@ -203,4 +203,18 @@ static inline void strarray_dump(struct vrend_strarray *sa)
vrend_printf("%s", sa->strings[i].buf);
}
static inline void strarray_dump_with_line_numbers(struct vrend_strarray *sa)
{
int lineno = 1;
for (int i = 0; i < sa->num_strings; i++) {
char *saveptr;
char *line = strtok_r(sa->strings[i].buf, "\n", &saveptr);
while (line) {
vrend_printf("%4d: %s\n", lineno++, line);
line = strtok_r(NULL, "\n", &saveptr);
}
}
}
#endif

Loading…
Cancel
Save