Merge commit 'origin/master' into gallium-map-range
[mesa.git] / src / mesa / drivers / dri / unichrome / via_screen.c
index 025d8f63af499ffaeb4d03a107de70b4972874f1..e9f566161c267ecd4c20bcbbbc938611dbee3cd2 100644 (file)
 
 #include <stdio.h>
 
-#include "utils.h"
 #include "dri_util.h"
-#include "glheader.h"
-#include "context.h"
-#include "framebuffer.h"
-#include "renderbuffer.h"
-#include "matrix.h"
-#include "simple_list.h"
+#include "utils.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/matrix.h"
+#include "main/simple_list.h"
 #include "vblank.h"
 
 #include "via_state.h"
@@ -48,7 +48,7 @@
 
 #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)
@@ -64,8 +64,6 @@ static const GLuint __driNConfigOptions = 3;
 
 extern const struct dri_extension card_extensions[];
 
-static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
-
 static drmBufMapPtr via_create_empty_buffers(void)
 {
     drmBufMapPtr retval;
@@ -98,8 +96,6 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
 {
     viaScreenPrivate *viaScreen;
     VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv;
-    PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
-      (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
     int i;
 
     if (sPriv->devPrivSize != sizeof(VIADRIRec)) {
@@ -177,14 +173,12 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
 
     i = 0;
     viaScreen->extensions[i++] = &driFrameTrackingExtension.base;
-    if ( glx_enable_extension != NULL ) {
-       if ( viaScreen->irqEnabled ) {
-         viaScreen->extensions[i++] = &driSwapControlExtension.base;
-         (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
-       }
-
-       (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" );
+    viaScreen->extensions[i++] = &driReadDrawableExtension;
+    if ( viaScreen->irqEnabled ) {
+       viaScreen->extensions[i++] = &driSwapControlExtension.base;
+       viaScreen->extensions[i++] = &driMediaStreamCounterExtension.base;
     }
+
     viaScreen->extensions[i++] = NULL;
     sPriv->extensions = viaScreen->extensions;
 
@@ -325,31 +319,11 @@ viaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
    _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)));
 }
 
-
-
-static struct __DriverAPIRec viaAPI = {
-   .DestroyScreen   = viaDestroyScreen,
-   .CreateContext   = viaCreateContext,
-   .DestroyContext  = viaDestroyContext,
-   .CreateBuffer    = viaCreateBuffer,
-   .DestroyBuffer   = viaDestroyBuffer,
-   .SwapBuffers     = viaSwapBuffers,
-   .MakeCurrent     = viaMakeCurrent,
-   .UnbindContext   = viaUnbindContext,
-   .GetSwapInfo     = getSwapInfo,
-   .GetMSC          = driGetMSC32,
-   .WaitForMSC      = driWaitForMSC32,
-   .WaitForSBC      = NULL,
-   .SwapBuffersMSC  = NULL
-};
-
-
-static __GLcontextModes *
-viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
+static const __DRIconfig **
+viaFillInModes( __DRIscreenPrivate *psp,
+               unsigned pixel_bits, GLboolean have_back_buffer )
 {
-    __GLcontextModes * modes;
-    __GLcontextModes * m;
-    unsigned num_modes;
+    __DRIconfig **configs;
     const unsigned back_buffer_factor = (have_back_buffer) ? 2 : 1;
     GLenum fb_format;
     GLenum fb_type;
@@ -366,13 +340,11 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
     /* The 32-bit depth-buffer mode isn't supported yet, so don't actually
      * enable it.
      */
-    static const u_int8_t depth_bits_array[4]   = { 0, 16, 24, 32 };
-    static const u_int8_t stencil_bits_array[4] = { 0,  0,  8,  0 };
+    static const uint8_t depth_bits_array[4]   = { 0, 16, 24, 32 };
+    static const uint8_t stencil_bits_array[4] = { 0,  0,  8,  0 };
+    uint8_t msaa_samples_array[1] = { 0 };
     const unsigned depth_buffer_factor = 3;
 
-
-    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;
@@ -382,29 +354,18 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
         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 ) ) {
-       fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
-                __func__, __LINE__ );
+    configs = driCreateConfigs(fb_format, fb_type,
+                              depth_bits_array, stencil_bits_array,
+                              depth_buffer_factor, back_buffer_modes,
+                              back_buffer_factor,
+                               msaa_samples_array, 1);
+    if (configs == NULL) {
+       fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+               __LINE__);
        return NULL;
     }
 
-    return modes;
+    return (const __DRIconfig **) configs;
 }
 
 
@@ -415,7 +376,8 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
  *
  * \return the __GLcontextModes supported by this driver
  */
-__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
+static const __DRIconfig **
+viaInitScreen(__DRIscreenPrivate *psp)
 {
    static const __DRIversion ddx_expected = { VIA_DRIDDX_VERSION_MAJOR,
                                               VIA_DRIDDX_VERSION_MINOR,
@@ -431,8 +393,6 @@ __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
                                      &psp->drm_version, & drm_expected) )
       return NULL;
 
-   psp->DriverAPI = viaAPI;
-
    /* 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
@@ -448,7 +408,7 @@ __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
    if (!viaInitDriver(psp))
        return NULL;
 
-   return viaFillInModes( dri_priv->bytesPerPixel * 8, GL_TRUE );
+   return viaFillInModes( psp, dri_priv->bytesPerPixel * 8, GL_TRUE );
 
 }
 
@@ -478,3 +438,20 @@ getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
 
    return 0;
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = viaInitScreen,
+   .DestroyScreen   = viaDestroyScreen,
+   .CreateContext   = viaCreateContext,
+   .DestroyContext  = viaDestroyContext,
+   .CreateBuffer    = viaCreateBuffer,
+   .DestroyBuffer   = viaDestroyBuffer,
+   .SwapBuffers     = viaSwapBuffers,
+   .MakeCurrent     = viaMakeCurrent,
+   .UnbindContext   = viaUnbindContext,
+   .GetSwapInfo     = getSwapInfo,
+   .GetDrawableMSC  = driDrawableGetMSC32,
+   .WaitForMSC      = driWaitForMSC32,
+   .WaitForSBC      = NULL,
+   .SwapBuffersMSC  = NULL
+};