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 #include "util/u_memory.h"
00029 #include "pipe/p_shader_tokens.h"
00030 #include "draw/draw_context.h"
00031 #include "draw/draw_vertex.h"
00032 #include "cell_context.h"
00033 #include "cell_batch.h"
00034 #include "cell_state.h"
00035 #include "cell_state_emit.h"
00036
00037
00043 static void
00044 calculate_vertex_layout( struct cell_context *cell )
00045 {
00046 const struct cell_fragment_shader_state *fs = cell->fs;
00047 const enum interp_mode colorInterp
00048 = cell->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
00049 struct vertex_info *vinfo = &cell->vertex_info;
00050 uint i;
00051 int src;
00052
00053 #if 0
00054 if (cell->vbuf) {
00055
00056
00057
00058 struct vertex_info *vinfo_vbuf = &cell->vertex_info_vbuf;
00059 vinfo_vbuf->num_attribs = 0;
00060 draw_emit_vertex_attr(vinfo_vbuf, EMIT_ALL, INTERP_NONE, 0);
00061 vinfo_vbuf->size = 4 * vs->num_outputs + sizeof(struct vertex_header)/4;
00062 }
00063 #endif
00064
00065
00066 vinfo->num_attribs = 0;
00067
00068
00069 src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_POSITION, 0);
00070 assert(src >= 0);
00071 draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
00072
00073
00074
00075
00076
00077
00078 for (i = 0; i < fs->info.num_inputs; i++) {
00079 switch (fs->info.input_semantic_name[i]) {
00080 case TGSI_SEMANTIC_POSITION:
00081
00082 break;
00083
00084 case TGSI_SEMANTIC_COLOR:
00085 src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_COLOR,
00086 fs->info.input_semantic_index[i]);
00087 assert(src >= 0);
00088 draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
00089 break;
00090
00091 case TGSI_SEMANTIC_FOG:
00092 src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_FOG, 0);
00093 #if 1
00094 if (src < 0)
00095 src = 0;
00096 #endif
00097 assert(src >= 0);
00098 draw_emit_vertex_attr(vinfo, EMIT_1F, INTERP_PERSPECTIVE, src);
00099 break;
00100
00101 case TGSI_SEMANTIC_GENERIC:
00102
00103 src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_GENERIC,
00104 fs->info.input_semantic_index[i]);
00105 assert(src >= 0);
00106 draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
00107 break;
00108
00109 default:
00110 assert(0);
00111 }
00112 }
00113
00114 draw_compute_vertex_size(vinfo);
00115
00116
00117 cell->dirty |= CELL_NEW_VERTEX_INFO;
00118 }
00119
00120
00121 #if 0
00122
00125 static void
00126 compute_cliprect(struct cell_context *sp)
00127 {
00128 uint surfWidth = sp->framebuffer.width;
00129 uint surfHeight = sp->framebuffer.height;
00130
00131 if (sp->rasterizer->scissor) {
00132
00133 sp->cliprect.minx = MAX2(sp->scissor.minx, 0);
00134 sp->cliprect.miny = MAX2(sp->scissor.miny, 0);
00135 sp->cliprect.maxx = MIN2(sp->scissor.maxx, surfWidth);
00136 sp->cliprect.maxy = MIN2(sp->scissor.maxy, surfHeight);
00137 }
00138 else {
00139
00140 sp->cliprect.minx = 0;
00141 sp->cliprect.miny = 0;
00142 sp->cliprect.maxx = surfWidth;
00143 sp->cliprect.maxy = surfHeight;
00144 }
00145 }
00146 #endif
00147
00148
00149
00153 void cell_update_derived( struct cell_context *cell )
00154 {
00155 if (cell->dirty & (CELL_NEW_RASTERIZER |
00156 CELL_NEW_FS |
00157 CELL_NEW_VS))
00158 calculate_vertex_layout( cell );
00159
00160 #if 0
00161 if (cell->dirty & (CELL_NEW_SCISSOR |
00162 CELL_NEW_DEPTH_STENCIL_ALPHA |
00163 CELL_NEW_FRAMEBUFFER))
00164 compute_cliprect(cell);
00165 #endif
00166
00167 cell_emit_state(cell);
00168
00169 cell->dirty = 0;
00170 }