summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/trace
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-08-08 23:53:53 +0100
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-08-09 14:10:25 +0100
commitb65259de6c0a2e77550bbef6b291c6d09dfb5867 (patch)
tree747fdb6eda554079bee20140a11bb25e663c38d9 /src/gallium/drivers/trace
parent6c7aff209ca3b310008dd345836ebc020d2db004 (diff)
trace: Allow to dump binary data.
Diffstat (limited to 'src/gallium/drivers/trace')
-rw-r--r--src/gallium/drivers/trace/tr_dump.c19
-rw-r--r--src/gallium/drivers/trace/tr_dump.h1
-rw-r--r--src/gallium/drivers/trace/tr_state.c38
-rw-r--r--src/gallium/drivers/trace/trace.xsl6
4 files changed, 37 insertions, 27 deletions
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 359a903ab9..f545de30f4 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -272,6 +272,25 @@ void trace_dump_float(struct trace_stream *stream,
trace_dump_writef(stream, "<float>%g</float>", value);
}
+void trace_dump_bytes(struct trace_stream *stream,
+ const void *data,
+ long unsigned size)
+{
+ static char hex_table[] = "0123456789ABCDE";
+ const uint8_t *p = data;
+ long unsigned i;
+ trace_dump_write(stream, "<bytes>");
+ for(i = 0; i < size; ++i) {
+ uint8_t byte = *p++;
+ char str[3];
+ str[0] = hex_table[byte >> 4];
+ str[1] = hex_table[byte & 0xf];
+ str[2] = 0;
+ trace_dump_write(stream, str);
+ }
+ trace_dump_write(stream, "</bytes>");
+}
+
void trace_dump_string(struct trace_stream *stream,
const char *str)
{
diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h
index 7b15da3033..b2367c3288 100644
--- a/src/gallium/drivers/trace/tr_dump.h
+++ b/src/gallium/drivers/trace/tr_dump.h
@@ -52,6 +52,7 @@ void trace_dump_bool(struct trace_stream *stream, int value);
void trace_dump_int(struct trace_stream *stream, long int value);
void trace_dump_uint(struct trace_stream *stream, long unsigned value);
void trace_dump_float(struct trace_stream *stream, double value);
+void trace_dump_bytes(struct trace_stream *stream, const void *data, long unsigned size);
void trace_dump_string(struct trace_stream *stream, const char *str);
void trace_dump_enum(struct trace_stream *stream, const char *value);
void trace_dump_array_begin(struct trace_stream *stream);
diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c
index f17006dd81..e0e48185fa 100644
--- a/src/gallium/drivers/trace/tr_state.c
+++ b/src/gallium/drivers/trace/tr_state.c
@@ -51,23 +51,6 @@ void trace_dump_block(struct trace_stream *stream,
}
-void trace_dump_buffer(struct trace_stream *stream,
- const struct pipe_buffer *buffer)
-{
- if(!buffer) {
- trace_dump_null(stream);
- return;
- }
-
- trace_dump_struct_begin(stream, "pipe_buffer");
- trace_dump_member(stream, uint, buffer, alignment);
- trace_dump_member(stream, uint, buffer, usage);
- trace_dump_member(stream, uint, buffer, size);
- /* TODO: buffer data */
- trace_dump_struct_end(stream);
-}
-
-
void trace_dump_template(struct trace_stream *stream,
const struct pipe_texture *templat)
{
@@ -162,7 +145,11 @@ void trace_dump_poly_stipple(struct trace_stream *stream,
trace_dump_struct_begin(stream, "pipe_poly_stipple");
- trace_dump_member_array(stream, uint, state, stipple);
+ trace_dump_member_begin(stream, "stipple");
+ trace_dump_bytes(stream,
+ state->stipple,
+ sizeof(state->stipple));
+ trace_dump_member_end(stream);
trace_dump_struct_end(stream);
}
@@ -243,7 +230,7 @@ void trace_dump_constant_buffer(struct trace_stream *stream,
trace_dump_struct_begin(stream, "pipe_constant_buffer");
- trace_dump_member(stream, buffer, state, buffer);
+ trace_dump_member(stream, ptr, state, buffer);
trace_dump_member(stream, uint, state, size);
trace_dump_struct_end(stream);
@@ -253,21 +240,18 @@ void trace_dump_constant_buffer(struct trace_stream *stream,
void trace_dump_shader_state(struct trace_stream *stream,
const struct pipe_shader_state *state)
{
- uint32_t *p = (uint32_t *)state->tokens;
- unsigned n = tgsi_num_tokens(state->tokens);
-
assert(state);
if(!state) {
trace_dump_null(stream);
return;
}
- assert(sizeof(struct tgsi_token) == 4);
-
trace_dump_struct_begin(stream, "pipe_shader_state");
trace_dump_member_begin(stream, "tokens");
- trace_dump_array(stream, uint, p, n);
+ trace_dump_bytes(stream,
+ state->tokens,
+ sizeof(struct tgsi_token) * tgsi_num_tokens(state->tokens));
trace_dump_member_end(stream);
trace_dump_struct_end(stream);
@@ -433,7 +417,7 @@ void trace_dump_surface(struct trace_stream *stream,
trace_dump_struct_begin(stream, "pipe_surface");
- trace_dump_member(stream, buffer, state, buffer);
+ trace_dump_member(stream, ptr, state, buffer);
trace_dump_member(stream, format, state, format);
trace_dump_member(stream, uint, state, status);
trace_dump_member(stream, uint, state, clear_value);
@@ -475,7 +459,7 @@ void trace_dump_vertex_buffer(struct trace_stream *stream,
trace_dump_member(stream, uint, state, pitch);
trace_dump_member(stream, uint, state, max_index);
trace_dump_member(stream, uint, state, buffer_offset);
- trace_dump_member(stream, buffer, state, buffer);
+ trace_dump_member(stream, ptr, state, buffer);
trace_dump_struct_end(stream);
}
diff --git a/src/gallium/drivers/trace/trace.xsl b/src/gallium/drivers/trace/trace.xsl
index 13039d44c4..991e5bf935 100644
--- a/src/gallium/drivers/trace/trace.xsl
+++ b/src/gallium/drivers/trace/trace.xsl
@@ -100,6 +100,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</span>
</xsl:template>
+ <xsl:template match="bytes">
+ <span class="lit">
+ <xsl:text>...</xsl:text>
+ </span>
+ </xsl:template>
+
<xsl:template match="string">
<span class="lit">
<xsl:text>"</xsl:text>