summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/sw
diff options
context:
space:
mode:
authorGeorge Sapountzis <[email protected]>2010-03-25 17:01:54 +0200
committerGeorge Sapountzis <[email protected]>2010-03-25 17:01:54 +0200
commit007e0e3ef90d73f232c463e353da13378ffcef63 (patch)
tree8907227ce2383c5a16b2099d6d820b7b5e9271a3 /src/gallium/winsys/sw
parent992e9572bdbc1f3d5243ca8eecbd6a372721a62b (diff)
swrastg_dri: add winsys and target
Diffstat (limited to 'src/gallium/winsys/sw')
-rw-r--r--src/gallium/winsys/sw/dri/Makefile13
-rw-r--r--src/gallium/winsys/sw/dri/dri_sw_winsys.c197
-rw-r--r--src/gallium/winsys/sw/dri/dri_sw_winsys.h36
3 files changed, 246 insertions, 0 deletions
diff --git a/src/gallium/winsys/sw/dri/Makefile b/src/gallium/winsys/sw/dri/Makefile
new file mode 100644
index 00000000000..a3fca6be885
--- /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 00000000000..abf92b86b04
--- /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 <[email protected]>
+ *
+ * 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 00000000000..c2382a68d78
--- /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 <[email protected]>
+ *
+ * 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