From 002dfb12fce045d0e124301e5df805df772149d8 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 8 Jan 2009 14:10:56 +0000 Subject: gallium: split driver-independent code out of xlib winsys Place in new xlib state-tracker. This is a statetracker for the GLX API. --- src/gallium/drivers/trace/Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/gallium/drivers/trace/Makefile (limited to 'src/gallium/drivers/trace/Makefile') diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile new file mode 100644 index 0000000000..3859b8acb0 --- /dev/null +++ b/src/gallium/drivers/trace/Makefile @@ -0,0 +1,18 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = trace + +C_SOURCES = \ + tr_context.c \ + tr_dump.c \ + tr_screen.c \ + tr_state.c \ + tr_texture.c \ + tr_winsys.c + + +include ../../Makefile.template + +symlinks: + -- cgit v1.2.3 From d9602e5144bc76b9791fa3382ca38c880df96198 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 20 Feb 2009 00:14:00 +0100 Subject: gallium: Improve makefiles for libraries The template makefile that most libraries in gallium included was based on dri and had a bunch unrelevant junk in it. Update it and improve the depending makefiles. --- src/gallium/Makefile.template | 74 ++++++++++++++-------------- src/gallium/auxiliary/cso_cache/Makefile | 3 -- src/gallium/auxiliary/draw/Makefile | 4 -- src/gallium/auxiliary/indices/Makefile | 4 -- src/gallium/auxiliary/pipebuffer/Makefile | 3 -- src/gallium/auxiliary/rtasm/Makefile | 3 -- src/gallium/auxiliary/sct/Makefile | 3 -- src/gallium/auxiliary/tgsi/Makefile | 3 -- src/gallium/auxiliary/translate/Makefile | 3 -- src/gallium/auxiliary/util/Makefile | 3 -- src/gallium/drivers/failover/Makefile | 3 -- src/gallium/drivers/i915simple/Makefile | 3 -- src/gallium/drivers/i965simple/Makefile | 2 - src/gallium/drivers/nv04/Makefile | 11 +---- src/gallium/drivers/nv10/Makefile | 11 +---- src/gallium/drivers/nv20/Makefile | 11 +---- src/gallium/drivers/nv30/Makefile | 11 +---- src/gallium/drivers/nv40/Makefile | 11 +---- src/gallium/drivers/nv50/Makefile | 11 +---- src/gallium/drivers/r300/Makefile | 2 - src/gallium/drivers/softpipe/Makefile | 3 -- src/gallium/drivers/trace/Makefile | 6 +-- src/gallium/state_trackers/glx/xlib/Makefile | 18 ++----- 23 files changed, 50 insertions(+), 156 deletions(-) (limited to 'src/gallium/drivers/trace/Makefile') diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 655e949ca2..98487d43bd 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -1,64 +1,66 @@ -# -*-makefile-*- +# src/gallium/Makefile.template - -# We still have a dependency on the "dri" buffer manager. Most likely -# the interface can be reused in non-dri environments, and also as a -# frontend to simpler memory managers. +# Template makefile for gallium libraries. +# +# Usage: +# The minimum that the including makefile needs to define +# is TOP, LIBNAME and one of of the *_SOURCES. # -COMMON_SOURCES = +# Optional defines: +# LIBRARY_INCLUDES are appended to the list of includes directories. +# LIBRARY_DEFINES is not used for makedepend, but for compilation. -OBJECTS = $(C_SOURCES:.c=.o) \ - $(CPP_SOURCES:.cpp=.o) \ - $(ASM_SOURCES:.S=.o) +### Basic defines ### +OBJECTS = $(C_SOURCES:.c=.o) \ + $(CPP_SOURCES:.cpp=.o) \ + $(ASM_SOURCES:.S=.o) -### Include directories INCLUDES = \ -I. \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/include \ - $(DRIVER_INCLUDES) - - -##### RULES ##### - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ - -.cpp.o: - $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@ - -.S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + -I$(GALLIUM)/src/gallium/include \ + -I$(GALLIUM)/src/gallium/auxiliary \ + -I$(GALLIUM)/src/gallium/drivers \ + $(LIBRARY_INCLUDES) ##### TARGETS ##### -default: depend symlinks lib$(LIBNAME).a - +default: depend lib$(LIBNAME).a lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template - $(TOP)/bin/mklib -o $(LIBNAME) -static $(OBJECTS) $(DRIVER_LIBS) - + $(MKLIB) -o $(LIBNAME) -static $(OBJECTS) depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) rm -f depend touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \ - $(ASM_SOURCES) 2> /dev/null - + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) 2> /dev/null # Emacs tags tags: etags `find . -name \*.[ch]` `find ../include` - # Remove .o and backup files -clean:: - -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS) - -rm -f depend depend.bak +clean: + rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak + +# Dummy target +install: + @echo -n "" + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ + +.cpp.o: + $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ -include depend +sinclude depend diff --git a/src/gallium/auxiliary/cso_cache/Makefile b/src/gallium/auxiliary/cso_cache/Makefile index 6bd6602088..8726afcd94 100644 --- a/src/gallium/auxiliary/cso_cache/Makefile +++ b/src/gallium/auxiliary/cso_cache/Makefile @@ -9,6 +9,3 @@ C_SOURCES = \ cso_hash.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/auxiliary/draw/Makefile b/src/gallium/auxiliary/draw/Makefile index bdbf5a08ed..5041dcc072 100644 --- a/src/gallium/auxiliary/draw/Makefile +++ b/src/gallium/auxiliary/draw/Makefile @@ -43,8 +43,4 @@ C_SOURCES = \ draw_vs_ppc.c \ draw_vs_sse.c - include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/auxiliary/indices/Makefile b/src/gallium/auxiliary/indices/Makefile index 8fa61d265e..25ee899c40 100644 --- a/src/gallium/auxiliary/indices/Makefile +++ b/src/gallium/auxiliary/indices/Makefile @@ -10,7 +10,3 @@ include ../../Makefile.template u_indices_gen.c: u_indices_gen.py python $< > $@ - - -symlinks: - diff --git a/src/gallium/auxiliary/pipebuffer/Makefile b/src/gallium/auxiliary/pipebuffer/Makefile index 3b501c51df..1c00ba8d98 100644 --- a/src/gallium/auxiliary/pipebuffer/Makefile +++ b/src/gallium/auxiliary/pipebuffer/Makefile @@ -17,6 +17,3 @@ C_SOURCES = \ pb_validate.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/auxiliary/rtasm/Makefile b/src/gallium/auxiliary/rtasm/Makefile index 252dc5274a..ab8ea464c6 100644 --- a/src/gallium/auxiliary/rtasm/Makefile +++ b/src/gallium/auxiliary/rtasm/Makefile @@ -11,6 +11,3 @@ C_SOURCES = \ rtasm_ppc_spe.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/auxiliary/sct/Makefile b/src/gallium/auxiliary/sct/Makefile index 516d1756cf..a7d111b689 100644 --- a/src/gallium/auxiliary/sct/Makefile +++ b/src/gallium/auxiliary/sct/Makefile @@ -7,6 +7,3 @@ C_SOURCES = \ sct.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/auxiliary/tgsi/Makefile b/src/gallium/auxiliary/tgsi/Makefile index d7df9490cf..b4900e8dba 100644 --- a/src/gallium/auxiliary/tgsi/Makefile +++ b/src/gallium/auxiliary/tgsi/Makefile @@ -19,6 +19,3 @@ C_SOURCES = \ tgsi_util.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/auxiliary/translate/Makefile b/src/gallium/auxiliary/translate/Makefile index ad2a5b705e..3c82f8ae03 100644 --- a/src/gallium/auxiliary/translate/Makefile +++ b/src/gallium/auxiliary/translate/Makefile @@ -10,6 +10,3 @@ C_SOURCES = \ translate_cache.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile index 671e671df2..160df8dfa7 100644 --- a/src/gallium/auxiliary/util/Makefile +++ b/src/gallium/auxiliary/util/Makefile @@ -27,6 +27,3 @@ C_SOURCES = \ u_simple_screen.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/failover/Makefile b/src/gallium/drivers/failover/Makefile index f08b8df07a..dfb7f5dcf6 100644 --- a/src/gallium/drivers/failover/Makefile +++ b/src/gallium/drivers/failover/Makefile @@ -9,6 +9,3 @@ C_SOURCES = \ fo_context.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/i915simple/Makefile b/src/gallium/drivers/i915simple/Makefile index 41a61a0020..12821c5a76 100644 --- a/src/gallium/drivers/i915simple/Makefile +++ b/src/gallium/drivers/i915simple/Makefile @@ -26,6 +26,3 @@ C_SOURCES = \ i915_surface.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/i965simple/Makefile b/src/gallium/drivers/i965simple/Makefile index e97146e57c..19182afa75 100644 --- a/src/gallium/drivers/i965simple/Makefile +++ b/src/gallium/drivers/i965simple/Makefile @@ -50,5 +50,3 @@ C_SOURCES = \ brw_wm_surface_state.c include ../../Makefile.template - -symlinks: diff --git a/src/gallium/drivers/nv04/Makefile b/src/gallium/drivers/nv04/Makefile index 4ed62dae95..cf9deea851 100644 --- a/src/gallium/drivers/nv04/Makefile +++ b/src/gallium/drivers/nv04/Makefile @@ -3,7 +3,7 @@ include $(TOP)/configs/current LIBNAME = nv04 -DRIVER_SOURCES = \ +C_SOURCES = \ nv04_surface_2d.c \ nv04_clear.c \ nv04_context.c \ @@ -17,13 +17,4 @@ DRIVER_SOURCES = \ nv04_surface.c \ nv04_vbo.c -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/nv10/Makefile b/src/gallium/drivers/nv10/Makefile index 4ba7ce586d..2b5fbd4f5a 100644 --- a/src/gallium/drivers/nv10/Makefile +++ b/src/gallium/drivers/nv10/Makefile @@ -3,7 +3,7 @@ include $(TOP)/configs/current LIBNAME = nv10 -DRIVER_SOURCES = \ +C_SOURCES = \ nv10_clear.c \ nv10_context.c \ nv10_fragprog.c \ @@ -16,13 +16,4 @@ DRIVER_SOURCES = \ nv10_surface.c \ nv10_vbo.c -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/nv20/Makefile b/src/gallium/drivers/nv20/Makefile index d777fd3d8b..93e34f8e92 100644 --- a/src/gallium/drivers/nv20/Makefile +++ b/src/gallium/drivers/nv20/Makefile @@ -3,7 +3,7 @@ include $(TOP)/configs/current LIBNAME = nv20 -DRIVER_SOURCES = \ +C_SOURCES = \ nv20_clear.c \ nv20_context.c \ nv20_fragprog.c \ @@ -17,13 +17,4 @@ DRIVER_SOURCES = \ nv20_vbo.c # nv20_vertprog.c -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile index 69f2790dfe..4c29e2eab3 100644 --- a/src/gallium/drivers/nv30/Makefile +++ b/src/gallium/drivers/nv30/Makefile @@ -3,7 +3,7 @@ include $(TOP)/configs/current LIBNAME = nv30 -DRIVER_SOURCES = \ +C_SOURCES = \ nv30_clear.c \ nv30_context.c \ nv30_draw.c \ @@ -25,13 +25,4 @@ DRIVER_SOURCES = \ nv30_vbo.c \ nv30_vertprog.c -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile index 9c8eadf7e4..8c738aefa6 100644 --- a/src/gallium/drivers/nv40/Makefile +++ b/src/gallium/drivers/nv40/Makefile @@ -3,7 +3,7 @@ include $(TOP)/configs/current LIBNAME = nv40 -DRIVER_SOURCES = \ +C_SOURCES = \ nv40_clear.c \ nv40_context.c \ nv40_draw.c \ @@ -25,13 +25,4 @@ DRIVER_SOURCES = \ nv40_vbo.c \ nv40_vertprog.c -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/nv50/Makefile b/src/gallium/drivers/nv50/Makefile index 48244dbbac..612aea28a3 100644 --- a/src/gallium/drivers/nv50/Makefile +++ b/src/gallium/drivers/nv50/Makefile @@ -3,7 +3,7 @@ include $(TOP)/configs/current LIBNAME = nv50 -DRIVER_SOURCES = \ +C_SOURCES = \ nv50_clear.c \ nv50_context.c \ nv50_draw.c \ @@ -18,13 +18,4 @@ DRIVER_SOURCES = \ nv50_transfer.c \ nv50_vbo.c -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile index 85b3f15ac5..9b7524b523 100644 --- a/src/gallium/drivers/r300/Makefile +++ b/src/gallium/drivers/r300/Makefile @@ -18,5 +18,3 @@ C_SOURCES = \ r300_texture.c include ../../Makefile.template - -symlinks: diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile index f186f6df1d..516e3992fd 100644 --- a/src/gallium/drivers/softpipe/Makefile +++ b/src/gallium/drivers/softpipe/Makefile @@ -42,6 +42,3 @@ C_SOURCES = \ sp_surface.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index 3859b8acb0..e1bd970937 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -9,10 +9,6 @@ C_SOURCES = \ tr_screen.c \ tr_state.c \ tr_texture.c \ - tr_winsys.c - + tr_winsys.c include ../../Makefile.template - -symlinks: - diff --git a/src/gallium/state_trackers/glx/xlib/Makefile b/src/gallium/state_trackers/glx/xlib/Makefile index 1b63db1f0e..6d10b090aa 100644 --- a/src/gallium/state_trackers/glx/xlib/Makefile +++ b/src/gallium/state_trackers/glx/xlib/Makefile @@ -3,23 +3,15 @@ include $(TOP)/configs/current LIBNAME = xlib - -DRIVER_INCLUDES = \ +LIBRARY_INCLUDES = \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/gallium/auxiliary + -I$(TOP)/src/mesa/main C_SOURCES = \ - glxapi.c \ - fakeglx.c \ - fakeglx_fonts.c \ + glxapi.c \ + fakeglx.c \ + fakeglx_fonts.c \ xm_api.c - include ../../../Makefile.template - -symlinks: - -- cgit v1.2.3 From 808f32279964f4e80f0708f737fdf3a901ff51e5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 11 Mar 2009 22:45:48 +0100 Subject: trace: Move buffer functions from winsys to screen --- src/gallium/drivers/trace/Makefile | 3 +- src/gallium/drivers/trace/SConscript | 3 +- src/gallium/drivers/trace/tr_context.c | 21 +- src/gallium/drivers/trace/tr_dump.c | 1 + src/gallium/drivers/trace/tr_screen.c | 441 +++++++++++++++++++++++++++++++- src/gallium/drivers/trace/tr_screen.h | 13 + src/gallium/drivers/trace/tr_winsys.c | 448 --------------------------------- src/gallium/drivers/trace/tr_winsys.h | 76 ------ 8 files changed, 458 insertions(+), 548 deletions(-) delete mode 100644 src/gallium/drivers/trace/tr_winsys.c delete mode 100644 src/gallium/drivers/trace/tr_winsys.h (limited to 'src/gallium/drivers/trace/Makefile') diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index e1bd970937..7c570bf7a5 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -8,7 +8,6 @@ C_SOURCES = \ tr_dump.c \ tr_screen.c \ tr_state.c \ - tr_texture.c \ - tr_winsys.c + tr_texture.c include ../../Makefile.template diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 0a6bfb8f4c..45e5ef6868 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -10,7 +10,6 @@ trace = env.ConvenienceLibrary( 'tr_screen.c', 'tr_state.c', 'tr_texture.c', - 'tr_winsys.c', ]) -Export('trace') \ No newline at end of file +Export('trace') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 42146daf7a..6e367af57a 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -32,7 +32,6 @@ #include "tr_state.h" #include "tr_screen.h" #include "tr_texture.h" -#include "tr_winsys.h" #include "tr_context.h" @@ -132,7 +131,7 @@ trace_context_draw_elements(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; boolean result; - trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer); + trace_screen_user_buffer_update(_pipe->screen, indexBuffer); trace_dump_call_begin("pipe_context", "draw_elements"); @@ -167,7 +166,7 @@ trace_context_draw_range_elements(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; boolean result; - trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer); + trace_screen_user_buffer_update(_pipe->screen, indexBuffer); trace_dump_call_begin("pipe_context", "draw_range_elements"); @@ -696,7 +695,7 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe, 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_screen_user_buffer_update(_pipe->screen, (struct pipe_buffer *)buffer); trace_dump_call_begin("pipe_context", "set_constant_buffer"); @@ -830,7 +829,7 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, unsigned i; for(i = 0; i < num_buffers; ++i) - trace_winsys_user_buffer_update(_pipe->winsys, buffers[i].buffer); + trace_screen_user_buffer_update(_pipe->screen, buffers[i].buffer); trace_dump_call_begin("pipe_context", "set_vertex_buffers"); @@ -996,10 +995,12 @@ trace_context_destroy(struct pipe_context *_pipe) struct pipe_context * -trace_context_create(struct pipe_screen *screen, +trace_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) { + struct trace_screen *tr_scr = trace_screen(_screen); struct trace_context *tr_ctx; + struct pipe_screen *screen = tr_scr->screen; if(!pipe) goto error1; @@ -1011,8 +1012,8 @@ trace_context_create(struct pipe_screen *screen, if(!tr_ctx) goto error1; - tr_ctx->base.winsys = screen->winsys; - tr_ctx->base.screen = screen; + tr_ctx->base.winsys = _screen->winsys; + tr_ctx->base.screen = _screen; tr_ctx->base.destroy = trace_context_destroy; tr_ctx->base.set_edgeflags = trace_context_set_edgeflags; tr_ctx->base.draw_arrays = trace_context_draw_arrays; @@ -1059,9 +1060,7 @@ trace_context_create(struct pipe_screen *screen, tr_ctx->pipe = pipe; trace_dump_call_begin("", "pipe_context_create"); - trace_dump_arg_begin("screen"); - trace_dump_ptr(pipe->screen); - trace_dump_arg_end(); + trace_dump_arg(ptr, screen); trace_dump_ret(ptr, pipe); trace_dump_call_end(); diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index ec8f8cd62e..0f29ba7e7e 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -51,6 +51,7 @@ #include "util/u_stream.h" #include "tr_dump.h" +#include "tr_screen.h" static struct util_stream *stream = NULL; diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index e370f09fff..8e7e033d51 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -29,10 +29,10 @@ #include "tr_dump.h" #include "tr_state.h" -#include "tr_winsys.h" #include "tr_texture.h" #include "tr_screen.h" +#include "pipe/p_inlines.h" static const char * trace_screen_get_name(struct pipe_screen *_screen) @@ -151,6 +151,36 @@ trace_screen_is_format_supported(struct pipe_screen *_screen, } +static void +trace_screen_flush_frontbuffer(struct pipe_screen *_screen, + struct pipe_surface *_surface, + void *context_private) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture); + struct trace_surface *tr_surf = trace_surface(tr_tex, _surface); + struct pipe_screen *screen = tr_scr->screen; + struct pipe_surface *surface = tr_surf->surface; + + trace_dump_call_begin("pipe_winsys", "flush_frontbuffer"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, surface); + /* XXX: hide, as there is nothing we can do with this + trace_dump_arg(ptr, context_private); + */ + + screen->flush_frontbuffer(screen, surface, context_private); + + trace_dump_call_end(); +} + + +/******************************************************************** + * texture + */ + + static struct pipe_texture * trace_screen_texture_create(struct pipe_screen *_screen, const struct pipe_texture *templat) @@ -223,10 +253,15 @@ trace_screen_texture_destroy(struct pipe_texture *_texture) trace_dump_call_end(); - trace_texture_destroy(trace_screen(screen), texture); + trace_texture_destroy(tr_scr, _texture); } +/******************************************************************** + * surface + */ + + static struct pipe_surface * trace_screen_get_tex_surface(struct pipe_screen *_screen, struct pipe_texture *_texture, @@ -283,6 +318,11 @@ trace_screen_tex_surface_destroy(struct pipe_surface *_surface) } +/******************************************************************** + * transfer + */ + + static struct pipe_transfer * trace_screen_get_tex_transfer(struct pipe_screen *_screen, struct pipe_texture *_texture, @@ -409,6 +449,379 @@ trace_screen_transfer_unmap(struct pipe_screen *_screen, } +/******************************************************************** + * buffer + */ + + +static struct pipe_buffer * +trace_screen_surface_buffer_create(struct pipe_screen *_screen, + unsigned width, unsigned height, + enum pipe_format format, + unsigned usage, + unsigned *pstride) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + unsigned stride; + struct pipe_buffer *result; + + trace_dump_call_begin("pipe_screen", "surface_buffer_create"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(uint, width); + trace_dump_arg(uint, height); + trace_dump_arg(format, format); + trace_dump_arg(uint, usage); + + result = screen->surface_buffer_create(screen, + width, 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_screen_buffer_create(struct pipe_screen *_screen, + unsigned alignment, + unsigned usage, + unsigned size) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + struct pipe_buffer *result; + + trace_dump_call_begin("pipe_screen", "buffer_create"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(uint, alignment); + trace_dump_arg(uint, usage); + trace_dump_arg(uint, size); + + result = screen->buffer_create(screen, alignment, usage, size); + + trace_dump_ret(ptr, result); + + trace_dump_call_end(); + + /* Zero the buffer to avoid dumping uninitialized memory */ + if(result->usage & PIPE_BUFFER_USAGE_CPU_WRITE) { + void *map; + map = pipe_buffer_map(screen, result, PIPE_BUFFER_USAGE_CPU_WRITE); + if(map) { + memset(map, 0, result->size); + screen->buffer_unmap(screen, result); + } + } + + return result; +} + + +static struct pipe_buffer * +trace_screen_user_buffer_create(struct pipe_screen *_screen, + void *data, + unsigned size) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + struct pipe_buffer *result; + + trace_dump_call_begin("pipe_screen", "user_buffer_create"); + + trace_dump_arg(ptr, screen); + trace_dump_arg_begin("data"); + trace_dump_bytes(data, size); + trace_dump_arg_end(); + trace_dump_arg(uint, size); + + result = screen->user_buffer_create(screen, data, size); + + trace_dump_ret(ptr, result); + + trace_dump_call_end(); + + /* 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; +} + + +/** + * This function is used to track if data has been changed on a user buffer + * without map/unmap being called. + */ +void +trace_screen_user_buffer_update(struct pipe_screen *_screen, + struct pipe_buffer *buffer) +{ +#if 0 + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + const void *map; + + if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) { + map = screen->buffer_map(screen, buffer, PIPE_BUFFER_USAGE_CPU_READ); + if(map) { + trace_dump_call_begin("pipe_winsys", "buffer_write"); + + trace_dump_arg(ptr, screen); + + 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(); + + screen->buffer_unmap(screen, buffer); + } + } +#endif +} + + +static void * +trace_screen_buffer_map(struct pipe_screen *_screen, + struct pipe_buffer *buffer, + unsigned usage) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + void *map; + + trace_dump_call_begin("pipe_screen", "buffer_map"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, buffer); + trace_dump_arg(uint, usage); + + assert(screen->buffer_map); + map = screen->buffer_map(screen, buffer, usage); + + trace_dump_ret(ptr, map); +#if 0 + if(map) { + if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) { + assert(!hash_table_get(tr_ws->buffer_maps, buffer)); + hash_table_set(tr_ws->buffer_maps, buffer, map); + } + } +#endif + + return map; +} + + +static void * +trace_screen_buffer_map_range(struct pipe_screen *_screen, + struct pipe_buffer *buffer, + unsigned offset, + unsigned length, + unsigned usage) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + void *map; + + trace_dump_call_begin("pipe_screen", "buffer_map_range"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, buffer); + trace_dump_arg(uint, offset); + trace_dump_arg(uint, length); + trace_dump_arg(uint, usage); + + assert(screen->buffer_map_range); + map = screen->buffer_map_range(screen, buffer, offset, length, usage); + + trace_dump_ret(ptr, map); + + trace_dump_call_end(); + + return map; +} + + +static void +trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen, + struct pipe_buffer *buffer, + unsigned offset, + unsigned length) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + + trace_dump_call_begin("pipe_screen", "buffer_flush_mapped_range"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, buffer); + trace_dump_arg(uint, offset); + trace_dump_arg(uint, length); + + assert(screen->buffer_flush_mapped_range); + screen->buffer_flush_mapped_range(screen, buffer, offset, length); + + trace_dump_call_end(); +} + + +static void +trace_screen_buffer_unmap(struct pipe_screen *_screen, + struct pipe_buffer *buffer) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; +#if 0 + 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); + } +#endif + + trace_dump_call_begin("pipe_screen", "buffer_flush_mapped_range"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, buffer); + + assert(screen->buffer_unmap); + screen->buffer_unmap(screen, buffer); + + trace_dump_call_end(); +} + + +static void +trace_screen_buffer_destroy(struct pipe_buffer *buffer) +{ + struct trace_screen *tr_scr = trace_screen(buffer->screen); + struct pipe_screen *screen = tr_scr->screen; + + trace_dump_call_begin("pipe_screen", "buffer_destroy"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, buffer); + + assert(screen->buffer_destroy); + screen->buffer_destroy(buffer); + + trace_dump_call_end(); +} + + +static void +trace_screen_fence_reference(struct pipe_screen *_screen, + struct pipe_fence_handle **dst, + struct pipe_fence_handle *src) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + + trace_dump_call_begin("pipe_screen", "fence_reference"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, dst); + trace_dump_arg(ptr, src); + + screen->fence_reference(screen, dst, src); + + trace_dump_call_end(); +} + + +static int +trace_screen_fence_signalled(struct pipe_screen *_screen, + struct pipe_fence_handle *fence, + unsigned flag) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + int result; + + trace_dump_call_begin("pipe_screen", "fence_signalled"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, fence); + trace_dump_arg(uint, flag); + + result = screen->fence_signalled(screen, fence, flag); + + trace_dump_ret(int, result); + + trace_dump_call_end(); + + return result; +} + + +static int +trace_screen_fence_finish(struct pipe_screen *_screen, + struct pipe_fence_handle *fence, + unsigned flag) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + int result; + + trace_dump_call_begin("pipe_screen", "fence_finish"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, fence); + trace_dump_arg(uint, flag); + + result = screen->fence_finish(screen, fence, flag); + + trace_dump_ret(int, result); + + trace_dump_call_end(); + + return result; +} + + +/******************************************************************** + * screen + */ + static void trace_screen_destroy(struct pipe_screen *_screen) { @@ -442,12 +855,6 @@ trace_screen_create(struct pipe_screen *screen) goto error1; trace_dump_call_begin("", "pipe_screen_create"); - trace_dump_arg_begin("screen"); - trace_dump_ptr(screen); - trace_dump_arg_end(); - trace_dump_arg_begin("screen->winsys"); - trace_dump_ptr(screen->winsys); - trace_dump_arg_end(); tr_scr = CALLOC_STRUCT(trace_screen); if(!tr_scr) @@ -477,9 +884,25 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.tex_transfer_destroy = trace_screen_tex_transfer_destroy; tr_scr->base.transfer_map = trace_screen_transfer_map; tr_scr->base.transfer_unmap = trace_screen_transfer_unmap; + tr_scr->base.buffer_create = trace_screen_buffer_create; + tr_scr->base.user_buffer_create = trace_screen_user_buffer_create; + tr_scr->base.surface_buffer_create = trace_screen_surface_buffer_create; + if (screen->buffer_map) + tr_scr->base.buffer_map = trace_screen_buffer_map; + if (screen->buffer_map_range) + tr_scr->base.buffer_map_range = trace_screen_buffer_map_range; + if (screen->buffer_flush_mapped_range) + tr_scr->base.buffer_flush_mapped_range = trace_screen_buffer_flush_mapped_range; + if (screen->buffer_unmap) + tr_scr->base.buffer_unmap = trace_screen_buffer_unmap; + tr_scr->base.buffer_destroy = trace_screen_buffer_destroy; + tr_scr->base.fence_reference = trace_screen_fence_reference; + tr_scr->base.fence_signalled = trace_screen_fence_signalled; + tr_scr->base.fence_finish = trace_screen_fence_finish; + tr_scr->base.flush_frontbuffer = trace_screen_flush_frontbuffer; tr_scr->screen = screen; - trace_dump_ret(ptr, &tr_scr->base); + trace_dump_ret(ptr, screen); trace_dump_call_end(); return &tr_scr->base; diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h index 15fe1bc015..8c65516b50 100644 --- a/src/gallium/drivers/trace/tr_screen.h +++ b/src/gallium/drivers/trace/tr_screen.h @@ -37,6 +37,14 @@ extern "C" { #endif +/** + * 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_screen { struct pipe_screen base; @@ -53,6 +61,11 @@ struct pipe_screen * trace_screen_create(struct pipe_screen *screen); +void +trace_screen_user_buffer_update(struct pipe_screen *screen, + struct pipe_buffer *buffer); + + #ifdef __cplusplus } #endif diff --git a/src/gallium/drivers/trace/tr_winsys.c b/src/gallium/drivers/trace/tr_winsys.c deleted file mode 100644 index 1031ec7004..0000000000 --- a/src/gallium/drivers/trace/tr_winsys.c +++ /dev/null @@ -1,448 +0,0 @@ -/************************************************************************** - * - * 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 "util/u_memory.h" -#include "util/u_hash_table.h" - -#include "tr_dump.h" -#include "tr_state.h" -#include "tr_screen.h" -#include "tr_texture.h" -#include "tr_winsys.h" - - -static unsigned trace_buffer_hash(void *buffer) -{ - return (unsigned)(uintptr_t)buffer; -} - - -static int trace_buffer_compare(void *buffer1, void *buffer2) -{ - 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 -trace_winsys_flush_frontbuffer(struct pipe_winsys *_winsys, - struct pipe_surface *surface, - void *context_private) -{ - 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_texture *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_arg(ptr, surface); - /* XXX: hide, as there is nothing we can do with this - trace_dump_arg(ptr, context_private); - */ - - winsys->flush_frontbuffer(winsys, surface, context_private); - - trace_dump_call_end(); -} - - -static struct pipe_buffer * -trace_winsys_surface_buffer_create(struct pipe_winsys *_winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned *pstride) -{ - struct trace_winsys *tr_ws = trace_winsys(_winsys); - 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); - trace_dump_arg(format, format); - trace_dump_arg(uint, usage); - - result = winsys->surface_buffer_create(winsys, - width, 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, - 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 */ - if(buffer->usage & PIPE_BUFFER_USAGE_CPU_WRITE) { - void *map; - map = winsys->buffer_map(winsys, buffer, PIPE_BUFFER_USAGE_CPU_WRITE); - if(map) { - memset(map, 0, buffer->size); - winsys->buffer_unmap(winsys, buffer); - } - } - - return buffer; -} - - -static struct pipe_buffer * -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_end(); - 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 - * 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, - 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, - 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) { - assert(!hash_table_get(tr_ws->buffer_maps, buffer)); - hash_table_set(tr_ws->buffer_maps, buffer, map); - } - } - - return map; -} - - -static void -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); -} - - -static void -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(); -} - - -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 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(); -} - - -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 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; -} - - -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 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; -} - - -static void -trace_winsys_destroy(struct pipe_winsys *_winsys) -{ - 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); - */ - - trace_dump_call_end(); - - hash_table_destroy(tr_ws->buffer_maps); - - FREE(tr_ws); -} - - -struct pipe_winsys * -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.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_buffer_create = trace_winsys_surface_buffer_create; - 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->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: - return winsys; -} diff --git a/src/gallium/drivers/trace/tr_winsys.h b/src/gallium/drivers/trace/tr_winsys.h deleted file mode 100644 index f1837c7fc5..0000000000 --- a/src/gallium/drivers/trace/tr_winsys.h +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************************** - * - * 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 "util/u_debug.h" -#include "pipe/internal/p_winsys_screen.h" - - -/** - * 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 hash_table; - - -struct trace_winsys -{ - struct pipe_winsys base; - - struct pipe_winsys *winsys; - - struct hash_table *buffer_maps; -}; - - -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); - - -void -trace_winsys_user_buffer_update(struct pipe_winsys *winsys, - struct pipe_buffer *buffer); - - -#endif /* TR_WINSYS_H_ */ -- cgit v1.2.3 From e8ee34e7f34c51121dcfa6c763fc5eb900b562df Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 12 Mar 2009 13:20:37 +0100 Subject: trace: Wrap pipe_buffers --- src/gallium/drivers/trace/Makefile | 1 + src/gallium/drivers/trace/SConscript | 1 + src/gallium/drivers/trace/tr_buffer.c | 68 +++++++++++++++++++++++++++++++++ src/gallium/drivers/trace/tr_buffer.h | 69 ++++++++++++++++++++++++++++++++++ src/gallium/drivers/trace/tr_context.c | 50 +++++++++++++++++++++--- src/gallium/drivers/trace/tr_screen.c | 42 ++++++++++++++------- src/gallium/drivers/trace/tr_state.c | 4 +- 7 files changed, 215 insertions(+), 20 deletions(-) create mode 100644 src/gallium/drivers/trace/tr_buffer.c create mode 100644 src/gallium/drivers/trace/tr_buffer.h (limited to 'src/gallium/drivers/trace/Makefile') diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index 7c570bf7a5..e087db169a 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -4,6 +4,7 @@ include $(TOP)/configs/current LIBNAME = trace C_SOURCES = \ + tr_buffer.c \ tr_context.c \ tr_dump.c \ tr_screen.c \ diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 45e5ef6868..4215215d1a 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -5,6 +5,7 @@ env = env.Clone() trace = env.ConvenienceLibrary( target = 'trace', source = [ + 'tr_buffer.c', 'tr_context.c', 'tr_dump.c', 'tr_screen.c', diff --git a/src/gallium/drivers/trace/tr_buffer.c b/src/gallium/drivers/trace/tr_buffer.c new file mode 100644 index 0000000000..12c491c571 --- /dev/null +++ b/src/gallium/drivers/trace/tr_buffer.c @@ -0,0 +1,68 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 "util/u_memory.h" + +#include "tr_buffer.h" + + +struct pipe_buffer * +trace_buffer_create(struct trace_screen *tr_scr, + struct pipe_buffer *buffer) +{ + struct trace_buffer *tr_buf; + + if(!buffer) + goto error; + + assert(buffer->screen == tr_scr->screen); + + tr_buf = CALLOC_STRUCT(trace_buffer); + if(!tr_buf) + goto error; + + memcpy(&tr_buf->base, buffer, sizeof(struct pipe_buffer)); + tr_buf->base.screen = &tr_scr->base; + tr_buf->buffer = buffer; + + return &tr_buf->base; + +error: + pipe_buffer_reference(&buffer, NULL); + return NULL; +} + + +void +trace_buffer_destroy(struct trace_screen *tr_scr, + struct pipe_buffer *buffer) +{ + struct trace_buffer *tr_buf = trace_buffer(tr_scr, buffer); + pipe_buffer_reference(&tr_buf->buffer, NULL); + FREE(tr_buf); +} diff --git a/src/gallium/drivers/trace/tr_buffer.h b/src/gallium/drivers/trace/tr_buffer.h new file mode 100644 index 0000000000..e9daeb7702 --- /dev/null +++ b/src/gallium/drivers/trace/tr_buffer.h @@ -0,0 +1,69 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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_BUFFER_H_ +#define TR_BUFFER_H_ + + +#include "pipe/p_compiler.h" +#include "pipe/p_state.h" + +#include "tr_screen.h" + + +struct trace_buffer +{ + struct pipe_buffer base; + + struct pipe_buffer *buffer; + + void *map; +}; + + +static INLINE struct trace_buffer * +trace_buffer(struct trace_screen *tr_scr, + struct pipe_buffer *buffer) +{ + if(!buffer) + return NULL; + assert(tr_scr); + assert(buffer->screen == &tr_scr->base); + return (struct trace_buffer *)buffer; +} + + +struct pipe_buffer * +trace_buffer_create(struct trace_screen *tr_scr, + struct pipe_buffer *buffer); + +void +trace_buffer_destroy(struct trace_screen *tr_scr, + struct pipe_buffer *buffer); + + +#endif diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 6e367af57a..9dcd13f114 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -30,11 +30,30 @@ #include "tr_dump.h" #include "tr_state.h" +#include "tr_buffer.h" #include "tr_screen.h" #include "tr_texture.h" #include "tr_context.h" +static INLINE struct pipe_buffer * +trace_buffer_unwrap(struct trace_context *tr_ctx, + struct pipe_buffer *buffer) +{ + struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); + struct trace_buffer *tr_buf; + + if(!buffer) + return NULL; + + tr_buf = trace_buffer(tr_scr, buffer); + + assert(tr_buf->buffer); + assert(tr_buf->buffer->screen == tr_scr->screen); + return tr_buf->buffer; +} + + static INLINE struct pipe_texture * trace_texture_unwrap(struct trace_context *tr_ctx, struct pipe_texture *texture) @@ -123,12 +142,15 @@ trace_context_draw_arrays(struct pipe_context *_pipe, static INLINE boolean trace_context_draw_elements(struct pipe_context *_pipe, - struct pipe_buffer *indexBuffer, + struct pipe_buffer *_indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count) { + struct trace_screen *tr_scr = trace_screen(_pipe->screen); struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer); struct pipe_context *pipe = tr_ctx->pipe; + struct pipe_buffer *indexBuffer = tr_buf->buffer; boolean result; trace_screen_user_buffer_update(_pipe->screen, indexBuffer); @@ -154,7 +176,7 @@ trace_context_draw_elements(struct pipe_context *_pipe, static INLINE boolean trace_context_draw_range_elements(struct pipe_context *_pipe, - struct pipe_buffer *indexBuffer, + struct pipe_buffer *_indexBuffer, unsigned indexSize, unsigned minIndex, unsigned maxIndex, @@ -162,8 +184,11 @@ trace_context_draw_range_elements(struct pipe_context *_pipe, unsigned start, unsigned count) { + struct trace_screen *tr_scr = trace_screen(_pipe->screen); struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer); struct pipe_context *pipe = tr_ctx->pipe; + struct pipe_buffer *indexBuffer = tr_buf->buffer; boolean result; trace_screen_user_buffer_update(_pipe->screen, indexBuffer); @@ -695,7 +720,8 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe, struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - trace_screen_user_buffer_update(_pipe->screen, (struct pipe_buffer *)buffer); + if (buffer) + trace_screen_user_buffer_update(_pipe->screen, buffer->buffer); trace_dump_call_begin("pipe_context", "set_constant_buffer"); @@ -704,7 +730,13 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe, trace_dump_arg(uint, index); trace_dump_arg(constant_buffer, buffer); - pipe->set_constant_buffer(pipe, shader, index, buffer);; + if (buffer) { + struct pipe_constant_buffer _buffer; + _buffer.buffer = trace_buffer_unwrap(tr_ctx, buffer->buffer); + pipe->set_constant_buffer(pipe, shader, index, &_buffer); + } else { + pipe->set_constant_buffer(pipe, shader, index, buffer); + } trace_dump_call_end(); } @@ -840,7 +872,15 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, trace_dump_struct_array(vertex_buffer, buffers, num_buffers); trace_dump_arg_end(); - pipe->set_vertex_buffers(pipe, num_buffers, buffers);; + if (num_buffers) { + struct pipe_vertex_buffer *_buffers = malloc(num_buffers * sizeof(*_buffers)); + memcpy(_buffers, buffers, num_buffers * sizeof(*_buffers)); + for (i = 0; i < num_buffers; i++) + _buffers[i].buffer = trace_buffer_unwrap(tr_ctx, buffers[i].buffer); + pipe->set_vertex_buffers(pipe, num_buffers, _buffers); + } else { + pipe->set_vertex_buffers(pipe, num_buffers, buffers); + } trace_dump_call_end(); } diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 8e7e033d51..5ad4cccf0a 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -27,6 +27,7 @@ #include "util/u_memory.h" +#include "tr_buffer.h" #include "tr_dump.h" #include "tr_state.h" #include "tr_texture.h" @@ -34,6 +35,7 @@ #include "pipe/p_inlines.h" + static const char * trace_screen_get_name(struct pipe_screen *_screen) { @@ -488,7 +490,7 @@ trace_screen_surface_buffer_create(struct pipe_screen *_screen, trace_dump_call_end(); - return result; + return trace_buffer_create(tr_scr, result); } @@ -525,7 +527,7 @@ trace_screen_buffer_create(struct pipe_screen *_screen, } } - return result; + return trace_buffer_create(tr_scr, result); } @@ -559,7 +561,7 @@ trace_screen_user_buffer_create(struct pipe_screen *_screen, result->usage |= TRACE_BUFFER_USAGE_USER; } - return result; + return trace_buffer_create(tr_scr, result); } @@ -569,7 +571,7 @@ trace_screen_user_buffer_create(struct pipe_screen *_screen, */ void trace_screen_user_buffer_update(struct pipe_screen *_screen, - struct pipe_buffer *buffer) + struct pipe_buffer *_buffer) { #if 0 struct trace_screen *tr_scr = trace_screen(_screen); @@ -604,11 +606,13 @@ trace_screen_user_buffer_update(struct pipe_screen *_screen, static void * trace_screen_buffer_map(struct pipe_screen *_screen, - struct pipe_buffer *buffer, + struct pipe_buffer *_buffer, unsigned usage) { struct trace_screen *tr_scr = trace_screen(_screen); + struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer); struct pipe_screen *screen = tr_scr->screen; + struct pipe_buffer *buffer = tr_buf->buffer; void *map; trace_dump_call_begin("pipe_screen", "buffer_map"); @@ -636,13 +640,15 @@ trace_screen_buffer_map(struct pipe_screen *_screen, static void * trace_screen_buffer_map_range(struct pipe_screen *_screen, - struct pipe_buffer *buffer, + struct pipe_buffer *_buffer, unsigned offset, unsigned length, unsigned usage) { struct trace_screen *tr_scr = trace_screen(_screen); + struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer); struct pipe_screen *screen = tr_scr->screen; + struct pipe_buffer *buffer = tr_buf->buffer; void *map; trace_dump_call_begin("pipe_screen", "buffer_map_range"); @@ -666,12 +672,14 @@ trace_screen_buffer_map_range(struct pipe_screen *_screen, static void trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen, - struct pipe_buffer *buffer, + struct pipe_buffer *_buffer, unsigned offset, unsigned length) { struct trace_screen *tr_scr = trace_screen(_screen); + struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer); struct pipe_screen *screen = tr_scr->screen; + struct pipe_buffer *buffer = tr_buf->buffer; trace_dump_call_begin("pipe_screen", "buffer_flush_mapped_range"); @@ -689,10 +697,12 @@ trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen, static void trace_screen_buffer_unmap(struct pipe_screen *_screen, - struct pipe_buffer *buffer) + struct pipe_buffer *_buffer) { struct trace_screen *tr_scr = trace_screen(_screen); + struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer); struct pipe_screen *screen = tr_scr->screen; + struct pipe_buffer *buffer = tr_buf->buffer; #if 0 const void *map; @@ -731,23 +741,29 @@ trace_screen_buffer_unmap(struct pipe_screen *_screen, static void -trace_screen_buffer_destroy(struct pipe_buffer *buffer) +trace_screen_buffer_destroy(struct pipe_buffer *_buffer) { - struct trace_screen *tr_scr = trace_screen(buffer->screen); + struct trace_screen *tr_scr = trace_screen(_buffer->screen); + struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer); struct pipe_screen *screen = tr_scr->screen; + struct pipe_buffer *buffer = tr_buf->buffer; trace_dump_call_begin("pipe_screen", "buffer_destroy"); trace_dump_arg(ptr, screen); trace_dump_arg(ptr, buffer); - assert(screen->buffer_destroy); - screen->buffer_destroy(buffer); - trace_dump_call_end(); + + trace_buffer_destroy(tr_scr, _buffer); } +/******************************************************************** + * fence + */ + + static void trace_screen_fence_reference(struct pipe_screen *_screen, struct pipe_fence_handle **dst, diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c index 6c02826d9e..11384b9892 100644 --- a/src/gallium/drivers/trace/tr_state.c +++ b/src/gallium/drivers/trace/tr_state.c @@ -230,7 +230,7 @@ void trace_dump_constant_buffer(const struct pipe_constant_buffer *state) trace_dump_struct_begin("pipe_constant_buffer"); - trace_dump_member(ptr, state, buffer); + trace_dump_member(buffer_ptr, state, buffer); trace_dump_struct_end(); } @@ -469,7 +469,7 @@ void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state) trace_dump_member(uint, state, stride); trace_dump_member(uint, state, max_index); trace_dump_member(uint, state, buffer_offset); - trace_dump_member(ptr, state, buffer); + trace_dump_member(buffer_ptr, state, buffer); trace_dump_struct_end(); } -- cgit v1.2.3 From c30f66118974f41f57e86d49f372b7c78f891223 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 15 May 2009 04:17:00 +0200 Subject: trace: Move state dump functions to tr_dump_state.[c|h] --- src/gallium/drivers/trace/Makefile | 2 +- src/gallium/drivers/trace/SConscript | 2 +- src/gallium/drivers/trace/tr_context.c | 2 +- src/gallium/drivers/trace/tr_dump_state.c | 491 ++++++++++++++++++++++++++++++ src/gallium/drivers/trace/tr_dump_state.h | 78 +++++ src/gallium/drivers/trace/tr_screen.c | 2 +- src/gallium/drivers/trace/tr_state.c | 491 ------------------------------ src/gallium/drivers/trace/tr_state.h | 78 ----- 8 files changed, 573 insertions(+), 573 deletions(-) create mode 100644 src/gallium/drivers/trace/tr_dump_state.c create mode 100644 src/gallium/drivers/trace/tr_dump_state.h delete mode 100644 src/gallium/drivers/trace/tr_state.c delete mode 100644 src/gallium/drivers/trace/tr_state.h (limited to 'src/gallium/drivers/trace/Makefile') diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index e087db169a..188998d579 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -7,8 +7,8 @@ C_SOURCES = \ tr_buffer.c \ tr_context.c \ tr_dump.c \ + tr_dump_state.c \ tr_screen.c \ - tr_state.c \ tr_texture.c include ../../Makefile.template diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 4215215d1a..4ab829a3a8 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -8,8 +8,8 @@ trace = env.ConvenienceLibrary( 'tr_buffer.c', 'tr_context.c', 'tr_dump.c', + 'tr_dump_state.c', 'tr_screen.c', - 'tr_state.c', 'tr_texture.c', ]) diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 47280459a7..6a19233a9a 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -31,7 +31,7 @@ #include "pipe/p_screen.h" #include "tr_dump.h" -#include "tr_state.h" +#include "tr_dump_state.h" #include "tr_buffer.h" #include "tr_screen.h" #include "tr_texture.h" diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c new file mode 100644 index 0000000000..1b2b3493a6 --- /dev/null +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -0,0 +1,491 @@ +/************************************************************************** + * + * 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_compiler.h" +#include "util/u_memory.h" +#include "tgsi/tgsi_dump.h" + +#include "tr_dump.h" +#include "tr_dump_state.h" + + +void trace_dump_format(enum pipe_format format) +{ + trace_dump_enum(pf_name(format) ); +} + + +void trace_dump_block(const struct pipe_format_block *block) +{ + trace_dump_struct_begin("pipe_format_block"); + trace_dump_member(uint, block, size); + trace_dump_member(uint, block, width); + trace_dump_member(uint, block, height); + trace_dump_struct_end(); +} + + +static void trace_dump_reference(const struct pipe_reference *reference) +{ + trace_dump_struct_begin("pipe_reference"); + trace_dump_member(int, &reference->count, count); + trace_dump_struct_end(); +} + + +void trace_dump_template(const struct pipe_texture *templat) +{ + if(!templat) { + trace_dump_null(); + return; + } + + 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("height"); + trace_dump_array(uint, templat->height, 1); + trace_dump_member_end(); + + trace_dump_member_begin("depth"); + trace_dump_array(uint, templat->depth, 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(); +} + + +void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_rasterizer_state"); + + trace_dump_member(bool, state, flatshade); + trace_dump_member(bool, state, light_twoside); + trace_dump_member(uint, state, front_winding); + trace_dump_member(uint, state, cull_mode); + trace_dump_member(uint, state, fill_cw); + trace_dump_member(uint, state, fill_ccw); + trace_dump_member(bool, state, offset_cw); + trace_dump_member(bool, state, offset_ccw); + trace_dump_member(bool, state, scissor); + trace_dump_member(bool, state, poly_smooth); + trace_dump_member(bool, state, poly_stipple_enable); + trace_dump_member(bool, state, point_smooth); + trace_dump_member(bool, state, point_sprite); + trace_dump_member(bool, state, point_size_per_vertex); + trace_dump_member(bool, state, multisample); + trace_dump_member(bool, state, line_smooth); + trace_dump_member(bool, state, line_stipple_enable); + trace_dump_member(uint, state, line_stipple_factor); + trace_dump_member(uint, state, line_stipple_pattern); + trace_dump_member(bool, state, line_last_pixel); + trace_dump_member(bool, state, bypass_vs_clip_and_viewport); + trace_dump_member(bool, state, flatshade_first); + trace_dump_member(bool, state, gl_rasterization_rules); + + trace_dump_member(float, state, line_width); + trace_dump_member(float, state, point_size); + trace_dump_member(float, state, point_size_min); + 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(); +} + + +void trace_dump_poly_stipple(const struct pipe_poly_stipple *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_poly_stipple"); + + trace_dump_member_begin("stipple"); + trace_dump_array(uint, + state->stipple, + Elements(state->stipple)); + trace_dump_member_end(); + + trace_dump_struct_end(); +} + + +void trace_dump_viewport_state(const struct pipe_viewport_state *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_viewport_state"); + + trace_dump_member_array(float, state, scale); + trace_dump_member_array(float, state, translate); + + trace_dump_struct_end(); +} + + +void trace_dump_scissor_state(const struct pipe_scissor_state *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_scissor_state"); + + trace_dump_member(uint, state, minx); + trace_dump_member(uint, state, miny); + trace_dump_member(uint, state, maxx); + trace_dump_member(uint, state, maxy); + + trace_dump_struct_end(); +} + + +void trace_dump_clip_state(const struct pipe_clip_state *state) +{ + unsigned i; + + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_clip_state"); + + trace_dump_member_begin("ucp"); + trace_dump_array_begin(); + for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) { + trace_dump_elem_begin(); + trace_dump_array(float, state->ucp[i], 4); + trace_dump_elem_end(); + } + trace_dump_array_end(); + trace_dump_member_end(); + + trace_dump_member(uint, state, nr); + + trace_dump_struct_end(); +} + + +void trace_dump_constant_buffer(const struct pipe_constant_buffer *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_constant_buffer"); + + trace_dump_member(buffer_ptr, state, buffer); + + trace_dump_struct_end(); +} + + +void trace_dump_shader_state(const struct pipe_shader_state *state) +{ + static char str[8192]; + + 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"); + trace_dump_string(str); + trace_dump_member_end(); + + trace_dump_struct_end(); +} + + +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_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_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_elem_begin(); + trace_dump_struct_begin("pipe_stencil_state"); + trace_dump_member(bool, &state->stencil[i], enabled); + trace_dump_member(uint, &state->stencil[i], func); + trace_dump_member(uint, &state->stencil[i], fail_op); + trace_dump_member(uint, &state->stencil[i], zpass_op); + trace_dump_member(uint, &state->stencil[i], zfail_op); + trace_dump_member(uint, &state->stencil[i], ref_value); + trace_dump_member(uint, &state->stencil[i], valuemask); + trace_dump_member(uint, &state->stencil[i], writemask); + trace_dump_struct_end(); + trace_dump_elem_end(); + } + 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_struct_end(); +} + + +void trace_dump_blend_state(const struct pipe_blend_state *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_blend_state"); + + trace_dump_member(bool, state, blend_enable); + + trace_dump_member(uint, state, rgb_func); + trace_dump_member(uint, state, rgb_src_factor); + trace_dump_member(uint, state, rgb_dst_factor); + + trace_dump_member(uint, state, alpha_func); + trace_dump_member(uint, state, alpha_src_factor); + trace_dump_member(uint, state, alpha_dst_factor); + + trace_dump_member(bool, state, logicop_enable); + trace_dump_member(uint, state, logicop_func); + + trace_dump_member(uint, state, colormask); + trace_dump_member(bool, state, dither); + + trace_dump_struct_end(); +} + + +void trace_dump_blend_color(const struct pipe_blend_color *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_blend_color"); + + trace_dump_member_array(float, state, color); + + trace_dump_struct_end(); +} + + +void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state) +{ + trace_dump_struct_begin("pipe_framebuffer_state"); + + trace_dump_member(uint, state, width); + trace_dump_member(uint, state, height); + trace_dump_member(uint, state, nr_cbufs); + trace_dump_member_array(ptr, state, cbufs); + trace_dump_member(ptr, state, zsbuf); + + trace_dump_struct_end(); +} + + +void trace_dump_sampler_state(const struct pipe_sampler_state *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_sampler_state"); + + trace_dump_member(uint, state, wrap_s); + trace_dump_member(uint, state, wrap_t); + trace_dump_member(uint, state, wrap_r); + trace_dump_member(uint, state, min_img_filter); + trace_dump_member(uint, state, min_mip_filter); + trace_dump_member(uint, state, mag_img_filter); + trace_dump_member(bool, state, compare_mode); + trace_dump_member(uint, state, compare_func); + trace_dump_member(bool, state, normalized_coords); + trace_dump_member(uint, state, prefilter); + trace_dump_member(float, state, shadow_ambient); + trace_dump_member(float, state, lod_bias); + trace_dump_member(float, state, min_lod); + trace_dump_member(float, state, max_lod); + trace_dump_member_array(float, state, border_color); + trace_dump_member(float, state, max_anisotropy); + + trace_dump_struct_end(); +} + + +void trace_dump_surface(const struct pipe_surface *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_surface"); + + trace_dump_reference(&state->reference); + + trace_dump_member(format, state, format); + trace_dump_member(uint, state, width); + trace_dump_member(uint, state, height); + + trace_dump_member(uint, state, layout); + trace_dump_member(uint, state, offset); + trace_dump_member(uint, state, usage); + + trace_dump_member(ptr, state, texture); + trace_dump_member(uint, state, face); + trace_dump_member(uint, state, level); + trace_dump_member(uint, state, zslice); + + trace_dump_struct_end(); +} + + +void trace_dump_transfer(const struct pipe_transfer *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_transfer"); + + trace_dump_member(format, state, format); + trace_dump_member(uint, state, width); + trace_dump_member(uint, state, height); + + 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, usage); + + trace_dump_member(ptr, state, texture); + trace_dump_member(uint, state, face); + trace_dump_member(uint, state, level); + trace_dump_member(uint, state, zslice); + + trace_dump_struct_end(); +} + + +void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_vertex_buffer"); + + trace_dump_member(uint, state, stride); + trace_dump_member(uint, state, max_index); + trace_dump_member(uint, state, buffer_offset); + trace_dump_member(buffer_ptr, state, buffer); + + trace_dump_struct_end(); +} + + +void trace_dump_vertex_element(const struct pipe_vertex_element *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_vertex_element"); + + trace_dump_member(uint, state, src_offset); + + 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(); +} diff --git a/src/gallium/drivers/trace/tr_dump_state.h b/src/gallium/drivers/trace/tr_dump_state.h new file mode 100644 index 0000000000..05b821adb6 --- /dev/null +++ b/src/gallium/drivers/trace/tr_dump_state.h @@ -0,0 +1,78 @@ +/************************************************************************** + * + * 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_DUMP_STATE_H_ +#define TR_DUMP_STATE_H_ + +#include "pipe/p_format.h" +#include "pipe/p_state.h" +#include "pipe/p_shader_tokens.h" + + +void trace_dump_format(enum pipe_format format); + +void trace_dump_block(const struct pipe_format_block *block); + +void trace_dump_template(const struct pipe_texture *templat); + + +void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state); + +void trace_dump_poly_stipple(const struct pipe_poly_stipple *state); + +void trace_dump_viewport_state(const struct pipe_viewport_state *state); + +void trace_dump_scissor_state(const struct pipe_scissor_state *state); + +void trace_dump_clip_state(const struct pipe_clip_state *state); + +void trace_dump_constant_buffer(const struct pipe_constant_buffer *state); + +void trace_dump_token(const struct tgsi_token *token); + +void trace_dump_shader_state(const struct pipe_shader_state *state); + +void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state); + +void trace_dump_blend_state(const struct pipe_blend_state *state); + +void trace_dump_blend_color(const struct pipe_blend_color *state); + +void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state); + +void trace_dump_sampler_state(const struct pipe_sampler_state *state); + +void trace_dump_surface(const struct pipe_surface *state); + +void trace_dump_transfer(const struct pipe_transfer *state); + +void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state); + +void trace_dump_vertex_element(const struct pipe_vertex_element *state); + + +#endif /* TR_STATE_H */ diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 12a8535342..e659416aba 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -30,7 +30,7 @@ #include "tr_buffer.h" #include "tr_dump.h" -#include "tr_state.h" +#include "tr_dump_state.h" #include "tr_texture.h" #include "tr_screen.h" diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c deleted file mode 100644 index a9570c1aeb..0000000000 --- a/src/gallium/drivers/trace/tr_state.c +++ /dev/null @@ -1,491 +0,0 @@ -/************************************************************************** - * - * 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_compiler.h" -#include "util/u_memory.h" -#include "tgsi/tgsi_dump.h" - -#include "tr_dump.h" -#include "tr_state.h" - - -void trace_dump_format(enum pipe_format format) -{ - trace_dump_enum(pf_name(format) ); -} - - -void trace_dump_block(const struct pipe_format_block *block) -{ - trace_dump_struct_begin("pipe_format_block"); - trace_dump_member(uint, block, size); - trace_dump_member(uint, block, width); - trace_dump_member(uint, block, height); - trace_dump_struct_end(); -} - - -static void trace_dump_reference(const struct pipe_reference *reference) -{ - trace_dump_struct_begin("pipe_reference"); - trace_dump_member(int, &reference->count, count); - trace_dump_struct_end(); -} - - -void trace_dump_template(const struct pipe_texture *templat) -{ - if(!templat) { - trace_dump_null(); - return; - } - - 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("height"); - trace_dump_array(uint, templat->height, 1); - trace_dump_member_end(); - - trace_dump_member_begin("depth"); - trace_dump_array(uint, templat->depth, 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(); -} - - -void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_rasterizer_state"); - - trace_dump_member(bool, state, flatshade); - trace_dump_member(bool, state, light_twoside); - trace_dump_member(uint, state, front_winding); - trace_dump_member(uint, state, cull_mode); - trace_dump_member(uint, state, fill_cw); - trace_dump_member(uint, state, fill_ccw); - trace_dump_member(bool, state, offset_cw); - trace_dump_member(bool, state, offset_ccw); - trace_dump_member(bool, state, scissor); - trace_dump_member(bool, state, poly_smooth); - trace_dump_member(bool, state, poly_stipple_enable); - trace_dump_member(bool, state, point_smooth); - trace_dump_member(bool, state, point_sprite); - trace_dump_member(bool, state, point_size_per_vertex); - trace_dump_member(bool, state, multisample); - trace_dump_member(bool, state, line_smooth); - trace_dump_member(bool, state, line_stipple_enable); - trace_dump_member(uint, state, line_stipple_factor); - trace_dump_member(uint, state, line_stipple_pattern); - trace_dump_member(bool, state, line_last_pixel); - trace_dump_member(bool, state, bypass_vs_clip_and_viewport); - trace_dump_member(bool, state, flatshade_first); - trace_dump_member(bool, state, gl_rasterization_rules); - - trace_dump_member(float, state, line_width); - trace_dump_member(float, state, point_size); - trace_dump_member(float, state, point_size_min); - 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(); -} - - -void trace_dump_poly_stipple(const struct pipe_poly_stipple *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_poly_stipple"); - - trace_dump_member_begin("stipple"); - trace_dump_array(uint, - state->stipple, - Elements(state->stipple)); - trace_dump_member_end(); - - trace_dump_struct_end(); -} - - -void trace_dump_viewport_state(const struct pipe_viewport_state *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_viewport_state"); - - trace_dump_member_array(float, state, scale); - trace_dump_member_array(float, state, translate); - - trace_dump_struct_end(); -} - - -void trace_dump_scissor_state(const struct pipe_scissor_state *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_scissor_state"); - - trace_dump_member(uint, state, minx); - trace_dump_member(uint, state, miny); - trace_dump_member(uint, state, maxx); - trace_dump_member(uint, state, maxy); - - trace_dump_struct_end(); -} - - -void trace_dump_clip_state(const struct pipe_clip_state *state) -{ - unsigned i; - - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_clip_state"); - - trace_dump_member_begin("ucp"); - trace_dump_array_begin(); - for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) { - trace_dump_elem_begin(); - trace_dump_array(float, state->ucp[i], 4); - trace_dump_elem_end(); - } - trace_dump_array_end(); - trace_dump_member_end(); - - trace_dump_member(uint, state, nr); - - trace_dump_struct_end(); -} - - -void trace_dump_constant_buffer(const struct pipe_constant_buffer *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_constant_buffer"); - - trace_dump_member(buffer_ptr, state, buffer); - - trace_dump_struct_end(); -} - - -void trace_dump_shader_state(const struct pipe_shader_state *state) -{ - static char str[8192]; - - 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"); - trace_dump_string(str); - trace_dump_member_end(); - - trace_dump_struct_end(); -} - - -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_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_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_elem_begin(); - trace_dump_struct_begin("pipe_stencil_state"); - trace_dump_member(bool, &state->stencil[i], enabled); - trace_dump_member(uint, &state->stencil[i], func); - trace_dump_member(uint, &state->stencil[i], fail_op); - trace_dump_member(uint, &state->stencil[i], zpass_op); - trace_dump_member(uint, &state->stencil[i], zfail_op); - trace_dump_member(uint, &state->stencil[i], ref_value); - trace_dump_member(uint, &state->stencil[i], valuemask); - trace_dump_member(uint, &state->stencil[i], writemask); - trace_dump_struct_end(); - trace_dump_elem_end(); - } - 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_struct_end(); -} - - -void trace_dump_blend_state(const struct pipe_blend_state *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_blend_state"); - - trace_dump_member(bool, state, blend_enable); - - trace_dump_member(uint, state, rgb_func); - trace_dump_member(uint, state, rgb_src_factor); - trace_dump_member(uint, state, rgb_dst_factor); - - trace_dump_member(uint, state, alpha_func); - trace_dump_member(uint, state, alpha_src_factor); - trace_dump_member(uint, state, alpha_dst_factor); - - trace_dump_member(bool, state, logicop_enable); - trace_dump_member(uint, state, logicop_func); - - trace_dump_member(uint, state, colormask); - trace_dump_member(bool, state, dither); - - trace_dump_struct_end(); -} - - -void trace_dump_blend_color(const struct pipe_blend_color *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_blend_color"); - - trace_dump_member_array(float, state, color); - - trace_dump_struct_end(); -} - - -void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state) -{ - trace_dump_struct_begin("pipe_framebuffer_state"); - - trace_dump_member(uint, state, width); - trace_dump_member(uint, state, height); - trace_dump_member(uint, state, nr_cbufs); - trace_dump_member_array(ptr, state, cbufs); - trace_dump_member(ptr, state, zsbuf); - - trace_dump_struct_end(); -} - - -void trace_dump_sampler_state(const struct pipe_sampler_state *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_sampler_state"); - - trace_dump_member(uint, state, wrap_s); - trace_dump_member(uint, state, wrap_t); - trace_dump_member(uint, state, wrap_r); - trace_dump_member(uint, state, min_img_filter); - trace_dump_member(uint, state, min_mip_filter); - trace_dump_member(uint, state, mag_img_filter); - trace_dump_member(bool, state, compare_mode); - trace_dump_member(uint, state, compare_func); - trace_dump_member(bool, state, normalized_coords); - trace_dump_member(uint, state, prefilter); - trace_dump_member(float, state, shadow_ambient); - trace_dump_member(float, state, lod_bias); - trace_dump_member(float, state, min_lod); - trace_dump_member(float, state, max_lod); - trace_dump_member_array(float, state, border_color); - trace_dump_member(float, state, max_anisotropy); - - trace_dump_struct_end(); -} - - -void trace_dump_surface(const struct pipe_surface *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_surface"); - - trace_dump_reference(&state->reference); - - trace_dump_member(format, state, format); - trace_dump_member(uint, state, width); - trace_dump_member(uint, state, height); - - trace_dump_member(uint, state, layout); - trace_dump_member(uint, state, offset); - trace_dump_member(uint, state, usage); - - trace_dump_member(ptr, state, texture); - trace_dump_member(uint, state, face); - trace_dump_member(uint, state, level); - trace_dump_member(uint, state, zslice); - - trace_dump_struct_end(); -} - - -void trace_dump_transfer(const struct pipe_transfer *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_transfer"); - - trace_dump_member(format, state, format); - trace_dump_member(uint, state, width); - trace_dump_member(uint, state, height); - - 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, usage); - - trace_dump_member(ptr, state, texture); - trace_dump_member(uint, state, face); - trace_dump_member(uint, state, level); - trace_dump_member(uint, state, zslice); - - trace_dump_struct_end(); -} - - -void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_vertex_buffer"); - - trace_dump_member(uint, state, stride); - trace_dump_member(uint, state, max_index); - trace_dump_member(uint, state, buffer_offset); - trace_dump_member(buffer_ptr, state, buffer); - - trace_dump_struct_end(); -} - - -void trace_dump_vertex_element(const struct pipe_vertex_element *state) -{ - if(!state) { - trace_dump_null(); - return; - } - - trace_dump_struct_begin("pipe_vertex_element"); - - trace_dump_member(uint, state, src_offset); - - 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(); -} diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h deleted file mode 100644 index 513ed0ac98..0000000000 --- a/src/gallium/drivers/trace/tr_state.h +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************** - * - * 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_STATE_H -#define TR_STATE_H - -#include "pipe/p_format.h" -#include "pipe/p_state.h" -#include "pipe/p_shader_tokens.h" - - -void trace_dump_format(enum pipe_format format); - -void trace_dump_block(const struct pipe_format_block *block); - -void trace_dump_template(const struct pipe_texture *templat); - - -void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state); - -void trace_dump_poly_stipple(const struct pipe_poly_stipple *state); - -void trace_dump_viewport_state(const struct pipe_viewport_state *state); - -void trace_dump_scissor_state(const struct pipe_scissor_state *state); - -void trace_dump_clip_state(const struct pipe_clip_state *state); - -void trace_dump_constant_buffer(const struct pipe_constant_buffer *state); - -void trace_dump_token(const struct tgsi_token *token); - -void trace_dump_shader_state(const struct pipe_shader_state *state); - -void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state); - -void trace_dump_blend_state(const struct pipe_blend_state *state); - -void trace_dump_blend_color(const struct pipe_blend_color *state); - -void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state); - -void trace_dump_sampler_state(const struct pipe_sampler_state *state); - -void trace_dump_surface(const struct pipe_surface *state); - -void trace_dump_transfer(const struct pipe_transfer *state); - -void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state); - -void trace_dump_vertex_element(const struct pipe_vertex_element *state); - - -#endif /* TR_STATE_H */ -- cgit v1.2.3 From 3b4da4e9dac00f181380a9896ef3329964432c43 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 15 May 2009 05:30:43 +0200 Subject: trace: Put shaders on a list in the context --- src/gallium/drivers/trace/Makefile | 1 + src/gallium/drivers/trace/SConscript | 1 + src/gallium/drivers/trace/tr_context.c | 41 ++++++++++++++++++----- src/gallium/drivers/trace/tr_context.h | 7 ++++ src/gallium/drivers/trace/tr_state.c | 50 ++++++++++++++++++++++++++++ src/gallium/drivers/trace/tr_state.h | 59 ++++++++++++++++++++++++++++++++++ 6 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 src/gallium/drivers/trace/tr_state.c create mode 100644 src/gallium/drivers/trace/tr_state.h (limited to 'src/gallium/drivers/trace/Makefile') diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index 188998d579..94be0bfd5a 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -8,6 +8,7 @@ C_SOURCES = \ tr_context.c \ tr_dump.c \ tr_dump_state.c \ + tr_state.c \ tr_screen.c \ tr_texture.c diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 4ab829a3a8..9b5af0d86f 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -10,6 +10,7 @@ trace = env.ConvenienceLibrary( 'tr_dump.c', 'tr_dump_state.c', 'tr_screen.c', + 'tr_state.c', 'tr_texture.c', ]) diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 6a19233a9a..dee9ac57b4 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -32,10 +32,10 @@ #include "tr_dump.h" #include "tr_dump_state.h" +#include "tr_state.h" #include "tr_buffer.h" #include "tr_screen.h" #include "tr_texture.h" -#include "tr_context.h" static INLINE struct pipe_buffer * @@ -573,23 +573,30 @@ trace_context_create_fs_state(struct pipe_context *_pipe, trace_dump_call_end(); + result = trace_shader_create(tr_ctx, state, result); + return result; } static INLINE void trace_context_bind_fs_state(struct pipe_context *_pipe, - void *state) + void *_state) { struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; + void *state = tr_shdr ? tr_shdr->state : NULL; trace_dump_call_begin("pipe_context", "bind_fs_state"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, state); - pipe->bind_fs_state(pipe, state);; + if (tr_shdr && tr_shdr->replaced) + state = tr_shdr->replaced; + + pipe->bind_fs_state(pipe, state); trace_dump_call_end(); } @@ -597,19 +604,23 @@ trace_context_bind_fs_state(struct pipe_context *_pipe, static INLINE void trace_context_delete_fs_state(struct pipe_context *_pipe, - void *state) + void *_state) { struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; + void *state = tr_shdr->state; trace_dump_call_begin("pipe_context", "delete_fs_state"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, state); - pipe->delete_fs_state(pipe, state);; + pipe->delete_fs_state(pipe, state); trace_dump_call_end(); + + trace_shader_destroy(tr_ctx, tr_shdr); } @@ -626,28 +637,35 @@ trace_context_create_vs_state(struct pipe_context *_pipe, trace_dump_arg(ptr, pipe); trace_dump_arg(shader_state, state); - result = pipe->create_vs_state(pipe, state);; + result = pipe->create_vs_state(pipe, state); trace_dump_ret(ptr, result); trace_dump_call_end(); + result = trace_shader_create(tr_ctx, state, result); + return result; } static INLINE void trace_context_bind_vs_state(struct pipe_context *_pipe, - void *state) + void *_state) { struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; + void *state = tr_shdr ? tr_shdr->state : NULL; trace_dump_call_begin("pipe_context", "bind_vs_state"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, state); + if (tr_shdr && tr_shdr->replaced) + state = tr_shdr->replaced; + pipe->bind_vs_state(pipe, state);; trace_dump_call_end(); @@ -656,10 +674,12 @@ trace_context_bind_vs_state(struct pipe_context *_pipe, static INLINE void trace_context_delete_vs_state(struct pipe_context *_pipe, - void *state) + void *_state) { struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; + void *state = tr_shdr->state; trace_dump_call_begin("pipe_context", "delete_vs_state"); @@ -669,6 +689,8 @@ trace_context_delete_vs_state(struct pipe_context *_pipe, pipe->delete_vs_state(pipe, state);; trace_dump_call_end(); + + trace_shader_destroy(tr_ctx, tr_shdr); } @@ -1099,6 +1121,9 @@ trace_context_create(struct pipe_screen *_screen, if(!tr_ctx) goto error1; + pipe_mutex_init(tr_ctx->list_mutex); + make_empty_list(&tr_ctx->shaders); + tr_ctx->base.winsys = _screen->winsys; tr_ctx->base.screen = _screen; tr_ctx->base.destroy = trace_context_destroy; diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h index 2512a0a232..a7da7b9526 100644 --- a/src/gallium/drivers/trace/tr_context.h +++ b/src/gallium/drivers/trace/tr_context.h @@ -33,6 +33,7 @@ #include "util/u_debug.h" #include "pipe/p_context.h" +#include "tr_screen.h" #ifdef __cplusplus extern "C" { @@ -45,7 +46,13 @@ struct trace_context struct pipe_context *pipe; + /* for list on screen */ struct tr_list list; + + /* list of state objects */ + pipe_mutex list_mutex; + unsigned num_shaders; + struct tr_list shaders; }; diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c new file mode 100644 index 0000000000..c9ce63a0ed --- /dev/null +++ b/src/gallium/drivers/trace/tr_state.c @@ -0,0 +1,50 @@ +/* + * Copyright 2009 VMware, Inc. + * 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 + * on 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 + * VMWARE AND/OR THEIR 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 "tr_state.h" + +#include "util/u_memory.h" +#include "util/u_simple_list.h" + +struct trace_shader * trace_shader_create(struct trace_context *tr_ctx, + const struct pipe_shader_state *state, + void *result) +{ + struct trace_shader *tr_shdr = CALLOC_STRUCT(trace_shader); + + tr_shdr->state = result; + + /* works on context as well */ + trace_screen_add_to_list(tr_ctx, shaders, tr_shdr); + + return tr_shdr; +} + +void trace_shader_destroy(struct trace_context *tr_ctx, + struct trace_shader *tr_shdr) +{ + trace_screen_remove_from_list(tr_ctx, shaders, tr_shdr); + + FREE(tr_shdr); +} diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h new file mode 100644 index 0000000000..bca615c50e --- /dev/null +++ b/src/gallium/drivers/trace/tr_state.h @@ -0,0 +1,59 @@ +/* + * Copyright 2009 VMware, Inc. + * 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 + * on 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 + * VMWARE AND/OR THEIR 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_STATE_H_ +#define TR_STATE_H_ + +#include "tr_context.h" + +struct tgsi_token; + +struct trace_shader +{ + struct tr_list list; + + void *state; + void *replaced; + + struct tgsi_token *tokens; + struct tgsi_token *replaced_tokens; + + boolean disabled; +}; + + +static INLINE struct trace_shader * +trace_shader(void *state) +{ + return (struct trace_shader *)state; +} + +struct trace_shader * trace_shader_create(struct trace_context *tr_ctx, + const struct pipe_shader_state *state, + void *result); + +void trace_shader_destroy(struct trace_context *tr_ctx, + struct trace_shader *tr_shdr); + +#endif -- cgit v1.2.3 From f04c38fa1fab0fe640b89d0de82fa44e2ee984a9 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 16 May 2009 01:49:11 +0100 Subject: trace: Export enabled status --- src/gallium/drivers/trace/Makefile | 2 +- src/gallium/drivers/trace/tr_context.c | 2 +- src/gallium/drivers/trace/tr_screen.c | 23 ++++++++++++++++------- src/gallium/drivers/trace/tr_screen.h | 7 +++++++ 4 files changed, 25 insertions(+), 9 deletions(-) (limited to 'src/gallium/drivers/trace/Makefile') diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index 94be0bfd5a..ecb69fb996 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -8,8 +8,8 @@ C_SOURCES = \ tr_context.c \ tr_dump.c \ tr_dump_state.c \ - tr_state.c \ tr_screen.c \ + tr_state.c \ tr_texture.c include ../../Makefile.template diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index e51af2451b..a416628562 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1124,7 +1124,7 @@ trace_context_create(struct pipe_screen *_screen, if(!pipe) goto error1; - if(!trace_dump_trace_enabled()) + if(!trace_enabled()) goto error1; tr_scr = trace_screen(_screen); diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 58855a8346..bc14248eeb 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -37,6 +37,8 @@ #include "pipe/p_inlines.h" +static boolean trace = FALSE; + static const char * trace_screen_get_name(struct pipe_screen *_screen) { @@ -820,16 +822,20 @@ trace_screen_destroy(struct pipe_screen *_screen) struct pipe_screen *screen = tr_scr->screen; trace_dump_call_begin("pipe_screen", "destroy"); - trace_dump_arg(ptr, screen); + trace_dump_call_end(); + trace_dump_trace_end(); screen->destroy(screen); - trace_dump_call_end(); + FREE(tr_scr); +} - trace_dump_trace_end(); - FREE(tr_scr); +boolean +trace_enabled(void) +{ + return trace; } @@ -844,10 +850,13 @@ trace_screen_create(struct pipe_screen *screen) trace_dump_init(); - if(!trace_dump_trace_begin()) - goto error1; + if(trace_dump_trace_begin()) { + trace_dumping_start(); + trace = TRUE; + } - trace_dumping_start(); + if (!trace) + goto error1; trace_dump_call_begin("", "pipe_screen_create"); diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h index 59f254166d..7fae182985 100644 --- a/src/gallium/drivers/trace/tr_screen.h +++ b/src/gallium/drivers/trace/tr_screen.h @@ -71,6 +71,13 @@ struct trace_screen }; +/* + * tr_screen.c + */ + +boolean +trace_enabled(void); + struct trace_screen * trace_screen(struct pipe_screen *screen); -- cgit v1.2.3 From 01fa34cb98d9ea6008c7108b6112348e278864f4 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 1 Jun 2009 11:19:55 +0100 Subject: trace/rbug: Add rbug integration for remote debugging --- src/gallium/drivers/trace/Makefile | 1 + src/gallium/drivers/trace/README | 18 +- src/gallium/drivers/trace/SConscript | 1 + src/gallium/drivers/trace/tr_rbug.c | 636 ++++++++++++++++++++++++++++++++++ src/gallium/drivers/trace/tr_screen.c | 14 +- src/gallium/drivers/trace/tr_screen.h | 21 +- 6 files changed, 685 insertions(+), 6 deletions(-) create mode 100644 src/gallium/drivers/trace/tr_rbug.c (limited to 'src/gallium/drivers/trace/Makefile') diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index ecb69fb996..4aeb8e3d7e 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -10,6 +10,7 @@ C_SOURCES = \ tr_dump_state.c \ tr_screen.c \ tr_state.c \ + tr_rbug.c \ tr_texture.c include ../../Makefile.template diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README index 73dce20372..1000c31e49 100644 --- a/src/gallium/drivers/trace/README +++ b/src/gallium/drivers/trace/README @@ -3,7 +3,8 @@ = About = -This directory contains a Gallium3D pipe driver which traces all incoming calls. +This directory contains a Gallium3D debugger pipe driver. +It can traces all incoming calls and/or provide remote debugging functionality. = Build Instructions = @@ -23,7 +24,9 @@ ensure the right libGL.so is being picked by doing ldd progs/trivial/tri -and then try running +== Traceing == + +For traceing then do export XMESA_TRACE=y GALLIUM_TRACE=tri.trace progs/trivial/tri @@ -32,6 +35,16 @@ which should create a tri.trace file, which is an XML file. You can view copying trace.xsl to the same directory, and opening with a XSLT capable browser such as Firefox or Internet Explorer. +== Remote debugging == + +For remote debugging + + export XMESA_TRACE=y + GALLIUM_RBUG=true progs/trivial/tri + +which should open gallium remote debugging session. While the program is running +you can launch the small remote debugging application from progs/rbug. More +information is in that directory. = Integrating = @@ -62,3 +75,4 @@ trace_screen with real_screen when creating them. -- Jose Fonseca +Jakob Bornecrantz diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 9b5af0d86f..e635fed77d 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -11,6 +11,7 @@ trace = env.ConvenienceLibrary( 'tr_dump_state.c', 'tr_screen.c', 'tr_state.c', + 'tr_rbug.c', 'tr_texture.c', ]) diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c new file mode 100644 index 0000000000..1b26f60da4 --- /dev/null +++ b/src/gallium/drivers/trace/tr_rbug.c @@ -0,0 +1,636 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 "util/u_string.h" +#include "util/u_memory.h" +#include "util/u_simple_list.h" +#include "util/u_network.h" + +#include "tgsi/tgsi_parse.h" + +#include "tr_dump.h" +#include "tr_state.h" +#include "tr_buffer.h" +#include "tr_texture.h" + +#include "rbug/rbug.h" + +#include + +#if defined(PIPE_SUBSYSTEM_WINDOWS_USER) +# define sleep Sleep +#elif defined(PIPE_OS_LINUX) +void usleep(int); +# define sleep usleep +#else +# warning "No socket implementation" +#endif + +#define U642VOID(x) ((void *)(unsigned long)(x)) +#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) + +struct trace_rbug +{ + struct trace_screen *tr_scr; + struct rbug_connection *con; + pipe_thread thread; + boolean running; +}; + +PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug); + + +/********************************************************** + * Helper functions + */ + + +static struct trace_context * +trace_rbug_get_context_locked(struct trace_screen *tr_scr, rbug_context_t ctx) +{ + struct trace_context *tr_ctx = NULL; + struct tr_list *ptr; + + foreach(ptr, &tr_scr->contexts) { + tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list)); + if (ctx == VOID2U64(tr_ctx)) + break; + tr_ctx = NULL; + } + + return tr_ctx; +} + +static struct trace_shader * +trace_rbug_get_shader_locked(struct trace_context *tr_ctx, rbug_shader_t shdr) +{ + struct trace_shader *tr_shdr = NULL; + struct tr_list *ptr; + + foreach(ptr, &tr_ctx->shaders) { + tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list)); + if (shdr == VOID2U64(tr_shdr)) + break; + tr_shdr = NULL; + } + + return tr_shdr; +} + +static void * +trace_shader_create_locked(struct pipe_context *pipe, + struct trace_shader *tr_shdr, + struct tgsi_token *tokens) +{ + void *state = NULL; + struct pipe_shader_state pss = { 0 }; + pss.tokens = tokens; + + if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { + state = pipe->create_fs_state(pipe, &pss); + } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { + state = pipe->create_vs_state(pipe, &pss); + } else + assert(0); + + return state; +} + +static void +trace_shader_bind_locked(struct pipe_context *pipe, + struct trace_shader *tr_shdr, + void *state) +{ + if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { + pipe->bind_fs_state(pipe, state); + } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { + pipe->bind_vs_state(pipe, state); + } else + assert(0); +} + +static void +trace_shader_delete_locked(struct pipe_context *pipe, + struct trace_shader *tr_shdr, + void *state) +{ + if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { + pipe->delete_fs_state(pipe, state); + } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { + pipe->delete_vs_state(pipe, state); + } else + assert(0); +} + +/************************************************ + * Request handler functions + */ + + +static int +trace_rbug_texture_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_texture *tr_tex = NULL; + struct tr_list *ptr; + rbug_texture_t *texs; + int i = 0; + + pipe_mutex_lock(tr_scr->list_mutex); + texs = MALLOC(tr_scr->num_textures * sizeof(rbug_texture_t)); + foreach(ptr, &tr_scr->textures) { + tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list)); + texs[i++] = VOID2U64(tr_tex); + } + pipe_mutex_unlock(tr_scr->list_mutex); + + rbug_send_texture_list_reply(tr_rbug->con, serial, texs, i, NULL); + FREE(texs); + + return 0; +} + +static int +trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_texture *tr_tex; + struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header; + struct tr_list *ptr; + struct pipe_texture *t; + + pipe_mutex_lock(tr_scr->list_mutex); + foreach(ptr, &tr_scr->textures) { + tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list)); + if (gpti->texture == VOID2U64(tr_tex)) + break; + tr_tex = NULL; + } + + if (!tr_tex) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + t = tr_tex->texture; + rbug_send_texture_info_reply(tr_rbug->con, serial, + t->target, t->format, + t->width, t->last_level + 1, + t->height, t->last_level + 1, + t->depth, t->last_level + 1, + t->block.width, t->block.height, t->block.size, + t->last_level, + t->nr_samples, + t->tex_usage, + NULL); + + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_texture *tr_tex; + struct tr_list *ptr; + + struct pipe_screen *screen = tr_scr->screen; + struct pipe_texture *tex; + struct pipe_transfer *t; + + void *map; + + pipe_mutex_lock(tr_scr->list_mutex); + foreach(ptr, &tr_scr->textures) { + tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list)); + if (gptr->texture == VOID2U64(tr_tex)) + break; + tr_tex = NULL; + } + + if (!tr_tex) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + tex = tr_tex->texture; + t = screen->get_tex_transfer(tr_scr->screen, tex, + gptr->face, gptr->level, gptr->zslice, + PIPE_TRANSFER_READ, + gptr->x, gptr->y, gptr->w, gptr->h); + + map = screen->transfer_map(screen, t); + + rbug_send_texture_read_reply(tr_rbug->con, serial, + t->format, + t->block.width, t->block.height, t->block.size, + (uint8_t*)map, t->stride * t->nblocksy, + t->stride, + NULL); + + screen->transfer_unmap(screen, t); + screen->tex_transfer_destroy(t); + + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_context_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct tr_list *ptr; + struct trace_context *tr_ctx = NULL; + rbug_context_t *ctxs; + int i = 0; + + pipe_mutex_lock(tr_scr->list_mutex); + ctxs = MALLOC(tr_scr->num_contexts * sizeof(rbug_context_t)); + foreach(ptr, &tr_scr->contexts) { + tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list)); + ctxs[i++] = VOID2U64(tr_ctx); + } + pipe_mutex_unlock(tr_scr->list_mutex); + + rbug_send_context_list_reply(tr_rbug->con, serial, ctxs, i, NULL); + FREE(ctxs); + + return 0; +} + +static int +trace_rbug_shader_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_shader_list *list = (struct rbug_proto_shader_list *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + struct trace_shader *tr_shdr = NULL; + struct tr_list *ptr; + rbug_shader_t *shdrs; + int i = 0; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, list->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->list_mutex); + shdrs = MALLOC(tr_ctx->num_shaders * sizeof(rbug_shader_t)); + foreach(ptr, &tr_ctx->shaders) { + tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list)); + shdrs[i++] = VOID2U64(tr_shdr); + } + + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + + rbug_send_shader_list_reply(tr_rbug->con, serial, shdrs, i, NULL); + FREE(shdrs); + + return 0; +} + +static int +trace_rbug_shader_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_shader_info *info = (struct rbug_proto_shader_info *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + struct trace_shader *tr_shdr = NULL; + unsigned original_len; + unsigned replaced_len; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, info->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->list_mutex); + + tr_shdr = trace_rbug_get_shader_locked(tr_ctx, info->shader); + + if (!tr_shdr) { + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + /* just in case */ + assert(sizeof(struct tgsi_token) == 4); + + original_len = tgsi_num_tokens(tr_shdr->tokens); + if (tr_shdr->replaced_tokens) + replaced_len = tgsi_num_tokens(tr_shdr->replaced_tokens); + else + replaced_len = 0; + + rbug_send_shader_info_reply(tr_rbug->con, serial, + (uint32_t*)tr_shdr->tokens, original_len, + (uint32_t*)tr_shdr->replaced_tokens, replaced_len, + tr_shdr->disabled, + NULL); + + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_shader_disable(struct trace_rbug *tr_rbug, struct rbug_header *header) +{ + struct rbug_proto_shader_disable *dis = (struct rbug_proto_shader_disable *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + struct trace_shader *tr_shdr = NULL; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, dis->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->list_mutex); + + tr_shdr = trace_rbug_get_shader_locked(tr_ctx, dis->shader); + + if (!tr_shdr) { + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + tr_shdr->disabled = dis->disable; + + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; +} + +static int +trace_rbug_shader_replace(struct trace_rbug *tr_rbug, struct rbug_header *header) +{ + struct rbug_proto_shader_replace *rep = (struct rbug_proto_shader_replace *)header; + + struct trace_screen *tr_scr = tr_rbug->tr_scr; + struct trace_context *tr_ctx = NULL; + struct trace_shader *tr_shdr = NULL; + struct pipe_context *pipe = NULL; + void *state; + + pipe_mutex_lock(tr_scr->list_mutex); + tr_ctx = trace_rbug_get_context_locked(tr_scr, rep->context); + + if (!tr_ctx) { + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(tr_ctx->list_mutex); + + tr_shdr = trace_rbug_get_shader_locked(tr_ctx, rep->shader); + + if (!tr_shdr) { + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + return -ESRCH; + } + + /* protect the pipe context */ + trace_dump_call_lock(); + + pipe = tr_ctx->pipe; + + /* remove old replaced shader */ + if (tr_shdr->replaced) { + if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr) + trace_shader_bind_locked(pipe, tr_shdr, tr_shdr->state); + + FREE(tr_shdr->replaced_tokens); + trace_shader_delete_locked(pipe, tr_shdr, tr_shdr->replaced); + tr_shdr->replaced = NULL; + tr_shdr->replaced_tokens = NULL; + } + + /* empty inputs means restore old which we did above */ + if (rep->tokens_len == 0) + goto out; + + tr_shdr->replaced_tokens = tgsi_dup_tokens((struct tgsi_token *)rep->tokens); + if (!tr_shdr->replaced_tokens) + goto err; + + state = trace_shader_create_locked(pipe, tr_shdr, tr_shdr->replaced_tokens); + if (!state) + goto err; + + /* bind new shader if the shader is currently a bound */ + if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr) + trace_shader_bind_locked(pipe, tr_shdr, state); + + /* save state */ + tr_shdr->replaced = state; + +out: + trace_dump_call_unlock(); + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + + return 0; + +err: + FREE(tr_shdr->replaced_tokens); + tr_shdr->replaced = NULL; + tr_shdr->replaced_tokens = NULL; + + trace_dump_call_unlock(); + pipe_mutex_unlock(tr_ctx->list_mutex); + pipe_mutex_unlock(tr_scr->list_mutex); + return -EINVAL; +} + +static boolean +trace_rbug_header(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + int ret = 0; + + switch(header->opcode) { + case RBUG_OP_PING: + rbug_send_ping_reply(tr_rbug->con, serial, NULL); + break; + case RBUG_OP_TEXTURE_LIST: + ret = trace_rbug_texture_list(tr_rbug, header, serial); + break; + case RBUG_OP_TEXTURE_INFO: + ret = trace_rbug_texture_info(tr_rbug, header, serial); + break; + case RBUG_OP_TEXTURE_READ: + ret = trace_rbug_texture_read(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_LIST: + ret = trace_rbug_context_list(tr_rbug, header, serial); + break; + case RBUG_OP_SHADER_LIST: + ret = trace_rbug_shader_list(tr_rbug, header, serial); + break; + case RBUG_OP_SHADER_INFO: + ret = trace_rbug_shader_info(tr_rbug, header, serial); + break; + case RBUG_OP_SHADER_DISABLE: + ret = trace_rbug_shader_disable(tr_rbug, header); + break; + case RBUG_OP_SHADER_REPLACE: + ret = trace_rbug_shader_replace(tr_rbug, header); + break; + default: + debug_printf("%s - unsupported opcode %u\n", __FUNCTION__, header->opcode); + ret = -ENOSYS; + break; + } + rbug_free_header(header); + + if (ret) + rbug_send_error_reply(tr_rbug->con, serial, ret, NULL); + + return TRUE; +} + +static void +trace_rbug_con(struct trace_rbug *tr_rbug) +{ + struct rbug_header *header; + uint32_t serial; + + debug_printf("%s - connection received\n", __FUNCTION__); + + while(tr_rbug->running) { + header = rbug_get_message(tr_rbug->con, &serial); + if (!header) + break; + + if (!trace_rbug_header(tr_rbug, header, serial)) + break; + } + + debug_printf("%s - connection closed\n", __FUNCTION__); + + rbug_disconnect(tr_rbug->con); + tr_rbug->con = NULL; +} + +PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug) +{ + struct trace_rbug *tr_rbug = void_tr_rbug; + uint16_t port = 13370; + int s = -1; + int c; + + u_socket_init(); + + for (;port <= 13379 && s < 0; port++) + s = u_socket_listen_on_port(port); + + if (s < 0) { + debug_printf("trace_rbug - failed to listen\n"); + return NULL; + } + + u_socket_block(s, false); + + debug_printf("trace_rbug - remote debugging listening on port %u\n", --port); + + while(tr_rbug->running) { + sleep(1); + + c = u_socket_accept(s); + if (c < 0) + continue; + + u_socket_block(c, true); + tr_rbug->con = rbug_from_socket(c); + + trace_rbug_con(tr_rbug); + + u_socket_close(c); + } + + u_socket_close(s); + + u_socket_stop(); + + return NULL; +} + +/********************************************************** + * + */ + +struct trace_rbug * +trace_rbug_start(struct trace_screen *tr_scr) +{ + struct trace_rbug *tr_rbug = MALLOC_STRUCT(trace_rbug); + if (!tr_rbug) + return NULL; + + tr_rbug->tr_scr = tr_scr; + tr_rbug->running = TRUE; + tr_rbug->thread = pipe_thread_create(trace_rbug_thread, tr_rbug); + + return tr_rbug; +} + +void +trace_rbug_stop(struct trace_rbug *tr_rbug) +{ + if (!tr_rbug) + return; + + tr_rbug->running = false; + pipe_thread_wait(tr_rbug->thread); + + FREE(tr_rbug); + + return; +} diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index bc14248eeb..920f418ebf 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -826,24 +826,26 @@ trace_screen_destroy(struct pipe_screen *_screen) trace_dump_call_end(); trace_dump_trace_end(); + if (tr_scr->rbug) + trace_rbug_stop(tr_scr->rbug); + screen->destroy(screen); FREE(tr_scr); } - boolean trace_enabled(void) { return trace; } - struct pipe_screen * trace_screen_create(struct pipe_screen *screen) { struct trace_screen *tr_scr; struct pipe_winsys *winsys; + boolean rbug = FALSE; if(!screen) goto error1; @@ -855,6 +857,11 @@ trace_screen_create(struct pipe_screen *screen) trace = TRUE; } + if (debug_get_bool_option("GALLIUM_RBUG", FALSE)) { + trace = TRUE; + rbug = TRUE; + } + if (!trace) goto error1; @@ -915,6 +922,9 @@ trace_screen_create(struct pipe_screen *screen) trace_dump_ret(ptr, screen); trace_dump_call_end(); + if (rbug) + tr_scr->rbug = trace_rbug_start(tr_scr); + return &tr_scr->base; #if 0 diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h index 7fae182985..dba8cd7c65 100644 --- a/src/gallium/drivers/trace/tr_screen.h +++ b/src/gallium/drivers/trace/tr_screen.h @@ -57,6 +57,9 @@ struct trace_screen struct pipe_screen *screen; + /* remote debugger */ + struct trace_rbug *rbug; + pipe_mutex list_mutex; int num_buffers; int num_contexts; @@ -71,21 +74,34 @@ struct trace_screen }; +/* + * tr_rbug.c + */ + + +struct trace_rbug; + +struct trace_rbug * +trace_rbug_start(struct trace_screen *tr_scr); + +void +trace_rbug_stop(struct trace_rbug *tr_rbug); + + /* * tr_screen.c */ + boolean trace_enabled(void); struct trace_screen * trace_screen(struct pipe_screen *screen); - struct pipe_screen * trace_screen_create(struct pipe_screen *screen); - void trace_screen_user_buffer_update(struct pipe_screen *screen, struct pipe_buffer *buffer); @@ -106,6 +122,7 @@ trace_screen_user_buffer_update(struct pipe_screen *screen, pipe_mutex_unlock(tr_scr->list_mutex); \ } while (0) + #ifdef __cplusplus } #endif -- cgit v1.2.3 From c0d7502a2cf994e635f1383f523653b92f4bd709 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 2 Jul 2009 14:57:55 +0200 Subject: trace: Add drm api integration This is okay since drm_api.h doesn't have any external dependancies, one could make it only compile on platforms that support drm. --- src/gallium/drivers/trace/Makefile | 1 + src/gallium/drivers/trace/tr_drm.c | 211 ++++++++++++++++++++++++++++++++++ src/gallium/drivers/trace/tr_drm.h | 35 ++++++ src/gallium/drivers/trace/tr_screen.c | 30 +++-- 4 files changed, 265 insertions(+), 12 deletions(-) create mode 100644 src/gallium/drivers/trace/tr_drm.c create mode 100644 src/gallium/drivers/trace/tr_drm.h (limited to 'src/gallium/drivers/trace/Makefile') diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index 4aeb8e3d7e..dd6831c70a 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -11,6 +11,7 @@ C_SOURCES = \ tr_screen.c \ tr_state.c \ tr_rbug.c \ + tr_drm.c \ tr_texture.c include ../../Makefile.template diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c new file mode 100644 index 0000000000..98ac75e3fa --- /dev/null +++ b/src/gallium/drivers/trace/tr_drm.c @@ -0,0 +1,211 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE 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 "state_tracker/drm_api.h" + +#include "util/u_memory.h" +#include "trace/tr_drm.h" +#include "trace/tr_screen.h" +#include "trace/tr_context.h" +#include "trace/tr_buffer.h" +#include "trace/tr_texture.h" + +struct trace_drm_api +{ + struct drm_api base; + + struct drm_api *api; +}; + +static INLINE struct trace_drm_api * +trace_drm_api(struct drm_api *_api) +{ + return (struct trace_drm_api *)_api; +} + +static struct pipe_screen * +trace_drm_create_screen(struct drm_api *_api, int fd, + struct drm_create_screen_arg *arg) +{ + struct trace_drm_api *tr_api = trace_drm_api(_api); + struct drm_api *api = tr_api->api; + struct pipe_screen *screen; + + /* TODO trace call */ + + if (arg && arg->mode != DRM_CREATE_NORMAL) + return NULL; + + screen = api->create_screen(api, fd, arg); + + return trace_screen_create(screen); +}; + +static struct pipe_context * +trace_drm_create_context(struct drm_api *_api, + struct pipe_screen *_screen) +{ + struct trace_screen *tr_screen = trace_screen(_screen); + struct trace_drm_api *tr_api = trace_drm_api(_api); + struct pipe_screen *screen = tr_screen->screen; + struct drm_api *api = tr_api->api; + struct pipe_context *pipe; + + /* TODO trace call */ + + pipe = api->create_context(api, screen); + + pipe = trace_context_create(_screen, pipe); + + return pipe; +}; + +static boolean +trace_drm_buffer_from_texture(struct drm_api *_api, + struct pipe_texture *_texture, + struct pipe_buffer **_buffer, + unsigned *stride) +{ + struct trace_texture *tr_texture = trace_texture(_texture); + struct trace_drm_api *tr_api = trace_drm_api(_api); + struct pipe_texture *texture = tr_texture->texture; + struct drm_api *api = tr_api->api; + struct pipe_buffer *buffer = NULL; + boolean result; + + /* TODO trace call */ + + result = api->buffer_from_texture(api, texture, &buffer, stride); + + if (result && _buffer) + buffer = trace_buffer_create(trace_screen(texture->screen), buffer); + + if (_buffer) + *_buffer = buffer; + else + pipe_buffer_reference(&buffer, NULL); + + return result; +} + +static struct pipe_buffer * +trace_drm_buffer_from_handle(struct drm_api *_api, + struct pipe_screen *_screen, + const char *name, + unsigned handle) +{ + struct trace_screen *tr_screen = trace_screen(_screen); + struct trace_drm_api *tr_api = trace_drm_api(_api); + struct pipe_screen *screen = tr_screen->screen; + struct drm_api *api = tr_api->api; + struct pipe_buffer *result; + + /* TODO trace call */ + + result = api->buffer_from_handle(api, screen, name, handle); + + result = trace_buffer_create(trace_screen(_screen), result); + + return result; +} + +static boolean +trace_drm_handle_from_buffer(struct drm_api *_api, + struct pipe_screen *_screen, + struct pipe_buffer *_buffer, + unsigned *handle) +{ + struct trace_screen *tr_screen = trace_screen(_screen); + struct trace_buffer *tr_buffer = trace_buffer(_buffer); + struct trace_drm_api *tr_api = trace_drm_api(_api); + struct pipe_screen *screen = tr_screen->screen; + struct pipe_buffer *buffer = tr_buffer->buffer; + struct drm_api *api = tr_api->api; + + /* TODO trace call */ + + return api->handle_from_buffer(api, screen, buffer, handle); +} + +static boolean +trace_drm_global_handle_from_buffer(struct drm_api *_api, + struct pipe_screen *_screen, + struct pipe_buffer *_buffer, + unsigned *handle) +{ + struct trace_screen *tr_screen = trace_screen(_screen); + struct trace_buffer *tr_buffer = trace_buffer(_buffer); + struct trace_drm_api *tr_api = trace_drm_api(_api); + struct pipe_screen *screen = tr_screen->screen; + struct pipe_buffer *buffer = tr_buffer->buffer; + struct drm_api *api = tr_api->api; + + /* TODO trace call */ + + return api->global_handle_from_buffer(api, screen, buffer, handle); +} + +static void +trace_drm_destroy(struct drm_api *_api) +{ + struct trace_drm_api *tr_api = trace_drm_api(_api); + struct drm_api *api = tr_api->api; + api->destroy(api); + + free(tr_api); +} + +struct drm_api * +trace_drm_create(struct drm_api *api) +{ + struct trace_drm_api *tr_api; + + if (!api) + goto error; + + if (!trace_enabled()) + goto error; + + tr_api = CALLOC_STRUCT(trace_drm_api); + + if (!tr_api) + goto error; + + tr_api->base.create_screen = trace_drm_create_screen; + tr_api->base.create_context = trace_drm_create_context; + tr_api->base.buffer_from_texture = trace_drm_buffer_from_texture; + tr_api->base.buffer_from_handle = trace_drm_buffer_from_handle; + tr_api->base.handle_from_buffer = trace_drm_handle_from_buffer; + tr_api->base.global_handle_from_buffer = trace_drm_global_handle_from_buffer; + tr_api->base.destroy = trace_drm_destroy; + tr_api->api = api; + + return &tr_api->base; + +error: + return api; +} diff --git a/src/gallium/drivers/trace/tr_drm.h b/src/gallium/drivers/trace/tr_drm.h new file mode 100644 index 0000000000..845c66a32a --- /dev/null +++ b/src/gallium/drivers/trace/tr_drm.h @@ -0,0 +1,35 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE 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_DRM_H +#define TR_DRM_H + +struct drm_api; + +struct drm_api* trace_drm_create(struct drm_api *api); + +#endif /* ID_DRM_H */ diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 920f418ebf..5b1e26a52d 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -38,6 +38,7 @@ static boolean trace = FALSE; +static boolean rbug = FALSE; static const char * trace_screen_get_name(struct pipe_screen *_screen) @@ -837,18 +838,11 @@ trace_screen_destroy(struct pipe_screen *_screen) boolean trace_enabled(void) { - return trace; -} + static boolean firstrun = TRUE; -struct pipe_screen * -trace_screen_create(struct pipe_screen *screen) -{ - struct trace_screen *tr_scr; - struct pipe_winsys *winsys; - boolean rbug = FALSE; - - if(!screen) - goto error1; + if (!firstrun) + return trace; + firstrun = FALSE; trace_dump_init(); @@ -862,7 +856,19 @@ trace_screen_create(struct pipe_screen *screen) rbug = TRUE; } - if (!trace) + return trace; +} + +struct pipe_screen * +trace_screen_create(struct pipe_screen *screen) +{ + struct trace_screen *tr_scr; + struct pipe_winsys *winsys; + + if(!screen) + goto error1; + + if (!trace_enabled()) goto error1; trace_dump_call_begin("", "pipe_screen_create"); -- cgit v1.2.3