diff options
Diffstat (limited to 'src/i830_memory.c')
-rw-r--r-- | src/i830_memory.c | 129 |
1 files changed, 46 insertions, 83 deletions
diff --git a/src/i830_memory.c b/src/i830_memory.c index 96a4d67f..23288588 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -111,15 +111,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* Our hardware status area is just a single page */ #define HWSTATUS_PAGE_SIZE GTT_PAGE_SIZE -enum tile_format { - TILING_NONE, - TILING_XMAJOR, - TILING_YMAJOR -}; - static i830_memory * i830_allocate_aperture(ScrnInfoPtr pScrn, const char *name, long size, unsigned long alignment, int flags); + static void i830_set_fence(ScrnInfoPtr pScrn, int nr, unsigned int offset, unsigned int pitch, unsigned int size, enum tile_format tile_format); @@ -765,6 +760,8 @@ i830_allocate_memory(ScrnInfoPtr pScrn, const char *name, } } + mem->tiling = TILE_NONE; + return mem; } @@ -789,7 +786,7 @@ i830_allocate_memory_tiled(ScrnInfoPtr pScrn, const char *name, i830_memory *mem; int fence_divide, i; - if (tile_format == TILING_NONE) + if (tile_format == TILE_NONE) return i830_allocate_memory(pScrn, name, size, alignment, flags); /* XXX: for now, refuse to tile with movable buffer object allocations, @@ -866,19 +863,11 @@ i830_allocate_memory_tiled(ScrnInfoPtr pScrn, const char *name, } mem->size = size; + mem->tiling = tile_format; return mem; } -static void -i830_describe_tiling(ScrnInfoPtr pScrn, int verbosity, const char *prefix, - i830_memory *mem, unsigned int tiling_mode) -{ - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity, - "%s%s is %stiled\n", prefix, mem->name, - (tiling_mode == FENCE_LINEAR) ? "not " : ""); -} - void i830_describe_allocations(ScrnInfoPtr pScrn, int verbosity, const char *prefix) { @@ -901,6 +890,8 @@ i830_describe_allocations(ScrnInfoPtr pScrn, int verbosity, const char *prefix) "%sFixed memory allocation layout:\n", prefix); for (mem = pI830->memory_list->next; mem->next != NULL; mem = mem->next) { + char phys_suffix[32] = ""; + char *tile_suffix = ""; if (mem->offset >= pI830->stolen_size && mem->prev->offset < pI830->stolen_size) @@ -910,19 +901,18 @@ i830_describe_allocations(ScrnInfoPtr pScrn, int verbosity, const char *prefix) prefix, pI830->stolen_size); } - if (mem->bus_addr == 0) { - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity, - "%s0x%08lx-0x%08lx: %s (%ld kB)\n", prefix, - mem->offset, mem->end - 1, mem->name, - mem->size / 1024); - } else { - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity, - "%s0x%08lx-0x%08lx: %s " - "(%ld kB, 0x%016llx physical)\n", - prefix, - mem->offset, mem->end - 1, mem->name, - mem->size / 1024, mem->bus_addr); - } + if (mem->bus_addr != 0) + snprintf(phys_suffix, sizeof(phys_suffix), + ", 0x%016llx physical\n", mem->bus_addr); + if (mem->tiling == TILE_XMAJOR) + tile_suffix = " X tiled"; + else if (mem->tiling == TILE_YMAJOR) + tile_suffix = " Y tiled"; + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity, + "%s0x%08lx-0x%08lx: %s (%ld kB%s)%s\n", prefix, + mem->offset, mem->end - 1, mem->name, + mem->size / 1024, phys_suffix, tile_suffix); } xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity, "%s0x%08lx: end of aperture\n", @@ -952,25 +942,6 @@ i830_describe_allocations(ScrnInfoPtr pScrn, int verbosity, const char *prefix) prefix, pI830->memory_manager->end); } #endif /* XF86DRI_MM */ - - if (pI830->front_buffer != NULL) { - i830_describe_tiling(pScrn, verbosity, prefix, pI830->front_buffer, - pI830->front_tiled); - } -#ifdef XF86DRI - if (pI830->back_buffer != NULL) { - i830_describe_tiling(pScrn, verbosity, prefix, pI830->back_buffer, - pI830->back_tiled); - } - if (pI830->third_buffer != NULL) { - i830_describe_tiling(pScrn, verbosity, prefix, pI830->third_buffer, - pI830->third_tiled); - } - if (pI830->depth_buffer != NULL) { - i830_describe_tiling(pScrn, verbosity, prefix, pI830->depth_buffer, - pI830->depth_tiled); - } -#endif } static Bool @@ -1098,6 +1069,7 @@ i830_allocate_framebuffer(ScrnInfoPtr pScrn, I830Ptr pI830, BoxPtr FbMemBox, char *name; int flags; i830_memory *front_buffer = NULL; + Bool tiling; /* The front buffer is currently marked as NEED_LIFETIME_FIXED because * DRIDoMappings is the only caller of the rm/add map functions, @@ -1172,24 +1144,30 @@ i830_allocate_framebuffer(ScrnInfoPtr pScrn, I830Ptr pI830, BoxPtr FbMemBox, name = secondary ? "secondary front buffer" : "front buffer"; - /* Attempt to allocate it tiled first if possible. */ - if (pI830->tiling && IsTileable(pScrn, pitch)) { + /* Front buffer tiling has to be disabled with G965 XAA because some of the + * acceleration operations (non-XY COLOR_BLT) can't be done to tiled + * buffers. + */ + if (!pI830->useEXA && IS_I965G(pI830)) + tiling = FALSE; + else + tiling = pI830->tiling; + + /* Attempt to allocate it tiled first if we have page flipping on. */ + if (tiling && IsTileable(pScrn, pitch)) { /* XXX: probably not the case on 965 */ if (IS_I9XX(pI830)) align = MB(1); else align = KB(512); front_buffer = i830_allocate_memory_tiled(pScrn, name, size, - pitch, align, - flags, - TILING_XMAJOR); - pI830->front_tiled = FENCE_XMAJOR; + pitch, align, flags, + TILE_XMAJOR); } /* If not, attempt it linear */ if (front_buffer == NULL) { front_buffer = i830_allocate_memory(pScrn, name, size, KB(64), flags); - pI830->front_tiled = FENCE_LINEAR; } if (front_buffer == NULL) { @@ -1343,10 +1321,7 @@ static void i830_setup_fb_compression(ScrnInfoPtr pScrn) } out: - if (pI830->fb_compression) - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Framebuffer compression " - "enabled\n"); - else + if (!pI830->fb_compression) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Allocation error, framebuffer" " compression disabled\n"); @@ -1522,7 +1497,7 @@ myLog2(unsigned int n) static Bool i830_allocate_backbuffer(ScrnInfoPtr pScrn, i830_memory **buffer, - unsigned int *tiled, const char *name) + const char *name) { I830Ptr pI830 = I830PTR(pScrn); unsigned int pitch = pScrn->displayWidth * pI830->cpp; @@ -1543,8 +1518,7 @@ i830_allocate_backbuffer(ScrnInfoPtr pScrn, i830_memory **buffer, ALIGN_BOTH_ENDS | NEED_LIFETIME_FIXED | ALLOW_SHARING, - TILING_XMAJOR); - *tiled = FENCE_XMAJOR; + TILE_XMAJOR); } /* Otherwise, just allocate it linear. The offset must stay constant @@ -1556,7 +1530,6 @@ i830_allocate_backbuffer(ScrnInfoPtr pScrn, i830_memory **buffer, ALIGN_BOTH_ENDS | NEED_LIFETIME_FIXED | ALLOW_SHARING); - *tiled = FENCE_LINEAR; } if (*buffer == NULL) { @@ -1592,7 +1565,7 @@ i830_allocate_depthbuffer(ScrnInfoPtr pScrn) /* The 965 requires that the depth buffer be in Y Major format, while * the rest appear to fail when handed that format. */ - tile_format = IS_I965G(pI830) ? TILING_YMAJOR: TILING_XMAJOR; + tile_format = IS_I965G(pI830) ? TILE_YMAJOR: TILE_XMAJOR; pI830->depth_buffer = i830_allocate_memory_tiled(pScrn, "depth buffer", size, pitch, @@ -1601,8 +1574,6 @@ i830_allocate_depthbuffer(ScrnInfoPtr pScrn) NEED_LIFETIME_FIXED | ALLOW_SHARING, tile_format); - pI830->depth_tiled = (tile_format == TILING_YMAJOR) ? FENCE_YMAJOR : - FENCE_XMAJOR; } /* Otherwise, allocate it linear. The offset must stay constant @@ -1613,7 +1584,6 @@ i830_allocate_depthbuffer(ScrnInfoPtr pScrn) pI830->depth_buffer = i830_allocate_memory(pScrn, "depth buffer", size, GTT_PAGE_SIZE, ALLOW_SHARING | NEED_LIFETIME_FIXED); - pI830->depth_tiled = FENCE_LINEAR; } if (pI830->depth_buffer == NULL) { @@ -1697,13 +1667,11 @@ i830_allocate_3d_memory(ScrnInfoPtr pScrn) return FALSE; } - if (!i830_allocate_backbuffer(pScrn, &pI830->back_buffer, - &pI830->back_tiled, "back buffer")) + if (!i830_allocate_backbuffer(pScrn, &pI830->back_buffer, "back buffer")) return FALSE; if (pI830->TripleBuffer && !i830_allocate_backbuffer(pScrn, &pI830->third_buffer, - &pI830->third_tiled, "third buffer")) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to allocate third buffer, triple buffering " @@ -1739,14 +1707,9 @@ i830_set_fence(ScrnInfoPtr pScrn, int nr, unsigned int offset, DPRINTF(PFX, "i830_set_fence(): %d, 0x%08x, %d, %d kByte\n", nr, offset, pitch, size / 1024); - assert(tile_format != TILING_NONE); + assert(tile_format != TILE_NONE); if (IS_I965G(pI830)) { - if (tile_format == TILING_XMAJOR) - pitch = 512; - else - pitch = 128; - if (nr < 0 || nr >= FENCE_NEW_NR) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "i830_set_fence(): fence %d out of range\n",nr); @@ -1754,18 +1717,18 @@ i830_set_fence(ScrnInfoPtr pScrn, int nr, unsigned int offset, } switch (tile_format) { - case TILING_XMAJOR: + case TILE_XMAJOR: pI830->fence[nr] = (((pitch / 128) - 1) << 2) | offset | 1; pI830->fence[nr] |= I965_FENCE_X_MAJOR; break; - case TILING_YMAJOR: + case TILE_YMAJOR: /* YMajor can be 128B aligned but the current code dictates * otherwise. This isn't a problem apart from memory waste. * FIXME */ pI830->fence[nr] = (((pitch / 128) - 1) << 2) | offset | 1; pI830->fence[nr] |= I965_FENCE_Y_MAJOR; break; - case TILING_NONE: + case TILE_NONE: break; } @@ -1813,13 +1776,13 @@ i830_set_fence(ScrnInfoPtr pScrn, int nr, unsigned int offset, val = offset | FENCE_VALID; switch (tile_format) { - case TILING_XMAJOR: + case TILE_XMAJOR: val |= FENCE_X_MAJOR; break; - case TILING_YMAJOR: + case TILE_YMAJOR: val |= FENCE_Y_MAJOR; break; - case TILING_NONE: + case TILE_NONE: break; } @@ -1887,7 +1850,7 @@ i830_set_fence(ScrnInfoPtr pScrn, int nr, unsigned int offset, } if ((IS_I945G(pI830) || IS_I945GM(pI830) || IS_G33CLASS(pI830)) - && tile_format == TILING_YMAJOR) + && tile_format == TILE_YMAJOR) fence_pitch = pitch / 128; else if (IS_I9XX(pI830)) fence_pitch = pitch / 512; |