From d0aea650320fec0b8e01110eeee22b1f3700d587 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 17:27:58 +0000 Subject: gallium: create helper for swrast+xlib combination Several targets may want to reuse this code. It's pretty simple, not sure if this is really a win. --- src/gallium/auxiliary/Makefile | 3 +- src/gallium/include/state_tracker/xlib_sw_winsys.h | 11 +--- src/gallium/state_trackers/glx/xlib/xm_api.c | 2 +- src/gallium/state_trackers/glx/xlib/xm_public.h | 44 ++++++++++++++ src/gallium/state_trackers/glx/xlib/xm_winsys.h | 42 ------------- src/gallium/targets/libgl-xlib/xlib.c | 70 ++-------------------- src/gallium/winsys/drm/i965/xlib/xlib_i965.c | 2 +- 7 files changed, 55 insertions(+), 119 deletions(-) create mode 100644 src/gallium/state_trackers/glx/xlib/xm_public.h delete mode 100644 src/gallium/state_trackers/glx/xlib/xm_winsys.h diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 68b1a3e854..c84e8d781d 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -131,7 +131,8 @@ C_SOURCES = \ vl/vl_mpeg12_mc_renderer.c \ vl/vl_compositor.c \ vl/vl_csc.c \ - vl/vl_shader_build.c + vl/vl_shader_build.c \ + target-helpers/swrast_xlib.c GALLIVM_SOURCES = \ gallivm/lp_bld_alpha.c \ diff --git a/src/gallium/include/state_tracker/xlib_sw_winsys.h b/src/gallium/include/state_tracker/xlib_sw_winsys.h index 13dc837712..f22c22bb62 100644 --- a/src/gallium/include/state_tracker/xlib_sw_winsys.h +++ b/src/gallium/include/state_tracker/xlib_sw_winsys.h @@ -9,8 +9,9 @@ struct pipe_screen; struct pipe_surface; /* This is what the xlib software winsys expects to find in the - * "private" field of flush_frontbuffers(). Xlib-based state trackers - * somehow need to know this. + * "private" field of flush_frontbuffers(). + * + * Xlib-based state trackers somehow need to know this. */ struct xlib_drawable { Visual *visual; @@ -18,12 +19,6 @@ struct xlib_drawable { Drawable drawable; }; -/* This is the interface required by the glx/xlib state tracker. Why - * is it being defined in this file? - */ -struct xm_driver { - struct pipe_screen *(*create_pipe_screen)( Display *display ); -}; /* This is the public interface to the ws/xlib module. Why isn't it * being defined in that directory? diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index b8647d71c6..568bc6e962 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -63,7 +63,7 @@ #include "pipe/p_screen.h" #include "pipe/p_context.h" -#include "xm_winsys.h" +#include "xm_public.h" #include diff --git a/src/gallium/state_trackers/glx/xlib/xm_public.h b/src/gallium/state_trackers/glx/xlib/xm_public.h new file mode 100644 index 0000000000..ac6a8ffb27 --- /dev/null +++ b/src/gallium/state_trackers/glx/xlib/xm_public.h @@ -0,0 +1,44 @@ + +/************************************************************************** + * + * Copyright 2006 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 XM_WINSYS_H +#define XM_WINSYS_H + +struct xm_driver; + +/* This is the driver interface required by the glx/xlib state tracker. + */ +struct xm_driver { + struct pipe_screen *(*create_pipe_screen)( Display *display ); +}; + +extern void +xmesa_set_driver( const struct xm_driver *driver ); + + +#endif diff --git a/src/gallium/state_trackers/glx/xlib/xm_winsys.h b/src/gallium/state_trackers/glx/xlib/xm_winsys.h deleted file mode 100644 index 648f1c90ef..0000000000 --- a/src/gallium/state_trackers/glx/xlib/xm_winsys.h +++ /dev/null @@ -1,42 +0,0 @@ - -/************************************************************************** - * - * Copyright 2006 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 XM_WINSYS_H -#define XM_WINSYS_H - -struct pipe_context; -struct pipe_screen; -struct pipe_surface; -struct xlib_drawable; - - -extern void -xmesa_set_driver( const struct xm_driver *driver ); - - -#endif diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 7881bc2cb1..54764440e7 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -30,81 +30,19 @@ * Authors: * Keith Whitwell */ - -#include "state_tracker/xlib_sw_winsys.h" -#include "xm_winsys.h" -#include "util/u_debug.h" -#include "softpipe/sp_public.h" -#include "llvmpipe/lp_public.h" -#include "identity/id_public.h" -#include "trace/tr_public.h" -#include "cell/ppu/cell_public.h" - +#include "pipe/p_compiler.h" +#include "target-helpers/swrast_xlib.h" +#include "xm_public.h" /* advertise OpenGL support */ PUBLIC const int st_api_OpenGL = 1; - -static struct pipe_screen * -create_screen( struct sw_winsys *winsys ) -{ -#if defined(GALLIUM_CELL) - if (!debug_get_bool_option("GALLIUM_NOCELL", FALSE)) - return cell_create_screen( winsys ); -#endif - -#if defined(GALLIUM_LLVMPIPE) - return llvmpipe_create_screen( winsys ); -#endif - - return softpipe_create_screen( winsys ); -} - - - -static struct pipe_screen * -xlib_create_screen( Display *display ) -{ - struct sw_winsys *winsys; - struct pipe_screen *screen; - - winsys = xlib_create_sw_winsys( display ); - if (winsys == NULL) - return NULL; - - screen = create_screen(winsys); - if (screen == NULL) - goto fail; - - /* Finally we have somewhere to inject layers into the stack in a - * clean fashion: - */ - if (debug_get_bool_option("GALLIUM_WRAP", FALSE)) { - screen = identity_screen_create(screen); - } - - if (debug_get_bool_option("GALLIUM_TRACE", FALSE)) { - screen = trace_screen_create( screen ); - } - - return screen; - -fail: - if (winsys) - winsys->destroy( winsys ); - - return NULL; -} - - struct xm_driver xlib_driver = { - .create_pipe_screen = xlib_create_screen, + .create_pipe_screen = swrast_xlib_create_screen, }; - - /* Build the rendering stack. */ static void _init( void ) __attribute__((constructor)); diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c index 74501eeb16..063e9f600b 100644 --- a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c +++ b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c @@ -38,7 +38,7 @@ #include "pipe/p_error.h" #include "pipe/p_context.h" -#include "xm_winsys.h" +#include "xm_public.h" #include "i965/brw_winsys.h" #include "i965/brw_screen.h" -- cgit v1.2.3