Merge branch '7.8'
authorMichel Dänzer <daenzer@vmware.com>
Wed, 10 Mar 2010 17:33:17 +0000 (18:33 +0100)
committerMichel Dänzer <daenzer@vmware.com>
Wed, 10 Mar 2010 17:33:17 +0000 (18:33 +0100)
1  2 
src/gallium/state_trackers/xorg/xorg_crtc.c
src/gallium/state_trackers/xorg/xorg_driver.c

index 44f7da0f9604a7982c1c2f0d95b8594097be3a37,53a3c5c2b7d6f53a63bb8f176130fbb2f8095ec7..7268a79a23d2209472b236f2d9c433faca2f4b91
@@@ -197,11 -197,11 +197,11 @@@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr 
  
      if (!crtcp->cursor_tex) {
        struct pipe_texture templat;
 -      unsigned pitch;
 +      struct winsys_handle whandle;
  
        memset(&templat, 0, sizeof(templat));
        templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
 -      templat.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY;
 +      templat.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT;
        templat.target = PIPE_TEXTURE_2D;
        templat.last_level = 0;
        templat.depth0 = 1;
        templat.width0 = 64;
        templat.height0 = 64;
  
 +      memset(&whandle, 0, sizeof(whandle));
 +      whandle.type = DRM_API_HANDLE_TYPE_KMS;
 +
        crtcp->cursor_tex = ms->screen->texture_create(ms->screen,
                                                       &templat);
 -      ms->api->local_handle_from_texture(ms->api,
 -                                         ms->screen,
 -                                         crtcp->cursor_tex,
 -                                         &pitch,
 -                                         &crtcp->cursor_handle);
 +      ms->screen->texture_get_handle(ms->screen, crtcp->cursor_tex, &whandle);
 +
 +      crtcp->cursor_handle = whandle.handle;
      }
  
      transfer = ms->screen->get_tex_transfer(ms->screen, crtcp->cursor_tex,
@@@ -276,7 -275,21 +276,21 @@@ err_bo_destroy
  static void
  crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
  {
+     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
      modesettingPtr ms = modesettingPTR(crtc->scrn);
+     /* Older X servers have cursor reference counting bugs leading to use of
+      * freed memory and consequently random crashes. Should be fixed as of
+      * xserver 1.8, but this workaround shouldn't hurt anyway.
+      */
+     if (config->cursor)
+        config->cursor->refcnt++;
+     if (ms->cursor)
+        FreeCursor(ms->cursor, None);
+     ms->cursor = config->cursor;
      if (ms->screen)
        crtc_load_cursor_argb_ga3d(crtc, image);
  #ifdef HAVE_LIBKMS
index 004a28f00e1133481d219b9309b16b7ac44da178,d7c67463d217e8d2a5c110c68795cdd42c869cea..8ac5179545a1fb147b9bc2daf8eacaaa76a4710f
@@@ -922,6 -922,11 +922,11 @@@ drv_close_screen(int scrnIndex, ScreenP
        drv_leave_vt(scrnIndex, 0);
      }
  
+     if (ms->cursor) {
+        FreeCursor(ms->cursor, None);
+        ms->cursor = NULL;
+     }
      if (cust && cust->winsys_screen_close)
        cust->winsys_screen_close(cust);
  
@@@ -989,9 -994,8 +994,9 @@@ static Boo
  drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn)
  {
      modesettingPtr ms = modesettingPTR(pScrn);
 -    unsigned handle, stride, fb_id;
      struct pipe_texture *tex;
 +    struct winsys_handle whandle;
 +    unsigned fb_id;
      int ret;
  
      ms->noEvict = TRUE;
      if (!tex)
        return FALSE;
  
 -    if (!ms->api->local_handle_from_texture(ms->api, ms->screen,
 -                                          tex,
 -                                          &stride,
 -                                          &handle))
 +    memset(&whandle, 0, sizeof(whandle));
 +    whandle.type = DRM_API_HANDLE_TYPE_KMS;
 +
 +    if (!ms->screen->texture_get_handle(ms->screen, tex, &whandle))
        goto err_destroy;
  
      ret = drmModeAddFB(ms->fd,
                       pScrn->virtualY,
                       pScrn->depth,
                       pScrn->bitsPerPixel,
 -                     stride,
 -                     handle,
 +                     whandle.stride,
 +                     whandle.handle,
                       &fb_id);
      if (ret) {
        debug_printf("%s: failed to create framebuffer (%i, %s)\n",