cell_flush.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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       /* XXX: Implement real fencing */
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;  /* recursion catcher */
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    /* Send CMD_FINISH to all SPUs */
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       /* Wait for ack */
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 }

Generated on Tue Sep 29 06:25:15 2009 for Gallium3D by  doxygen 1.5.4