return NULL;
scene->pipe = pipe;
- scene->data.head = &scene->data.first;
+
+ scene->data.head =
+ CALLOC_STRUCT(data_block);
pipe_mutex_init(scene->mutex);
lp_scene_destroy(struct lp_scene *scene)
{
pipe_mutex_destroy(scene->mutex);
- assert(scene->data.head == &scene->data.first);
+ assert(scene->data.head->next == NULL);
+ FREE(scene->data.head);
FREE(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;
}
}
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]));
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);
/* Look at existing resource blocks:
*/
for (ref = scene->resources; ref; ref = ref->next) {
+ last = &ref->next;
/* Search for this resource:
*/
if (ref->resource[i] == resource)
return TRUE;
- /* If the block is half-empty, this is the last block. Append
- * the reference here.
- */
- if (ref->count < RESOURCE_REF_SZ)
- goto add_new_ref;
-
- last = &ref->next;
+ if (ref->count < RESOURCE_REF_SZ) {
+ /* If the block is half-empty, then append the reference here.
+ */
+ break;
+ }
}
- /* Otherwise, need to create a new block:
+ /* Create a new block if no half-empty block was found.
*/
- *last = lp_scene_alloc(scene, sizeof(struct resource_ref));
- if (*last) {
+ if (!ref) {
+ assert(*last == NULL);
+ *last = lp_scene_alloc(scene, sizeof *ref);
+ if (*last == NULL)
+ return FALSE;
+
ref = *last;
memset(ref, 0, sizeof *ref);
- goto add_new_ref;
}
- return FALSE;
-
-add_new_ref:
+ /* Append the reference to the reference block.
+ */
pipe_resource_reference(&ref->resource[ref->count++], resource);
scene->resource_reference_size += llvmpipe_resource_size(resource);