#include "tr_context.h"
-static INLINE struct pipe_texture *
+static INLINE struct pipe_texture *
trace_texture_unwrap(struct trace_context *tr_ctx,
struct pipe_texture *texture)
{
- struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
+ struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
struct trace_texture *tr_tex;
-
+
if(!texture)
return NULL;
-
+
tr_tex = trace_texture(tr_scr, texture);
-
+
assert(tr_tex->texture);
assert(tr_tex->texture->screen == tr_scr->screen);
return tr_tex->texture;
}
-static INLINE struct pipe_surface *
+static INLINE struct pipe_surface *
trace_surface_unwrap(struct trace_context *tr_ctx,
struct pipe_surface *surface)
{
- struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
+ struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
struct trace_texture *tr_tex;
struct trace_surface *tr_surf;
-
+
if(!surface)
return NULL;
assert(surface->texture);
if(!surface->texture)
return surface;
-
+
tr_tex = trace_texture(tr_scr, surface->texture);
tr_surf = trace_surface(tr_tex, surface);
-
+
assert(tr_surf->surface);
assert(tr_surf->surface->texture->screen == tr_scr->screen);
return tr_surf->surface;
struct pipe_context *pipe = tr_ctx->pipe;
trace_dump_call_begin("pipe_context", "set_edgeflags");
-
+
trace_dump_arg(ptr, pipe);
/* FIXME: we don't know how big this array is */
trace_dump_arg(ptr, bitfield);
result = pipe->draw_arrays(pipe, mode, start, count);;
trace_dump_ret(bool, result);
-
+
trace_dump_call_end();
-
+
return result;
}
result = pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count);;
trace_dump_ret(bool, result);
-
+
trace_dump_call_end();
-
+
return result;
}
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
- unsigned mode,
- unsigned start,
+ unsigned mode,
+ unsigned start,
unsigned count)
{
struct trace_context *tr_ctx = trace_context(_pipe);
trace_dump_arg(uint, start);
trace_dump_arg(uint, count);
- result = pipe->draw_range_elements(pipe,
- indexBuffer,
- indexSize, minIndex, maxIndex,
+ result = pipe->draw_range_elements(pipe,
+ indexBuffer,
+ indexSize, minIndex, maxIndex,
mode, start, count);
-
+
trace_dump_ret(bool, result);
-
+
trace_dump_call_end();
-
+
return result;
}
result = pipe->create_query(pipe, query_type);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_begin_query(struct pipe_context *_pipe,
+trace_context_begin_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
static INLINE void
-trace_context_end_query(struct pipe_context *_pipe,
+trace_context_end_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
static INLINE boolean
-trace_context_get_query_result(struct pipe_context *_pipe,
+trace_context_get_query_result(struct pipe_context *_pipe,
struct pipe_query *query,
boolean wait,
uint64_t *presult)
trace_dump_arg(uint, result);
trace_dump_ret(bool, _result);
-
+
trace_dump_call_end();
-
+
return _result;
}
trace_dump_ret(ptr, result);
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_blend_state(struct pipe_context *_pipe,
+trace_context_bind_blend_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
static INLINE void
-trace_context_delete_blend_state(struct pipe_context *_pipe,
+trace_context_delete_blend_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
result = pipe->create_sampler_state(pipe, state);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_sampler_states(struct pipe_context *_pipe,
+trace_context_bind_sampler_states(struct pipe_context *_pipe,
unsigned num_states, void **states)
{
struct trace_context *tr_ctx = trace_context(_pipe);
static INLINE void
-trace_context_delete_sampler_state(struct pipe_context *_pipe,
+trace_context_delete_sampler_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
result = pipe->create_rasterizer_state(pipe, state);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
+trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
static INLINE void
-trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
+trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
trace_dump_arg(ptr, pipe);
trace_dump_arg(depth_stencil_alpha_state, state);
-
+
trace_dump_ret(ptr, result);
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
+trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
static INLINE void
-trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
+trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
result = pipe->create_fs_state(pipe, state);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_fs_state(struct pipe_context *_pipe,
+trace_context_bind_fs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
static INLINE void
-trace_context_delete_fs_state(struct pipe_context *_pipe,
+trace_context_delete_fs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
result = pipe->create_vs_state(pipe, state);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_vs_state(struct pipe_context *_pipe,
+trace_context_bind_vs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
static INLINE void
-trace_context_delete_vs_state(struct pipe_context *_pipe,
+trace_context_delete_vs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
trace_winsys_user_buffer_update(_pipe->winsys, (struct pipe_buffer *)buffer);
-
+
trace_dump_call_begin("pipe_context", "set_constant_buffer");
trace_dump_arg(ptr, 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));
for(i = 0; i < state->nr_cbufs; ++i)
unwrapped_state.cbufs[i] = NULL;
unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
state = &unwrapped_state;
-
+
trace_dump_call_begin("pipe_context", "set_framebuffer_state");
trace_dump_arg(ptr, pipe);
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS];
unsigned i;
-
+
for(i = 0; i < num_textures; ++i)
unwrapped_textures[i] = trace_texture_unwrap(tr_ctx, textures[i]);
textures = unwrapped_textures;
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, num_buffers);
-
+
trace_dump_arg_begin("buffers");
trace_dump_struct_array(vertex_buffer, buffers, num_buffers);
trace_dump_arg_end();
dest = trace_surface_unwrap(tr_ctx, dest);
src = trace_surface_unwrap(tr_ctx, src);
-
+
trace_dump_call_begin("pipe_context", "surface_copy");
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, width);
trace_dump_arg(uint, height);
- pipe->surface_copy(pipe, do_flip,
- dest, destx, desty,
+ pipe->surface_copy(pipe, do_flip,
+ dest, destx, desty,
src, srcx, srcy, width, height);
-
+
trace_dump_call_end();
}
static INLINE void
-trace_context_clear(struct pipe_context *_pipe,
+trace_context_clear(struct pipe_context *_pipe,
struct pipe_surface *surface,
unsigned clearValue)
{
trace_dump_arg(ptr, pipe);
pipe->destroy(pipe);
-
+
trace_dump_call_end();
FREE(tr_ctx);
struct pipe_context *
-trace_context_create(struct pipe_screen *screen,
+trace_context_create(struct pipe_screen *screen,
struct pipe_context *pipe)
{
struct trace_context *tr_ctx;
-
+
if(!pipe)
goto error1;
-
+
if(!trace_dump_enabled())
goto error1;
-
+
tr_ctx = CALLOC_STRUCT(trace_context);
if(!tr_ctx)
goto error1;
tr_ctx->base.flush = trace_context_flush;
tr_ctx->pipe = pipe;
-
+
trace_dump_call_begin("", "pipe_context_create");
trace_dump_arg_begin("screen");
trace_dump_ptr(pipe->screen);
trace_dump_call_end();
return &tr_ctx->base;
-
+
error1:
return pipe;
}
extern "C" {
#endif
-
+
struct trace_context
{
struct pipe_context base;
-
+
struct pipe_context *pipe;
};
/**
* @file
* Trace dumping functions.
- *
+ *
* For now we just use standard XML for dumping the trace calls, as this is
- * simple to write, parse, and visually inspect, but the actual representation
- * is abstracted out of this file, so that we can switch to a binary
+ * simple to write, parse, and visually inspect, but the actual representation
+ * is abstracted out of this file, so that we can switch to a binary
* representation if/when it becomes justified.
- *
- * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
+ *
+ * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
*/
#include "pipe/p_config.h"
static unsigned refcount = 0;
-static INLINE void
+static INLINE void
trace_dump_write(const char *buf, size_t size)
{
if(stream)
}
-static INLINE void
+static INLINE void
trace_dump_writes(const char *s)
{
trace_dump_write(s, strlen(s));
}
-static INLINE void
+static INLINE void
trace_dump_writef(const char *format, ...)
{
static char buf[1024];
}
-static INLINE void
-trace_dump_escape(const char *str)
+static INLINE void
+trace_dump_escape(const char *str)
{
const unsigned char *p = (const unsigned char *)str;
unsigned char c;
}
-static INLINE void
+static INLINE void
trace_dump_indent(unsigned level)
{
unsigned i;
}
-static INLINE void
-trace_dump_newline(void)
+static INLINE void
+trace_dump_newline(void)
{
trace_dump_writes("\n");
}
-static INLINE void
+static INLINE void
trace_dump_tag(const char *name)
{
trace_dump_writes("<");
}
-static INLINE void
+static INLINE void
trace_dump_tag_begin(const char *name)
{
trace_dump_writes("<");
trace_dump_writes(">");
}
-static INLINE void
-trace_dump_tag_begin1(const char *name,
+static INLINE void
+trace_dump_tag_begin1(const char *name,
const char *attr1, const char *value1)
{
trace_dump_writes("<");
}
-static INLINE void
-trace_dump_tag_begin2(const char *name,
+static INLINE void
+trace_dump_tag_begin2(const char *name,
const char *attr1, const char *value1,
const char *attr2, const char *value2)
{
}
-static INLINE void
-trace_dump_tag_begin3(const char *name,
+static INLINE void
+trace_dump_tag_begin3(const char *name,
const char *attr1, const char *value1,
const char *attr2, const char *value2,
const char *attr3, const char *value3)
trace_dump_writes(">");
}
-static void
+static void
trace_dump_trace_close(void)
{
if(stream) {
boolean trace_dump_trace_begin()
{
const char *filename;
-
+
filename = debug_get_option("GALLIUM_TRACE", NULL);
if(!filename)
return FALSE;
-
+
if(!stream) {
-
+
stream = util_stream_create(filename, 0);
if(!stream)
return FALSE;
-
+
trace_dump_writes("<?xml version='1.0' encoding='UTF-8'?>\n");
trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
trace_dump_writes("<trace version='0.1'>\n");
-
+
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
- /* Linux applications rarely cleanup GL / Gallium resources so catch
- * application exit here */
+ /* Linux applications rarely cleanup GL / Gallium resources so catch
+ * application exit here */
atexit(trace_dump_trace_close);
#endif
}
-
+
++refcount;
-
+
return TRUE;
}
/*
- * Code saving macros.
+ * Code saving macros.
*/
#define trace_dump_arg(_type, _arg) \
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
const char *result;
-
+
trace_dump_call_begin("pipe_screen", "get_name");
-
+
trace_dump_arg(ptr, screen);
result = screen->get_name(screen);
-
+
trace_dump_ret(string, result);
-
+
trace_dump_call_end();
-
+
return result;
}
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
const char *result;
-
+
trace_dump_call_begin("pipe_screen", "get_vendor");
-
+
trace_dump_arg(ptr, screen);
-
+
result = screen->get_vendor(screen);
-
+
trace_dump_ret(string, result);
-
+
trace_dump_call_end();
-
+
return result;
}
-static int
-trace_screen_get_param(struct pipe_screen *_screen,
+static int
+trace_screen_get_param(struct pipe_screen *_screen,
int param)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
int result;
-
+
trace_dump_call_begin("pipe_screen", "get_param");
-
+
trace_dump_arg(ptr, screen);
trace_dump_arg(int, param);
result = screen->get_param(screen, param);
-
+
trace_dump_ret(int, result);
-
+
trace_dump_call_end();
-
+
return result;
}
-static float
-trace_screen_get_paramf(struct pipe_screen *_screen,
+static float
+trace_screen_get_paramf(struct pipe_screen *_screen,
int param)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
float result;
-
+
trace_dump_call_begin("pipe_screen", "get_paramf");
-
+
trace_dump_arg(ptr, screen);
trace_dump_arg(int, param);
result = screen->get_paramf(screen, param);
-
+
trace_dump_ret(float, result);
-
+
trace_dump_call_end();
-
+
return result;
}
-static boolean
+static boolean
trace_screen_is_format_supported(struct pipe_screen *_screen,
enum pipe_format format,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned tex_usage,
unsigned geom_flags)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
boolean result;
-
+
trace_dump_call_begin("pipe_screen", "is_format_supported");
-
+
trace_dump_arg(ptr, screen);
trace_dump_arg(format, format);
trace_dump_arg(int, target);
trace_dump_arg(uint, geom_flags);
result = screen->is_format_supported(screen, format, target, tex_usage, geom_flags);
-
+
trace_dump_ret(bool, result);
-
+
trace_dump_call_end();
-
+
return result;
}
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
struct pipe_texture *result;
-
+
trace_dump_call_begin("pipe_screen", "texture_create");
trace_dump_arg(ptr, screen);
trace_dump_arg(template, templat);
result = screen->texture_create(screen, templat);
-
+
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
result = trace_texture_create(tr_scr, result);
-
+
return result;
}
trace_dump_arg(ptr, buffer);
result = screen->texture_blanket(screen, templat, ppitch, buffer);
-
+
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
result = trace_texture_create(tr_scr, result);
-
+
return result;
}
-static void
+static void
trace_screen_texture_destroy(struct pipe_texture *_texture)
{
struct trace_screen *tr_scr = trace_screen(_texture->screen);
struct pipe_surface *result = NULL;
assert(texture->screen == screen);
-
+
trace_dump_call_begin("pipe_screen", "get_tex_surface");
-
+
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, texture);
trace_dump_arg(uint, face);
result = screen->get_tex_surface(screen, texture, face, level, zslice, usage);
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
result = trace_surface_create(tr_tex, result);
return result;
}
-static void
+static void
trace_screen_tex_surface_destroy(struct pipe_surface *_surface)
{
struct trace_screen *tr_scr = trace_screen(_surface->texture->screen);
x, y, w, h);
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
result = trace_transfer_create(tr_tex, result);
return result;
}
-static void
+static void
trace_screen_tex_transfer_destroy(struct pipe_transfer *_transfer)
{
struct trace_screen *tr_scr = trace_screen(_transfer->texture->screen);
tr_trans->map = map;
}
}
-
+
return map;
}
-static void
+static void
trace_screen_transfer_unmap(struct pipe_screen *_screen,
struct pipe_transfer *_transfer)
{
if(tr_trans->map) {
size_t size = transfer->nblocksy * transfer->stride;
-
+
trace_dump_call_begin("pipe_screen", "transfer_write");
-
+
trace_dump_arg(ptr, screen);
-
+
trace_dump_arg(ptr, transfer);
-
+
trace_dump_arg_begin("data");
trace_dump_bytes(tr_trans->map, size);
trace_dump_arg_end();
trace_dump_arg_begin("size");
trace_dump_uint(size);
trace_dump_arg_end();
-
+
trace_dump_call_end();
tr_trans->map = NULL;
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
-
+
trace_dump_call_begin("pipe_screen", "destroy");
-
+
trace_dump_arg(ptr, screen);
screen->destroy(screen);
-
+
trace_dump_call_end();
trace_dump_trace_end();
{
struct trace_screen *tr_scr;
struct pipe_winsys *winsys;
-
+
if(!screen)
goto error1;
extern "C" {
#endif
-
+
struct trace_screen
{
struct pipe_screen base;
-
+
struct pipe_screen *screen;
};
}
trace_dump_struct_begin("pipe_texture");
-
+
trace_dump_member(int, templat, target);
trace_dump_member(format, templat, format);
-
+
trace_dump_member_begin("width");
trace_dump_array(uint, templat->width, 1);
trace_dump_member_end();
trace_dump_member_begin("block");
trace_dump_block(&templat->block);
trace_dump_member_end();
-
+
trace_dump_member(uint, templat, last_level);
trace_dump_member(uint, templat, tex_usage);
-
+
trace_dump_struct_end();
}
trace_dump_member(float, state, point_size_max);
trace_dump_member(float, state, offset_units);
trace_dump_member(float, state, offset_scale);
-
+
trace_dump_member_array(uint, state, sprite_coord_mode);
-
+
trace_dump_struct_end();
}
trace_dump_member_begin("stipple");
trace_dump_array(uint,
- state->stipple,
+ state->stipple,
Elements(state->stipple));
trace_dump_member_end();
-
+
trace_dump_struct_end();
}
trace_dump_member_array(float, state, scale);
trace_dump_member_array(float, state, translate);
-
+
trace_dump_struct_end();
}
void trace_dump_clip_state(const struct pipe_clip_state *state)
{
unsigned i;
-
+
if(!state) {
trace_dump_null();
return;
}
tgsi_dump_str(state->tokens, 0, str, sizeof(str));
-
+
trace_dump_struct_begin("pipe_shader_state");
trace_dump_member_begin("tokens");
void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
{
unsigned i;
-
+
if(!state) {
trace_dump_null();
return;
trace_dump_member(bool, &state->depth, occlusion_count);
trace_dump_struct_end();
trace_dump_member_end();
-
+
trace_dump_member_begin("stencil");
trace_dump_array_begin();
for(i = 0; i < Elements(state->stencil); ++i) {
trace_dump_member_begin("block");
trace_dump_block(&state->block);
trace_dump_member_end();
-
+
trace_dump_member(uint, state, nblocksx);
trace_dump_member(uint, state, nblocksy);
trace_dump_member(uint, state, stride);
trace_dump_member(uint, state, vertex_buffer_index);
trace_dump_member(uint, state, nr_components);
-
+
trace_dump_member(format, state, src_format);
trace_dump_struct_end();
struct pipe_texture *
-trace_texture_create(struct trace_screen *tr_scr,
+trace_texture_create(struct trace_screen *tr_scr,
struct pipe_texture *texture)
{
struct trace_texture *tr_tex;
-
+
if(!texture)
goto error;
-
+
assert(texture->screen == tr_scr->screen);
-
+
tr_tex = CALLOC_STRUCT(trace_texture);
if(!tr_tex)
goto error;
-
+
memcpy(&tr_tex->base, texture, sizeof(struct pipe_texture));
tr_tex->base.screen = &tr_scr->base;
tr_tex->texture = texture;
-
+
return &tr_tex->base;
-
+
error:
pipe_texture_reference(&texture, NULL);
return NULL;
void
-trace_texture_destroy(struct trace_screen *tr_scr,
+trace_texture_destroy(struct trace_screen *tr_scr,
struct pipe_texture *texture)
{
- struct trace_texture *tr_tex = trace_texture(tr_scr, texture);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, texture);
pipe_texture_reference(&tr_tex->texture, NULL);
FREE(tr_tex);
}
struct pipe_surface *
-trace_surface_create(struct trace_texture *tr_tex,
+trace_surface_create(struct trace_texture *tr_tex,
struct pipe_surface *surface)
{
struct trace_surface *tr_surf;
-
+
if(!surface)
goto error;
-
+
assert(surface->texture == tr_tex->texture);
-
+
tr_surf = CALLOC_STRUCT(trace_surface);
if(!tr_surf)
goto error;
-
+
memcpy(&tr_surf->base, surface, sizeof(struct pipe_surface));
-
+
tr_surf->base.texture = NULL;
pipe_texture_reference(&tr_surf->base.texture, &tr_tex->base);
tr_surf->surface = surface;
return &tr_surf->base;
-
+
error:
pipe_surface_reference(&surface, NULL);
return NULL;
void
-trace_surface_destroy(struct trace_texture *tr_tex,
+trace_surface_destroy(struct trace_texture *tr_tex,
struct pipe_surface *surface)
{
struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
struct pipe_transfer *
-trace_transfer_create(struct trace_texture *tr_tex,
+trace_transfer_create(struct trace_texture *tr_tex,
struct pipe_transfer *transfer)
{
struct trace_transfer *tr_trans;
-
+
if(!transfer)
goto error;
-
+
assert(transfer->texture == tr_tex->texture);
-
+
tr_trans = CALLOC_STRUCT(trace_transfer);
if(!tr_trans)
goto error;
-
+
memcpy(&tr_trans->base, transfer, sizeof(struct pipe_transfer));
tr_trans->base.texture = NULL;
assert(tr_trans->base.texture == &tr_tex->base);
return &tr_trans->base;
-
+
error:
transfer->texture->screen->tex_transfer_destroy(transfer);
return NULL;
void
-trace_transfer_destroy(struct trace_texture *tr_tex,
+trace_transfer_destroy(struct trace_texture *tr_tex,
struct pipe_transfer *transfer)
{
struct trace_transfer *tr_trans = trace_transfer(tr_tex, transfer);
struct pipe_transfer base;
struct pipe_transfer *transfer;
-
+
void *map;
};
static INLINE struct trace_texture *
-trace_texture(struct trace_screen *tr_scr,
+trace_texture(struct trace_screen *tr_scr,
struct pipe_texture *texture)
{
if(!texture)
static INLINE struct trace_surface *
-trace_surface(struct trace_texture *tr_tex,
+trace_surface(struct trace_texture *tr_tex,
struct pipe_surface *surface)
{
if(!surface)
static INLINE struct trace_transfer *
-trace_transfer(struct trace_texture *tr_tex,
+trace_transfer(struct trace_texture *tr_tex,
struct pipe_transfer *transfer)
{
if(!transfer)
struct pipe_texture *
-trace_texture_create(struct trace_screen *tr_scr,
+trace_texture_create(struct trace_screen *tr_scr,
struct pipe_texture *texture);
void
-trace_texture_destroy(struct trace_screen *tr_scr,
+trace_texture_destroy(struct trace_screen *tr_scr,
struct pipe_texture *texture);
struct pipe_surface *
-trace_surface_create(struct trace_texture *tr_tex,
+trace_surface_create(struct trace_texture *tr_tex,
struct pipe_surface *surface);
void
struct pipe_surface *surface);
struct pipe_transfer *
-trace_transfer_create(struct trace_texture *tr_tex,
+trace_transfer_create(struct trace_texture *tr_tex,
struct pipe_transfer *transfer);
void
return (char *)buffer2 - (char *)buffer1;
}
-
+
static const char *
trace_winsys_get_name(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
const char *result;
-
+
trace_dump_call_begin("pipe_winsys", "get_name");
-
+
trace_dump_arg(ptr, winsys);
result = winsys->get_name(winsys);
-
+
trace_dump_ret(string, result);
-
+
trace_dump_call_end();
-
+
return result;
}
-static void
+static void
trace_winsys_flush_frontbuffer(struct pipe_winsys *_winsys,
struct pipe_surface *surface,
void *context_private)
struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
surface = tr_surf->surface;
}
-
+
trace_dump_call_begin("pipe_winsys", "flush_frontbuffer");
-
+
trace_dump_arg(ptr, winsys);
trace_dump_arg(ptr, surface);
/* XXX: hide, as there is nothing we can do with this
*/
winsys->flush_frontbuffer(winsys, surface, context_private);
-
+
trace_dump_call_end();
}
struct pipe_winsys *winsys = tr_ws->winsys;
unsigned stride;
struct pipe_buffer *result;
-
+
trace_dump_call_begin("pipe_winsys", "surface_buffer_create");
-
+
trace_dump_arg(ptr, winsys);
trace_dump_arg(uint, width);
trace_dump_arg(uint, height);
format,
usage,
pstride);
-
+
stride = *pstride;
-
+
trace_dump_arg(uint, stride);
-
+
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static struct pipe_buffer *
-trace_winsys_buffer_create(struct pipe_winsys *_winsys,
- unsigned alignment,
+trace_winsys_buffer_create(struct pipe_winsys *_winsys,
+ unsigned alignment,
unsigned usage,
unsigned size)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_buffer *buffer;
-
+
trace_dump_call_begin("pipe_winsys", "buffer_create");
-
+
trace_dump_arg(ptr, winsys);
trace_dump_arg(uint, alignment);
trace_dump_arg(uint, usage);
trace_dump_arg(uint, size);
buffer = winsys->buffer_create(winsys, alignment, usage, size);
-
+
trace_dump_ret(ptr, buffer);
-
+
trace_dump_call_end();
/* Zero the buffer to avoid dumping uninitialized memory */
winsys->buffer_unmap(winsys, buffer);
}
}
-
+
return buffer;
}
static struct pipe_buffer *
-trace_winsys_user_buffer_create(struct pipe_winsys *_winsys,
+trace_winsys_user_buffer_create(struct pipe_winsys *_winsys,
void *data,
unsigned size)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_buffer *result;
-
+
trace_dump_call_begin("pipe_winsys", "user_buffer_create");
-
+
trace_dump_arg(ptr, winsys);
trace_dump_arg_begin("data");
trace_dump_bytes(data, size);
trace_dump_arg(uint, size);
result = winsys->user_buffer_create(winsys, data, size);
-
+
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
- /* XXX: Mark the user buffers. (we should wrap pipe_buffers, but is is
+
+ /* XXX: Mark the user buffers. (we should wrap pipe_buffers, but is is
* impossible to do so while texture-less surfaces are still around */
if(result) {
assert(!(result->usage & TRACE_BUFFER_USAGE_USER));
result->usage |= TRACE_BUFFER_USAGE_USER;
}
-
+
return result;
}
void
-trace_winsys_user_buffer_update(struct pipe_winsys *_winsys,
+trace_winsys_user_buffer_update(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
const void *map;
-
+
if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) {
map = winsys->buffer_map(winsys, buffer, PIPE_BUFFER_USAGE_CPU_READ);
if(map) {
trace_dump_call_begin("pipe_winsys", "buffer_write");
-
+
trace_dump_arg(ptr, winsys);
-
+
trace_dump_arg(ptr, buffer);
-
+
trace_dump_arg_begin("data");
trace_dump_bytes(map, buffer->size);
trace_dump_arg_end();
-
+
trace_dump_arg_begin("size");
trace_dump_uint(buffer->size);
trace_dump_arg_end();
-
+
trace_dump_call_end();
-
+
winsys->buffer_unmap(winsys, buffer);
}
}
static void *
-trace_winsys_buffer_map(struct pipe_winsys *_winsys,
+trace_winsys_buffer_map(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer,
unsigned usage)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
void *map;
-
+
map = winsys->buffer_map(winsys, buffer, usage);
if(map) {
if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
hash_table_set(tr_ws->buffer_maps, buffer, map);
}
}
-
+
return map;
}
static void
-trace_winsys_buffer_unmap(struct pipe_winsys *_winsys,
+trace_winsys_buffer_unmap(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
const void *map;
-
+
map = hash_table_get(tr_ws->buffer_maps, buffer);
if(map) {
trace_dump_call_begin("pipe_winsys", "buffer_write");
-
+
trace_dump_arg(ptr, winsys);
-
+
trace_dump_arg(ptr, buffer);
-
+
trace_dump_arg_begin("data");
trace_dump_bytes(map, buffer->size);
trace_dump_arg_end();
trace_dump_arg_begin("size");
trace_dump_uint(buffer->size);
trace_dump_arg_end();
-
+
trace_dump_call_end();
hash_table_remove(tr_ws->buffer_maps, buffer);
}
-
+
winsys->buffer_unmap(winsys, buffer);
}
trace_winsys_buffer_destroy(struct pipe_buffer *buffer)
{
struct pipe_winsys *winsys = buffer->screen->winsys;
-
+
trace_dump_call_begin("pipe_winsys", "buffer_destroy");
-
+
trace_dump_arg(ptr, winsys);
trace_dump_arg(ptr, buffer);
winsys->buffer_destroy(buffer);
-
+
trace_dump_call_end();
}
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_fence_handle *dst = *pdst;
-
+
trace_dump_call_begin("pipe_winsys", "fence_reference");
-
+
trace_dump_arg(ptr, winsys);
trace_dump_arg(ptr, dst);
trace_dump_arg(ptr, src);
winsys->fence_reference(winsys, pdst, src);
-
+
trace_dump_call_end();
}
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
-
+
trace_dump_call_begin("pipe_winsys", "fence_signalled");
-
+
trace_dump_arg(ptr, winsys);
trace_dump_arg(ptr, fence);
trace_dump_arg(uint, flag);
result = winsys->fence_signalled(winsys, fence, flag);
-
+
trace_dump_ret(int, result);
-
+
trace_dump_call_end();
-
+
return result;
}
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
-
+
trace_dump_call_begin("pipe_winsys", "fence_finish");
-
+
trace_dump_arg(ptr, winsys);
trace_dump_arg(ptr, fence);
trace_dump_arg(uint, flag);
result = winsys->fence_finish(winsys, fence, flag);
-
+
trace_dump_ret(int, result);
-
+
trace_dump_call_end();
-
+
return result;
}
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
-
+
trace_dump_call_begin("pipe_winsys", "destroy");
-
+
trace_dump_arg(ptr, winsys);
- /*
- winsys->destroy(winsys);
+ /*
+ winsys->destroy(winsys);
*/
-
+
trace_dump_call_end();
-
+
hash_table_destroy(tr_ws->buffer_maps);
FREE(tr_ws);
trace_winsys_create(struct pipe_winsys *winsys)
{
struct trace_winsys *tr_ws;
-
+
if(!winsys)
goto error1;
-
+
tr_ws = CALLOC_STRUCT(trace_winsys);
if(!tr_ws)
goto error1;
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->buffer_maps = hash_table_create(trace_buffer_hash,
+ tr_ws->buffer_maps = hash_table_create(trace_buffer_hash,
trace_buffer_compare);
if(!tr_ws->buffer_maps)
goto error2;
-
+
trace_dump_call_begin("", "pipe_winsys_create");
trace_dump_ret(ptr, winsys);
trace_dump_call_end();
return &tr_ws->base;
-
+
error2:
FREE(tr_ws);
error1:
/**
- * It often happens that new data is written directly to the user buffers
- * without mapping/unmapping. This flag marks user buffers, so that their
+ * It often happens that new data is written directly to the user buffers
+ * without mapping/unmapping. This flag marks user buffers, so that their
* contents can be dumpped before being used by the pipe context.
*/
#define TRACE_BUFFER_USAGE_USER (1 << 31)
struct trace_winsys
{
struct pipe_winsys base;
-
+
struct pipe_winsys *winsys;
-
+
struct hash_table *buffer_maps;
};
void
-trace_winsys_user_buffer_update(struct pipe_winsys *winsys,
+trace_winsys_user_buffer_update(struct pipe_winsys *winsys,
struct pipe_buffer *buffer);