env = env.Clone()
trace = env.ConvenienceLibrary(
- target = 'trace',
- source = [
+ target = 'trace',
+ source = [
'tr_context.c',
'tr_dump.c',
- 'tr_screen.c',
+ 'tr_screen.c',
'tr_state.c',
- 'tr_stream.c',
+ 'tr_stream.c',
+ 'tr_texture.c',
'tr_winsys.c',
- ])
+ ])
Export('trace')
\ No newline at end of file
#include "tr_dump.h"
#include "tr_state.h"
+#include "tr_screen.h"
+#include "tr_texture.h"
#include "tr_context.h"
+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_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 *
+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_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;
+}
+
+
static INLINE void
trace_context_set_edgeflags(struct pipe_context *_pipe,
const unsigned *bitfield)
{
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));
+ for(i = 0; i < state->num_cbufs; ++i)
+ unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
+ for(i = state->num_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;
+
trace_dump_call_begin("pipe_context", "set_framebuffer_state");
trace_dump_arg(ptr, pipe);
{
struct trace_context *tr_ctx = trace_context(_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_call_begin("pipe_context", "set_sampler_textures");
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
+ 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);
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
+ dst = trace_surface_unwrap(tr_ctx, dst);
+
trace_dump_call_begin("pipe_context", "surface_fill");
trace_dump_arg(ptr, pipe);
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
+ surface = trace_surface_unwrap(tr_ctx, surface);
+
trace_dump_call_begin("pipe_context", "clear");
trace_dump_arg(ptr, pipe);
if(!pipe)
goto error1;
+ if(!trace_dump_enabled())
+ goto error1;
+
tr_ctx = CALLOC_STRUCT(trace_context);
if(!tr_ctx)
goto error1;
**************************************************************************/
#include "pipe/p_util.h"
-#include "util/u_hash_table.h"
#include "tr_dump.h"
#include "tr_state.h"
#include "tr_winsys.h"
+#include "tr_texture.h"
#include "tr_screen.h"
-static unsigned trace_surface_hash(void *surface)
-{
- return (unsigned)(uintptr_t)surface;
-}
-
-
-static int trace_surface_compare(void *surface1, void *surface2)
-{
- return (char *)surface2 - (char *)surface1;
-}
-
-
static const char *
trace_screen_get_name(struct pipe_screen *_screen)
{
trace_dump_call_end();
+ result = trace_texture_create(tr_scr, result);
+
return result;
}
trace_dump_call_end();
+ result = trace_texture_create(tr_scr, result);
+
return result;
}
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_texture *texture = *ptexture;
+ struct trace_texture *tr_tex;
+ struct pipe_texture *texture;
+
+ assert(ptexture);
+ if(*ptexture) {
+ tr_tex = trace_texture(tr_scr, *ptexture);
+ texture = tr_tex->texture;
+ assert(texture->screen == screen);
+ }
+ else
+ texture = NULL;
trace_dump_call_begin("pipe_screen", "texture_release");
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, texture);
- screen->texture_release(screen, ptexture);
+ if (*ptexture) {
+ if (!--(*ptexture)->refcount)
+ trace_texture_destroy(tr_scr, *ptexture);
+
+ *ptexture = NULL;
+ }
trace_dump_call_end();
}
+
static struct pipe_surface *
trace_screen_get_tex_surface(struct pipe_screen *_screen,
struct pipe_texture *texture,
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
+ struct trace_texture *tr_tex;
struct pipe_surface *result;
+ assert(texture);
+ tr_tex = trace_texture(tr_scr, texture);
+ texture = tr_tex->texture;
+ assert(texture->screen == screen);
+
trace_dump_call_begin("pipe_screen", "get_tex_surface");
trace_dump_arg(ptr, screen);
trace_dump_call_end();
+ result = trace_surface_create(tr_tex, result);
+
return result;
}
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_surface *surface = *psurface;
+ struct trace_texture *tr_tex;
+ struct trace_surface *tr_surf;
+ struct pipe_surface *surface;
+
+ assert(psurface);
+ if(*psurface) {
+ tr_tex = trace_texture(tr_scr, (*psurface)->texture);
+ tr_surf = trace_surface(tr_tex, *psurface);
+ surface = tr_surf->surface;
+ }
+ else
+ surface = NULL;
trace_dump_call_begin("pipe_screen", "tex_surface_release");
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, surface);
- screen->tex_surface_release(screen, psurface);
+ if (*psurface) {
+ if (!--(*psurface)->refcount)
+ trace_surface_destroy(tr_tex, *psurface);
+
+ *psurface = NULL;
+ }
trace_dump_call_end();
}
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
+ struct trace_texture *tr_tex;
+ struct trace_surface *tr_surf;
void *map;
+ tr_tex = trace_texture(tr_scr, surface->texture);
+ tr_surf = trace_surface(tr_tex, surface);
+ surface = tr_surf->surface;
+
map = screen->surface_map(screen, surface, flags);
if(map) {
if(flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
- assert(!hash_table_get(tr_scr->surface_maps, surface));
- hash_table_set(tr_scr->surface_maps, surface, map);
+ assert(!tr_surf->map);
+ tr_surf->map = map;
}
}
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
- const void *map;
+ struct trace_texture *tr_tex;
+ struct trace_surface *tr_surf;
- map = hash_table_get(tr_scr->surface_maps, surface);
- if(map) {
+ tr_tex = trace_texture(tr_scr, surface->texture);
+ tr_surf = trace_surface(tr_tex, surface);
+ surface = tr_surf->surface;
+
+ if(tr_surf->map) {
size_t size = surface->nblocksy * surface->stride;
trace_dump_call_begin("pipe_winsys", "surface_write");
trace_dump_arg(ptr, surface);
trace_dump_arg_begin("data");
- trace_dump_bytes(map, size);
+ trace_dump_bytes(tr_surf->map, size);
trace_dump_arg_end();
trace_dump_arg_begin("stride");
trace_dump_call_end();
- hash_table_remove(tr_scr->surface_maps, surface);
+ tr_surf->map = NULL;
}
screen->surface_unmap(screen, surface);
tr_scr->screen = screen;
- tr_scr->surface_maps = hash_table_create(trace_surface_hash,
- trace_surface_compare);
- if(!tr_scr->surface_maps)
- goto error3;
-
trace_dump_call_begin("", "pipe_screen_create");
trace_dump_arg_begin("winsys");
trace_dump_ptr(screen->winsys);
error1:
return screen;
}
+
+
+struct trace_screen *
+trace_screen(struct pipe_screen *screen)
+{
+ assert(screen);
+ assert(screen->destroy == trace_screen_destroy);
+ return (struct trace_screen *)screen;
+}
#define TR_SCREEN_H_
-#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
#include "pipe/p_screen.h"
-struct hash_table;
-
-
struct trace_screen
{
struct pipe_screen base;
struct pipe_screen *screen;
-
- struct hash_table *surface_maps;
};
-static INLINE struct trace_screen *
-trace_screen(struct pipe_screen *screen)
-{
- assert(screen);
- return (struct trace_screen *)screen;
-}
-
+struct trace_screen *
+trace_screen(struct pipe_screen *screen);
struct pipe_screen *
--- /dev/null
+/**************************************************************************
+ *
+ * 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 "pipe/p_inlines.h"
+#include "util/u_hash_table.h"
+
+#include "tr_screen.h"
+#include "tr_texture.h"
+
+
+struct pipe_texture *
+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,
+ struct pipe_texture *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,
+ 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.winsys = tr_tex->base.screen->winsys;
+ 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,
+ struct pipe_surface *surface)
+{
+ struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
+ pipe_texture_reference(&tr_surf->base.texture, NULL);
+ pipe_surface_reference(&tr_surf->surface, NULL);
+ FREE(tr_surf);
+}
+
--- /dev/null
+/**************************************************************************
+ *
+ * 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_TEXTURE_H_
+#define TR_TEXTURE_H_
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+#include "tr_screen.h"
+
+
+struct trace_texture
+{
+ struct pipe_texture base;
+
+ struct pipe_texture *texture;
+};
+
+
+struct trace_surface
+{
+ struct pipe_surface base;
+
+ struct pipe_surface *surface;
+
+ void *map;
+};
+
+
+static INLINE struct trace_texture *
+trace_texture(struct trace_screen *tr_scr,
+ struct pipe_texture *texture)
+{
+ if(!texture)
+ return NULL;
+ assert(texture->screen == &tr_scr->base);
+ return (struct trace_texture *)texture;
+}
+
+
+static INLINE struct trace_surface *
+trace_surface(struct trace_texture *tr_tex,
+ struct pipe_surface *surface)
+{
+ if(!surface)
+ return NULL;
+ assert(surface->texture == &tr_tex->base);
+ return (struct trace_surface *)surface;
+}
+
+
+struct pipe_texture *
+trace_texture_create(struct trace_screen *tr_scr,
+ struct pipe_texture *texture);
+
+void
+trace_texture_destroy(struct trace_screen *tr_scr,
+ struct pipe_texture *texture);
+
+struct pipe_surface *
+trace_surface_create(struct trace_texture *tr_tex,
+ struct pipe_surface *surface);
+
+void
+trace_surface_destroy(struct trace_texture *tr_tex,
+ struct pipe_surface *surface);
+
+
+#endif /* TR_TEXTURE_H_ */
#include "tr_dump.h"
#include "tr_state.h"
+#include "tr_screen.h"
+#include "tr_texture.h"
#include "tr_winsys.h"
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
+ assert(surface);
+ if(surface->texture) {
+ struct trace_screen *tr_scr = trace_screen(surface->texture->screen);
+ struct trace_screen *tr_tex = trace_texture(tr_scr, surface->texture);
+ 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_call_end();
+ assert(!result || !result->texture);
+
return result;
}
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
+ assert(surface && !surface->texture);
+
trace_dump_call_begin("pipe_winsys", "surface_alloc_storage");
trace_dump_arg(ptr, winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_surface *surface = *psurface;
+ assert(psurface && *psurface && !(*psurface)->texture);
+
trace_dump_call_begin("pipe_winsys", "surface_release");
trace_dump_arg(ptr, winsys);