debug: Add shader logging code

Add flags tgsi,glsl,stream, and shader and change the corresponding
logging code.

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
macos/master
Gert Wollny 6 years ago committed by Jakob Bornecrantz
parent 20afd5c45b
commit 05a10455a2
  1. 4
      src/vrend_debug.c
  2. 5
      src/vrend_debug.h
  3. 28
      src/vrend_renderer.c
  4. 1
      src/vrend_renderer.h
  5. 21
      src/vrend_shader.c
  6. 9
      src/vrend_shader.h

@ -28,6 +28,10 @@
#include <stdlib.h>
#include <stdio.h>
static const struct debug_named_value vrend_debug_options[] = {
{"tgsi", dbg_shader_tgsi, "Print TGSI"},
{"glsl", dbg_shader_glsl, "Print GLSL shaders created from TGSI"},
{"shader", dbg_shader, "Print TGSI and created GLSL shaders"},
{"stream", dbg_shader_streamout, "Print shader streamout"},
DEBUG_NAMED_VALUE_END
};

@ -29,7 +29,10 @@ struct vrend_context;
void vrend_print_context_name(struct vrend_context *ctx);
enum virgl_debug_flags {
dummy
dbg_shader_tgsi = 1 << 0,
dbg_shader_glsl = 1 << 1,
dbg_shader_streamout = 1 << 2,
dbg_shader = dbg_shader_tgsi | dbg_shader_glsl | dbg_shader_streamout,
};
void vrend_init_debug_flags(void);

@ -57,9 +57,6 @@
#include <sys/eventfd.h>
#endif
/* debugging aid to dump shaders */
int vrend_dump_shaders;
/* debugging via KHR_debug extension */
int vrend_use_debug_cb = 0;
@ -991,7 +988,8 @@ static char *get_skip_str(int *skip_val)
return start_skip;
}
static void set_stream_out_varyings(int prog_id, struct vrend_shader_info *sinfo)
static void set_stream_out_varyings(struct vrend_context *ctx, int prog_id,
struct vrend_shader_info *sinfo)
{
struct pipe_stream_output_info *so = &sinfo->so_info;
char *varyings[PIPE_MAX_SHADER_OUTPUTS*2];
@ -1004,8 +1002,7 @@ static void set_stream_out_varyings(int prog_id, struct vrend_shader_info *sinfo
if (!so->num_outputs)
return;
if (vrend_dump_shaders)
dump_stream_out(so);
VREND_DEBUG_EXT(dbg_shader_streamout, ctx, dump_stream_out(so));
for (i = 0; i < so->num_outputs; i++) {
if (last_buffer != so->output[i].output_buffer) {
@ -1271,15 +1268,15 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
bool ret;
if (gs)
vrend_patch_vertex_shader_interpolants(&ctx->shader_cfg, gs->glsl_prog,
vrend_patch_vertex_shader_interpolants(ctx, &ctx->shader_cfg, gs->glsl_prog,
&gs->sel->sinfo,
&fs->sel->sinfo, "gso", fs->key.flatshade);
else if (tes)
vrend_patch_vertex_shader_interpolants(&ctx->shader_cfg, tes->glsl_prog,
vrend_patch_vertex_shader_interpolants(ctx, &ctx->shader_cfg, tes->glsl_prog,
&tes->sel->sinfo,
&fs->sel->sinfo, "teo", fs->key.flatshade);
else
vrend_patch_vertex_shader_interpolants(&ctx->shader_cfg, vs->glsl_prog,
vrend_patch_vertex_shader_interpolants(ctx, &ctx->shader_cfg, vs->glsl_prog,
&vs->sel->sinfo,
&fs->sel->sinfo, "vso", fs->key.flatshade);
ret = vrend_compile_shader(ctx, gs ? gs : (tes ? tes : vs));
@ -1306,11 +1303,11 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
if (gs) {
if (gs->id > 0)
glAttachShader(prog_id, gs->id);
set_stream_out_varyings(prog_id, &gs->sel->sinfo);
set_stream_out_varyings(ctx, prog_id, &gs->sel->sinfo);
} else if (tes)
set_stream_out_varyings(prog_id, &tes->sel->sinfo);
set_stream_out_varyings(ctx, prog_id, &tes->sel->sinfo);
else
set_stream_out_varyings(prog_id, &vs->sel->sinfo);
set_stream_out_varyings(ctx, prog_id, &vs->sel->sinfo);
glAttachShader(prog_id, fs->id);
if (fs->sel->sinfo.num_outputs > 1) {
@ -2859,7 +2856,8 @@ static int vrend_shader_create(struct vrend_context *ctx,
shader->id = glCreateShader(conv_shader_type(shader->sel->type));
shader->compiled_fs_id = 0;
shader->glsl_prog = vrend_convert_shader(&ctx->shader_cfg, shader->sel->tokens, shader->sel->req_local_mem, &key, &shader->sel->sinfo);
shader->glsl_prog = vrend_convert_shader(ctx, &ctx->shader_cfg, shader->sel->tokens,
shader->sel->req_local_mem, &key, &shader->sel->sinfo);
if (!shader->glsl_prog) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0);
glDeleteShader(shader->id);
@ -3075,8 +3073,8 @@ int vrend_create_shader(struct vrend_context *ctx,
goto error;
}
if (vrend_dump_shaders)
fprintf(stderr,"shader\n%s\n", shd_text);
VREND_DEBUG(dbg_shader_tgsi, ctx, "shader\n%s\n", shd_text);
if (!tgsi_text_translate((const char *)shd_text, tokens, num_tokens + 10)) {
free(tokens);
ret = EINVAL;

@ -42,7 +42,6 @@ struct virgl_gl_ctx_param {
bool shared;
};
extern int vrend_dump_shaders;
struct vrend_context;
/* Number of mipmap levels for which to keep the backing iov offsets.

@ -32,8 +32,7 @@
#include <math.h>
#include <errno.h>
#include "vrend_shader.h"
extern int vrend_dump_shaders;
#include "vrend_debug.h"
/* start convert of tgsi to glsl */
@ -5054,7 +5053,8 @@ static boolean analyze_instruction(struct tgsi_iterate_context *iter,
return true;
}
char *vrend_convert_shader(struct vrend_shader_cfg *cfg,
char *vrend_convert_shader(struct vrend_context *rctx,
struct vrend_shader_cfg *cfg,
const struct tgsi_token *tokens,
uint32_t req_local_mem,
struct vrend_shader_key *key,
@ -5147,8 +5147,9 @@ char *vrend_convert_shader(struct vrend_shader_cfg *cfg,
strcat(glsl_final, glsl_hdr);
strcat(glsl_final, ctx.glsl_main);
if (vrend_dump_shaders)
fprintf(stderr,"GLSL: %s\n", glsl_final);
VREND_DEBUG(dbg_shader_glsl, rctx, "GLSL: %s\n", glsl_final);
free(ctx.temp_ranges);
free(ctx.glsl_main);
free(glsl_hdr);
@ -5251,9 +5252,11 @@ static void require_gpu_shader5_and_msinterp(char *program)
memcpy(ptr, gpu_shader5_and_msinterp_string, strlen(gpu_shader5_and_msinterp_string));
}
bool vrend_patch_vertex_shader_interpolants(struct vrend_shader_cfg *cfg, char *program,
bool vrend_patch_vertex_shader_interpolants(struct vrend_context *rctx,
struct vrend_shader_cfg *cfg, char *program,
struct vrend_shader_info *vs_info,
struct vrend_shader_info *fs_info, const char *oprefix, bool flatshade)
struct vrend_shader_info *fs_info,
const char *oprefix, bool flatshade)
{
int i;
const char *pstring, *auxstring;
@ -5307,7 +5310,7 @@ bool vrend_patch_vertex_shader_interpolants(struct vrend_shader_cfg *cfg, char *
}
}
if (vrend_dump_shaders)
fprintf(stderr,"GLSL: post interp: %s\n", program);
VREND_DEBUG(dbg_shader_glsl, rctx, "GLSL: post interp: %s\n", program);
return true;
}

@ -111,19 +111,24 @@ struct vrend_shader_cfg {
bool use_explicit_locations;
};
bool vrend_patch_vertex_shader_interpolants(struct vrend_shader_cfg *cfg,
struct vrend_context;
bool vrend_patch_vertex_shader_interpolants(struct vrend_context *rctx,
struct vrend_shader_cfg *cfg,
char *program,
struct vrend_shader_info *vs_info,
struct vrend_shader_info *fs_info,
const char *oprefix, bool flatshade);
char *vrend_convert_shader(struct vrend_shader_cfg *cfg,
char *vrend_convert_shader(struct vrend_context *rctx,
struct vrend_shader_cfg *cfg,
const struct tgsi_token *tokens,
uint32_t req_local_mem,
struct vrend_shader_key *key,
struct vrend_shader_info *sinfo);
const char *vrend_shader_samplertypeconv(bool use_gles, int sampler_type, int *is_shad);
char vrend_shader_samplerreturnconv(enum tgsi_return_type type);
int shader_lookup_sampler_array(struct vrend_shader_info *sinfo, int index);

Loading…
Cancel
Save