intel: Move MapBufferRange mesa state setting up to cover the 915 case.
[mesa.git] / src / mesa / drivers / dri / trident / trident_context.c
index f43c1e732c45db3b019440aa9d255cfd82a700a2..b5126b07ea641595dd602111a4606cea99ccac7b 100644 (file)
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
-#include "array_cache/acache.h"
+#include "vbo/vbo.h"
 
 #include "tnl/tnl.h"
 #include "tnl/t_pipeline.h"
 
-#include "context.h"
-#include "simple_list.h"
-#include "matrix.h"
-#include "extensions.h"
-#include "framebuffer.h"
-#include "renderbuffer.h"
+#include "main/context.h"
+#include "main/simple_list.h"
+#include "main/matrix.h"
+#include "main/extensions.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/viewport.h"
 #if defined(USE_X86_ASM)
 #include "x86/common_x86_asm.h"
 #endif
-#include "simple_list.h"
-#include "mm.h"
+#include "main/simple_list.h"
+#include "main/mm.h"
 #include "drirenderbuffer.h"
 
 #include "drivers/common/driverfuncs.h"
 #include "dri_util.h"
+#include "utils.h"
 
 static const struct tnl_pipeline_stage *trident_pipeline[] = {
    &_tnl_vertex_transform_stage, 
@@ -62,9 +64,10 @@ static const struct tnl_pipeline_stage *trident_pipeline[] = {
 };
 
 
-GLboolean tridentCreateContext( const __GLcontextModes *glVisual,
-                            __DRIcontextPrivate *driContextPriv,
-                            void *sharedContextPrivate)
+static GLboolean
+tridentCreateContext( const __GLcontextModes *glVisual,
+                      __DRIcontextPrivate *driContextPriv,
+                      void *sharedContextPrivate)
 {
    GLcontext *ctx, *shareCtx;
    __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
@@ -126,6 +129,8 @@ GLboolean tridentCreateContext( const __GLcontextModes *glVisual,
    ctx->Const.MaxPointSizeAA = 16.0; 
    ctx->Const.PointSizeGranularity = 0.25;
 
+   ctx->Const.MaxDrawBuffers = 1;
+
 #if 0
    tmesa->texHeap = mmInit( 0, tmesa->tridentScreen->textureSize );
 
@@ -141,7 +146,7 @@ GLboolean tridentCreateContext( const __GLcontextModes *glVisual,
    /* Initialize the software rasterizer and helper modules.
     */
    _swrast_CreateContext( ctx );
-   _ac_CreateContext( ctx );
+   _vbo_CreateContext( ctx );
    _tnl_CreateContext( ctx );
    _swsetup_CreateContext( ctx );
 
@@ -181,7 +186,7 @@ tridentDestroyContext(__DRIcontextPrivate *driContextPriv)
     if (tmesa) {
       _swsetup_DestroyContext( tmesa->glCtx );
       _tnl_DestroyContext( tmesa->glCtx );
-      _ac_DestroyContext( tmesa->glCtx );
+      _vbo_DestroyContext( tmesa->glCtx );
       _swrast_DestroyContext( tmesa->glCtx );
 
       /* free the Mesa context */
@@ -277,7 +282,7 @@ tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 static void
 tridentDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
 {
-   _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+   _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
 static void
@@ -348,7 +353,8 @@ tridentUnbindContext( __DRIcontextPrivate *driContextPriv )
 }
 
 
-tridentScreenPtr tridentCreateScreen( __DRIscreenPrivate *sPriv )
+static tridentScreenPtr
+tridentCreateScreen( __DRIscreenPrivate *sPriv )
 {
    TRIDENTDRIPtr tDRIPriv = (TRIDENTDRIPtr)sPriv->pDevPriv;
    tridentScreenPtr tridentScreen;
@@ -393,12 +399,14 @@ printf("MAPPED at %p\n", tridentScreen->mmio.map);
 
 /* Destroy the device specific screen private data struct.
  */
-void tridentDestroyScreen( __DRIscreenPrivate *sPriv )
+static void
+tridentDestroyScreen( __DRIscreenPrivate *sPriv )
 {
     tridentScreenPtr tridentScreen = (tridentScreenPtr)sPriv->private;
 
     FREE(tridentScreen);
 }
+
 static GLboolean 
 tridentInitDriver(__DRIscreenPrivate *sPriv)
 {
@@ -412,56 +420,46 @@ tridentInitDriver(__DRIscreenPrivate *sPriv)
     return GL_TRUE;
 }
 
-static struct __DriverAPIRec tridentAPI = {
-   tridentInitDriver,
-   tridentDestroyScreen,
-   tridentCreateContext,
-   tridentDestroyContext,
-   tridentCreateBuffer,
-   tridentDestroyBuffer,
-   tridentSwapBuffers,
-   tridentMakeCurrent,
-   tridentUnbindContext,
-};
-
-
-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 )
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
+ */
+const __DRIconfig **tridentInitScreen(__DRIscreenPrivate *psp)
 {
-    __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 4, 0, 0 };
    static const __DRIversion dri_expected = { 3, 1, 0 };
    static const __DRIversion drm_expected = { 1, 0, 0 };
-
-   dri_interface = interface;
-
+   
    if ( ! driCheckDriDdxDrmVersions2( "Trident",
-                                     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, &tridentAPI);
+   if (!tridentInitDriver(psp))
+       return NULL;
 
-    if ( psp != NULL ) {
+    /* Wait... what?  This driver doesn't report any modes... */
 #if 0
-       TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
-       *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
-                                          GL_TRUE );
+   TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
+   *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
+                                      GL_TRUE );
 #endif
-    }
-    return (void *) psp;
+
+   return NULL;
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   tridentInitScreen,
+   tridentDestroyScreen,
+   tridentCreateContext,
+   tridentDestroyContext,
+   tridentCreateBuffer,
+   tridentDestroyBuffer,
+   tridentSwapBuffers,
+   tridentMakeCurrent,
+   tridentUnbindContext,
+};