Beispiel #1
0
/* Move locking out to get reasonable span performance.
 */
void i830SpanRenderStart( GLcontext *ctx )
{
   i830ContextPtr imesa = I830_CONTEXT(ctx);
   I830_FIREVERTICES(imesa);
   LOCK_HARDWARE(imesa);
   i830RegetLockQuiescent( imesa );
}
Beispiel #2
0
void i830Fallback( i830ContextPtr imesa, GLuint bit, GLboolean mode )
{
   GLcontext *ctx = imesa->glCtx;
   TNLcontext *tnl = TNL_CONTEXT(ctx);
   GLuint oldfallback = imesa->Fallback;

   if (mode) {
      imesa->Fallback |= bit;
      if (oldfallback == 0) {
	 I830_FIREVERTICES(imesa);
	 if (I830_DEBUG & DEBUG_FALLBACKS) 
	    fprintf(stderr, "ENTER FALLBACK %s\n", getFallbackString( bit ));
	 _swsetup_Wakeup( ctx );
	 imesa->RenderIndex = ~0;
      }
   }
   else {
      imesa->Fallback &= ~bit;
      if (oldfallback == bit) {
	 _swrast_flush( ctx );
	 if (I830_DEBUG & DEBUG_FALLBACKS) 
	    fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString( bit ));
	 tnl->Driver.Render.Start = i830RenderStart;
	 tnl->Driver.Render.PrimitiveNotify = i830RenderPrimitive;
	 tnl->Driver.Render.Finish = i830RenderFinish;
	 tnl->Driver.Render.BuildVertices = i830BuildVertices;
	 imesa->NewGLState |= (_I830_NEW_RENDERSTATE|_I830_NEW_VERTEX);
      }
   }
}
Beispiel #3
0
/* Flip the front & back buffes
 */
void i830PageFlip( const __DRIdrawablePrivate *dPriv )
{
   i830ContextPtr imesa;
   int tmp, ret;

   if (I830_DEBUG & DEBUG_IOCTL)
      fprintf(stderr, "%s\n", __FUNCTION__);

   assert(dPriv);
   assert(dPriv->driContextPriv);
   assert(dPriv->driContextPriv->driverPrivate);

   imesa = (i830ContextPtr) dPriv->driContextPriv->driverPrivate;

   I830_FIREVERTICES( imesa );
   LOCK_HARDWARE( imesa );

   imesa->sarea->perf_boxes |= imesa->perf_boxes;
   imesa->perf_boxes = 0;

   if (dPriv->pClipRects) {
      *(XF86DRIClipRectRec *)imesa->sarea->boxes = dPriv->pClipRects[0];
      imesa->sarea->nbox = 1;
   }

   ret = drmCommandNone(imesa->driFd, DRM_I830_FLIP); 
   if (ret) {
      fprintf(stderr, "%s: %d\n", __FUNCTION__, ret);
      UNLOCK_HARDWARE( imesa );
      exit(1);
   }

   tmp = GET_ENQUEUE_AGE(imesa);
   UNLOCK_HARDWARE( imesa );

   /* multiarb will suck the life out of the server without this throttle:
    */
   if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap) {
      i830WaitAge(imesa, imesa->lastSwap);
   }

   i830SetDrawBuffer( imesa->glCtx, imesa->glCtx->Color.DriverDrawBuffer );
   imesa->upload_cliprects = GL_TRUE;
   imesa->lastSwap = tmp;
}
Beispiel #4
0
/*
 * Copy the back buffer to the front buffer. 
 */
void i830CopyBuffer( const __DRIdrawablePrivate *dPriv ) 
{
   i830ContextPtr imesa;
   XF86DRIClipRectPtr pbox;
   int nbox, i, tmp;

   assert(dPriv);
   assert(dPriv->driContextPriv);
   assert(dPriv->driContextPriv->driverPrivate);

   imesa = (i830ContextPtr) dPriv->driContextPriv->driverPrivate;

   I830_FIREVERTICES( imesa );
   LOCK_HARDWARE( imesa );

   imesa->sarea->perf_boxes |= imesa->perf_boxes;
   imesa->perf_boxes = 0;

   pbox = dPriv->pClipRects;
   nbox = dPriv->numClipRects;

   for (i = 0 ; i < nbox ; )
   {
      int nr = MIN2(i + I830_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
      XF86DRIClipRectRec *b = (XF86DRIClipRectRec *)imesa->sarea->boxes;

      imesa->sarea->nbox = nr - i;

      for ( ; i < nr ; i++) 
	 *b++ = pbox[i];
      drmCommandNone(imesa->driFd, DRM_I830_SWAP);
   }

   tmp = GET_ENQUEUE_AGE(imesa);
   UNLOCK_HARDWARE( imesa );

   /* multiarb will suck the life out of the server without this throttle:
    */
   if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap) {
      i830WaitAge(imesa, imesa->lastSwap);
   }

   imesa->lastSwap = tmp;
   imesa->upload_cliprects = GL_TRUE;
}
Beispiel #5
0
static void i830RunPipeline( GLcontext *ctx )
{
   i830ContextPtr imesa = I830_CONTEXT(ctx);

   if (imesa->NewGLState) {
      if (imesa->NewGLState & _NEW_TEXTURE) {
	 I830_FIREVERTICES( imesa );
	 i830UpdateTextureState( ctx ); /* may modify imesa->NewGLState */
      }

      if (!imesa->Fallback) {
	 if (imesa->NewGLState & _I830_NEW_VERTEX)
	    i830ChooseVertexState( ctx );

	 if (imesa->NewGLState & _I830_NEW_RENDERSTATE)
	    i830ChooseRenderState( ctx );
      }

      imesa->NewGLState = 0;
   }

   _tnl_run_pipeline( ctx );
}
Beispiel #6
0
static void i830DDFlush( GLcontext *ctx )
{
   i830ContextPtr imesa = I830_CONTEXT( ctx );
   I830_FIREVERTICES( imesa );
}
Beispiel #7
0
/* This waits for *everybody* to finish rendering -- overkill.
 */
void i830DmaFinish( i830ContextPtr imesa  )
{
   I830_FIREVERTICES( imesa );
   LOCK_HARDWARE_QUIESCENT( imesa );
   UNLOCK_HARDWARE( imesa );
}
Beispiel #8
0
static void i830Clear(GLcontext *ctx, GLbitfield mask, GLboolean all,
		      GLint cx1, GLint cy1, GLint cw, GLint ch)
{
   i830ContextPtr imesa = I830_CONTEXT( ctx );
   __DRIdrawablePrivate *dPriv = imesa->driDrawable;
   const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
   drmI830Clear clear;
   GLbitfield tri_mask = 0;
   int i;
   GLint cx, cy;

   /* flip top to bottom */
   cy = dPriv->h-cy1-ch;
   cx = cx1 + imesa->drawX;
   cy += imesa->drawY;

   if(0) fprintf(stderr, "\nClearColor : 0x%08x\n", imesa->ClearColor);
   
   clear.flags = 0;
   clear.clear_color = imesa->ClearColor;
   clear.clear_depth = 0;
   clear.clear_colormask = 0;
   clear.clear_depthmask = 0;

   I830_FIREVERTICES( imesa );

   if (mask & DD_FRONT_LEFT_BIT) {
      if(colorMask == ~0) {
	 clear.flags |= I830_FRONT;
      } else {
	 tri_mask |= DD_FRONT_LEFT_BIT;
      }
      mask &= ~DD_FRONT_LEFT_BIT;
   }

   if (mask & DD_BACK_LEFT_BIT) {
      if(colorMask == ~0) {
	 clear.flags |= I830_BACK;
      } else {
	 tri_mask |= DD_BACK_LEFT_BIT;
      }
      mask &= ~DD_BACK_LEFT_BIT;
   }

   if (mask & DD_DEPTH_BIT) {
      clear.flags |= I830_DEPTH;
      clear.clear_depthmask = imesa->depth_clear_mask;
      clear.clear_depth = (GLuint)(ctx->Depth.Clear * imesa->ClearDepth);
      mask &= ~DD_DEPTH_BIT;
   }

   if((mask & DD_STENCIL_BIT) && imesa->hw_stencil) {
      if (ctx->Stencil.WriteMask != 0xff) {
	 tri_mask |= DD_STENCIL_BIT;
      } else {
	 clear.flags |= I830_DEPTH;
	 clear.clear_depthmask |= imesa->stencil_clear_mask;
	 clear.clear_depth |= imesa->stencil_clear_mask;
      }
      mask &= ~DD_STENCIL_BIT;
   }

   /* First check for clears that need to happen with triangles */
   if(tri_mask) {
      i830ClearWithTris(ctx, tri_mask, all, cx, cy, cw, ch);
   } else {
      mask |= tri_mask;
   }

   if (clear.flags) {
      LOCK_HARDWARE( imesa );

      for (i = 0 ; i < imesa->numClipRects ; ) 
      { 	 
	 int nr = MIN2(i + I830_NR_SAREA_CLIPRECTS, imesa->numClipRects);
	 XF86DRIClipRectRec *box = imesa->pClipRects;	 
	 drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes;
	 int n = 0;

	 if (!all) {
	    for ( ; i < nr ; i++) {
	       GLint x = box[i].x1;
	       GLint y = box[i].y1;
	       GLint w = box[i].x2 - x;
	       GLint h = box[i].y2 - y;

	       if (x < cx) w -= cx - x, x = cx; 
	       if (y < cy) h -= cy - y, y = cy;
	       if (x + w > cx + cw) w = cx + cw - x;
	       if (y + h > cy + ch) h = cy + ch - y;
	       if (w <= 0) continue;
	       if (h <= 0) continue;

	       b->x1 = x;
	       b->y1 = y;
	       b->x2 = x + w;
	       b->y2 = y + h;
	       b++;
	       n++;
	    }
	 } else {
	    for ( ; i < nr ; i++) {
	       *b++ = *(drm_clip_rect_t *)&box[i];
	       n++;
	    }
	 }

	 imesa->sarea->nbox = n;
	 drmCommandWrite(imesa->driFd, DRM_I830_CLEAR,
			 &clear, sizeof(drmI830Clear));
      }

      UNLOCK_HARDWARE( imesa );
      imesa->upload_cliprects = GL_TRUE;
   }

   if (mask)
      _swrast_Clear( ctx, mask, all, cx1, cy1, cw, ch );
}