summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/cell/ppu/cell_batch.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-10-22 10:34:13 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-10-22 10:34:13 -0600
commit70dd4379d2cd54f229c3940312537912470218d3 (patch)
treecf24b8e884221c7637cf9c9b27890c2c9b8ec599 /src/gallium/drivers/cell/ppu/cell_batch.c
parent0ae4728eb429d7b5217d34ec96fc973a5e7cfe95 (diff)
cell: implement fencing for texture buffers
If we delete a texture, we need to keep the underlying tiled data buffer around until any rendering that references it has completed. Keep a list of buffers referenced by a rendering batch. Unref/free them when the associated batch's fence is executed/signalled.
Diffstat (limited to 'src/gallium/drivers/cell/ppu/cell_batch.c')
-rw-r--r--src/gallium/drivers/cell/ppu/cell_batch.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gallium/drivers/cell/ppu/cell_batch.c b/src/gallium/drivers/cell/ppu/cell_batch.c
index 01254aed60..448b723d85 100644
--- a/src/gallium/drivers/cell/ppu/cell_batch.c
+++ b/src/gallium/drivers/cell/ppu/cell_batch.c
@@ -28,6 +28,7 @@
#include "cell_context.h"
#include "cell_batch.h"
+#include "cell_fence.h"
#include "cell_spu.h"
@@ -63,6 +64,10 @@ cell_get_empty_buffer(struct cell_context *cell)
printf("PPU: ALLOC BUFFER %u, %u tries\n", buf, tries);
*/
prev_buffer = buf;
+
+ /* release tex buffer associated w/ prev use of this batch buf */
+ cell_free_fenced_buffers(cell, &cell->fenced_buffers[buf]);
+
return buf;
}
}
@@ -85,6 +90,26 @@ cell_get_empty_buffer(struct cell_context *cell)
/**
+ * Append a fence command to the current batch buffer.
+ * Note that we're sure there's always room for this because of the
+ * adjusted size check in cell_batch_free_space().
+ */
+static void
+emit_fence(struct cell_context *cell)
+{
+ const uint batch = cell->cur_batch;
+ const uint size = cell->buffer_size[batch];
+ struct cell_command_fence *fence_cmd;
+
+ ASSERT(size + sizeof(struct cell_command_fence) <= CELL_BUFFER_SIZE);
+
+ fence_cmd = (struct cell_command_fence *) (cell->buffer[batch] + size);
+ fence_cmd->opcode = CELL_CMD_FENCE;
+ fence_cmd->fence = &cell->fenced_buffers[batch].fence;
+}
+
+
+/**
* Flush the current batch buffer to the SPUs.
* An empty buffer will be found and set as the new current batch buffer
* for subsequent commands/data.
@@ -102,6 +127,12 @@ cell_batch_flush(struct cell_context *cell)
if (size == 0)
return;
+ /* Before we use this batch buffer, make sure any fenced texture buffers
+ * are released.
+ */
+ if (cell->fenced_buffers[batch].head)
+ emit_fence(cell);
+
flushing = TRUE;
assert(batch < CELL_NUM_BUFFERS);
@@ -142,6 +173,7 @@ uint
cell_batch_free_space(const struct cell_context *cell)
{
uint free = CELL_BUFFER_SIZE - cell->buffer_size[cell->cur_batch];
+ free -= sizeof(struct cell_command_fence);
return free;
}