diff options
author | Brian <brian.paul@tungstengraphics.com> | 2008-01-19 12:04:06 -0700 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2008-01-19 12:04:06 -0700 |
commit | a1f4a5e802ad62c88fca6834b9de1c83672230a6 (patch) | |
tree | 79f89f370a4d2b8197f313fe4ea7d081e386a916 /src/mesa/pipe/cell/ppu/cell_batch.c | |
parent | 06b019d16bc20d772a8aed2a68d1c5d37a402a81 (diff) |
Cell: improve "finished copying batch buffer" signalling.
When the SPU is done copying a batch buffer to local store, use an mfc_put()
to write a "done" message back to the buffer status array in main memory.
We were previously using a mailbox message for synchronization.
Diffstat (limited to 'src/mesa/pipe/cell/ppu/cell_batch.c')
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_batch.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/src/mesa/pipe/cell/ppu/cell_batch.c b/src/mesa/pipe/cell/ppu/cell_batch.c index 45f62ac3ad..ab4553f16c 100644 --- a/src/mesa/pipe/cell/ppu/cell_batch.c +++ b/src/mesa/pipe/cell/ppu/cell_batch.c @@ -34,9 +34,9 @@ void cell_batch_flush(struct cell_context *cell) { - const uint batch = cell->cur_batch; + uint batch = cell->cur_batch; const uint size = cell->batch_buffer_size[batch]; - uint i, cmd_word; + uint spu, cmd_word; if (size == 0) return; @@ -48,25 +48,44 @@ cell_batch_flush(struct cell_context *cell) batch, &cell->batch_buffer[batch][0], size); */ + /* + * Build "BATCH" command and sent to all SPUs. + */ cmd_word = CELL_CMD_BATCH | (batch << 8) | (size << 16); - for (i = 0; i < cell->num_spus; i++) { - send_mbox_message(cell_global.spe_contexts[i], cmd_word); + for (spu = 0; spu < cell->num_spus; spu++) { + assert(cell->buffer_status[spu][batch][0] == CELL_BUFFER_STATUS_USED); + send_mbox_message(cell_global.spe_contexts[spu], cmd_word); } - /* XXX wait for the DMX xfer to finish. - * Using mailboxes here is temporary. - * Ideally, we want to use a PPE-side DMA status check function... + /* When the SPUs are done copying the buffer into their locals stores + * they'll write a BUFFER_STATUS_FREE message into the buffer_status[] + * array indicating that the PPU can re-use the buffer. */ - for (i = 0; i < cell->num_spus; i++) { - uint k = wait_mbox_message(cell_global.spe_contexts[i]); - assert(k == CELL_BATCH_FINISHED); - } - /* next buffer */ - cell->cur_batch = (batch + 1) % CELL_NUM_BATCH_BUFFERS; - cell->batch_buffer_size[cell->cur_batch] = 0; /* empty */ + /* 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->cur_batch = batch; } |