Exemplo n.º 1
0
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
{
	__DRIdrawablePrivate *const drawable = radeon_get_drawable(rmesa);
	__DRIdrawablePrivate *const readable = radeon_get_readable(rmesa);
	__DRIscreenPrivate *sPriv = rmesa->dri.screen;

	drmGetLock(rmesa->dri.fd, rmesa->dri.hwContext, flags);

	/* The window might have moved, so we might need to get new clip
	 * rects.
	 *
	 * NOTE: This releases and regrabs the hw lock to allow the X server
	 * to respond to the DRI protocol request for new drawable info.
	 * Since the hardware state depends on having the latest drawable
	 * clip rects, all state checking must be done _after_ this call.
	 */
	if (drawable)
		DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);
	if (readable && drawable != readable) {
		DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);
	}

	if (drawable && (rmesa->lastStamp != drawable->lastStamp)) {
		radeon_window_moved(rmesa);
		rmesa->lastStamp = drawable->lastStamp;
	}

	rmesa->vtbl.get_lock(rmesa);
}
Exemplo n.º 2
0
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void radeonGetLock(radeonContextPtr radeon, GLuint flags)
{
	__DRIdrawablePrivate *dPriv = radeon->dri.drawable;
	__DRIscreenPrivate *sPriv = radeon->dri.screen;
	drm_radeon_sarea_t *sarea = radeon->sarea;

	drmGetLock(radeon->dri.fd, radeon->dri.hwContext, flags);

	/* The window might have moved, so we might need to get new clip
	 * rects.
	 *
	 * NOTE: This releases and regrabs the hw lock to allow the X server
	 * to respond to the DRI protocol request for new drawable info.
	 * Since the hardware state depends on having the latest drawable
	 * clip rects, all state checking must be done _after_ this call.
	 */
	DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);

	if (sarea->ctx_owner != radeon->dri.hwContext)
		sarea->ctx_owner = radeon->dri.hwContext;

	if (IS_FAMILY_R300(radeon))
		r300RegainedLock(radeon);
#if R200_MERGED
	else
		r200RegainedLock((r200ContextPtr)radeon);
#endif
	
	radeon->lost_context = GL_TRUE;
}
Exemplo n.º 3
0
Arquivo: sis_lock.c Projeto: aosm/X11
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void
sisGetLock( sisContextPtr smesa, GLuint flags )
{
   __DRIdrawablePrivate *dPriv = smesa->driDrawable;
   __DRIscreenPrivate *sPriv = smesa->driScreen;
   SISSAREAPrivPtr sarea = smesa->sarea;

   drmGetLock( smesa->driFd, smesa->hHWContext, flags );

   /* The window might have moved, so we might need to get new clip
    * rects.
    *
    * NOTE: This releases and regrabs the hw lock to allow the X server
    * to respond to the DRI protocol request for new drawable info.
    * Since the hardware state depends on having the latest drawable
    * clip rects, all state checking must be done _after_ this call.
    */
   DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );

   if ( smesa->lastStamp != dPriv->lastStamp ) {
      sisUpdateBufferSize( smesa );
      sisUpdateClipping( smesa->glCtx );
      sisDDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer );
      smesa->lastStamp = dPriv->lastStamp;
   }

   if ( sarea->CtxOwner != smesa->hHWContext ) {
      sarea->CtxOwner = smesa->hHWContext;
      smesa->GlobalFlag = GFLAG_ALL;
   }
}
Exemplo n.º 4
0
static void client()
{
	int drmfd, ret;
	unsigned int time;

	wait_event(0, SERVER_READY);

	/* XXX: Should make sure we open the same DRM as the master */
	drmfd = drm_open_any();

	client_auth(drmfd);

	/* Wait for the server to grab the lock, then grab it ourselves (to
	 * contest it).  Hopefully we hit it within the window of when the
	 * server locks.
	 */
	wait_event(0, SERVER_LOCKED);
	ret = drmGetLock(drmfd, lock2, 0);
	time = get_millis();
	if (ret != 0)
		err(1, "Failed to get lock on client\n");
	drmUnlock(drmfd, lock2);

	/* Tell the server that our locking completed, and when it did */
	send_event(0, CLIENT_LOCKED);
	ret = write(commfd[0], &time, sizeof(time));

	close(drmfd);
	exit(0);
}
Exemplo n.º 5
0
void tdfxGetLock( tdfxContextPtr fxMesa )
{
    __DRIcontextPrivate *cPriv = fxMesa->driContext;
    __DRIdrawablePrivate *const drawable = cPriv->driDrawablePriv;
    __DRIdrawablePrivate *const readable = cPriv->driReadablePriv;
    __DRIscreenPrivate *sPriv = drawable->driScreenPriv;
    TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) (((char *) sPriv->pSAREA) +
					fxMesa->fxScreen->sarea_priv_offset);
    unsigned int stamp = drawable->lastStamp;

    drmGetLock( fxMesa->driFd, fxMesa->hHWContext, 0 );

    /* This macro will update drawable's cliprects if needed */
    DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);
    if (drawable != readable) {
	DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);
    }

    if ( saPriv->fifoOwner != fxMesa->hHWContext ) {
        fxMesa->Glide.grDRIImportFifo( saPriv->fifoPtr, saPriv->fifoRead );
    }

    if ( saPriv->ctxOwner != fxMesa->hHWContext ) {
        /* This sequence looks a little odd. Glide mirrors the state, and
	 * when you get the state you are forcing the mirror to be up to
	 * date, and then getting a copy from the mirror. You can then force
	 * that state onto the hardware when you set the state.
	 */
        void *state;
        FxI32 stateSize;
        fxMesa->Glide.grGet(GR_GLIDE_STATE_SIZE, 4, &stateSize);
        state = malloc(stateSize);
        fxMesa->Glide.grGlideGetState( state );
        fxMesa->Glide.grGlideSetState( state );
        free( state );
    }

#if 0
    if ( saPriv->texOwner != fxMesa->hHWContext ) {
        tdfxTMRestoreTextures_NoLock( fxMesa );
    }
#endif

    if ((*drawable->pStamp != stamp)
	|| (saPriv->ctxOwner != fxMesa->hHWContext)) {
       driUpdateFramebufferSize(fxMesa->glCtx, drawable);
       if (drawable != readable) {
	   driUpdateFramebufferSize(fxMesa->glCtx, readable);
       }

       tdfxUpdateClipping(fxMesa->glCtx);
       tdfxUploadClipping(fxMesa);
    }

    DEBUG_LOCK();
}
Exemplo n.º 6
0
/** Tests that locking is successful in normal conditions */
static void
test_lock_unlock(int drmfd)
{
	int ret;

	ret = drmGetLock(drmfd, lock1, 0);
	if (ret != 0)
		err(1, "Locking failed");
	ret = drmUnlock(drmfd, lock1);
	if (ret != 0)
		err(1, "Unlocking failed");
}
Exemplo n.º 7
0
/**
 * Tests that an open/close by the same process doesn't result in the lock
 * being dropped.
 */
static void test_open_close_locked(drmfd)
{
	int ret, tempfd;

	ret = drmGetLock(drmfd, lock1, 0);
	assert(ret == 0);
	/* XXX: Need to make sure that this is the same device as drmfd */
	tempfd = drm_open_any();
	close(tempfd);
	ret = drmUnlock(drmfd, lock1);
	if (ret != 0)
		errx(1, "lock lost during open/close by same pid");
}
Exemplo n.º 8
0
/** Tests that unlocking a lock held by another context fails appropriately */
static void
test_unlock_unowned(int drmfd)
{
	int ret;

	ret = drmGetLock(drmfd, lock1, 0);
	assert(ret == 0);
	ret = drmUnlock(drmfd, lock2);
	if (ret == 0)
		errx(1, "Unlocking other context's lock succeeded");
	ret = drmUnlock(drmfd, lock1);
	assert(ret == 0);
}
Exemplo n.º 9
0
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void mach64GetLock( mach64ContextPtr mmesa, GLuint flags )
{
   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
   __DRIscreenPrivate *sPriv = mmesa->driScreen;
   drm_mach64_sarea_t *sarea = mmesa->sarea;
   int i;

   drmGetLock( mmesa->driFd, mmesa->hHWContext, flags );

   /* The window might have moved, so we might need to get new clip
    * rects.
    *
    * NOTE: This releases and regrabs the hw lock to allow the X server
    * to respond to the DRI protocol request for new drawable info.
    * Since the hardware state depends on having the latest drawable
    * clip rects, all state checking must be done _after_ this call.
    */
   DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv ); 

   if ( mmesa->lastStamp != dPriv->lastStamp ) {
      mmesa->lastStamp = dPriv->lastStamp;
      if (mmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT)
         mach64SetCliprects( mmesa->glCtx, GL_BACK_LEFT );
      else
         mach64SetCliprects( mmesa->glCtx, GL_FRONT_LEFT );
      driUpdateFramebufferSize( mmesa->glCtx, dPriv );
      mach64CalcViewport( mmesa->glCtx );
   }

   mmesa->dirty |= (MACH64_UPLOAD_CONTEXT
		    | MACH64_UPLOAD_MISC
		    | MACH64_UPLOAD_CLIPRECTS);

   /* EXA render acceleration uses the texture engine, so restore it */
   mmesa->dirty |= (MACH64_UPLOAD_TEXTURE);

   if ( sarea->ctx_owner != mmesa->hHWContext ) {
      sarea->ctx_owner = mmesa->hHWContext;
      mmesa->dirty = MACH64_UPLOAD_ALL;
   }

   for ( i = mmesa->firstTexHeap ; i < mmesa->lastTexHeap ; i++ ) {
      DRI_AGE_TEXTURES( mmesa->texture_heaps[i] );
   }
}
Exemplo n.º 10
0
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void r200GetLock( r200ContextPtr rmesa, GLuint flags )
{
   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
   __DRIscreenPrivate *sPriv = rmesa->dri.screen;
   drm_radeon_sarea_t *sarea = rmesa->sarea;
   int i;

   drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );

   /* The window might have moved, so we might need to get new clip
    * rects.
    *
    * NOTE: This releases and regrabs the hw lock to allow the X server
    * to respond to the DRI protocol request for new drawable info.
    * Since the hardware state depends on having the latest drawable
    * clip rects, all state checking must be done _after_ this call.
    */
   DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );

   if ( rmesa->lastStamp != dPriv->lastStamp ) {
      r200UpdatePageFlipping( rmesa );
      if (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
         r200SetCliprects( rmesa, GL_BACK_LEFT );
      else
         r200SetCliprects( rmesa, GL_FRONT_LEFT );
      r200UpdateViewportOffset( rmesa->glCtx );
      rmesa->lastStamp = dPriv->lastStamp;
   }

   R200_STATECHANGE( rmesa, ctx );
   if (rmesa->sarea->tiling_enabled) {
      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
   }
   else rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &= ~R200_COLOR_TILE_ENABLE;

   if ( sarea->ctx_owner != rmesa->dri.hwContext ) {
      sarea->ctx_owner = rmesa->dri.hwContext;
   }

   for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
      DRI_AGE_TEXTURES( rmesa->texture_heaps[ i ] );
   }

   rmesa->lost_context = GL_TRUE;
}
Exemplo n.º 11
0
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
{
    __DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
    __DRIdrawablePrivate *const readable = rmesa->dri.readable;
    __DRIscreenPrivate *sPriv = rmesa->dri.screen;
    drm_radeon_sarea_t *sarea = rmesa->sarea;
    r300ContextPtr r300 = (r300ContextPtr) rmesa;

    assert(drawable != NULL);

    drmGetLock(rmesa->dri.fd, rmesa->dri.hwContext, flags);

    /* The window might have moved, so we might need to get new clip
     * rects.
     *
     * NOTE: This releases and regrabs the hw lock to allow the X server
     * to respond to the DRI protocol request for new drawable info.
     * Since the hardware state depends on having the latest drawable
     * clip rects, all state checking must be done _after_ this call.
     */
    DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);
    if (drawable != readable) {
        DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);
    }

    if (rmesa->lastStamp != drawable->lastStamp) {
        radeonUpdatePageFlipping(rmesa);
        radeonSetCliprects(rmesa);
        r300UpdateViewportOffset(rmesa->glCtx);
        driUpdateFramebufferSize(rmesa->glCtx, drawable);
    }

    if (sarea->ctx_owner != rmesa->dri.hwContext) {
        int i;

        sarea->ctx_owner = rmesa->dri.hwContext;
        for (i = 0; i < r300->nr_heaps; i++) {
            DRI_AGE_TEXTURES(r300->texture_heaps[i]);
        }
    }

    rmesa->lost_context = GL_TRUE;
}
Exemplo n.º 12
0
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void s3vGetLock( s3vContextPtr vmesa, GLuint flags )
{
   __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
/*   __DRIscreenPrivate *sPriv = vmesa->driScreen; */

   printf("s3vGetLock <- ***\n");

   drmGetLock( vmesa->driFd, vmesa->hHWContext, flags );

   /* The window might have moved, so we might need to get new clip
    * rects.
    *
    * NOTE: This releases and regrabs the hw lock to allow the X server
    * to respond to the DRI protocol request for new drawable info.
    * Since the hardware state depends on having the latest drawable
    * clip rects, all state checking must be done _after_ this call.
    */
   /* DRI_VALIDATE_DRAWABLE_INFO( vmesa->display, sPriv, dPriv ); */

   if ( vmesa->lastStamp != dPriv->lastStamp ) {
      vmesa->lastStamp = dPriv->lastStamp;
      vmesa->new_state |= S3V_NEW_WINDOW | S3V_NEW_CLIP;
   }

   vmesa->numClipRects = dPriv->numClipRects;
   vmesa->pClipRects = dPriv->pClipRects;

#if 0
   vmesa->dirty = ~0;

   if ( sarea->ctxOwner != vmesa->hHWContext ) {
      sarea->ctxOwner = vmesa->hHWContext;
      vmesa->dirty = S3V_UPLOAD_ALL;
   }

   for ( i = 0 ; i < vmesa->lastTexHeap ; i++ ) {
      if ( sarea->texAge[i] != vmesa->lastTexAge[i] ) {
	 s3vAgeTextures( vmesa, i );
      }
   }
#endif
}
Exemplo n.º 13
0
/* Lock the hardware and validate our state.
 */
void
LOCK_HARDWARE(struct nouveau_context *nv)
{
	struct nouveau_screen *nv_screen = nv->dri_screen->private;
	struct nouveau_device *dev = nv_screen->device;
	struct nouveau_device_priv *nvdev = nouveau_device(dev);
	char __ret=0;

	assert(!nv->locked);
	pipe_mutex_lock(lockMutex);

	DRM_CAS(nvdev->lock, nvdev->ctx,
		(DRM_LOCK_HELD | nvdev->ctx), __ret);

	if (__ret) {
		drmGetLock(nvdev->fd, nvdev->ctx, 0);
		nouveau_contended_lock(nv);
	}
	nv->locked = 1;
}
Exemplo n.º 14
0
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void gammaGetLock( gammaContextPtr gmesa, GLuint flags )
{
   __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
   __DRIscreenPrivate *sPriv = gmesa->driScreen;

   drmGetLock( gmesa->driFd, gmesa->hHWContext, flags );

   /* The window might have moved, so we might need to get new clip
    * rects.
    *
    * NOTE: This releases and regrabs the hw lock to allow the X server
    * to respond to the DRI protocol request for new drawable info.
    * Since the hardware state depends on having the latest drawable
    * clip rects, all state checking must be done _after_ this call.
    */
   DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );

   if ( gmesa->lastStamp != dPriv->lastStamp ) {
      driUpdateFramebufferSize(gmesa->glCtx, dPriv);
      gmesa->lastStamp = dPriv->lastStamp;
      gmesa->new_state |= GAMMA_NEW_WINDOW | GAMMA_NEW_CLIP;
   }

   gmesa->numClipRects = dPriv->numClipRects;
   gmesa->pClipRects = dPriv->pClipRects;

#if 0
   gmesa->dirty = ~0;

   if ( sarea->ctxOwner != gmesa->hHWContext ) {
      sarea->ctxOwner = gmesa->hHWContext;
      gmesa->dirty = GAMMA_UPLOAD_ALL;
   }

   for ( i = 0 ; i < gmesa->lastTexHeap ; i++ ) {
      if ( sarea->texAge[i] != gmesa->lastTexAge[i] ) {
	 gammaAgeTextures( gmesa, i );
      }
   }
#endif
}
Exemplo n.º 15
0
/* Update the hardware state.  This is called if another main/context.has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void r128GetLock( r128ContextPtr rmesa, GLuint flags )
{
   __DRIdrawable *dPriv = rmesa->driDrawable;
   __DRIscreen *sPriv = rmesa->driScreen;
   drm_r128_sarea_t *sarea = rmesa->sarea;
   int i;

   drmGetLock( rmesa->driFd, rmesa->hHWContext, flags );

   /* The window might have moved, so we might need to get new clip
    * rects.
    *
    * NOTE: This releases and regrabs the hw lock to allow the X server
    * to respond to the DRI protocol request for new drawable info.
    * Since the hardware state depends on having the latest drawable
    * clip rects, all state checking must be done _after_ this call.
    */
   DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );

   if ( rmesa->lastStamp != dPriv->lastStamp ) {
      r128UpdatePageFlipping( rmesa );
      driUpdateFramebufferSize(rmesa->glCtx, dPriv);
      rmesa->lastStamp = dPriv->lastStamp;
      rmesa->new_state |= R128_NEW_CLIP;
      RENDERINPUTS_ONES( rmesa->tnl_state_bitset );
   }

   rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_CLIPRECTS;

   rmesa->numClipRects = dPriv->numClipRects;
   rmesa->pClipRects = dPriv->pClipRects;

   if ( sarea->ctx_owner != rmesa->hHWContext ) {
      sarea->ctx_owner = rmesa->hHWContext;
      rmesa->dirty = R128_UPLOAD_ALL;
   }

   for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
      DRI_AGE_TEXTURES( rmesa->texture_heaps[i] );
   }
}
Exemplo n.º 16
0
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void nouveauGetLock( nouveauContextPtr nmesa, GLuint flags )
{
   __DRIdrawablePrivate *dPriv = nmesa->driDrawable;
   __DRIscreenPrivate *sPriv = nmesa->driScreen;
   drm_nouveau_sarea_t *sarea = nmesa->sarea;

   drmGetLock( nmesa->driFd, nmesa->hHWContext, flags );

   /* The window might have moved, so we might need to get new clip
    * rects.
    *
    * NOTE: This releases and regrabs the hw lock to allow the X server
    * to respond to the DRI protocol request for new drawable info.
    * Since the hardware state depends on having the latest drawable
    * clip rects, all state checking must be done _after_ this call.
    */
   DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );

   /* If timestamps don't match, the window has been changed */
   if (nmesa->lastStamp != dPriv->lastStamp) {
      struct gl_framebuffer *fb = (struct gl_framebuffer *)dPriv->driverPrivate;

      /* _mesa_resize_framebuffer will take care of calling the renderbuffer's
       * AllocStorage function if we need more memory to hold it */
      if (fb->Width != dPriv->w || fb->Height != dPriv->h) {
	 _mesa_resize_framebuffer(nmesa->glCtx, fb, dPriv->w, dPriv->h);
	 /* resize buffers, will call nouveau_window_moved */
	 nouveau_build_framebuffer(nmesa->glCtx, fb);
      } else {
	 nouveau_window_moved(nmesa->glCtx);
      }

      nmesa->lastStamp = dPriv->lastStamp;
   }

   nmesa->numClipRects = dPriv->numClipRects;
   nmesa->pClipRects = dPriv->pClipRects;

}
Exemplo n.º 17
0
static void server()
{
	int drmfd, tempfd, ret;
	unsigned int client_time, unlock_time;

	drmfd = drm_open_any_master();

	test_lock_unlock(drmfd);
	test_unlock_unlocked(drmfd);
	test_unlock_unowned(drmfd);
	test_open_close_locked(drmfd);

	/* Perform the authentication sequence with the client. */
	server_auth(drmfd);

	/* Now, test that the client attempting to lock while the server
	 * holds the lock works correctly.
	 */
	ret = drmGetLock(drmfd, lock1, 0);
	assert(ret == 0);
	send_event(1, SERVER_LOCKED);
	/* Wait a while for the client to do its thing */
	sleep(1);
	ret = drmUnlock(drmfd, lock1);
	assert(ret == 0);
	unlock_time = get_millis();

	wait_event(1, CLIENT_LOCKED);
	ret = read(commfd[1], &client_time, sizeof(client_time));
	if (ret == -1)
		err(1, "Failure to read client magic");

	if (client_time < unlock_time)
		errx(1, "Client took lock before server released it");

	close(drmfd);
}
Exemplo n.º 18
0
/* Update the hardware state.  This is called if another context has
 * grabbed the hardware lock, which includes the X server.  This
 * function also updates the driver's window state after the X server
 * moves, resizes or restacks a window -- the change will be reflected
 * in the drawable position and clip rects.  Since the X server grabs
 * the hardware lock when it changes the window state, this routine will
 * automatically be called after such a change.
 */
void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
{
   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
   __DRIscreenPrivate *sPriv = rmesa->dri.screen;
   RADEONSAREAPrivPtr sarea = rmesa->sarea;
   int i;

   drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );

   /* The window might have moved, so we might need to get new clip
    * rects.
    *
    * NOTE: This releases and regrabs the hw lock to allow the X server
    * to respond to the DRI protocol request for new drawable info.
    * Since the hardware state depends on having the latest drawable
    * clip rects, all state checking must be done _after_ this call.
    */
   DRI_VALIDATE_DRAWABLE_INFO( rmesa->dri.display, sPriv, dPriv );

   if ( rmesa->lastStamp != dPriv->lastStamp ) {
      radeonUpdatePageFlipping( rmesa );
      radeonSetCliprects( rmesa, rmesa->glCtx->Color.DriverDrawBuffer );
      radeonUpdateViewportOffset( rmesa->glCtx );
      rmesa->lastStamp = dPriv->lastStamp;
   }

   if ( sarea->ctxOwner != rmesa->dri.hwContext ) {
      sarea->ctxOwner = rmesa->dri.hwContext;

      for ( i = 0 ; i < rmesa->texture.numHeaps ; i++ ) {
	 if ( rmesa->texture.heap[i] && sarea->texAge[i] != rmesa->texture.age[i] ) {
	    radeonAgeTextures( rmesa, i );
	 }
      }
   }
}
Exemplo n.º 19
0
struct bufmgr *
bm_intel_Attach(struct intel_context *intel)
{
   GLuint i;

   for (i = 0; i < nr_bms; i++)
      if (bufmgr_pool[i].driFd == intel->driFd) {
	 bufmgr_pool[i].refcount++;
	 _mesa_printf("retrieive old bufmgr for fd %d\n",
		      bufmgr_pool[i].driFd);
	 return &bufmgr_pool[i];
      }

   if (nr_bms < BM_MAX) {
      struct bufmgr *bm = &bufmgr_pool[nr_bms++];

      _mesa_printf("create new bufmgr for fd %d\n", intel->driFd);
      bm->driFd = intel->driFd;
      bm->hash = _mesa_NewHashTable();
      bm->refcount = 1;
      _glthread_INIT_MUTEX(bm->mutex);

      drmGetLock(bm->driFd, intel->hHWContext, 0);
      BM_CKFATAL(drmMMAllocBufferPool(bm->driFd, mmPoolRing, 0,
				      DRM_MM_TT | DRM_MM_NO_EVICT |
				      DRM_MM_READ | DRM_MM_EXE |
				      BM_BATCHBUFFER, 1024 * 1024, 4096,
				      &bm->batchPool));

      drmUnlock(bm->driFd, intel->hHWContext);
      return bm;
   }

   _mesa_printf("failed to create new bufmgr for fd %d\n", intel->driFd);
   return NULL;
}