gallium: add PIPE_CAP_USER_INDEX_BUFFERS and PIPE_CAP_USER_CONSTANT_BUFFERS
[mesa.git] / src / gallium / drivers / llvmpipe / lp_scene.c
index f6c6941507177ddd567137fcf6f919f67a3cfa90..ed998246fb9364e98a6fdb9f09a01d0399b6af85 100644 (file)
@@ -58,7 +58,9 @@ lp_scene_create( struct pipe_context *pipe )
       return NULL;
 
    scene->pipe = pipe;
-   scene->data.head = &scene->data.first;
+
+   scene->data.head =
+      CALLOC_STRUCT(data_block);
 
    pipe_mutex_init(scene->mutex);
 
@@ -72,8 +74,10 @@ lp_scene_create( struct pipe_context *pipe )
 void
 lp_scene_destroy(struct lp_scene *scene)
 {
+   lp_fence_reference(&scene->fence, NULL);
    pipe_mutex_destroy(scene->mutex);
-   assert(scene->data.head == &scene->data.first);
+   assert(scene->data.head->next == NULL);
+   FREE(scene->data.head);
    FREE(scene);
 }
 
@@ -118,6 +122,7 @@ lp_scene_bin_reset(struct lp_scene *scene, unsigned x, unsigned y)
 {
    struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
 
+   bin->last_state = NULL;
    bin->head = bin->tail;
    if (bin->tail) {
       bin->tail->next = NULL;
@@ -133,30 +138,30 @@ lp_scene_begin_rasterization(struct lp_scene *scene)
    int i;
 
    //LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
-   
+
    for (i = 0; i < scene->fb.nr_cbufs; i++) {
       struct pipe_surface *cbuf = scene->fb.cbufs[i];
+      assert(cbuf->u.tex.first_layer == cbuf->u.tex.last_layer);
       scene->cbufs[i].stride = llvmpipe_resource_stride(cbuf->texture,
-                                                        cbuf->level);
+                                                        cbuf->u.tex.level);
 
       scene->cbufs[i].map = llvmpipe_resource_map(cbuf->texture,
-                                                  cbuf->face,
-                                                  cbuf->level,
-                                                  cbuf->zslice,
+                                                  cbuf->u.tex.level,
+                                                  cbuf->u.tex.first_layer,
                                                   LP_TEX_USAGE_READ_WRITE,
                                                   LP_TEX_LAYOUT_LINEAR);
    }
 
    if (fb->zsbuf) {
       struct pipe_surface *zsbuf = scene->fb.zsbuf;
-      scene->zsbuf.stride = llvmpipe_resource_stride(zsbuf->texture, zsbuf->level);
+      assert(zsbuf->u.tex.first_layer == zsbuf->u.tex.last_layer);
+      scene->zsbuf.stride = llvmpipe_resource_stride(zsbuf->texture, zsbuf->u.tex.level);
       scene->zsbuf.blocksize = 
          util_format_get_blocksize(zsbuf->texture->format);
 
       scene->zsbuf.map = llvmpipe_resource_map(zsbuf->texture,
-                                               zsbuf->face,
-                                               zsbuf->level,
-                                               zsbuf->zslice,
+                                               zsbuf->u.tex.level,
+                                               zsbuf->u.tex.first_layer,
                                                LP_TEX_USAGE_READ_WRITE,
                                                LP_TEX_LAYOUT_NONE);
    }
@@ -178,9 +183,8 @@ lp_scene_end_rasterization(struct lp_scene *scene )
       if (scene->cbufs[i].map) {
          struct pipe_surface *cbuf = scene->fb.cbufs[i];
          llvmpipe_resource_unmap(cbuf->texture,
-                                 cbuf->face,
-                                 cbuf->level,
-                                 cbuf->zslice);
+                                 cbuf->u.tex.level,
+                                 cbuf->u.tex.first_layer);
          scene->cbufs[i].map = NULL;
       }
    }
@@ -189,9 +193,8 @@ lp_scene_end_rasterization(struct lp_scene *scene )
    if (scene->zsbuf.map) {
       struct pipe_surface *zsbuf = scene->fb.zsbuf;
       llvmpipe_resource_unmap(zsbuf->texture,
-                             zsbuf->face,
-                             zsbuf->level,
-                             zsbuf->zslice);
+                              zsbuf->u.tex.level,
+                              zsbuf->u.tex.first_layer);
       scene->zsbuf.map = NULL;
    }
 
@@ -200,7 +203,9 @@ lp_scene_end_rasterization(struct lp_scene *scene )
    for (i = 0; i < scene->tiles_x; i++) {
       for (j = 0; j < scene->tiles_y; j++) {
          struct cmd_bin *bin = lp_scene_get_bin(scene, i, j);
-         bin->head = bin->tail = NULL;
+         bin->head = NULL;
+         bin->tail = NULL;
+         bin->last_state = NULL;
       }
    }
 
@@ -220,7 +225,7 @@ lp_scene_end_rasterization(struct lp_scene *scene )
             if (LP_DEBUG & DEBUG_SETUP)
                debug_printf("resource %d: %p %dx%d sz %d\n",
                             j,
-                            ref->resource[i],
+                            (void *) ref->resource[i],
                             ref->resource[i]->width0,
                             ref->resource[i]->height0,
                             llvmpipe_resource_size(ref->resource[i]));
@@ -240,14 +245,13 @@ lp_scene_end_rasterization(struct lp_scene *scene )
       struct data_block_list *list = &scene->data;
       struct data_block *block, *tmp;
 
-      for (block = list->head; block; block = tmp) {
+      for (block = list->head->next; block; block = tmp) {
          tmp = block->next;
-         if (block != &list->first)
-            FREE(block);
+        FREE(block);
       }
 
-      list->head = &list->first;
       list->head->next = NULL;
+      list->head->used = 0;
    }
 
    lp_fence_reference(&scene->fence, NULL);