change back driver change from previous commit
[mesa.git] / src / mesa / drivers / dri / i915tex / intel_context.c
index c6c66e26caea6816c1a3ee1b659c55ce147342a3..ec4a7a746d48485be1a143e8140df6cb0ff655f8 100644 (file)
@@ -130,6 +130,18 @@ intelGetString(GLcontext * ctx, GLenum name)
       case PCI_CHIP_I945_GM:
          chipset = "Intel(R) 945GM";
          break;
+      case PCI_CHIP_I945_GME:
+         chipset = "Intel(R) 945GME";
+         break;
+      case PCI_CHIP_G33_G:
+        chipset = "Intel(R) G33";
+        break;
+      case PCI_CHIP_Q35_G:
+        chipset = "Intel(R) Q35";
+        break;
+      case PCI_CHIP_Q33_G:
+        chipset = "Intel(R) Q33";
+        break;
       default:
          chipset = "Unknown Intel Chipset";
          break;
@@ -180,6 +192,7 @@ const struct dri_extension card_extensions[] = {
 #if 1                           /* XXX FBO temporary? */
    {"GL_EXT_packed_depth_stencil", NULL},
 #endif
+   {"GL_EXT_pixel_buffer_object", NULL},
    {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
    {"GL_EXT_stencil_wrap", NULL},
    {"GL_EXT_texture_edge_clamp", NULL},
@@ -270,18 +283,26 @@ intelFlush(GLcontext * ctx)
  * Check if we need to rotate/warp the front color buffer to the
  * rotated screen.  We generally need to do this when we get a glFlush
  * or glFinish after drawing to the front color buffer.
+ * If no rotation, just copy the private fake front buffer to the real one.
  */
 static void
-intelCheckFrontRotate(GLcontext * ctx)
+intelCheckFrontUpdate(GLcontext * ctx)
 {
    struct intel_context *intel = intel_context(ctx);
+   /* rely on _ColorDrawBufferMask being kept up to date by mesa
+      even for window-fbos. */
+   /* not sure. Might need that for all masks including
+      BUFFER_BIT_FRONT_LEFT maybe? */
    if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] ==
        BUFFER_BIT_FRONT_LEFT) {
       intelScreenPrivate *screen = intel->intelScreen;
+      __DRIdrawablePrivate *dPriv = intel->driDrawable;
       if (screen->current_rotation != 0) {
-         __DRIdrawablePrivate *dPriv = intel->driDrawable;
          intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT);
       }
+      else {
+         intelCopyBuffer(dPriv, NULL);
+      }
    }
 }
 
@@ -293,7 +314,7 @@ static void
 intelglFlush(GLcontext * ctx)
 {
    intelFlush(ctx);
-   intelCheckFrontRotate(ctx);
+   intelCheckFrontUpdate(ctx);
 }
 
 void
@@ -307,7 +328,7 @@ intelFinish(GLcontext * ctx)
       driFenceUnReference(intel->batch->last_fence);
       intel->batch->last_fence = NULL;
    }
-   intelCheckFrontRotate(ctx);
+   intelCheckFrontUpdate(ctx);
 }
 
 
@@ -346,6 +367,14 @@ intelInitContext(struct intel_context *intel,
    drmI830Sarea *saPriv = (drmI830Sarea *)
       (((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset);
    int fthrottle_mode;
+   GLboolean havePools;
+
+   DRM_LIGHT_LOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
+   havePools = intelCreatePools(intelScreen);
+   DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
+
+   if (!havePools)
+      return GL_FALSE;
 
    if (!_mesa_initialize_context(&intel->ctx,
                                  mesaVis, shareCtx,
@@ -549,6 +578,13 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
                  __DRIdrawablePrivate * driReadPriv)
 {
 
+#if 0
+   if (driDrawPriv) {
+      fprintf(stderr, "x %d, y %d, width %d, height %d\n",
+             driDrawPriv->x, driDrawPriv->y, driDrawPriv->w, driDrawPriv->h);
+   }
+#endif
+
    if (driContextPriv) {
       struct intel_context *intel =
          (struct intel_context *) driContextPriv->driverPrivate;
@@ -556,6 +592,9 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
         (struct intel_framebuffer *) driDrawPriv->driverPrivate;
       GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate;
 
+      /* this is a hack so we have a valid context when the region allocation
+         is done. Need a per-screen context? */
+      intel->intelScreen->dummyctxptr = intel;
 
       /* XXX FBO temporary fix-ups! */
       /* if the renderbuffers don't have regions, init them from the context */
@@ -585,11 +624,11 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
          }
       }
 
-      /* set GLframebuffer size to match window, if needed */
+      /* update GLframebuffer size to match window if needed */
       driUpdateFramebufferSize(&intel->ctx, driDrawPriv);
 
       if (driReadPriv != driDrawPriv) {
-        driUpdateFramebufferSize(&intel->ctx, driReadPriv);
+         driUpdateFramebufferSize(&intel->ctx, driReadPriv);
       }
 
       _mesa_make_current(&intel->ctx, &intel_fb->Base, readFb);
@@ -607,9 +646,11 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
                                  &intel_fb->vbl_seq);
            intel->driDrawable = driDrawPriv;
            intelWindowMoved(intel);
+           intel->lastStamp = driDrawPriv->lastStamp;
+        }
+        else if (intel->lastStamp != driDrawPriv->lastStamp) {
+           intel_draw_buffer(&intel->ctx, &intel_fb->Base);
         }
-
-        intel_draw_buffer(&intel->ctx, &intel_fb->Base);
       }
    }
    else {
@@ -647,6 +688,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
       intelUpdateScreenRotation(sPriv, sarea);
    }
 
+#if 0
    if (sarea->width != intel->width ||
        sarea->height != intel->height ||
        sarea->rotation != intel->current_rotation) {
@@ -689,13 +731,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
       intel->height = sarea->height;
       intel->current_rotation = sarea->rotation;
    }
-
-   /* Drawable changed?
-    */
-   if (dPriv && intel->lastStamp != dPriv->lastStamp) {
-      intelWindowMoved(intel);
-      intel->lastStamp = dPriv->lastStamp;
-   }
+#endif
 }