python: Fix up state tracker for sw api.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 10 Mar 2010 10:34:29 +0000 (10:34 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 10 Mar 2010 10:34:29 +0000 (10:34 +0000)
SConstruct
src/gallium/state_trackers/python/SConscript
src/gallium/state_trackers/python/st_device.c
src/gallium/state_trackers/python/st_device.h
src/gallium/state_trackers/python/st_hardpipe_winsys.c
src/gallium/state_trackers/python/st_llvmpipe_winsys.c [deleted file]
src/gallium/state_trackers/python/st_softpipe_winsys.c
src/gallium/state_trackers/python/st_winsys.h

index 5e171ea2e16d8b9e2abee07f7dd79041f457f284..606be015c06307250932162788f69a2281cf757f 100644 (file)
@@ -124,6 +124,7 @@ env.Append(CPPPATH = [
        '#/src/gallium/include',
        '#/src/gallium/auxiliary',
        '#/src/gallium/drivers',
+       '#/src/gallium/winsys',
 ])
 
 if env['msvc']:
index 527e065cd9181cb7589ff85bf0b4187f416fbde6..8010f122b73e4d72bb068b81a540268fec86e3b0 100644 (file)
@@ -33,31 +33,26 @@ if 'python' in env['statetrackers']:
         'gallium.i',
         'st_device.c',
         'st_sample.c',
+        'st_hardpipe_winsys.c',
+        'st_softpipe_winsys.c',
     ]
 
-    drivers = [
-        trace
-    ]
+    env.Prepend(LIBS = [
+        trace,
+        gallium
+    ])
 
     if 'llvmpipe' in env['drivers']:
+        env.Append(CPPDEFINES = ['HAVE_LLVMPIPE'])
         env.Tool('llvm')
-        sources += ['st_llvmpipe_winsys.c']
-        drivers += [llvmpipe]
-    else:
-        sources += ['st_softpipe_winsys.c']
-        drivers += [softpipe]
-
-    pyst = env.ConvenienceLibrary(
-        target = 'pyst',
-        source = sources,
-    )
+        env.Prepend(LIBS = [llvmpipe])
+    if 'softpipe' in env['drivers']:
+        env.Append(CPPDEFINES = ['HAVE_SOFTPIPE'])
+        env.Prepend(LIBS = [softpipe])
 
     env['no_import_lib'] = 1
 
     env.SharedLibrary(
         target = '_gallium',
-        source = [
-            'st_hardpipe_winsys.c',
-        ],
-        LIBS = [pyst] + drivers + gallium + env['LIBS'],
+        source = sources,
     )
index 45e78417500e505b34625674da5d0f9a78cc5867..335e8e7f0d854c1d6dc7b8a3443c47d0d6b29ad5 100644 (file)
@@ -34,8 +34,7 @@
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_simple_shaders.h"
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
+#include "trace/tr_public.h"
 
 #include "st_device.h"
 #include "st_winsys.h"
@@ -75,43 +74,34 @@ st_device_destroy(struct st_device *st_dev)
 }
 
 
-static struct st_device *
-st_device_create_from_st_winsys(const struct st_winsys *st_ws) 
+struct st_device *
+st_device_create(boolean hardware)
 {
+   struct pipe_screen *screen;
    struct st_device *st_dev;
-   
-   if(!st_ws->screen_create)
-      return NULL;
-   
+
+   if (hardware)
+      screen = st_hardware_screen_create();
+   else
+      screen = st_software_screen_create();
+
+   screen = trace_screen_create(screen);
+   if (!screen)
+      goto no_screen;
+
    st_dev = CALLOC_STRUCT(st_device);
-   if(!st_dev)
-      return NULL;
+   if (!st_dev)
+      goto no_device;
    
    pipe_reference_init(&st_dev->reference, 1);
-   st_dev->st_ws = st_ws;
-   
-   st_dev->real_screen = st_ws->screen_create();
-   if(!st_dev->real_screen) {
-      st_device_destroy(st_dev);
-      return NULL;
-   }
-
-   st_dev->screen = trace_screen_create(st_dev->real_screen);
-   if(!st_dev->screen) {
-      st_device_destroy(st_dev);
-      return NULL;
-   }
+   st_dev->screen = screen;
    
    return st_dev;
-}
-
 
-struct st_device *
-st_device_create(boolean hardware) {
-   if(hardware)
-      return st_device_create_from_st_winsys(&st_hardpipe_winsys);
-   else
-      return st_device_create_from_st_winsys(&st_softpipe_winsys);
+no_device:
+   screen->destroy(screen);
+no_screen:
+   return NULL;
 }
 
 
index de9e0215d8e881ae66b24400818333d239db5b36..6ec7409b11d48ec338ff649feb40e303eec3b733 100644 (file)
@@ -47,7 +47,8 @@ struct st_surface
 };
 
 
-struct st_context {
+struct st_context
+{
    struct st_device *st_dev;
    
    struct pipe_context *pipe;
@@ -72,13 +73,11 @@ struct st_context {
 };
 
 
-struct st_device {
+struct st_device
+{
    /* FIXME: we also need to refcount for textures and surfaces... */
    struct pipe_reference reference;
 
-   const struct st_winsys *st_ws; 
-
-   struct pipe_screen *real_screen;
    struct pipe_screen *screen;
 };
 
index a3110a19d5d996fa2b9ca6ded44ae72fa17819a7..0bf7c51613ce797672ba82a2098f13ddfecff240 100644 (file)
@@ -207,16 +207,11 @@ st_hardpipe_load(void)
 #endif
 
 
-static struct pipe_screen *
-st_hardpipe_screen_create(void)
+struct pipe_screen *
+st_hardware_screen_create(void)
 {
    if(st_hardpipe_load())
       return pfnGetGalliumScreenMESA();
    else
-      return st_softpipe_winsys.screen_create();
+      return st_software_screen_create();
 }
-
-
-const struct st_winsys st_hardpipe_winsys = {
-   &st_hardpipe_screen_create
-};
diff --git a/src/gallium/state_trackers/python/st_llvmpipe_winsys.c b/src/gallium/state_trackers/python/st_llvmpipe_winsys.c
deleted file mode 100644 (file)
index 5d83b5a..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2010 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 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.
- * 
- * 
- **************************************************************************/
-
-/**
- * @file
- * Llvmpipe support. 
- * 
- * @author Jose Fonseca
- */
-
-
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "util/u_inlines.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "llvmpipe/lp_winsys.h"
-#include "st_winsys.h"
-
-
-static boolean
-llvmpipe_ws_is_displaytarget_format_supported( struct llvmpipe_winsys *ws,
-      enum pipe_format format )
-{
-   return FALSE;
-}
-
-
-static void *
-llvmpipe_ws_displaytarget_map(struct llvmpipe_winsys *ws,
-                              struct llvmpipe_displaytarget *dt,
-                              unsigned flags )
-{
-   assert(0);
-   return NULL;
-}
-
-
-static void
-llvmpipe_ws_displaytarget_unmap(struct llvmpipe_winsys *ws,
-                                struct llvmpipe_displaytarget *dt )
-{
-   assert(0);
-}
-
-
-static void
-llvmpipe_ws_displaytarget_destroy(struct llvmpipe_winsys *winsys,
-                                  struct llvmpipe_displaytarget *dt)
-{
-   assert(0);
-}
-
-
-static struct llvmpipe_displaytarget *
-llvmpipe_ws_displaytarget_create(struct llvmpipe_winsys *winsys,
-                                 enum pipe_format format,
-                                 unsigned width, unsigned height,
-                                 unsigned alignment,
-                                 unsigned *stride)
-{
-   return NULL;
-}
-
-
-static void
-llvmpipe_ws_displaytarget_display(struct llvmpipe_winsys *winsys,
-                                  struct llvmpipe_displaytarget *dt,
-                                  void *context_private)
-{
-   assert(0);
-}
-
-
-static void
-llvmpipe_ws_destroy(struct llvmpipe_winsys *winsys)
-{
-   FREE(winsys);
-}
-
-
-static struct pipe_screen *
-st_llvmpipe_screen_create(void)
-{
-   static struct llvmpipe_winsys *winsys;
-   struct pipe_screen *screen;
-
-   winsys = CALLOC_STRUCT(llvmpipe_winsys);
-   if (!winsys)
-      goto no_winsys;
-
-   winsys->destroy = llvmpipe_ws_destroy;
-   winsys->is_displaytarget_format_supported = llvmpipe_ws_is_displaytarget_format_supported;
-   winsys->displaytarget_create = llvmpipe_ws_displaytarget_create;
-   winsys->displaytarget_map = llvmpipe_ws_displaytarget_map;
-   winsys->displaytarget_unmap = llvmpipe_ws_displaytarget_unmap;
-   winsys->displaytarget_display = llvmpipe_ws_displaytarget_display;
-   winsys->displaytarget_destroy = llvmpipe_ws_displaytarget_destroy;
-
-   screen = llvmpipe_create_screen(winsys);
-   if (!screen)
-      goto no_screen;
-
-   return screen;
-
-no_screen:
-   FREE(winsys);
-no_winsys:
-   return NULL;
-}
-
-
-
-const struct st_winsys st_softpipe_winsys = {
-   &st_llvmpipe_screen_create
-};
index 81676bc3a4fdde1cf12cc3966a81edbd0d42936f..cd3e786f1a64f2bb0d6669e0934440d4d3929718 100644 (file)
  * 
  **************************************************************************/
 
-/**
- * @file
- * Softpipe support. 
- * 
- * @author Keith Whitwell
- * @author Brian Paul
- * @author Jose Fonseca
- */
-
-#include "softpipe/sp_winsys.h"
+#include "util/u_debug.h"
+#include "softpipe/sp_public.h"
+#include "llvmpipe/lp_public.h"
+#include "state_tracker/sw_winsys.h"
+#include "null/null_sw_winsys.h"
 #include "st_winsys.h"
 
-const struct st_winsys st_softpipe_winsys = {
-   &softpipe_create_screen_malloc
-};
+
+struct pipe_screen *
+st_software_screen_create(void)
+{
+   struct sw_winsys *ws;
+   const char *default_driver;
+   const char *driver;
+   struct pipe_screen *screen = NULL;
+
+#if defined(HAVE_LLVMPIPE)
+   default_driver = "llvmpipe";
+#elif defined(HAVE_SOFTPIPE)
+   default_driver = "softpipe";
+#endif
+
+   ws = null_sw_create();
+   if(!ws)
+      return NULL;
+
+   driver = debug_get_option("GALLIUM_DRIVER", default_driver);
+
+#ifdef HAVE_LLVMPIPE
+   if (strcmp(driver, "llvmpipe") == 0) {
+      screen = llvmpipe_create_screen(ws);
+   }
+#endif
+
+#ifdef HAVE_SOFTPIPE
+   if (strcmp(driver, "softpipe") == 0) {
+      screen = softpipe_create_screen(ws);
+   }
+#endif
+
+   return screen;
+}
index 0c7b6a200e118264b89b37537e2a59f86bb5fdf7..e1a99383a4135907814bf41e8aec384d66c1136d 100644 (file)
 
 
 struct pipe_screen;
-struct pipe_context;
 
 
-struct st_winsys 
-{
-   struct pipe_screen *
-   (*screen_create)(void);
-};
+struct pipe_screen *
+st_hardware_screen_create(void);
 
-
-extern const struct st_winsys st_softpipe_winsys;
-
-extern const struct st_winsys st_hardpipe_winsys;
+struct pipe_screen *
+st_software_screen_create(void);
 
 
 #endif /* ST_WINSYS_H_ */