00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "cell_context.h"
00030 #include "cell_batch.h"
00031 #include "cell_flush.h"
00032 #include "cell_spu.h"
00033 #include "cell_render.h"
00034 #include "draw/draw_context.h"
00035
00036
00040 void
00041 cell_flush(struct pipe_context *pipe, unsigned flags,
00042 struct pipe_fence_handle **fence)
00043 {
00044 struct cell_context *cell = cell_context(pipe);
00045
00046 if (fence) {
00047 *fence = NULL;
00048
00049 flags |= CELL_FLUSH_WAIT;
00050 }
00051
00052 if (flags & PIPE_FLUSH_SWAPBUFFERS)
00053 flags |= CELL_FLUSH_WAIT;
00054
00055 draw_flush( cell->draw );
00056 cell_flush_int(cell, flags);
00057 }
00058
00059
00065 void
00066 cell_flush_int(struct cell_context *cell, unsigned flags)
00067 {
00068 static boolean flushing = FALSE;
00069 uint i;
00070
00071 ASSERT(!flushing);
00072 flushing = TRUE;
00073
00074 if (flags & CELL_FLUSH_WAIT) {
00075 uint64_t *cmd = (uint64_t *) cell_batch_alloc(cell, sizeof(uint64_t));
00076 *cmd = CELL_CMD_FINISH;
00077 }
00078
00079 cell_batch_flush(cell);
00080
00081 #if 0
00082
00083 for (i = 0; i < cell->num_spus; i++) {
00084 send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FINISH);
00085 }
00086 #endif
00087
00088 if (flags & CELL_FLUSH_WAIT) {
00089
00090 for (i = 0; i < cell->num_spus; i++) {
00091 uint k = wait_mbox_message(cell_global.spe_contexts[i]);
00092 assert(k == CELL_CMD_FINISH);
00093 }
00094 }
00095
00096 flushing = FALSE;
00097 }
00098
00099
00100 void
00101 cell_flush_buffer_range(struct cell_context *cell, void *ptr,
00102 unsigned size)
00103 {
00104 uint64_t batch[1 + (ROUNDUP8(sizeof(struct cell_buffer_range)) / 8)];
00105 struct cell_buffer_range *br = (struct cell_buffer_range *) & batch[1];
00106
00107 batch[0] = CELL_CMD_FLUSH_BUFFER_RANGE;
00108 br->base = (uintptr_t) ptr;
00109 br->size = size;
00110 cell_batch_append(cell, batch, sizeof(batch));
00111 }