summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/cell/ppu/cell_batch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/cell/ppu/cell_batch.c')
-rw-r--r--src/mesa/pipe/cell/ppu/cell_batch.c84
1 files changed, 49 insertions, 35 deletions
diff --git a/src/mesa/pipe/cell/ppu/cell_batch.c b/src/mesa/pipe/cell/ppu/cell_batch.c
index c894ef8608..178caa74e1 100644
--- a/src/mesa/pipe/cell/ppu/cell_batch.c
+++ b/src/mesa/pipe/cell/ppu/cell_batch.c
@@ -31,12 +31,46 @@
#include "cell_spu.h"
+
+uint
+cell_get_empty_buffer(struct cell_context *cell)
+{
+ uint buf = 0;
+
+ /* Find a buffer that's marked as free by all SPUs */
+ while (1) {
+ uint spu, num_free = 0;
+
+ for (spu = 0; spu < cell->num_spus; spu++) {
+ if (cell->buffer_status[spu][buf][0] == CELL_BUFFER_STATUS_FREE) {
+ num_free++;
+
+ if (num_free == cell->num_spus) {
+ /* found a free buffer, now mark status as used */
+ for (spu = 0; spu < cell->num_spus; spu++) {
+ cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_USED;
+ }
+ return buf;
+ }
+ }
+ else {
+ break;
+ }
+ }
+
+ /* try next buf */
+ buf = (buf + 1) % CELL_NUM_BUFFERS;
+ }
+}
+
+
+
void
cell_batch_flush(struct cell_context *cell)
{
static boolean flushing = FALSE;
uint batch = cell->cur_batch;
- const uint size = cell->batch_buffer_size[batch];
+ const uint size = cell->buffer_size[batch];
uint spu, cmd_word;
assert(!flushing);
@@ -46,7 +80,7 @@ cell_batch_flush(struct cell_context *cell)
flushing = TRUE;
- assert(batch < CELL_NUM_BATCH_BUFFERS);
+ assert(batch < CELL_NUM_BUFFERS);
/*
printf("cell_batch_dispatch: buf %u at %p, size %u\n",
@@ -68,28 +102,9 @@ cell_batch_flush(struct cell_context *cell)
* array indicating that the PPU can re-use the buffer.
*/
+ batch = cell_get_empty_buffer(cell);
- /* Find a buffer that's marked as free by all SPUs */
- while (1) {
- uint num_free = 0;
-
- batch = (batch + 1) % CELL_NUM_BATCH_BUFFERS;
-
- for (spu = 0; spu < cell->num_spus; spu++) {
- if (cell->buffer_status[spu][batch][0] == CELL_BUFFER_STATUS_FREE)
- num_free++;
- }
-
- if (num_free == cell->num_spus) {
- /* found a free buffer, now mark status as used */
- for (spu = 0; spu < cell->num_spus; spu++) {
- cell->buffer_status[spu][batch][0] = CELL_BUFFER_STATUS_USED;
- }
- break;
- }
- }
-
- cell->batch_buffer_size[batch] = 0; /* empty */
+ cell->buffer_size[batch] = 0; /* empty */
cell->cur_batch = batch;
flushing = FALSE;
@@ -99,8 +114,7 @@ cell_batch_flush(struct cell_context *cell)
uint
cell_batch_free_space(const struct cell_context *cell)
{
- uint free = CELL_BATCH_BUFFER_SIZE
- - cell->batch_buffer_size[cell->cur_batch];
+ uint free = CELL_BUFFER_SIZE - cell->buffer_size[cell->cur_batch];
return free;
}
@@ -117,18 +131,18 @@ cell_batch_append(struct cell_context *cell, const void *cmd, uint length)
assert(length % 4 == 0);
assert(cell->cur_batch >= 0);
- size = cell->batch_buffer_size[cell->cur_batch];
+ size = cell->buffer_size[cell->cur_batch];
- if (size + length > CELL_BATCH_BUFFER_SIZE) {
+ if (size + length > CELL_BUFFER_SIZE) {
cell_batch_flush(cell);
size = 0;
}
- assert(size + length <= CELL_BATCH_BUFFER_SIZE);
+ assert(size + length <= CELL_BUFFER_SIZE);
- memcpy(cell->batch_buffer[cell->cur_batch] + size, cmd, length);
+ memcpy(cell->buffer[cell->cur_batch] + size, cmd, length);
- cell->batch_buffer_size[cell->cur_batch] = size + length;
+ cell->buffer_size[cell->cur_batch] = size + length;
}
@@ -142,18 +156,18 @@ cell_batch_alloc(struct cell_context *cell, uint bytes)
assert(cell->cur_batch >= 0);
- size = cell->batch_buffer_size[cell->cur_batch];
+ size = cell->buffer_size[cell->cur_batch];
- if (size + bytes > CELL_BATCH_BUFFER_SIZE) {
+ if (size + bytes > CELL_BUFFER_SIZE) {
cell_batch_flush(cell);
size = 0;
}
- assert(size + bytes <= CELL_BATCH_BUFFER_SIZE);
+ assert(size + bytes <= CELL_BUFFER_SIZE);
- pos = (void *) (cell->batch_buffer[cell->cur_batch] + size);
+ pos = (void *) (cell->buffer[cell->cur_batch] + size);
- cell->batch_buffer_size[cell->cur_batch] = size + bytes;
+ cell->buffer_size[cell->cur_batch] = size + bytes;
return pos;
}