Go to the source code of this file.
Data Structures | |
struct | setup_stage |
Triangle setup info (derived from draw_stage). More... | |
Functions | |
static struct setup_stage * | setup_stage (struct draw_stage *stage) |
Basically a cast wrapper. | |
static void | emit_hw_vertex (struct i915_context *i915, const struct vertex_header *vertex) |
Extract the needed fields from vertex_header and emit i915 dwords. | |
static void | emit_prim (struct draw_stage *stage, struct prim_header *prim, unsigned hwprim, unsigned nr) |
static void | setup_tri (struct draw_stage *stage, struct prim_header *prim) |
static void | setup_line (struct draw_stage *stage, struct prim_header *prim) |
static void | setup_point (struct draw_stage *stage, struct prim_header *prim) |
static void | setup_flush (struct draw_stage *stage, unsigned flags) |
static void | reset_stipple_counter (struct draw_stage *stage) |
static void | render_destroy (struct draw_stage *stage) |
struct draw_stage * | i915_draw_render_stage (struct i915_context *i915) |
Create a new primitive setup/render stage. |
static void emit_hw_vertex | ( | struct i915_context * | i915, | |
const struct vertex_header * | vertex | |||
) | [static] |
Extract the needed fields from vertex_header and emit i915 dwords.
Recall that the vertices are constructed by the 'draw' module and have a couple of slots at the beginning (1-dword header, 4-dword clip pos) that we ignore here.
Definition at line 70 of file i915_prim_emit.c.
References assert, vertex_info::attrib, i915_context::current, vertex_header::data, i915_context::dirty, vertex_info::emit, EMIT_1F, EMIT_2F, EMIT_3F, EMIT_4F, EMIT_4UB, float_to_ubyte(), fui(), vertex_info::num_attribs, OUT_BATCH, pack_ub4(), vertex_info::size, vertex_info::src_index, and i915_state::vertex_info.
00072 { 00073 const struct vertex_info *vinfo = &i915->current.vertex_info; 00074 uint i; 00075 uint count = 0; /* for debug/sanity */ 00076 00077 assert(!i915->dirty); 00078 00079 for (i = 0; i < vinfo->num_attribs; i++) { 00080 const uint j = vinfo->attrib[i].src_index; 00081 const float *attrib = vertex->data[j]; 00082 switch (vinfo->attrib[i].emit) { 00083 case EMIT_1F: 00084 OUT_BATCH( fui(attrib[0]) ); 00085 count++; 00086 break; 00087 case EMIT_2F: 00088 OUT_BATCH( fui(attrib[0]) ); 00089 OUT_BATCH( fui(attrib[1]) ); 00090 count += 2; 00091 break; 00092 case EMIT_3F: 00093 OUT_BATCH( fui(attrib[0]) ); 00094 OUT_BATCH( fui(attrib[1]) ); 00095 OUT_BATCH( fui(attrib[2]) ); 00096 count += 3; 00097 break; 00098 case EMIT_4F: 00099 OUT_BATCH( fui(attrib[0]) ); 00100 OUT_BATCH( fui(attrib[1]) ); 00101 OUT_BATCH( fui(attrib[2]) ); 00102 OUT_BATCH( fui(attrib[3]) ); 00103 count += 4; 00104 break; 00105 case EMIT_4UB: 00106 OUT_BATCH( pack_ub4(float_to_ubyte( attrib[2] ), 00107 float_to_ubyte( attrib[1] ), 00108 float_to_ubyte( attrib[0] ), 00109 float_to_ubyte( attrib[3] )) ); 00110 count += 1; 00111 break; 00112 default: 00113 assert(0); 00114 } 00115 } 00116 assert(count == vinfo->size); 00117 }
static void emit_prim | ( | struct draw_stage * | stage, | |
struct prim_header * | prim, | |||
unsigned | hwprim, | |||
unsigned | nr | |||
) | [static] |
Definition at line 122 of file i915_prim_emit.c.
References _3DPRIMITIVE, assert, BEGIN_BATCH, i915_context::current, i915_context::dirty, emit_hw_vertex(), FLUSH_BATCH, i915_context::hardware_dirty, setup_stage::i915, i915_emit_hardware_state(), i915_update_derived(), OUT_BATCH, setup_stage(), vertex_info::size, prim_header::v, and i915_state::vertex_info.
00126 { 00127 struct i915_context *i915 = setup_stage(stage)->i915; 00128 unsigned vertex_size; 00129 unsigned i; 00130 00131 if (i915->dirty) 00132 i915_update_derived( i915 ); 00133 00134 if (i915->hardware_dirty) 00135 i915_emit_hardware_state( i915 ); 00136 00137 /* need to do this after validation! */ 00138 vertex_size = i915->current.vertex_info.size * 4; /* in bytes */ 00139 assert(vertex_size >= 12); /* never smaller than 12 bytes */ 00140 00141 if (!BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 )) { 00142 FLUSH_BATCH(NULL); 00143 00144 /* Make sure state is re-emitted after a flush: 00145 */ 00146 i915_update_derived( i915 ); 00147 i915_emit_hardware_state( i915 ); 00148 00149 if (!BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 )) { 00150 assert(0); 00151 return; 00152 } 00153 } 00154 00155 /* Emit each triangle as a single primitive. I told you this was 00156 * simple. 00157 */ 00158 OUT_BATCH(_3DPRIMITIVE | 00159 hwprim | 00160 ((4 + vertex_size * nr)/4 - 2)); 00161 00162 for (i = 0; i < nr; i++) 00163 emit_hw_vertex(i915, prim->v[i]); 00164 }
struct draw_stage* i915_draw_render_stage | ( | struct i915_context * | i915 | ) | [read] |
Create a new primitive setup/render stage.
This gets plugged into the 'draw' module's pipeline.
Definition at line 206 of file i915_prim_emit.c.
References CALLOC_STRUCT, draw_stage::destroy, i915_context::draw, draw_stage::draw, draw_stage::flush, setup_stage::i915, draw_stage::line, draw_stage::point, render_destroy(), reset_stipple_counter(), draw_stage::reset_stipple_counter, setup, setup_flush(), setup_line(), setup_point(), setup_tri(), setup_stage::stage, and draw_stage::tri.
00207 { 00208 struct setup_stage *setup = CALLOC_STRUCT(setup_stage); 00209 00210 setup->i915 = i915; 00211 setup->stage.draw = i915->draw; 00212 setup->stage.point = setup_point; 00213 setup->stage.line = setup_line; 00214 setup->stage.tri = setup_tri; 00215 setup->stage.flush = setup_flush; 00216 setup->stage.reset_stipple_counter = reset_stipple_counter; 00217 setup->stage.destroy = render_destroy; 00218 00219 return &setup->stage; 00220 }
static void render_destroy | ( | struct draw_stage * | stage | ) | [static] |
Definition at line 196 of file i915_prim_emit.c.
References FREE.
00197 { 00198 FREE( stage ); 00199 }
static void reset_stipple_counter | ( | struct draw_stage * | stage | ) | [static] |
static void setup_flush | ( | struct draw_stage * | stage, | |
unsigned | flags | |||
) | [static] |
static void setup_line | ( | struct draw_stage * | stage, | |
struct prim_header * | prim | |||
) | [static] |
Definition at line 175 of file i915_prim_emit.c.
References emit_prim(), and PRIM3D_LINELIST.
00176 { 00177 emit_prim( stage, prim, PRIM3D_LINELIST, 2 ); 00178 }
static void setup_point | ( | struct draw_stage * | stage, | |
struct prim_header * | prim | |||
) | [static] |
Definition at line 182 of file i915_prim_emit.c.
References emit_prim(), and PRIM3D_POINTLIST.
00183 { 00184 emit_prim( stage, prim, PRIM3D_POINTLIST, 1 ); 00185 }
static struct setup_stage* setup_stage | ( | struct draw_stage * | stage | ) | [static, read] |
Basically a cast wrapper.
Definition at line 57 of file i915_prim_emit.c.
00058 { 00059 return (struct setup_stage *)stage; 00060 }
static void setup_tri | ( | struct draw_stage * | stage, | |
struct prim_header * | prim | |||
) | [static] |
Definition at line 168 of file i915_prim_emit.c.
References emit_prim(), and PRIM3D_TRILIST.
00169 { 00170 emit_prim( stage, prim, PRIM3D_TRILIST, 3 ); 00171 }