1 /**************************************************************************
3 * Copyright 2007 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include "main/context.h"
30 #include "main/debug_output.h"
31 #include "program/prog_print.h"
33 #include "pipe/p_state.h"
34 #include "pipe/p_shader_tokens.h"
35 #include "tgsi/tgsi_dump.h"
37 #include "cso_cache/cso_cache.h"
39 #include "st_context.h"
41 #include "st_program.h"
48 static const struct debug_named_value st_debug_flags
[] = {
49 { "mesa", DEBUG_MESA
, NULL
},
50 { "tgsi", DEBUG_TGSI
, NULL
},
51 { "constants",DEBUG_CONSTANTS
, NULL
},
52 { "pipe", DEBUG_PIPE
, NULL
},
53 { "tex", DEBUG_TEX
, NULL
},
54 { "fallback", DEBUG_FALLBACK
, NULL
},
55 { "screen", DEBUG_SCREEN
, NULL
},
56 { "query", DEBUG_QUERY
, NULL
},
57 { "draw", DEBUG_DRAW
, NULL
},
58 { "buffer", DEBUG_BUFFER
, NULL
},
59 { "wf", DEBUG_WIREFRAME
, NULL
},
60 { "precompile", DEBUG_PRECOMPILE
, NULL
},
61 { "gremedy", DEBUG_GREMEDY
, "Enable GREMEDY debug extensions" },
62 { "noreadpixcache", DEBUG_NOREADPIXCACHE
, NULL
},
66 DEBUG_GET_ONCE_FLAGS_OPTION(st_debug
, "ST_DEBUG", st_debug_flags
, 0)
74 ST_DEBUG
= debug_get_option_st_debug();
81 * Print current state. May be called from inside gdb to see currently
82 * bound vertex/fragment shaders and associated constants.
85 st_print_current(void)
87 GET_CURRENT_CONTEXT(ctx
);
88 struct st_context
*st
= st_context(ctx
);
93 printf("Vertex Transform Inputs:\n");
94 for (i
= 0; i
< st
->vp
->state
.num_inputs
; i
++) {
95 printf(" Slot %d: VERT_ATTRIB_%d\n", i
, st
->vp
->index_to_input
[i
]);
100 tgsi_dump( st
->vp
->variants
[0].tgsi
.tokens
, 0 );
101 if (st
->vp
->Base
.Parameters
)
102 _mesa_print_parameter_list(st
->vp
->Base
.Parameters
);
104 tgsi_dump(st
->fp
->tgsi
.tokens
, 0);
105 if (st
->fp
->Base
.Base
.Parameters
)
106 _mesa_print_parameter_list(st
->fp
->Base
.Base
.Parameters
);
111 * Installed as pipe_debug_callback when GL_DEBUG_OUTPUT is enabled.
114 st_debug_message(void *data
,
116 enum pipe_debug_type ptype
,
120 struct st_context
*st
= data
;
121 enum mesa_debug_source source
;
122 enum mesa_debug_type type
;
123 enum mesa_debug_severity severity
;
126 case PIPE_DEBUG_TYPE_OUT_OF_MEMORY
:
127 source
= MESA_DEBUG_SOURCE_API
;
128 type
= MESA_DEBUG_TYPE_ERROR
;
129 severity
= MESA_DEBUG_SEVERITY_MEDIUM
;
131 case PIPE_DEBUG_TYPE_ERROR
:
132 source
= MESA_DEBUG_SOURCE_API
;
133 type
= MESA_DEBUG_TYPE_ERROR
;
134 severity
= MESA_DEBUG_SEVERITY_MEDIUM
;
136 case PIPE_DEBUG_TYPE_SHADER_INFO
:
137 source
= MESA_DEBUG_SOURCE_SHADER_COMPILER
;
138 type
= MESA_DEBUG_TYPE_OTHER
;
139 severity
= MESA_DEBUG_SEVERITY_NOTIFICATION
;
141 case PIPE_DEBUG_TYPE_PERF_INFO
:
142 source
= MESA_DEBUG_SOURCE_API
;
143 type
= MESA_DEBUG_TYPE_PERFORMANCE
;
144 severity
= MESA_DEBUG_SEVERITY_NOTIFICATION
;
146 case PIPE_DEBUG_TYPE_INFO
:
147 source
= MESA_DEBUG_SOURCE_API
;
148 type
= MESA_DEBUG_TYPE_OTHER
;
149 severity
= MESA_DEBUG_SEVERITY_NOTIFICATION
;
151 case PIPE_DEBUG_TYPE_FALLBACK
:
152 source
= MESA_DEBUG_SOURCE_API
;
153 type
= MESA_DEBUG_TYPE_PERFORMANCE
;
154 severity
= MESA_DEBUG_SEVERITY_NOTIFICATION
;
156 case PIPE_DEBUG_TYPE_CONFORMANCE
:
157 source
= MESA_DEBUG_SOURCE_API
;
158 type
= MESA_DEBUG_TYPE_OTHER
;
159 severity
= MESA_DEBUG_SEVERITY_NOTIFICATION
;
162 unreachable("invalid debug type");
164 _mesa_gl_vdebug(st
->ctx
, id
, source
, type
, severity
, fmt
, args
);
168 st_update_debug_callback(struct st_context
*st
)
170 struct pipe_context
*pipe
= st
->pipe
;
172 if (!pipe
->set_debug_callback
)
175 if (_mesa_get_debug_state_int(st
->ctx
, GL_DEBUG_OUTPUT
)) {
176 struct pipe_debug_callback cb
;
177 memset(&cb
, 0, sizeof(cb
));
178 cb
.async
= !_mesa_get_debug_state_int(st
->ctx
, GL_DEBUG_OUTPUT_SYNCHRONOUS
);
179 cb
.debug_message
= st_debug_message
;
181 pipe
->set_debug_callback(pipe
, &cb
);
183 pipe
->set_debug_callback(pipe
, NULL
);