aux/trace: hook tc methods
these need to have the context/screen unwrapped in order to not crash while tracing Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10899>
This commit is contained in:
parent
d2ae8e6d5e
commit
3fedd2bbe8
|
@ -33,6 +33,7 @@
|
|||
#include "util/u_debug.h"
|
||||
#include "util/hash_table.h"
|
||||
#include "pipe/p_context.h"
|
||||
#include "util/u_threaded_context.h"
|
||||
|
||||
#include "tr_screen.h"
|
||||
|
||||
|
@ -52,6 +53,8 @@ struct trace_context
|
|||
struct hash_table depth_stencil_alpha_states;
|
||||
|
||||
struct pipe_context *pipe;
|
||||
tc_replace_buffer_storage_func replace_buffer_storage;
|
||||
tc_create_fence_func create_fence;
|
||||
|
||||
struct pipe_framebuffer_state unwrapped_state;
|
||||
bool seen_fb_state;
|
||||
|
@ -81,7 +84,10 @@ trace_context_create(struct trace_screen *tr_scr,
|
|||
struct pipe_context *pipe);
|
||||
|
||||
struct pipe_context *
|
||||
trace_context_create_threaded(struct pipe_screen *_screen, struct pipe_context *pipe);
|
||||
trace_context_create_threaded(struct pipe_screen *screen, struct pipe_context *pipe,
|
||||
tc_replace_buffer_storage_func *replace_buffer,
|
||||
tc_create_fence_func *create_fence,
|
||||
tc_is_resource_busy *is_resource_busy);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "util/u_memory.h"
|
||||
#include "util/hash_table.h"
|
||||
#include "util/simple_list.h"
|
||||
#include "util/u_threaded_context.h"
|
||||
|
||||
#include "tr_dump.h"
|
||||
#include "tr_dump_defines.h"
|
||||
|
@ -265,9 +264,73 @@ trace_screen_is_format_supported(struct pipe_screen *_screen,
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
trace_context_replace_buffer_storage(struct pipe_context *_pipe,
|
||||
struct pipe_resource *dst,
|
||||
struct pipe_resource *src,
|
||||
unsigned delete_buffer_id)
|
||||
{
|
||||
struct trace_context *tr_ctx = trace_context(_pipe);
|
||||
struct pipe_context *pipe = tr_ctx->pipe;
|
||||
|
||||
trace_dump_call_begin("pipe_context", "replace_buffer_storage");
|
||||
|
||||
trace_dump_arg(ptr, pipe);
|
||||
trace_dump_arg(ptr, dst);
|
||||
trace_dump_arg(ptr, src);
|
||||
trace_dump_arg(uint, delete_buffer_id);
|
||||
trace_dump_call_end();
|
||||
|
||||
tr_ctx->replace_buffer_storage(pipe, dst, src, delete_buffer_id);
|
||||
}
|
||||
|
||||
static struct pipe_fence_handle *
|
||||
trace_context_create_fence(struct pipe_context *_pipe, struct tc_unflushed_batch_token *token)
|
||||
{
|
||||
struct trace_context *tr_ctx = trace_context(_pipe);
|
||||
struct pipe_context *pipe = tr_ctx->pipe;
|
||||
|
||||
trace_dump_call_begin("pipe_context", "create_fence");
|
||||
|
||||
trace_dump_arg(ptr, pipe);
|
||||
trace_dump_arg(ptr, token);
|
||||
|
||||
struct pipe_fence_handle *ret = tr_ctx->create_fence(pipe, token);
|
||||
trace_dump_ret(ptr, ret);
|
||||
trace_dump_call_end();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool
|
||||
trace_context_is_resource_busy(struct pipe_screen *_screen,
|
||||
struct pipe_resource *resource,
|
||||
unsigned usage)
|
||||
{
|
||||
struct trace_screen *tr_scr = trace_screen(_screen);
|
||||
struct pipe_screen *screen = tr_scr->screen;
|
||||
bool result;
|
||||
|
||||
trace_dump_call_begin("pipe_screen", "is_resource_busy");
|
||||
|
||||
trace_dump_arg(ptr, screen);
|
||||
trace_dump_arg(ptr, resource);
|
||||
trace_dump_arg(uint, usage);
|
||||
|
||||
result = tr_scr->is_resource_busy(screen, resource, usage);
|
||||
|
||||
trace_dump_ret(bool, result);
|
||||
|
||||
trace_dump_call_end();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
struct pipe_context *
|
||||
trace_context_create_threaded(struct pipe_screen *screen, struct pipe_context *pipe)
|
||||
trace_context_create_threaded(struct pipe_screen *screen, struct pipe_context *pipe,
|
||||
tc_replace_buffer_storage_func *replace_buffer,
|
||||
tc_create_fence_func *create_fence,
|
||||
tc_is_resource_busy *is_resource_busy)
|
||||
{
|
||||
if (!trace_screens)
|
||||
return pipe;
|
||||
|
@ -281,10 +344,19 @@ trace_context_create_threaded(struct pipe_screen *screen, struct pipe_context *p
|
|||
return pipe;
|
||||
|
||||
struct pipe_context *ctx = trace_context_create(tr_scr, pipe);
|
||||
if (ctx) {
|
||||
struct trace_context *tr_ctx = trace_context(ctx);
|
||||
tr_ctx->threaded = true;
|
||||
}
|
||||
if (!ctx)
|
||||
return pipe;
|
||||
|
||||
struct trace_context *tr_ctx = trace_context(ctx);
|
||||
tr_ctx->replace_buffer_storage = *replace_buffer;
|
||||
tr_ctx->create_fence = *create_fence;
|
||||
tr_scr->is_resource_busy = *is_resource_busy;
|
||||
tr_ctx->threaded = true;
|
||||
*replace_buffer = trace_context_replace_buffer_storage;
|
||||
if (*create_fence)
|
||||
*create_fence = trace_context_create_fence;
|
||||
if (*is_resource_busy)
|
||||
*is_resource_busy = trace_context_is_resource_busy;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "pipe/p_screen.h"
|
||||
#include "os/os_thread.h"
|
||||
|
||||
#include "util/u_threaded_context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -51,6 +51,7 @@ struct trace_screen
|
|||
struct pipe_screen base;
|
||||
|
||||
struct pipe_screen *screen;
|
||||
tc_is_resource_busy is_resource_busy;
|
||||
bool trace_tc;
|
||||
};
|
||||
|
||||
|
|
|
@ -3844,7 +3844,7 @@ threaded_context_create(struct pipe_context *pipe,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pipe = trace_context_create_threaded(pipe->screen, pipe);
|
||||
pipe = trace_context_create_threaded(pipe->screen, pipe, &replace_buffer, &create_fence, &is_resource_busy);
|
||||
|
||||
/* The driver context isn't wrapped, so set its "priv" to NULL. */
|
||||
pipe->priv = NULL;
|
||||
|
|
Loading…
Reference in New Issue