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
|
||||
ATISetOffscreen (KdScreenInfo *screen)
|
||||
{
|
||||
#if defined(USE_DRI) && defined(GLXEXT)
|
||||
ATICardInfo(screen);
|
||||
ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
|
||||
int screen_size = screen->fb[0].byteStride * screen->height;
|
||||
#if defined(USE_DRI) && defined(GLXEXT)
|
||||
int l;
|
||||
#endif
|
||||
int screen_size = screen->fb[0].byteStride * screen->height;
|
||||
|
||||
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)
|
||||
/* 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
|
||||
@ -357,22 +348,6 @@ ATISetOffscreen (KdScreenInfo *screen)
|
||||
atis->textureSize = 0;
|
||||
}
|
||||
#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
|
||||
@ -574,6 +549,9 @@ static void
|
||||
ATIDisable(ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
#if defined(USE_DRI) && defined(GLXEXT)
|
||||
ATIScreenInfo(pScreenPriv);
|
||||
#endif /* USE_DRI && GLXEXT */
|
||||
ATICardInfo(pScreenPriv);
|
||||
|
||||
ATIUnmapReg(pScreenPriv->card, atic);
|
||||
@ -605,8 +583,6 @@ ATILog2(int val)
|
||||
{
|
||||
int bits;
|
||||
|
||||
if (!val)
|
||||
return 1;
|
||||
for (bits = 0; val != 0; val >>= 1, ++bits)
|
||||
;
|
||||
return bits - 1;
|
||||
|
@ -162,10 +162,7 @@ typedef struct _ATICursor {
|
||||
Bool has_cursor;
|
||||
CursorPtr pCursor;
|
||||
Pixel source, mask;
|
||||
KdOffscreenArea *area;
|
||||
CARD32 offset;
|
||||
|
||||
int cursor_size;
|
||||
KdOffscreenArea *area;
|
||||
} ATICursor;
|
||||
|
||||
typedef struct _ATIPortPriv {
|
||||
@ -213,12 +210,10 @@ typedef struct _ATIScreenInfo {
|
||||
ATICardInfo *atic;
|
||||
KdScreenInfo *screen;
|
||||
|
||||
void (*save_blockhandler)(int screen, pointer blockData,
|
||||
pointer timeout, pointer readmask);
|
||||
|
||||
int scratch_offset;
|
||||
int scratch_next;
|
||||
int scratch_size;
|
||||
KdOffscreenArea *scratch_area;
|
||||
|
||||
ATICursor cursor;
|
||||
|
||||
|
@ -63,7 +63,8 @@ ATIMoveCursor(ScreenPtr pScreen, int x, int y)
|
||||
(xoff << 16) | yoff);
|
||||
MMIO_OUT32(mmio, ATI_REG_CUR_HORZ_VERT_POSN, ATI_CUR_LOCK |
|
||||
(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
|
||||
@ -163,7 +164,7 @@ ClassicLoadCursor(ScreenPtr pScreen)
|
||||
|
||||
/* Stick new image into cursor memory */
|
||||
ram = (CARD32 *)(pScreenPriv->screen->memory_base +
|
||||
pCurPriv->offset);
|
||||
pCurPriv->area->offset);
|
||||
mskLine = (CARD32 *)bits->mask;
|
||||
srcLine = (CARD32 *)bits->source;
|
||||
|
||||
@ -261,7 +262,7 @@ RadeonLoadCursor(ScreenPtr pScreen)
|
||||
|
||||
/* Stick new image into cursor memory */
|
||||
ram = (CARD32 *)(pScreenPriv->screen->memory_base +
|
||||
pCurPriv->offset);
|
||||
pCurPriv->area->offset);
|
||||
if (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
|
||||
ATICursorEnable(ScreenPtr pScreen)
|
||||
{
|
||||
@ -456,6 +467,19 @@ ATICursorEnable(ScreenPtr pScreen)
|
||||
if (!pCurPriv->has_cursor)
|
||||
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) {
|
||||
int x, y;
|
||||
|
||||
@ -495,7 +519,7 @@ ATICursorInit(ScreenPtr pScreen)
|
||||
|
||||
pCurPriv->has_cursor = FALSE;
|
||||
|
||||
if (pCurPriv->cursor_size == 0)
|
||||
if (pCurPriv->area == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (atic->reg_base == NULL)
|
||||
|
@ -91,6 +91,7 @@ ATIDrawSetup(ScreenPtr pScreen)
|
||||
* issues.
|
||||
*/
|
||||
/*if (!atic->is_radeon) {
|
||||
char *mmio = atic->reg_base;
|
||||
ATIWaitIdle(atis);
|
||||
MMIO_OUT32(mmio, R128_REG_PC_GUI_MODE,
|
||||
R128_PC_BYPASS_EN);
|
||||
@ -615,23 +616,23 @@ ATIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
|
||||
atis->kaa.offscreenPitch - 1) & ~(atis->kaa.offscreenPitch - 1);
|
||||
|
||||
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",
|
||||
pSrc->drawable.width, pSrc->drawable.height));
|
||||
|
||||
atis->scratch_next = (atis->scratch_next +
|
||||
atis->kaa.offscreenByteAlign - 1) &
|
||||
~(atis->kaa.offscreenByteAlign - 1);
|
||||
if (atis->scratch_next + size > atis->scratch_offset +
|
||||
atis->scratch_size) {
|
||||
if (atis->scratch_next + size > atis->scratch_area->offset +
|
||||
atis->scratch_area->size) {
|
||||
/* Only sync when we've used all of the scratch area. */
|
||||
KdCheckSync(pSrc->drawable.pScreen);
|
||||
atis->scratch_next = atis->scratch_offset;
|
||||
atis->scratch_next = atis->scratch_area->offset;
|
||||
}
|
||||
memcpy(pDst, pSrc, sizeof(*pDst));
|
||||
pDst->devKind = dst_pitch;
|
||||
pDst->devPrivate.ptr = atis->scratch_next +
|
||||
pScreenPriv->screen->memory_base;
|
||||
pDst->devPrivate.ptr = pScreenPriv->screen->memory_base +
|
||||
atis->scratch_next;
|
||||
atis->scratch_next += size;
|
||||
|
||||
src = pSrc->devPrivate.ptr;
|
||||
@ -662,7 +663,7 @@ ATIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
|
||||
}
|
||||
|
||||
static void
|
||||
ATIBlockHandler (pointer blockData, OSTimePtr timeout, pointer readmask)
|
||||
ATIBlockHandler(pointer blockData, OSTimePtr timeout, pointer readmask)
|
||||
{
|
||||
ScreenPtr pScreen = (ScreenPtr) blockData;
|
||||
KdScreenPriv(pScreen);
|
||||
@ -675,7 +676,7 @@ ATIBlockHandler (pointer blockData, OSTimePtr timeout, pointer readmask)
|
||||
}
|
||||
|
||||
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);
|
||||
ATIScreenInfo(pScreenPriv);
|
||||
ATICardInfo(pScreenPriv);
|
||||
int align_scratch;
|
||||
|
||||
ErrorF("Screen: %d/%d depth/bpp\n", pScreenPriv->screen->fb[0].depth,
|
||||
pScreenPriv->screen->fb[0].bitsPerPixel);
|
||||
@ -719,19 +719,21 @@ ATIDrawInit(ScreenPtr pScreen)
|
||||
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))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
ATIScratchSave(ScreenPtr pScreen, KdOffscreenArea *area)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
ATIScreenInfo(pScreenPriv);
|
||||
|
||||
atis->scratch_area = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ATIDrawEnable(ScreenPtr pScreen)
|
||||
{
|
||||
@ -780,7 +782,18 @@ ATIDrawEnable(ScreenPtr pScreen)
|
||||
}
|
||||
|
||||
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,
|
||||
pScreen);
|
||||
@ -791,10 +804,10 @@ ATIDrawEnable(ScreenPtr pScreen)
|
||||
void
|
||||
ATIDrawDisable(ScreenPtr pScreen)
|
||||
{
|
||||
ATIDMATeardown(pScreen);
|
||||
|
||||
RemoveBlockAndWakeupHandlers (ATIBlockHandler, ATIWakeupHandler,
|
||||
pScreen);
|
||||
|
||||
ATIDMATeardown(pScreen);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -89,10 +89,11 @@ void
|
||||
ATIWaitIdle(ATIScreenInfo *atis);
|
||||
|
||||
#if 0
|
||||
#define ATI_FALLBACK(x) \
|
||||
do { \
|
||||
ErrorF x; \
|
||||
return FALSE; \
|
||||
#define ATI_FALLBACK(x) \
|
||||
do { \
|
||||
ErrorF("%s: ", __FUNCTION__); \
|
||||
ErrorF x; \
|
||||
return FALSE; \
|
||||
} while (0)
|
||||
#else
|
||||
#define ATI_FALLBACK(x) return FALSE
|
||||
|
Loading…
Reference in New Issue
Block a user