summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-02-10 22:59:47 +0000
committerMartin Jansa <Martin.Jansa@gmail.com>2010-02-18 15:39:21 +0100
commit013b2daf84322703a8270491a8eaa8697aaf643f (patch)
treeba9df9287c4a6dc5bf84f2a2ff81cb9bc36a5441 /src
parent260be54c67eb77b4da9550f70c14a6aa33c95768 (diff)
Context stuff
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/glamo/Makefile5
-rw-r--r--src/mesa/drivers/dri/glamo/glamo_context.c154
-rw-r--r--src/mesa/drivers/dri/glamo/glamo_context.h70
-rw-r--r--src/mesa/drivers/dri/glamo/glamo_screen.c (renamed from src/mesa/drivers/dri/glamo/glamo_dri.c)105
-rw-r--r--src/mesa/drivers/dri/glamo/glamo_screen.h40
5 files changed, 341 insertions, 33 deletions
diff --git a/src/mesa/drivers/dri/glamo/Makefile b/src/mesa/drivers/dri/glamo/Makefile
index 0ef3afcc51..e72577198a 100644
--- a/src/mesa/drivers/dri/glamo/Makefile
+++ b/src/mesa/drivers/dri/glamo/Makefile
@@ -6,13 +6,13 @@ include $(TOP)/configs/current
LIBNAME = glamo_dri.so
DRIVER_SOURCES = \
- glamo_dri.c
+ glamo_screen.c glamo_context.c
C_SOURCES = \
$(COMMON_SOURCES) \
$(DRIVER_SOURCES)
-ASM_SOURCES =
+ASM_SOURCES =
# XXX not 100% sure this is right
#WINDOW_SYSTEM = solo
@@ -20,4 +20,3 @@ ASM_SOURCES =
include ../Makefile.template
symlinks:
-
diff --git a/src/mesa/drivers/dri/glamo/glamo_context.c b/src/mesa/drivers/dri/glamo/glamo_context.c
new file mode 100644
index 0000000000..627f8f56a0
--- /dev/null
+++ b/src/mesa/drivers/dri/glamo/glamo_context.c
@@ -0,0 +1,154 @@
+/*
+ * Direct Rendering Support for SMedia Glamo 336x/337x
+ *
+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
+ * Roughly based on sis_context.c (c) 2003 Eric Anholt
+ *
+ * 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 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 "dri_util.h"
+#include "utils.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "drivers/common/driverfuncs.h"
+#include "vbo/vbo.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "glamo_context.h"
+#include "glamo_screen.h"
+
+
+GLboolean glamoCreateContext(const __GLcontextModes *glVisual,
+ __DRIcontext *driContextPriv,
+ void *sharedContextPrivate)
+{
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ glamoContextPtr context;
+ glamoScreenPtr glamoScreen;
+ struct dd_function_table functions;
+
+ context = (glamoContextPtr)CALLOC(sizeof(*context));
+ if ( context == NULL ) return GL_FALSE;
+
+ _mesa_init_driver_functions(&functions);
+
+ /* Allocate the Mesa context */
+ if ( sharedContextPrivate )
+ shareCtx = ((glamoContextPtr)sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ context->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *)context);
+ if ( context->glCtx == NULL ) {
+ FREE(context);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = context;
+ ctx = context->glCtx;
+
+ glamoScreen = context->glamoScreen = (glamoScreenPtr)sPriv->private;
+
+ context->driContext = driContextPriv;
+ context->driScreen = sPriv;
+ context->driDrawable = NULL;
+ context->driFd = sPriv->fd;
+
+ /* Parse configuration files */
+ driParseConfigFiles(&context->optionCache, &glamoScreen->optionCache,
+ glamoScreen->driScreen->myNum, "glamo");
+
+ /* Initialize the software rasterizer and helper modules. */
+ _swrast_CreateContext( ctx );
+ _vbo_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ _swrast_allow_pixel_fog( ctx, GL_TRUE );
+ _swrast_allow_vertex_fog( ctx, GL_FALSE );
+ _tnl_allow_pixel_fog( ctx, GL_TRUE );
+ _tnl_allow_vertex_fog( ctx, GL_FALSE );
+
+ return GL_TRUE;
+}
+
+
+void glamoDestroyContext(__DRIcontext *driContextPriv)
+{
+ glamoContextPtr context;
+
+ context = (glamoContextPtr)driContextPriv->driverPrivate;
+ assert(context != NULL);
+
+ if ( context != NULL ) {
+
+ _swsetup_DestroyContext(context->glCtx);
+ _tnl_DestroyContext(context->glCtx);
+ _vbo_DestroyContext(context->glCtx);
+ _swrast_DestroyContext(context->glCtx);
+
+ _mesa_destroy_context(context->glCtx);
+
+ }
+
+ FREE(context);
+}
+
+
+GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
+ __DRIdrawable *driDrawPriv,
+ __DRIdrawable *driReadPriv)
+{
+ if ( driContextPriv ) {
+
+ GET_CURRENT_CONTEXT(ctx);
+ glamoContextPtr oldGlamoCtx;
+ glamoContextPtr newGlamoCtx;
+ struct gl_framebuffer *drawBuffer, *readBuffer;
+
+ oldGlamoCtx = ctx ? GLAMO_CONTEXT(ctx) : NULL;
+ newGlamoCtx = (glamoContextPtr)driContextPriv->driverPrivate;
+
+ if ( newGlamoCtx != oldGlamoCtx) {
+ newGlamoCtx->GlobalFlag = GFLAG_ALL;
+ }
+
+ newGlamoCtx->driDrawable = driDrawPriv;
+
+ drawBuffer = (GLframebuffer *)driDrawPriv->driverPrivate;
+ readBuffer = (GLframebuffer *)driReadPriv->driverPrivate;
+
+ _mesa_make_current(newGlamoCtx->glCtx, drawBuffer, readBuffer);
+
+ } else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return GL_TRUE;
+}
+
+
+GLboolean glamoUnbindContext(__DRIcontext *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
diff --git a/src/mesa/drivers/dri/glamo/glamo_context.h b/src/mesa/drivers/dri/glamo/glamo_context.h
new file mode 100644
index 0000000000..8f4d811c61
--- /dev/null
+++ b/src/mesa/drivers/dri/glamo/glamo_context.h
@@ -0,0 +1,70 @@
+/*
+ * Direct Rendering Support for SMedia Glamo 336x/337x
+ *
+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
+ * Roughly based on sis_context.h (c) 2003 Eric Anholt
+ *
+ * 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 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 __GLAMO_CONTEXT_H
+#define __GLAMO_CONTEXT_H
+
+#include "dri_util.h"
+#include "utils.h"
+#include "glamo_screen.h"
+
+/* Flags for hardware state that needs to be updated */
+#define GFLAG_ALL 0xffffffff
+
+typedef struct glamo_context glamoContextRec;
+typedef struct glamo_context *glamoContextPtr;
+
+struct glamo_context {
+
+ /* This must be first in this structure */
+ GLcontext *glCtx;
+
+ int driFd; /* DRM fd */
+
+ __DRIcontextPrivate *driContext; /* DRI context */
+ __DRIscreenPrivate *driScreen; /* DRI screen */
+ __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */
+
+ glamoScreenPtr glamoScreen; /* Screen private DRI data */
+
+ driOptionCache optionCache;
+
+ GLint GlobalFlag; /* What needs to be updated */
+
+};
+
+#define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx))
+
+extern GLboolean glamoCreateContext(const __GLcontextModes *glVis,
+ __DRIcontext *driContextPriv,
+ void *sharedContextPrivate);
+extern void glamoDestroyContext(__DRIcontext *dcp);
+extern GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
+ __DRIdrawable *driDrawPriv,
+ __DRIdrawable *driReadPriv);
+extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv);
+
+#endif /* __GLAMO_CONTEXT_H */
+
+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
diff --git a/src/mesa/drivers/dri/glamo/glamo_dri.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
index a6351dc46b..7ec44ac161 100644
--- a/src/mesa/drivers/dri/glamo/glamo_dri.c
+++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
@@ -2,6 +2,7 @@
* Direct Rendering Support for SMedia Glamo 336x/337x
*
* (c) 2009 Thomas White <taw@bitwiz.org.uk>
+ * Roughly based on sis_screen.c (c) 2003 Eric Anholt
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -21,8 +22,17 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+
#include "dri_util.h"
#include "utils.h"
+#include "xmlconfig.h"
+#include "GL/internal/dri_interface.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#include "glamo_screen.h"
+#include "glamo_context.h"
+
static int glamoInitDriver(__DRIscreenPrivate *psp)
{
@@ -30,41 +40,71 @@ static int glamoInitDriver(__DRIscreenPrivate *psp)
}
-static const __DRIconfig **glamoInitScreen(__DRIscreenPrivate *psp)
+static glamoScreenPtr glamoCreateScreen(__DRIscreenPrivate *sPriv)
{
- uint8_t depth_bits_array[1];
- uint8_t stencil_bits_array[1];
- static const GLenum db_modes[1] = { GLX_NONE };
+ glamoScreenPtr glamoScreen;
- /* Our basic initialisation */
- if ( glamoInitDriver(psp) ) {
+ /* Allocate the private area */
+ glamoScreen = (glamoScreenPtr)CALLOC(sizeof(*glamoScreen));
+ if ( glamoScreen == NULL )
return NULL;
- }
- depth_bits_array[0] = 24;
- stencil_bits_array[0] = 8;
+ glamoScreen->driScreen = sPriv;
- /* Report what modes we can handle */
- return driCreateConfigs(GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,
- depth_bits_array, stencil_bits_array, 1,
- db_modes, 1);
+ /* parse information in __driConfigOptions */
+// driParseOptionInfo(&glamoScreen->optionCache,
+// __driConfigOptions, __driNConfigOptions);
+
+ return glamoScreen;
}
-static void glamoDestroyScreen(__DRIscreenPrivate *psp)
+static void glamoDestroyScreen(__DRIscreenPrivate *sPriv)
{
-}
+ glamoScreenPtr glamoScreen = (glamoScreenPtr)sPriv->private;
+ if ( glamoScreen == NULL )
+ return;
-static GLboolean glamoCreateContext(const __GLcontextModes *glVis,
- __DRIcontext *driContextPriv,
- void *sharedContextPrivate)
-{
+ FREE(glamoScreen);
+ sPriv->private = NULL;
}
-static void glamoDestroyContext(__DRIcontext *dcp)
+static const __DRIconfig **glamoInitScreen(__DRIscreenPrivate *sPriv)
{
+ __DRIconfig **configs;
+ uint8_t depth_bits_array[2];
+ uint8_t stencil_bits_array[2];
+ static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
+
+ /* Driver initialisation */
+ if ( glamoInitDriver(sPriv) ) {
+ return NULL;
+ }
+
+ /* Screen-specific initialisation */
+ sPriv->private = glamoCreateScreen(sPriv);
+ if ( !sPriv->private ) {
+ glamoDestroyScreen(sPriv);
+ return NULL;
+ }
+
+ depth_bits_array[0] = 0;
+ stencil_bits_array[0] = 0;
+ depth_bits_array[1] = 16;
+ stencil_bits_array[1] = 0;
+
+ configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
+ depth_bits_array, stencil_bits_array, 2,
+ db_modes, 2);
+
+ if ( configs == NULL ) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
+ return NULL;
+ }
+
+ return (const __DRIconfig **)configs;
}
@@ -73,27 +113,32 @@ static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
const __GLcontextModes *glVis,
GLboolean pixmapBuffer)
{
-}
+ struct gl_framebuffer *fb;
+ if ( pixmapBuffer )
+ return GL_FALSE; /* not implemented */
-static void glamoDestroyBuffer(__DRIdrawable *driDrawPriv)
-{
-}
+ fb = _mesa_create_framebuffer(glVis);
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ glVis->stencilBits > 0,
+ glVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *)fb;
-static void glamoSwapBuffers(__DRIdrawable *driDrawPriv)
-{
+ return (driDrawPriv->driverPrivate != NULL);
}
-static GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
- __DRIdrawable *driDrawPriv,
- __DRIdrawable *driReadPriv)
+static void glamoDestroyBuffer(__DRIdrawable *driDrawPriv)
{
}
-static GLboolean glamoUnbindContext(__DRIcontext *driContextPriv)
+static void glamoSwapBuffers(__DRIdrawable *driDrawPriv)
{
}
diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.h b/src/mesa/drivers/dri/glamo/glamo_screen.h
new file mode 100644
index 0000000000..79ff949ad7
--- /dev/null
+++ b/src/mesa/drivers/dri/glamo/glamo_screen.h
@@ -0,0 +1,40 @@
+/*
+ * Direct Rendering Support for SMedia Glamo 336x/337x
+ *
+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
+ * Roughly based on sis_screen.h (c) 2003 Eric Anholt
+ *
+ * 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 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 __GLAMO_SCREEN_H
+#define __GLAMO_SCREEN_H
+
+#include "xmlconfig.h"
+#include "dri_util.h"
+
+typedef struct {
+
+ __DRIscreenPrivate *driScreen;
+ driOptionCache optionCache;
+
+} glamoScreenRec, *glamoScreenPtr;
+
+#endif /* __GLAMO_SCREEN_H */
+
+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */