common.h

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 
00033 #ifndef CELL_COMMON_H
00034 #define CELL_COMMON_H
00035 
00036 #include "pipe/p_compiler.h"
00037 #include "pipe/p_format.h"
00038 #include "pipe/p_state.h"
00039 
00040 
00042 #define ASSERT(x) \
00043    if (!(x)) { \
00044       ubyte *p = NULL; \
00045       fprintf(stderr, "%s:%d: %s(): assertion %s failed.\n", \
00046               __FILE__, __LINE__, __FUNCTION__, #x);             \
00047       *p = 0; \
00048       exit(1); \
00049    }
00050 
00051 
00053 #define ASSERT_ALIGN16(ptr) \
00054   ASSERT((((unsigned long) (ptr)) & 0xf) == 0);
00055 
00056 
00058 #define ROUNDUP4(k)  (((k) + 0x3) & ~0x3)
00059 
00061 #define ROUNDUP8(k)  (((k) + 0x7) & ~0x7)
00062 
00064 #define ROUNDUP16(k)  (((k) + 0xf) & ~0xf)
00065 
00066 
00067 #define CELL_MAX_SPUS 6
00068 
00069 #define CELL_MAX_SAMPLERS 4
00070 
00071 #define TILE_SIZE 32
00072 
00073 
00078 #define CELL_CMD_OPCODE_MASK 0xff
00079 
00080 #define CELL_CMD_EXIT                 1
00081 #define CELL_CMD_CLEAR_SURFACE        2
00082 #define CELL_CMD_FINISH               3
00083 #define CELL_CMD_RENDER               4
00084 #define CELL_CMD_BATCH                5
00085 #define CELL_CMD_RELEASE_VERTS        6
00086 #define CELL_CMD_STATE_FRAMEBUFFER   10
00087 #define CELL_CMD_STATE_FRAGMENT_OPS  11
00088 #define CELL_CMD_STATE_SAMPLER       12
00089 #define CELL_CMD_STATE_TEXTURE       13
00090 #define CELL_CMD_STATE_VERTEX_INFO   14
00091 #define CELL_CMD_STATE_VIEWPORT      15
00092 #define CELL_CMD_STATE_UNIFORMS      16
00093 #define CELL_CMD_STATE_VS_ARRAY_INFO 17
00094 #define CELL_CMD_STATE_BIND_VS       18
00095 #define CELL_CMD_STATE_FRAGMENT_PROGRAM 19
00096 #define CELL_CMD_STATE_ATTRIB_FETCH  20
00097 #define CELL_CMD_VS_EXECUTE          22
00098 #define CELL_CMD_FLUSH_BUFFER_RANGE  23
00099 
00100 
00101 #define CELL_NUM_BUFFERS 4
00102 #define CELL_BUFFER_SIZE (4*1024)  
00104 #define CELL_BUFFER_STATUS_FREE 10
00105 #define CELL_BUFFER_STATUS_USED 20
00106 
00107 
00108 #define CELL_DEBUG_CHECKER  (1 << 0)
00109 #define CELL_DEBUG_SYNC     (1 << 1)
00110 
00111 
00112 
00114 #define SPU_MAX_FRAGMENT_OPS_INSTS 64
00115 
00116 
00120 struct cell_command_fragment_ops
00121 {
00122    uint64_t opcode;      
00123    struct pipe_depth_stencil_alpha_state dsa;
00124    struct pipe_blend_state blend;
00125    unsigned code[SPU_MAX_FRAGMENT_OPS_INSTS];
00126 };
00127 
00128 
00130 #define SPU_MAX_FRAGMENT_PROGRAM_INSTS 128
00131 
00135 struct cell_command_fragment_program
00136 {
00137    uint64_t opcode;      
00138    uint num_inst;        
00139    unsigned code[SPU_MAX_FRAGMENT_PROGRAM_INSTS];
00140 };
00141 
00142 
00146 struct cell_command_framebuffer
00147 {
00148    uint64_t opcode;     
00149    int width, height;
00150    void *color_start, *depth_start;
00151    enum pipe_format color_format, depth_format;
00152 };
00153 
00154 
00158 struct cell_command_clear_surface
00159 {
00160    uint64_t opcode;     
00161    uint surface; 
00162    uint value;
00163 };
00164 
00165 
00169 struct cell_array_info
00170 {
00171    uint64_t base;      
00172    uint attr;          
00173    uint pitch;         
00174    uint size;
00175    uint function_offset;
00176 };
00177 
00178 
00179 struct cell_attribute_fetch_code
00180 {
00181    uint64_t base;
00182    uint size;
00183 };
00184 
00185 
00186 struct cell_buffer_range
00187 {
00188    uint64_t base;
00189    unsigned size;
00190 };
00191 
00192 
00193 struct cell_shader_info
00194 {
00195    uint64_t declarations;
00196    uint64_t instructions;
00197    uint64_t  immediates;
00198 
00199    unsigned num_outputs;
00200    unsigned num_declarations;
00201    unsigned num_instructions;
00202    unsigned num_immediates;
00203 };
00204 
00205 
00206 #define SPU_VERTS_PER_BATCH 64
00207 struct cell_command_vs
00208 {
00209    uint64_t opcode;       
00210    uint64_t vOut[SPU_VERTS_PER_BATCH];
00211    unsigned num_elts;
00212    unsigned elts[SPU_VERTS_PER_BATCH];
00213    float plane[12][4];
00214    unsigned nr_planes;
00215    unsigned nr_attrs;
00216 };
00217 
00218 
00219 struct cell_command_render
00220 {
00221    uint64_t opcode;   
00222    uint prim_type;    
00223    uint num_verts;
00224    uint vertex_size;  
00225    uint num_indexes;
00226    uint vertex_buf;  
00227    float xmin, ymin, xmax, ymax;  /* XXX another dummy field */
00228    uint min_index;
00229    boolean inline_verts;
00230 };
00231 
00232 
00233 struct cell_command_release_verts
00234 {
00235    uint64_t opcode;         
00236    uint vertex_buf;    
00237 };
00238 
00239 
00240 struct cell_command_sampler
00241 {
00242    uint64_t opcode;         
00243    uint unit;
00244    struct pipe_sampler_state state;
00245 };
00246 
00247 
00248 struct cell_command_texture
00249 {
00250    uint64_t opcode;     
00251    uint unit;
00252    void *start;         
00253    ushort width, height;
00254 };
00255 
00256 
00258 /* XXX this should go away; all commands should be placed in batch buffers */
00259 struct cell_command
00260 {
00261 #if 0
00262    struct cell_command_framebuffer fb;
00263    struct cell_command_clear_surface clear;
00264    struct cell_command_render render;
00265 #endif
00266    struct cell_command_vs vs;
00267 } ALIGN16_ATTRIB;
00268 
00269 
00271 struct cell_init_info
00272 {
00273    unsigned id;
00274    unsigned num_spus;
00275    unsigned debug_flags;  
00276    struct cell_command *cmd;
00277 
00279    ubyte *buffers[CELL_NUM_BUFFERS];
00280    uint *buffer_status;  
00281 } ALIGN16_ATTRIB;
00282 
00283 
00284 #endif /* CELL_COMMON_H */

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