summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/driver_trace
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2021-07-22 10:17:30 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2021-07-22 10:17:30 +0000
commitca11beabae33eb59fb981b8adf50b1d47a2a98f0 (patch)
tree3e4691a396e6e54cd54224a190663d5cf976625b /lib/mesa/src/gallium/auxiliary/driver_trace
parent27c8a50e8bbde7d28b1fc46d715a4c469e24f2c4 (diff)
Import Mesa 21.1.5
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/driver_trace')
-rw-r--r--lib/mesa/src/gallium/auxiliary/driver_trace/README2
-rw-r--r--lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.c204
-rw-r--r--lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.h8
-rw-r--r--lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.c52
-rw-r--r--lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.h4
-rw-r--r--lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.c100
-rw-r--r--lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.h8
-rw-r--r--lib/mesa/src/gallium/auxiliary/driver_trace/tr_screen.c171
-rw-r--r--lib/mesa/src/gallium/auxiliary/driver_trace/tr_texture.c2
9 files changed, 486 insertions, 65 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/driver_trace/README b/lib/mesa/src/gallium/auxiliary/driver_trace/README
index fbad26c44..a4d1b98d2 100644
--- a/lib/mesa/src/gallium/auxiliary/driver_trace/README
+++ b/lib/mesa/src/gallium/auxiliary/driver_trace/README
@@ -33,7 +33,7 @@ For remote debugging see:
= Integrating =
-You can integrate the trace pipe driver either inside the state tracker or the
+You can integrate the trace pipe driver either inside the gallium frontend or the
target. The procedure on both cases is the same. Let's assume you have a
pipe_screen obtained by the usual means (variable and function names are just
for illustration purposes):
diff --git a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.c b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.c
index 083458dc1..1252d367b 100644
--- a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.c
+++ b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.c
@@ -25,9 +25,11 @@
*
**************************************************************************/
+#include "util/ralloc.h"
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/simple_list.h"
+#include "util/u_framebuffer.h"
#include "pipe/p_format.h"
#include "pipe/p_screen.h"
@@ -86,22 +88,51 @@ trace_surface_unwrap(struct trace_context *tr_ctx,
return tr_surf->surface;
}
+static void
+dump_fb_state(struct trace_context *tr_ctx,
+ const char *method,
+ bool deep)
+{
+ struct pipe_context *pipe = tr_ctx->pipe;
+
+ trace_dump_call_begin("pipe_context", method);
+
+ trace_dump_arg(ptr, pipe);
+ if (deep)
+ trace_dump_arg(framebuffer_state_deep, &tr_ctx->unwrapped_state);
+ else
+ trace_dump_arg(framebuffer_state, &tr_ctx->unwrapped_state);
+ trace_dump_call_end();
+
+ tr_ctx->seen_fb_state = true;
+}
static void
trace_context_draw_vbo(struct pipe_context *_pipe,
- const struct pipe_draw_info *info)
+ const struct pipe_draw_info *info,
+ const struct pipe_draw_indirect_info *indirect,
+ const struct pipe_draw_start_count *draws,
+ unsigned num_draws)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
+ if (!tr_ctx->seen_fb_state && trace_dump_is_triggered())
+ dump_fb_state(tr_ctx, "current_framebuffer_state", true);
+
trace_dump_call_begin("pipe_context", "draw_vbo");
trace_dump_arg(ptr, pipe);
trace_dump_arg(draw_info, info);
+ trace_dump_arg(draw_indirect_info, indirect);
+ trace_dump_arg_begin("draws");
+ trace_dump_struct_array(draw_start_count, draws, num_draws);
+ trace_dump_arg_end();
+ trace_dump_arg(uint, num_draws);
trace_dump_trace_flush();
- pipe->draw_vbo(pipe, info);
+ pipe->draw_vbo(pipe, info, indirect, draws, num_draws);
trace_dump_call_end();
}
@@ -283,6 +314,12 @@ trace_context_create_blend_state(struct pipe_context *_pipe,
trace_dump_call_end();
+ struct pipe_blend_state *blend = ralloc(tr_ctx, struct pipe_blend_state);
+ if (blend) {
+ memcpy(blend, state, sizeof(struct pipe_blend_state));
+ _mesa_hash_table_insert(&tr_ctx->blend_states, result, blend);
+ }
+
return result;
}
@@ -297,7 +334,14 @@ trace_context_bind_blend_state(struct pipe_context *_pipe,
trace_dump_call_begin("pipe_context", "bind_blend_state");
trace_dump_arg(ptr, pipe);
- trace_dump_arg(ptr, state);
+ if (state && trace_dump_is_triggered()) {
+ struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->blend_states, state);
+ if (he)
+ trace_dump_arg(blend_state, he->data);
+ else
+ trace_dump_arg(blend_state, NULL);
+ } else
+ trace_dump_arg(ptr, state);
pipe->bind_blend_state(pipe, state);
@@ -319,6 +363,14 @@ trace_context_delete_blend_state(struct pipe_context *_pipe,
pipe->delete_blend_state(pipe, state);
+ if (state) {
+ struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->blend_states, state);
+ if (he) {
+ ralloc_free(he->data);
+ _mesa_hash_table_remove(&tr_ctx->blend_states, he);
+ }
+ }
+
trace_dump_call_end();
}
@@ -410,6 +462,12 @@ trace_context_create_rasterizer_state(struct pipe_context *_pipe,
trace_dump_call_end();
+ struct pipe_rasterizer_state *rasterizer = ralloc(tr_ctx, struct pipe_rasterizer_state);
+ if (rasterizer) {
+ memcpy(rasterizer, state, sizeof(struct pipe_rasterizer_state));
+ _mesa_hash_table_insert(&tr_ctx->rasterizer_states, result, rasterizer);
+ }
+
return result;
}
@@ -424,7 +482,14 @@ trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
trace_dump_call_begin("pipe_context", "bind_rasterizer_state");
trace_dump_arg(ptr, pipe);
- trace_dump_arg(ptr, state);
+ if (state && trace_dump_is_triggered()) {
+ struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->rasterizer_states, state);
+ if (he)
+ trace_dump_arg(rasterizer_state, he->data);
+ else
+ trace_dump_arg(rasterizer_state, NULL);
+ } else
+ trace_dump_arg(ptr, state);
pipe->bind_rasterizer_state(pipe, state);
@@ -447,6 +512,14 @@ trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
pipe->delete_rasterizer_state(pipe, state);
trace_dump_call_end();
+
+ if (state) {
+ struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->rasterizer_states, state);
+ if (he) {
+ ralloc_free(he->data);
+ _mesa_hash_table_remove(&tr_ctx->rasterizer_states, he);
+ }
+ }
}
@@ -469,6 +542,12 @@ trace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
trace_dump_call_end();
+ struct pipe_depth_stencil_alpha_state *depth_stencil_alpha = ralloc(tr_ctx, struct pipe_depth_stencil_alpha_state);
+ if (depth_stencil_alpha) {
+ memcpy(depth_stencil_alpha, state, sizeof(struct pipe_depth_stencil_alpha_state));
+ _mesa_hash_table_insert(&tr_ctx->depth_stencil_alpha_states, result, depth_stencil_alpha);
+ }
+
return result;
}
@@ -483,7 +562,14 @@ trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
trace_dump_call_begin("pipe_context", "bind_depth_stencil_alpha_state");
trace_dump_arg(ptr, pipe);
- trace_dump_arg(ptr, state);
+ if (state && trace_dump_is_triggered()) {
+ struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->depth_stencil_alpha_states, state);
+ if (he)
+ trace_dump_arg(depth_stencil_alpha_state, he->data);
+ else
+ trace_dump_arg(depth_stencil_alpha_state, NULL);
+ } else
+ trace_dump_arg(ptr, state);
pipe->bind_depth_stencil_alpha_state(pipe, state);
@@ -506,6 +592,14 @@ trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
pipe->delete_depth_stencil_alpha_state(pipe, state);
trace_dump_call_end();
+
+ if (state) {
+ struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->depth_stencil_alpha_states, state);
+ if (he) {
+ ralloc_free(he->data);
+ _mesa_hash_table_remove(&tr_ctx->depth_stencil_alpha_states, he);
+ }
+ }
}
@@ -690,7 +784,7 @@ trace_context_set_blend_color(struct pipe_context *_pipe,
static void
trace_context_set_stencil_ref(struct pipe_context *_pipe,
- const struct pipe_stencil_ref *state)
+ const struct pipe_stencil_ref state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
@@ -698,7 +792,7 @@ trace_context_set_stencil_ref(struct pipe_context *_pipe,
trace_dump_call_begin("pipe_context", "set_stencil_ref");
trace_dump_arg(ptr, pipe);
- trace_dump_arg(stencil_ref, state);
+ trace_dump_arg(stencil_ref, &state);
pipe->set_stencil_ref(pipe, state);
@@ -743,6 +837,7 @@ trace_context_set_sample_mask(struct pipe_context *_pipe,
static void
trace_context_set_constant_buffer(struct pipe_context *_pipe,
enum pipe_shader_type shader, uint index,
+ bool take_ownership,
const struct pipe_constant_buffer *constant_buffer)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -753,9 +848,10 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe,
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, shader);
trace_dump_arg(uint, index);
+ trace_dump_arg(bool, take_ownership);
trace_dump_arg(constant_buffer, constant_buffer);
- pipe->set_constant_buffer(pipe, shader, index, constant_buffer);
+ pipe->set_constant_buffer(pipe, shader, index, take_ownership, constant_buffer);
trace_dump_call_end();
}
@@ -767,25 +863,37 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe,
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
- struct pipe_framebuffer_state unwrapped_state;
unsigned i;
-
/* Unwrap the input state */
- memcpy(&unwrapped_state, state, sizeof(unwrapped_state));
+ memcpy(&tr_ctx->unwrapped_state, state, sizeof(tr_ctx->unwrapped_state));
for (i = 0; i < state->nr_cbufs; ++i)
- unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
+ tr_ctx->unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
for (i = state->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; ++i)
- unwrapped_state.cbufs[i] = NULL;
- unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
- state = &unwrapped_state;
+ tr_ctx->unwrapped_state.cbufs[i] = NULL;
+ tr_ctx->unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
+ state = &tr_ctx->unwrapped_state;
+
+ dump_fb_state(tr_ctx, "set_framebuffer_state", trace_dump_is_triggered());
- trace_dump_call_begin("pipe_context", "set_framebuffer_state");
+ pipe->set_framebuffer_state(pipe, state);
+}
+
+static void
+trace_context_set_inlinable_constants(struct pipe_context *_pipe, enum pipe_shader_type shader,
+ uint num_values, uint32_t *values)
+{
+ struct trace_context *tr_ctx = trace_context(_pipe);
+ struct pipe_context *pipe = tr_ctx->pipe;
+
+ trace_dump_call_begin("pipe_context", "set_inlinable_constants");
trace_dump_arg(ptr, pipe);
- trace_dump_arg(framebuffer_state, state);
+ trace_dump_arg(uint, shader);
+ trace_dump_arg(uint, num_values);
+ trace_dump_arg_array(uint, values, num_values);
- pipe->set_framebuffer_state(pipe, state);
+ pipe->set_inlinable_constants(pipe, shader, num_values, values);
trace_dump_call_end();
}
@@ -808,6 +916,23 @@ trace_context_set_polygon_stipple(struct pipe_context *_pipe,
trace_dump_call_end();
}
+static void
+trace_context_set_min_samples(struct pipe_context *_pipe,
+ unsigned min_samples)
+{
+ struct trace_context *tr_ctx = trace_context(_pipe);
+ struct pipe_context *pipe = tr_ctx->pipe;
+
+ trace_dump_call_begin("pipe_context", "set_min_samples");
+
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, min_samples);
+
+ pipe->set_min_samples(pipe, min_samples);
+
+ trace_dump_call_end();
+}
+
static void
trace_context_set_scissor_states(struct pipe_context *_pipe,
@@ -979,6 +1104,7 @@ trace_context_set_sampler_views(struct pipe_context *_pipe,
enum pipe_shader_type shader,
unsigned start,
unsigned num,
+ unsigned unbind_num_trailing_slots,
struct pipe_sampler_view **views)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -1002,9 +1128,11 @@ trace_context_set_sampler_views(struct pipe_context *_pipe,
trace_dump_arg(uint, shader);
trace_dump_arg(uint, start);
trace_dump_arg(uint, num);
+ trace_dump_arg(uint, unbind_num_trailing_slots);
trace_dump_arg_array(ptr, views, num);
- pipe->set_sampler_views(pipe, shader, start, num, views);
+ pipe->set_sampler_views(pipe, shader, start, num,
+ unbind_num_trailing_slots, views);
trace_dump_call_end();
}
@@ -1013,6 +1141,8 @@ trace_context_set_sampler_views(struct pipe_context *_pipe,
static void
trace_context_set_vertex_buffers(struct pipe_context *_pipe,
unsigned start_slot, unsigned num_buffers,
+ unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -1023,12 +1153,16 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe,
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, start_slot);
trace_dump_arg(uint, num_buffers);
+ trace_dump_arg(uint, unbind_num_trailing_slots);
+ trace_dump_arg(bool, take_ownership);
trace_dump_arg_begin("buffers");
trace_dump_struct_array(vertex_buffer, buffers, num_buffers);
trace_dump_arg_end();
- pipe->set_vertex_buffers(pipe, start_slot, num_buffers, buffers);
+ pipe->set_vertex_buffers(pipe, start_slot, num_buffers,
+ unbind_num_trailing_slots, take_ownership,
+ buffers);
trace_dump_call_end();
}
@@ -1175,6 +1309,7 @@ trace_context_flush_resource(struct pipe_context *_pipe,
static void
trace_context_clear(struct pipe_context *_pipe,
unsigned buffers,
+ const struct pipe_scissor_state *scissor_state,
const union pipe_color_union *color,
double depth,
unsigned stencil)
@@ -1186,6 +1321,9 @@ trace_context_clear(struct pipe_context *_pipe,
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, buffers);
+ trace_dump_arg_begin("scissor_state");
+ trace_dump_scissor_state(scissor_state);
+ trace_dump_arg_end();
trace_dump_arg_begin("color");
if (color)
trace_dump_array(float, color->f, 4);
@@ -1195,7 +1333,7 @@ trace_context_clear(struct pipe_context *_pipe,
trace_dump_arg(float, depth);
trace_dump_arg(uint, stencil);
- pipe->clear(pipe, buffers, color, depth, stencil);
+ pipe->clear(pipe, buffers, scissor_state, color, depth, stencil);
trace_dump_call_end();
}
@@ -1311,6 +1449,11 @@ trace_context_flush(struct pipe_context *_pipe,
trace_dump_ret(ptr, *fence);
trace_dump_call_end();
+
+ if (flags & PIPE_FLUSH_END_OF_FRAME) {
+ trace_dump_check_trigger();
+ tr_ctx->seen_fb_state = false;
+ }
}
@@ -1402,7 +1545,7 @@ trace_context_destroy(struct pipe_context *_pipe)
pipe->destroy(pipe);
- FREE(tr_ctx);
+ ralloc_free(tr_ctx);
}
@@ -1436,7 +1579,7 @@ trace_context_transfer_map(struct pipe_context *_context,
*transfer = trace_transfer_create(tr_context, resource, result);
if (map) {
- if (usage & PIPE_TRANSFER_WRITE) {
+ if (usage & PIPE_MAP_WRITE) {
trace_transfer(*transfer)->map = map;
}
}
@@ -1746,8 +1889,8 @@ static void trace_context_set_shader_buffers(struct pipe_context *_context,
trace_dump_arg(uint, start);
trace_dump_arg_begin("buffers");
trace_dump_struct_array(shader_buffer, buffers, nr);
- trace_dump_arg(uint, writable_bitmask);
trace_dump_arg_end();
+ trace_dump_arg(uint, writable_bitmask);
trace_dump_call_end();
context->set_shader_buffers(context, shader, start, nr, buffers,
@@ -1757,6 +1900,7 @@ static void trace_context_set_shader_buffers(struct pipe_context *_context,
static void trace_context_set_shader_images(struct pipe_context *_context,
enum pipe_shader_type shader,
unsigned start, unsigned nr,
+ unsigned unbind_num_trailing_slots,
const struct pipe_image_view *images)
{
struct trace_context *tr_context = trace_context(_context);
@@ -1769,9 +1913,11 @@ static void trace_context_set_shader_images(struct pipe_context *_context,
trace_dump_arg_begin("images");
trace_dump_struct_array(image_view, images, nr);
trace_dump_arg_end();
+ trace_dump_arg(uint, unbind_num_trailing_slots);
trace_dump_call_end();
- context->set_shader_images(context, shader, start, nr, images);
+ context->set_shader_images(context, shader, start, nr,
+ unbind_num_trailing_slots, images);
}
static void trace_context_launch_grid(struct pipe_context *_pipe,
@@ -1910,10 +2056,14 @@ trace_context_create(struct trace_screen *tr_scr,
if (!trace_enabled())
goto error1;
- tr_ctx = CALLOC_STRUCT(trace_context);
+ tr_ctx = ralloc(NULL, struct trace_context);
if (!tr_ctx)
goto error1;
+ _mesa_hash_table_init(&tr_ctx->blend_states, tr_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal);
+ _mesa_hash_table_init(&tr_ctx->rasterizer_states, tr_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal);
+ _mesa_hash_table_init(&tr_ctx->depth_stencil_alpha_states, tr_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal);
+
tr_ctx->base.priv = pipe->priv; /* expose wrapped priv data */
tr_ctx->base.screen = &tr_scr->base;
tr_ctx->base.stream_uploader = pipe->stream_uploader;
@@ -1971,7 +2121,9 @@ trace_context_create(struct trace_screen *tr_scr,
TR_CTX_INIT(set_sample_mask);
TR_CTX_INIT(set_constant_buffer);
TR_CTX_INIT(set_framebuffer_state);
+ TR_CTX_INIT(set_inlinable_constants);
TR_CTX_INIT(set_polygon_stipple);
+ TR_CTX_INIT(set_min_samples);
TR_CTX_INIT(set_scissor_states);
TR_CTX_INIT(set_viewport_states);
TR_CTX_INIT(set_sampler_views);
diff --git a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.h b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.h
index ad57d9d52..95469e875 100644
--- a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.h
+++ b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_context.h
@@ -31,6 +31,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
+#include "util/hash_table.h"
#include "pipe/p_context.h"
#include "tr_screen.h"
@@ -46,7 +47,14 @@ struct trace_context
{
struct pipe_context base;
+ struct hash_table blend_states;
+ struct hash_table rasterizer_states;
+ struct hash_table depth_stencil_alpha_states;
+
struct pipe_context *pipe;
+
+ struct pipe_framebuffer_state unwrapped_state;
+ bool seen_fb_state;
};
diff --git a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.c b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.c
index 0be21ac6f..9032ddfce 100644
--- a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.c
+++ b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.c
@@ -43,6 +43,11 @@
#include <stdio.h>
#include <stdlib.h>
+/* for access() */
+#ifdef _WIN32
+# include <io.h>
+#endif
+
#include "pipe/p_compiler.h"
#include "os/os_thread.h"
#include "util/os_time.h"
@@ -63,11 +68,47 @@ static mtx_t call_mutex = _MTX_INITIALIZER_NP;
static long unsigned call_no = 0;
static bool dumping = false;
+static bool trigger_active = true;
+static char *trigger_filename = NULL;
+
+void
+trace_dump_trigger_active(bool active)
+{
+ trigger_active = active;
+}
+
+void
+trace_dump_check_trigger(void)
+{
+ if (!trigger_filename)
+ return;
+
+ mtx_lock(&call_mutex);
+ if (trigger_active) {
+ trigger_active = false;
+ } else {
+ if (!access(trigger_filename, 2 /* W_OK but compiles on Windows */)) {
+ if (!unlink(trigger_filename)) {
+ trigger_active = true;
+ } else {
+ fprintf(stderr, "error removing trigger file\n");
+ trigger_active = false;
+ }
+ }
+ }
+ mtx_unlock(&call_mutex);
+}
+
+bool
+trace_dump_is_triggered(void)
+{
+ return trigger_active && !!trigger_filename;
+}
static inline void
trace_dump_write(const char *buf, size_t size)
{
- if (stream) {
+ if (stream && trigger_active) {
fwrite(buf, size, 1, stream);
}
}
@@ -175,6 +216,7 @@ static void
trace_dump_trace_close(void)
{
if (stream) {
+ trigger_active = true;
trace_dump_writes("</trace>\n");
if (close_stream) {
fclose(stream);
@@ -182,6 +224,7 @@ trace_dump_trace_close(void)
stream = NULL;
}
call_no = 0;
+ free(trigger_filename);
}
}
@@ -234,6 +277,13 @@ trace_dump_trace_begin(void)
* time.
*/
atexit(trace_dump_trace_close);
+
+ const char *trigger = debug_get_option("GALLIUM_TRACE_TRIGGER", NULL);
+ if (trigger) {
+ trigger_filename = strdup(trigger);
+ trigger_active = false;
+ } else
+ trigger_active = true;
}
return true;
diff --git a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.h b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.h
index 3c14edfc9..9a4b29437 100644
--- a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.h
+++ b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump.h
@@ -108,6 +108,10 @@ void trace_dump_ptr(const void *value);
void trace_dump_surface_ptr(struct pipe_surface *_surface);
void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
+void trace_dump_trigger_active(bool active);
+void trace_dump_check_trigger(void);
+bool trace_dump_is_triggered(void);
+
/*
* Code saving macros.
*/
diff --git a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.c b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.c
index bd0d7204c..ec479b596 100644
--- a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.c
+++ b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.c
@@ -353,13 +353,9 @@ void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_
trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
- trace_dump_member_begin("depth");
- trace_dump_struct_begin("pipe_depth_state");
- trace_dump_member(bool, &state->depth, enabled);
- trace_dump_member(bool, &state->depth, writemask);
- trace_dump_member(uint, &state->depth, func);
- trace_dump_struct_end();
- trace_dump_member_end();
+ trace_dump_member(bool, state, depth_enabled);
+ trace_dump_member(bool, state, depth_writemask);
+ trace_dump_member(uint, state, depth_func);
trace_dump_member_begin("stencil");
trace_dump_array_begin();
@@ -379,13 +375,9 @@ void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_
trace_dump_array_end();
trace_dump_member_end();
- trace_dump_member_begin("alpha");
- trace_dump_struct_begin("pipe_alpha_state");
- trace_dump_member(bool, &state->alpha, enabled);
- trace_dump_member(uint, &state->alpha, func);
- trace_dump_member(float, &state->alpha, ref_value);
- trace_dump_struct_end();
- trace_dump_member_end();
+ trace_dump_member(bool, state, alpha_enabled);
+ trace_dump_member(uint, state, alpha_func);
+ trace_dump_member(float, state, alpha_ref_value);
trace_dump_struct_end();
}
@@ -423,16 +415,19 @@ void trace_dump_blend_state(const struct pipe_blend_state *state)
trace_dump_struct_begin("pipe_blend_state");
- trace_dump_member(bool, state, dither);
-
+ trace_dump_member(bool, state, independent_blend_enable);
trace_dump_member(bool, state, logicop_enable);
trace_dump_member(uint, state, logicop_func);
-
- trace_dump_member(bool, state, independent_blend_enable);
+ trace_dump_member(bool, state, dither);
+ trace_dump_member(bool, state, alpha_to_coverage);
+ trace_dump_member(bool, state, alpha_to_coverage_dither);
+ trace_dump_member(bool, state, alpha_to_one);
+ trace_dump_member(uint, state, max_rt);
+ trace_dump_member(uint, state, advanced_blend_func);
trace_dump_member_begin("rt");
if (state->independent_blend_enable)
- valid_entries = PIPE_MAX_COLOR_BUFS;
+ valid_entries = state->max_rt + 1;
trace_dump_struct_array(rt_blend_state, state->rt, valid_entries);
trace_dump_member_end();
@@ -492,6 +487,24 @@ void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
trace_dump_struct_end();
}
+void trace_dump_framebuffer_state_deep(const struct pipe_framebuffer_state *state)
+{
+ if (!trace_dumping_enabled_locked())
+ return;
+
+ trace_dump_struct_begin("pipe_framebuffer_state");
+
+ trace_dump_member(uint, state, width);
+ trace_dump_member(uint, state, height);
+ trace_dump_member(uint, state, samples);
+ trace_dump_member(uint, state, layers);
+ trace_dump_member(uint, state, nr_cbufs);
+ trace_dump_member_array(surface, state, cbufs);
+ trace_dump_member(surface, state, zsbuf);
+
+ trace_dump_struct_end();
+}
+
void trace_dump_sampler_state(const struct pipe_sampler_state *state)
{
@@ -571,6 +584,12 @@ void trace_dump_sampler_view_template(const struct pipe_sampler_view *state,
}
+void trace_dump_surface(const struct pipe_surface *surface)
+{
+ trace_dump_surface_template(surface, surface ? surface->texture->target : 0);
+}
+
+
void trace_dump_surface_template(const struct pipe_surface *state,
enum pipe_texture_target target)
{
@@ -775,11 +794,7 @@ void trace_dump_draw_info(const struct pipe_draw_info *state)
trace_dump_member(uint, state, index_size);
trace_dump_member(uint, state, has_user_indices);
-
trace_dump_member(uint, state, mode);
- trace_dump_member(uint, state, start);
- trace_dump_member(uint, state, count);
-
trace_dump_member(uint, state, start_instance);
trace_dump_member(uint, state, instance_count);
@@ -793,19 +808,38 @@ void trace_dump_draw_info(const struct pipe_draw_info *state)
trace_dump_member(uint, state, restart_index);
trace_dump_member(ptr, state, index.resource);
- trace_dump_member(ptr, state, count_from_stream_output);
+ trace_dump_struct_end();
+}
- if (!state->indirect) {
- trace_dump_member(ptr, state, indirect);
- } else {
- trace_dump_member(uint, state, indirect->offset);
- trace_dump_member(uint, state, indirect->stride);
- trace_dump_member(uint, state, indirect->draw_count);
- trace_dump_member(uint, state, indirect->indirect_draw_count_offset);
- trace_dump_member(ptr, state, indirect->buffer);
- trace_dump_member(ptr, state, indirect->indirect_draw_count);
+void trace_dump_draw_start_count(const struct pipe_draw_start_count *state)
+{
+ if (!trace_dumping_enabled_locked())
+ return;
+
+ trace_dump_struct_begin("pipe_draw_start_count");
+ trace_dump_member(uint, state, start);
+ trace_dump_member(uint, state, count);
+ trace_dump_struct_end();
+}
+
+void trace_dump_draw_indirect_info(const struct pipe_draw_indirect_info *state)
+{
+ if (!trace_dumping_enabled_locked())
+ return;
+
+ if (!state) {
+ trace_dump_null();
+ return;
}
+ trace_dump_struct_begin("pipe_draw_indirect_info");
+ trace_dump_member(uint, state, offset);
+ trace_dump_member(uint, state, stride);
+ trace_dump_member(uint, state, draw_count);
+ trace_dump_member(uint, state, indirect_draw_count_offset);
+ trace_dump_member(ptr, state, buffer);
+ trace_dump_member(ptr, state, indirect_draw_count);
+ trace_dump_member(ptr, state, count_from_stream_output);
trace_dump_struct_end();
}
diff --git a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.h b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.h
index baff0252f..1a969c750 100644
--- a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.h
+++ b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_dump_state.h
@@ -62,11 +62,15 @@ void trace_dump_stencil_ref(const struct pipe_stencil_ref *state);
void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state);
+void trace_dump_framebuffer_state_deep(const struct pipe_framebuffer_state *state);
+
void trace_dump_sampler_state(const struct pipe_sampler_state *state);
void trace_dump_sampler_view_template(const struct pipe_sampler_view *view,
enum pipe_texture_target target);
+void trace_dump_surface(const struct pipe_surface *surface);
+
void trace_dump_surface_template(const struct pipe_surface *state,
enum pipe_texture_target target);
@@ -82,6 +86,10 @@ void trace_dump_shader_buffer(const struct pipe_shader_buffer *buffer);
void trace_dump_draw_info(const struct pipe_draw_info *state);
+void trace_dump_draw_start_count(const struct pipe_draw_start_count *state);
+
+void trace_dump_draw_indirect_info(const struct pipe_draw_indirect_info *state);
+
void trace_dump_blit_info(const struct pipe_blit_info *);
void trace_dump_query_result(unsigned query_type,
diff --git a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_screen.c b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_screen.c
index a0943519e..95ce875bc 100644
--- a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_screen.c
+++ b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_screen.c
@@ -103,6 +103,18 @@ trace_screen_get_device_vendor(struct pipe_screen *_screen)
}
+static const void *
+trace_screen_get_compiler_options(struct pipe_screen *_screen,
+ enum pipe_shader_ir ir,
+ enum pipe_shader_type shader)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+
+ return screen->get_compiler_options(screen, ir, shader);
+}
+
+
static struct disk_cache *
trace_screen_get_disk_shader_cache(struct pipe_screen *_screen)
{
@@ -279,6 +291,7 @@ trace_screen_context_create(struct pipe_screen *_screen, void *priv,
static void
trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
+ struct pipe_context *_pipe,
struct pipe_resource *resource,
unsigned level, unsigned layer,
void *context_private,
@@ -286,6 +299,7 @@ trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_context *pipe = _pipe ? trace_context(_pipe)->pipe : NULL;
trace_dump_call_begin("pipe_screen", "flush_frontbuffer");
@@ -297,7 +311,7 @@ trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
trace_dump_arg(ptr, context_private);
*/
- screen->flush_frontbuffer(screen, resource, level, layer, context_private, sub_box);
+ screen->flush_frontbuffer(screen, pipe, resource, level, layer, context_private, sub_box);
trace_dump_call_end();
}
@@ -336,6 +350,134 @@ trace_screen_get_device_uuid(struct pipe_screen *_screen, char *uuid)
* texture
*/
+static void *
+trace_screen_map_memory(struct pipe_screen *_screen,
+ struct pipe_memory_allocation *pmem)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+ void *result;
+
+ trace_dump_call_begin("pipe_screen", "map_memory");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, pmem);
+
+ result = screen->map_memory(screen, pmem);
+
+ trace_dump_ret(ptr, result);
+
+ trace_dump_call_end();
+
+ return result;
+}
+
+static void
+trace_screen_unmap_memory(struct pipe_screen *_screen,
+ struct pipe_memory_allocation *pmem)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+
+ trace_dump_call_begin("pipe_screen", "unmap_memory");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, pmem);
+
+ screen->unmap_memory(screen, pmem);
+
+
+ trace_dump_call_end();
+}
+
+static struct pipe_memory_allocation *
+trace_screen_allocate_memory(struct pipe_screen *_screen,
+ uint64_t size)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_memory_allocation *result;
+
+ trace_dump_call_begin("pipe_screen", "allocate_memory");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(uint, size);
+
+ result = screen->allocate_memory(screen, size);
+
+ trace_dump_ret(ptr, result);
+
+ trace_dump_call_end();
+
+ return result;
+}
+
+static void
+trace_screen_free_memory(struct pipe_screen *_screen,
+ struct pipe_memory_allocation *pmem)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+
+ trace_dump_call_begin("pipe_screen", "free_memory");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, pmem);
+
+ screen->free_memory(screen, pmem);
+
+
+ trace_dump_call_end();
+}
+
+static void
+trace_screen_resource_bind_backing(struct pipe_screen *_screen,
+ struct pipe_resource *resource,
+ struct pipe_memory_allocation *pmem,
+ uint64_t offset)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+
+ trace_dump_call_begin("pipe_screen", "resource_bind_backing");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, resource);
+ trace_dump_arg(ptr, pmem);
+ trace_dump_arg(uint, offset);
+
+ screen->resource_bind_backing(screen, resource, pmem, offset);
+
+ trace_dump_call_end();
+}
+
+static struct pipe_resource *
+trace_screen_resource_create_unbacked(struct pipe_screen *_screen,
+ const struct pipe_resource *templat,
+ uint64_t *size_required)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_resource *result;
+
+ trace_dump_call_begin("pipe_screen", "resource_create_unbacked");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(resource_template, templat);
+
+ result = screen->resource_create_unbacked(screen, templat, size_required);
+
+ trace_dump_ret_begin();
+ trace_dump_uint(*size_required);
+ trace_dump_ret_end();
+ trace_dump_ret(ptr, result);
+
+ trace_dump_call_end();
+
+ if (result)
+ result->screen = _screen;
+ return result;
+}
static struct pipe_resource *
trace_screen_resource_create(struct pipe_screen *_screen,
@@ -413,6 +555,7 @@ trace_screen_resource_get_param(struct pipe_screen *_screen,
struct pipe_resource *resource,
unsigned plane,
unsigned layer,
+ unsigned level,
enum pipe_resource_param param,
unsigned handle_usage,
uint64_t *value)
@@ -424,7 +567,7 @@ trace_screen_resource_get_param(struct pipe_screen *_screen,
/* TODO trace call */
return screen->resource_get_param(screen, tr_pipe ? tr_pipe->pipe : NULL,
- resource, plane, layer, param,
+ resource, plane, layer, level, param,
handle_usage, value);
}
@@ -688,6 +831,23 @@ trace_screen_create(struct pipe_screen *screen)
{
struct trace_screen *tr_scr;
+#ifdef ZINK_WITH_SWRAST_VK
+ /* if zink+lavapipe is enabled, ensure that only one driver is traced */
+ const char *driver = debug_get_option("MESA_LOADER_DRIVER_OVERRIDE", NULL);
+ if (driver && !strcmp(driver, "zink")) {
+ /* the user wants zink: check whether they want to trace zink or lavapipe */
+ bool trace_lavapipe = debug_get_bool_option("ZINK_TRACE_LAVAPIPE", false);
+ if (!strncmp(screen->get_name(screen), "zink", 4)) {
+ /* this is the zink screen: only trace if lavapipe tracing is disabled */
+ if (trace_lavapipe)
+ return screen;
+ } else {
+ /* this is the llvmpipe screen: only trace if lavapipe tracing is enabled */
+ if (!trace_lavapipe)
+ return screen;
+ }
+ }
+#endif
if (!trace_enabled())
goto error1;
@@ -704,6 +864,7 @@ trace_screen_create(struct pipe_screen *screen)
tr_scr->base.get_name = trace_screen_get_name;
tr_scr->base.get_vendor = trace_screen_get_vendor;
tr_scr->base.get_device_vendor = trace_screen_get_device_vendor;
+ SCR_INIT(get_compiler_options);
SCR_INIT(get_disk_shader_cache);
tr_scr->base.get_param = trace_screen_get_param;
tr_scr->base.get_shader_param = trace_screen_get_shader_param;
@@ -713,7 +874,13 @@ trace_screen_create(struct pipe_screen *screen)
assert(screen->context_create);
tr_scr->base.context_create = trace_screen_context_create;
tr_scr->base.resource_create = trace_screen_resource_create;
+ tr_scr->base.resource_create_unbacked = trace_screen_resource_create_unbacked;
+ tr_scr->base.resource_bind_backing = trace_screen_resource_bind_backing;
tr_scr->base.resource_from_handle = trace_screen_resource_from_handle;
+ tr_scr->base.allocate_memory = trace_screen_allocate_memory;
+ tr_scr->base.free_memory = trace_screen_free_memory;
+ tr_scr->base.map_memory = trace_screen_map_memory;
+ tr_scr->base.unmap_memory = trace_screen_unmap_memory;
SCR_INIT(check_resource_capability);
tr_scr->base.resource_get_handle = trace_screen_resource_get_handle;
SCR_INIT(resource_get_param);
diff --git a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_texture.c b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_texture.c
index fe0c7b52c..d644e1b08 100644
--- a/lib/mesa/src/gallium/auxiliary/driver_trace/tr_texture.c
+++ b/lib/mesa/src/gallium/auxiliary/driver_trace/tr_texture.c
@@ -87,8 +87,6 @@ trace_transfer_create(struct trace_context *tr_ctx,
if (!transfer)
goto error;
- assert(transfer->resource == res);
-
tr_trans = CALLOC_STRUCT(trace_transfer);
if (!tr_trans)
goto error;