trace: Trace pipe_winsys calls.

This commit is contained in:
José Fonseca 2008-08-08 23:11:56 +01:00
parent fcfe63805d
commit 6c7aff209c
5 changed files with 482 additions and 8 deletions

View File

@ -10,6 +10,7 @@ trace = env.ConvenienceLibrary(
'tr_screen.c',
'tr_state.c',
'tr_stream.c',
'tr_winsys.c',
])
Export('trace')

View File

@ -30,6 +30,7 @@
#include "tr_stream.h"
#include "tr_dump.h"
#include "tr_state.h"
#include "tr_winsys.h"
#include "tr_screen.h"
@ -338,10 +339,6 @@ trace_screen_destroy(struct pipe_screen *_screen)
trace_dump_call_end(stream);
trace_dump_trace_end(stream);
trace_stream_close(tr_scr->stream);
FREE(tr_scr);
}
@ -375,11 +372,9 @@ trace_screen_create(struct pipe_screen *screen)
tr_scr->screen = screen;
tr_scr->stream = trace_stream_create("gallium", "trace");
tr_scr->stream = trace_winsys(screen->winsys)->stream;
if(!tr_scr->stream)
return NULL;
trace_dump_trace_begin(tr_scr->stream, 0);
return &tr_scr->base;
}

View File

@ -0,0 +1,410 @@
/**************************************************************************
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "pipe/p_util.h"
#include "tr_stream.h"
#include "tr_dump.h"
#include "tr_state.h"
#include "tr_winsys.h"
static const char *
trace_winsys_get_name(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
const char *result;
trace_dump_call_begin(stream, "pipe_winsys", "get_name");
trace_dump_arg(stream, ptr, winsys);
result = winsys->get_name(winsys);
trace_dump_ret(stream, string, result);
trace_dump_call_end(stream);
return result;
}
static void
trace_winsys_flush_frontbuffer(struct pipe_winsys *_winsys,
struct pipe_surface *surface,
void *context_private)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
trace_dump_call_begin(stream, "pipe_winsys", "flush_frontbuffer");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, surface);
trace_dump_arg(stream, ptr, context_private);
winsys->flush_frontbuffer(winsys, surface, context_private);
trace_dump_call_end(stream);
}
static struct pipe_surface *
trace_winsys_surface_alloc(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_surface *result;
trace_dump_call_begin(stream, "pipe_winsys", "surface_alloc");
trace_dump_arg(stream, ptr, winsys);
result = winsys->surface_alloc(winsys);
trace_dump_ret(stream, ptr, result);
trace_dump_call_end(stream);
return result;
}
static int
trace_winsys_surface_alloc_storage(struct pipe_winsys *_winsys,
struct pipe_surface *surface,
unsigned width, unsigned height,
enum pipe_format format,
unsigned flags,
unsigned tex_usage)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
trace_dump_call_begin(stream, "pipe_winsys", "surface_alloc_storage");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, surface);
trace_dump_arg(stream, uint, width);
trace_dump_arg(stream, uint, height);
trace_dump_arg(stream, format, format);
trace_dump_arg(stream, uint, flags);
trace_dump_arg(stream, uint, tex_usage);
result = winsys->surface_alloc_storage(winsys,
surface,
width, height,
format,
flags,
tex_usage);
trace_dump_ret(stream, int, result);
trace_dump_call_end(stream);
return result;
}
static void
trace_winsys_surface_release(struct pipe_winsys *_winsys,
struct pipe_surface **psurface)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_surface *surface = *psurface;
trace_dump_call_begin(stream, "pipe_winsys", "surface_release");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, surface);
winsys->surface_release(winsys, psurface);
trace_dump_call_end(stream);
}
static struct pipe_buffer *
trace_winsys_buffer_create(struct pipe_winsys *_winsys,
unsigned alignment,
unsigned usage,
unsigned size)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_buffer *result;
trace_dump_call_begin(stream, "pipe_winsys", "buffer_create");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, uint, alignment);
trace_dump_arg(stream, uint, usage);
trace_dump_arg(stream, uint, size);
result = winsys->buffer_create(winsys, alignment, usage, size);
trace_dump_ret(stream, ptr, result);
trace_dump_call_end(stream);
return result;
}
static struct pipe_buffer *
trace_winsys_user_buffer_create(struct pipe_winsys *_winsys,
void *ptr,
unsigned bytes)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_buffer *result;
trace_dump_call_begin(stream, "pipe_winsys", "user_buffer_create");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, ptr);
trace_dump_arg(stream, uint, bytes);
result = winsys->user_buffer_create(winsys, ptr, bytes);
trace_dump_ret(stream, ptr, result);
trace_dump_call_end(stream);
return result;
}
static void *
trace_winsys_buffer_map(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer,
unsigned usage)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
void *result;
trace_dump_call_begin(stream, "pipe_winsys", "buffer_map");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, buffer);
trace_dump_arg(stream, uint, usage);
result = winsys->buffer_map(winsys, buffer, usage);
trace_dump_ret(stream, ptr, result);
trace_dump_call_end(stream);
return result;
}
static void
trace_winsys_buffer_unmap(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
trace_dump_call_begin(stream, "pipe_winsys", "buffer_unmap");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, buffer);
winsys->buffer_unmap(winsys, buffer);
trace_dump_call_end(stream);
}
static void
trace_winsys_buffer_destroy(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
trace_dump_call_begin(stream, "pipe_winsys", "buffer_destroy");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, buffer);
winsys->buffer_destroy(winsys, buffer);
trace_dump_call_end(stream);
}
static void
trace_winsys_fence_reference(struct pipe_winsys *_winsys,
struct pipe_fence_handle **pdst,
struct pipe_fence_handle *src)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_fence_handle *dst = *pdst;
trace_dump_call_begin(stream, "pipe_winsys", "fence_reference");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, dst);
trace_dump_arg(stream, ptr, src);
winsys->fence_reference(winsys, pdst, src);
trace_dump_call_end(stream);
}
static int
trace_winsys_fence_signalled(struct pipe_winsys *_winsys,
struct pipe_fence_handle *fence,
unsigned flag)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
trace_dump_call_begin(stream, "pipe_winsys", "fence_signalled");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, fence);
trace_dump_arg(stream, uint, flag);
result = winsys->fence_signalled(winsys, fence, flag);
trace_dump_ret(stream, int, result);
trace_dump_call_end(stream);
return result;
}
static int
trace_winsys_fence_finish(struct pipe_winsys *_winsys,
struct pipe_fence_handle *fence,
unsigned flag)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
trace_dump_call_begin(stream, "pipe_winsys", "fence_finish");
trace_dump_arg(stream, ptr, winsys);
trace_dump_arg(stream, ptr, fence);
trace_dump_arg(stream, uint, flag);
result = winsys->fence_finish(winsys, fence, flag);
trace_dump_ret(stream, int, result);
trace_dump_call_end(stream);
return result;
}
static void
trace_winsys_destroy(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
trace_dump_call_begin(stream, "pipe_winsys", "destroy");
trace_dump_arg(stream, ptr, winsys);
winsys->destroy(winsys);
trace_dump_call_end(stream);
trace_dump_trace_end(stream);
trace_stream_close(tr_ws->stream);
FREE(tr_ws);
}
struct pipe_winsys *
trace_winsys_create(struct pipe_winsys *winsys)
{
struct trace_winsys *tr_ws;
if(!debug_get_bool_option("GALLIUM_TRACE", FALSE))
return winsys;
tr_ws = CALLOC_STRUCT(trace_winsys);
if(!tr_ws)
return NULL;
tr_ws->base.destroy = trace_winsys_destroy;
tr_ws->base.get_name = trace_winsys_get_name;
tr_ws->base.flush_frontbuffer = trace_winsys_flush_frontbuffer;
tr_ws->base.surface_alloc = trace_winsys_surface_alloc;
tr_ws->base.surface_alloc_storage = trace_winsys_surface_alloc_storage;
tr_ws->base.surface_release = trace_winsys_surface_release;
tr_ws->base.buffer_create = trace_winsys_buffer_create;
tr_ws->base.user_buffer_create = trace_winsys_user_buffer_create;
tr_ws->base.buffer_map = trace_winsys_buffer_map;
tr_ws->base.buffer_unmap = trace_winsys_buffer_unmap;
tr_ws->base.buffer_destroy = trace_winsys_buffer_destroy;
tr_ws->base.fence_reference = trace_winsys_fence_reference;
tr_ws->base.fence_signalled = trace_winsys_fence_signalled;
tr_ws->base.fence_finish = trace_winsys_fence_finish;
tr_ws->winsys = winsys;
tr_ws->stream = trace_stream_create("gallium", "trace");
if(!tr_ws->stream)
return NULL;
trace_dump_trace_begin(tr_ws->stream, 0);
return &tr_ws->base;
}

View File

@ -0,0 +1,63 @@
/**************************************************************************
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef TR_WINSYS_H_
#define TR_WINSYS_H_
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
#include "pipe/p_winsys.h"
struct trace_stream;
struct trace_winsys
{
struct pipe_winsys base;
struct pipe_winsys *winsys;
struct trace_stream *stream;
};
static INLINE struct trace_winsys *
trace_winsys(struct pipe_winsys *winsys)
{
assert(winsys);
return (struct trace_winsys *)winsys;
}
struct pipe_winsys *
trace_winsys_create(struct pipe_winsys *winsys);
#endif /* TR_WINSYS_H_ */

View File

@ -55,6 +55,7 @@
#endif
#ifdef GALLIUM_TRACE
#include "trace/tr_winsys.h"
#include "trace/tr_screen.h"
#include "trace/tr_context.h"
#endif
@ -650,7 +651,11 @@ xmesa_get_pipe_winsys(struct xmesa_visual *xm_vis)
ws->base.get_name = xm_get_name;
}
return &ws->base;
#ifdef GALLIUM_TRACE
return trace_winsys_create(&ws->base);
#else
return &ws->base;
#endif
}