summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2004-02-11 08:11:58 +0000
committerIan Romanick <idr@us.ibm.com>2004-02-11 08:11:58 +0000
commit0b87abd11bf53034bd368adbbd7f084e3c6eb850 (patch)
treed7c85789df1e2928b4b4dd0ac3fd6f358b3a8203
parent1d6e08db95cfdcd93f4d33a71894deaf5c593391 (diff)
Initial pass at adding support for the new DRI driver interfaces to
the R200 driver. Not as clean / well commented as it should / could be.
-rw-r--r--src/mesa/drivers/dri/r200/r200_screen.c205
1 files changed, 161 insertions, 44 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_screen.c b/src/mesa/drivers/dri/r200/r200_screen.c
index 99409eb02a..9f8091287d 100644
--- a/src/mesa/drivers/dri/r200/r200_screen.c
+++ b/src/mesa/drivers/dri/r200/r200_screen.c
@@ -28,9 +28,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
+/**
+ * \file r200_screen.c
+ * Screen initialization functions for the R200 driver.
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
*/
#include <dlfcn.h>
@@ -101,10 +103,113 @@ static const GLuint __driNConfigOptions = 10;
#define PCI_CHIP_RS300_5837 0x5837
#endif
+#ifdef USE_NEWINTERFACE
+static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
+#endif /* USE_NEWINTERFACE */
+
static r200ScreenPtr __r200Screen;
static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
+#ifdef USE_NEWINTERFACE
+static __GLcontextModes * fill_in_modes( __GLcontextModes * modes,
+ unsigned pixel_bits,
+ unsigned depth_bits,
+ unsigned stencil_bits,
+ const GLenum * db_modes,
+ unsigned num_db_modes )
+{
+ static const uint8_t bits[2][4] = {
+ { 5, 6, 5, 0 },
+ { 8, 8, 8, 8 }
+ };
+
+ static const uint32_t masks[2][4] = {
+ { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 },
+ { 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 }
+ };
+
+ unsigned i;
+ const unsigned index = (pixel_bits / 8) - 1;
+
+ for ( i = 0 ; i < num_db_modes ; i++ ) {
+
+ modes->redBits = bits[index][0];
+ modes->greenBits = bits[index][1];
+ modes->blueBits = bits[index][2];
+ modes->alphaBits = bits[index][3];
+ modes->redMask = masks[index][0];
+ modes->greenMask = masks[index][1];
+ modes->blueMask = masks[index][2];
+ modes->alphaMask = masks[index][3];
+ modes->rgbBits = pixel_bits;
+
+ modes->stencilBits = stencil_bits;
+ modes->depthBits = depth_bits;
+
+ if ( db_modes[i] == GLX_NONE ) {
+ modes->doubleBufferMode = GL_FALSE;
+ }
+ else {
+ modes->doubleBufferMode = GL_TRUE;
+ modes->swapMethod = db_modes[i];
+ }
+
+ modes = modes->next;
+ }
+
+ return modes;
+}
+#endif /* USE_NEWINTERFACE */
+
+
+#ifdef USE_NEWINTERFACE
+static __GLcontextModes *
+r200FillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ unsigned i;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ int depth_buffer_modes[2][2] = {
+ { 0, 0 },
+ { 0, 0 }
+ };
+
+ depth_buffer_modes[1][0] = depth_bits;
+ depth_buffer_modes[1][1] = stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor;
+
+ modes = (*create_context_modes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
+ m = fill_in_modes( m, pixel_bits,
+ depth_buffer_modes[i][0], depth_buffer_modes[i][1],
+ back_buffer_modes, back_buffer_factor );
+ }
+
+ return modes;
+}
+#endif USE_NEWINTERFACE
+
+
/* Create the device specific screen private data struct.
*/
static r200ScreenPtr
@@ -327,12 +432,17 @@ r200CreateScreen( __DRIscreenPrivate *sPriv )
(*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
if ( driCompareGLXAPIVersion( 20030818 ) >= 0 ) {
- sPriv->psc->allocateMemory = r200AllocateMemoryMESA;
- sPriv->psc->freeMemory = r200FreeMemoryMESA;
- sPriv->psc->memoryOffset = r200GetMemoryOffsetMESA;
+ sPriv->psc->allocateMemory = (void *) r200AllocateMemoryMESA;
+ sPriv->psc->freeMemory = (void *) r200FreeMemoryMESA;
+ sPriv->psc->memoryOffset = (void *) r200GetMemoryOffsetMESA;
(*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
}
+
+ if ( driCompareGLXAPIVersion( 20030915 ) >= 0 ) {
+ (*glx_enable_extension)( psc, "GLX_SGIX_fbconfig" );
+ (*glx_enable_extension)( psc, "GLX_OML_swap_method" );
+ }
}
}
#endif
@@ -378,8 +488,12 @@ r200InitDriver( __DRIscreenPrivate *sPriv )
-/* Create and initialize the Mesa and driver specific pixmap buffer
+/**
+ * Create and initialize the Mesa and driver specific pixmap buffer
* data.
+ *
+ * \todo This function (and its interface) will need to be updated to support
+ * pbuffers.
*/
static GLboolean
r200CreateBuffer( __DRIscreenPrivate *driScrnPriv,
@@ -416,20 +530,7 @@ r200DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
-/* Fullscreen mode isn't used for much -- could be a way to shrink
- * front/back buffers & get more texture memory if the client has
- * changed the video resolution.
- *
- * Pageflipping is now done automatically whenever there is a single
- * 3d client.
- */
-static GLboolean
-r200OpenCloseFullScreen( __DRIcontextPrivate *driContextPriv )
-{
- return GL_TRUE;
-}
-
-static struct __DriverAPIRec r200API = {
+static const struct __DriverAPIRec r200API = {
.InitDriver = r200InitDriver,
.DestroyScreen = r200DestroyScreen,
.CreateContext = r200CreateContext,
@@ -439,8 +540,8 @@ static struct __DriverAPIRec r200API = {
.SwapBuffers = r200SwapBuffers,
.MakeCurrent = r200MakeCurrent,
.UnbindContext = r200UnbindContext,
- .OpenFullScreen = r200OpenCloseFullScreen,
- .CloseFullScreen = r200OpenCloseFullScreen,
+ .OpenFullScreen = NULL,
+ .CloseFullScreen = NULL,
.GetSwapInfo = getSwapInfo,
.GetMSC = driGetMSC32,
.WaitForMSC = driWaitForMSC32,
@@ -473,35 +574,51 @@ void *__driCreateScreen(struct DRIDriverRec *driver,
}
#endif
-#ifndef _SOLO
+
/**
- * This function is called by libGL.so to allow the driver to dynamically
- * extend libGL. We can add new GLX functions and/or new GL functions.
- * Note that _mesa_create_context() will probably add most of the newer
- * OpenGL extension functions into the dispatcher.
- *
- * \todo This interface has been deprecated, so we should probably remove
- * this function before the next XFree86 release.
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
*/
-void
-__driRegisterExtensions( void )
+#ifdef USE_NEWINTERFACE
+void * __driCreateNewScreen( Display *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ __GLcontextModes ** driver_modes )
+
{
- PFNGLXENABLEEXTENSIONPROC glx_enable_extension;
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, modes,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &r200API);
- if ( driCompareGLXAPIVersion( 20030317 ) >= 0 ) {
- glx_enable_extension = (PFNGLXENABLEEXTENSIONPROC)
- glXGetProcAddress( (const GLubyte *) "__glXEnableExtension" );
- if ( glx_enable_extension != NULL ) {
- (*glx_enable_extension)( "GLX_SGI_swap_control", GL_FALSE );
- (*glx_enable_extension)( "GLX_SGI_video_sync", GL_FALSE );
- (*glx_enable_extension)( "GLX_MESA_swap_control", GL_FALSE );
- (*glx_enable_extension)( "GLX_MESA_swap_frame_usage", GL_FALSE );
- }
+ create_context_modes =
+ (PFNGLXCREATECONTEXTMODES) glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
+ if ( create_context_modes != NULL ) {
+ RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
+ *driver_modes = r200FillInModes( dri_priv->bpp,
+ (dri_priv->bpp == 16) ? 16 : 24,
+ (dri_priv->bpp == 16) ? 0 : 8,
+ (dri_priv->backOffset != dri_priv->depthOffset) );
}
+
+ return (void *) psp;
}
-#endif
+#endif /* USE_NEWINTERFACE */
+
/**
* Get information about previous buffer swaps.