cell_context.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 
00034 #include <stdio.h>
00035 
00036 #include "pipe/p_defines.h"
00037 #include "pipe/p_format.h"
00038 #include "util/u_memory.h"
00039 #include "pipe/p_winsys.h"
00040 #include "pipe/p_screen.h"
00041 
00042 #include "draw/draw_context.h"
00043 #include "draw/draw_private.h"
00044 
00045 #include "cell/common.h"
00046 #include "cell_batch.h"
00047 #include "cell_clear.h"
00048 #include "cell_context.h"
00049 #include "cell_draw_arrays.h"
00050 #include "cell_flush.h"
00051 #include "cell_state.h"
00052 #include "cell_surface.h"
00053 #include "cell_spu.h"
00054 #include "cell_pipe_state.h"
00055 #include "cell_texture.h"
00056 #include "cell_vbuf.h"
00057 
00058 
00059 
00060 static void
00061 cell_destroy_context( struct pipe_context *pipe )
00062 {
00063    struct cell_context *cell = cell_context(pipe);
00064 
00065    cell_spu_exit(cell);
00066 
00067    align_free(cell);
00068 }
00069 
00070 
00071 static struct draw_context *
00072 cell_draw_create(struct cell_context *cell)
00073 {
00074    struct draw_context *draw = draw_create();
00075 
00076 #if 0 /* broken */
00077    if (getenv("GALLIUM_CELL_VS")) {
00078       /* plug in SPU-based vertex transformation code */
00079       draw->shader_queue_flush = cell_vertex_shader_queue_flush;
00080       draw->driver_private = cell;
00081    }
00082 #endif
00083 
00084    return draw;
00085 }
00086 
00087 
00088 #ifdef DEBUG
00089 static const struct debug_named_value cell_debug_flags[] = {
00090    {"checker", CELL_DEBUG_CHECKER},
00091    {"sync", CELL_DEBUG_SYNC},      
00092    {NULL, 0}
00093 };
00094 #endif
00095 
00096 
00097 struct pipe_context *
00098 cell_create_context(struct pipe_screen *screen,
00099                     struct cell_winsys *cws)
00100 {
00101    struct cell_context *cell;
00102 
00103    /* some fields need to be 16-byte aligned, so align the whole object */
00104    cell = (struct cell_context*) align_malloc(sizeof(struct cell_context), 16);
00105    if (!cell)
00106       return NULL;
00107 
00108    memset(cell, 0, sizeof(*cell));
00109 
00110    cell->winsys = cws;
00111    cell->pipe.winsys = screen->winsys;
00112    cell->pipe.screen = screen;
00113    cell->pipe.destroy = cell_destroy_context;
00114 
00115    cell->pipe.clear = cell_clear_surface;
00116    cell->pipe.flush = cell_flush;
00117 
00118 #if 0
00119    cell->pipe.begin_query = cell_begin_query;
00120    cell->pipe.end_query = cell_end_query;
00121    cell->pipe.wait_query = cell_wait_query;
00122 #endif
00123 
00124    cell_init_draw_functions(cell);
00125    cell_init_state_functions(cell);
00126    cell_init_shader_functions(cell);
00127    cell_init_surface_functions(cell);
00128    cell_init_texture_functions(cell);
00129    cell_init_vertex_functions(cell);
00130 
00131    cell->draw = cell_draw_create(cell);
00132 
00133    cell_init_vbuf(cell);
00134 
00135    draw_set_rasterize_stage(cell->draw, cell->vbuf);
00136 
00137    /* convert all points/lines to tris for the time being */
00138    draw_wide_point_threshold(cell->draw, 0.0);
00139    draw_wide_line_threshold(cell->draw, 0.0);
00140 
00141    /* get env vars or read config file to get debug flags */
00142    cell->debug_flags = debug_get_flags_option("CELL_DEBUG", 
00143                                               cell_debug_flags, 
00144                                               0 );
00145 
00146    /*
00147     * SPU stuff
00148     */
00149    cell->num_spus = 6;
00150    /* XXX is this in SDK 3.0 only?
00151    cell->num_spus = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
00152    */
00153 
00154    cell_start_spus(cell);
00155 
00156    cell_init_batch_buffers(cell);
00157 
00158    return &cell->pipe;
00159 }

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