diff options
Diffstat (limited to 'src/mesa/drivers/dri/savage/savagedma.c')
-rw-r--r-- | src/mesa/drivers/dri/savage/savagedma.c | 150 |
1 files changed, 1 insertions, 149 deletions
diff --git a/src/mesa/drivers/dri/savage/savagedma.c b/src/mesa/drivers/dri/savage/savagedma.c index 86ee763a31f..51a1e6d2bd1 100644 --- a/src/mesa/drivers/dri/savage/savagedma.c +++ b/src/mesa/drivers/dri/savage/savagedma.c @@ -30,20 +30,7 @@ #include <time.h> #include <unistd.h> -/* Commit does not depend on whether we use real DMA or fake it via the BCI */ -void savageDMACommit (savageContextPtr imesa, void *endPtr) { - DMABufferPtr dmaBuff = &imesa->DMABuf; - GLuint end = (GLuint)endPtr; - - /* make sure that enough space was allocated */ - assert (end <= dmaBuff->allocEnd); - - dmaBuff->allocEnd = dmaBuff->end = end; - - /* TODO: check commands, either here or in flush */ -} - -#if SAVAGE_CMD_DMA +#if 0 /* flag = 0 return -1 if no available page 1 wait until a page be available */ @@ -219,139 +206,4 @@ int savageDMAClose (savageContextPtr imesa) return GL_TRUE; } -#else -/* Allocate space in faked DMA buffer */ -void *savageDMAAlloc (savageContextPtr imesa, GLuint size) { - DMABufferPtr dmaBuff = &imesa->DMABuf; - - /* make sure that everything has been filled in and committed */ - assert (dmaBuff->end == dmaBuff->allocEnd); - - size *= sizeof (u_int32_t); /* size in bytes */ - if (dmaBuff->end + size >= dmaBuff->buf->linear + DMA_PAGE_SIZE) { - /* need kick off */ - savageDMAFlush (imesa); - } - dmaBuff->allocEnd = dmaBuff->end + size; - return (void *)dmaBuff->end; -} - -/* Flush DMA buffer via BCI (faked DMA) */ -void savageDMAFlush(savageContextPtr imesa) { - volatile u_int32_t* BCIbase; - DMABufferPtr dmaBuff = &imesa->DMABuf; - u_int32_t *entry; - - /* make sure that everything has been filled in and committed */ - assert (dmaBuff->allocEnd == dmaBuff->end); - - if (dmaBuff->start == dmaBuff->end) /* no command? */ - return; - - /* get bci base */ - BCIbase = (volatile u_int32_t *)SAVAGE_GET_BCI_POINTER( - imesa, (dmaBuff->end - dmaBuff->start) / sizeof (u_int32_t)); - - for (entry = (u_int32_t *)dmaBuff->start; - entry < (u_int32_t *)dmaBuff->end; ++entry) - *BCIbase = *entry; - - dmaBuff->end = dmaBuff->allocEnd = dmaBuff->start; -} - -/* Init faked DMA */ -int savageDMAInit (savageContextPtr imesa) { - DMABufferPtr dmaBuff = &imesa->DMABuf; - drm_savage_alloc_cont_mem_t * req; - - req = (drm_savage_alloc_cont_mem_t *) - malloc (sizeof(drm_savage_alloc_cont_mem_t)); - if (!req) - return GL_FALSE; - - req->linear = (GLuint)malloc (DMA_PAGE_SIZE); - if (!req->linear) { - free (req); - return GL_FALSE; - } - - dmaBuff->buf = req; - - dmaBuff->start = dmaBuff->end = dmaBuff->allocEnd = req->linear; - dmaBuff->usingPage = 0; - dmaBuff->kickFlag = GL_FALSE; - - return GL_TRUE; -} - -/* Close faked DMA */ -int savageDMAClose (savageContextPtr imesa) { - DMABufferPtr dmaBuff = &imesa->DMABuf; - drm_savage_alloc_cont_mem_t * req = dmaBuff->buf; - - free ((void *)req->linear); - free (req); - - return GL_TRUE; -} - #endif - -/* Faked vertex buffers - * - * This is a dirty hack, knowing that it will go away soon when real - * vertex DMA is implemented and eventually moved to the DRM. - */ - -static u_int32_t vertex_data[16384]; /* 64KB */ -static drmBuf vertex_buffer = { - 0, /* idx */ - 65536, /* total = 64KB */ - 0, /* used */ - (drmAddress)vertex_data /* address */ -}; - -void savageFakeVertices (savageContextPtr imesa, drmBufPtr buffer) { - GLuint vertexStride = imesa->HwVertexSize; /* stride in dwords */ - GLuint vertexSize = imesa->HwVertexSize; /* the real vertex size in dwords */ - GLuint nVertices = buffer->used / (vertexStride*4); - u_int32_t *data = (u_int32_t*)buffer->address; - u_int32_t vertexFormat = imesa->DrawPrimitiveCmd & SAVAGE_HW_SKIPFLAGS; - GLuint i, j, left; - - /* we have the monopoly on vertex buffers ;-) */ - assert (buffer == &vertex_buffer); - assert (buffer->used % (vertexStride*4) == 0); /* whole vertices */ - assert (nVertices % 3 == 0); /* triangle lists */ - - /* Flush (pseodo) DMA before accessing the BCI directly. */ - savageDMAFlush(imesa); - - left = nVertices; - while (left != 0) { - /* Can emit up to 255 vertices (85 triangles) with one command. */ - GLuint count = left > 255 ? 255 : left; - /* Don't go through another buffering mechanism, copy to BCI - * directly. */ - volatile u_int32_t *vb = SAVAGE_GET_BCI_POINTER(imesa, - count*vertexSize + 1); - - WRITE_CMD (vb, SAVAGE_DRAW_PRIMITIVE( - count, SAVAGE_HW_TRIANGLE_LIST | vertexFormat, 0), - u_int32_t); - for (i = 0; i < count; ++i) { - for (j = 0; j < vertexSize; ++j) - WRITE_CMD (vb, data[j], u_int32_t); - data += vertexStride; - } - left -= count; - } - - /* clear the vertex buffer for the next set of vertices */ - vertex_buffer.used = 0; -} - -drmBufPtr savageFakeGetBuffer (savageContextPtr imesa) { - assert (vertex_buffer.used == 0); /* has been flushed */ - return &vertex_buffer; -} |