mesa/st: add ST_DEBUG environment variable
At last it's possible to turn on tgsi dumps and other debugging in the state tracker without modifying sources...
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_inlines.h"
|
||||
|
||||
#include "st_debug.h"
|
||||
#include "st_context.h"
|
||||
#include "st_atom.h"
|
||||
#include "st_atom_constbuf.h"
|
||||
@@ -75,7 +76,7 @@ void st_upload_constants( struct st_context *st,
|
||||
PIPE_BUFFER_USAGE_CONSTANT,
|
||||
paramBytes );
|
||||
|
||||
if (0) {
|
||||
if (ST_DEBUG & DEBUG_CONSTANTS) {
|
||||
debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n",
|
||||
__FUNCTION__, shader_type, params->NumParameters,
|
||||
params->StateFlags);
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include "main/image.h"
|
||||
#include "main/macros.h"
|
||||
|
||||
#include "st_debug.h"
|
||||
#include "st_context.h"
|
||||
#include "st_cb_accum.h"
|
||||
#include "st_cb_fbo.h"
|
||||
@@ -136,6 +137,9 @@ accum_accum(struct st_context *st, GLfloat value,
|
||||
GLubyte *data = acc_strb->data;
|
||||
GLfloat *buf;
|
||||
|
||||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s: fallback processing\n", __FUNCTION__);
|
||||
|
||||
color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture,
|
||||
0, 0, 0,
|
||||
PIPE_TRANSFER_READ, xpos, ypos,
|
||||
@@ -181,6 +185,10 @@ accum_load(struct st_context *st, GLfloat value,
|
||||
GLubyte *data = acc_strb->data;
|
||||
GLfloat *buf;
|
||||
|
||||
|
||||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s: fallback processing\n", __FUNCTION__);
|
||||
|
||||
color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture,
|
||||
0, 0, 0,
|
||||
PIPE_TRANSFER_READ, xpos, ypos,
|
||||
@@ -228,6 +236,9 @@ accum_return(GLcontext *ctx, GLfloat value,
|
||||
const GLubyte *data = acc_strb->data;
|
||||
GLfloat *buf;
|
||||
|
||||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s: fallback processing\n", __FUNCTION__);
|
||||
|
||||
buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
|
||||
|
||||
if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3])
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include "shader/prog_parameter.h"
|
||||
#include "shader/prog_print.h"
|
||||
|
||||
#include "st_debug.h"
|
||||
#include "st_context.h"
|
||||
#include "st_atom.h"
|
||||
#include "st_atom_constbuf.h"
|
||||
@@ -1090,6 +1091,9 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
||||
struct pipe_transfer *ptTex;
|
||||
enum pipe_transfer_usage transfer_usage;
|
||||
|
||||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s: fallback processing\n", __FUNCTION__);
|
||||
|
||||
if (type == GL_DEPTH && pf_is_depth_and_stencil(pt->format))
|
||||
transfer_usage = PIPE_TRANSFER_READ_WRITE;
|
||||
else
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "util/u_tile.h"
|
||||
|
||||
#include "st_debug.h"
|
||||
#include "st_context.h"
|
||||
#include "st_cb_bitmap.h"
|
||||
#include "st_cb_readpixels.h"
|
||||
@@ -416,6 +417,9 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
yStep = 1;
|
||||
}
|
||||
|
||||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s: fallback processing\n", __FUNCTION__);
|
||||
|
||||
/*
|
||||
* Copy pixels from pipe_transfer to user memory
|
||||
*/
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include "main/texobj.h"
|
||||
#include "main/texstore.h"
|
||||
|
||||
#include "state_tracker/st_debug.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
#include "state_tracker/st_cb_fbo.h"
|
||||
#include "state_tracker/st_cb_texture.h"
|
||||
@@ -903,6 +904,9 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
|
||||
GLvoid *dest = _mesa_image_address2d(&ctx->Pack, pixels, width,
|
||||
height, format, type, row, 0);
|
||||
|
||||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s: fallback format translation\n", __FUNCTION__);
|
||||
|
||||
/* get float[4] rgba row from surface */
|
||||
pipe_get_tile_rgba(tex_xfer, 0, row, width, 1, rgba);
|
||||
|
||||
@@ -1295,6 +1299,9 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLvoid *texDest;
|
||||
enum pipe_transfer_usage transfer_usage;
|
||||
|
||||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s: fallback processing\n", __FUNCTION__);
|
||||
|
||||
assert(width <= MAX_WIDTH);
|
||||
|
||||
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
@@ -1419,6 +1426,12 @@ compatible_src_dst_formats(const struct gl_renderbuffer *src,
|
||||
return TGSI_WRITEMASK_XYZ; /* A ==> 1.0 */
|
||||
}
|
||||
else {
|
||||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s failed for src %s, dst %s\n",
|
||||
__FUNCTION__,
|
||||
_mesa_lookup_enum_by_nr(srcFormat),
|
||||
_mesa_lookup_enum_by_nr(dstLogicalFormat));
|
||||
|
||||
/* Otherwise fail.
|
||||
*/
|
||||
return 0;
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include "shader/shader_api.h"
|
||||
#include "glapi/glapi.h"
|
||||
#include "st_public.h"
|
||||
#include "st_debug.h"
|
||||
#include "st_context.h"
|
||||
#include "st_cb_accum.h"
|
||||
#include "st_cb_bitmap.h"
|
||||
@@ -113,6 +114,9 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
|
||||
st->ctx = ctx;
|
||||
st->pipe = pipe;
|
||||
|
||||
/* XXX: this is one-off, per-screen init: */
|
||||
st_debug_init();
|
||||
|
||||
/* state tracker needs the VBO module */
|
||||
_vbo_CreateContext(ctx);
|
||||
|
||||
|
@@ -41,6 +41,32 @@
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
int ST_DEBUG = 0;
|
||||
|
||||
static const struct debug_named_value st_debug_flags[] = {
|
||||
{ "mesa", DEBUG_MESA },
|
||||
{ "tgsi", DEBUG_TGSI },
|
||||
{ "pipe", DEBUG_PIPE },
|
||||
{ "tex", DEBUG_TEX },
|
||||
{ "fallback", DEBUG_FALLBACK },
|
||||
{ "screen", DEBUG_SCREEN },
|
||||
{ "query", DEBUG_QUERY },
|
||||
{NULL, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
st_debug_init(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
ST_DEBUG = debug_get_flags_option("ST_DEBUG", st_debug_flags, 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Print current state. May be called from inside gdb to see currently
|
||||
* bound vertex/fragment shaders and associated constants.
|
||||
@@ -68,3 +94,5 @@ st_print_current(void)
|
||||
if (st->fp->Base.Base.Parameters)
|
||||
_mesa_print_parameter_list(st->fp->Base.Base.Parameters);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -29,8 +29,44 @@
|
||||
#ifndef ST_DEBUG_H
|
||||
#define ST_DEBUG_H
|
||||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "util/u_debug.h"
|
||||
|
||||
extern void
|
||||
st_print_current(void);
|
||||
|
||||
|
||||
#define DEBUG_MESA 0x1
|
||||
#define DEBUG_TGSI 0x2
|
||||
#define DEBUG_CONSTANTS 0x4
|
||||
#define DEBUG_PIPE 0x8
|
||||
#define DEBUG_TEX 0x10
|
||||
#define DEBUG_FALLBACK 0x20
|
||||
#define DEBUG_QUERY 0x40
|
||||
#define DEBUG_SCREEN 0x80
|
||||
|
||||
#ifdef DEBUG
|
||||
extern int ST_DEBUG;
|
||||
#define DBSTR(x) x
|
||||
#else
|
||||
#define ST_DEBUG 0
|
||||
#define DBSTR(x) ""
|
||||
#endif
|
||||
|
||||
void st_debug_init( void );
|
||||
|
||||
static INLINE void
|
||||
ST_DBG( unsigned flag, const char *fmt, ... )
|
||||
{
|
||||
if (ST_DEBUG & flag)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, fmt );
|
||||
debug_vprintf( fmt, args );
|
||||
va_end( args );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* ST_DEBUG_H */
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#include "cso_cache/cso_cache.h"
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
#include "st_debug.h"
|
||||
#include "st_context.h"
|
||||
#include "st_draw.h"
|
||||
#include "st_gen_mipmap.h"
|
||||
@@ -114,6 +115,9 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
|
||||
GLenum datatype;
|
||||
GLuint comps;
|
||||
|
||||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s: fallback processing\n", __FUNCTION__);
|
||||
|
||||
assert(target != GL_TEXTURE_3D); /* not done yet */
|
||||
|
||||
_mesa_format_to_type_and_comps(texObj->Image[face][baseLevel]->TexFormat,
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#include "draw/draw_context.h"
|
||||
#include "tgsi/tgsi_dump.h"
|
||||
|
||||
#include "st_debug.h"
|
||||
#include "st_context.h"
|
||||
#include "st_atom.h"
|
||||
#include "st_program.h"
|
||||
@@ -49,9 +50,6 @@
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
|
||||
#define TGSI_DEBUG 0
|
||||
|
||||
|
||||
/**
|
||||
* Translate a Mesa vertex shader into a TGSI shader.
|
||||
* \param outputMapping to map vertex program output registers (VERT_RESULT_x)
|
||||
@@ -346,11 +344,15 @@ st_translate_vertex_program(struct st_context *st,
|
||||
stvp->num_inputs = vs_num_inputs;
|
||||
stvp->driver_shader = pipe->create_vs_state(pipe, &stvp->state);
|
||||
|
||||
if (0)
|
||||
if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
|
||||
_mesa_print_program(&stvp->Base.Base);
|
||||
debug_printf("\n");
|
||||
}
|
||||
|
||||
if (TGSI_DEBUG)
|
||||
if (ST_DEBUG & DEBUG_TGSI) {
|
||||
tgsi_dump( stvp->state.tokens, 0 );
|
||||
debug_printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -526,11 +528,15 @@ st_translate_fragment_program(struct st_context *st,
|
||||
|
||||
stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->state);
|
||||
|
||||
if (0)
|
||||
if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
|
||||
_mesa_print_program(&stfp->Base.Base);
|
||||
debug_printf("\n");
|
||||
}
|
||||
|
||||
if (TGSI_DEBUG)
|
||||
if (ST_DEBUG & DEBUG_TGSI) {
|
||||
tgsi_dump( stfp->state.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
|
||||
debug_printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user