summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/savage/savage_xmesa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/savage/savage_xmesa.c')
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c204
1 files changed, 71 insertions, 133 deletions
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index 00171253290..a344aab71bb 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -26,16 +26,16 @@
#include <X11/Xlibint.h>
#include <stdio.h>
-#include "savagecontext.h"
-#include "context.h"
-#include "matrix.h"
-#include "framebuffer.h"
-#include "renderbuffer.h"
-#include "simple_list.h"
+#include "main/context.h"
+#include "main/context.h"
+#include "main/matrix.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/simple_list.h"
#include "utils.h"
-#include "extensions.h"
+#include "main/extensions.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
@@ -168,16 +168,17 @@ static const struct tnl_pipeline_stage *savage_pipeline[] = {
};
-/* this is first function called in dirver*/
+PUBLIC const __DRIextension *savageScreenExtensions[] = {
+ &driCoreExtension.base,
+ &driLegacyExtension.base,
+ &driReadDrawableExtension,
+};
static GLboolean
savageInitDriver(__DRIscreenPrivate *sPriv)
{
savageScreenPrivate *savageScreen;
SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv;
- PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
- (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
-
if (sPriv->devPrivSize != sizeof(SAVAGEDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(SAVAGEDRIRec) does not match passed size from device driver\n");
@@ -265,10 +266,7 @@ savageInitDriver(__DRIscreenPrivate *sPriv)
driParseOptionInfo (&savageScreen->optionCache,
__driConfigOptions, __driNConfigOptions);
- if (glx_enable_extension != NULL) {
- (*glx_enable_extension)(sPriv->psc->screenConfigs,
- "GLX_SGI_make_current_read");
- }
+ sPriv->extensions = savageScreenExtensions;
#if 0
savageDDFastPathInit();
@@ -295,34 +293,6 @@ savageDestroyScreen(__DRIscreenPrivate *sPriv)
sPriv->private = NULL;
}
-#if 0
-GLvisual *XMesaCreateVisual(Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- const XVisualInfo *visinfo,
- const __GLXvisualConfig *config)
-{
- /* Drivers may change the args to _mesa_create_visual() in order to
- * setup special visuals.
- */
- return _mesa_create_visual( config->rgba,
- config->doubleBuffer,
- config->stereo,
- _mesa_bitcount(visinfo->red_mask),
- _mesa_bitcount(visinfo->green_mask),
- _mesa_bitcount(visinfo->blue_mask),
- config->alphaSize,
- 0, /* index bits */
- config->depthSize,
- config->stencilSize,
- config->accumRedSize,
- config->accumGreenSize,
- config->accumBlueSize,
- config->accumAlphaSize,
- 0 /* num samples */ );
-}
-#endif
-
-
static GLboolean
savageCreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
@@ -525,7 +495,7 @@ savageCreateContext( const __GLcontextModes *mesaVis,
"enable_fastpath");
/* DRM versions before 2.1.3 would only render triangle lists. ELTS
* support was added in 2.2.0. */
- if (imesa->enable_fastpath && sPriv->drmMinor < 2) {
+ if (imesa->enable_fastpath && sPriv->drm_version.minor < 2) {
fprintf (stderr,
"*** Disabling fast path because your DRM version is buggy "
"or doesn't\n*** support ELTS. You need at least Savage DRM "
@@ -732,7 +702,7 @@ void savageXMesaSetClipRects(savageContextPtr imesa)
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
if ((dPriv->numBackClipRects == 0)
- || (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT)) {
+ || (imesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)) {
imesa->numClipRects = dPriv->numClipRects;
imesa->pClipRects = dPriv->pClipRects;
imesa->drawX = dPriv->x;
@@ -917,32 +887,18 @@ void savageGetLock( savageContextPtr imesa, GLuint flags )
}
}
-
-
-static const struct __DriverAPIRec savageAPI = {
- savageInitDriver,
- savageDestroyScreen,
- savageCreateContext,
- savageDestroyContext,
- savageCreateBuffer,
- savageDestroyBuffer,
- savageSwapBuffers,
- savageMakeCurrent,
- savageUnbindContext
-};
-
-
-static __GLcontextModes *
-savageFillInModes( unsigned pixel_bits, unsigned depth_bits,
+static const __DRIconfig **
+savageFillInModes( __DRIscreenPrivate *psp,
+ unsigned pixel_bits, unsigned depth_bits,
unsigned stencil_bits, GLboolean have_back_buffer )
{
- __GLcontextModes * modes;
+ __DRIconfig **configs;
__GLcontextModes * m;
- unsigned num_modes;
unsigned depth_buffer_factor;
unsigned back_buffer_factor;
GLenum fb_format;
GLenum fb_type;
+ int 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
@@ -973,8 +929,6 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_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 * 4;
-
if ( pixel_bits == 16 ) {
fb_format = GL_RGB;
fb_type = GL_UNSIGNED_SHORT_5_6_5;
@@ -984,21 +938,11 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_bits,
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
}
- modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
- m = modes;
- if ( ! driFillInModes( & m, fb_format, fb_type,
- depth_bits_array, stencil_bits_array, depth_buffer_factor,
- back_buffer_modes, back_buffer_factor,
- GLX_TRUE_COLOR ) ) {
- fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
- __func__, __LINE__ );
- return NULL;
- }
-
- if ( ! driFillInModes( & m, fb_format, fb_type,
- depth_bits_array, stencil_bits_array, depth_buffer_factor,
- back_buffer_modes, back_buffer_factor,
- GLX_DIRECT_COLOR ) ) {
+ configs = driCreateConfigs(fb_format, fb_type,
+ depth_bits_array, stencil_bits_array,
+ depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor);
+ if (configs == NULL) {
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
__func__, __LINE__ );
return NULL;
@@ -1006,74 +950,68 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_bits,
/* Mark the visual as slow if there are "fake" stencil bits.
*/
- for ( m = modes ; m != NULL ; m = m->next ) {
- if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ for (i = 0; configs[i]; i++) {
+ m = &configs[i]->modes;
+ if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
m->visualRating = GLX_SLOW_CONFIG;
}
}
- return modes;
+ return (const __DRIconfig **) configs;
}
/**
- * 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.
+ * This is the driver specific part of the createNewScreen entry point.
*
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
- * failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
*/
-PUBLIC
-void * __driCreateNewScreen_20050727( __DRInativeDisplay *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,
- const __DRIinterfaceMethods * interface,
- __GLcontextModes ** driver_modes )
-
+static const __DRIconfig **
+savageInitScreen(__DRIscreenPrivate *psp)
{
- __DRIscreenPrivate *psp;
static const __DRIversion ddx_expected = { 2, 0, 0 };
static const __DRIversion dri_expected = { 4, 0, 0 };
static const __DRIversion drm_expected = { 2, 1, 0 };
-
- dri_interface = interface;
+ SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv;
if ( ! driCheckDriDdxDrmVersions2( "Savage",
- dri_version, & dri_expected,
- ddx_version, & ddx_expected,
- drm_version, & drm_expected ) ) {
+ &psp->dri_version, & dri_expected,
+ &psp->ddx_version, & ddx_expected,
+ &psp->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, &savageAPI);
- if ( psp != NULL ) {
- SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv;
- *driver_modes = savageFillInModes( dri_priv->cpp*8,
- (dri_priv->cpp == 2) ? 16 : 24,
- (dri_priv->cpp == 2) ? 0 : 8,
- (dri_priv->backOffset != dri_priv->depthOffset) );
-
- /* 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;
+ /* 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 );
+
+ if (!savageInitDriver(psp))
+ return NULL;
+
+ return savageFillInModes( psp,
+ dri_priv->cpp*8,
+ (dri_priv->cpp == 2) ? 16 : 24,
+ (dri_priv->cpp == 2) ? 0 : 8,
+ (dri_priv->backOffset != dri_priv->depthOffset) );
}
+
+const struct __DriverAPIRec driDriverAPI = {
+ savageInitScreen,
+ savageDestroyScreen,
+ savageCreateContext,
+ savageDestroyContext,
+ savageCreateBuffer,
+ savageDestroyBuffer,
+ savageSwapBuffers,
+ savageMakeCurrent,
+ savageUnbindContext
+};