* Authors:
* Gareth Hughes <gareth@valinux.com>
* Leif Delgass <ldelgass@retinalburn.net>
- * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
*/
#include "mach64_context.h"
#include "mach64_ioctl.h"
#include "mach64_tris.h"
#include "mach64_vb.h"
+#include "mach64_span.h"
#include "context.h"
#include "imports.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "utils.h"
#include "vblank.h"
-#ifndef _SOLO
-#include "glxextensions.h"
-#endif
+#include "GL/internal/dri_interface.h"
/* Mach64 configuration
*/
#include "xmlpool.h"
-const char __driConfigOptions[] =
+PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN
DRI_CONF_SECTION_PERFORMANCE
DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
DRI_CONF_SECTION_END
-#if ENABLE_PERF_BOXES
DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+#if ENABLE_PERF_BOXES
DRI_CONF_PERFORMANCE_BOXES(false)
- DRI_CONF_SECTION_END
#endif
+ DRI_CONF_SECTION_END
DRI_CONF_END;
#if ENABLE_PERF_BOXES
-static const GLuint __driNConfigOptions = 2;
+static const GLuint __driNConfigOptions = 3;
#else
-static const GLuint __driNConfigOptions = 1;
+static const GLuint __driNConfigOptions = 2;
#endif
-#ifdef USE_NEW_INTERFACE
-static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
-#endif /* USE_NEW_INTERFACE */
+extern const struct dri_extension card_extensions[];
-#ifdef USE_NEW_INTERFACE
static __GLcontextModes * fill_in_modes( __GLcontextModes * modes,
unsigned pixel_bits,
unsigned depth_bits,
unsigned num_db_modes,
int visType )
{
- static const uint8_t bits[2][4] = {
+ static const u_int8_t bits[2][4] = {
{ 5, 6, 5, 0 },
{ 8, 8, 8, 0 }
};
- static const uint32_t masks[2][4] = {
+ static const u_int32_t masks[2][4] = {
{ 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 },
{ 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }
};
return modes;
}
-#endif /* USE_NEW_INTERFACE */
-#ifdef USE_NEW_INTERFACE
static __GLcontextModes *
mach64FillInModes( unsigned pixel_bits, unsigned depth_bits,
unsigned stencil_bits, GLboolean have_back_buffer )
num_modes = depth_buffer_factor * back_buffer_factor * 4;
- modes = (*create_context_modes)( num_modes, sizeof( __GLcontextModes ) );
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
m = modes;
for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
m = fill_in_modes( m, pixel_bits,
return modes;
}
-#endif /* USE_NEW_INTERFACE */
/* Create the device specific screen private data struct.
{
mach64ScreenPtr mach64Screen;
ATIDRIPtr serverInfo = (ATIDRIPtr)sPriv->pDevPriv;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(ATIDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(ATIDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
if ( MACH64_DEBUG & DEBUG_VERBOSE_DRI )
fprintf( stderr, "%s\n", __FUNCTION__ );
- if ( ! driCheckDriDdxDrmVersions( sPriv, "Mach64", 4, 0, 6, 4, 1, 0 ) )
- return NULL;
-
/* Allocate the private area */
mach64Screen = (mach64ScreenPtr) CALLOC( sizeof(*mach64Screen) );
if ( !mach64Screen ) return NULL;
mach64Screen->IsPCI = serverInfo->IsPCI;
{
- drmMach64GetParam gp;
+ drm_mach64_getparam_t gp;
int ret;
gp.param = MACH64_PARAM_IRQ_NR;
- gp.value = &mach64Screen->irq;
+ gp.value = (void *) &mach64Screen->irq;
ret = drmCommandWriteRead( sPriv->fd, DRM_MACH64_GETPARAM,
&gp, sizeof(gp));
mach64Screen->texSize[MACH64_AGP_HEAP] = 0;
mach64Screen->logTexGranularity[MACH64_AGP_HEAP] = 0;
} else {
- if (mach64Screen->texSize[MACH64_CARD_HEAP] > 0) {
+ if (serverInfo->textureSize > 0) {
mach64Screen->numTexHeaps = MACH64_NR_TEX_HEAPS;
mach64Screen->firstTexHeap = MACH64_CARD_HEAP;
} else {
}
mach64Screen->driScreen = sPriv;
-#ifndef _SOLO
- if ( driCompareGLXAPIVersion( 20030813 ) >= 0 ) {
- PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
- (PFNGLXSCRENABLEEXTENSIONPROC) glXGetProcAddress( (const GLubyte *) "__glXScrEnableExtension" );
- void * const psc = sPriv->psc->screenConfigs;
-
- if ( glx_enable_extension != NULL ) {
- if ( mach64Screen->irq != 0 ) {
- (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
- (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
- (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
- }
-
- (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+
+ if ( glx_enable_extension != NULL ) {
+ if ( mach64Screen->irq != 0 ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
}
+
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
}
-#endif
+
return mach64Screen;
}
driScreen->private = NULL;
}
-/* Initialize the fullscreen mode.
- */
-static GLboolean
-mach64OpenFullScreen( __DRIcontextPrivate *driContextPriv )
-{
- return GL_TRUE;
-}
-
-/* Shut down the fullscreen mode.
- */
-static GLboolean
-mach64CloseFullScreen( __DRIcontextPrivate *driContextPriv )
-{
- return GL_TRUE;
-}
-
/* Create and initialize the Mesa and driver specific pixmap buffer
* data.
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ mach64ScreenPtr screen = (mach64ScreenPtr) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
- driDrawPriv->driverPrivate = (void *)
- _mesa_create_framebuffer( mesaVis,
- GL_FALSE, /* software depth buffer? */
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA,
+ NULL,
+ screen->cpp,
+ screen->frontOffset, screen->frontPitch,
+ driDrawPriv);
+ mach64SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA,
+ NULL,
+ screen->cpp,
+ screen->backOffset, screen->backPitch,
+ driDrawPriv);
+ mach64SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+ NULL, screen->cpp,
+ screen->depthOffset, screen->depthPitch,
+ driDrawPriv);
+ mach64SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ /* XXX I don't think 24-bit Z is supported - so this isn't used */
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+ NULL,
+ screen->cpp,
+ screen->depthOffset, screen->depthPitch,
+ driDrawPriv);
+ mach64SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
mesaVis->stencilBits > 0,
mesaVis->accumRedBits > 0,
- mesaVis->alphaBits > 0 );
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+
return (driDrawPriv->driverPrivate != NULL);
}
}
static void
mach64DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
{
- _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+ _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)));
}
return GL_TRUE;
}
-#ifndef _SOLO
-/* This function is called by libGL.so as soon as libGL.so is loaded.
- * This is where we register new extension functions with the dispatcher.
- */
-void __driRegisterExtensions( void )
-{
- PFNGLXENABLEEXTENSIONPROC glx_enable_extension;
-
- 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 );
- }
- }
-}
-#endif
static struct __DriverAPIRec mach64API = {
.InitDriver = mach64InitDriver,
.SwapBuffers = mach64SwapBuffers,
.MakeCurrent = mach64MakeCurrent,
.UnbindContext = mach64UnbindContext,
- .OpenFullScreen = mach64OpenFullScreen,
- .CloseFullScreen = mach64CloseFullScreen,
.GetSwapInfo = NULL,
.GetMSC = driGetMSC32,
.WaitForMSC = driWaitForMSC32,
};
-/*
- * This is the bootstrap function for the driver.
- * The __driCreateScreen name is the symbol that libGL.so fetches.
- * Return: pointer to a __DRIscreenPrivate.
- */
-#ifndef _SOLO
-void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config)
-{
- __DRIscreenPrivate *psp;
- psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &mach64API);
- return (void *) psp;
-}
-#else
-void *__driCreateScreen(struct DRIDriverRec *driver,
- struct DRIDriverContextRec *driverContext)
-{
- __DRIscreenPrivate *psp;
- psp = __driUtilCreateScreen(driver, driverContext, &mach64API);
- return (void *) psp;
-}
-#endif
-
/**
* This is the bootstrap function for the driver. libGL supplies all of the
* requisite information about the system, and the driver initializes itself.
* \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
* failure.
*/
-#ifdef USE_NEW_INTERFACE
-void * __driCreateNewScreen( Display *dpy, int scrn, __DRIscreen *psc,
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
const __DRIframebuffer * frame_buffer,
drmAddress pSAREA, int fd,
int internal_api_version,
+ const __DRIinterfaceMethods * interface,
__GLcontextModes ** driver_modes )
{
__DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 6, 4, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 2, 0, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "Mach64",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
ddx_version, dri_version, drm_version,
frame_buffer, pSAREA, fd,
internal_api_version, &mach64API);
-
-
- create_context_modes =
- (PFNGLXCREATECONTEXTMODES) glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
- if ( create_context_modes != NULL ) {
+ if ( psp != NULL ) {
ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv;
*driver_modes = mach64FillInModes( dri_priv->cpp * 8,
16,
0,
1);
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
}
return (void *) psp;
}
-#endif /* USE_NEW_INTERFACE */