summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/cell/ppu/cell_batch.c
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-01-20 10:38:35 +1100
committerBen Skeggs <skeggsb@gmail.com>2008-01-20 10:38:35 +1100
commitdf09ed9d1ecf11be14ee7f189273c14375fbaa57 (patch)
tree7322a2670877dff003f57a5485c9e92226b57167 /src/mesa/pipe/cell/ppu/cell_batch.c
parent0feec292ddc279998a1e25c10ea70d211f7b4b62 (diff)
parenta1f4a5e802ad62c88fca6834b9de1c83672230a6 (diff)
Merge branch 'upstream-gallium-0.1' into darktama-gallium-0.1
Diffstat (limited to 'src/mesa/pipe/cell/ppu/cell_batch.c')
-rw-r--r--src/mesa/pipe/cell/ppu/cell_batch.c47
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;
}