Change default of driconf "allow_large_textures" to announce hardware limits.
[mesa.git] / src / mesa / drivers / dri / intel / intel_screen.c
index 5d0bf4a1da14b81cfc54504545e6cc5b6ad4f751..52e062eececbfea1f23082da5a4e6da059abfac5 100644 (file)
@@ -56,17 +56,26 @@ PUBLIC const char __driConfigOptions[] =
    DRI_CONF_SECTION_PERFORMANCE
       DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
       DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+      /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
+       * DRI_CONF_BO_REUSE_ALL
+       */
+      DRI_CONF_OPT_BEGIN_V(bo_reuse, enum, 0, "0:1")
+        DRI_CONF_DESC_BEGIN(en, "Buffer object reuse")
+           DRI_CONF_ENUM(0, "Disable buffer object reuse")
+           DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
+        DRI_CONF_DESC_END
+      DRI_CONF_OPT_END
    DRI_CONF_SECTION_END
    DRI_CONF_SECTION_QUALITY
       DRI_CONF_FORCE_S3TC_ENABLE(false)
-      DRI_CONF_ALLOW_LARGE_TEXTURES(1)
+      DRI_CONF_ALLOW_LARGE_TEXTURES(2)
    DRI_CONF_SECTION_END
    DRI_CONF_SECTION_DEBUG
      DRI_CONF_NO_RAST(false)
    DRI_CONF_SECTION_END
 DRI_CONF_END;
 
-const GLuint __driNConfigOptions = 5;
+const GLuint __driNConfigOptions = 6;
 
 #ifdef USE_NEW_INTERFACE
 static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
@@ -284,14 +293,17 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
 
 static void
 intelHandleDrawableConfig(__DRIdrawablePrivate *dPriv,
+                         __DRIcontextPrivate *pcp,
                          __DRIDrawableConfigEvent *event)
 {
    struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
    struct intel_region *region = NULL;
    struct intel_renderbuffer *rb, *depth_rb, *stencil_rb;
-   struct intel_context *intel = dPriv->driContextPriv->driverPrivate;
-   int cpp = intel->ctx.Visual.rgbBits / 8;
-   GLuint pitch = ((cpp * dPriv->w + 63) & ~63) / cpp;
+   struct intel_context *intel = pcp->driverPrivate;
+   int cpp, pitch;
+
+   cpp = intel->ctx.Visual.rgbBits / 8;
+   pitch = ((cpp * dPriv->w + 63) & ~63) / cpp;
 
    rb = intel_fb->color_rb[1];
    if (rb) {
@@ -322,12 +334,13 @@ intelHandleDrawableConfig(__DRIdrawablePrivate *dPriv,
 
 static void
 intelHandleBufferAttach(__DRIdrawablePrivate *dPriv,
+                       __DRIcontextPrivate *pcp,
                        __DRIBufferAttachEvent *ba)
 {
    struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
    struct intel_renderbuffer *rb;
    struct intel_region *region;
-   struct intel_context *intel = dPriv->driContextPriv->driverPrivate;
+   struct intel_context *intel = pcp->driverPrivate;
    GLuint tiled;
 
    switch (ba->buffer.attachment) {
@@ -371,22 +384,6 @@ intelHandleBufferAttach(__DRIdrawablePrivate *dPriv,
    intel_renderbuffer_set_region(rb, region);
 }
 
-static void
-intelUpdateBuffer(__DRIdrawablePrivate *dPriv, unsigned int *event)
-{
-   switch (DRI2_EVENT_TYPE(*event)) {
-   case DRI2_EVENT_DRAWABLE_CONFIG:
-      /* flush all current regions, allocate new ones, except front buffer */
-      intelHandleDrawableConfig(dPriv, (__DRIDrawableConfigEvent *) event);
-      break;
-
-   case DRI2_EVENT_BUFFER_ATTACH:
-      /* attach buffer if different from what we have */
-      intelHandleBufferAttach(dPriv, (__DRIBufferAttachEvent *) event);
-      break;
-   }
-}
-
 static const __DRItexOffsetExtension intelTexOffsetExtension = {
    { __DRI_TEX_OFFSET },
    intelSetTexOffset,
@@ -397,7 +394,7 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
    intelSetTexBuffer,
 };
 
-static const __DRIextension *intelExtensions[] = {
+static const __DRIextension *intelScreenExtensions[] = {
     &driReadDrawableExtension,
     &driCopySubBufferExtension.base,
     &driSwapControlExtension.base,
@@ -482,7 +479,7 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
                        &intelScreen->allow_batchbuffer))
       return GL_FALSE;
 
-   sPriv->extensions = intelExtensions;
+   sPriv->extensions = intelScreenExtensions;
 
    return GL_TRUE;
 }
@@ -656,36 +653,18 @@ intelCreateContext(const __GLcontextModes * mesaVis,
 }
 
 
-static const struct __DriverAPIRec intelAPI = {
-   .DestroyScreen = intelDestroyScreen,
-   .CreateContext = intelCreateContext,
-   .DestroyContext = intelDestroyContext,
-   .CreateBuffer = intelCreateBuffer,
-   .DestroyBuffer = intelDestroyBuffer,
-   .SwapBuffers = intelSwapBuffers,
-   .MakeCurrent = intelMakeCurrent,
-   .UnbindContext = intelUnbindContext,
-   .GetSwapInfo = intelGetSwapInfo,
-   .GetDrawableMSC = driDrawableGetMSC32,
-   .WaitForMSC = driWaitForMSC32,
-   .WaitForSBC = NULL,
-   .SwapBuffersMSC = NULL,
-   .CopySubBuffer = intelCopySubBuffer,
-   .UpdateBuffer = intelUpdateBuffer,
-};
-
-
-static __GLcontextModes *
-intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
+static __DRIconfig **
+intelFillInModes(__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;
 
    /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
     * support pageflipping at all.
@@ -697,7 +676,6 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
    u_int8_t depth_bits_array[3];
    u_int8_t stencil_bits_array[3];
 
-
    depth_bits_array[0] = 0;
    depth_bits_array[1] = depth_bits;
    depth_bits_array[2] = depth_bits;
@@ -716,8 +694,6 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
    depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
    back_buffer_factor = (have_back_buffer) ? 3 : 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;
@@ -727,36 +703,26 @@ intelFillInModes(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)) {
-      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+   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;
    }
 
    /* Mark the visual as slow if there are "fake" stencil bits.
     */
-   for (m = modes; m != NULL; m = m->next) {
+   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 configs;
 }
 
 
@@ -767,7 +733,7 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
  *
  * \return the __GLcontextModes supported by this driver
  */
-PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
+static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
 {
 #ifdef I915
    static const __DRIversion ddx_expected = { 1, 5, 0 };
@@ -778,8 +744,6 @@ PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
    static const __DRIversion drm_expected = { 1, 5, 0 };
    I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
 
-   psp->DriverAPI = intelAPI;
-
    if (!driCheckDriDdxDrmVersions2("i915",
                                    &psp->dri_version, &dri_expected,
                                    &psp->ddx_version, &ddx_expected,
@@ -802,9 +766,12 @@ PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
    if (!intelInitDriver(psp))
        return NULL;
 
-   return intelFillInModes(dri_priv->cpp * 8,
-                          (dri_priv->cpp == 2) ? 16 : 24,
-                          (dri_priv->cpp == 2) ? 0  : 8, 1);
+   psp->extensions = intelScreenExtensions;
+
+   return (const __DRIconfig **)
+       intelFillInModes(psp, dri_priv->cpp * 8,
+                       (dri_priv->cpp == 2) ? 16 : 24,
+                       (dri_priv->cpp == 2) ? 0  : 8, 1);
 }
 
 struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
@@ -827,23 +794,10 @@ struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
  * 
  * \return the __GLcontextModes supported by this driver
  */
-PUBLIC __GLcontextModes *__dri2DriverInitScreen(__DRIscreenPrivate *psp)
+static const
+__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
 {
-   static const __DRIversion ddx_expected = { 1, 9, 0 };
-   static const __DRIversion dri_expected = { 4, 0, 0 };
-   static const __DRIversion drm_expected = { 1, 5, 0 };
    intelScreenPrivate *intelScreen;
-   __GLcontextModes *modes, *m;
-
-   psp->DriverAPI = intelAPI;
-
-   if (!driCheckDriDdxDrmVersions2("i915",
-                                   &psp->dri_version, &dri_expected,
-                                   &psp->ddx_version, &ddx_expected,
-                                   &psp->drm_version, &drm_expected)) {
-      fprintf(stderr, "bad version voodoo\n");
-      return NULL;
-   }
 
    /* Calling driInitExtensions here, with a NULL context pointer,
     * does not actually enable the extensions.  It just makes sure
@@ -892,12 +846,28 @@ PUBLIC __GLcontextModes *__dri2DriverInitScreen(__DRIscreenPrivate *psp)
       return GL_FALSE;
    }
 
-   psp->extensions = intelExtensions;
-
-   modes = intelFillInModes(16, 16, 0, 1);
-   for (m = modes; m->next != NULL; m = m->next)
-     ;
-   m->next = intelFillInModes(32, 24, 8, 1);
+   psp->extensions = intelScreenExtensions;
 
-   return modes;
+   return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1),
+                          intelFillInModes(psp, 32, 24, 8, 1));
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen          = intelInitScreen,
+   .DestroyScreen       = intelDestroyScreen,
+   .CreateContext       = intelCreateContext,
+   .DestroyContext      = intelDestroyContext,
+   .CreateBuffer        = intelCreateBuffer,
+   .DestroyBuffer       = intelDestroyBuffer,
+   .SwapBuffers                 = intelSwapBuffers,
+   .MakeCurrent                 = intelMakeCurrent,
+   .UnbindContext       = intelUnbindContext,
+   .GetSwapInfo                 = intelGetSwapInfo,
+   .GetDrawableMSC      = driDrawableGetMSC32,
+   .WaitForMSC          = driWaitForMSC32,
+   .CopySubBuffer       = intelCopySubBuffer,
+
+   .InitScreen2                 = intelInitScreen2,
+   .HandleDrawableConfig = intelHandleDrawableConfig,
+   .HandleBufferAttach  = intelHandleBufferAttach,
+};