Add bufmgr_old that keeps the old pre-ttm functionality.

Modify bufmgr_fake.c for new drm interface. Full rework for bufmgr.c pending.
This commit is contained in:
Thomas Hellström 2006-03-03 18:13:19 +00:00
parent 4291f24abd
commit 78aa58c914
2 changed files with 1192 additions and 27 deletions

View file

@ -28,8 +28,6 @@ static int ttmcount = 0;
* Backdoor mapping will very probably fix this. (texdown-pool)
*/
#define NO_TTM
#undef CACHED_TTMS
/*
@ -44,11 +42,6 @@ static int ttmcount = 0;
#define BATCH_LOCATION 1
#ifdef NO_TTM
#undef BATCH_LOCATION
#define BATCH_LOCATION 0
#endif
#if (BATCH_LOCATION == 2)
#warning Batch buffers using dynamic TTMS. Making TTMS uncached.
#undef CACHED_TTMS
@ -173,12 +166,8 @@ static struct block *alloc_block( struct bufmgr *bm,
int ret;
struct block *block;
unsigned alignment = ( 1 << align );
#ifdef NO_TTM
flags |= BM_NO_TTM;
#endif
if (!(flags & BM_NO_TTM)
if (!(flags & BM_NO_TTM)
#if (BATCH_LOCATION != 2)
#warning Disabling dynamic batch buffers
&& !(flags & BM_CLIENT)
@ -203,9 +192,9 @@ static struct block *alloc_block( struct bufmgr *bm,
block->drm_buf.next = NULL;
#ifdef CACHED_TTMS
block->drm_buf.flags = DRM_TTM_FLAG_NEW | DRM_TTM_FLAG_CACHED;
block->drm_buf.flags = DRM_MM_NEW | DRM_MM_CACHED;
#else
block->drm_buf.flags = DRM_TTM_FLAG_NEW;
block->drm_buf.flags = DRM_MM_NEW;
#endif
block->has_ttm = 2;
if (block->has_ttm > 1)
@ -414,6 +403,7 @@ static int move_buffers( struct bufmgr *bm,
last_block = block;
block->drm_buf.op = ((flags & BM_MEM_MASK) == BM_MEM_AGP) ?
ttm_validate : ttm_unbind;
block->drm_buf.fence_type = 0;
block->mem_type = flags & BM_MEM_MASK;
}
}
@ -662,7 +652,7 @@ int bmInitPool( struct bufmgr *bm,
pool->drm_buf.ttm_page_offset = 0;
pool->drm_buf.num_pages = pool->drm_ttm.size / getpagesize();
pool->drm_buf.next = NULL;
pool->drm_buf.flags = DRM_TTM_FLAG_NEW | DRM_TTM_FLAG_PINNED;
pool->drm_buf.flags = DRM_MM_NEW | DRM_MM_NO_EVICT;
pool->drm_buf.op = ttm_validate;
pool->drm_ttm.op = ttm_bufs;
pool->drm_ttm.num_bufs = 1;
@ -1054,11 +1044,13 @@ unsigned bmFenceBufferList( struct bufmgr *bm, struct bm_buffer_list *list )
drm_ttm_arg_t arg;
int ret;
#if 0
arg.op = ttm_bufs;
arg.do_fence = 1;
arg.num_bufs = 0;
ret = ioctl(bm->intel->driFd, DRM_IOCTL_TTM, &arg);
assert(ret == 0);
#endif
DBG("%s (%d bufs)\n", __FUNCTION__, list->nr);
@ -1091,28 +1083,30 @@ unsigned bmFenceBufferList( struct bufmgr *bm, struct bm_buffer_list *list )
* For now they can stay, but will likely change/move before final:
*/
unsigned bmSetFence( struct bufmgr *bm )
{
assert(bm->intel->locked);
{
/*
* drmEmitFence basically does the same for intel, but userspace
* doesn't know, and calls the kernel to do this. Bypass libdrm.
*/
return intelEmitIrqLocked( bm->intel );
return bm->intel->sarea->last_enqueue;
}
int bmTestFence( struct bufmgr *bm, unsigned fence )
{
/* if (fence % 1024 == 0) */
/* _mesa_printf("%d %d\n", fence, bm->intel->sarea->last_dispatch); */
DBG("fence: %d %d\n", fence, bm->intel->sarea->last_dispatch);
return fence <= bm->intel->sarea->last_dispatch;
drmFence dFence = {0, fence};
int retired;
assert(!drmTestFence(bm->intel->driFd, dFence, 0, &retired));
return retired;
}
void bmFinishFence( struct bufmgr *bm, unsigned fence )
{
if (!bmTestFence(bm, fence))
intelWaitIrq( bm->intel, fence );
drmFence dFence = {0, fence};
assert(!drmWaitFence(bm->intel->driFd, dFence));
}
/* There is a need to tell the hardware to flush various caches
* before we can start reading and writing video memory.
*

File diff suppressed because it is too large Load diff