Use the offscreen memory manager as much as possible to do the reservation
of memory at startup. Do some drive-by cleanups while I'm here (sorry!).
This commit is contained in:
parent
e2bb9f38cd
commit
9fe216a458
|
@ -291,24 +291,15 @@ ATICardFini(KdCardInfo *card)
|
||||||
static void
|
static void
|
||||||
ATISetOffscreen (KdScreenInfo *screen)
|
ATISetOffscreen (KdScreenInfo *screen)
|
||||||
{
|
{
|
||||||
|
#if defined(USE_DRI) && defined(GLXEXT)
|
||||||
ATICardInfo(screen);
|
ATICardInfo(screen);
|
||||||
ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
|
ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
|
||||||
int screen_size = screen->fb[0].byteStride * screen->height;
|
|
||||||
#if defined(USE_DRI) && defined(GLXEXT)
|
|
||||||
int l;
|
int l;
|
||||||
#endif
|
#endif
|
||||||
|
int screen_size = screen->fb[0].byteStride * screen->height;
|
||||||
|
|
||||||
screen->off_screen_base = screen_size;
|
screen->off_screen_base = screen_size;
|
||||||
|
|
||||||
if (atic->is_radeon)
|
|
||||||
atis->cursor.cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4;
|
|
||||||
else
|
|
||||||
atis->cursor.cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 3;
|
|
||||||
|
|
||||||
atis->cursor.offset = screen->off_screen_base;
|
|
||||||
|
|
||||||
screen->off_screen_base += atis->cursor.cursor_size;
|
|
||||||
|
|
||||||
#if defined(USE_DRI) && defined(GLXEXT)
|
#if defined(USE_DRI) && defined(GLXEXT)
|
||||||
/* Reserve a static area for the back buffer the same size as the
|
/* Reserve a static area for the back buffer the same size as the
|
||||||
* visible screen. XXX: This would be better initialized in ati_dri.c
|
* visible screen. XXX: This would be better initialized in ati_dri.c
|
||||||
|
@ -357,22 +348,6 @@ ATISetOffscreen (KdScreenInfo *screen)
|
||||||
atis->textureSize = 0;
|
atis->textureSize = 0;
|
||||||
}
|
}
|
||||||
#endif /* USE_DRI && GLXEXT */
|
#endif /* USE_DRI && GLXEXT */
|
||||||
|
|
||||||
/* Reserve a scratch area. It'll be used for storing glyph data during
|
|
||||||
* Composite operations, because glyphs aren't in real pixmaps and thus
|
|
||||||
* can't be migrated.
|
|
||||||
*/
|
|
||||||
atis->scratch_size = 131072; /* big enough for 128x128@32bpp */
|
|
||||||
if (screen->off_screen_base + atis->scratch_size <= screen->memory_size)
|
|
||||||
{
|
|
||||||
atis->scratch_offset = screen->off_screen_base;
|
|
||||||
screen->off_screen_base += atis->scratch_size;
|
|
||||||
atis->scratch_next = atis->scratch_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
atis->scratch_size = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
|
@ -574,6 +549,9 @@ static void
|
||||||
ATIDisable(ScreenPtr pScreen)
|
ATIDisable(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
KdScreenPriv(pScreen);
|
KdScreenPriv(pScreen);
|
||||||
|
#if defined(USE_DRI) && defined(GLXEXT)
|
||||||
|
ATIScreenInfo(pScreenPriv);
|
||||||
|
#endif /* USE_DRI && GLXEXT */
|
||||||
ATICardInfo(pScreenPriv);
|
ATICardInfo(pScreenPriv);
|
||||||
|
|
||||||
ATIUnmapReg(pScreenPriv->card, atic);
|
ATIUnmapReg(pScreenPriv->card, atic);
|
||||||
|
@ -605,8 +583,6 @@ ATILog2(int val)
|
||||||
{
|
{
|
||||||
int bits;
|
int bits;
|
||||||
|
|
||||||
if (!val)
|
|
||||||
return 1;
|
|
||||||
for (bits = 0; val != 0; val >>= 1, ++bits)
|
for (bits = 0; val != 0; val >>= 1, ++bits)
|
||||||
;
|
;
|
||||||
return bits - 1;
|
return bits - 1;
|
||||||
|
|
|
@ -162,10 +162,7 @@ typedef struct _ATICursor {
|
||||||
Bool has_cursor;
|
Bool has_cursor;
|
||||||
CursorPtr pCursor;
|
CursorPtr pCursor;
|
||||||
Pixel source, mask;
|
Pixel source, mask;
|
||||||
KdOffscreenArea *area;
|
KdOffscreenArea *area;
|
||||||
CARD32 offset;
|
|
||||||
|
|
||||||
int cursor_size;
|
|
||||||
} ATICursor;
|
} ATICursor;
|
||||||
|
|
||||||
typedef struct _ATIPortPriv {
|
typedef struct _ATIPortPriv {
|
||||||
|
@ -213,12 +210,10 @@ typedef struct _ATIScreenInfo {
|
||||||
ATICardInfo *atic;
|
ATICardInfo *atic;
|
||||||
KdScreenInfo *screen;
|
KdScreenInfo *screen;
|
||||||
|
|
||||||
void (*save_blockhandler)(int screen, pointer blockData,
|
|
||||||
pointer timeout, pointer readmask);
|
|
||||||
|
|
||||||
int scratch_offset;
|
int scratch_offset;
|
||||||
int scratch_next;
|
int scratch_next;
|
||||||
int scratch_size;
|
int scratch_size;
|
||||||
|
KdOffscreenArea *scratch_area;
|
||||||
|
|
||||||
ATICursor cursor;
|
ATICursor cursor;
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,8 @@ ATIMoveCursor(ScreenPtr pScreen, int x, int y)
|
||||||
(xoff << 16) | yoff);
|
(xoff << 16) | yoff);
|
||||||
MMIO_OUT32(mmio, ATI_REG_CUR_HORZ_VERT_POSN, ATI_CUR_LOCK |
|
MMIO_OUT32(mmio, ATI_REG_CUR_HORZ_VERT_POSN, ATI_CUR_LOCK |
|
||||||
(x << 16) | y);
|
(x << 16) | y);
|
||||||
MMIO_OUT32(mmio, ATI_REG_CUR_OFFSET, (pCurPriv->offset + yoff * stride));
|
MMIO_OUT32(mmio, ATI_REG_CUR_OFFSET, (pCurPriv->area->offset + yoff *
|
||||||
|
stride));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -163,7 +164,7 @@ ClassicLoadCursor(ScreenPtr pScreen)
|
||||||
|
|
||||||
/* Stick new image into cursor memory */
|
/* Stick new image into cursor memory */
|
||||||
ram = (CARD32 *)(pScreenPriv->screen->memory_base +
|
ram = (CARD32 *)(pScreenPriv->screen->memory_base +
|
||||||
pCurPriv->offset);
|
pCurPriv->area->offset);
|
||||||
mskLine = (CARD32 *)bits->mask;
|
mskLine = (CARD32 *)bits->mask;
|
||||||
srcLine = (CARD32 *)bits->source;
|
srcLine = (CARD32 *)bits->source;
|
||||||
|
|
||||||
|
@ -261,7 +262,7 @@ RadeonLoadCursor(ScreenPtr pScreen)
|
||||||
|
|
||||||
/* Stick new image into cursor memory */
|
/* Stick new image into cursor memory */
|
||||||
ram = (CARD32 *)(pScreenPriv->screen->memory_base +
|
ram = (CARD32 *)(pScreenPriv->screen->memory_base +
|
||||||
pCurPriv->offset);
|
pCurPriv->area->offset);
|
||||||
if (pCursor->bits->argb)
|
if (pCursor->bits->argb)
|
||||||
{
|
{
|
||||||
srcLine = pCursor->bits->argb;
|
srcLine = pCursor->bits->argb;
|
||||||
|
@ -445,6 +446,16 @@ ATIQueryBestSize(int class, unsigned short *pwidth, unsigned short *pheight,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ATICursorSave(ScreenPtr pScreen, KdOffscreenArea *area)
|
||||||
|
{
|
||||||
|
KdScreenPriv(pScreen);
|
||||||
|
ATIScreenInfo(pScreenPriv);
|
||||||
|
ATICursor *pCurPriv = &atis->cursor;
|
||||||
|
|
||||||
|
pCurPriv->area = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ATICursorEnable(ScreenPtr pScreen)
|
ATICursorEnable(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
|
@ -456,6 +467,19 @@ ATICursorEnable(ScreenPtr pScreen)
|
||||||
if (!pCurPriv->has_cursor)
|
if (!pCurPriv->has_cursor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (pCurPriv->area == NULL) {
|
||||||
|
if (atic->is_radeon)
|
||||||
|
pCurPriv->area = KdOffscreenAlloc(pScreen,
|
||||||
|
ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4,
|
||||||
|
1, TRUE, ATICursorSave, atis);
|
||||||
|
else
|
||||||
|
pCurPriv->area = KdOffscreenAlloc(pScreen,
|
||||||
|
ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 2,
|
||||||
|
1, TRUE, ATICursorSave, atis);
|
||||||
|
}
|
||||||
|
if (pCurPriv->area == NULL)
|
||||||
|
FatalError("Couldn't allocate offscreen memory for cursor.\n");
|
||||||
|
|
||||||
if (pCurPriv->pCursor) {
|
if (pCurPriv->pCursor) {
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
|
@ -495,7 +519,7 @@ ATICursorInit(ScreenPtr pScreen)
|
||||||
|
|
||||||
pCurPriv->has_cursor = FALSE;
|
pCurPriv->has_cursor = FALSE;
|
||||||
|
|
||||||
if (pCurPriv->cursor_size == 0)
|
if (pCurPriv->area == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (atic->reg_base == NULL)
|
if (atic->reg_base == NULL)
|
||||||
|
|
|
@ -91,6 +91,7 @@ ATIDrawSetup(ScreenPtr pScreen)
|
||||||
* issues.
|
* issues.
|
||||||
*/
|
*/
|
||||||
/*if (!atic->is_radeon) {
|
/*if (!atic->is_radeon) {
|
||||||
|
char *mmio = atic->reg_base;
|
||||||
ATIWaitIdle(atis);
|
ATIWaitIdle(atis);
|
||||||
MMIO_OUT32(mmio, R128_REG_PC_GUI_MODE,
|
MMIO_OUT32(mmio, R128_REG_PC_GUI_MODE,
|
||||||
R128_PC_BYPASS_EN);
|
R128_PC_BYPASS_EN);
|
||||||
|
@ -615,23 +616,23 @@ ATIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
|
||||||
atis->kaa.offscreenPitch - 1) & ~(atis->kaa.offscreenPitch - 1);
|
atis->kaa.offscreenPitch - 1) & ~(atis->kaa.offscreenPitch - 1);
|
||||||
|
|
||||||
size = dst_pitch * pSrc->drawable.height;
|
size = dst_pitch * pSrc->drawable.height;
|
||||||
if (size > atis->scratch_size)
|
if (size > atis->scratch_area->size)
|
||||||
ATI_FALLBACK(("Pixmap too large for scratch (%d,%d)\n",
|
ATI_FALLBACK(("Pixmap too large for scratch (%d,%d)\n",
|
||||||
pSrc->drawable.width, pSrc->drawable.height));
|
pSrc->drawable.width, pSrc->drawable.height));
|
||||||
|
|
||||||
atis->scratch_next = (atis->scratch_next +
|
atis->scratch_next = (atis->scratch_next +
|
||||||
atis->kaa.offscreenByteAlign - 1) &
|
atis->kaa.offscreenByteAlign - 1) &
|
||||||
~(atis->kaa.offscreenByteAlign - 1);
|
~(atis->kaa.offscreenByteAlign - 1);
|
||||||
if (atis->scratch_next + size > atis->scratch_offset +
|
if (atis->scratch_next + size > atis->scratch_area->offset +
|
||||||
atis->scratch_size) {
|
atis->scratch_area->size) {
|
||||||
/* Only sync when we've used all of the scratch area. */
|
/* Only sync when we've used all of the scratch area. */
|
||||||
KdCheckSync(pSrc->drawable.pScreen);
|
KdCheckSync(pSrc->drawable.pScreen);
|
||||||
atis->scratch_next = atis->scratch_offset;
|
atis->scratch_next = atis->scratch_area->offset;
|
||||||
}
|
}
|
||||||
memcpy(pDst, pSrc, sizeof(*pDst));
|
memcpy(pDst, pSrc, sizeof(*pDst));
|
||||||
pDst->devKind = dst_pitch;
|
pDst->devKind = dst_pitch;
|
||||||
pDst->devPrivate.ptr = atis->scratch_next +
|
pDst->devPrivate.ptr = pScreenPriv->screen->memory_base +
|
||||||
pScreenPriv->screen->memory_base;
|
atis->scratch_next;
|
||||||
atis->scratch_next += size;
|
atis->scratch_next += size;
|
||||||
|
|
||||||
src = pSrc->devPrivate.ptr;
|
src = pSrc->devPrivate.ptr;
|
||||||
|
@ -662,7 +663,7 @@ ATIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ATIBlockHandler (pointer blockData, OSTimePtr timeout, pointer readmask)
|
ATIBlockHandler(pointer blockData, OSTimePtr timeout, pointer readmask)
|
||||||
{
|
{
|
||||||
ScreenPtr pScreen = (ScreenPtr) blockData;
|
ScreenPtr pScreen = (ScreenPtr) blockData;
|
||||||
KdScreenPriv(pScreen);
|
KdScreenPriv(pScreen);
|
||||||
|
@ -675,7 +676,7 @@ ATIBlockHandler (pointer blockData, OSTimePtr timeout, pointer readmask)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ATIWakeupHandler (pointer blockData, int result, pointer readmask)
|
ATIWakeupHandler(pointer blockData, int result, pointer readmask)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,7 +686,6 @@ ATIDrawInit(ScreenPtr pScreen)
|
||||||
KdScreenPriv(pScreen);
|
KdScreenPriv(pScreen);
|
||||||
ATIScreenInfo(pScreenPriv);
|
ATIScreenInfo(pScreenPriv);
|
||||||
ATICardInfo(pScreenPriv);
|
ATICardInfo(pScreenPriv);
|
||||||
int align_scratch;
|
|
||||||
|
|
||||||
ErrorF("Screen: %d/%d depth/bpp\n", pScreenPriv->screen->fb[0].depth,
|
ErrorF("Screen: %d/%d depth/bpp\n", pScreenPriv->screen->fb[0].depth,
|
||||||
pScreenPriv->screen->fb[0].bitsPerPixel);
|
pScreenPriv->screen->fb[0].bitsPerPixel);
|
||||||
|
@ -719,19 +719,21 @@ ATIDrawInit(ScreenPtr pScreen)
|
||||||
atis->kaa.offscreenPitch = 32;
|
atis->kaa.offscreenPitch = 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Align the scratch area to what offscreenByteAlign requires. */
|
|
||||||
align_scratch = (atis->scratch_offset +
|
|
||||||
atis->kaa.offscreenByteAlign - 1) &
|
|
||||||
~(atis->kaa.offscreenByteAlign - 1);
|
|
||||||
atis->scratch_size -= align_scratch - atis->scratch_offset;
|
|
||||||
atis->scratch_offset = align_scratch;
|
|
||||||
|
|
||||||
if (!kaaDrawInit(pScreen, &atis->kaa))
|
if (!kaaDrawInit(pScreen, &atis->kaa))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ATIScratchSave(ScreenPtr pScreen, KdOffscreenArea *area)
|
||||||
|
{
|
||||||
|
KdScreenPriv(pScreen);
|
||||||
|
ATIScreenInfo(pScreenPriv);
|
||||||
|
|
||||||
|
atis->scratch_area = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ATIDrawEnable(ScreenPtr pScreen)
|
ATIDrawEnable(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
|
@ -780,7 +782,18 @@ ATIDrawEnable(ScreenPtr pScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
atis->kaa.UploadToScreen = ATIUploadToScreen;
|
atis->kaa.UploadToScreen = ATIUploadToScreen;
|
||||||
atis->kaa.UploadToScratch = ATIUploadToScratch;
|
|
||||||
|
/* Reserve a scratch area. It'll be used for storing glyph data during
|
||||||
|
* Composite operations, because glyphs aren't in real pixmaps and thus
|
||||||
|
* can't be migrated.
|
||||||
|
*/
|
||||||
|
atis->scratch_area = KdOffscreenAlloc(pScreen, 131072,
|
||||||
|
atis->kaa.offscreenByteAlign, TRUE, ATIScratchSave, atis);
|
||||||
|
if (atis->scratch_area != NULL) {
|
||||||
|
atis->scratch_next = atis->scratch_area->offset;
|
||||||
|
atis->kaa.UploadToScratch = ATIUploadToScratch;
|
||||||
|
} else
|
||||||
|
atis->kaa.UploadToScratch = NULL;
|
||||||
|
|
||||||
RegisterBlockAndWakeupHandlers (ATIBlockHandler, ATIWakeupHandler,
|
RegisterBlockAndWakeupHandlers (ATIBlockHandler, ATIWakeupHandler,
|
||||||
pScreen);
|
pScreen);
|
||||||
|
@ -791,10 +804,10 @@ ATIDrawEnable(ScreenPtr pScreen)
|
||||||
void
|
void
|
||||||
ATIDrawDisable(ScreenPtr pScreen)
|
ATIDrawDisable(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
ATIDMATeardown(pScreen);
|
|
||||||
|
|
||||||
RemoveBlockAndWakeupHandlers (ATIBlockHandler, ATIWakeupHandler,
|
RemoveBlockAndWakeupHandlers (ATIBlockHandler, ATIWakeupHandler,
|
||||||
pScreen);
|
pScreen);
|
||||||
|
|
||||||
|
ATIDMATeardown(pScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -89,10 +89,11 @@ void
|
||||||
ATIWaitIdle(ATIScreenInfo *atis);
|
ATIWaitIdle(ATIScreenInfo *atis);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define ATI_FALLBACK(x) \
|
#define ATI_FALLBACK(x) \
|
||||||
do { \
|
do { \
|
||||||
ErrorF x; \
|
ErrorF("%s: ", __FUNCTION__); \
|
||||||
return FALSE; \
|
ErrorF x; \
|
||||||
|
return FALSE; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define ATI_FALLBACK(x) return FALSE
|
#define ATI_FALLBACK(x) return FALSE
|
||||||
|
|
Loading…
Reference in New Issue