#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "util/u_blitter.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
#include "util/u_transfer.h"
#include "util/u_surface.h"
#include "util/u_pack_color.h"
{
struct compute_memory_pool* pool = (struct compute_memory_pool*)
CALLOC(sizeof(struct compute_memory_pool), 1);
- if (pool == NULL)
+ if (!pool)
return NULL;
COMPUTE_DBG(rscreen, "* compute_memory_pool_new()\n");
unsigned initial_size_in_dw)
{
- COMPUTE_DBG(pool->screen, "* compute_memory_pool_init() initial_size_in_dw = %ld\n",
+ COMPUTE_DBG(pool->screen, "* compute_memory_pool_init() initial_size_in_dw = %u\n",
initial_size_in_dw);
pool->size_in_dw = initial_size_in_dw;
- pool->bo = (struct r600_resource*)r600_compute_buffer_alloc_vram(pool->screen,
- pool->size_in_dw * 4);
+ pool->bo = r600_compute_buffer_alloc_vram(pool->screen,
+ pool->size_in_dw * 4);
}
/**
pool->screen->b.b.resource_destroy((struct pipe_screen *)
pool->screen, (struct pipe_resource *)pool->bo);
}
+ /* In theory, all of the items were freed in compute_memory_free.
+ * Just delete the list heads
+ */
+ free(pool->item_list);
+ free(pool->unallocated_list);
+ /* And then the pool itself */
free(pool);
}
assert(size_in_dw <= pool->size_in_dw);
- COMPUTE_DBG(pool->screen, "* compute_memory_prealloc_chunk() size_in_dw = %ld\n",
+ COMPUTE_DBG(pool->screen, "* compute_memory_prealloc_chunk() size_in_dw = %"PRIi64"\n",
size_in_dw);
LIST_FOR_EACH_ENTRY(item, pool->item_list, link) {
struct compute_memory_item *next;
struct list_head *next_link;
- COMPUTE_DBG(pool->screen, "* compute_memory_postalloc_chunck() start_in_dw = %ld\n",
+ COMPUTE_DBG(pool->screen, "* compute_memory_postalloc_chunck() start_in_dw = %"PRIi64"\n",
start_in_dw);
/* Check if we can insert it in the front of the list */
} else {
struct r600_resource *temp = NULL;
- temp = (struct r600_resource *)r600_compute_buffer_alloc_vram(
- pool->screen, new_size_in_dw * 4);
+ temp = r600_compute_buffer_alloc_vram(pool->screen, new_size_in_dw * 4);
if (temp != NULL) {
struct pipe_resource *src = (struct pipe_resource *)pool->bo;
pool->screen->b.b.resource_destroy(
(struct pipe_screen *)pool->screen,
(struct pipe_resource *)pool->bo);
- pool->bo = (struct r600_resource*)r600_compute_buffer_alloc_vram(
- pool->screen,
- pool->size_in_dw * 4);
+ pool->bo = r600_compute_buffer_alloc_vram(pool->screen, pool->size_in_dw * 4);
compute_memory_shadow(pool, pipe, 0);
if (pool->status & POOL_FRAGMENTED) {
COMPUTE_DBG(pool->screen, "* compute_memory_finalize_pending()\n");
LIST_FOR_EACH_ENTRY(item, pool->item_list, link) {
- COMPUTE_DBG(pool->screen, " + list: offset = %i id = %i size = %i "
- "(%i bytes)\n",item->start_in_dw, item->id,
+ COMPUTE_DBG(pool->screen, " + list: offset = %"PRIi64" id = %"PRIi64" size = %"PRIi64" "
+ "(%"PRIi64" bytes)\n", item->start_in_dw, item->id,
item->size_in_dw, item->size_in_dw * 4);
}
struct pipe_box box;
COMPUTE_DBG(pool->screen, "* compute_memory_promote_item()\n"
- " + Promoting Item: %i , starting at: %u (%u bytes) "
- "size: %u (%u bytes)\n\t\t\tnew start: %u (%u bytes)\n",
+ " + Promoting Item: %"PRIi64" , starting at: %"PRIi64" (%"PRIi64" bytes) "
+ "size: %"PRIi64" (%"PRIi64" bytes)\n\t\t\tnew start: %"PRIi64" (%"PRIi64" bytes)\n",
item->id, item->start_in_dw, item->start_in_dw * 4,
item->size_in_dw, item->size_in_dw * 4,
start_in_dw, start_in_dw * 4);
list_addtail(&item->link, pool->item_list);
item->start_in_dw = start_in_dw;
- if (src != NULL) {
+ if (src) {
u_box_1d(0, item->size_in_dw * 4, &box);
rctx->b.b.resource_copy_region(pipe,
struct pipe_box box;
COMPUTE_DBG(pool->screen, "* compute_memory_demote_item()\n"
- " + Demoting Item: %i, starting at: %u (%u bytes) "
- "size: %u (%u bytes)\n", item->id, item->start_in_dw,
+ " + Demoting Item: %"PRIi64", starting at: %"PRIi64" (%"PRIi64" bytes) "
+ "size: %"PRIi64" (%"PRIi64" bytes)\n", item->id, item->start_in_dw,
item->start_in_dw * 4, item->size_in_dw, item->size_in_dw * 4);
/* First, we remove the item from the item_list */
/* We check if the intermediate buffer exists, and if it
* doesn't, we create it again */
if (item->real_buffer == NULL) {
- item->real_buffer = (struct r600_resource*)r600_compute_buffer_alloc_vram(
+ item->real_buffer = r600_compute_buffer_alloc_vram(
pool->screen, item->size_in_dw * 4);
}
struct r600_context *rctx = (struct r600_context *)pipe;
struct pipe_box box;
- struct compute_memory_item *prev;
+ MAYBE_UNUSED struct compute_memory_item *prev;
COMPUTE_DBG(pool->screen, "* compute_memory_move_item()\n"
- " + Moving item %i from %u (%u bytes) to %u (%u bytes)\n",
+ " + Moving item %"PRIi64" from %"PRIi64" (%"PRIi64" bytes) to %"PRIu64" (%"PRIu64" bytes)\n",
item->id, item->start_in_dw, item->start_in_dw * 4,
new_start_in_dw, new_start_in_dw * 4);
struct pipe_screen *screen = (struct pipe_screen *)pool->screen;
struct pipe_resource *res;
- COMPUTE_DBG(pool->screen, "* compute_memory_free() id + %ld \n", id);
+ COMPUTE_DBG(pool->screen, "* compute_memory_free() id + %"PRIi64" \n", id);
LIST_FOR_EACH_ENTRY_SAFE(item, next, pool->item_list, link) {
{
struct compute_memory_item *new_item = NULL;
- COMPUTE_DBG(pool->screen, "* compute_memory_alloc() size_in_dw = %ld (%ld bytes)\n",
+ COMPUTE_DBG(pool->screen, "* compute_memory_alloc() size_in_dw = %"PRIi64" (%"PRIi64" bytes)\n",
size_in_dw, 4 * size_in_dw);
new_item = (struct compute_memory_item *)
CALLOC(sizeof(struct compute_memory_item), 1);
- if (new_item == NULL)
+ if (!new_item)
return NULL;
new_item->size_in_dw = size_in_dw;
list_addtail(&new_item->link, pool->unallocated_list);
- COMPUTE_DBG(pool->screen, " + Adding item %p id = %u size = %u (%u bytes)\n",
+ COMPUTE_DBG(pool->screen, " + Adding item %p id = %"PRIi64" size = %"PRIi64" (%"PRIi64" bytes)\n",
new_item, new_item->id, new_item->size_in_dw,
new_item->size_in_dw * 4);
return new_item;