i915: Remove most of the code under gen >= 4 checks.
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_dma.c
index 22499bc38d1b8fb981f59626f0c7cc9b3b86daf8..3497d481d4b71dc73ffd214d9cc028c9cfcd43e2 100644 (file)
@@ -32,6 +32,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <errno.h>
 #include "radeon_common.h"
+#include "radeon_fog.h"
 #include "main/simple_list.h"
 
 #if defined(USE_X86_ASM)
@@ -133,7 +134,7 @@ void radeonEmitVec16(uint32_t *out, const GLvoid * data, int stride, int count)
                }
 }
 
-void rcommon_emit_vector(GLcontext * ctx, struct radeon_aos *aos,
+void rcommon_emit_vector(struct gl_context * ctx, struct radeon_aos *aos,
                         const GLvoid * data, int size, int stride, int count)
 {
        radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
@@ -165,6 +166,41 @@ void rcommon_emit_vector(GLcontext * ctx, struct radeon_aos *aos,
        radeon_bo_unmap(aos->bo);
 }
 
+void rcommon_emit_vecfog(struct gl_context *ctx, struct radeon_aos *aos,
+                        GLvoid *data, int stride, int count)
+{
+       int i;
+       float *out;
+       int size = 1;
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+       if (RADEON_DEBUG & RADEON_VERTS)
+               fprintf(stderr, "%s count %d stride %d\n",
+                       __FUNCTION__, count, stride);
+
+       if (stride == 0) {
+               radeonAllocDmaRegion( rmesa, &aos->bo, &aos->offset, size * 4, 32 );
+               count = 1;
+               aos->stride = 0;
+       } else {
+               radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * count * 4, 32);
+               aos->stride = size;
+       }
+
+       aos->components = size;
+       aos->count = count;
+
+       /* Emit the data */
+       radeon_bo_map(aos->bo, 1);
+       out = (float*)((char*)aos->bo->ptr + aos->offset);
+       for (i = 0; i < count; i++) {
+               out[0] = radeonComputeFogBlendFactor( ctx, *(GLfloat *)data );
+               out++;
+               data += stride;
+       }
+       radeon_bo_unmap(aos->bo);
+}
+
 void radeon_init_dma(radeonContextPtr rmesa)
 {
        make_empty_list(&rmesa->dma.free);
@@ -181,12 +217,9 @@ void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size)
        if (size > rmesa->dma.minimum_size)
                rmesa->dma.minimum_size = (size + 15) & (~15);
 
-       radeon_print(RADEON_DMA, RADEON_NORMAL, "%s size %d minimum_size %d\n",
+       radeon_print(RADEON_DMA, RADEON_NORMAL, "%s size %d minimum_size %Zi\n",
                        __FUNCTION__, size, rmesa->dma.minimum_size);
 
-       if (!is_empty_list(&rmesa->dma.reserved))
-               radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo);
-
        if (is_empty_list(&rmesa->dma.free)
              || last_elem(&rmesa->dma.free)->bo->size < size) {
                dma_bo = CALLOC_STRUCT(radeon_dma_bo);
@@ -237,7 +270,7 @@ void radeonAllocDmaRegion(radeonContextPtr rmesa,
                fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
 
        if (rmesa->dma.flush)
-               rmesa->dma.flush(rmesa->glCtx);
+               rmesa->dma.flush(&rmesa->glCtx);
 
        assert(rmesa->dma.current_used == rmesa->dma.current_vertexptr);
 
@@ -269,19 +302,19 @@ void radeonFreeDmaRegions(radeonContextPtr rmesa)
        foreach_s(dma_bo, temp, &rmesa->dma.free) {
                remove_from_list(dma_bo);
                radeon_bo_unref(dma_bo->bo);
-               FREE(dma_bo);
+               free(dma_bo);
        }
 
        foreach_s(dma_bo, temp, &rmesa->dma.wait) {
                remove_from_list(dma_bo);
                radeon_bo_unref(dma_bo->bo);
-               FREE(dma_bo);
+               free(dma_bo);
        }
 
        foreach_s(dma_bo, temp, &rmesa->dma.reserved) {
                remove_from_list(dma_bo);
                radeon_bo_unref(dma_bo->bo);
-               FREE(dma_bo);
+               free(dma_bo);
        }
 }
 
@@ -331,14 +364,6 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
                      __FUNCTION__, free, wait, reserved, rmesa->dma.minimum_size);
        }
 
-       if (!rmesa->radeonScreen->driScreen->dri2.enabled) {
-               /* request updated cs processing information from kernel */
-               legacy_track_pending(rmesa->radeonScreen->bom, 0);
-       }
-
-       if (!is_empty_list(&rmesa->dma.reserved))
-               radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo);
-
        /* move waiting bos to free list.
           wait list provides gpu time to handle data before reuse */
        foreach_s(dma_bo, temp, &rmesa->dma.wait) {
@@ -346,20 +371,18 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
                        WARN_ONCE("Leaking dma buffer object!\n");
                        radeon_bo_unref(dma_bo->bo);
                        remove_from_list(dma_bo);
-                       FREE(dma_bo);
+                       free(dma_bo);
                        continue;
                }
                /* free objects that are too small to be used because of large request */
                if (dma_bo->bo->size < rmesa->dma.minimum_size) {
                   radeon_bo_unref(dma_bo->bo);
                   remove_from_list(dma_bo);
-                  FREE(dma_bo);
+                  free(dma_bo);
                   continue;
                }
                if (!radeon_bo_is_idle(dma_bo->bo)) {
-                       if (rmesa->radeonScreen->driScreen->dri2.enabled)
-                               break;
-                       continue;
+                       break;
                }
                remove_from_list(dma_bo);
                dma_bo->expire_counter = expire_at;
@@ -368,11 +391,12 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
 
        /* move reserved to wait list */
        foreach_s(dma_bo, temp, &rmesa->dma.reserved) {
+               radeon_bo_unmap(dma_bo->bo);
                /* free objects that are too small to be used because of large request */
                if (dma_bo->bo->size < rmesa->dma.minimum_size) {
                   radeon_bo_unref(dma_bo->bo);
                   remove_from_list(dma_bo);
-                  FREE(dma_bo);
+                  free(dma_bo);
                   continue;
                }
                remove_from_list(dma_bo);
@@ -386,7 +410,7 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
                        break;
                remove_from_list(dma_bo);
                radeon_bo_unref(dma_bo->bo);
-               FREE(dma_bo);
+               free(dma_bo);
        }
 
 }
@@ -394,7 +418,7 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
 
 /* Flush vertices in the current dma region.
  */
-void rcommon_flush_last_swtcl_prim( GLcontext *ctx  )
+void rcommon_flush_last_swtcl_prim( struct gl_context *ctx  )
 {
        radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
        struct radeon_dma *dma = &rmesa->dma;
@@ -435,7 +459,7 @@ rcommonAllocDmaLowVerts( radeonContextPtr rmesa, int nverts, int vsize )
        if(is_empty_list(&rmesa->dma.reserved)
              ||rmesa->dma.current_vertexptr + bytes > first_elem(&rmesa->dma.reserved)->bo->size) {
                if (rmesa->dma.flush) {
-                       rmesa->dma.flush(rmesa->glCtx);
+                       rmesa->dma.flush(&rmesa->glCtx);
                }
 
                 radeonRefillCurrentDmaRegion(rmesa, bytes);
@@ -445,7 +469,7 @@ rcommonAllocDmaLowVerts( radeonContextPtr rmesa, int nverts, int vsize )
 
         if (!rmesa->dma.flush) {
                /* if cmdbuf flushed DMA restart */
-                rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+                rmesa->glCtx.Driver.NeedFlush |= FLUSH_STORED_VERTICES;
                 rmesa->dma.flush = rcommon_flush_last_swtcl_prim;
         }
 
@@ -467,7 +491,7 @@ rcommonAllocDmaLowVerts( radeonContextPtr rmesa, int nverts, int vsize )
        return head;
 }
 
-void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs )
+void radeonReleaseArrays( struct gl_context *ctx, GLuint newinputs )
 {
    radeonContextPtr radeon = RADEON_CONTEXT( ctx );
    int i;
@@ -475,7 +499,7 @@ void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs )
                fprintf(stderr, "%s\n", __FUNCTION__);
 
    if (radeon->dma.flush) {
-       radeon->dma.flush(radeon->glCtx);
+       radeon->dma.flush(&radeon->glCtx);
    }
    for (i = 0; i < radeon->tcl.aos_count; i++) {
       if (radeon->tcl.aos[i].bo) {