diff options
author | George Sapountzis <gsapountzis@gmail.com> | 2010-03-25 17:01:54 +0200 |
---|---|---|
committer | George Sapountzis <gsapountzis@gmail.com> | 2010-03-25 17:01:54 +0200 |
commit | 007e0e3ef90d73f232c463e353da13378ffcef63 (patch) | |
tree | 8907227ce2383c5a16b2099d6d820b7b5e9271a3 /src/gallium | |
parent | 992e9572bdbc1f3d5243ca8eecbd6a372721a62b (diff) |
swrastg_dri: add winsys and target
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/targets/dri-swrast/Makefile | 30 | ||||
-rw-r--r-- | src/gallium/targets/dri-swrast/swrast_drm_api.c | 93 | ||||
-rw-r--r-- | src/gallium/winsys/sw/dri/Makefile | 13 | ||||
-rw-r--r-- | src/gallium/winsys/sw/dri/dri_sw_winsys.c | 197 | ||||
-rw-r--r-- | src/gallium/winsys/sw/dri/dri_sw_winsys.h | 36 |
5 files changed, 369 insertions, 0 deletions
diff --git a/src/gallium/targets/dri-swrast/Makefile b/src/gallium/targets/dri-swrast/Makefile new file mode 100644 index 0000000000..57a9e02a4b --- /dev/null +++ b/src/gallium/targets/dri-swrast/Makefile @@ -0,0 +1,30 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = swrastg_dri.so + +DRIVER_DEFINES = -D__NOT_HAVE_DRM_H + +PIPE_DRIVERS = \ + $(TOP)/src/gallium/state_trackers/drisw/libdrisw.a \ + $(TOP)/src/gallium/winsys/sw/dri/libswdri.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +SWRAST_COMMON_GALLIUM_SOURCES = \ + $(TOP)/src/mesa/drivers/dri/common/utils.c \ + $(TOP)/src/mesa/drivers/dri/common/drisw_util.c \ + $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c + +C_SOURCES = \ + swrast_drm_api.c \ + $(SWRAST_COMMON_GALLIUM_SOURCES) \ + $(DRIVER_SOURCES) + +ASM_SOURCES = + +include ../Makefile.dri + +INCLUDES += \ + -I$(TOP)/src/gallium/winsys/sw/dri + +symlinks: diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c new file mode 100644 index 0000000000..211836d784 --- /dev/null +++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c @@ -0,0 +1,93 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright 2010 George Sapountzis <gsapountzis@gmail.com> + * + * 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 "pipe/p_compiler.h" +#include "util/u_memory.h" + +#include "softpipe/sp_public.h" +#include "state_tracker/drm_api.h" +#include "state_tracker/sw_winsys.h" +#include "dri_sw_winsys.h" + +static struct pipe_screen * +swrast_create_screen(struct drm_api *api, + int drmFD, + struct drm_create_screen_arg *arg) +{ + struct sw_winsys *winsys = NULL; + struct pipe_screen *screen = NULL; + + (void) drmFD; + + if (arg != NULL) { + switch(arg->mode) { + case DRM_CREATE_DRISW: + break; + default: + return NULL; + } + } + + winsys = dri_create_sw_winsys(); + if (winsys == NULL) + return NULL; + + screen = softpipe_create_screen( winsys ); + if (screen == NULL) + goto fail; + + return screen; + +fail: + if (winsys) + winsys->destroy( winsys ); + + return NULL; +} + +static void +swrast_drm_api_destroy(struct drm_api *api) +{ + return; +} + +static struct drm_api swrast_drm_api = +{ + .name = "swrast", + .driver_name = "swrast", + .create_screen = swrast_create_screen, + .destroy = swrast_drm_api_destroy, +}; + +struct drm_api * +drm_api_create() +{ + return &swrast_drm_api; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/winsys/sw/dri/Makefile b/src/gallium/winsys/sw/dri/Makefile new file mode 100644 index 0000000000..a3fca6be88 --- /dev/null +++ b/src/gallium/winsys/sw/dri/Makefile @@ -0,0 +1,13 @@ +TOP = ../../../../.. +include $(TOP)/configs/current + +LIBNAME = swdri + +LIBRARY_INCLUDES = + +LIBRARY_DEFINES = + +C_SOURCES = \ + dri_sw_winsys.c + +include ../../../Makefile.template diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c new file mode 100644 index 0000000000..abf92b86b0 --- /dev/null +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -0,0 +1,197 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright 2010 George Sapountzis <gsapountzis@gmail.com> + * + * 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 "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" + +#include "state_tracker/sw_winsys.h" +#include "dri_sw_winsys.h" + + +struct xm_displaytarget +{ + void *data; + void *mapped; +}; + + +/** Cast wrapper */ +static INLINE struct xm_displaytarget * +xm_displaytarget( struct sw_displaytarget *dt ) +{ + return (struct xm_displaytarget *)dt; +} + + +/* pipe_screen::is_format_supported */ +static boolean +xm_is_displaytarget_format_supported( struct sw_winsys *ws, + unsigned tex_usage, + enum pipe_format format ) +{ + /* TODO: check visuals or other sensible thing here */ + return TRUE; +} + +/* pipe_screen::texture_create DISPLAY_TARGET / SCANOUT / SHARED */ +static struct sw_displaytarget * +xm_displaytarget_create(struct sw_winsys *winsys, + unsigned tex_usage, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride) +{ + struct xm_displaytarget *xm_dt; + unsigned nblocksy, size, xm_stride; + + xm_dt = CALLOC_STRUCT(xm_displaytarget); + if(!xm_dt) + goto no_xm_dt; + + nblocksy = util_format_get_nblocksy(format, height); + xm_stride = align(util_format_get_stride(format, width), alignment); + size = xm_stride * nblocksy; + + xm_dt->data = align_malloc(size, alignment); + if(!xm_dt->data) + goto no_data; + + *stride = xm_stride; + return (struct sw_displaytarget *)xm_dt; + +no_data: + FREE(xm_dt); +no_xm_dt: + return NULL; +} + +/* pipe_screen::texture_destroy */ +static void +xm_displaytarget_destroy(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + + if (xm_dt->data) { + FREE(xm_dt->data); + } + + FREE(xm_dt); +} + +/* pipe_context::transfer_map */ +static void * +xm_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags) +{ + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + xm_dt->mapped = xm_dt->data; + return xm_dt->mapped; +} + +/* pipe_context::transfer_unmap */ +static void +xm_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + xm_dt->mapped = NULL; +} + +/* pipe_screen::texture_from_handle */ +static struct sw_displaytarget * +xm_displaytarget_from_handle(struct sw_winsys *winsys, + const struct pipe_texture *templ, + struct winsys_handle *whandle, + unsigned *stride) +{ + assert(0); + return NULL; +} + +/* pipe_screen::texture_get_handle */ +static boolean +xm_displaytarget_get_handle(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + struct winsys_handle *whandle) +{ + assert(0); + return FALSE; +} + +/* pipe_screen::flush_frontbuffer */ +static void +xm_displaytarget_display(struct sw_winsys *ws, + struct sw_displaytarget *dt, + void *context_private) +{ + assert(0); +} + + +static void +dri_destroy_sw_winsys(struct sw_winsys *winsys) +{ + FREE(winsys); +} + +struct sw_winsys * +dri_create_sw_winsys(void) +{ + struct sw_winsys *ws; + + ws = CALLOC_STRUCT(sw_winsys); + if (!ws) + return NULL; + + ws->destroy = dri_destroy_sw_winsys; + + ws->is_displaytarget_format_supported = xm_is_displaytarget_format_supported; + + /* screen texture functions */ + ws->displaytarget_create = xm_displaytarget_create; + ws->displaytarget_destroy = xm_displaytarget_destroy; + ws->displaytarget_from_handle = xm_displaytarget_from_handle; + ws->displaytarget_get_handle = xm_displaytarget_get_handle; + + /* texture functions */ + ws->displaytarget_map = xm_displaytarget_map; + ws->displaytarget_unmap = xm_displaytarget_unmap; + + ws->displaytarget_display = xm_displaytarget_display; + + return ws; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.h b/src/gallium/winsys/sw/dri/dri_sw_winsys.h new file mode 100644 index 0000000000..c2382a68d7 --- /dev/null +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.h @@ -0,0 +1,36 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright 2010 George Sapountzis <gsapountzis@gmail.com> + * + * 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 DRI_SW_WINSYS +#define DRI_SW_WINSYS + +struct sw_winsys; + +struct sw_winsys *dri_create_sw_winsys(void); + +#endif |