DRI2: Drop sarea, implement swap buffers in the X server.
[mesa.git] / src / mesa / drivers / dri / intel / intel_screen.c
index 8fd503ee8b73099940db7427b9724ce07a9dd6de..c193830f05fb40dbabeeede87d555656423ea5ce 100644 (file)
@@ -55,7 +55,7 @@ PUBLIC const char __driConfigOptions[] =
    DRI_CONF_BEGIN
    DRI_CONF_SECTION_PERFORMANCE
       DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
-      DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+      DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC)
       /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
        * DRI_CONF_BO_REUSE_ALL
        */
@@ -90,51 +90,6 @@ intelMapScreenRegions(__DRIscreenPrivate * sPriv)
 {
    intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
 
-   if (intelScreen->front.handle) {
-      if (drmMap(sPriv->fd,
-                 intelScreen->front.handle,
-                 intelScreen->front.size,
-                 (drmAddress *) & intelScreen->front.map) != 0) {
-         _mesa_problem(NULL, "drmMap(frontbuffer) failed!");
-         return GL_FALSE;
-      }
-   }
-   else {
-      _mesa_warning(NULL, "no front buffer handle in intelMapScreenRegions!");
-   }
-
-   if (0)
-      _mesa_printf("Back 0x%08x ", intelScreen->back.handle);
-   if (drmMap(sPriv->fd,
-              intelScreen->back.handle,
-              intelScreen->back.size,
-              (drmAddress *) & intelScreen->back.map) != 0) {
-      intelUnmapScreenRegions(intelScreen);
-      return GL_FALSE;
-   }
-
-   if (intelScreen->third.handle) {
-      if (0)
-        _mesa_printf("Third 0x%08x ", intelScreen->third.handle);
-      if (drmMap(sPriv->fd,
-                intelScreen->third.handle,
-                intelScreen->third.size,
-                (drmAddress *) & intelScreen->third.map) != 0) {
-        intelUnmapScreenRegions(intelScreen);
-        return GL_FALSE;
-      }
-   }
-
-   if (0)
-      _mesa_printf("Depth 0x%08x ", intelScreen->depth.handle);
-   if (drmMap(sPriv->fd,
-              intelScreen->depth.handle,
-              intelScreen->depth.size,
-              (drmAddress *) & intelScreen->depth.map) != 0) {
-      intelUnmapScreenRegions(intelScreen);
-      return GL_FALSE;
-   }
-
    if (0)
       _mesa_printf("TEX 0x%08x ", intelScreen->tex.handle);
    if (intelScreen->tex.size != 0) {
@@ -147,50 +102,15 @@ intelMapScreenRegions(__DRIscreenPrivate * sPriv)
       }
    }
 
-   if (0)
-      printf("Mappings:  front: %p  back: %p  third: %p  depth: %p  tex: %p\n",
-             intelScreen->front.map,
-             intelScreen->back.map, intelScreen->third.map,
-             intelScreen->depth.map, intelScreen->tex.map);
    return GL_TRUE;
 }
 
 void
 intelUnmapScreenRegions(intelScreenPrivate * intelScreen)
 {
-#define REALLY_UNMAP 1
-   if (intelScreen->front.map) {
-#if REALLY_UNMAP
-      if (drmUnmap(intelScreen->front.map, intelScreen->front.size) != 0)
-         printf("drmUnmap front failed!\n");
-#endif
-      intelScreen->front.map = NULL;
-   }
-   if (intelScreen->back.map) {
-#if REALLY_UNMAP
-      if (drmUnmap(intelScreen->back.map, intelScreen->back.size) != 0)
-         printf("drmUnmap back failed!\n");
-#endif
-      intelScreen->back.map = NULL;
-   }
-   if (intelScreen->third.map) {
-#if REALLY_UNMAP
-      if (drmUnmap(intelScreen->third.map, intelScreen->third.size) != 0)
-         printf("drmUnmap third failed!\n");
-#endif
-      intelScreen->third.map = NULL;
-   }
-   if (intelScreen->depth.map) {
-#if REALLY_UNMAP
-      drmUnmap(intelScreen->depth.map, intelScreen->depth.size);
-      intelScreen->depth.map = NULL;
-#endif
-   }
    if (intelScreen->tex.map) {
-#if REALLY_UNMAP
       drmUnmap(intelScreen->tex.map, intelScreen->tex.size);
       intelScreen->tex.map = NULL;
-#endif
    }
 }
 
@@ -291,106 +211,6 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
       intelPrintSAREA(sarea);
 }
 
-
-/**
- * DRI2 entrypoint
- */
-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 = 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) {
-      region = intel_region_alloc(intel, cpp, pitch, dPriv->h);
-      intel_renderbuffer_set_region(rb, region);
-   }
-
-   rb = intel_fb->color_rb[2];
-   if (rb) {
-      region = intel_region_alloc(intel, cpp, pitch, dPriv->h);
-      intel_renderbuffer_set_region(rb, region);
-   }
-
-   depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
-   stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-   if (depth_rb || stencil_rb)
-      region = intel_region_alloc(intel, cpp, pitch, dPriv->h);
-   if (depth_rb)
-      intel_renderbuffer_set_region(depth_rb, region);
-   if (stencil_rb)
-      intel_renderbuffer_set_region(stencil_rb, region);
-
-   /* FIXME: Tell the X server about the regions we just allocated and
-    * attached. */
-}
-
-#define BUFFER_FLAG_TILED 0x0100
-
-/**
- * DRI2 entrypoint
- */
-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 = pcp->driverPrivate;
-   GLuint tiled;
-
-   switch (ba->buffer.attachment) {
-   case DRI_DRAWABLE_BUFFER_FRONT_LEFT:
-      rb = intel_fb->color_rb[0];
-      break;
-
-   case DRI_DRAWABLE_BUFFER_BACK_LEFT:
-      rb = intel_fb->color_rb[0];
-      break;
-
-   case DRI_DRAWABLE_BUFFER_DEPTH:
-     rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
-     break;
-
-   case DRI_DRAWABLE_BUFFER_STENCIL:
-     rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-     break;
-
-   case DRI_DRAWABLE_BUFFER_ACCUM:
-   default:
-      fprintf(stderr, "unhandled buffer attach event, attacment type %d\n",
-             ba->buffer.attachment);
-      return;
-   }
-
-#if 0
-   /* FIXME: Add this so we can filter out when the X server sends us
-    * attachment events for the buffers we just allocated.  Need to
-    * get the BO handle for a render buffer. */
-   if (intel_renderbuffer_get_region_handle(rb) == ba->buffer.handle)
-      return;
-#endif
-
-   tiled = (ba->buffer.flags & BUFFER_FLAG_TILED) > 0;
-   region = intel_region_alloc_for_handle(intel, ba->buffer.cpp,
-                                         ba->buffer.pitch / ba->buffer.cpp,
-                                         dPriv->h, tiled,
-                                         ba->buffer.handle);
-
-   intel_renderbuffer_set_region(rb, region);
-}
-
 static const __DRItexOffsetExtension intelTexOffsetExtension = {
    { __DRI_TEX_OFFSET },
    intelSetTexOffset,
@@ -530,24 +350,20 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
       _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis);
 
       /* setup the hardware-based renderbuffers */
-      {
-         intel_fb->color_rb[0] = intel_create_renderbuffer(rgbFormat, 
-                                                          screen->ttm ? screen->front.tiled : INTEL_TILE_NONE);
-         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
-                               &intel_fb->color_rb[0]->Base);
-      }
+      intel_fb->color_rb[0] = intel_create_renderbuffer(rgbFormat);
+      _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
+                            &intel_fb->color_rb[0]->Base);
 
       if (mesaVis->doubleBufferMode) {
-         intel_fb->color_rb[1] = intel_create_renderbuffer(rgbFormat,
-                                                          screen->ttm ? screen->back.tiled : INTEL_TILE_NONE);
+        intel_fb->color_rb[1] = intel_create_renderbuffer(rgbFormat);
+
          _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
                                &intel_fb->color_rb[1]->Base);
 
         if (screen->third.handle) {
            struct gl_renderbuffer *tmp_rb = NULL;
 
-           intel_fb->color_rb[2] = intel_create_renderbuffer(rgbFormat,
-                                                             screen->ttm ? screen->third.tiled : INTEL_TILE_NONE);
+           intel_fb->color_rb[2] = intel_create_renderbuffer(rgbFormat);
            _mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base);
         }
       }
@@ -556,8 +372,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
         if (mesaVis->stencilBits == 8) {
            /* combined depth/stencil buffer */
            struct intel_renderbuffer *depthStencilRb
-              = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT,
-                                          screen->ttm ? screen->depth.tiled : INTEL_TILE_NONE);
+              = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT);
            /* note: bind RB to two attachment points */
            _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
                                   &depthStencilRb->Base);
@@ -565,8 +380,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
                                   &depthStencilRb->Base);
         } else {
            struct intel_renderbuffer *depthRb
-              = intel_create_renderbuffer(GL_DEPTH_COMPONENT24,
-                                          screen->ttm ? screen->depth.tiled : INTEL_TILE_NONE);
+              = intel_create_renderbuffer(GL_DEPTH_COMPONENT24);
            _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
                                   &depthRb->Base);
         }
@@ -574,8 +388,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
       else if (mesaVis->depthBits == 16) {
          /* just 16-bit depth buffer, no hw stencil */
          struct intel_renderbuffer *depthRb
-            = intel_create_renderbuffer(GL_DEPTH_COMPONENT16,
-                                       screen->ttm ? screen->depth.tiled : INTEL_TILE_NONE);
+           = intel_create_renderbuffer(GL_DEPTH_COMPONENT16);
          _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
       }
 
@@ -841,26 +654,12 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
 
    intelScreen->drmMinor = psp->drm_version.minor;
 
-   /* Determine chipset ID? */
+   /* Determine chipset ID */
    if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID,
                        &intelScreen->deviceID))
       return GL_FALSE;
 
-   /* Determine if IRQs are active? */
-   if (!intel_get_param(psp, I915_PARAM_IRQ_ACTIVE,
-                       &intelScreen->irq_active))
-      return GL_FALSE;
-
-   /* Determine if batchbuffers are allowed */
-   if (!intel_get_param(psp, I915_PARAM_ALLOW_BATCHBUFFER,
-                       &intelScreen->allow_batchbuffer))
-      return GL_FALSE;
-
-   if (!intelScreen->allow_batchbuffer) {
-      fprintf(stderr, "batch buffer not allowed\n");
-      return GL_FALSE;
-   }
-
+   intelScreen->irq_active = 1;
    psp->extensions = intelScreenExtensions;
 
    return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1),
@@ -883,6 +682,4 @@ const struct __DriverAPIRec driDriverAPI = {
    .CopySubBuffer       = intelCopySubBuffer,
 
    .InitScreen2                 = intelInitScreen2,
-   .HandleDrawableConfig = intelHandleDrawableConfig,
-   .HandleBufferAttach  = intelHandleBufferAttach,
 };