diff options
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_batch.c | 52 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_batch.h | 2 |
2 files changed, 42 insertions, 12 deletions
diff --git a/src/mesa/pipe/cell/ppu/cell_batch.c b/src/mesa/pipe/cell/ppu/cell_batch.c index 178caa74e1b..2d032fc9026 100644 --- a/src/mesa/pipe/cell/ppu/cell_batch.c +++ b/src/mesa/pipe/cell/ppu/cell_batch.c @@ -35,7 +35,7 @@ uint cell_get_empty_buffer(struct cell_context *cell) { - uint buf = 0; + uint buf = 0, tries = 0; /* Find a buffer that's marked as free by all SPUs */ while (1) { @@ -50,6 +50,9 @@ cell_get_empty_buffer(struct cell_context *cell) for (spu = 0; spu < cell->num_spus; spu++) { cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_USED; } + /* + printf("PPU: ALLOC BUFFER %u\n", buf); + */ return buf; } } @@ -60,11 +63,17 @@ cell_get_empty_buffer(struct cell_context *cell) /* try next buf */ buf = (buf + 1) % CELL_NUM_BUFFERS; + + tries++; + if (tries == 100) { + /* + printf("PPU WAITING for buffer...\n"); + */ + } } } - void cell_batch_flush(struct cell_context *cell) { @@ -120,29 +129,39 @@ cell_batch_free_space(const struct cell_context *cell) /** - * \param cmd command to append - * \param length command size in bytes + * Append data to current batch. */ void -cell_batch_append(struct cell_context *cell, const void *cmd, uint length) +cell_batch_append(struct cell_context *cell, const void *data, uint bytes) { uint size; - assert(length % 4 == 0); - assert(cell->cur_batch >= 0); + ASSERT(bytes % 4 == 0); + ASSERT(bytes <= CELL_BUFFER_SIZE); + ASSERT(cell->cur_batch >= 0); + +#ifdef ASSERT + { + uint spu; + for (spu = 0; spu < cell->num_spus; spu++) { + ASSERT(cell->buffer_status[spu][cell->cur_batch][0] + == CELL_BUFFER_STATUS_USED); + } + } +#endif size = cell->buffer_size[cell->cur_batch]; - if (size + length > CELL_BUFFER_SIZE) { + if (size + bytes > CELL_BUFFER_SIZE) { cell_batch_flush(cell); size = 0; } - assert(size + length <= CELL_BUFFER_SIZE); + assert(size + bytes <= CELL_BUFFER_SIZE); - memcpy(cell->buffer[cell->cur_batch] + size, cmd, length); + memcpy(cell->buffer[cell->cur_batch] + size, data, bytes); - cell->buffer_size[cell->cur_batch] = size + length; + cell->buffer_size[cell->cur_batch] = size + bytes; } @@ -153,9 +172,20 @@ cell_batch_alloc(struct cell_context *cell, uint bytes) uint size; ASSERT(bytes % 4 == 0); + ASSERT(bytes <= CELL_BUFFER_SIZE); assert(cell->cur_batch >= 0); +#ifdef ASSERT + { + uint spu; + for (spu = 0; spu < cell->num_spus; spu++) { + ASSERT(cell->buffer_status[spu][cell->cur_batch][0] + == CELL_BUFFER_STATUS_USED); + } + } +#endif + size = cell->buffer_size[cell->cur_batch]; if (size + bytes > CELL_BUFFER_SIZE) { diff --git a/src/mesa/pipe/cell/ppu/cell_batch.h b/src/mesa/pipe/cell/ppu/cell_batch.h index b4c96f465a8..f4f37314a48 100644 --- a/src/mesa/pipe/cell/ppu/cell_batch.h +++ b/src/mesa/pipe/cell/ppu/cell_batch.h @@ -45,7 +45,7 @@ extern uint cell_batch_free_space(const struct cell_context *cell); extern void -cell_batch_append(struct cell_context *cell, const void *cmd, uint length); +cell_batch_append(struct cell_context *cell, const void *data, uint bytes); extern void * cell_batch_alloc(struct cell_context *cell, uint bytes); |