From 67171ed85f3f9486238a994e8a427ddc1ac31069 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 28 Dec 2009 16:25:48 +0000 Subject: [PATCH] xlib: Integrate the trace driver with all pipe drivers. And not just softpipe. It is particularly convenient to use llvmpipe instead, since it is much faster. It also allows to use rbug with all xlib drivers. --- src/gallium/drivers/trace/README | 5 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 23 +++- src/gallium/winsys/xlib/Makefile | 7 +- src/gallium/winsys/xlib/SConscript | 7 +- src/gallium/winsys/xlib/xlib.c | 9 -- src/gallium/winsys/xlib/xlib.h | 1 - src/gallium/winsys/xlib/xlib_trace.c | 113 ------------------- 7 files changed, 24 insertions(+), 141 deletions(-) delete mode 100644 src/gallium/winsys/xlib/xlib_trace.c diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README index 1000c31e49a..203c3851bc3 100644 --- a/src/gallium/drivers/trace/README +++ b/src/gallium/drivers/trace/README @@ -24,11 +24,10 @@ ensure the right libGL.so is being picked by doing ldd progs/trivial/tri -== Traceing == +== Tracing == -For traceing then do +For tracing then do - export XMESA_TRACE=y GALLIUM_TRACE=tri.trace progs/trivial/tri which should create a tri.trace file, which is an XML file. You can view copying diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index c76dfb31d2b..1783bc504d9 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -67,6 +67,10 @@ #include "pipe/p_screen.h" #include "pipe/p_context.h" +#include "trace/tr_screen.h" +#include "trace/tr_context.h" +#include "trace/tr_texture.h" + #include "xm_winsys.h" #include @@ -87,6 +91,8 @@ void xmesa_set_driver( const struct xm_driver *templ ) */ pipe_mutex _xmesa_lock; +static struct pipe_screen *_screen = NULL; +static struct pipe_screen *screen = NULL; /**********************************************************************/ @@ -754,7 +760,7 @@ PUBLIC XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) { static GLboolean firstTime = GL_TRUE; - static struct pipe_screen *screen = NULL; + struct pipe_context *_pipe = NULL; struct pipe_context *pipe = NULL; XMesaContext c; GLcontext *mesaCtx; @@ -762,7 +768,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) if (firstTime) { pipe_mutex_init(_xmesa_lock); - screen = driver.create_pipe_screen(); + _screen = driver.create_pipe_screen(); + screen = trace_screen_create( _screen ); firstTime = GL_FALSE; } @@ -781,9 +788,11 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) if (screen == NULL) goto fail; - pipe = driver.create_pipe_context(screen, (void *) c); - if (pipe == NULL) + _pipe = driver.create_pipe_context(_screen, (void *) c); + if (_pipe == NULL) goto fail; + pipe = trace_context_create(screen, _pipe); + pipe->priv = c; c->st = st_create_context(pipe, &v->mesa_visual, @@ -1110,6 +1119,12 @@ void XMesaSwapBuffers( XMesaBuffer b ) st_swapbuffers(b->stfb, &frontLeftSurf, NULL); if (frontLeftSurf) { + if (_screen != screen) { + struct trace_surface *tr_surf = trace_surface( frontLeftSurf ); + struct pipe_surface *surf = tr_surf->surface; + frontLeftSurf = surf; + } + driver.display_surface(b, frontLeftSurf); } diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index a0293fe9b4b..9482e8f9b11 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -23,17 +23,14 @@ INCLUDE_DIRS = \ -I$(TOP)/src/gallium/auxiliary DEFINES += \ - -DGALLIUM_SOFTPIPE \ - -DGALLIUM_TRACE \ - -DGALLIUM_BRW + -DGALLIUM_SOFTPIPE #-DGALLIUM_CELL will be defined by the config */ XLIB_WINSYS_SOURCES = \ xlib.c \ xlib_cell.c \ xlib_llvmpipe.c \ - xlib_softpipe.c \ - xlib_trace.c + xlib_softpipe.c XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o) diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index 7a9e985cb58..ccec2566b1c 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -22,7 +22,7 @@ if env['platform'] == 'linux' \ 'xlib.c', ] - drivers = [] + drivers = [trace] if 'softpipe' in env['drivers']: env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') @@ -42,11 +42,6 @@ if env['platform'] == 'linux' \ sources += ['xlib_cell.c'] drivers += [cell] - if 'trace' in env['drivers']: - env.Append(CPPDEFINES = 'GALLIUM_TRACE') - sources += ['xlib_trace.c'] - drivers += [trace] - # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions libgl = env.SharedLibrary( target ='GL', diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c index 163cc8863cb..6dbe05f193e 100644 --- a/src/gallium/winsys/xlib/xlib.c +++ b/src/gallium/winsys/xlib/xlib.c @@ -42,7 +42,6 @@ */ enum mode { - MODE_TRACE, MODE_CELL, MODE_LLVMPIPE, MODE_SOFTPIPE @@ -51,9 +50,6 @@ enum mode { static enum mode get_mode() { - if (getenv("XMESA_TRACE")) - return MODE_TRACE; - #ifdef GALLIUM_CELL if (!getenv("GALLIUM_NOCELL")) return MODE_CELL; @@ -73,11 +69,6 @@ static void _init( void ) enum mode xlib_mode = get_mode(); switch (xlib_mode) { - case MODE_TRACE: -#if defined(GALLIUM_TRACE) && defined(GALLIUM_SOFTPIPE) - xmesa_set_driver( &xlib_trace_driver ); -#endif - break; case MODE_CELL: #if defined(GALLIUM_CELL) xmesa_set_driver( &xlib_cell_driver ); diff --git a/src/gallium/winsys/xlib/xlib.h b/src/gallium/winsys/xlib/xlib.h index f0855035f77..8e091d0c084 100644 --- a/src/gallium/winsys/xlib/xlib.h +++ b/src/gallium/winsys/xlib/xlib.h @@ -5,7 +5,6 @@ #include "pipe/p_compiler.h" #include "xm_winsys.h" -extern struct xm_driver xlib_trace_driver; extern struct xm_driver xlib_softpipe_driver; extern struct xm_driver xlib_llvmpipe_driver; extern struct xm_driver xlib_cell_driver; diff --git a/src/gallium/winsys/xlib/xlib_trace.c b/src/gallium/winsys/xlib/xlib_trace.c deleted file mode 100644 index dbea655ab45..00000000000 --- a/src/gallium/winsys/xlib/xlib_trace.c +++ /dev/null @@ -1,113 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - * Brian Paul - */ - - -#include "xlib.h" - -#include "trace/tr_screen.h" -#include "trace/tr_context.h" -#include "trace/tr_texture.h" - -#include "pipe/p_screen.h" - - - -static struct pipe_screen * -xlib_create_trace_screen( void ) -{ - struct pipe_screen *screen, *trace_screen; - - screen = xlib_softpipe_driver.create_pipe_screen(); - if (screen == NULL) - goto fail; - - /* Wrap it: - */ - trace_screen = trace_screen_create(screen); - if (trace_screen == NULL) - goto fail; - - return trace_screen; - -fail: - if (screen) - screen->destroy( screen ); - return NULL; -} - -static struct pipe_context * -xlib_create_trace_context( struct pipe_screen *_screen, - void *priv ) -{ - struct trace_screen *tr_scr = trace_screen( _screen ); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_context *pipe, *trace_pipe; - - pipe = xlib_softpipe_driver.create_pipe_context( screen, priv ); - if (pipe == NULL) - goto fail; - - /* Wrap it: - */ - trace_pipe = trace_context_create(_screen, pipe); - if (trace_pipe == NULL) - goto fail; - - trace_pipe->priv = priv; - - return trace_pipe; - -fail: - if (pipe) - pipe->destroy( pipe ); - return NULL; -} - -static void -xlib_trace_display_surface( struct xmesa_buffer *buffer, - struct pipe_surface *_surf ) -{ - struct trace_surface *tr_surf = trace_surface( _surf ); - struct pipe_surface *surf = tr_surf->surface; - - xlib_softpipe_driver.display_surface( buffer, surf ); -} - - -struct xm_driver xlib_trace_driver = -{ - .create_pipe_screen = xlib_create_trace_screen, - .create_pipe_context = xlib_create_trace_context, - .display_surface = xlib_trace_display_surface, -}; -- 2.30.2