st/dri: Move DRI1 bits in dri_screen.c to dri1.c.
authorChia-I Wu <olv@lunarg.com>
Tue, 16 Mar 2010 01:47:18 +0000 (09:47 +0800)
committerChia-I Wu <olv@lunarg.com>
Thu, 18 Mar 2010 00:48:12 +0000 (08:48 +0800)
src/gallium/state_trackers/dri/Makefile
src/gallium/state_trackers/dri/SConscript
src/gallium/state_trackers/dri/dri1.c [new file with mode: 0644]
src/gallium/state_trackers/dri/dri1.h [new file with mode: 0644]
src/gallium/state_trackers/dri/dri_context.c
src/gallium/state_trackers/dri/dri_drawable.c
src/gallium/state_trackers/dri/dri_drawable.h
src/gallium/state_trackers/dri/dri_screen.c
src/gallium/state_trackers/dri/dri_screen.h

index ef8f19709ab242e497bb80210fd138e54c222362..24244417b97c3961067bf8f9687595ca541dd1ef 100644 (file)
@@ -15,7 +15,8 @@ C_SOURCES = \
        dri_context.c \
        dri_screen.c \
        dri_drawable.c \
-       dri_extensions.c
+       dri_extensions.c \
+       dri1.c
 
 #      $(TOP)/src/mesa/drivers/dri/common/utils.c \
        $(TOP)/src/mesa/drivers/dri/common/vblank.c \
index ce2c27359742db6e46872c9096a34cf24189ae00..6310fe06e4385e15f70958790cd62d07b49d8291 100644 (file)
@@ -18,6 +18,7 @@ if env['dri']:
                'dri_drawable.c',
                'dri_extensions.c',
                'dri_screen.c',
+               'dri1.c',
                ]
     )
     Export('st_dri')
diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c
new file mode 100644 (file)
index 0000000..1222f42
--- /dev/null
@@ -0,0 +1,117 @@
+/**************************************************************************
+ *
+ * Copyright 2009, 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 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.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "util/u_memory.h"
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+#include "dri1.h"
+
+static const __DRIextension *dri1_screen_extensions[] = {
+   &driReadDrawableExtension,
+   &driCopySubBufferExtension.base,
+   &driSwapControlExtension.base,
+   &driFrameTrackingExtension.base,
+   &driMediaStreamCounterExtension.base,
+   NULL
+};
+
+struct dri1_api *__dri1_api_hooks = NULL;
+
+static INLINE void
+dri1_copy_version(struct dri1_api_version *dst,
+                 const struct __DRIversionRec *src)
+{
+   dst->major = src->major;
+   dst->minor = src->minor;
+   dst->patch_level = src->patch;
+}
+
+const __DRIconfig **
+dri1_init_screen(__DRIscreen * sPriv)
+{
+   struct dri_screen *screen;
+   const __DRIconfig **configs;
+   struct dri1_create_screen_arg arg;
+
+   screen = CALLOC_STRUCT(dri_screen);
+   if (!screen)
+      return NULL;
+
+   screen->api = drm_api_create();
+   screen->sPriv = sPriv;
+   screen->fd = sPriv->fd;
+   screen->drmLock = (drmLock *) & sPriv->pSAREA->lock;
+
+   sPriv->private = (void *)screen;
+   sPriv->extensions = dri1_screen_extensions;
+
+   arg.base.mode = DRM_CREATE_DRI1;
+   arg.lf = &dri1_lf;
+   arg.ddx_info = sPriv->pDevPriv;
+   arg.ddx_info_size = sPriv->devPrivSize;
+   arg.sarea = sPriv->pSAREA;
+   dri1_copy_version(&arg.ddx_version, &sPriv->ddx_version);
+   dri1_copy_version(&arg.dri_version, &sPriv->dri_version);
+   dri1_copy_version(&arg.drm_version, &sPriv->drm_version);
+   arg.api = NULL;
+
+   screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg.base);
+
+   if (!screen->pipe_screen || !arg.api) {
+      debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__);
+      goto out_no_screen;
+   }
+
+   __dri1_api_hooks = arg.api;
+
+   screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer;
+   driParseOptionInfo(&screen->optionCache,
+                     __driConfigOptions, __driNConfigOptions);
+
+   /**
+    * FIXME: If the driver supports format conversion swapbuffer blits, we might
+    * want to support other color bit depths than the server is currently
+    * using.
+    */
+
+   configs = dri_fill_in_modes(screen, sPriv->fbBPP);
+   if (!configs)
+      goto out_no_configs;
+
+   return configs;
+ out_no_configs:
+   screen->pipe_screen->destroy(screen->pipe_screen);
+ out_no_screen:
+   FREE(screen);
+   return NULL;
+}
diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h
new file mode 100644 (file)
index 0000000..731b13c
--- /dev/null
@@ -0,0 +1,43 @@
+/**************************************************************************
+ *
+ * Copyright 2009, 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 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.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#ifndef DRI1_H
+#define DRI1_H
+
+#include "state_tracker/dri1_api.h"
+#include "dri_util.h"
+
+extern struct dri1_api *__dri1_api_hooks;
+
+const __DRIconfig **
+dri1_init_screen(__DRIscreen * sPriv);
+
+#endif /* DRI1_H */
index f772ba5d16b921fd34382defa07cde35190940b9..a5ed0006dc9ea4829edabf9da1ad50f477a1ea4b 100644 (file)
@@ -38,6 +38,7 @@
 #include "pipe/p_context.h"
 
 #include "dri_context.h"
+#include "dri1.h"
 
 #include "util/u_memory.h"
 
index c400725c7f2dc9fc575dc2e1b7babcec86074b18..83b1a29681bf3d52420af05cea92bb7685c373a5 100644 (file)
@@ -32,6 +32,7 @@
 #include "dri_screen.h"
 #include "dri_context.h"
 #include "dri_drawable.h"
+#include "dri1.h"
 
 #include "pipe/p_context.h"
 #include "pipe/p_screen.h"
index 8bc59cb4c3d20bd05be9570c26b4cc7d71d102d6..80bd2f5bdf0b6716eb2a2fb8a0a4f96785439091 100644 (file)
@@ -29,6 +29,7 @@
 #define DRI_DRAWABLE_H
 
 #include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
 
 struct pipe_surface;
 struct pipe_fence_handle;
index 7ccad8f5dd6c52468c057e0075048c0e558f3135..8a586d637fc90784ecffb4d50269235803801dab 100644 (file)
@@ -36,6 +36,7 @@
 #include "dri_screen.h"
 #include "dri_context.h"
 #include "dri_drawable.h"
+#include "dri1.h"
 
 #include "pipe/p_screen.h"
 #include "pipe/p_format.h"
@@ -53,7 +54,7 @@ PUBLIC const char __driConfigOptions[] =
    DRI_CONF_ALLOW_LARGE_TEXTURES(1)
    DRI_CONF_SECTION_END DRI_CONF_END;
 
-   const uint __driNConfigOptions = 3;
+const uint __driNConfigOptions = 3;
 
 static const __DRItexBufferExtension dri2TexBufferExtension = {
     { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
@@ -83,9 +84,7 @@ static const __DRI2flushExtension dri2FlushExtension = {
       NULL
    };
 
-struct dri1_api *__dri1_api_hooks = NULL;
-
-static const __DRIconfig **
+const __DRIconfig **
 dri_fill_in_modes(struct dri_screen *screen,
                  unsigned pixel_bits)
 {
@@ -240,75 +239,6 @@ dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo)
       return 0;
 }
 
-static INLINE void
-dri_copy_version(struct dri1_api_version *dst,
-                const struct __DRIversionRec *src)
-{
-   dst->major = src->major;
-   dst->minor = src->minor;
-   dst->patch_level = src->patch;
-}
-
-static const __DRIconfig **
-dri_init_screen(__DRIscreen * sPriv)
-{
-   struct dri_screen *screen;
-   const __DRIconfig **configs;
-   struct dri1_create_screen_arg arg;
-
-   screen = CALLOC_STRUCT(dri_screen);
-   if (!screen)
-      return NULL;
-
-   screen->api = drm_api_create();
-   screen->sPriv = sPriv;
-   screen->fd = sPriv->fd;
-   screen->drmLock = (drmLock *) & sPriv->pSAREA->lock;
-
-   sPriv->private = (void *)screen;
-   sPriv->extensions = dri_screen_extensions;
-
-   arg.base.mode = DRM_CREATE_DRI1;
-   arg.lf = &dri1_lf;
-   arg.ddx_info = sPriv->pDevPriv;
-   arg.ddx_info_size = sPriv->devPrivSize;
-   arg.sarea = sPriv->pSAREA;
-   dri_copy_version(&arg.ddx_version, &sPriv->ddx_version);
-   dri_copy_version(&arg.dri_version, &sPriv->dri_version);
-   dri_copy_version(&arg.drm_version, &sPriv->drm_version);
-   arg.api = NULL;
-
-   screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg.base);
-
-   if (!screen->pipe_screen || !arg.api) {
-      debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__);
-      goto out_no_screen;
-   }
-
-   __dri1_api_hooks = arg.api;
-
-   screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer;
-   driParseOptionInfo(&screen->optionCache,
-                     __driConfigOptions, __driNConfigOptions);
-
-   /**
-    * FIXME: If the driver supports format conversion swapbuffer blits, we might
-    * want to support other color bit depths than the server is currently
-    * using.
-    */
-
-   configs = dri_fill_in_modes(screen, sPriv->fbBPP);
-   if (!configs)
-      goto out_no_configs;
-
-   return configs;
- out_no_configs:
-   screen->pipe_screen->destroy(screen->pipe_screen);
- out_no_screen:
-   FREE(screen);
-   return NULL;
-}
-
 /**
  * This is the driver specific part of the createNewScreen entry point.
  *
@@ -375,7 +305,6 @@ dri_destroy_screen(__DRIscreen * sPriv)
 }
 
 PUBLIC const struct __DriverAPIRec driDriverAPI = {
-   .InitScreen = dri_init_screen,
    .DestroyScreen = dri_destroy_screen,
    .CreateContext = dri_create_context,
    .DestroyContext = dri_destroy_context,
@@ -388,7 +317,7 @@ PUBLIC const struct __DriverAPIRec driDriverAPI = {
    .GetDrawableMSC = driDrawableGetMSC32,
    .WaitForMSC = driWaitForMSC32,
    .CopySubBuffer = dri_copy_sub_buffer,
-   .InitScreen = dri_init_screen,
+   .InitScreen = dri1_init_screen,
    .InitScreen2 = dri_init_screen2,
 };
 
index 75a0ee4250e89a7f6df1768272b8df4fb07d42f9..3130135692396265cdcb053eb76817752a1fff76 100644 (file)
@@ -37,8 +37,6 @@
 
 #include "pipe/p_compiler.h"
 
-#include "state_tracker/dri1_api.h"
-
 struct dri_screen
 {
    /* dri */
@@ -69,11 +67,10 @@ dri_screen(__DRIscreen * sPriv)
    return (struct dri_screen *)sPriv->private;
 }
 
-/***********************************************************************
- * dri_screen.c
- */
+extern const uint __driNConfigOptions;
 
-extern struct dri1_api *__dri1_api_hooks;
+const __DRIconfig **
+dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits);
 
 #endif