xf86-video-intel: Branch 'intel-batchbuffer' - 3 commits - configure.ac src/check-remap.sh src/dri_bufmgr.c src/dri_bufmgr_compat.h src/dri_bufmgr.h src/dri_bufmgr_remap.h src/i830_accel.c src/i830_common.h src/i830_display.c src/i830_dri.c src/i830_driver.c src/i830_exa.c src/i830.h src/i830_memory.c src/i830_render.c src/i915_render.c src/i965_render.c src/intel_batchbuffer.c src/intel_batchbuffer.h src/intel_bufmgr_ttm.c src/intel_bufmgr_ttm.h src/Makefile.am
Kristian Høgsberg
krh at kemper.freedesktop.org
Thu Feb 14 16:59:43 PST 2008
configure.ac | 17 +
src/Makefile.am | 8
src/check-remap.sh | 29 +
src/dri_bufmgr.c | 50 +--
src/dri_bufmgr.h | 126 +++++---
src/dri_bufmgr_compat.h | 37 ++
src/dri_bufmgr_remap.h | 55 +++
src/i830.h | 26 +
src/i830_accel.c | 4
src/i830_common.h | 25 -
src/i830_display.c | 7
src/i830_dri.c | 364 +++++++++++++++++++----
src/i830_driver.c | 141 ++++++---
src/i830_exa.c | 88 ++++-
src/i830_memory.c | 13
src/i830_render.c | 8
src/i915_render.c | 8
src/i965_render.c | 42 +-
src/intel_batchbuffer.c | 26 -
src/intel_batchbuffer.h | 15
src/intel_bufmgr_ttm.c | 740 ++++++++++++++++++++++--------------------------
src/intel_bufmgr_ttm.h | 6
22 files changed, 1180 insertions(+), 655 deletions(-)
New commits:
commit dfffdafca765fd54ef01e1fa1332767602507c29
Author: Kristian Høgsberg <krh at redhat.com>
Date: Wed Feb 6 12:15:21 2008 -0500
Implement DRI2 support.
diff --git a/configure.ac b/configure.ac
index 334a1f4..0e35d66 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,11 @@ AC_ARG_ENABLE(dri, AC_HELP_STRING([--disable-dri],
[DRI="$enableval"],
[DRI=auto])
+AC_ARG_ENABLE(dri2, AC_HELP_STRING([--disable-dri2],
+ [Disable DRI2 support [[default=auto]]]),
+ [DRI="$enableval"],
+ [DRI=auto])
+
AC_ARG_ENABLE(video-debug, AC_HELP_STRING([--enable-video-debug],
[Enable video debugging support [[default=no]]]),
[VIDEO_DEBUG="$enableval"],
@@ -106,6 +111,10 @@ if test x$DRI = xauto; then
fi
AC_MSG_RESULT([$DRI])
+if test "$DRI2" != no; then
+ AC_CHECK_FILE([${sdkdir}/dri2.h], [DRI2="yes"], [DRI2="no"])
+fi
+
save_CFLAGS="$CFLAGS"
CFLAGS="$XORG_CFLAGS"
AC_CHECK_HEADER(xf86Modes.h,[XMODES=yes],[XMODES=no],[#include "xorg-server.h"])
@@ -203,6 +212,14 @@ if test "$DRI" = yes; then
CFLAGS="$save_CFLAGS"
fi
+AM_CONDITIONAL(DRI2, test x$DRI2 = xyes)
+if test "$DRI2" = yes; then
+ PKG_CHECK_MODULES(DRI2, [libdrm >= 2.3.1])
+ AC_DEFINE(DRI2,1,[Enable DRI driver support])
+ AC_DEFINE(XF86DRI_MM,1,[Extended DRI memory management])
+fi
+
+
AM_CONDITIONAL(VIDEO_DEBUG, test x$VIDEO_DEBUG = xyes)
if test "$VIDEO_DEBUG" = yes; then
AC_DEFINE(VIDEO_DEBUG,1,[Enable debug support])
diff --git a/src/dri_bufmgr.c b/src/dri_bufmgr.c
index fc9871a..9d7632e 100644
--- a/src/dri_bufmgr.c
+++ b/src/dri_bufmgr.c
@@ -83,6 +83,12 @@ dri_bo_map(dri_bo *buf, GLboolean write_enable)
return buf->bufmgr->bo_map(buf, write_enable);
}
+unsigned int
+dri_bo_get_handle(dri_bo *buf)
+{
+ return buf->bufmgr->bo_get_handle(buf);
+}
+
int
dri_bo_unmap(dri_bo *buf)
{
diff --git a/src/dri_bufmgr.h b/src/dri_bufmgr.h
index 77ef0f6..710a343 100644
--- a/src/dri_bufmgr.h
+++ b/src/dri_bufmgr.h
@@ -119,6 +119,9 @@ struct _dri_bufmgr {
/** Reduces the refcount on the userspace mapping of the buffer object. */
int (*bo_unmap)(dri_bo *buf);
+ /** Get the handle of the underlying DRM buffer object, if available . */
+ unsigned int (*bo_get_handle)(dri_bo *buf);
+
/** Takes a reference on a fence object */
void (*fence_reference)(dri_fence *fence);
@@ -191,6 +194,7 @@ void dri_bo_reference(dri_bo *bo);
void dri_bo_unreference(dri_bo *bo);
int dri_bo_map(dri_bo *buf, GLboolean write_enable);
int dri_bo_unmap(dri_bo *buf);
+unsigned int dri_bo_get_handle(dri_bo *buf);
void dri_fence_wait(dri_fence *fence);
void dri_fence_reference(dri_fence *fence);
void dri_fence_unreference(dri_fence *fence);
diff --git a/src/i830.h b/src/i830.h
index e237c42..f66b5a7 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -87,6 +87,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef I830_USE_EXA
#include "exa.h"
Bool I830EXAInit(ScreenPtr pScreen);
+unsigned int I830EXAGetPixmapHandle(PixmapPtr pPix, unsigned int *flags);
#define EXA_LINEAR_EXTRA (64*1024)
unsigned long long I830TexOffsetStart(PixmapPtr pPix);
#endif
@@ -351,6 +352,12 @@ enum backlight_control {
BCM_KERNEL,
};
+enum dri_type {
+ DRI_TYPE_NONE,
+ DRI_TYPE_XF86DRI,
+ DRI_TYPE_DRI2
+};
+
typedef struct _I830Rec {
unsigned char *MMIOBase;
unsigned char *GTTBase;
@@ -511,7 +518,7 @@ typedef struct _I830Rec {
PixmapPtr texture_pixmaps[2];
Bool directRenderingDisabled; /* DRI disabled in PreInit. */
- Bool directRenderingEnabled; /* DRI enabled this generation. */
+ enum dri_type directRendering; /* Type of DRI enabled this generation. */
#ifdef XF86DRI
Bool directRenderingOpen;
@@ -523,6 +530,11 @@ typedef struct _I830Rec {
I830ConfigPrivPtr pVisualConfigsPriv;
drm_handle_t buffer_map;
drm_handle_t ring_map;
+
+ drm_hw_lock_t *lock;
+ int lockRefCount;
+ int lockingContext;
+ drm_context_t context;
#endif
/* Broken-out options. */
@@ -717,6 +729,14 @@ extern Bool I830DRISetVBlankInterrupt (ScrnInfoPtr pScrn, Bool on);
Bool i830_update_dri_buffers(ScrnInfoPtr pScrn);
#endif
+#ifdef DRI2
+extern void I830DRI2Prepare(ScreenPtr pScreen);
+extern void I830DRI2ScreenInit(ScreenPtr pScreen);
+extern void I830DRI2CloseScreen(ScreenPtr pScreen);
+extern void I830DRI2Lock(ScreenPtr pScrn);
+extern void I830DRI2Unlock(ScreenPtr pScrn);
+#endif
+
unsigned long intel_get_pixmap_offset(PixmapPtr pPix);
unsigned long intel_get_pixmap_pitch(PixmapPtr pPix);
extern Bool I830AccelInit(ScreenPtr pScreen);
diff --git a/src/i830_accel.c b/src/i830_accel.c
index d0aff7d..eb858d4 100644
--- a/src/i830_accel.c
+++ b/src/i830_accel.c
@@ -136,7 +136,7 @@ I830WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis)
i830_dump_error_state(pScrn);
ErrorF("space: %d wanted %d\n", ring->space, n);
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering == DRI_TYPE_XF86DRI) {
DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
DRICloseScreen(screenInfo.screens[pScrn->scrnIndex]);
}
@@ -176,7 +176,7 @@ I830Sync(ScrnInfoPtr pScrn)
#ifdef XF86DRI
/* VT switching tries to do this.
*/
- if (!pI830->LockHeld && pI830->directRenderingEnabled) {
+ if (!pI830->LockHeld && pI830->directRendering != DRI_TYPE_NONE) {
return;
}
#endif
diff --git a/src/i830_common.h b/src/i830_common.h
index f3a7ea0..c914882 100644
--- a/src/i830_common.h
+++ b/src/i830_common.h
@@ -57,31 +57,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define DRM_I830_GET_VBLANK_PIPE 0x0e
#define DRM_I830_HWS_PAGE_ADDR 0x11
-
-typedef struct {
- enum {
- I830_INIT_DMA = 0x01,
- I830_CLEANUP_DMA = 0x02,
- I830_RESUME_DMA = 0x03
- } func;
- unsigned int mmio_offset;
- int sarea_priv_offset;
- unsigned int ring_start;
- unsigned int ring_end;
- unsigned int ring_size;
- unsigned int front_offset;
- unsigned int back_offset;
- unsigned int depth_offset;
- unsigned int w;
- unsigned int h;
- unsigned int pitch; /* Pitch of front buffer in units of pixels */
- unsigned int pitch_bits;
- unsigned int back_pitch;
- unsigned int depth_pitch;
- unsigned int cpp;
- unsigned int chipset;
-} drmI830Init;
-
typedef struct {
drmTextureRegion texList[I830_NR_TEX_REGIONS+1];
int last_upload; /* last time texture was uploaded */
diff --git a/src/i830_display.c b/src/i830_display.c
index d16871d..ef7e7a6 100644
--- a/src/i830_display.c
+++ b/src/i830_display.c
@@ -419,7 +419,7 @@ i830PipeSetBase(xf86CrtcPtr crtc, int x, int y)
}
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering == DRI_TYPE_XF86DRI) {
drmI830Sarea *sPriv = (drmI830Sarea *) DRIGetSAREAPrivate(pScrn->pScreen);
if (!sPriv)
@@ -770,7 +770,7 @@ i830_crtc_dpms(xf86CrtcPtr crtc, int mode)
intel_crtc->dpms_mode = mode;
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering == DRI_TYPE_XF86DRI) {
drmI830Sarea *sPriv = (drmI830Sarea *) DRIGetSAREAPrivate(pScrn->pScreen);
Bool enabled = crtc->enabled && mode != DPMSModeOff;
@@ -793,7 +793,10 @@ i830_crtc_dpms(xf86CrtcPtr crtc, int mode)
"Can't update pipe %d in SAREA\n", pipe);
break;
}
+ } else if (pI830->directRendering == DRI_TYPE_DRI2) {
+ I830DRISetVBlankInterrupt (pScrn, TRUE);
}
+
#endif
}
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 0857603..09e5247 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -85,6 +85,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "intel_bufmgr_ttm.h"
+#ifdef DRI2
+#include "dri2.h"
+#endif
+
/* This block and the corresponding configure test can be removed when
* libdrm >= 2.3.1 is required.
*/
@@ -149,13 +153,13 @@ static Bool
I830CleanupDma(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
- drmI830Init info;
+ drm_i915_init_t info;
- memset(&info, 0, sizeof(drmI830Init));
- info.func = I830_CLEANUP_DMA;
+ memset(&info, 0, sizeof(info));
+ info.func = I915_CLEANUP_DMA;
if (drmCommandWrite(pI830->drmSubFD, DRM_I830_INIT,
- &info, sizeof(drmI830Init))) {
+ &info, sizeof(info))) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I830 Dma Cleanup Failed\n");
return FALSE;
}
@@ -169,10 +173,10 @@ I830InitDma(ScrnInfoPtr pScrn)
I830Ptr pI830 = I830PTR(pScrn);
I830RingBuffer *ring = pI830->LpRing;
I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
- drmI830Init info;
+ drm_i915_init_t info;
- memset(&info, 0, sizeof(drmI830Init));
- info.func = I830_INIT_DMA;
+ memset(&info, 0, sizeof(info));
+ info.func = I915_INIT_DMA;
info.ring_start = ring->mem->offset + pI830->LinearAddr;
info.ring_end = ring->mem->end + pI830->LinearAddr;
@@ -193,7 +197,7 @@ I830InitDma(ScrnInfoPtr pScrn)
info.cpp = pI830->cpp;
if (drmCommandWrite(pI830->drmSubFD, DRM_I830_INIT,
- &info, sizeof(drmI830Init))) {
+ &info, sizeof(info))) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"I830 Dma Initialization Failed\n");
return FALSE;
@@ -206,13 +210,13 @@ static Bool
I830ResumeDma(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
- drmI830Init info;
+ drm_i915_init_t info;
- memset(&info, 0, sizeof(drmI830Init));
- info.func = I830_RESUME_DMA;
+ memset(&info, 0, sizeof(info));
+ info.func = I915_RESUME_DMA;
if (drmCommandWrite(pI830->drmSubFD, DRM_I830_INIT,
- &info, sizeof(drmI830Init))) {
+ &info, sizeof(info))) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I830 Dma Resume Failed\n");
return FALSE;
}
@@ -1007,50 +1011,59 @@ I830DestroyContext(ScreenPtr pScreen, drm_context_t hwContext,
{
}
+static Bool
+I830InitializeIrq(ScreenPtr pScreen, int *irq)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+
+ *irq = drmGetInterruptFromBusID(pI830->drmSubFD,
+#if XSERVER_LIBPCIACCESS
+ ((pI830->PciInfo->domain << 8) |
+ pI830->PciInfo->bus),
+ pI830->PciInfo->dev,
+ pI830->PciInfo->func
+#else
+ ((pciConfigPtr) pI830->
+ PciInfo->thisCard)->busnum,
+ ((pciConfigPtr) pI830->
+ PciInfo->thisCard)->devnum,
+ ((pciConfigPtr) pI830->
+ PciInfo->thisCard)->funcnum
+#endif
+ );
+
+ if (drmCtlInstHandler(pI830->drmSubFD, *irq)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[drm] failure adding irq handler\n");
+ *irq = 0;
+ return FALSE;
+ }
+ else
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "[drm] dma control initialized, using IRQ %d\n", *irq);
+
+ return TRUE;
+}
+
Bool
I830DRIFinishScreenInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
+ I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
DPRINTF(PFX, "I830DRIFinishScreenInit\n");
if (!DRIFinishScreenInit(pScreen))
return FALSE;
- /* Okay now initialize the dma engine */
- {
- I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
-
- pI830DRI->irq = drmGetInterruptFromBusID(pI830->drmSubFD,
-#if XSERVER_LIBPCIACCESS
- ((pI830->PciInfo->domain << 8) |
- pI830->PciInfo->bus),
- pI830->PciInfo->dev,
- pI830->PciInfo->func
-#else
- ((pciConfigPtr) pI830->
- PciInfo->thisCard)->busnum,
- ((pciConfigPtr) pI830->
- PciInfo->thisCard)->devnum,
- ((pciConfigPtr) pI830->
- PciInfo->thisCard)->funcnum
-#endif
- );
-
- if (drmCtlInstHandler(pI830->drmSubFD, pI830DRI->irq)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "[drm] failure adding irq handler\n");
- pI830DRI->irq = 0;
- DRICloseScreen(pScreen);
- return FALSE;
- }
- else
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] dma control initialized, using IRQ %d\n",
- pI830DRI->irq);
- return TRUE;
+ if (!I830InitializeIrq(pScreen, &pI830DRI->irq)) {
+ DRICloseScreen(pScreen);
+ return FALSE;
}
+
+ return TRUE;
}
#ifdef DAMAGE
@@ -1787,7 +1800,7 @@ I830DRISetVBlankInterrupt (ScrnInfoPtr pScrn, Bool on)
if (!pI830->want_vblank_interrupts)
on = FALSE;
- if (pI830->directRenderingEnabled && pI830->drmMinor >= 5) {
+ if (pI830->directRendering == DRI_TYPE_XF86DRI && pI830->drmMinor >= 5) {
if (on) {
if (xf86_config->num_crtc > 1 && xf86_config->crtc[1]->enabled)
if (pI830->drmMinor >= 6)
@@ -1813,25 +1826,257 @@ I830DRILock(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
- if (pI830->directRenderingEnabled && !pI830->LockHeld) {
- DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
- pI830->LockHeld = 1;
- i830_refresh_ring(pScrn);
- return TRUE;
- }
- else
+ if (pI830->LockHeld || pI830->directRendering == DRI_TYPE_NONE)
return FALSE;
-}
+ else if (pI830->directRendering == DRI_TYPE_XF86DRI)
+ DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
+ else if (pI830->directRendering == DRI_TYPE_DRI2)
+ I830DRI2Lock(screenInfo.screens[pScrn->scrnIndex]);
+ pI830->LockHeld = 1;
+ i830_refresh_ring(pScrn);
+ return TRUE;
+}
void
I830DRIUnlock(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
- if (pI830->directRenderingEnabled && pI830->LockHeld) {
+ if (!pI830->LockHeld || pI830->directRendering == DRI_TYPE_NONE)
+ return;
+ else if (pI830->directRendering == DRI_TYPE_XF86DRI)
DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
- pI830->LockHeld = 0;
- }
+ else if (pI830->directRendering == DRI_TYPE_DRI2)
+ I830DRI2Unlock(screenInfo.screens[pScrn->scrnIndex]);
+
+ pI830->LockHeld = 0;
+}
+
+void
+I830DRI2Lock(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+
+ ErrorF("taking lock\n");
+
+ if (pI830->lockRefCount == 0) {
+ DRM_LOCK(pI830->drmSubFD, pI830->lock, pI830->context, 0);
+ pI830->lockingContext = pI830->context;
+ } else if (pI830->lockingContext != pI830->context) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] Locking deadlock.\n"
+ "\tAlready locked with context %d,\n"
+ "\ttrying to lock with context %d.\n",
+ pI830->lockingContext, pI830->context);
+ }
+
+ pI830->lockRefCount++;
+}
+
+void
+I830DRI2Unlock(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+
+ ErrorF("releasing lock\n");
+
+ if (pI830 == NULL)
+ return;
+
+ if (pI830->lockRefCount > 0) {
+ if (pI830->lockingContext != pI830->context) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] Unlocking inconsistency:\n"
+ "\tContext %d trying to unlock lock held by context %d\n",
+ pI830->context, pI830->lockingContext);
+ }
+ pI830->lockRefCount--;
+ } else {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "DRIUnlock called when not locked.\n");
+ return;
+ }
+
+ if (pI830->lockRefCount == 0)
+ DRM_UNLOCK(pI830->drmSubFD, pI830->lock, pI830->context);
+}
+
+static void
+I830DRI2BeginClipNotify(ScreenPtr pScreen)
+{
+ I830DRI2Lock(pScreen);
+}
+
+static void
+I830DRI2EndClipNotify(ScreenPtr pScreen)
+{
+ I830EmitFlush(xf86Screens[pScreen->myNum]);
+ I830DRI2Unlock(pScreen);
+}
+
+void
+I830DRI2Prepare(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+ char busId[64];
+ drmVersionPtr version;
+
+#if XSERVER_LIBPCIACCESS
+ sprintf(busId, "pci:%04x:%02x:%02x.%d",
+ pI830->PciInfo->domain, pI830->PciInfo->bus,
+ pI830->PciInfo->dev, pI830->PciInfo->func);
+#else
+ snprintf(busId, "PCI:%d:%d:%d",
+ ((pciConfigPtr) pI830->PciInfo->thisCard)->busnum,
+ ((pciConfigPtr) pI830->PciInfo->thisCard)->devnum,
+ ((pciConfigPtr) pI830->PciInfo->thisCard)->funcnum);
+#endif
+
+ /* Low level DRM open */
+ pI830->drmSubFD = drmOpen("i915", busId);
+ if (pI830->drmSubFD < 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[DRI2] drmOpen failed\n");
+ return;
+ }
+
+ version = drmGetVersion(pI830->drmSubFD);
+ if (!version) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[DRI2] Failed to get DRM version\n");
+ return;
+ }
+
+ if (version->version_major != 1 || version->version_minor < 3) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[DRI2] Need at least version 1.3 for DRI2\n");
+ drmClose(pI830->drmSubFD);
+ return;
+ }
+
+ pI830->LockHeld = 0;
+ pI830->drmMinor = version->version_minor;
+ drmFreeVersion(version);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "[DRI2] Opened DRM device successfully\n");
+
+ I830InitBufMgr(pScreen);
+ if (!pI830->use_ttm_batch)
+ return;
+
+ pI830->directRendering = DRI_TYPE_DRI2;
+}
+
+struct __DRILock {
+ unsigned int block_header;
+ drm_hw_lock_t lock;
+};
+
+#define DRI2_SAREA_BLOCK_HEADER(type, size) (((type) << 16) | (size))
+#define DRI2_SAREA_BLOCK_LOCK 0x0001
+
+void
+I830DRI2ScreenInit(ScreenPtr pScreen)
+{
+ DRI2InfoRec dri2info;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+ I830RingBuffer *ring = pI830->LpRing;
+ drm_i915_init_t info;
+ int irq;
+ int fd, major, minor, patch;
+ const char *driverName;
+ unsigned int sarea_handle;
+ void *p;
+ struct __DRILock *driLock;
+
+ dri2info.version = 1;
+ dri2info.fd = pI830->drmSubFD;
+ dri2info.driverSareaSize = sizeof *driLock;
+ dri2info.driverName = IS_I965G(pI830) ? "i965" : "i915";
+ dri2info.ddxVersionMajor = I830_MAJOR_VERSION;
+ dri2info.ddxVersionMinor = I830_MINOR_VERSION;
+ dri2info.ddxVersionPatch = I830_PATCHLEVEL;
+ dri2info.getPixmapHandle = I830EXAGetPixmapHandle;
+ dri2info.beginClipNotify = I830DRI2BeginClipNotify;
+ dri2info.endClipNotify = I830DRI2EndClipNotify;
+
+ p = DRI2ScreenInit(pScreen, &dri2info);
+ if (!p) {
+ pI830->directRendering = DRI_TYPE_NONE;
+ return;
+ }
+
+ driLock = p;
+ driLock->block_header =
+ DRI2_SAREA_BLOCK_HEADER(DRI2_SAREA_BLOCK_LOCK, sizeof *driLock);
+ pI830->lock = &driLock->lock;
+ pI830->lockRefCount = 0;
+ pI830->lockingContext = 0;
+
+ if (drmCreateContext(pI830->drmSubFD, &pI830->context)) {
+ pI830->directRendering = DRI_TYPE_NONE;
+ return;
+ }
+
+ I830DRI2Lock(pScreen);
+
+ /* Get sarea BO handle... maybe we need a dedicated function for
+ * that or maybe a DRI2 info struct that it fills out. */
+ DRI2Connect(pScreen, &fd, &driverName, &major, &minor, &patch,
+ &sarea_handle);
+
+ memset(&info, 0, sizeof(info));
+ info.func = I915_INIT_DMA2;
+ info.ring_start = ring->mem->offset + pI830->LinearAddr;
+ info.ring_end = ring->mem->end + pI830->LinearAddr;
+ info.ring_size = ring->mem->size;
+ info.mmio_offset = 0;
+ info.sarea_priv_offset = 0;
+ info.sarea_handle = sarea_handle;
+
+ if (drmCommandWrite(pI830->drmSubFD, DRM_I830_INIT,
+ &info, sizeof(info))) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "I830 Dma Initialization Failed\n");
+ pI830->directRendering = DRI_TYPE_NONE;
+
+ return;
+ }
+
+ if (IS_G33CLASS(pI830)) {
+ if (!I830SetHWS(pScrn, pI830->hw_status->offset)) {
+ pI830->directRendering = DRI_TYPE_NONE;
+ return;
+ }
+ }
+
+ if (DEVICE_ID(pI830->PciInfo) != PCI_CHIP_845_G &&
+ DEVICE_ID(pI830->PciInfo) != PCI_CHIP_I830_M) {
+ I830SetParam(pScrn, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1);
+ }
+
+ if (!I830InitializeIrq(pScreen, &irq)) {
+ pI830->directRendering = DRI_TYPE_NONE;
+ return;
+ }
+}
+
+void
+I830DRI2CloseScreen(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+
+ drmCtlUninstHandler(pI830->drmSubFD);
+ I830CleanupDma(pScrn);
+ drmDestroyContext(pI830->drmSubFD, pI830->context);
+ I830DRI2Unlock(pScreen);
+ DRI2CloseScreen(pScreen);
+ drmClose(pI830->drmSubFD);
}
diff --git a/src/i830_driver.c b/src/i830_driver.c
index e2d1e6f..ca8fa16 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -298,7 +298,8 @@ typedef enum {
OPTION_INTELTEXPOOL,
#endif
OPTION_TRIPLEBUFFER,
- OPTION_FORCEENABLEPIPEA
+ OPTION_FORCEENABLEPIPEA,
+ OPTION_DRI2
} I830Opts;
static OptionInfoRec I830Options[] = {
@@ -322,6 +323,7 @@ static OptionInfoRec I830Options[] = {
#endif
{OPTION_TRIPLEBUFFER, "TripleBuffer", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_FORCEENABLEPIPEA, "ForceEnablePipeA", OPTV_BOOLEAN, {0}, FALSE},
+ {OPTION_DRI2, "DRI2", OPTV_BOOLEAN, {0}, FALSE},
{-1, NULL, OPTV_NONE, {0}, FALSE}
};
/* *INDENT-ON* */
@@ -1492,7 +1494,7 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
pI830->directRenderingDisabled =
!xf86ReturnOptValBool(pI830->Options, OPTION_DRI, TRUE);
-#ifdef XF86DRI
+#if defined(XF86DRI) || defined(DRI2)
if (!pI830->directRenderingDisabled) {
if (pI830->noAccel || pI830->SWCursor) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it "
@@ -1743,6 +1745,14 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
}
#endif
+#if defined(DRI2)
+ /* Load the dri2 module if requested. */
+ if (xf86ReturnOptValBool(pI830->Options, OPTION_DRI2, FALSE) &&
+ !pI830->directRenderingDisabled) {
+ xf86LoadSubModule(pScrn, "dri2");
+ }
+#endif
+
pI830->preinit = FALSE;
return TRUE;
@@ -2306,7 +2316,7 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn)
return;
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering == DRI_TYPE_XF86DRI) {
drmI830Sarea *sarea = DRIGetSAREAPrivate(pScrn->pScreen);
/* Mark that the X Server was the last holder of the context */
@@ -2457,21 +2467,29 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pScrn->videoRam &= ~3;
}
+ pI830->directRendering = DRI_TYPE_NONE;
+#ifdef DRI2
+ if (xf86ReturnOptValBool(pI830->Options, OPTION_DRI2, FALSE))
+ I830DRI2Prepare(pScreen);
+#endif
+
#ifdef XF86DRI
/* Check for appropriate bpp and module support to initialize DRI. */
- if (!I830CheckDRIAvailable(pScrn)) {
- pI830->directRenderingDisabled = TRUE;
- }
+ if (pI830->directRendering == DRI_TYPE_NONE) {
- /* If DRI hasn't been explicitly disabled, try to initialize it.
- * It will be used by the memory allocator.
- */
- if (!pI830->directRenderingDisabled)
- pI830->directRenderingEnabled = I830DRIScreenInit(pScreen);
- else
- pI830->directRenderingEnabled = FALSE;
-#else
- pI830->directRenderingEnabled = FALSE;
+ if (!I830CheckDRIAvailable(pScrn)) {
+ pI830->directRendering = DRI_TYPE_XF86DRI;
+ }
+
+ /* If DRI hasn't been explicitly disabled, try to initialize it.
+ * It will be used by the memory allocator.
+ */
+ if (!pI830->directRenderingDisabled)
+ pI830->directRendering =
+ I830DRIScreenInit(pScreen) ? DRI_TYPE_XF86DRI : DRI_TYPE_NONE;
+ else
+ pI830->directRendering = DRI_TYPE_NONE;
+ }
#endif
/* Set up our video memory allocator for the chosen videoRam */
@@ -2554,7 +2572,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Need MMIO mapped to do GTT lookups during memory allocation. */
I830MapMMIO(pScrn);
-#if defined(XF86DRI)
+#if defined(XF86DRI) || defined(DRI2)
/*
* If DRI is potentially usable, check if there is enough memory available
* for it, and if there's also enough to allow tiling to be enabled.
@@ -2569,7 +2587,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pI830->XvEnabled = !pI830->XvDisabled;
#endif
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering != DRI_TYPE_NONE) {
int savedDisplayWidth = pScrn->displayWidth;
Bool tiled = FALSE;
@@ -2650,7 +2668,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (i == MM_TURNS) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Not enough video memory. Disabling DRI.\n");
- pI830->directRenderingEnabled = FALSE;
+ pI830->directRendering = DRI_TYPE_NONE;
}
}
#endif
@@ -2670,7 +2688,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Cannot support DRI with frame buffer width > 2048.\n");
pI830->tiling = FALSE;
- pI830->directRenderingEnabled = FALSE;
+ pI830->directRendering = DRI_TYPE_NONE;
}
#ifdef HAS_MTRR_SUPPORT
@@ -2768,26 +2786,32 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
#endif
-#ifdef XF86DRI
+#if defined(XF86DRI) || defined(DRI2)
/*
* Setup DRI after visuals have been established, but before fbScreenInit
* is called. fbScreenInit will eventually call into the drivers
* InitGLXVisuals call back.
*/
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering != DRI_TYPE_NONE) {
if (pI830->noAccel || pI830->SWCursor || (pI830->StolenOnly && I830IsPrimary(pScrn))) {
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "DRI is disabled because it "
"needs HW cursor, 2D accel and AGPGART.\n");
- pI830->directRenderingEnabled = FALSE;
+ pI830->directRendering = DRI_TYPE_NONE;
}
}
- if (pI830->directRenderingEnabled)
- pI830->directRenderingEnabled = I830DRIDoMappings(pScreen);
+ if (pI830->directRendering == DRI_TYPE_XF86DRI)
+ pI830->directRendering =
+ I830DRIDoMappings(pScreen) ? DRI_TYPE_XF86DRI : DRI_TYPE_NONE;
+
+ /* FIXME-DRI2: Necessary? */
+ pScrn->pScreen = pScreen;
+ pScreen->width = pScrn->virtualX;
+ pScreen->height = pScrn->virtualY;
/* If we failed for any reason, free DRI memory. */
- if (!pI830->directRenderingEnabled)
+ if (pI830->directRendering == DRI_TYPE_NONE)
i830_free_3d_memory(pScrn);
config = XF86_CRTC_CONFIG_PTR(pScrn);
@@ -2800,8 +2824,9 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
* Also make sure the DRM can handle the swap.
*/
if (I830LVDSPresent(pScrn) && !IS_I965GM(pI830) && !IS_IGD_GM(pI830) &&
- (!pI830->directRenderingEnabled ||
- (pI830->directRenderingEnabled && pI830->drmMinor >= 10))) {
+ (pI830->directRendering == DRI_TYPE_NONE ||
+ (pI830->directRendering == DRI_TYPE_XF86DRI && pI830->drmMinor >= 10) ||
+ (pI830->directRendering == DRI_TYPE_DRI2))) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "adjusting plane->pipe mappings "
"to allow for framebuffer compression\n");
for (c = 0; c < config->num_crtc; c++) {
@@ -2814,9 +2839,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
intel_crtc->plane = 0;
}
}
-
-#else
- pI830->directRenderingEnabled = FALSE;
#endif
#ifdef XF86DRI
@@ -2923,8 +2945,14 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Must be called before EnterVT, so we can acquire the DRI lock when
* binding our memory.
*/
- if (pI830->directRenderingEnabled)
- pI830->directRenderingEnabled = I830DRIFinishScreenInit(pScreen);
+ if (pI830->directRendering == DRI_TYPE_XF86DRI)
+ pI830->directRendering =
+ I830DRIFinishScreenInit(pScreen) ? DRI_TYPE_XF86DRI : DRI_TYPE_NONE;
+#endif
+
+#ifdef DRI2
+ if (pI830->directRendering == DRI_TYPE_DRI2)
+ I830DRI2ScreenInit(pScreen);
#endif
if (!I830EnterVT(scrnIndex, 0))
@@ -2953,7 +2981,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
IntelEmitInvarientState(pScrn);
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering != DRI_TYPE_NONE) {
pI830->directRenderingOpen = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Enabled\n");
} else {
@@ -2962,7 +2990,9 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
else
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Failed\n");
}
-#else
+#endif
+
+#if !defined(XF86DRI) || !defined(DRI2)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Not available\n");
#endif
@@ -2999,6 +3029,11 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
OUTREG(SVG_WORK_CTL, 0x00000010);
}
+#ifdef DRI2
+ if (pI830->directRendering == DRI_TYPE_DRI2 && pI830->directRenderingOpen)
+ I830DRI2Unlock(pScreen);
+#endif
+
pI830->starting = FALSE;
pI830->closing = FALSE;
pI830->suspended = FALSE;
@@ -3059,9 +3094,9 @@ I830LeaveVT(int scrnIndex, int flags)
}
}
-#ifdef XF86DRI
+#if defined(XF86DRI) || defined(DRI2)
if (pI830->directRenderingOpen) {
- DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
+ I830DRILock(pScrn);
I830DRISetVBlankInterrupt (pScrn, FALSE);
}
@@ -3073,7 +3108,7 @@ I830LeaveVT(int scrnIndex, int flags)
i830_stop_ring(pScrn, TRUE);
-#ifdef XF86DRI
+#if defined(XF86DRI) || defined(DRI2)
/* don't disable interrupt before stopping the ring for fencing */
if (pI830->directRenderingOpen) {
drmCtlUninstHandler(pI830->drmSubFD);
@@ -3127,7 +3162,7 @@ I830EnterVT(int scrnIndex, int flags)
pI830->leaving = FALSE;
#ifdef XF86DRI_MM
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering != DRI_TYPE_NONE) {
/* Unlock the memory manager first of all so that we can pin our
* buffer objects
*/
@@ -3175,8 +3210,24 @@ I830EnterVT(int scrnIndex, int flags)
i830_stop_ring(pScrn, TRUE);
SetHWOperatingState(pScrn);
+#ifdef DRI2
+ if (pI830->directRendering == DRI_TYPE_DRI2) {
+ I830DRISetVBlankInterrupt (pScrn, TRUE);
+
+ if (!pI830->starting) {
+ I830DRIResume(screenInfo.screens[scrnIndex]);
+ i830_refresh_ring(pScrn);
+ I830Sync(pScrn);
+ DO_RING_IDLE();
+
+ DPRINTF(PFX, "calling dri unlock\n");
+ I830DRIUnlock(pScrn);
+ }
+ }
+#endif
+
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering == DRI_TYPE_XF86DRI) {
/* Update buffer offsets in sarea and mappings, since buffer offsets
* may have changed.
*/
@@ -3247,7 +3298,7 @@ I830CloseScreen(int scrnIndex, ScreenPtr pScreen)
if (pScrn->vtSema == TRUE) {
I830LeaveVT(scrnIndex, 0);
#ifdef XF86DRI_MM
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRendering != DRI_TYPE_NONE) {
if (pI830->memory_manager != NULL) {
drmMMUnlock(pI830->drmSubFD, DRM_BO_MEM_TT, 1);
}
@@ -3287,7 +3338,8 @@ I830CloseScreen(int scrnIndex, ScreenPtr pScreen)
i830_allocator_fini(pScrn);
#ifdef XF86DRI
- if (pI830->directRenderingOpen) {
+ if (pI830->directRenderingOpen &&
+ pI830->directRendering == DRI_TYPE_XF86DRI) {
#ifdef DAMAGE
if (pI830->pDamage) {
PixmapPtr pPix = pScreen->GetScreenPixmap(pScreen);
@@ -3302,6 +3354,13 @@ I830CloseScreen(int scrnIndex, ScreenPtr pScreen)
}
#endif
+#ifdef DRI2
+ if (pI830->directRenderingOpen && pI830->directRendering == DRI_TYPE_DRI2) {
+ pI830->directRenderingOpen = FALSE;
+ I830DRI2CloseScreen(pScreen);
+ }
+#endif
+
if (I830IsPrimary(pScrn)) {
xf86GARTCloseScreen(scrnIndex);
diff --git a/src/i830_exa.c b/src/i830_exa.c
index f06ac49..22055fd 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -97,6 +97,26 @@ const int I830PatternROP[16] =
ROP_1
};
+static void dri2Lock(PixmapPtr pPixmap)
+{
+#ifdef DRI2
+ I830Ptr pI830 = I830PTR(xf86Screens[pPixmap->drawable.pScreen->myNum]);
+
+ if (pI830->directRendering == DRI_TYPE_DRI2)
+ I830DRI2Lock(pPixmap->drawable.pScreen);
+#endif
+}
+
+static void dri2Unlock(PixmapPtr pPixmap)
+{
+#ifdef DRI2
+ I830Ptr pI830 = I830PTR(xf86Screens[pPixmap->drawable.pScreen->myNum]);
+
+ if (pI830->directRendering == DRI_TYPE_DRI2)
+ I830DRI2Unlock(pPixmap->drawable.pScreen);
+#endif
+}
+
/**
* Returns whether a given pixmap is tiled or not.
*
@@ -205,6 +225,9 @@ I830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)
break;
}
pI830->BR[16] = fg;
+
+ dri2Lock(pPixmap);
+
return TRUE;
}
@@ -252,6 +275,8 @@ I830EXADoneSolid(PixmapPtr pPixmap)
I830Sync(pScrn);
#endif
+
+ dri2Unlock(pPixmap);
}
/**
@@ -282,6 +307,9 @@ I830EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
pI830->BR[13] |= ((1 << 25) | (1 << 24));
break;
}
+
+ dri2Lock(pDstPixmap);
+
return TRUE;
}
@@ -349,6 +377,8 @@ I830EXADoneCopy(PixmapPtr pDstPixmap)
I830Sync(pScrn);
#endif
+
+ dri2Unlock(pDstPixmap);
}
#define xFixedToFloat(val) \
@@ -416,6 +446,22 @@ static void I830EXADestroyPixmap(ScreenPtr pScreen, void *driverPriv)
xfree(driverPriv);
}
+#define BUFFER_FLAG_TILED 0x0100
+
+unsigned int I830EXAGetPixmapHandle(PixmapPtr pPix, unsigned int *flags)
+{
+ struct i830_exa_pixmap_priv *driver_priv;
+
+ driver_priv = exaGetPixmapDriverPrivate(pPix);
+ if (!driver_priv)
+ return 0;
+
+ if (i830_pixmap_tiled(pPix))
+ *flags = 0x0100;
+
+ return dri_bo_get_handle(driver_priv->bo);
+}
+
static Bool I830EXAPixmapIsOffscreen(PixmapPtr pPix)
{
struct i830_exa_pixmap_priv *driver_priv;
@@ -449,20 +495,26 @@ static Bool I830EXAPrepareAccess(PixmapPtr pPix, int index)
if (driver_priv->bo) {
mmDebug("mapping %p %d %dx%d\n", pPix, driver_priv->flags, pPix->drawable.width, pPix->drawable.height);
- if ((driver_priv->flags & I830_EXA_PIXMAP_IS_MAPPED))
- return TRUE;
-
- ret = dri_bo_map(driver_priv->bo, 1);
- if (ret)
- return FALSE;
+ if (!(driver_priv->flags & I830_EXA_PIXMAP_IS_MAPPED)) {
+ ret = dri_bo_map(driver_priv->bo, 1);
+ if (ret)
+ return FALSE;
- driver_priv->flags |= I830_EXA_PIXMAP_IS_MAPPED;
- pPix->devPrivate.ptr = driver_priv->bo->virtual;
+ driver_priv->flags |= I830_EXA_PIXMAP_IS_MAPPED;
+ pPix->devPrivate.ptr = driver_priv->bo->virtual;
+ }
}
+ dri2Lock(pPix);
+
return TRUE;
}
+static void I830ExaFinishAccess(PixmapPtr pPix, int index)
+{
+ dri2Unlock(pPix);
+}
+
static Bool I830EXAModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
int depth, int bitsPerPixel, int devKind,
pointer pPixData)
@@ -537,6 +589,7 @@ I830EXAInit(ScreenPtr pScreen)
} else {
pI830->EXADriverPtr->flags = EXA_OFFSCREEN_PIXMAPS | EXA_HANDLES_PIXMAPS;
pI830->EXADriverPtr->PrepareAccess = I830EXAPrepareAccess;
+ pI830->EXADriverPtr->FinishAccess = I830ExaFinishAccess;
}
DPRINTF(PFX, "EXA Mem: memoryBase 0x%x, end 0x%x, offscreen base 0x%x, "
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 6287bab..2f8a5ff 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -361,7 +361,10 @@ i830_free_3d_memory(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
-#ifdef XF86DRI
+#if defined(XF86DRI) || defined(DRI2)
+ if (pI830->directRendering == DRI_TYPE_DRI2)
+ return;
+
i830_free_memory(pScrn, pI830->back_buffer);
pI830->back_buffer = NULL;
i830_free_memory(pScrn, pI830->third_buffer);
@@ -434,7 +437,7 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long offset, unsigned long size)
* 5.4 or newer so we can rely on the lock being held after DRIScreenInit,
* rather than after DRIFinishScreenInit.
*/
- if (pI830->directRenderingEnabled && pI830->drmMinor >= 7 &&
+ if (pI830->directRendering != DRI_TYPE_NONE && pI830->drmMinor >= 7 &&
(dri_major > 5 || (dri_major == 5 && dri_minor >= 4)))
{
int mmsize;
@@ -1391,7 +1394,7 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
return FALSE;
#ifdef I830_USE_EXA
- if (pI830->useEXA) {
+ if (pI830->useEXA && !pI830->use_ttm_batch) {
if (pI830->exa_offscreen == NULL) {
/* Default EXA to having 3 screens worth of offscreen memory space
* (for pixmaps).
@@ -1647,6 +1650,10 @@ i830_allocate_3d_memory(ScrnInfoPtr pScrn)
return FALSE;
}
+ /* DRI2 doesn't need pre-allocated backbuffer, so return here. */
+ if (pI830->directRendering == DRI_TYPE_DRI2)
+ return TRUE;
+
if (!i830_allocate_backbuffer(pScrn, &pI830->back_buffer, "back buffer"))
return FALSE;
diff --git a/src/intel_bufmgr_ttm.c b/src/intel_bufmgr_ttm.c
index 32b407c..9287ee7 100644
--- a/src/intel_bufmgr_ttm.c
+++ b/src/intel_bufmgr_ttm.c
@@ -541,6 +541,14 @@ dri_ttm_bo_unmap(dri_bo *buf)
return drmBOUnmap(bufmgr_ttm->fd, &ttm_buf->drm_bo);
}
+static unsigned int
+dri_ttm_bo_get_handle(dri_bo *buf)
+{
+ dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
+
+ return ttm_buf->drm_bo.handle;
+}
+
/**
* Returns a dri_bo wrapping the given buffer object handle.
*
@@ -850,6 +858,7 @@ intel_bufmgr_ttm_init(int fd, unsigned int fence_type,
bufmgr_ttm->bufmgr.bo_unreference = dri_ttm_bo_unreference;
bufmgr_ttm->bufmgr.bo_map = dri_ttm_bo_map;
bufmgr_ttm->bufmgr.bo_unmap = dri_ttm_bo_unmap;
+ bufmgr_ttm->bufmgr.bo_get_handle = dri_ttm_bo_get_handle;
bufmgr_ttm->bufmgr.fence_reference = dri_ttm_fence_reference;
bufmgr_ttm->bufmgr.fence_unreference = dri_ttm_fence_unreference;
bufmgr_ttm->bufmgr.fence_wait = dri_ttm_fence_wait;
commit 33af38d2da6f2dc56660d36be56e03b233ad299e
Author: Eric Anholt <eric at anholt.net>
Date: Thu Jan 24 13:08:30 2008 -0800
Update to i915-ttm-cfu DRM changes (copied from Mesa)
diff --git a/src/intel_bufmgr_ttm.c b/src/intel_bufmgr_ttm.c
index 252c128..32b407c 100644
--- a/src/intel_bufmgr_ttm.c
+++ b/src/intel_bufmgr_ttm.c
@@ -35,18 +35,20 @@
*/
#include <xf86drm.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
-#include <stdio.h>
+
#include "errno.h"
#include "dri_bufmgr.h"
-#include "intel_bufmgr_ttm.h"
#include "string.h"
#include "i915_drm.h"
+#include "intel_bufmgr_ttm.h"
+
#define DBG(...) do { \
if (bufmgr_ttm->bufmgr.debug) \
fprintf(stderr, __VA_ARGS__); \
@@ -81,7 +83,6 @@ typedef struct _dri_bufmgr_ttm {
int validate_array_size;
int validate_count;
- drmBO *cached_reloc_buf;
uint32_t *cached_reloc_buf_data;
} dri_bufmgr_ttm;
@@ -110,7 +111,6 @@ typedef struct _dri_bo_ttm {
int validate_index;
/** DRM buffer object containing relocation list */
- drmBO *reloc_buf;
uint32_t *reloc_buf_data;
struct dri_ttm_reloc *relocs;
@@ -151,7 +151,7 @@ static void dri_ttm_dump_validation_list(dri_bufmgr_ttm *bufmgr_ttm)
bufmgr_ttm->validate_array[reloc_entry[2]].bo;
dri_bo_ttm *target_ttm = (dri_bo_ttm *)target_bo;
- DBG("%2d: %s at 0x%08x -> %s at 0x%08x + 0x%08x\n",
+ DBG("%2d: %s at 0x%08x -> %s at 0x%08lx + 0x%08x\n",
i,
bo_ttm->name, reloc_entry[0],
target_ttm->name, target_bo->offset,
@@ -237,10 +237,10 @@ intel_add_validate_buffer(dri_bo *buf,
req->bo_req.mask = INTEL_BO_MASK;
req->bo_req.fence_class = 0; /* Backwards compat. */
- if (ttm_buf->reloc_buf != NULL)
- arg->reloc_handle = ttm_buf->reloc_buf->handle;
+ if (ttm_buf->reloc_buf_data != NULL)
+ arg->reloc_ptr = (unsigned long)(void *)ttm_buf->reloc_buf_data;
else
- arg->reloc_handle = 0;
+ arg->reloc_ptr = 0;
/* Hook up the linked list of args for the kernel */
arg->next = 0;
@@ -286,52 +286,25 @@ intel_setup_reloc_list(dri_bo *bo)
{
dri_bo_ttm *bo_ttm = (dri_bo_ttm *)bo;
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bo->bufmgr;
- int ret;
bo_ttm->relocs = malloc(sizeof(struct dri_ttm_reloc) *
bufmgr_ttm->max_relocs);
- if (bufmgr_ttm->cached_reloc_buf != NULL) {
- bo_ttm->reloc_buf = bufmgr_ttm->cached_reloc_buf;
+ if (bufmgr_ttm->cached_reloc_buf_data != NULL) {
bo_ttm->reloc_buf_data = bufmgr_ttm->cached_reloc_buf_data;
- bufmgr_ttm->cached_reloc_buf = NULL;
bufmgr_ttm->cached_reloc_buf_data = NULL;
} else {
- bo_ttm->reloc_buf = malloc(sizeof(bo_ttm->drm_bo));
- ret = drmBOCreate(bufmgr_ttm->fd,
- RELOC_BUF_SIZE(bufmgr_ttm->max_relocs), 0,
- NULL,
- DRM_BO_FLAG_MEM_LOCAL |
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MAPPABLE |
- DRM_BO_FLAG_CACHED,
- 0, bo_ttm->reloc_buf);
- if (ret) {
- fprintf(stderr, "Failed to create relocation BO: %s\n",
- strerror(-ret));
- return ret;
- }
-
- ret = drmBOMap(bufmgr_ttm->fd, bo_ttm->reloc_buf,
- DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
- 0, (void **)&bo_ttm->reloc_buf_data);
- if (ret) {
- fprintf(stderr, "Failed to map relocation BO: %s\n",
- strerror(-ret));
- return ret;
- }
+ bo_ttm->reloc_buf_data = calloc(1, RELOC_BUF_SIZE(bufmgr_ttm->max_relocs));
}
/* Initialize the relocation list with the header:
- * DWORD 0: relocation type, relocation count
- * DWORD 1: handle to next relocation list (currently none)
- * DWORD 2: unused
- * DWORD 3: unused
+ * DWORD 0: relocation count
+ * DWORD 1: relocation type
+ * DWORD 2+3: handle to next relocation list (currently none) 64-bits
*/
- bo_ttm->reloc_buf_data[0] = I915_RELOC_TYPE_0 << 16;
- bo_ttm->reloc_buf_data[1] = 0;
+ bo_ttm->reloc_buf_data[0] = 0;
+ bo_ttm->reloc_buf_data[1] = I915_RELOC_TYPE_0;
bo_ttm->reloc_buf_data[2] = 0;
bo_ttm->reloc_buf_data[3] = 0;
@@ -390,7 +363,6 @@ dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
ttm_buf->bo.bufmgr = bufmgr;
ttm_buf->name = name;
ttm_buf->refcount = 1;
- ttm_buf->reloc_buf = NULL;
ttm_buf->reloc_buf_data = NULL;
ttm_buf->relocs = NULL;
ttm_buf->last_flags = ttm_buf->drm_bo.flags;
@@ -398,7 +370,7 @@ dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
ttm_buf->delayed_unmap = GL_FALSE;
ttm_buf->validate_index = -1;
- DBG("bo_create: %p (%s) %db\n", &ttm_buf->bo, ttm_buf->name, size);
+ DBG("bo_create: %p (%s) %ldb\n", &ttm_buf->bo, ttm_buf->name, size);
return &ttm_buf->bo;
}
@@ -446,7 +418,6 @@ intel_ttm_bo_create_from_handle(dri_bufmgr *bufmgr, const char *name,
ttm_buf->bo.bufmgr = bufmgr;
ttm_buf->name = name;
ttm_buf->refcount = 1;
- ttm_buf->reloc_buf = NULL;
ttm_buf->reloc_buf_data = NULL;
ttm_buf->relocs = NULL;
ttm_buf->last_flags = ttm_buf->drm_bo.flags;
@@ -480,7 +451,7 @@ dri_ttm_bo_unreference(dri_bo *buf)
if (--ttm_buf->refcount == 0) {
int ret;
- if (ttm_buf->reloc_buf) {
+ if (ttm_buf->reloc_buf_data) {
int i;
/* Unreference all the target buffers */
@@ -488,18 +459,16 @@ dri_ttm_bo_unreference(dri_bo *buf)
dri_bo_unreference(ttm_buf->relocs[i].target_buf);
free(ttm_buf->relocs);
- if (bufmgr_ttm->cached_reloc_buf == NULL) {
+ if (bufmgr_ttm->cached_reloc_buf_data == NULL) {
/* Cache a single relocation buffer allocation to avoid
* repeated create/map/unmap/destroy for batchbuffer
* relocations.
*/
- bufmgr_ttm->cached_reloc_buf = ttm_buf->reloc_buf;
bufmgr_ttm->cached_reloc_buf_data = ttm_buf->reloc_buf_data;
} else {
/* Free the kernel BO containing relocation entries */
- drmBOUnmap(bufmgr_ttm->fd, ttm_buf->reloc_buf);
- drmBOUnreference(bufmgr_ttm->fd, ttm_buf->reloc_buf);
- free(ttm_buf->reloc_buf);
+ free(ttm_buf->reloc_buf_data);
+ ttm_buf->reloc_buf_data = NULL;
}
}
@@ -651,7 +620,7 @@ dri_ttm_fence_wait(dri_fence *fence)
ret = drmFenceWait(bufmgr_ttm->fd, DRM_FENCE_FLAG_WAIT_LAZY, &fence_ttm->drm_fence, 0);
if (ret != 0) {
- fprintf(stderr, "%s:%d: Error %d waiting for fence %s.\n",
+ fprintf(stderr, "%s:%d: Error %d waiting for fence %s.\n",
__FILE__, __LINE__, ret, fence_ttm->name);
abort();
}
@@ -664,11 +633,8 @@ dri_bufmgr_ttm_destroy(dri_bufmgr *bufmgr)
{
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
- if (bufmgr_ttm->cached_reloc_buf) {
- /* Free the cached kernel BO containing relocation entries */
- drmBOUnmap(bufmgr_ttm->fd, bufmgr_ttm->cached_reloc_buf);
- drmBOUnreference(bufmgr_ttm->fd, bufmgr_ttm->cached_reloc_buf);
- free(bufmgr_ttm->cached_reloc_buf);
+ if (bufmgr_ttm->cached_reloc_buf_data) {
+ free(bufmgr_ttm->cached_reloc_buf_data);
}
free(bufmgr_ttm->validate_array);
@@ -691,25 +657,25 @@ dri_ttm_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
{
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)reloc_buf->bufmgr;
dri_bo_ttm *reloc_buf_ttm = (dri_bo_ttm *)reloc_buf;
+ dri_bo_ttm *target_buf_ttm = (dri_bo_ttm *)target_buf;
int num_relocs;
uint32_t *this_reloc;
/* Create a new relocation list if needed */
- if (reloc_buf_ttm->reloc_buf == NULL)
+ if (reloc_buf_ttm->reloc_buf_data == NULL)
intel_setup_reloc_list(reloc_buf);
- num_relocs = (reloc_buf_ttm->reloc_buf_data[0] & 0xffff);
+ num_relocs = reloc_buf_ttm->reloc_buf_data[0];
/* Check overflow */
- assert((reloc_buf_ttm->reloc_buf_data[0] & 0xffff) <
- bufmgr_ttm->max_relocs);
+ assert(num_relocs < bufmgr_ttm->max_relocs);
this_reloc = reloc_buf_ttm->reloc_buf_data + I915_RELOC_HEADER +
num_relocs * I915_RELOC0_STRIDE;
this_reloc[0] = offset;
this_reloc[1] = delta;
- this_reloc[2] = -1; /* To be filled in at exec time */
+ this_reloc[2] = target_buf_ttm->drm_bo.handle; /* To be filled in at exec time */
this_reloc[3] = 0;
reloc_buf_ttm->relocs[num_relocs].validate_flags = flags;
@@ -718,7 +684,7 @@ dri_ttm_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
reloc_buf_ttm->reloc_buf_data[0]++; /* Increment relocation count */
/* Check wraparound */
- assert((reloc_buf_ttm->reloc_buf_data[0] & 0xffff) != 0);
+ assert(reloc_buf_ttm->reloc_buf_data[0] != 0);
}
/**
@@ -740,19 +706,12 @@ dri_ttm_bo_process_reloc(dri_bo *bo)
for (i = 0; i < nr_relocs; i++) {
struct dri_ttm_reloc *r = &bo_ttm->relocs[i];
- dri_bo_ttm *target_ttm = (dri_bo_ttm *)r->target_buf;
- uint32_t *reloc_entry;
/* Continue walking the tree depth-first. */
dri_ttm_bo_process_reloc(r->target_buf);
/* Add the target to the validate list */
intel_add_validate_buffer(r->target_buf, r->validate_flags);
-
- /* Update the index of the target in the relocation entry */
- reloc_entry = bo_ttm->reloc_buf_data + I915_RELOC_HEADER +
- i * I915_RELOC0_STRIDE;
- reloc_entry[2] = target_ttm->validate_index;
}
}
@@ -826,8 +785,8 @@ intel_update_buffer_offsets (dri_bufmgr_ttm *bufmgr_ttm)
}
/* Update the buffer offset */
if (rep->bo_info.offset != bo->offset) {
- DBG("BO %s migrated: 0x%08x -> 0x%08x\n",
- bo_ttm->name, bo->offset, rep->bo_info.offset);
+ DBG("BO %s migrated: 0x%08lx -> 0x%08lx\n",
+ bo_ttm->name, bo->offset, (unsigned long)rep->bo_info.offset);
bo->offset = rep->bo_info.offset;
}
}
@@ -875,7 +834,6 @@ intel_bufmgr_ttm_init(int fd, unsigned int fence_type,
bufmgr_ttm->fd = fd;
bufmgr_ttm->fence_type = fence_type;
bufmgr_ttm->fence_type_flush = fence_type_flush;
- bufmgr_ttm->cached_reloc_buf = NULL;
bufmgr_ttm->cached_reloc_buf_data = NULL;
/* Let's go with one relocation per every 2 dwords (but round down a bit
commit 5a5bb0b9ee9009cfd0c95a8b91e5e0301ce8f6b1
Author: Eric Anholt <eric at anholt.net>
Date: Wed Jan 23 13:02:52 2008 -0800
Replace dri_bufmgr code with nearly-straight mesa code and a remapping header.
While here, fix the relocation arguments to not include the useless mask arg
and always supply at least DRM_BO_FLAG_READ (otherwise, the kernel rejects our
buffers).
To avoid any future mistakese with renaming, a make check test is added to make
sure we covered all the symbols.
diff --git a/src/Makefile.am b/src/Makefile.am
index b014c0e..a36eb1b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -119,7 +119,9 @@ intel_drv_la_SOURCES = \
dri_bufmgr.c \
dri_bufmgr.h \
intel_bufmgr_ttm.c \
- intel_batchbuffer.c
+ intel_bufmgr_ttm.h \
+ intel_batchbuffer.c \
+ intel_batchbuffer.h
INTEL_G4A = \
packed_yuv_sf.g4a \
@@ -200,3 +202,7 @@ install-data-local: install-intel_drv_laLTLIBRARIES
uninstall-local:
(cd $(DESTDIR)$(intel_drv_ladir) && rm -f i810_drv.so)
+
+TESTS_ENVIRONMENT = srcdir="$(srcdir)"
+TESTS = check-remap.sh
+EXTRA_DIST += $(TESTS)
diff --git a/src/check-remap.sh b/src/check-remap.sh
new file mode 100755
index 0000000..1bcde94
--- /dev/null
+++ b/src/check-remap.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+LANG=C
+
+if ! which nm 2>/dev/null >/dev/null; then
+ echo "'nm' not found; skipping test"
+ exit 0
+fi
+
+test -z "$srcdir" && srcdir=.
+status=0
+
+objs="dri_bufmgr.o intel_bufmgr_ttm.o"
+for obj in $objs; do
+ obj=.libs/${obj}
+
+ test -f $obj || continue
+ echo Checking $obj
+
+ syms=`nm "$obj" | grep " T " | cut -d" " -f3 | grep -E "intel|dri"`
+ bad_syms=`echo $syms | grep -v "ddx_"`
+
+ if test "x$bad_syms" != "x"; then
+ echo "ERROR: $obj contains non-remapped symbols: $bad_syms"
+ status=1
+ fi
+done
+
+exit $status
diff --git a/src/dri_bufmgr.c b/src/dri_bufmgr.c
index 578eff6..fc9871a 100644
--- a/src/dri_bufmgr.c
+++ b/src/dri_bufmgr.c
@@ -25,6 +25,9 @@
*
*/
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
#include "dri_bufmgr.h"
/** @file dri_bufmgr.c
@@ -32,8 +35,8 @@
* Convenience functions for buffer management methods.
*/
-ddx_bo *
-ddx_bo_alloc(ddx_bufmgr *bufmgr, const char *name, unsigned long size,
+dri_bo *
+dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
unsigned int alignment, uint64_t location_mask)
{
assert((location_mask & ~(DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_MEM_TT |
@@ -44,8 +47,8 @@ ddx_bo_alloc(ddx_bufmgr *bufmgr, const char *name, unsigned long size,
return bufmgr->bo_alloc(bufmgr, name, size, alignment, location_mask);
}
-ddx_bo *
-ddx_bo_alloc_static(ddx_bufmgr *bufmgr, const char *name, unsigned long offset,
+dri_bo *
+dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name, unsigned long offset,
unsigned long size, void *virtual,
uint64_t location_mask)
{
@@ -60,13 +63,13 @@ ddx_bo_alloc_static(ddx_bufmgr *bufmgr, const char *name, unsigned long offset,
}
void
-ddx_bo_reference(ddx_bo *bo)
+dri_bo_reference(dri_bo *bo)
{
bo->bufmgr->bo_reference(bo);
}
void
-ddx_bo_unreference(ddx_bo *bo)
+dri_bo_unreference(dri_bo *bo)
{
if (bo == NULL)
return;
@@ -75,13 +78,13 @@ ddx_bo_unreference(ddx_bo *bo)
}
int
-ddx_bo_map(ddx_bo *buf, Bool write_enable)
+dri_bo_map(dri_bo *buf, GLboolean write_enable)
{
return buf->bufmgr->bo_map(buf, write_enable);
}
int
-ddx_bo_unmap(ddx_bo *buf)
+dri_bo_unmap(dri_bo *buf)
{
return buf->bufmgr->bo_unmap(buf);
}
@@ -108,53 +111,54 @@ dri_fence_unreference(dri_fence *fence)
}
void
-ddx_bo_subdata(ddx_bo *bo, unsigned long offset,
+dri_bo_subdata(dri_bo *bo, unsigned long offset,
unsigned long size, const void *data)
{
if (size == 0 || data == NULL)
return;
- ddx_bo_map(bo, TRUE);
+ dri_bo_map(bo, GL_TRUE);
memcpy((unsigned char *)bo->virtual + offset, data, size);
- ddx_bo_unmap(bo);
+ dri_bo_unmap(bo);
}
void
-ddx_bo_get_subdata(ddx_bo *bo, unsigned long offset,
+dri_bo_get_subdata(dri_bo *bo, unsigned long offset,
unsigned long size, void *data)
{
if (size == 0 || data == NULL)
return;
- ddx_bo_map(bo, FALSE);
+ dri_bo_map(bo, GL_FALSE);
memcpy(data, (unsigned char *)bo->virtual + offset, size);
- ddx_bo_unmap(bo);
+ dri_bo_unmap(bo);
}
void
-ddx_bufmgr_destroy(ddx_bufmgr *bufmgr)
+dri_bufmgr_destroy(dri_bufmgr *bufmgr)
{
bufmgr->destroy(bufmgr);
}
-void dri_emit_reloc(ddx_bo *batch_buf, uint64_t flags, uint32_t delta, uint32_t offset, ddx_bo *relocatee)
+void dri_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
+ GLuint offset, dri_bo *target_buf)
{
- batch_buf->bufmgr->emit_reloc(batch_buf, flags, delta, offset, relocatee);
+ reloc_buf->bufmgr->emit_reloc(reloc_buf, flags, delta, offset, target_buf);
}
-void *dri_process_relocs(ddx_bo *batch_buf, uint32_t *count)
+void *dri_process_relocs(dri_bo *batch_buf, GLuint *count)
{
return batch_buf->bufmgr->process_relocs(batch_buf, count);
}
-void dri_post_submit(ddx_bo *batch_buf, dri_fence **last_fence)
+void dri_post_submit(dri_bo *batch_buf, dri_fence **last_fence)
{
batch_buf->bufmgr->post_submit(batch_buf, last_fence);
}
void
-dri_bufmgr_set_debug(ddx_bufmgr *bufmgr, Bool enable_debug)
+dri_bufmgr_set_debug(dri_bufmgr *bufmgr, GLboolean enable_debug)
{
bufmgr->debug = enable_debug;
}
diff --git a/src/dri_bufmgr.h b/src/dri_bufmgr.h
index e78f8ec..77ef0f6 100644
--- a/src/dri_bufmgr.h
+++ b/src/dri_bufmgr.h
@@ -34,16 +34,16 @@
#ifndef _DRI_BUFMGR_H_
#define _DRI_BUFMGR_H_
-#include <stdint.h>
#include <xf86drm.h>
-#include "xf86str.h"
+#include <GL/gl.h>
+#include "dri_bufmgr_remap.h"
-typedef struct _ddx_bufmgr ddx_bufmgr;
-typedef struct _ddx_bo ddx_bo;
+typedef struct _dri_bufmgr dri_bufmgr;
+typedef struct _dri_bo dri_bo;
typedef struct _dri_fence dri_fence;
-struct _ddx_bo {
+struct _dri_bo {
/** Size in bytes of the buffer object. */
unsigned long size;
/**
@@ -56,7 +56,7 @@ struct _ddx_bo {
*/
void *virtual;
/** Buffer manager context associated with this buffer object */
- ddx_bufmgr *bufmgr;
+ dri_bufmgr *bufmgr;
};
struct _dri_fence {
@@ -68,7 +68,7 @@ struct _dri_fence {
*/
unsigned int type;
/** Buffer manager context associated with this fence */
- ddx_bufmgr *bufmgr;
+ dri_bufmgr *bufmgr;
};
/**
@@ -76,7 +76,7 @@ struct _dri_fence {
*
* Contains public methods followed by private storage for the buffer manager.
*/
-struct _ddx_bufmgr {
+struct _dri_bufmgr {
/**
* Allocate a buffer object.
*
@@ -85,9 +85,9 @@ struct _ddx_bufmgr {
* bo_map() to be used by the CPU, and validated for use using bo_validate()
* to be used from the graphics device.
*/
- ddx_bo *(*bo_alloc)(ddx_bufmgr *bufmgr_ctx, const char *name,
+ dri_bo *(*bo_alloc)(dri_bufmgr *bufmgr_ctx, const char *name,
unsigned long size, unsigned int alignment,
- unsigned int location_mask);
+ uint64_t location_mask);
/**
* Allocates a buffer object for a static allocation.
@@ -95,18 +95,18 @@ struct _ddx_bufmgr {
* Static allocations are ones such as the front buffer that are offered by
* the X Server, which are never evicted and never moved.
*/
- ddx_bo *(*bo_alloc_static)(ddx_bufmgr *bufmgr_ctx, const char *name,
+ dri_bo *(*bo_alloc_static)(dri_bufmgr *bufmgr_ctx, const char *name,
unsigned long offset, unsigned long size,
- void *virtual, unsigned int location_mask);
+ void *virtual, uint64_t location_mask);
/** Takes a reference on a buffer object */
- void (*bo_reference)(ddx_bo *bo);
+ void (*bo_reference)(dri_bo *bo);
/**
* Releases a reference on a buffer object, freeing the data if
* rerefences remain.
*/
- void (*bo_unreference)(ddx_bo *bo);
+ void (*bo_unreference)(dri_bo *bo);
/**
* Maps the buffer into userspace.
@@ -114,10 +114,10 @@ struct _ddx_bufmgr {
* This function will block waiting for any existing fence on the buffer to
* clear, first. The resulting mapping is available at buf->virtual.
\ */
- int (*bo_map)(ddx_bo *buf, Bool write_enable);
+ int (*bo_map)(dri_bo *buf, GLboolean write_enable);
/** Reduces the refcount on the userspace mapping of the buffer object. */
- int (*bo_unmap)(ddx_bo *buf);
+ int (*bo_unmap)(dri_bo *buf);
/** Takes a reference on a fence object */
void (*fence_reference)(dri_fence *fence);
@@ -136,55 +136,87 @@ struct _ddx_bufmgr {
/**
* Tears down the buffer manager instance.
*/
- void (*destroy)(ddx_bufmgr *bufmgr);
-
+ void (*destroy)(dri_bufmgr *bufmgr);
+
/**
- * Add relocation
+ * Add relocation entry in reloc_buf, which will be updated with the
+ * target buffer's real offset on on command submission.
+ *
+ * Relocations remain in place for the lifetime of the buffer object.
+ *
+ * \param reloc_buf Buffer to write the relocation into.
+ * \param flags BO flags to be used in validating the target buffer.
+ * Applicable flags include:
+ * - DRM_BO_FLAG_READ: The buffer will be read in the process of
+ * command execution.
+ * - DRM_BO_FLAG_WRITE: The buffer will be written in the process of
+ * command execution.
+ * - DRM_BO_FLAG_MEM_TT: The buffer should be validated in TT memory.
+ * - DRM_BO_FLAG_MEM_VRAM: The buffer should be validated in video
+ * memory.
+ * \param delta Constant value to be added to the relocation target's offset.
+ * \param offset Byte offset within batch_buf of the relocated pointer.
+ * \param target Buffer whose offset should be written into the relocation
+ * entry.
*/
- void (*emit_reloc)(ddx_bo *batch_buf, uint64_t flags, uint32_t delta, uint32_t offset, ddx_bo *relocatee);
+ void (*emit_reloc)(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
+ GLuint offset, dri_bo *target);
- void *(*process_relocs)(ddx_bo *batch_buf, uint32_t *count);
+ /**
+ * Processes the relocations, either in userland or by converting the list
+ * for use in batchbuffer submission.
+ *
+ * Kernel-based implementations will return a pointer to the arguments
+ * to be handed with batchbuffer submission to the kernel. The userland
+ * implementation performs the buffer validation and emits relocations
+ * into them the appopriate order.
+ *
+ * \param batch_buf buffer at the root of the tree of relocations
+ * \param count returns the number of buffers validated.
+ * \return relocation record for use in command submission.
+ * */
+ void *(*process_relocs)(dri_bo *batch_buf, GLuint *count);
- void (*post_submit)(ddx_bo *batch_buf, dri_fence **fence);
+ void (*post_submit)(dri_bo *batch_buf, dri_fence **fence);
- Bool debug; /**< Enables verbose debugging printouts */
+ GLboolean debug; /**< Enables verbose debugging printouts */
};
-ddx_bo *ddx_bo_alloc(ddx_bufmgr *bufmgr, const char *name, unsigned long size,
+dri_bo *dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
unsigned int alignment, uint64_t location_mask);
-ddx_bo *ddx_bo_alloc_static(ddx_bufmgr *bufmgr, const char *name,
+dri_bo *dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name,
unsigned long offset, unsigned long size,
void *virtual, uint64_t location_mask);
-void ddx_bo_reference(ddx_bo *bo);
-void ddx_bo_unreference(ddx_bo *bo);
-int ddx_bo_map(ddx_bo *buf, Bool write_enable);
-int ddx_bo_unmap(ddx_bo *buf);
+void dri_bo_reference(dri_bo *bo);
+void dri_bo_unreference(dri_bo *bo);
+int dri_bo_map(dri_bo *buf, GLboolean write_enable);
+int dri_bo_unmap(dri_bo *buf);
void dri_fence_wait(dri_fence *fence);
void dri_fence_reference(dri_fence *fence);
void dri_fence_unreference(dri_fence *fence);
-void ddx_bo_subdata(ddx_bo *bo, unsigned long offset,
+void dri_bo_subdata(dri_bo *bo, unsigned long offset,
unsigned long size, const void *data);
-void ddx_bo_get_subdata(ddx_bo *bo, unsigned long offset,
+void dri_bo_get_subdata(dri_bo *bo, unsigned long offset,
unsigned long size, void *data);
-ddx_bufmgr *ddx_bufmgr_ttm_init(int fd, unsigned int fence_type,
- unsigned int fence_type_flush);
-
-void ddx_bufmgr_fake_contended_lock_take(ddx_bufmgr *bufmgr);
-ddx_bufmgr *ddx_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
+void dri_bufmgr_fake_contended_lock_take(dri_bufmgr *bufmgr);
+dri_bufmgr *dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
unsigned long size,
unsigned int (*fence_emit)(void *private),
int (*fence_wait)(void *private,
unsigned int cookie),
void *driver_priv);
-void ddx_bufmgr_destroy(ddx_bufmgr *bufmgr);
-ddx_bo *dri_ttm_bo_create_from_handle(ddx_bufmgr *bufmgr, const char *name,
- unsigned int handle);
-
-void dri_emit_reloc(ddx_bo *batch_buf, uint64_t flags, uint32_t delta, uint32_t offset, ddx_bo *relocatee);
-void *dri_process_relocs(ddx_bo *batch_buf, uint32_t *count);
-void dri_post_process_relocs(ddx_bo *batch_buf);
-void dri_post_submit(ddx_bo *batch_buf, dri_fence **last_fence);
-void dri_bufmgr_set_debug(ddx_bufmgr *bufmgr, Bool enable_debug);
+void dri_bufmgr_set_debug(dri_bufmgr *bufmgr, GLboolean enable_debug);
+void dri_bo_fake_disable_backing_store(dri_bo *bo,
+ void (*invalidate_cb)(dri_bo *bo,
+ void *ptr),
+ void *ptr);
+void dri_bufmgr_destroy(dri_bufmgr *bufmgr);
+
+void dri_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
+ GLuint offset, dri_bo *target_buf);
+void *dri_process_relocs(dri_bo *batch_buf, uint32_t *count);
+void dri_post_process_relocs(dri_bo *batch_buf);
+void dri_post_submit(dri_bo *batch_buf, dri_fence **last_fence);
#endif
diff --git a/src/dri_bufmgr_compat.h b/src/dri_bufmgr_compat.h
new file mode 100644
index 0000000..2cd2556
--- /dev/null
+++ b/src/dri_bufmgr_compat.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric at anholt.net>
+ *
+ */
+
+/**
+ * @file dri_bufmgr_compat.h
+ *
+ * This file contains typedefs and such to build the dri_bufmgr files from the
+ * 3d driver.
+ */
+
+typedef Bool GLboolean;
+typedef uint32_t GLuint;
+typedef int32_t GLint;
diff --git a/src/dri_bufmgr_remap.h b/src/dri_bufmgr_remap.h
new file mode 100644
index 0000000..a5e231e
--- /dev/null
+++ b/src/dri_bufmgr_remap.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric at anholt.net>
+ *
+ */
+
+/**
+ * @file dri_bufmgr_remap.h
+ *
+ * This file contains renaming macros for dri_bufmgr.c and intel_bufmgr_ttm.c,
+ * to prevent symbol collisions with the AIGLX-loaded 3D driver.
+ */
+
+#define dri_bo_alloc ddx_dri_bo_alloc
+#define dri_bo_alloc_static ddx_dri_bo_alloc_static
+#define dri_bo_reference ddx_dri_bo_reference
+#define dri_bo_unreference ddx_dri_bo_unreference
+#define dri_bo_map ddx_dri_bo_map
+#define dri_bo_unmap ddx_dri_bo_unmap
+#define dri_fence_wait ddx_dri_fence_wait
+#define dri_fence_reference ddx_dri_fence_reference
+#define dri_fence_unreference ddx_dri_fence_unreference
+#define dri_bo_subdata ddx_dri_bo_subdata
+#define dri_bo_get_subdata ddx_dri_bo_get_subdata
+#define dri_bufmgr_destroy ddx_dri_bufmgr_destroy
+#define dri_emit_reloc ddx_dri_emit_reloc
+#define dri_process_relocs ddx_dri_process_relocs
+#define dri_post_process_relocs ddx_dri_post_process_relocs
+#define dri_post_submit ddx_dri_post_submit
+
+#define intel_ttm_bo_create_from_handle ddx_intel_ttm_bo_create_from_handle
+#define intel_ttm_fence_create_from_arg ddx_intel_ttm_fence_create_from_arg
+#define intel_bufmgr_ttm_init ddx_intel_bufmgr_ttm_init
+
diff --git a/src/i830.h b/src/i830.h
index 923704c..e237c42 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -628,7 +628,7 @@ typedef struct _I830Rec {
/* batchbuffer support */
struct i965_exastate_buffer *exa965;
struct intelddx_batchbuffer *batch;
- ddx_bufmgr *bufmgr;
+ dri_bufmgr *bufmgr;
unsigned int maxBatchSize;
Bool use_ttm_batch;
} I830Rec;
@@ -645,7 +645,7 @@ typedef struct _I830Rec {
/* i830 pixmap private for TTM */
struct i830_exa_pixmap_priv {
- ddx_bo *bo;
+ dri_bo *bo;
dri_fence *fence;
int flags;
};
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 4bea2a7..0857603 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -531,9 +531,10 @@ I830InitBufMgr(ScreenPtr pScreen)
else
pI830->maxBatchSize = BATCH_SZ;
- pI830->bufmgr = intelddx_bufmgr_ttm_init(pI830->drmSubFD, DRM_FENCE_TYPE_EXE,
- DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW,
- BATCH_SZ);
+ pI830->bufmgr = intel_bufmgr_ttm_init(pI830->drmSubFD, DRM_FENCE_TYPE_EXE,
+ DRM_FENCE_TYPE_EXE |
+ DRM_I915_FENCE_TYPE_RW,
+ BATCH_SZ);
if (!pI830->bufmgr)
return;
diff --git a/src/i830_exa.c b/src/i830_exa.c
index 9e563e7..f06ac49 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -35,9 +35,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xaarop.h"
#include "i830.h"
#include "i810_reg.h"
-#include <string.h>
-
#include "intel_bufmgr_ttm.h"
+#include <string.h>
#ifdef I830DEBUG
#define DEBUG_I830FALLBACK 1
@@ -239,7 +238,7 @@ I830EXASolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2)
OUT_BATCH((y2 << 16) | (x2 & 0xffff));
OUT_PIXMAP_RELOC(pPixmap,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
+ 0);
OUT_BATCH(pI830->BR[16]);
ADVANCE_BATCH();
}
@@ -331,12 +330,12 @@ I830EXACopy(PixmapPtr pDstPixmap, int src_x1, int src_y1, int dst_x1,
OUT_BATCH((dst_y2 << 16) | (dst_x2 & 0xffff));
OUT_PIXMAP_RELOC(pDstPixmap,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
+ 0);
OUT_BATCH((src_y1 << 16) | (src_x1 & 0xffff));
OUT_BATCH(src_pitch);
OUT_PIXMAP_RELOC(pI830->pSrcPixmap,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
+ 0);
ADVANCE_BATCH();
}
@@ -398,7 +397,7 @@ static void *I830EXACreatePixmap(ScreenPtr pScreen, int size, int align)
if (size == 0)
return new_priv;
- new_priv->bo = ddx_bo_alloc(pI830->bufmgr, "pixmap",
+ new_priv->bo = dri_bo_alloc(pI830->bufmgr, "pixmap",
size, 4096, DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED | DRM_BO_FLAG_CACHED_MAPPED);
return new_priv;
@@ -411,9 +410,9 @@ static void I830EXADestroyPixmap(ScreenPtr pScreen, void *driverPriv)
struct i830_exa_pixmap_priv *driver_priv = driverPriv;
if (driver_priv->flags & I830_EXA_PIXMAP_IS_MAPPED)
- ddx_bo_unmap(driver_priv->bo);
+ dri_bo_unmap(driver_priv->bo);
- ddx_bo_unreference(driver_priv->bo);
+ dri_bo_unreference(driver_priv->bo);
xfree(driverPriv);
}
@@ -453,7 +452,7 @@ static Bool I830EXAPrepareAccess(PixmapPtr pPix, int index)
if ((driver_priv->flags & I830_EXA_PIXMAP_IS_MAPPED))
return TRUE;
- ret = ddx_bo_map(driver_priv->bo, 1);
+ ret = dri_bo_map(driver_priv->bo, 1);
if (ret)
return FALSE;
@@ -480,7 +479,9 @@ static Bool I830EXAModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
driver_priv->flags |= I830_EXA_PIXMAP_IS_FRONTBUFFER;
/* get a reference to the front buffer handle */
- driver_priv->bo = intelddx_ttm_bo_create_from_handle(pI830->bufmgr, "front", pI830->front_buffer->bo.handle);
+ driver_priv->bo =
+ intel_ttm_bo_create_from_handle(pI830->bufmgr, "front",
+ pI830->front_buffer->bo.handle);
miModifyPixmapHeader(pPixmap, width, height, depth,
bitsPerPixel, devKind, NULL);
diff --git a/src/i830_render.c b/src/i830_render.c
index 2b54a03..24ad262 100644
--- a/src/i830_render.c
+++ b/src/i830_render.c
@@ -319,7 +319,7 @@ i830_texture_setup(PicturePtr pPict, PixmapPtr pPix, int unit)
OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_MAP(unit) | 4);
OUT_PIXMAP_RELOC(pPix,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, TM0S0_USE_FENCE);
+ TM0S0_USE_FENCE);
OUT_BATCH(((pPix->drawable.height - 1) << TM0S1_HEIGHT_SHIFT) |
((pPix->drawable.width - 1) << TM0S1_WIDTH_SHIFT) | format);
OUT_BATCH((pitch/4 - 1) << TM0S2_PITCH_SHIFT | TM0S2_MAP_2D);
@@ -429,8 +429,10 @@ i830_prepare_composite(int op, PicturePtr pSrcPicture,
OUT_BATCH(BUF_3D_ID_COLOR_BACK| BUF_3D_USE_FENCE |
BUF_3D_PITCH(dst_pitch));
OUT_PIXMAP_RELOC(pDst,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_READ |
+ DRM_BO_FLAG_WRITE,
+ 0);
OUT_BATCH(MI_NOOP);
OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
diff --git a/src/i915_render.c b/src/i915_render.c
index b753bc1..151f89d 100644
--- a/src/i915_render.c
+++ b/src/i915_render.c
@@ -344,7 +344,7 @@ i915_prepare_composite(int op, PicturePtr pSrcPicture,
OUT_BATCH(0x00000001); /* map 0 */
OUT_PIXMAP_RELOC(pI830->texture_pixmaps[0],
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
+ 0);
OUT_BATCH(pI830->mapstate[1]);
OUT_BATCH(pI830->mapstate[2]);
@@ -360,12 +360,12 @@ i915_prepare_composite(int op, PicturePtr pSrcPicture,
OUT_BATCH(0x00000003); /* map 0,1 */
OUT_PIXMAP_RELOC(pI830->texture_pixmaps[0],
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
+ 0);
OUT_BATCH(pI830->mapstate[1]);
OUT_BATCH(pI830->mapstate[2]);
OUT_PIXMAP_RELOC(pI830->texture_pixmaps[1],
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
+ 0);
OUT_BATCH(pI830->mapstate[4]);
OUT_BATCH(pI830->mapstate[5]);
@@ -387,7 +387,7 @@ i915_prepare_composite(int op, PicturePtr pSrcPicture,
OUT_BATCH(BUF_3D_ID_COLOR_BACK| BUF_3D_USE_FENCE|
BUF_3D_PITCH(dst_pitch));
OUT_PIXMAP_RELOC(pDst, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
+ 0);
OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
OUT_BATCH(dst_format);
diff --git a/src/i965_render.c b/src/i965_render.c
index b1c8d12..91f62bf 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -697,20 +697,20 @@ i965_update_ps_kernel(ScrnInfoPtr pScrn, char *start_base,
memcpy(start_base + ps_kernel_offset, ps_kernels[need_ps_kernel].kernel, ps_kernels[need_ps_kernel].size);
}
-void
+static void
i965_exastate_reset(struct i965_exastate_buffer *state)
{
I830Ptr pI830 = I830PTR(state->pScrn);
if (state->buf != NULL) {
- ddx_bo_unreference(state->buf);
+ dri_bo_unreference(state->buf);
state->buf = NULL;
}
- state->buf = ddx_bo_alloc(pI830->bufmgr, "exa state buffer",
+ state->buf = dri_bo_alloc(pI830->bufmgr, "exa state buffer",
EXASTATE_SZ, 4096,
DRM_BO_FLAG_MEM_TT);
- ddx_bo_map(state->buf, TRUE);
+ dri_bo_map(state->buf, TRUE);
state->map = state->buf->virtual;
i965_init_state_objects(state->pScrn, state->map);
@@ -811,8 +811,9 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture,
if (pI830->use_ttm_batch) {
uint32_t _ret;
_ret = intelddx_batchbuffer_emit_pixmap(pDst,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_CACHED,
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_READ |
+ DRM_BO_FLAG_WRITE,
pI830->exa965->buf, dest_surf_offset + 4, 0);
dest_surf_state->ss1.base_addr = _ret;
} else {
@@ -832,9 +833,10 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture,
if (pI830->use_ttm_batch) {
uint32_t _ret;
_ret = intelddx_batchbuffer_emit_pixmap(pSrc,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ | DRM_BO_FLAG_CACHED,
- pI830->exa965->buf, src_surf_offset + 4, 0);
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_READ,
+ pI830->exa965->buf,
+ src_surf_offset + 4, 0);
src_surf_state->ss1.base_addr = _ret;
} else {
src_surf_state->ss1.base_addr = intel_get_pixmap_offset(pSrc);
@@ -851,10 +853,11 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture,
mask_surf_state->ss0.surface_format = i965_get_card_format(pMaskPicture);
if (pI830->use_ttm_batch) {
uint32_t _ret;
- _ret = intelddx_batchbuffer_emit_pixmap(pMask,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ | DRM_BO_FLAG_CACHED,
- pI830->exa965->buf, mask_surf_offset + 4, 0);
+ _ret = intelddx_batchbuffer_emit_pixmap(pMask,
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_READ,
+ pI830->exa965->buf,
+ mask_surf_offset + 4, 0);
mask_surf_state->ss1.base_addr = _ret;
} else {
mask_surf_state->ss1.base_addr = intel_get_pixmap_offset(pMask);
@@ -1004,9 +1007,13 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture,
OUT_BATCH(BRW_STATE_BASE_ADDRESS | 4);
if (pI830->use_ttm_batch) {
- OUT_RELOC(pI830->exa965->buf, DRM_BO_FLAG_MEM_TT, BASE_ADDRESS_MODIFY);
+ OUT_RELOC(pI830->exa965->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ BASE_ADDRESS_MODIFY);
- OUT_RELOC(pI830->exa965->buf, DRM_BO_FLAG_MEM_TT, BASE_ADDRESS_MODIFY);
+ OUT_RELOC(pI830->exa965->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ BASE_ADDRESS_MODIFY);
} else {
OUT_BATCH(pI830->exa_965_state->offset | BASE_ADDRESS_MODIFY);
OUT_BATCH(pI830->exa_965_state->offset | BASE_ADDRESS_MODIFY);
@@ -1098,7 +1105,8 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture,
((4 * 2 * nelem) << VB0_BUFFER_PITCH_SHIFT));
if (pI830->use_ttm_batch) {
- OUT_RELOC(pI830->exa965->buf, DRM_BO_FLAG_MEM_TT, vb_offset);
+ OUT_RELOC(pI830->exa965->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, vb_offset);
} else {
OUT_BATCH(pI830->exa_965_state->offset + vb_offset);
@@ -1275,7 +1283,7 @@ void i965_done_composite(PixmapPtr pDst)
}
if (pI830->use_ttm_batch) {
- ddx_bo_unmap(pI830->exa965->buf);
+ dri_bo_unmap(pI830->exa965->buf);
intelddx_batchbuffer_flush(pI830->batch);
} else {
I830Sync(pScrn);
diff --git a/src/intel_batchbuffer.c b/src/intel_batchbuffer.c
index 25ba4be..636c9eb 100644
--- a/src/intel_batchbuffer.c
+++ b/src/intel_batchbuffer.c
@@ -82,14 +82,14 @@ intelddx_batchbuffer_reset(struct intelddx_batchbuffer *batch)
I830Ptr pI830 = I830PTR(batch->pScrn);
if (batch->buf != NULL) {
- ddx_bo_unreference(batch->buf);
+ dri_bo_unreference(batch->buf);
batch->buf = NULL;
}
- batch->buf = ddx_bo_alloc(pI830->bufmgr, "batchbuffer",
+ batch->buf = dri_bo_alloc(pI830->bufmgr, "batchbuffer",
pI830->maxBatchSize, 4096,
DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED | DRM_BO_FLAG_CACHED_MAPPED);
- ddx_bo_map(batch->buf, TRUE);
+ dri_bo_map(batch->buf, TRUE);
batch->map = batch->buf->virtual;
batch->size = pI830->maxBatchSize;
batch->ptr = batch->map;
@@ -116,10 +116,10 @@ intelddx_batchbuffer_free(struct intelddx_batchbuffer *batch)
batch->last_fence = NULL;
}
if (batch->map) {
- ddx_bo_unmap(batch->buf);
+ dri_bo_unmap(batch->buf);
batch->map = NULL;
}
- ddx_bo_unreference(batch->buf);
+ dri_bo_unreference(batch->buf);
batch->buf = NULL;
free(batch);
}
@@ -157,7 +157,7 @@ intel_exec_ioctl(ScrnInfoPtr pScrn,
exit(1);
}
- fo = intelddx_ttm_fence_create_from_arg(pI830->bufmgr, "fence buffers",
+ fo = intel_ttm_fence_create_from_arg(pI830->bufmgr, "fence buffers",
&execbuf.fence_arg);
if (!fo) {
fprintf(stderr, "failed to fence handle: %08x\n", execbuf.fence_arg.handle);
@@ -175,7 +175,7 @@ do_flush_locked(struct intelddx_batchbuffer *batch,
void *start;
uint32_t count;
- ddx_bo_unmap(batch->buf);
+ dri_bo_unmap(batch->buf);
start = dri_process_relocs(batch->buf, &count);
batch->map = NULL;
@@ -244,7 +244,7 @@ intelddx_batchbuffer_finish(struct intelddx_batchbuffer *batch)
*/
Bool
intelddx_batchbuffer_emit_reloc(struct intelddx_batchbuffer *batch,
- ddx_bo *buffer,
+ dri_bo *buffer,
uint32_t flags, uint32_t delta)
{
dri_emit_reloc(batch->buf, flags, delta, batch->ptr - batch->map, buffer);
@@ -263,9 +263,11 @@ intelddx_batchbuffer_data(struct intelddx_batchbuffer *batch,
batch->ptr += bytes;
}
-uint32_t intelddx_batchbuffer_emit_pixmap(PixmapPtr pPixmap, unsigned int flags,
- unsigned int mask, ddx_bo *reloc_buf,
- unsigned int offset, unsigned int delta)
+uint32_t intelddx_batchbuffer_emit_pixmap(PixmapPtr pPixmap,
+ unsigned int flags,
+ dri_bo *reloc_buf,
+ unsigned int offset,
+ unsigned int delta)
{
ScreenPtr pScreen = pPixmap->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -273,7 +275,7 @@ uint32_t intelddx_batchbuffer_emit_pixmap(PixmapPtr pPixmap, unsigned int flags,
struct i830_exa_pixmap_priv *driver_priv = exaGetPixmapDriverPrivate(pPixmap);
if (driver_priv->flags & I830_EXA_PIXMAP_IS_MAPPED) {
- ddx_bo_unmap(driver_priv->bo);
+ dri_bo_unmap(driver_priv->bo);
driver_priv->flags &= ~I830_EXA_PIXMAP_IS_MAPPED;
}
dri_emit_reloc(reloc_buf, flags, delta, offset, driver_priv->bo);
diff --git a/src/intel_batchbuffer.h b/src/intel_batchbuffer.h
index c1e3937..0c0a95e 100644
--- a/src/intel_batchbuffer.h
+++ b/src/intel_batchbuffer.h
@@ -13,7 +13,7 @@ struct intelddx_batchbuffer
{
ScrnInfoPtr pScrn;
- ddx_bo *buf;
+ dri_bo *buf;
dri_fence *last_fence;
uint32_t flags;
@@ -26,7 +26,7 @@ struct intelddx_batchbuffer
};
struct i965_exastate_buffer {
- ddx_bo *buf;
+ dri_bo *buf;
dri_fence *last_fence;
ScrnInfoPtr pScrn;
unsigned char *map;
@@ -55,8 +55,8 @@ void intelddx_batchbuffer_release_space(struct intelddx_batchbuffer *batch,
uint32_t bytes);
Bool intelddx_batchbuffer_emit_reloc(struct intelddx_batchbuffer *batch,
- ddx_bo *buffer,
- uint32_t flags, uint32_t offset);
+ dri_bo *buffer,
+ uint32_t flags, uint32_t offset);
/* Inline functions - might actually be better off with these
* non-inlined. Certainly better off switching all command packets to
@@ -93,8 +93,7 @@ intelddx_batchbuffer_require_space(struct intelddx_batchbuffer *batch,
extern uint32_t intelddx_batchbuffer_emit_pixmap(PixmapPtr pPixmap,
unsigned int flags,
- unsigned int mask,
- ddx_bo *reloc_buf,
+ dri_bo *reloc_buf,
unsigned int offset,
unsigned int delta);
@@ -124,8 +123,8 @@ extern uint32_t intelddx_batchbuffer_emit_pixmap(PixmapPtr pPixmap,
intelddx_batchbuffer_emit_reloc(pI830->batch, buf, flags, delta); \
} while (0)
-#define OUT_PIXMAP_RELOC(pixmap, flags, mask, delta) if (pI830->use_ttm_batch) { \
- uint32_t _retval = intelddx_batchbuffer_emit_pixmap((pixmap), (flags), (mask), \
+#define OUT_PIXMAP_RELOC(pixmap, flags, delta) if (pI830->use_ttm_batch) { \
+ uint32_t _retval = intelddx_batchbuffer_emit_pixmap((pixmap), (flags), \
pI830->batch->buf, (pI830->batch->ptr - pI830->batch->map), (delta)); \
intelddx_batchbuffer_emit_dword (pI830->batch, _retval + (delta)); \
} else { \
diff --git a/src/intel_bufmgr_ttm.c b/src/intel_bufmgr_ttm.c
index 0fb657f..252c128 100644
--- a/src/intel_bufmgr_ttm.c
+++ b/src/intel_bufmgr_ttm.c
@@ -1,10 +1,10 @@
/**************************************************************************
- *
+ *
* Copyright © 2007 Red Hat Inc.
* Copyright © 2007 Intel Corporation
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -12,20 +12,20 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
- *
+ *
+ *
**************************************************************************/
/*
* Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
@@ -36,18 +36,20 @@
#include <xf86drm.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
+#include <assert.h>
+#include <stdio.h>
#include "errno.h"
#include "dri_bufmgr.h"
-#include <xf86mm.h>
+#include "intel_bufmgr_ttm.h"
+#include "string.h"
#include "i915_drm.h"
-#include "intel_bufmgr_ttm.h"
-
#define DBG(...) do { \
if (bufmgr_ttm->bufmgr.debug) \
- ErrorF(__VA_ARGS__); \
+ fprintf(stderr, __VA_ARGS__); \
} while (0)
/*
@@ -62,18 +64,18 @@
DRM_BO_FLAG_EXE)
struct intel_validate_entry {
- ddx_bo *bo;
+ dri_bo *bo;
struct drm_i915_op_arg bo_arg;
};
-typedef struct _ddx_bufmgr_ttm {
- ddx_bufmgr bufmgr;
+typedef struct _dri_bufmgr_ttm {
+ dri_bufmgr bufmgr;
- int fd;
- unsigned int fence_type;
- unsigned int fence_type_flush;
+ int fd;
+ unsigned int fence_type;
+ unsigned int fence_type_flush;
- uint32_t max_relocs;
+ uint32_t max_relocs;
struct intel_validate_entry *validate_array;
int validate_array_size;
@@ -81,24 +83,23 @@ typedef struct _ddx_bufmgr_ttm {
drmBO *cached_reloc_buf;
uint32_t *cached_reloc_buf_data;
-} ddx_bufmgr_ttm;
-
+} dri_bufmgr_ttm;
/**
* Private information associated with a relocation that isn't already stored
* in the relocation buffer to be passed to the kernel.
*/
-struct _ddx_ttm_reloc {
- ddx_bo *target_buf;
+struct dri_ttm_reloc {
+ dri_bo *target_buf;
uint64_t validate_flags;
};
-typedef struct _ddx_bo_ttm {
- ddx_bo bo;
+typedef struct _dri_bo_ttm {
+ dri_bo bo;
- int refcount; /* Protected by bufmgr->mutex */
- drmBO drm_bo;
- const char *name;
+ int refcount;
+ drmBO drm_bo;
+ const char *name;
uint64_t last_flags;
@@ -111,44 +112,44 @@ typedef struct _ddx_bo_ttm {
/** DRM buffer object containing relocation list */
drmBO *reloc_buf;
uint32_t *reloc_buf_data;
- struct _ddx_ttm_reloc *relocs;
+ struct dri_ttm_reloc *relocs;
/**
* Indicates that the buffer may be shared with other processes, so we
* can't hold maps beyond when the user does.
*/
- Bool shared;
+ GLboolean shared;
- Bool delayed_unmap;
+ GLboolean delayed_unmap;
/* Virtual address from the dri_bo_map whose unmap was delayed. */
void *saved_virtual;
-} ddx_bo_ttm;
+} dri_bo_ttm;
typedef struct _dri_fence_ttm
{
- dri_fence fence;
+ dri_fence fence;
- int refcount; /* Protected by bufmgr->mutex */
- const char *name;
- drmFence drm_fence;
+ int refcount;
+ const char *name;
+ drmFence drm_fence;
} dri_fence_ttm;
-static void dri_ttm_dump_validation_list(ddx_bufmgr_ttm *bufmgr_ttm)
+static void dri_ttm_dump_validation_list(dri_bufmgr_ttm *bufmgr_ttm)
{
int i, j;
for (i = 0; i < bufmgr_ttm->validate_count; i++) {
- ddx_bo *bo = bufmgr_ttm->validate_array[i].bo;
- ddx_bo_ttm *bo_ttm = (ddx_bo_ttm *)bo;
+ dri_bo *bo = bufmgr_ttm->validate_array[i].bo;
+ dri_bo_ttm *bo_ttm = (dri_bo_ttm *)bo;
if (bo_ttm->reloc_buf_data != NULL) {
for (j = 0; j < (bo_ttm->reloc_buf_data[0] & 0xffff); j++) {
uint32_t *reloc_entry = bo_ttm->reloc_buf_data +
I915_RELOC_HEADER +
j * I915_RELOC0_STRIDE;
- ddx_bo *target_bo =
+ dri_bo *target_bo =
bufmgr_ttm->validate_array[reloc_entry[2]].bo;
- ddx_bo_ttm *target_ttm = (ddx_bo_ttm *)target_bo;
+ dri_bo_ttm *target_ttm = (dri_bo_ttm *)target_bo;
DBG("%2d: %s at 0x%08x -> %s at 0x%08x + 0x%08x\n",
i,
@@ -171,18 +172,18 @@ static void dri_ttm_dump_validation_list(ddx_bufmgr_ttm *bufmgr_ttm)
* access flags.
*/
static void
-intelddx_add_validate_buffer(ddx_bo *buf,
+intel_add_validate_buffer(dri_bo *buf,
uint64_t flags)
{
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)buf->bufmgr;
- ddx_bo_ttm *ttm_buf = (ddx_bo_ttm *)buf;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
+ dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
/* If we delayed doing an unmap to mitigate map/unmap syscall thrashing,
* do that now.
*/
if (ttm_buf->delayed_unmap) {
drmBOUnmap(bufmgr_ttm->fd, &ttm_buf->drm_bo);
- ttm_buf->delayed_unmap = FALSE;
+ ttm_buf->delayed_unmap = GL_FALSE;
}
if (ttm_buf->validate_index == -1) {
@@ -218,7 +219,7 @@ intelddx_add_validate_buffer(ddx_bo *buf,
/* Fill in array entry */
entry->bo = buf;
- ddx_bo_reference(buf);
+ dri_bo_reference(buf);
/* Fill in kernel arg */
arg = &entry->bo_arg;
@@ -276,17 +277,18 @@ intelddx_add_validate_buffer(ddx_bo *buf,
}
}
+
#define RELOC_BUF_SIZE(x) ((I915_RELOC_HEADER + x * I915_RELOC0_STRIDE) * \
sizeof(uint32_t))
static int
-intelddx_setup_reloc_list(ddx_bo *bo)
+intel_setup_reloc_list(dri_bo *bo)
{
- ddx_bo_ttm *bo_ttm = (ddx_bo_ttm *)bo;
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)bo->bufmgr;
+ dri_bo_ttm *bo_ttm = (dri_bo_ttm *)bo;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bo->bufmgr;
int ret;
- bo_ttm->relocs = malloc(sizeof(struct _ddx_ttm_reloc) *
+ bo_ttm->relocs = malloc(sizeof(struct dri_ttm_reloc) *
bufmgr_ttm->max_relocs);
if (bufmgr_ttm->cached_reloc_buf != NULL) {
@@ -340,153 +342,150 @@ intelddx_setup_reloc_list(ddx_bo *bo)
int
driFenceSignaled(DriFenceObject * fence, unsigned type)
{
- int signaled;
- int ret;
+ int signaled;
+ int ret;
- if (fence == NULL)
- return TRUE;
+ if (fence == NULL)
+ return GL_TRUE;
- ret = drmFenceSignaled(bufmgr_ttm->fd, &fence->fence, type, &signaled);
- BM_CKFATAL(ret);
- return signaled;
+ ret = drmFenceSignaled(bufmgr_ttm->fd, &fence->fence, type, &signaled);
+ BM_CKFATAL(ret);
+ return signaled;
}
#endif
-static ddx_bo *
-dri_ttm_alloc(ddx_bufmgr *bufmgr, const char *name,
+static dri_bo *
+dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
unsigned long size, unsigned int alignment,
- uint64_t location_mask)
+ uint64_t location_mask)
{
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)bufmgr;
- ddx_bo_ttm *ttm_buf;
- unsigned int pageSize = getpagesize();
- int ret;
- unsigned int flags, hint;
-
- ttm_buf = malloc(sizeof(*ttm_buf));
- if (!ttm_buf)
- return NULL;
-
- /* The mask argument doesn't do anything for us that we want other than
- * determine which pool (TTM or local) the buffer is allocated into, so just
- * pass all of the allocation class flags.
- */
- flags = location_mask | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_EXE;
- /* No hints we want to use. */
- hint = 0;
-
- ret = drmBOCreate(bufmgr_ttm->fd, size, alignment / pageSize,
- NULL, flags, hint, &ttm_buf->drm_bo);
- if (ret != 0) {
- free(ttm_buf);
- return NULL;
- }
- ttm_buf->bo.size = ttm_buf->drm_bo.size;
- ttm_buf->bo.offset = ttm_buf->drm_bo.offset;
- ttm_buf->bo.virtual = NULL;
- ttm_buf->bo.bufmgr = bufmgr;
- ttm_buf->name = name;
- ttm_buf->refcount = 1;
- ttm_buf->reloc_buf = NULL;
- ttm_buf->reloc_buf_data = NULL;
- ttm_buf->relocs = NULL;
- ttm_buf->last_flags = ttm_buf->drm_bo.flags;
- ttm_buf->shared = FALSE;
- ttm_buf->delayed_unmap = FALSE;
- ttm_buf->validate_index = -1;
-
-#if BUFMGR_DEBUG
- fprintf(stderr, "bo_create: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
-#endif
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
+ dri_bo_ttm *ttm_buf;
+ unsigned int pageSize = getpagesize();
+ int ret;
+ unsigned int flags, hint;
- return &ttm_buf->bo;
+ ttm_buf = malloc(sizeof(*ttm_buf));
+ if (!ttm_buf)
+ return NULL;
+
+ /* The mask argument doesn't do anything for us that we want other than
+ * determine which pool (TTM or local) the buffer is allocated into, so
+ * just pass all of the allocation class flags.
+ */
+ flags = location_mask | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
+ DRM_BO_FLAG_EXE;
+ /* No hints we want to use. */
+ hint = 0;
+
+ ret = drmBOCreate(bufmgr_ttm->fd, size, alignment / pageSize,
+ NULL, flags, hint, &ttm_buf->drm_bo);
+ if (ret != 0) {
+ free(ttm_buf);
+ return NULL;
+ }
+ ttm_buf->bo.size = ttm_buf->drm_bo.size;
+ ttm_buf->bo.offset = ttm_buf->drm_bo.offset;
+ ttm_buf->bo.virtual = NULL;
+ ttm_buf->bo.bufmgr = bufmgr;
+ ttm_buf->name = name;
+ ttm_buf->refcount = 1;
+ ttm_buf->reloc_buf = NULL;
+ ttm_buf->reloc_buf_data = NULL;
+ ttm_buf->relocs = NULL;
+ ttm_buf->last_flags = ttm_buf->drm_bo.flags;
+ ttm_buf->shared = GL_FALSE;
+ ttm_buf->delayed_unmap = GL_FALSE;
+ ttm_buf->validate_index = -1;
+
+ DBG("bo_create: %p (%s) %db\n", &ttm_buf->bo, ttm_buf->name, size);
+
+ return &ttm_buf->bo;
}
/* Our TTM backend doesn't allow creation of static buffers, as that requires
* privelege for the non-fake case, and the lock in the fake case where we were
* working around the X Server not creating buffers and passing handles to us.
*/
-static ddx_bo *
-dri_ttm_alloc_static(ddx_bufmgr *bufmgr, const char *name,
+static dri_bo *
+dri_ttm_alloc_static(dri_bufmgr *bufmgr, const char *name,
unsigned long offset, unsigned long size, void *virtual,
uint64_t location_mask)
{
- return NULL;
+ return NULL;
}
-/** Returns a ddx_bo wrapping the given buffer object handle.
+/**
+ * Returns a dri_bo wrapping the given buffer object handle.
*
* This can be used when one application needs to pass a buffer object
* to another.
*/
-ddx_bo *
-intelddx_ttm_bo_create_from_handle(ddx_bufmgr *bufmgr, const char *name,
+dri_bo *
+intel_ttm_bo_create_from_handle(dri_bufmgr *bufmgr, const char *name,
unsigned int handle)
{
- ddx_bufmgr_ttm *bufmgr_ttm;
- ddx_bo_ttm *ttm_buf;
- int ret;
-
- bufmgr_ttm = (ddx_bufmgr_ttm *)bufmgr;
-
- ttm_buf = malloc(sizeof(*ttm_buf));
- if (!ttm_buf)
- return NULL;
-
- ret = drmBOReference(bufmgr_ttm->fd, handle, &ttm_buf->drm_bo);
- if (ret != 0) {
- free(ttm_buf);
- return NULL;
- }
- ttm_buf->bo.size = ttm_buf->drm_bo.size;
- ttm_buf->bo.offset = ttm_buf->drm_bo.offset;
- ttm_buf->bo.virtual = NULL;
- ttm_buf->bo.bufmgr = bufmgr;
- ttm_buf->name = name;
- ttm_buf->refcount = 1;
- ttm_buf->reloc_buf = NULL;
- ttm_buf->reloc_buf_data = NULL;
- ttm_buf->relocs = NULL;
- ttm_buf->last_flags = ttm_buf->drm_bo.flags;
- ttm_buf->shared = TRUE;
- ttm_buf->delayed_unmap = FALSE;
- ttm_buf->validate_index = -1;
-
-#if BUFMGR_DEBUG
- fprintf(stderr, "bo_create_from_handle: %p %08x (%s)\n", &ttm_buf->bo, handle,
- ttm_buf->name);
-#endif
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
+ dri_bo_ttm *ttm_buf;
+ int ret;
- return &ttm_buf->bo;
+ ttm_buf = malloc(sizeof(*ttm_buf));
+ if (!ttm_buf)
+ return NULL;
+
+ ret = drmBOReference(bufmgr_ttm->fd, handle, &ttm_buf->drm_bo);
+ if (ret != 0) {
+ fprintf(stderr, "Couldn't reference %s handle 0x%08x: %s\n",
+ name, handle, strerror(-ret));
+ free(ttm_buf);
+ return NULL;
+ }
+ ttm_buf->bo.size = ttm_buf->drm_bo.size;
+ ttm_buf->bo.offset = ttm_buf->drm_bo.offset;
+ ttm_buf->bo.virtual = NULL;
+ ttm_buf->bo.bufmgr = bufmgr;
+ ttm_buf->name = name;
+ ttm_buf->refcount = 1;
+ ttm_buf->reloc_buf = NULL;
+ ttm_buf->reloc_buf_data = NULL;
+ ttm_buf->relocs = NULL;
+ ttm_buf->last_flags = ttm_buf->drm_bo.flags;
+ ttm_buf->shared = GL_TRUE;
+ ttm_buf->delayed_unmap = GL_FALSE;
+ ttm_buf->validate_index = -1;
+
+ DBG("bo_create_from_handle: %p %08x (%s)\n",
+ &ttm_buf->bo, handle, ttm_buf->name);
+
+ return &ttm_buf->bo;
}
static void
-dri_ttm_bo_reference(ddx_bo *buf)
+dri_ttm_bo_reference(dri_bo *buf)
{
- ddx_bo_ttm *ttm_buf = (ddx_bo_ttm *)buf;
+ dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
- ttm_buf->refcount++;
+ ttm_buf->refcount++;
}
static void
-dri_ttm_bo_unreference(ddx_bo *buf)
+dri_ttm_bo_unreference(dri_bo *buf)
{
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)buf->bufmgr;
- ddx_bo_ttm *ttm_buf = (ddx_bo_ttm *)buf;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
+ dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
- if (!buf)
- return;
+ if (!buf)
+ return;
- if (--ttm_buf->refcount == 0) {
- int ret;
+ if (--ttm_buf->refcount == 0) {
+ int ret;
- if (ttm_buf->reloc_buf) {
+ if (ttm_buf->reloc_buf) {
int i;
/* Unreference all the target buffers */
for (i = 0; i < (ttm_buf->reloc_buf_data[0] & 0xffff); i++)
- ddx_bo_unreference(ttm_buf->relocs[i].target_buf);
+ dri_bo_unreference(ttm_buf->relocs[i].target_buf);
free(ttm_buf->relocs);
if (bufmgr_ttm->cached_reloc_buf == NULL) {
@@ -509,32 +508,30 @@ dri_ttm_bo_unreference(ddx_bo *buf)
ret = drmBOUnreference(bufmgr_ttm->fd, &ttm_buf->drm_bo);
if (ret != 0) {
- fprintf(stderr, "drmBOUnreference failed (%s): %s\n", ttm_buf->name,
- strerror(-ret));
+ fprintf(stderr, "drmBOUnreference failed (%s): %s\n",
+ ttm_buf->name, strerror(-ret));
}
-#if BUFMGR_DEBUG
- fprintf(stderr, "bo_unreference final: %p (%s)\n",
- &ttm_buf->bo, ttm_buf->name);
-#endif
+ DBG("bo_unreference final: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
+
free(buf);
return;
- }
+ }
}
static int
-dri_ttm_bo_map(ddx_bo *buf, Bool write_enable)
+dri_ttm_bo_map(dri_bo *buf, GLboolean write_enable)
{
- ddx_bufmgr_ttm *bufmgr_ttm;
- ddx_bo_ttm *ttm_buf = (ddx_bo_ttm *)buf;
- unsigned int flags;
+ dri_bufmgr_ttm *bufmgr_ttm;
+ dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
+ unsigned int flags;
- bufmgr_ttm = (ddx_bufmgr_ttm *)buf->bufmgr;
+ bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
- flags = DRM_BO_FLAG_READ;
- if (write_enable)
- flags |= DRM_BO_FLAG_WRITE;
+ flags = DRM_BO_FLAG_READ;
+ if (write_enable)
+ flags |= DRM_BO_FLAG_WRITE;
- assert(buf->virtual == NULL);
+ assert(buf->virtual == NULL);
DBG("bo_map: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
@@ -544,137 +541,128 @@ dri_ttm_bo_map(ddx_bo *buf, Bool write_enable)
return 0;
}
- return drmBOMap(bufmgr_ttm->fd, &ttm_buf->drm_bo, flags, 0, &buf->virtual);
+ return drmBOMap(bufmgr_ttm->fd, &ttm_buf->drm_bo, flags, 0, &buf->virtual);
}
static int
-dri_ttm_bo_unmap(ddx_bo *buf)
+dri_ttm_bo_unmap(dri_bo *buf)
{
- ddx_bufmgr_ttm *bufmgr_ttm;
- ddx_bo_ttm *ttm_buf = (ddx_bo_ttm *)buf;
+ dri_bufmgr_ttm *bufmgr_ttm;
+ dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
+
+ if (buf == NULL)
+ return 0;
- if (buf == NULL)
- return 0;
+ bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
- bufmgr_ttm = (ddx_bufmgr_ttm *)buf->bufmgr;
+ assert(buf->virtual != NULL);
- assert(buf->virtual != NULL);
+ DBG("bo_unmap: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
- if (!ttm_buf->shared) {
+ if (!ttm_buf->shared) {
ttm_buf->saved_virtual = buf->virtual;
- ttm_buf->delayed_unmap = TRUE;
+ ttm_buf->delayed_unmap = GL_TRUE;
buf->virtual = NULL;
- return 0;
- }
- buf->virtual = NULL;
+ return 0;
+ }
-#if BUFMGR_DEBUG
- fprintf(stderr, "bo_unmap: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
-#endif
+ buf->virtual = NULL;
- return drmBOUnmap(bufmgr_ttm->fd, &ttm_buf->drm_bo);
+ return drmBOUnmap(bufmgr_ttm->fd, &ttm_buf->drm_bo);
}
-/* Returns a ddx_bo wrapping the given buffer object handle.
+/**
+ * Returns a dri_bo wrapping the given buffer object handle.
*
* This can be used when one application needs to pass a buffer object
* to another.
*/
dri_fence *
-intelddx_ttm_fence_create_from_arg(ddx_bufmgr *bufmgr, const char *name,
+intel_ttm_fence_create_from_arg(dri_bufmgr *bufmgr, const char *name,
drm_fence_arg_t *arg)
{
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)bufmgr;
- dri_fence_ttm *ttm_fence;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
+ dri_fence_ttm *ttm_fence;
ttm_fence = malloc(sizeof(*ttm_fence));
- if (!ttm_fence)
- return NULL;
-
- ttm_fence->drm_fence.handle = arg->handle;
- ttm_fence->drm_fence.fence_class = arg->fence_class;
- ttm_fence->drm_fence.type = arg->type;
- ttm_fence->drm_fence.flags = arg->flags;
- ttm_fence->drm_fence.signaled = 0;
- ttm_fence->drm_fence.sequence = arg->sequence;
-
- ttm_fence->fence.bufmgr = bufmgr;
- ttm_fence->name = name;
- ttm_fence->refcount = 1;
-
-#if BUFMGR_DEBUG
- fprintf(stderr, "fence_create_from_handle: %p (%s)\n", &ttm_fence->fence,
- ttm_fence->name);
-#endif
+ if (!ttm_fence)
+ return NULL;
+
+ ttm_fence->drm_fence.handle = arg->handle;
+ ttm_fence->drm_fence.fence_class = arg->fence_class;
+ ttm_fence->drm_fence.type = arg->type;
+ ttm_fence->drm_fence.flags = arg->flags;
+ ttm_fence->drm_fence.signaled = 0;
+ ttm_fence->drm_fence.sequence = arg->sequence;
+
+ ttm_fence->fence.bufmgr = bufmgr;
+ ttm_fence->name = name;
+ ttm_fence->refcount = 1;
+
+ DBG("fence_create_from_handle: %p (%s)\n",
+ &ttm_fence->fence, ttm_fence->name);
- return &ttm_fence->fence;
+ return &ttm_fence->fence;
}
static void
dri_ttm_fence_reference(dri_fence *fence)
{
- dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence;
+ dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)fence->bufmgr;
- ++fence_ttm->refcount;
-#if BUFMGR_DEBUG
- fprintf(stderr, "fence_reference: %p (%s)\n", &fence_ttm->fence,
- fence_ttm->name);
-#endif
+ ++fence_ttm->refcount;
+ DBG("fence_reference: %p (%s)\n", &fence_ttm->fence, fence_ttm->name);
}
static void
dri_ttm_fence_unreference(dri_fence *fence)
{
- dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence;
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)fence->bufmgr;
+ dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)fence->bufmgr;
+
+ if (!fence)
+ return;
- if (!fence)
- return;
+ DBG("fence_unreference: %p (%s)\n", &fence_ttm->fence, fence_ttm->name);
-#if BUFMGR_DEBUG
- fprintf(stderr, "fence_unreference: %d %p (%s)\n", fence_ttm->refcount, &fence_ttm->fence,
- fence_ttm->name);
-#endif
- if (--fence_ttm->refcount == 0) {
- int ret;
-
- ret = drmFenceUnreference(bufmgr_ttm->fd, &fence_ttm->drm_fence);
- if (ret != 0) {
- fprintf(stderr, "drmFenceUnreference failed (%s): %s\n",
- fence_ttm->name, strerror(-ret));
- }
-
- free(fence);
- return;
- }
+ if (--fence_ttm->refcount == 0) {
+ int ret;
+
+ ret = drmFenceUnreference(bufmgr_ttm->fd, &fence_ttm->drm_fence);
+ if (ret != 0) {
+ fprintf(stderr, "drmFenceUnreference failed (%s): %s\n",
+ fence_ttm->name, strerror(-ret));
+ }
+
+ free(fence);
+ return;
+ }
}
static void
dri_ttm_fence_wait(dri_fence *fence)
{
- dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence;
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)fence->bufmgr;
- int ret;
-
- ret = drmFenceWait(bufmgr_ttm->fd, DRM_FENCE_FLAG_WAIT_LAZY, &fence_ttm->drm_fence, 0);
- if (ret != 0) {
- ErrorF("%s:%d: Error %d waiting for fence %s.\n",
- __FILE__, __LINE__, ret, fence_ttm->name);
- abort();
- }
-
-#if BUFMGR_DEBUG
- fprintf(stderr, "fence_wait: %p (%s)\n", &fence_ttm->fence,
- fence_ttm->name);
-#endif
+ dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)fence->bufmgr;
+ int ret;
+
+ ret = drmFenceWait(bufmgr_ttm->fd, DRM_FENCE_FLAG_WAIT_LAZY, &fence_ttm->drm_fence, 0);
+ if (ret != 0) {
+ fprintf(stderr, "%s:%d: Error %d waiting for fence %s.\n",
+ __FILE__, __LINE__, ret, fence_ttm->name);
+ abort();
+ }
+
+ DBG("fence_wait: %p (%s)\n", &fence_ttm->fence, fence_ttm->name);
}
static void
-ddx_bufmgr_ttm_destroy(ddx_bufmgr *bufmgr)
+dri_bufmgr_ttm_destroy(dri_bufmgr *bufmgr)
{
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)bufmgr;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
if (bufmgr_ttm->cached_reloc_buf) {
/* Free the cached kernel BO containing relocation entries */
@@ -685,7 +673,7 @@ ddx_bufmgr_ttm_destroy(ddx_bufmgr *bufmgr)
free(bufmgr_ttm->validate_array);
- free(bufmgr);
+ free(bufmgr);
}
/**
@@ -698,17 +686,17 @@ ddx_bufmgr_ttm_destroy(ddx_bufmgr *bufmgr)
* last known offset in target_buf.
*/
static void
-dri_ttm_emit_reloc(ddx_bo *reloc_buf, uint64_t flags, uint32_t delta,
- uint32_t offset, ddx_bo *target_buf)
+dri_ttm_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
+ GLuint offset, dri_bo *target_buf)
{
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)reloc_buf->bufmgr;
- ddx_bo_ttm *reloc_buf_ttm = (ddx_bo_ttm *)reloc_buf;
- int num_relocs;
- uint32_t *this_reloc;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)reloc_buf->bufmgr;
+ dri_bo_ttm *reloc_buf_ttm = (dri_bo_ttm *)reloc_buf;
+ int num_relocs;
+ uint32_t *this_reloc;
/* Create a new relocation list if needed */
if (reloc_buf_ttm->reloc_buf == NULL)
- intelddx_setup_reloc_list(reloc_buf);
+ intel_setup_reloc_list(reloc_buf);
num_relocs = (reloc_buf_ttm->reloc_buf_data[0] & 0xffff);
@@ -726,12 +714,11 @@ dri_ttm_emit_reloc(ddx_bo *reloc_buf, uint64_t flags, uint32_t delta,
reloc_buf_ttm->relocs[num_relocs].validate_flags = flags;
reloc_buf_ttm->relocs[num_relocs].target_buf = target_buf;
- ddx_bo_reference(target_buf);
+ dri_bo_reference(target_buf);
reloc_buf_ttm->reloc_buf_data[0]++; /* Increment relocation count */
/* Check wraparound */
assert((reloc_buf_ttm->reloc_buf_data[0] & 0xffff) != 0);
- return;
}
/**
@@ -740,9 +727,9 @@ dri_ttm_emit_reloc(ddx_bo *reloc_buf, uint64_t flags, uint32_t delta,
* index values into the validation list.
*/
static void
-dri_ttm_bo_process_reloc(ddx_bo *bo)
+dri_ttm_bo_process_reloc(dri_bo *bo)
{
- ddx_bo_ttm *bo_ttm = (ddx_bo_ttm *)bo;
+ dri_bo_ttm *bo_ttm = (dri_bo_ttm *)bo;
unsigned int nr_relocs;
int i;
@@ -752,15 +739,15 @@ dri_ttm_bo_process_reloc(ddx_bo *bo)
nr_relocs = bo_ttm->reloc_buf_data[0] & 0xffff;
for (i = 0; i < nr_relocs; i++) {
- struct _ddx_ttm_reloc *r = &bo_ttm->relocs[i];
- ddx_bo_ttm *target_ttm = (ddx_bo_ttm *)r->target_buf;
+ struct dri_ttm_reloc *r = &bo_ttm->relocs[i];
+ dri_bo_ttm *target_ttm = (dri_bo_ttm *)r->target_buf;
uint32_t *reloc_entry;
/* Continue walking the tree depth-first. */
dri_ttm_bo_process_reloc(r->target_buf);
/* Add the target to the validate list */
- intelddx_add_validate_buffer(r->target_buf, r->validate_flags);
+ intel_add_validate_buffer(r->target_buf, r->validate_flags);
/* Update the index of the target in the relocation entry */
reloc_entry = bo_ttm->reloc_buf_data + I915_RELOC_HEADER +
@@ -770,19 +757,19 @@ dri_ttm_bo_process_reloc(ddx_bo *bo)
}
static void *
-dri_ttm_process_reloc(ddx_bo *batch_buf, uint32_t *count)
+dri_ttm_process_reloc(dri_bo *batch_buf, GLuint *count)
{
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)batch_buf->bufmgr;
-
- /* Update indices and set up the validate list. */
- dri_ttm_bo_process_reloc(batch_buf);
-
- /* Add the batch buffer to the validation list. There are no relocations
- * pointing to it.
- */
- intelddx_add_validate_buffer(batch_buf,
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)batch_buf->bufmgr;
+
+ /* Update indices and set up the validate list. */
+ dri_ttm_bo_process_reloc(batch_buf);
+
+ /* Add the batch buffer to the validation list. There are no relocations
+ * pointing to it.
+ */
+ intel_add_validate_buffer(batch_buf,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE);
-
+
*count = bufmgr_ttm->validate_count;
return &bufmgr_ttm->validate_array[0].bo_arg;
}
@@ -816,13 +803,13 @@ intel_get_flags_caching_string(uint64_t flags)
}
static void
-intel_update_buffer_offsets (ddx_bufmgr_ttm *bufmgr_ttm)
+intel_update_buffer_offsets (dri_bufmgr_ttm *bufmgr_ttm)
{
int i;
for (i = 0; i < bufmgr_ttm->validate_count; i++) {
- ddx_bo *bo = bufmgr_ttm->validate_array[i].bo;
- ddx_bo_ttm *bo_ttm = (ddx_bo_ttm *)bo;
+ dri_bo *bo = bufmgr_ttm->validate_array[i].bo;
+ dri_bo_ttm *bo_ttm = (dri_bo_ttm *)bo;
struct drm_i915_op_arg *arg = &bufmgr_ttm->validate_array[i].bo_arg;
struct drm_bo_arg_rep *rep = &arg->d.rep;
@@ -847,27 +834,26 @@ intel_update_buffer_offsets (ddx_bufmgr_ttm *bufmgr_ttm)
}
static void
-dri_ttm_post_submit(ddx_bo *batch_buf, dri_fence **last_fence)
+dri_ttm_post_submit(dri_bo *batch_buf, dri_fence **last_fence)
{
- ddx_bufmgr_ttm *bufmgr_ttm = (ddx_bufmgr_ttm *)batch_buf->bufmgr;
- int i;
-
- intel_update_buffer_offsets (bufmgr_ttm);
-
- if (bufmgr_ttm->bufmgr.debug)
- dri_ttm_dump_validation_list(bufmgr_ttm);
-
- for (i = 0; i < bufmgr_ttm->validate_count; i++) {
- ddx_bo *bo = bufmgr_ttm->validate_array[i].bo;
- ddx_bo_ttm *bo_ttm = (ddx_bo_ttm *)bo;
-
- /* Disconnect the buffer from the validate list */
- bo_ttm->validate_index = -1;
- ddx_bo_unreference(bo);
- bufmgr_ttm->validate_array[i].bo = NULL;
- }
- bufmgr_ttm->validate_count = 0;
+ dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)batch_buf->bufmgr;
+ int i;
+
+ intel_update_buffer_offsets (bufmgr_ttm);
+
+ if (bufmgr_ttm->bufmgr.debug)
+ dri_ttm_dump_validation_list(bufmgr_ttm);
+
+ for (i = 0; i < bufmgr_ttm->validate_count; i++) {
+ dri_bo *bo = bufmgr_ttm->validate_array[i].bo;
+ dri_bo_ttm *bo_ttm = (dri_bo_ttm *)bo;
+ /* Disconnect the buffer from the validate list */
+ bo_ttm->validate_index = -1;
+ dri_bo_unreference(bo);
+ bufmgr_ttm->validate_array[i].bo = NULL;
+ }
+ bufmgr_ttm->validate_count = 0;
}
/**
@@ -879,35 +865,42 @@ dri_ttm_post_submit(ddx_bo *batch_buf, dri_fence **last_fence)
* \param fence_type_flush Driver-specific fence type used for fences with a
* flush.
*/
-ddx_bufmgr *
-intelddx_bufmgr_ttm_init(int fd, unsigned int fence_type,
+dri_bufmgr *
+intel_bufmgr_ttm_init(int fd, unsigned int fence_type,
unsigned int fence_type_flush, int batch_size)
{
- ddx_bufmgr_ttm *bufmgr_ttm;
-
- bufmgr_ttm = calloc(1, sizeof(*bufmgr_ttm));
- bufmgr_ttm->fd = fd;
- bufmgr_ttm->fence_type = fence_type;
- bufmgr_ttm->fence_type_flush = fence_type_flush;
- bufmgr_ttm->cached_reloc_buf = NULL;
- bufmgr_ttm->cached_reloc_buf_data = NULL;
-
- /* lets go with one relocation per every four dwords - purely heuristic */
- bufmgr_ttm->max_relocs = batch_size / sizeof(uint32_t) / 2 - 2;
-
- bufmgr_ttm->bufmgr.bo_alloc = dri_ttm_alloc;
- bufmgr_ttm->bufmgr.bo_alloc_static = dri_ttm_alloc_static;
- bufmgr_ttm->bufmgr.bo_reference = dri_ttm_bo_reference;
- bufmgr_ttm->bufmgr.bo_unreference = dri_ttm_bo_unreference;
- bufmgr_ttm->bufmgr.bo_map = dri_ttm_bo_map;
- bufmgr_ttm->bufmgr.bo_unmap = dri_ttm_bo_unmap;
- bufmgr_ttm->bufmgr.fence_reference = dri_ttm_fence_reference;
- bufmgr_ttm->bufmgr.fence_unreference = dri_ttm_fence_unreference;
- bufmgr_ttm->bufmgr.fence_wait = dri_ttm_fence_wait;
- bufmgr_ttm->bufmgr.destroy = ddx_bufmgr_ttm_destroy;
- bufmgr_ttm->bufmgr.emit_reloc = dri_ttm_emit_reloc;
- bufmgr_ttm->bufmgr.process_relocs = dri_ttm_process_reloc;
- bufmgr_ttm->bufmgr.post_submit = dri_ttm_post_submit;
- return &bufmgr_ttm->bufmgr;
+ dri_bufmgr_ttm *bufmgr_ttm;
+
+ bufmgr_ttm = calloc(1, sizeof(*bufmgr_ttm));
+ bufmgr_ttm->fd = fd;
+ bufmgr_ttm->fence_type = fence_type;
+ bufmgr_ttm->fence_type_flush = fence_type_flush;
+ bufmgr_ttm->cached_reloc_buf = NULL;
+ bufmgr_ttm->cached_reloc_buf_data = NULL;
+
+ /* Let's go with one relocation per every 2 dwords (but round down a bit
+ * since a power of two will mean an extra page allocation for the reloc
+ * buffer).
+ *
+ * Every 4 was too few for the blender benchmark.
+ */
+ bufmgr_ttm->max_relocs = batch_size / sizeof(uint32_t) / 2 - 2;
+
+ bufmgr_ttm->bufmgr.bo_alloc = dri_ttm_alloc;
+ bufmgr_ttm->bufmgr.bo_alloc_static = dri_ttm_alloc_static;
+ bufmgr_ttm->bufmgr.bo_reference = dri_ttm_bo_reference;
+ bufmgr_ttm->bufmgr.bo_unreference = dri_ttm_bo_unreference;
+ bufmgr_ttm->bufmgr.bo_map = dri_ttm_bo_map;
+ bufmgr_ttm->bufmgr.bo_unmap = dri_ttm_bo_unmap;
+ bufmgr_ttm->bufmgr.fence_reference = dri_ttm_fence_reference;
+ bufmgr_ttm->bufmgr.fence_unreference = dri_ttm_fence_unreference;
+ bufmgr_ttm->bufmgr.fence_wait = dri_ttm_fence_wait;
+ bufmgr_ttm->bufmgr.destroy = dri_bufmgr_ttm_destroy;
+ bufmgr_ttm->bufmgr.emit_reloc = dri_ttm_emit_reloc;
+ bufmgr_ttm->bufmgr.process_relocs = dri_ttm_process_reloc;
+ bufmgr_ttm->bufmgr.post_submit = dri_ttm_post_submit;
+ bufmgr_ttm->bufmgr.debug = GL_FALSE;
+
+ return &bufmgr_ttm->bufmgr;
}
diff --git a/src/intel_bufmgr_ttm.h b/src/intel_bufmgr_ttm.h
index d67a151..0738839 100644
--- a/src/intel_bufmgr_ttm.h
+++ b/src/intel_bufmgr_ttm.h
@@ -4,14 +4,14 @@
#include "dri_bufmgr.h"
-extern ddx_bo *intelddx_ttm_bo_create_from_handle(ddx_bufmgr *bufmgr, const char *name,
+extern dri_bo *intel_ttm_bo_create_from_handle(dri_bufmgr *bufmgr, const char *name,
unsigned int handle);
-dri_fence *intelddx_ttm_fence_create_from_arg(ddx_bufmgr *bufmgr, const char *name,
+dri_fence *intel_ttm_fence_create_from_arg(dri_bufmgr *bufmgr, const char *name,
drm_fence_arg_t *arg);
-ddx_bufmgr *intelddx_bufmgr_ttm_init(int fd, unsigned int fence_type,
+dri_bufmgr *intel_bufmgr_ttm_init(int fd, unsigned int fence_type,
unsigned int fence_type_flush, int batch_size);
#endif
More information about the xorg-commit
mailing list