[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-ati: Changes to 'upstream-experimental'



 configure.ac                      |   15 ++-
 src/ati.c                         |   26 ++++++
 src/ati_pciids_gen.h              |    3 
 src/drmmode_display.c             |    4 
 src/evergreen_exa.c               |   15 ++-
 src/evergreen_state.h             |    2 
 src/pcidb/ati_pciids.csv          |    3 
 src/r600_exa.c                    |   14 ++-
 src/r600_state.h                  |    4 
 src/radeon.h                      |   24 +++++
 src/radeon_bo_helper.c            |   10 +-
 src/radeon_chipinfo_gen.h         |    3 
 src/radeon_chipset_gen.h          |    3 
 src/radeon_dri2.c                 |  154 +++++++++++++++++++++++++++++---------
 src/radeon_driver.c               |    1 
 src/radeon_exa.c                  |   75 ++++++++++++++++++
 src/radeon_exa_funcs.c            |   13 ++-
 src/radeon_glamor.c               |    8 +
 src/radeon_glamor_wrappers.h      |    1 
 src/radeon_kms.c                  |   79 +++++++++++++++++--
 src/radeon_pci_chipset_gen.h      |    3 
 src/radeon_pci_device_match_gen.h |    3 
 src/radeon_probe.c                |   98 +++++++++++++++++++++++-
 23 files changed, 496 insertions(+), 65 deletions(-)

New commits:
commit e8cb0b721e6ea251f85c799ca0563bfa59a2d37c
Author: Adam Jackson <ajax@redhat.com>
Date:   Wed Sep 26 09:27:54 2012 -0400

    Remove mibstore.h
    
    Signed-off-by: Adam Jackson <ajax@redhat.com>

diff --git a/src/radeon_glamor_wrappers.h b/src/radeon_glamor_wrappers.h
index 9abbd22..53ce969 100644
--- a/src/radeon_glamor_wrappers.h
+++ b/src/radeon_glamor_wrappers.h
@@ -42,7 +42,6 @@
 #include "pixmapstr.h"
 #include "windowstr.h"
 #include "servermd.h"
-#include "mibstore.h"
 #include "colormapst.h"
 #include "gcstruct.h"
 #include "input.h"
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 2842a23..0a10bee 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -1215,13 +1215,8 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
 #endif
 
     pScrn->vtSema = TRUE;
-    /* Backing store setup */
-    xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
-		   "Initializing backing store\n");
-    miInitializeBackingStore(pScreen);
     xf86SetBackingStore(pScreen);
 
-
     if (info->directRenderingEnabled) {
 	xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n");
     } else {

commit 8637f772347c958fa3beea6c0dc9c22255db70e5
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 13 19:50:35 2012 +0200

    glamor: Force acceleration for DRI2 copies.
    
    Improves performance of non-pageflipped 3D apps on SI.
    
    Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

diff --git a/src/radeon.h b/src/radeon.h
index eb46db2..9c2073f 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -402,6 +402,7 @@ struct radeon_accel_state {
     int               vline_y1;
     int               vline_y2;
 
+    Bool              force;
 };
 
 typedef struct {
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 7c5898c..1e04b85 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -633,10 +633,12 @@ radeon_dri2_copy_region2(ScreenPtr pScreen,
 
     /* Driver option "SwapbuffersWait" defines if we vsync DRI2 copy-swaps. */ 
     info->accel_state->vsync = info->swapBuffersWait;
+    info->accel_state->force = TRUE;
 
     (*gc->ops->CopyArea)(src_drawable, dst_drawable, gc,
                          0, 0, drawable->width, drawable->height, off_x, off_y);
 
+    info->accel_state->force = FALSE;
     info->accel_state->vsync = vsync;
 
     FreeScratchGC(gc);
diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
index 12dfd38..99bc666 100644
--- a/src/radeon_glamor.c
+++ b/src/radeon_glamor.c
@@ -151,8 +151,12 @@ Bool radeon_glamor_prepare_access(PixmapPtr pixmap, glamor_access_t access)
 	struct radeon_bo *bo;
 	int ret;
 
-	if (access == GLAMOR_GPU_ACCESS_RW || access == GLAMOR_GPU_ACCESS_RO)
-		return info->ChipFamily < CHIP_FAMILY_TAHITI;
+	if (access == GLAMOR_GPU_ACCESS_RW || access == GLAMOR_GPU_ACCESS_RO) {
+		if (info->ChipFamily < CHIP_FAMILY_TAHITI)
+			return TRUE;
+
+		return info->accel_state->force;
+	}
 
 	bo = radeon_get_pixmap_bo(pixmap);
 	if (bo) {

commit 40b87f0e9db2642ca8a70e994fb4d3742e199640
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Wed Sep 12 18:44:10 2012 +0200

    glamor: Fix DRI2 crash introduced by PRIME changes.
    
    Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 02fe66d..7c5898c 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -358,7 +358,7 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
         pixmap->refcnt++;
     }
 
-    if (!pixmap && attachment != DRI2BufferFrontLeft) {
+    if (!pixmap && (is_glamor_pixmap || attachment != DRI2BufferFrontLeft)) {
 	/* tile the back buffer */
 	switch(attachment) {
 	case DRI2BufferDepth:

commit 646ffd49d2cf0d3130301e8ad2f49f620bd9ef1b
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Sep 10 15:31:06 2012 +1000

    radeon: fix build against old servers
    
    Fixes https://bugs.freedesktop.org/show_bug.cgi?id=54711
    
    Reported-by: wolput@onsneteindhoven.nl
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 94aa19c..2842a23 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -954,7 +954,11 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 	if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE;
     }
 
-    if (!pScrn->is_gpu && pScrn->modes == NULL) {
+    if (pScrn->modes == NULL
+#ifdef XSERVER_PLATFORM_BUS
+        && !pScrn->is_gpu
+#endif
+        ) {
       xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
       goto fail;
    }

commit 7c7f2775604da61537c24c249884aaa220e06e13
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Sep 10 11:27:45 2012 +1000

    radeon: don't fail to load if we have no modes and gpu driver.
    
    This ensures radeon loads on output less GPUs as a GPU driver.
    
    There are server bugs that also need to be fixed.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index e953082..94aa19c 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -954,7 +954,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 	if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE;
     }
 
-    if (pScrn->modes == NULL) {
+    if (!pScrn->is_gpu && pScrn->modes == NULL) {
       xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
       goto fail;
    }

commit 7fe16dd037ac688726869816888bd77fe4356f8e
Author: Dave Airlie <airlied@gmail.com>
Date:   Wed Sep 5 10:41:51 2012 +1000

    radeon: fix typo in glamor paths
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54519
    
    Reported-By: scaty@dcinformatique.com
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/radeon.h b/src/radeon.h
index b0676d4..eb46db2 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -637,7 +637,7 @@ static inline Bool radeon_get_pixmap_shared(PixmapPtr pPix)
 
     if (info->use_glamor) {
         ErrorF("glamor sharing todo\n");
-	return FALSE:
+	return FALSE;
     } else
 #endif
     {

commit cdc985e9190ce54dc6274ebc0e87ab954b15bb0d
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Sep 4 18:18:50 2012 +1000

    radeon: fix build against older servers
    
    Another silly one.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 81cb5ba..e953082 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -289,7 +289,9 @@ static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 	radeon_glamor_flush(pScrn);
 
     radeon_cs_flush_indirect(pScrn);
+#ifdef RADEON_PIXMAP_SHARING
     radeon_dirty_update(pScreen);
+#endif
 }
 
 static void

commit bd0e9c51407cb99f1fe4f0acfedc37ee0c354040
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Sep 4 18:17:06 2012 +1000

    radeon/dri2: fix build against older servers.
    
    Older servers won't have DRI2UpdatePrime, so fix build.
    
    bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54433
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index f6f5fd5..02fe66d 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -63,6 +63,10 @@
 #define USE_DRI2_SCHEDULING
 #endif
 
+#if DRI2INFOREC_VERSION >= 9
+#define USE_DRI2_PRIME
+#endif
+
 #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,6,99,0, 0)
 typedef DRI2BufferPtr BufferPtr;
 #else
@@ -578,6 +582,7 @@ radeon_dri2_copy_region2(ScreenPtr pScreen,
         src_drawable = drawable;
     }
     if (dst_private->attachment == DRI2BufferFrontLeft) {
+#ifdef USE_DRI2_PRIME
 	if (drawable->pScreen != pScreen) {
 	    dst_drawable = DRI2UpdatePrime(drawable, dest_buffer);
 	    if (!dst_drawable)
@@ -586,6 +591,7 @@ radeon_dri2_copy_region2(ScreenPtr pScreen,
 	    if (dst_drawable != drawable)
 		translate = TRUE;
 	} else
+#endif
 	    dst_drawable = drawable;
     }
 

commit 75c1f62f44d7b3709c1fa103d59733866967b841
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Sep 3 13:09:02 2012 +1000

    radeon: add capability and provider support
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 6a35728..9b9fc83 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1549,6 +1549,10 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 	/* workout clones */
 	drmmode_clones_init(pScrn, drmmode);
 
+#ifdef RADEON_PIXMAP_SHARING
+	xf86ProviderSetup(pScrn, NULL, "radeon");
+#endif
+
 	xf86InitialConfiguration(pScrn, TRUE);
 
 	drmmode->event_context.version = DRM_EVENT_CONTEXT_VERSION;
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 09aea7e..81cb5ba 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -715,6 +715,24 @@ static Bool r600_get_tile_config(ScrnInfoPtr pScrn)
 
 #endif /* EXA_MIXED_PIXMAPS */
 
+static void RADEONSetupCapabilities(ScrnInfoPtr pScrn)
+{
+#ifdef RADEON_PIXMAP_SHARING
+    RADEONInfoPtr  info = RADEONPTR(pScrn);
+    uint64_t value;
+    int ret;
+
+    pScrn->capabilities = 0;
+    ret = drmGetCap(info->dri2.drm_fd, DRM_CAP_PRIME, &value);
+    if (ret == 0) {
+	if (value & DRM_PRIME_CAP_EXPORT)
+	    pScrn->capabilities |= RR_Capability_SourceOutput | RR_Capability_SinkOffload;
+	if (value & DRM_PRIME_CAP_IMPORT)
+	    pScrn->capabilities |= RR_Capability_SourceOffload;
+    }
+#endif
+}
+
 Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 {
     RADEONInfoPtr     info;
@@ -797,6 +815,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 
     info->allowColorTiling2D = FALSE;
 
+    RADEONSetupCapabilities(pScrn);
 #ifdef EXA_MIXED_PIXMAPS
     /* don't enable tiling if accel is not enabled */
     if (!info->r600_shadow_fb) {

commit ca8b61e916998458203dfa4b9d0c997fa7d90ba9
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Sep 3 13:08:37 2012 +1000

    radeon: allocated shared pixmaps as untiled gtt.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c
index ccdf7eb..593c690 100644
--- a/src/radeon_bo_helper.c
+++ b/src/radeon_bo_helper.c
@@ -73,7 +73,7 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth,
     uint32_t tiling = 0;
     struct radeon_surface surface;
     struct radeon_bo *bo;
-
+    int domain = RADEON_GEM_DOMAIN_VRAM;
     if (usage_hint) {
 	if (info->allowColorTiling) {
 	    if (usage_hint & RADEON_CREATE_PIXMAP_TILING_MACRO)
@@ -84,6 +84,12 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth,
 	if (usage_hint & RADEON_CREATE_PIXMAP_DEPTH)
 		tiling |= RADEON_TILING_MACRO | RADEON_TILING_MICRO;
 
+#ifdef CREATE_PIXMAP_USAGE_SHARED
+	if ((usage_hint & 0xffff) == CREATE_PIXMAP_USAGE_SHARED) {
+		tiling = 0;
+		domain = RADEON_GEM_DOMAIN_GTT;
+	}
+#endif
     }
 
     /* Small pixmaps must not be macrotiled on R300, hw cannot sample them
@@ -166,7 +172,7 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth,
 	}
 
     bo = radeon_bo_open(info->bufmgr, 0, size, base_align,
-			RADEON_GEM_DOMAIN_VRAM, 0);
+			domain, 0);
 
     if (bo && tiling && radeon_bo_set_tiling(bo, tiling, pitch) == 0)
 	*new_tiling = tiling;

commit 8c1bf9d8fe3948b72795984e625ef46b2f0bf654
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Sep 3 13:08:05 2012 +1000

    radeon: add pixmap sharing hooks.
    
    This hooks into EXA and the dirty tracking to add sharing and output
    offload support.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/evergreen_exa.c b/src/evergreen_exa.c
index 40e2e96..883fa5c 100644
--- a/src/evergreen_exa.c
+++ b/src/evergreen_exa.c
@@ -1908,7 +1908,10 @@ EVERGREENDrawInit(ScreenPtr pScreen)
 #if (EXA_VERSION_MAJOR == 2 && EXA_VERSION_MINOR >= 5)
     info->accel_state->exa->CreatePixmap2 = RADEONEXACreatePixmap2;
 #endif
-
+#if (EXA_VERSION_MAJOR == 2 && EXA_VERSION_MINOR >= 6) 
+    info->accel_state->exa->SharePixmapBacking = RADEONEXASharePixmapBacking; 
+    info->accel_state->exa->SetSharedPixmapBacking = RADEONEXASetSharedPixmapBacking;
+#endif
     info->accel_state->exa->flags = EXA_OFFSCREEN_PIXMAPS;
 #ifdef EXA_SUPPORTS_PREPARE_AUX
     info->accel_state->exa->flags |= EXA_SUPPORTS_PREPARE_AUX;
diff --git a/src/evergreen_state.h b/src/evergreen_state.h
index c92393e..3ce2bf2 100644
--- a/src/evergreen_state.h
+++ b/src/evergreen_state.h
@@ -350,5 +350,7 @@ extern void *RADEONEXACreatePixmap2(ScreenPtr pScreen, int width, int height,
 extern void RADEONEXADestroyPixmap(ScreenPtr pScreen, void *driverPriv);
 extern struct radeon_bo *radeon_get_pixmap_bo(PixmapPtr pPix);
 extern Bool RADEONEXAPixmapIsOffscreen(PixmapPtr pPix);
+extern Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr slave, void **handle_p);
+extern Bool RADEONEXASetSharedPixmapBacking(PixmapPtr ppix, void *handle);
 
 #endif
diff --git a/src/r600_exa.c b/src/r600_exa.c
index be0a9fa..21df084 100644
--- a/src/r600_exa.c
+++ b/src/r600_exa.c
@@ -1888,6 +1888,10 @@ R600DrawInit(ScreenPtr pScreen)
     info->accel_state->exa->DownloadFromScreen = R600DownloadFromScreenCS;
 #if (EXA_VERSION_MAJOR == 2 && EXA_VERSION_MINOR >= 5)
     info->accel_state->exa->CreatePixmap2 = RADEONEXACreatePixmap2;
+#if (EXA_VERSION_MAJOR == 2 && EXA_VERSION_MINOR >= 6) 
+    info->accel_state->exa->SharePixmapBacking = RADEONEXASharePixmapBacking; 
+    info->accel_state->exa->SetSharedPixmapBacking = RADEONEXASetSharedPixmapBacking;
+#endif
 #endif
 #endif
 
diff --git a/src/r600_state.h b/src/r600_state.h
index 74b481c..fa777e8 100644
--- a/src/r600_state.h
+++ b/src/r600_state.h
@@ -321,6 +321,6 @@ extern void *RADEONEXACreatePixmap2(ScreenPtr pScreen, int width, int height,
 extern void RADEONEXADestroyPixmap(ScreenPtr pScreen, void *driverPriv);
 extern struct radeon_bo *radeon_get_pixmap_bo(PixmapPtr pPix);
 extern Bool RADEONEXAPixmapIsOffscreen(PixmapPtr pPix);
-
-
+extern Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr slave, void **handle_p);
+extern Bool RADEONEXASetSharedPixmapBacking(PixmapPtr ppix, void *handle);
 #endif
diff --git a/src/radeon.h b/src/radeon.h
index 2eac38e..b0676d4 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -527,6 +527,10 @@ extern void radeon_ddx_cs_start(ScrnInfoPtr pScrn,
 				const char *func, int line);
 void radeon_kms_update_vram_limit(ScrnInfoPtr pScrn, int new_fb_size);
 
+#if XF86_CRTC_VERSION >= 5
+#define RADEON_PIXMAP_SHARING 1
+#endif
+
 static inline struct radeon_surface *radeon_get_pixmap_surface(PixmapPtr pPix)
 {
 #ifdef USE_GLAMOR
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index 5c5d997..0c42735 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -41,7 +41,7 @@
 #include "radeon_probe.h"
 #include "radeon_version.h"
 #include "radeon_exa_shared.h"
-
+#include "radeon_bo_gem.h"
 #include "xf86.h"
 
 
@@ -325,6 +325,79 @@ void RADEONEXADestroyPixmap(ScreenPtr pScreen, void *driverPriv)
     free(driverPriv);
 }
 
+#ifdef RADEON_PIXMAP_SHARING
+Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr slave, void **fd_handle)
+{
+    struct radeon_exa_pixmap_priv *driver_priv;
+    int ret;
+    int handle;
+
+    driver_priv = exaGetPixmapDriverPrivate(ppix);
+
+    ret = radeon_gem_prime_share_bo(driver_priv->bo, &handle);
+    if (ret)
+	return FALSE;
+
+    driver_priv->shared = TRUE;
+    *fd_handle = (void *)(long)handle;
+    return TRUE;
+}
+
+Bool RADEONEXASetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle)
+{
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(ppix->drawable.pScreen);
+    RADEONInfoPtr info = RADEONPTR(pScrn);
+    struct radeon_exa_pixmap_priv *driver_priv;
+    struct radeon_bo *bo;
+    int ihandle = (int)(long)fd_handle;
+    uint32_t size = ppix->devKind * ppix->drawable.height;
+    struct radeon_surface surface;
+
+    driver_priv = exaGetPixmapDriverPrivate(ppix);
+
+    bo = radeon_gem_bo_open_prime(info->bufmgr, ihandle, size);
+    if (!bo)
+        return FALSE;
+
+    memset(&surface, 0, sizeof(struct radeon_surface));
+	
+    if (info->ChipFamily >= CHIP_FAMILY_R600 && info->surf_man) {
+
+	surface.npix_x = ppix->drawable.width;
+	surface.npix_y = ppix->drawable.height;
+	surface.npix_z = 1;
+	surface.blk_w = 1;
+	surface.blk_h = 1;
+	surface.blk_d = 1;
+	surface.array_size = 1;
+	surface.bpe = ppix->drawable.bitsPerPixel / 8;
+	surface.nsamples = 1;
+	surface.flags |= RADEON_SURF_SET(RADEON_SURF_TYPE_2D, TYPE);
+	surface.flags |= RADEON_SURF_SET(RADEON_SURF_MODE_LINEAR, MODE);
+	if (radeon_surface_best(info->surf_man, &surface)) {
+	    return FALSE;
+	}
+	if (radeon_surface_init(info->surf_man, &surface)) {
+	    return FALSE;
+	}
+	/* we have to post hack the surface to reflect the actual size
+	   of the shared pixmap */
+	surface.level[0].pitch_bytes = ppix->devKind;
+	surface.level[0].nblk_x = ppix->devKind / surface.bpe;
+    }
+    driver_priv->surface = surface;
+    driver_priv->shared = TRUE;
+    driver_priv->tiling_flags = 0;
+    radeon_set_pixmap_bo(ppix, bo);
+
+    close(ihandle);
+    /* we have a reference from the alloc and one from set pixmap bo,
+       drop one */
+    radeon_bo_unref(bo);
+    return TRUE;
+}
+#endif
+
 uint32_t radeon_get_pixmap_tiling(PixmapPtr pPix)
 {
     struct radeon_exa_pixmap_priv *driver_priv;
diff --git a/src/radeon_exa_funcs.c b/src/radeon_exa_funcs.c
index db44d94..2533d78 100644
--- a/src/radeon_exa_funcs.c
+++ b/src/radeon_exa_funcs.c
@@ -655,6 +655,10 @@ Bool RADEONDrawInit(ScreenPtr pScreen)
     info->accel_state->exa->FinishAccess = RADEONFinishAccess_CS;
 #if (EXA_VERSION_MAJOR == 2 && EXA_VERSION_MINOR >= 5)
     info->accel_state->exa->CreatePixmap2 = RADEONEXACreatePixmap2;
+#if (EXA_VERSION_MAJOR == 2 && EXA_VERSION_MINOR >= 6) 
+    info->accel_state->exa->SharePixmapBacking = RADEONEXASharePixmapBacking; 
+    info->accel_state->exa->SetSharedPixmapBacking = RADEONEXASetSharedPixmapBacking;
+#endif
 #endif
 #endif
 
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 2107640..09aea7e 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -241,6 +241,40 @@ static Bool RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
     return TRUE;
 }
 
+#ifdef RADEON_PIXMAP_SHARING
+static void
+redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)
+{
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
+	RegionRec pixregion;
+
+	PixmapRegionInit(&pixregion, dirty->slave_dst->master_pixmap);
+	PixmapSyncDirtyHelper(dirty, &pixregion);
+
+	radeon_cs_flush_indirect(pScrn);
+	DamageRegionAppend(&dirty->slave_dst->drawable, &pixregion);
+	RegionUninit(&pixregion);
+}
+
+static void
+radeon_dirty_update(ScreenPtr screen)
+{
+	RegionPtr region;
+	PixmapDirtyUpdatePtr ent;
+
+	if (xorg_list_is_empty(&screen->pixmap_dirty_list))
+		return;
+
+	xorg_list_for_each_entry(ent, &screen->pixmap_dirty_list, ent) {
+		region = DamageRegion(ent->damage);
+		if (RegionNotEmpty(region)) {
+			redisplay_dirty(screen, ent);
+			DamageEmpty(ent->damage);
+		}
+	}
+}
+#endif
+
 static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 {
     SCREEN_PTR(arg);
@@ -255,6 +289,7 @@ static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 	radeon_glamor_flush(pScrn);
 
     radeon_cs_flush_indirect(pScrn);
+    radeon_dirty_update(pScreen);
 }
 
 static void
@@ -1242,6 +1277,11 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
     info->CreateScreenResources = pScreen->CreateScreenResources;
     pScreen->CreateScreenResources = RADEONCreateScreenResources_KMS;
 
+#ifdef RADEON_PIXMAP_SHARING
+    pScreen->StartPixmapTracking = PixmapStartDirtyTracking;
+    pScreen->StopPixmapTracking = PixmapStopDirtyTracking;
+#endif
+
    if (!xf86CrtcScreenInit (pScreen))
        return FALSE;
 

commit 3add8df8122697acfe126d4857f3946ce44b8305
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Sep 3 13:07:07 2012 +1000

    radeon: add dri2 offload support.
    
    This adds the new dri2 interfaces required for radeon to be offloaded to.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 496c669..f6f5fd5 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -315,11 +315,11 @@ radeon_dri2_create_buffers(DrawablePtr drawable,
 }
 #else
 static BufferPtr
-radeon_dri2_create_buffer(DrawablePtr drawable,
-                          unsigned int attachment,
-                          unsigned int format)
+radeon_dri2_create_buffer2(ScreenPtr pScreen,
+			   DrawablePtr drawable,
+			   unsigned int attachment,
+			   unsigned int format)
 {
-    ScreenPtr pScreen = drawable->pScreen;
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     RADEONInfoPtr info = RADEONPTR(pScrn);
     BufferPtr buffers;
@@ -340,7 +340,9 @@ radeon_dri2_create_buffer(DrawablePtr drawable,
 
     if (attachment == DRI2BufferFrontLeft) {
         pixmap = get_drawable_pixmap(drawable);
-	if (info->use_glamor && !radeon_get_pixmap_bo(pixmap)) {
+	if (pScreen != pixmap->drawable.pScreen)
+	    pixmap = NULL;
+	else if (info->use_glamor && !radeon_get_pixmap_bo(pixmap)) {
 	    is_glamor_pixmap = TRUE;
 	    aligned_width = pixmap->drawable.width;
 	    height = pixmap->drawable.height;
@@ -352,7 +354,7 @@ radeon_dri2_create_buffer(DrawablePtr drawable,
         pixmap->refcnt++;
     }
 
-    if (!pixmap) {
+    if (!pixmap && attachment != DRI2BufferFrontLeft) {
 	/* tile the back buffer */
 	switch(attachment) {
 	case DRI2BufferDepth:
@@ -425,9 +427,6 @@ radeon_dri2_create_buffer(DrawablePtr drawable,
 					      flags | RADEON_CREATE_PIXMAP_DRI2);
     }
 
-    if (!pixmap)
-        return NULL;
-
     buffers = calloc(1, sizeof *buffers);
     if (buffers == NULL)
         goto error;
@@ -435,24 +434,30 @@ radeon_dri2_create_buffer(DrawablePtr drawable,
     if (attachment == DRI2BufferDepth) {
         depth_pixmap = pixmap;
     }
-    if (!info->use_glamor) {
-	info->exa_force_create = TRUE;
-	exaMoveInPixmap(pixmap);
-	info->exa_force_create = FALSE;
+
+    if (pixmap) {
+	if (!info->use_glamor) {
+	    info->exa_force_create = TRUE;
+	    exaMoveInPixmap(pixmap);
+	    info->exa_force_create = FALSE;
+	}
+
+	if (is_glamor_pixmap)
+	    pixmap = fixup_glamor(drawable, pixmap);
+	bo = radeon_get_pixmap_bo(pixmap);
+	if (!bo || radeon_gem_get_kernel_name(bo, &buffers->name) != 0)
+	    goto error;
     }
-    if (is_glamor_pixmap)
-	pixmap = fixup_glamor(drawable, pixmap);
-    bo = radeon_get_pixmap_bo(pixmap);
-    if (!bo || radeon_gem_get_kernel_name(bo, &buffers->name) != 0)
-        goto error;
 
     privates = calloc(1, sizeof(struct dri2_buffer_priv));
     if (privates == NULL)
         goto error;
 
     buffers->attachment = attachment;
-    buffers->pitch = pixmap->devKind;
-    buffers->cpp = pixmap->drawable.bitsPerPixel / 8;
+    if (pixmap) {
+	buffers->pitch = pixmap->devKind;
+	buffers->cpp = pixmap->drawable.bitsPerPixel / 8;
+    }
     buffers->driverPrivate = privates;
     buffers->format = format;
     buffers->flags = 0; /* not tiled */
@@ -468,6 +473,14 @@ error:
         (*pScreen->DestroyPixmap)(pixmap);
     return NULL;
 }
+
+DRI2BufferPtr
+radeon_dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment,
+			   unsigned int format)
+{
+	return radeon_dri2_create_buffer2(pDraw->pScreen, pDraw,
+					  attachment, format);
+}
 #endif
 
 #ifndef USE_DRI2_1_1_0
@@ -491,11 +504,11 @@ radeon_dri2_destroy_buffers(DrawablePtr drawable,
 }
 #else
 static void
-radeon_dri2_destroy_buffer(DrawablePtr drawable, BufferPtr buffers)
+radeon_dri2_destroy_buffer2(ScreenPtr pScreen,
+			    DrawablePtr drawable, BufferPtr buffers)
 {
     if(buffers)
     {
-        ScreenPtr pScreen = drawable->pScreen;
         struct dri2_buffer_priv *private = buffers->driverPrivate;
 
         /* Trying to free an already freed buffer is unlikely to end well */
@@ -511,24 +524,41 @@ radeon_dri2_destroy_buffer(DrawablePtr drawable, BufferPtr buffers)
         private->refcnt--;
         if (private->refcnt == 0)
         {
-            (*pScreen->DestroyPixmap)(private->pixmap);
+	    if (private->pixmap)
+                (*pScreen->DestroyPixmap)(private->pixmap);
 
             free(buffers->driverPrivate);
             free(buffers);
         }
     }
 }
+
+void
+radeon_dri2_destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buf)
+{
+    radeon_dri2_destroy_buffer2(pDraw->pScreen, pDraw, buf);
+}
 #endif
 
+
+static inline PixmapPtr GetDrawablePixmap(DrawablePtr drawable)
+{
+    if (drawable->type == DRAWABLE_PIXMAP)
+        return (PixmapPtr)drawable;
+    else {
+        struct _Window *pWin = (struct _Window *)drawable;
+        return drawable->pScreen->GetWindowPixmap(pWin);
+    }
+}
 static void
-radeon_dri2_copy_region(DrawablePtr drawable,
-                        RegionPtr region,
-                        BufferPtr dest_buffer,
-                        BufferPtr src_buffer)
+radeon_dri2_copy_region2(ScreenPtr pScreen,
+			 DrawablePtr drawable,
+			 RegionPtr region,
+			 BufferPtr dest_buffer,
+			 BufferPtr src_buffer)
 {
     struct dri2_buffer_priv *src_private = src_buffer->driverPrivate;
     struct dri2_buffer_priv *dst_private = dest_buffer->driverPrivate;
-    ScreenPtr pScreen = drawable->pScreen;
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DrawablePtr src_drawable;
     DrawablePtr dst_drawable;
@@ -536,20 +566,42 @@ radeon_dri2_copy_region(DrawablePtr drawable,
     GCPtr gc;
     RADEONInfoPtr info = RADEONPTR(pScrn);
     Bool vsync;
+    Bool translate = FALSE;
+    int off_x = 0, off_y = 0;
+    PixmapPtr dst_ppix;
+
+    dst_ppix = dst_private->pixmap;
+    src_drawable = &src_private->pixmap->drawable;
+    dst_drawable = &dst_private->pixmap->drawable;
 
     if (src_private->attachment == DRI2BufferFrontLeft) {
         src_drawable = drawable;
-    } else {
-        src_drawable = &src_private->pixmap->drawable;
     }
     if (dst_private->attachment == DRI2BufferFrontLeft) {
-        dst_drawable = drawable;
-    } else {
-        dst_drawable = &dst_private->pixmap->drawable;
+	if (drawable->pScreen != pScreen) {
+	    dst_drawable = DRI2UpdatePrime(drawable, dest_buffer);
+	    if (!dst_drawable)
+		return;
+	    dst_ppix = (PixmapPtr)dst_drawable;
+	    if (dst_drawable != drawable)
+		translate = TRUE;
+	} else
+	    dst_drawable = drawable;
+    }
+
+    if (translate && drawable->type == DRAWABLE_WINDOW) {
+	WindowPtr pWin = (WindowPtr)drawable;
+	off_x = pWin->origin.x;
+	off_y = pWin->origin.y;
     }
     gc = GetScratchGC(dst_drawable->depth, pScreen);
     copy_clip = REGION_CREATE(pScreen, NULL, 0);
     REGION_COPY(pScreen, copy_clip, region);
+
+    if (translate) {
+	REGION_TRANSLATE(pScreen, copy_clip, off_x, off_y);
+    }
+
     (*gc->funcs->ChangeClip) (gc, CT_REGION, copy_clip, 0);
     ValidateGC(dst_drawable, gc);
 
@@ -563,7 +615,7 @@ radeon_dri2_copy_region(DrawablePtr drawable,
 	    if (extents->x1 == 0 && extents->y1 == 0 &&
 		extents->x2 == drawable->width &&
 		extents->y2 == drawable->height) {
-		struct radeon_bo *bo = radeon_get_pixmap_bo(dst_private->pixmap);
+		struct radeon_bo *bo = radeon_get_pixmap_bo(dst_ppix);
 
 		if (bo)
 		    radeon_bo_wait(bo);
@@ -577,13 +629,20 @@ radeon_dri2_copy_region(DrawablePtr drawable,
     info->accel_state->vsync = info->swapBuffersWait;
 
     (*gc->ops->CopyArea)(src_drawable, dst_drawable, gc,
-                         0, 0, drawable->width, drawable->height, 0, 0);
+                         0, 0, drawable->width, drawable->height, off_x, off_y);
 
     info->accel_state->vsync = vsync;
 
     FreeScratchGC(gc);
 }
 
+void
+radeon_dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
+			 DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer)
+{
+    return radeon_dri2_copy_region2(pDraw->pScreen, pDraw, pRegion,
+				     pDstBuffer, pSrcBuffer);
+}
 
 #ifdef USE_DRI2_SCHEDULING
 
@@ -1500,6 +1559,13 @@ radeon_dri2_screen_init(ScreenPtr pScreen)
     }
 #endif
 
+#if DRI2INFOREC_VERSION >= 9
+    dri2_info.version = 9;
+    dri2_info.CreateBuffer2 = radeon_dri2_create_buffer2;
+    dri2_info.DestroyBuffer2 = radeon_dri2_destroy_buffer2;
+    dri2_info.CopyRegion2 = radeon_dri2_copy_region2;
+#endif
+
     info->dri2.enabled = DRI2ScreenInit(pScreen, &dri2_info);
     return info->dri2.enabled;
 }

commit f7502a11c8ef9c453ceb40d26109977116df88c2
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Sep 3 12:56:56 2012 +1000

    radeon: add shared support to pixmaps.
    
    this just adds the interface and shared support to the pixmap.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/evergreen_exa.c b/src/evergreen_exa.c
index f906cbf..40e2e96 100644
--- a/src/evergreen_exa.c
+++ b/src/evergreen_exa.c
@@ -480,7 +480,10 @@ EVERGREENPrepareCopy(PixmapPtr pSrc,   PixmapPtr pDst,
     dst_obj.width = pDst->drawable.width;
     dst_obj.height = pDst->drawable.height;
     dst_obj.bpp = pDst->drawable.bitsPerPixel;
-    dst_obj.domain = RADEON_GEM_DOMAIN_VRAM;
+    if (radeon_get_pixmap_shared(pDst) == TRUE)
+	dst_obj.domain = RADEON_GEM_DOMAIN_GTT;
+    else
+	dst_obj.domain = RADEON_GEM_DOMAIN_VRAM;
 
     if (!R600SetAccelState(pScrn,
 			   &src_obj,
@@ -1157,7 +1160,10 @@ static Bool EVERGREENPrepareComposite(int op, PicturePtr pSrcPicture,
     dst_obj.width = pDst->drawable.width;
     dst_obj.height = pDst->drawable.height;
     dst_obj.bpp = pDst->drawable.bitsPerPixel;
-    dst_obj.domain = RADEON_GEM_DOMAIN_VRAM;
+    if (radeon_get_pixmap_shared(pDst) == TRUE)
+	dst_obj.domain = RADEON_GEM_DOMAIN_GTT;
+    else
+	dst_obj.domain = RADEON_GEM_DOMAIN_VRAM;
 
     if (pMaskPicture) {
 	if (!pMask) {
diff --git a/src/r600_exa.c b/src/r600_exa.c
index 61b6315..be0a9fa 100644
--- a/src/r600_exa.c
+++ b/src/r600_exa.c
@@ -551,7 +551,10 @@ R600PrepareCopy(PixmapPtr pSrc,   PixmapPtr pDst,
     dst_obj.width = pDst->drawable.width;
     dst_obj.height = pDst->drawable.height;
     dst_obj.bpp = pDst->drawable.bitsPerPixel;
-    dst_obj.domain = RADEON_GEM_DOMAIN_VRAM;
+    if (radeon_get_pixmap_shared(pDst) == TRUE) {
+	dst_obj.domain = RADEON_GEM_DOMAIN_GTT;
+    } else
+	dst_obj.domain = RADEON_GEM_DOMAIN_VRAM;
 
     if (!R600SetAccelState(pScrn,
 			   &src_obj,
@@ -1203,7 +1206,10 @@ static Bool R600PrepareComposite(int op, PicturePtr pSrcPicture,
     dst_obj.width = pDst->drawable.width;
     dst_obj.height = pDst->drawable.height;
     dst_obj.bpp = pDst->drawable.bitsPerPixel;
-    dst_obj.domain = RADEON_GEM_DOMAIN_VRAM;
+    if (radeon_get_pixmap_shared(pDst) == TRUE)
+	dst_obj.domain = RADEON_GEM_DOMAIN_GTT;
+    else
+	dst_obj.domain = RADEON_GEM_DOMAIN_VRAM;
 
     if (pMaskPicture) {
 	if (!pMask) {
diff --git a/src/radeon.h b/src/radeon.h
index 2f05249..2eac38e 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -249,6 +249,7 @@ struct radeon_exa_pixmap_priv {
     uint32_t tiling_flags;


Reply to: