st/egl: Add egl-gdi target.
authorChia-I Wu <olv@lunarg.com>
Wed, 30 Jun 2010 05:15:18 +0000 (13:15 +0800)
committerChia-I Wu <olv@lunarg.com>
Wed, 30 Jun 2010 06:00:43 +0000 (14:00 +0800)
The target supports OpenVG on Windows with software rasterizer.  The
egl_g3d_loader defined by the target supports arbitrary client APIs and
window systems.  It is the SConscript that limits the support to OpenVG
and GDI.

This commit also fixes a typo in gdi backend.

src/gallium/state_trackers/egl/gdi/native_gdi.c
src/gallium/targets/SConscript
src/gallium/targets/egl-gdi/SConscript [new file with mode: 0644]
src/gallium/targets/egl-gdi/egl-static.c [new file with mode: 0644]
src/gallium/targets/egl/SConscript [deleted file]

index 06e3edfc391c6a95647aa2f84dcd04478dc593f2..91701e5b7df2675ea2d2d70607b9e276acf8a3f8 100644 (file)
@@ -363,7 +363,7 @@ gdi_create_display(HDC hDC, struct native_event_handler *event_handler,
       return NULL;
    }
 
-   gdpy->base.screen = gdpy->event_handler->create_sw_screen(winsys);
+   gdpy->base.screen = gdpy->event_handler->new_sw_screen(&gdpy->base, winsys);
    if (!gdpy->base.screen) {
       if (winsys->destroy)
          winsys->destroy(winsys);
index 97187030abc2c5195ecb09d181b49462c416f431..f8276b155587a1621a71d0d6011c93c49affc245 100644 (file)
@@ -32,8 +32,7 @@ if 'xorg' in env['statetrackers']:
 
 if 'egl' in env['statetrackers']:
        SConscript([
-               'egl-swrast/SConscript',
-               'egl-apis/SConscript',
+               'egl-gdi/SConscript',
        ])
 
 # Ideally all non-target directories would produce convenience
diff --git a/src/gallium/targets/egl-gdi/SConscript b/src/gallium/targets/egl-gdi/SConscript
new file mode 100644 (file)
index 0000000..8f8b28e
--- /dev/null
@@ -0,0 +1,47 @@
+#######################################################################
+# SConscript for egl-gdi target
+
+Import('*')
+
+if env['platform'] == 'windows':
+
+    env = env.Clone()
+
+    env.Append(CPPPATH = [
+            '#/src/gallium/state_trackers/egl',
+            '#/src/gallium/state_trackers/vega',
+            '#/src/egl/main',
+            '#/src/mesa',
+    ])
+
+    env.Append(CPPDEFINES = [
+            'FEATURE_VG=1',
+            'GALLIUM_SOFTPIPE',
+            'GALLIUM_RBUG',
+            'GALLIUM_TRACE',
+    ])
+
+    env.Append(LIBS = [
+        'gdi32',
+        'user32',
+        'kernel32',
+        'ws2_32',
+    ])
+
+    env['no_import_lib'] = 1
+
+    drivers = [softpipe]
+    if env['llvm']:
+        env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+        drivers += [llvmpipe]
+    drivers += [identity, trace, rbug]
+
+    apis = [vgapi, st_vega]
+
+    egl_gallium = env.SharedLibrary(
+        target ='egl_gallium',
+        source = 'egl-static.c',
+        LIBS = st_egl_gdi + ws_gdi + drivers + apis + gallium + egl + env['LIBS'],
+    )
+
+    env.InstallSharedLibrary(egl_gallium)
diff --git a/src/gallium/targets/egl-gdi/egl-static.c b/src/gallium/targets/egl-gdi/egl-static.c
new file mode 100644 (file)
index 0000000..ec2f865
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.9
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * 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, sublicense,
+ * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ *    Chia-I Wu <olv@lunarg.com>
+ */
+
+#include "common/egl_g3d_loader.h"
+#include "state_tracker/st_gl_api.h"
+#include "vg_api.h"
+#include "target-helpers/inline_sw_helper.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "egldriver.h"
+
+static uint
+get_api_mask(void)
+{
+   uint api_mask = 0x0;
+
+#if FEATURE_GL
+   api_mask |= 1 << ST_API_OPENGL;
+#endif
+#if FEATURE_ES1
+   api_mask |= 1 << ST_API_OPENGL_ES1;
+#endif
+#if FEATURE_ES2
+   api_mask |= 1 << ST_API_OPENGL_ES2;
+#endif
+#if FEATURE_VG
+   api_mask |= 1 << ST_API_OPENVG;
+#endif
+
+   return api_mask;
+}
+
+static struct st_api *
+get_st_api(enum st_api_type api)
+{
+   struct st_api *stapi = NULL;
+
+   switch (api) {
+#if FEATURE_GL
+      case ST_API_OPENGL:
+         stapi = st_gl_api_create();
+         break;
+#endif
+#if FEATURE_ES1
+      case ST_API_OPENGL_ES1:
+         stapi = st_gl_api_create_es1();
+         break;
+#endif
+#if FEATURE_ES2
+      case ST_API_OPENGL_ES2:
+         stapi = st_gl_api_create_es2();
+         break;
+#endif
+#if FEATURE_VG
+      case ST_API_OPENVG:
+         stapi = (struct st_api *) vg_api_get();
+         break;
+#endif
+      default:
+         break;
+   }
+
+   return stapi;
+}
+
+static struct st_api *
+guess_gl_api(void)
+{
+   return NULL;
+}
+
+static struct pipe_screen *
+create_drm_screen(const char *name, int fd)
+{
+   return NULL;
+}
+
+static struct pipe_screen *
+create_sw_screen(struct sw_winsys *ws)
+{
+   struct pipe_screen *screen;
+
+   screen = sw_screen_create(ws);
+   if (screen)
+      screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+static void
+init_loader(struct egl_g3d_loader *loader)
+{
+   if (loader->api_mask)
+      return;
+
+   loader->api_mask = get_api_mask();
+   loader->get_st_api = get_st_api;
+   loader->guess_gl_api = guess_gl_api;
+   loader->create_drm_screen = create_drm_screen;
+   loader->create_sw_screen = create_sw_screen;
+}
+
+static void
+egl_g3d_unload(_EGLDriver *drv)
+{
+   egl_g3d_destroy_driver(drv);
+}
+
+static struct egl_g3d_loader loader;
+
+_EGLDriver *
+_eglMain(const char *args)
+{
+   _EGLDriver *drv;
+
+   init_loader(&loader);
+   drv = egl_g3d_create_driver(&loader);
+   if (drv) {
+      drv->Name = "Gallium";
+      drv->Unload = egl_g3d_unload;
+   }
+
+   return drv;
+}
diff --git a/src/gallium/targets/egl/SConscript b/src/gallium/targets/egl/SConscript
deleted file mode 100644 (file)
index 1643867..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#######################################################################
-# SConscript for egl-apis target
-
-Import('*')
-
-if env['platform'] == 'windows':
-
-    env = env.Clone()
-
-    env.Append(CPPPATH = [
-            '#/src/gallium/state_trackers/vega',
-    ])
-
-    env.Append(LIBS = [
-        'gdi32',
-        'user32',
-        'kernel32',
-        'ws2_32',
-    ])
-
-    env['no_import_lib'] = 1
-
-    drivers = [softpipe]
-    if env['llvm']:
-        drivers += [llvmpipe]
-    drivers += [identity, trace, rbug]
-
-    egl_gallium = env.SharedLibrary(
-        target ='egl_gallium',
-       source = ['egl.c', 'pipe_swrast.c'],
-        LIBS = st_egl_gdi + ws_gdi + drivers + gallium + egl + env['LIBS'],
-    )
-
-    env.InstallSharedLibrary(egl_gallium)
-
-    api_libs = {
-        'OpenVG': vgapi + st_vega,
-    }
-
-    for name in api_libs.keys():
-        api = env.SharedLibrary(
-            target = 'st_' + name,
-            source = ['st_' + name + '.c'],
-            LIBS = api_libs[name] + gallium + env['LIBS'],
-        )
-        env.InstallSharedLibrary(api)