Commit dc035410 authored by Eric Anholt's avatar Eric Anholt

Move EXA implementation up to the top level and remove its XFree86

    dependencies. It was nearly abstract enough already to be used by
    multiple DDXes. This will be useful for EXA development through
    providing a fake acceleration implementation within Xephyr, so that
    testing can be done on new EXA code without worrying about buggy
    drivers.
parent c170aa83
......@@ -61,6 +61,7 @@ SUBDIRS = \
$(COMPOSITE_DIR) \
$(GLX_DIR) \
$(LBX_DIR) \
exa \
hw \
$(XPDDX_DIR) \
$(XPCONFIG_DIR)
......
......@@ -1538,6 +1538,7 @@ xkb/Makefile
Xext/Makefile
Xi/Makefile
xfixes/Makefile
exa/Makefile
hw/Makefile
hw/xfree86/Makefile
hw/xfree86/common/Makefile
......
module_LTLIBRARIES = libexa.la
noinst_LTLIBRARIES = libexa.la
sdk_HEADERS = exa.h
libexa_la_LDFLAGS = -avoid-version
INCLUDES = \
$(XORG_INCS) \
-I$(srcdir)/../../../miext/cw
-I$(srcdir)/../miext/cw
AM_CFLAGS = $(XORG_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@
AM_CFLAGS = $(XORG_CFLAGS) @SERVER_DEFINES@ @LOADER_DEFINES@ $(DIX_CFLAGS)
libexa_la_SOURCES = \
exa.c \
......
......@@ -22,14 +22,15 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <xorg-config.h>
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdlib.h>
#include "exa_priv.h"
#include <X11/fonts/fontstruct.h>
#include "dixfontstr.h"
#include "xf86str.h"
#include "xf86.h"
#include "exa.h"
#include "cw.h"
......@@ -119,29 +120,12 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)
PixmapPtr pPixmap;
ExaPixmapPrivPtr pExaPixmap;
int bpp;
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
ExaScreenPriv(pScreen);
if (w > 32767 || h > 32767)
return NullPixmap;
if (!pScrn->vtSema || pExaScr->swappedOut) {
pPixmap = pExaScr->SavedCreatePixmap(pScreen, w, h, depth);
} else {
bpp = BitsPerPixel (depth);
if (bpp == 32 && depth == 24)
{
int format;
for (format = 0; format < MAXFORMATS && pScrn->formats[format].depth; ++format)
if (pScrn->formats[format].depth == 24)
{
bpp = pScrn->formats[format].bitsPerPixel;
break;
}
}
pPixmap = fbCreatePixmapBpp (pScreen, w, h, depth, bpp);
}
pPixmap = fbCreatePixmap (pScreen, w, h, depth);
if (!pPixmap)
return NULL;
pExaPixmap = ExaGetPixmapPriv(pPixmap);
......@@ -288,7 +272,6 @@ exaCloseScreen(int i, ScreenPtr pScreen)
#ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
pScreen->CreateGC = pExaScr->SavedCreateGC;
pScreen->CloseScreen = pExaScr->SavedCloseScreen;
......@@ -305,8 +288,6 @@ exaCloseScreen(int i, ScreenPtr pScreen)
ps->Glyphs = pExaScr->SavedGlyphs;
}
#endif
if (pExaScr->wrappedEnableDisableFB)
pScrn->EnableDisableFBAccess = pExaScr->SavedEnableDisableFBAccess;
xfree (pExaScr);
......@@ -317,8 +298,6 @@ Bool
exaDriverInit (ScreenPtr pScreen,
ExaDriverPtr pScreenInfo)
{
/* Do NOT use XF86SCRNINFO macro here!! */
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ExaScreenPrivPtr pExaScr;
#ifdef RENDER
......@@ -334,8 +313,8 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr = xcalloc (sizeof (ExaScreenPrivRec), 1);
if (!pExaScr) {
xf86DrvMsg(pScreen->myNum, X_WARNING,
"EXA: Failed to allocate screen private\n");
LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n",
pScreen->myNum);
return FALSE;
}
......@@ -343,6 +322,8 @@ exaDriverInit (ScreenPtr pScreen,
pScreen->devPrivates[exaScreenPrivateIndex].ptr = (pointer) pExaScr;
exaDDXDriverInit(pScreen);
/*
* Replace various fb screen functions
*/
......@@ -389,8 +370,9 @@ exaDriverInit (ScreenPtr pScreen,
{
if (!AllocatePixmapPrivate(pScreen, exaPixmapPrivateIndex,
sizeof (ExaPixmapPrivRec))) {
xf86DrvMsg(pScreen->myNum, X_WARNING,
"EXA: Failed to allocate pixmap private\n");
LogMessage(X_WARNING,
"EXA(%d): Failed to allocate pixmap private\n",
pScreen->myNum);
return FALSE;
}
pExaScr->SavedCreatePixmap = pScreen->CreatePixmap;
......@@ -401,7 +383,7 @@ exaDriverInit (ScreenPtr pScreen,
}
else
{
xf86DrvMsg(pScreen->myNum, X_INFO, "EXA: No offscreen pixmaps\n");
LogMessage(X_INFO, "EXA(%d): No offscreen pixmaps\n", pScreen->myNum);
if (!AllocatePixmapPrivate(pScreen, exaPixmapPrivateIndex, 0))
return FALSE;
}
......@@ -410,14 +392,10 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr->info->card.memorySize));
if (pExaScr->info->card.offScreenBase < pExaScr->info->card.memorySize) {
if (!exaOffscreenInit (pScreen)) {
xf86DrvMsg(pScreen->myNum, X_WARNING,
"EXA: Offscreen pixmap setup failed\n");
LogMessage(X_WARNING, "EXA(%d): Offscreen pixmap setup failed\n",
pScreen->myNum);
return FALSE;
}
pExaScr->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess;
pScrn->EnableDisableFBAccess = exaEnableDisableFBAccess;
pExaScr->wrappedEnableDisableFB = TRUE;
}
return TRUE;
......@@ -444,9 +422,8 @@ void exaWaitSync(ScreenPtr pScreen)
{
ExaScreenPriv(pScreen);
ExaCardInfoPtr card = &(pExaScr->info->card);
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
if (card->needsSync && pScrn->vtSema) {
if (card->needsSync && !pExaScr->swappedOut) {
(*pExaScr->info->accel.WaitMarker)(pScreen, card->lastMarker);
card->needsSync = FALSE;
}
......@@ -456,61 +433,3 @@ unsigned int exaGetVersion(void)
{
return EXA_VERSION;
}
#ifdef XFree86LOADER
static MODULESETUPPROTO(exaSetup);
static const OptionInfoRec EXAOptions[] = {
{ -1, NULL,
OPTV_NONE, {0}, FALSE }
};
/*ARGSUSED*/
static const OptionInfoRec *
EXAAvailableOptions(void *unused)
{
return (EXAOptions);
}
static XF86ModuleVersionInfo exaVersRec =
{
"exa",
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
XORG_VERSION_CURRENT,
1, 2, 0,
ABI_CLASS_VIDEODRV, /* requires the video driver ABI */
ABI_VIDEODRV_VERSION,
MOD_CLASS_NONE,
{0,0,0,0}
};
XF86ModuleData exaModuleData = { &exaVersRec, exaSetup, NULL };
ModuleInfoRec EXA = {
1,
"EXA",
NULL,
0,
EXAAvailableOptions,
};
/*ARGSUSED*/
static pointer
exaSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor)
{
static Bool Initialised = FALSE;
if (!Initialised) {
Initialised = TRUE;
#ifndef REMOVE_LOADER_CHECK_MODULE_INFO
if (xf86LoaderCheckSymbol("xf86AddModuleInfo"))
#endif
xf86AddModuleInfo(&EXA, Module);
}
return (pointer)TRUE;
}
#endif
......@@ -249,6 +249,9 @@ exaGetPixmapPitch(PixmapPtr pPix);
unsigned long
exaGetPixmapSize(PixmapPtr pPix);
void
exaEnableDisableFBAccess (int index, Bool enable);
#define exaInitCard(exa, sync, memory_base, off_screen_base, memory_size, \
offscreen_byte_align, offscreen_pitch, flags, \
max_x, max_y) \
......
......@@ -22,14 +22,12 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <xorg-config.h>
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "exa_priv.h"
#include <X11/fonts/fontstruct.h>
#include "dixfontstr.h"
#include "xf86str.h"
#include "xf86.h"
#include "exa.h"
#include "cw.h"
......@@ -49,8 +47,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
int off_x, off_y;
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
if (!pScrn->vtSema) {
if (pExaScr->swappedOut) {
ExaCheckFillSpans(pDrawable, pGC, n, ppt, pwidth, fSorted);
return;
}
......@@ -213,8 +210,9 @@ RegionPtr
exaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
int srcx, int srcy, int width, int height, int dstx, int dsty)
{
ScrnInfoPtr pScrn = XF86SCRNINFO(pDstDrawable->pScreen);
if (!pScrn->vtSema) {
ExaScreenPriv (pDstDrawable->pScreen);
if (pExaScr->swappedOut) {
return ExaCheckCopyArea(pSrcDrawable, pDstDrawable, pGC,
srcx, srcy, width, height, dstx, dsty);
}
......@@ -232,7 +230,6 @@ exaPolyFillRect(DrawablePtr pDrawable,
{
ExaScreenPriv (pDrawable->pScreen);
RegionPtr pClip = fbGetCompositeClip(pGC);
ScrnInfoPtr pScrn = XF86SCRNINFO(pDrawable->pScreen);
PixmapPtr pPixmap;
register BoxPtr pbox;
BoxPtr pextent;
......@@ -243,7 +240,7 @@ exaPolyFillRect(DrawablePtr pDrawable,
int xorg, yorg;
int n;
if (!pScrn->vtSema ||
if (pExaScr->swappedOut ||
pGC->fillStyle != FillSolid ||
pDrawable->width > pExaScr->info->card.maxX ||
pDrawable->height > pExaScr->info->card.maxY ||
......@@ -341,14 +338,13 @@ exaSolidBoxClipped (DrawablePtr pDrawable,
int y2)
{
ExaScreenPriv (pDrawable->pScreen);
ScrnInfoPtr pScrn = XF86SCRNINFO(pDrawable->pScreen);
PixmapPtr pPixmap;
BoxPtr pbox;
int nbox;
int xoff, yoff;
int partX1, partX2, partY1, partY2;
if (!pScrn->vtSema ||
if (pExaScr->swappedOut ||
pDrawable->width > pExaScr->info->card.maxX ||
pDrawable->height > pExaScr->info->card.maxY ||
!(pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) ||
......@@ -560,12 +556,12 @@ const GCOps exaOps = {
void
exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
ExaScreenPriv (pWin->drawable.pScreen);
RegionRec rgnDst;
int dx, dy;
PixmapPtr pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
ScrnInfoPtr pScrn = XF86SCRNINFO(pWin->drawable.pScreen);
if (!pScrn->vtSema) {
if (pExaScr->swappedOut) {
ExaScreenPriv(pWin->drawable.pScreen);
pExaScr->SavedCopyWindow (pWin, ptOldOrg, prgnSrc);
exaDrawableDirty (&pWin->drawable);
......@@ -749,11 +745,10 @@ fallback:
void
exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
{
ScrnInfoPtr pScrn = XF86SCRNINFO(pWin->drawable.pScreen);
ExaScreenPriv (pWin->drawable.pScreen);
if (!REGION_NUM_RECTS(pRegion))
return;
if (pScrn->vtSema) {
if (!pExaScr->swappedOut) {
switch (what) {
case PW_BACKGROUND:
switch (pWin->backgroundState) {
......
......@@ -22,8 +22,8 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <xorg-config.h>
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <string.h>
......@@ -31,8 +31,6 @@
#include "exa_priv.h"
#include <X11/fonts/fontstruct.h>
#include "dixfontstr.h"
#include "xf86str.h"
#include "xf86.h"
#include "exa.h"
#include "cw.h"
......
......@@ -270,12 +270,7 @@ exaEnableDisableFBAccess (int index, Bool enable)
if (!enable) {
ExaOffscreenSwapOut (pScreen);
pExaScr->swappedOut = TRUE;
}
if (pExaScr->SavedEnableDisableFBAccess)
(*pExaScr->SavedEnableDisableFBAccess)(index, enable);
if (enable) {
} else {
ExaOffscreenSwapIn (pScreen);
pExaScr->swappedOut = FALSE;
}
......
......@@ -26,8 +26,8 @@
#ifndef EXAPRIV_H
#define EXAPRIV_H
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "exa.h"
......@@ -93,8 +93,6 @@ typedef struct {
CompositeProcPtr SavedComposite;
GlyphsProcPtr SavedGlyphs;
#endif
EnableDisableFBAccessProcPtr SavedEnableDisableFBAccess;
Bool wrappedEnableDisableFB;
Bool swappedOut;
} ExaScreenPrivRec, *ExaScreenPrivPtr;
......@@ -143,6 +141,11 @@ typedef struct {
unsigned int size;
} ExaPixmapPrivRec, *ExaPixmapPrivPtr;
/**
* exaDDXDriverInit must be implemented by the DDX using EXA, and is the place
* to set EXA options or hook in screen functions to handle using EXA as the AA.
*/
void exaDDXDriverInit (ScreenPtr pScreen);
/* exaasync.c */
void
......@@ -281,9 +284,6 @@ ExaOffscreenSwapIn (ScreenPtr pScreen);
void
ExaOffscreenFini (ScreenPtr pScreen);
void
exaEnableDisableFBAccess (int index, Bool enable);
/* exa.c */
void
exaDrawableUseScreen(DrawablePtr pDrawable);
......
/*
/*
* Copyright © 2001 Keith Packard
*
* Partly based on code that is Copyright © The XFree86 Project Inc.
......@@ -22,18 +22,17 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <xorg-config.h>
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdlib.h>
#include "exa_priv.h"
#ifdef RENDER
#include "mipict.h"
#include "xf86str.h"
#include "xf86.h"
#if DEBUG_TRACE_FALL
static void exaCompositeFallbackPictDesc(PicturePtr pict, char *string, int n)
{
......@@ -449,11 +448,10 @@ exaComposite(CARD8 op,
{
ExaScreenPriv (pDst->pDrawable->pScreen);
int ret = -1;
ScrnInfoPtr pScrn = XF86SCRNINFO(pDst->pDrawable->pScreen);
Bool saveSrcRepeat = pSrc->repeat;
Bool saveMaskRepeat = pMask ? pMask->repeat : 0;
if (!pScrn->vtSema) {
if (pExaScr->swappedOut) {
exaDrawableDirty(pDst->pDrawable);
pExaScr->SavedComposite(op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height);
......
module_LTLIBRARIES = libexa.la
sdk_HEADERS = exa.h
libexa_la_LDFLAGS = -avoid-version
INCLUDES = \
$(XORG_INCS) \
-I$(srcdir)/../../../exa \
-I$(srcdir)/../../../miext/cw
AM_CFLAGS = $(XORG_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@
libexa_la_SOURCES = \
exa.c \
exa.h \
exa_accel.c \
exa_migration.c \
exa_offscreen.c \
exa_render.c \
exa_priv.h \
exa_unaccel.c
examodule.c
libexa_la_LIBADD = \
../../../exa/libexa.la
/*
* Copyright 2006 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 <anholt@FreeBSD.org>
*
*/
#ifdef HAVE_CONFIG_H
#include <xorg-config.h>
#endif
#include "exa_priv.h"
#include "xf86str.h"
#include "xf86.h"
typedef struct _ExaXorgScreenPrivRec {
CloseScreenProcPtr SavedCloseScreen;
EnableDisableFBAccessProcPtr SavedEnableDisableFBAccess;
} ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr;
static int exaXorgServerGeneration;
static int exaXorgScreenPrivateIndex;
static Bool
exaXorgCloseScreen (int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
ExaXorgScreenPrivPtr pScreenPriv =
pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr;
pScreen->CloseScreen = pScreenPriv->SavedCloseScreen;
pScrn->EnableDisableFBAccess = pScreenPriv->SavedEnableDisableFBAccess;
xfree (pScreenPriv);
return pScreen->CloseScreen (i, pScreen);
}
static void
exaXorgEnableDisableFBAccess (int index, Bool enable)
{
ScreenPtr pScreen = screenInfo.screens[index];
ExaXorgScreenPrivPtr pScreenPriv =
pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr;
if (!enable)
exaEnableDisableFBAccess (index, enable);
if (pScreenPriv->SavedEnableDisableFBAccess)
pScreenPriv->SavedEnableDisableFBAccess (index, enable);
if (enable)
exaEnableDisableFBAccess (index, enable);
}
/**
* This will be called during exaDriverInit, giving us the chance to set options
* and hook in our EnableDisableFBAccess.
*/
void
exaDDXDriverInit(ScreenPtr pScreen)
{
/* Do NOT use XF86SCRNINFO macro here!! */
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ExaXorgScreenPrivPtr pScreenPriv;
if (exaXorgServerGeneration != serverGeneration) {
exaXorgScreenPrivateIndex = AllocateScreenPrivateIndex();
exaXorgServerGeneration = serverGeneration;
}
pScreenPriv = xcalloc (1, sizeof(ExaXorgScreenPrivRec));
if (pScreenPriv == NULL)
return;
pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr = pScreenPriv;
pScreenPriv->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess;
pScrn->EnableDisableFBAccess = exaXorgEnableDisableFBAccess;
pScreenPriv->SavedCloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = exaXorgCloseScreen;
}
static MODULESETUPPROTO(exaSetup);
static const OptionInfoRec EXAOptions[] = {
{ -1, NULL,
OPTV_NONE, {0}, FALSE }
};
/*ARGSUSED*/
static const OptionInfoRec *
EXAAvailableOptions(void *unused)
{
return (EXAOptions);
}
static XF86ModuleVersionInfo exaVersRec =
{
"exa",
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
XORG_VERSION_CURRENT,
1, 2, 0,
ABI_CLASS_VIDEODRV, /* requires the video driver ABI */
ABI_VIDEODRV_VERSION,
MOD_CLASS_NONE,
{0,0,0,0}
};
XF86ModuleData exaModuleData = { &exaVersRec, exaSetup, NULL };
ModuleInfoRec EXA = {
1,
"EXA",
NULL,
0,
EXAAvailableOptions,
};
/*ARGSUSED*/
static pointer
exaSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor)
{
static Bool Initialised = FALSE;
if (!Initialised) {
Initialised = TRUE;
#ifndef REMOVE_LOADER_CHECK_MODULE_INFO
if (xf86LoaderCheckSymbol("xf86AddModuleInfo"))
#endif
xf86AddModuleInfo(&EXA, Module);
}
return (pointer)TRUE;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment