intel: Enable GL_EXT_framebuffer_object for gles2
[mesa.git] / src / mesa / drivers / dri / intel / intel_buffers.c
index 7c4b79f743a8dca6d79d386cea6b4944bafea626..0480770ba1d4b077dcfb177eb1556f711f606479 100644 (file)
 #include "intel_context.h"
 #include "intel_buffers.h"
 #include "intel_fbo.h"
-#include "intel_regions.h"
-#include "intel_batchbuffer.h"
 #include "main/framebuffer.h"
-#include "drirenderbuffer.h"
-
-
-/**
- * XXX move this into a new dri/common/cliprects.c file.
- */
-GLboolean
-intel_intersect_cliprects(drm_clip_rect_t * dst,
-                          const drm_clip_rect_t * a,
-                          const drm_clip_rect_t * b)
-{
-   GLint bx = b->x1;
-   GLint by = b->y1;
-   GLint bw = b->x2 - bx;
-   GLint bh = b->y2 - by;
-
-   if (bx < a->x1)
-      bw -= a->x1 - bx, bx = a->x1;
-   if (by < a->y1)
-      bh -= a->y1 - by, by = a->y1;
-   if (bx + bw > a->x2)
-      bw = a->x2 - bx;
-   if (by + bh > a->y2)
-      bh = a->y2 - by;
-   if (bw <= 0)
-      return GL_FALSE;
-   if (bh <= 0)
-      return GL_FALSE;
-
-   dst->x1 = bx;
-   dst->y1 = by;
-   dst->x2 = bx + bw;
-   dst->y2 = by + bh;
-
-   return GL_TRUE;
-}
 
 /**
  * Return pointer to current color drawing region, or NULL.
@@ -96,24 +58,6 @@ intel_readbuf_region(struct intel_context *intel)
       return NULL;
 }
 
-void
-intel_get_cliprects(struct intel_context *intel,
-                   struct drm_clip_rect **cliprects,
-                   unsigned int *num_cliprects,
-                   int *x_off, int *y_off)
-{
-   intel->fboRect.x1 = 0;
-   intel->fboRect.y1 = 0;
-   intel->fboRect.x2 = intel->ctx.DrawBuffer->Width;
-   intel->fboRect.y2 = intel->ctx.DrawBuffer->Height;
-
-   *cliprects = &intel->fboRect;
-   *num_cliprects = 1;
-   *x_off = 0;
-   *y_off = 0;
-}
-
-
 /**
  * Check if we're about to draw into the front color buffer.
  * If so, set the intel->front_buffer_dirty field to true.
@@ -282,7 +226,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
        * only changes with _NEW_STENCIL (which seems sensible).  So flag it
        * here since this is the _NEW_BUFFERS path.
        */
-      ctx->NewState |= (_NEW_DEPTH | _NEW_STENCIL);
+      intel->NewGLState |= (_NEW_DEPTH | _NEW_STENCIL);
    }
 
    intel->vtbl.set_draw_region(intel, colorRegions, depthRegion, 
@@ -292,7 +236,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
 #ifdef I915
    intelCalcViewport(ctx);
 #else
-   ctx->NewState |= _NEW_VIEWPORT;
+   intel->NewGLState |= _NEW_VIEWPORT;
 #endif
    /* Set state we know depends on drawable parameters:
     */
@@ -312,7 +256,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
    if (ctx->Driver.FrontFace)
       ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
    else
-      ctx->NewState |= _NEW_POLYGON;
+      intel->NewGLState |= _NEW_POLYGON;
 }
 
 
@@ -327,13 +271,12 @@ intelDrawBuffer(GLcontext * ctx, GLenum mode)
       intel->is_front_buffer_rendering = (mode == GL_FRONT_LEFT)
        || (mode == GL_FRONT);
 
-      /* If we weren't front-buffer rendering before but we are now, make sure
-       * that the front-buffer has actually been allocated.
+      /* If we weren't front-buffer rendering before but we are now,
+       * invalidate our DRI drawable so we'll ask for new buffers
+       * (including the fake front) before we start rendering again.
        */
-      if (!was_front_buffer_rendering && intel->is_front_buffer_rendering) {
-        intel_update_renderbuffers(intel->driContext,
-                                   intel->driContext->driDrawablePriv);
-      }
+      if (!was_front_buffer_rendering && intel->is_front_buffer_rendering)
+        dri2InvalidateDrawable(intel->driContext->driDrawablePriv);
    }
 
    intel_draw_buffer(ctx, ctx->DrawBuffer);
@@ -351,13 +294,12 @@ intelReadBuffer(GLcontext * ctx, GLenum mode)
       intel->is_front_buffer_reading = (mode == GL_FRONT_LEFT)
        || (mode == GL_FRONT);
 
-      /* If we weren't front-buffer reading before but we are now, make sure
-       * that the front-buffer has actually been allocated.
+      /* If we weren't front-buffer reading before but we are now,
+       * invalidate our DRI drawable so we'll ask for new buffers
+       * (including the fake front) before we start reading again.
        */
-      if (!was_front_buffer_reading && intel->is_front_buffer_reading) {
-        intel_update_renderbuffers(intel->driContext,
-                                   intel->driContext->driDrawablePriv);
-      }
+      if (!was_front_buffer_reading && intel->is_front_buffer_reading)
+        dri2InvalidateDrawable(intel->driContext->driReadablePriv);
    }
 
    if (ctx->ReadBuffer == ctx->DrawBuffer) {