Go to the source code of this file.
Functions | |
void | cell_vertex_shader_queue_flush (struct draw_context *draw) |
Run the vertex shader on all vertices in the vertex queue. |
Definition in file cell_vertex_shader.c.
void cell_vertex_shader_queue_flush | ( | struct draw_context * | draw | ) |
Run the vertex shader on all vertices in the vertex queue.
Called by the draw module when the vertx cache needs to be flushed.
Definition at line 52 of file cell_vertex_shader.c.
References assert, cell_context::attrib_fetch, cell_context::attrib_fetch_offsets, cell_batch_alloc(), cell_batch_flush(), CELL_CMD_STATE_ATTRIB_FETCH, CELL_CMD_STATE_UNIFORMS, CELL_CMD_STATE_VIEWPORT, CELL_CMD_STATE_VS_ARRAY_INFO, CELL_CMD_VS_EXECUTE, cell_flush_int(), CELL_FLUSH_WAIT, cell_global, cell_update_vertex_fetch(), cell_global_info::command, draw_context::driver_private, draw_context::elts, MIN2, draw_context::nr_planes, pf_size_w, pf_size_x, pf_size_y, pf_size_z, draw_context::plane, ROUNDUP16, send_mbox_message(), cell_attribute_fetch_code::size, cell_global_info::spe_contexts, SPU_VERTS_PER_BATCH, pipe_vertex_element::src_format, spe_function::store, draw_context::user, draw_context::vertex_element, draw_context::viewport, draw_context::vs, cell_command::vs, and cell_context::vs.
00053 { 00054 #if 0 00055 struct cell_context *const cell = 00056 (struct cell_context *) draw->driver_private; 00057 struct cell_command_vs *const vs = &cell_global.command[0].vs; 00058 uint64_t *batch; 00059 struct cell_array_info *array_info; 00060 unsigned i, j; 00061 struct cell_attribute_fetch_code *cf; 00062 00063 assert(draw->vs.queue_nr != 0); 00064 00065 /* XXX: do this on statechange: 00066 */ 00067 draw_update_vertex_fetch(draw); 00068 cell_update_vertex_fetch(draw); 00069 00070 00071 batch = cell_batch_alloc(cell, sizeof(batch[0]) + sizeof(*cf)); 00072 batch[0] = CELL_CMD_STATE_ATTRIB_FETCH; 00073 cf = (struct cell_attribute_fetch_code *) (&batch[1]); 00074 cf->base = (uint64_t) cell->attrib_fetch.store; 00075 cf->size = ROUNDUP16((unsigned)((void *) cell->attrib_fetch.csr 00076 - (void *) cell->attrib_fetch.store)); 00077 00078 00079 for (i = 0; i < draw->vertex_fetch.nr_attrs; i++) { 00080 const enum pipe_format format = draw->vertex_element[i].src_format; 00081 const unsigned count = ((pf_size_x(format) != 0) 00082 + (pf_size_y(format) != 0) 00083 + (pf_size_z(format) != 0) 00084 + (pf_size_w(format) != 0)); 00085 const unsigned size = pf_size_x(format) * count; 00086 00087 batch = cell_batch_alloc(cell, sizeof(batch[0]) + sizeof(*array_info)); 00088 00089 batch[0] = CELL_CMD_STATE_VS_ARRAY_INFO; 00090 00091 array_info = (struct cell_array_info *) &batch[1]; 00092 assert(draw->vertex_fetch.src_ptr[i] != NULL); 00093 array_info->base = (uintptr_t) draw->vertex_fetch.src_ptr[i]; 00094 array_info->attr = i; 00095 array_info->pitch = draw->vertex_fetch.pitch[i]; 00096 array_info->size = size; 00097 array_info->function_offset = cell->attrib_fetch_offsets[i]; 00098 } 00099 00100 batch = cell_batch_alloc(cell, sizeof(batch[0]) 00101 + sizeof(struct pipe_viewport_state)); 00102 batch[0] = CELL_CMD_STATE_VIEWPORT; 00103 (void) memcpy(&batch[1], &draw->viewport, 00104 sizeof(struct pipe_viewport_state)); 00105 00106 { 00107 uint64_t uniforms = (uintptr_t) draw->user.constants; 00108 00109 batch = cell_batch_alloc(cell, 2 *sizeof(batch[0])); 00110 batch[0] = CELL_CMD_STATE_UNIFORMS; 00111 batch[1] = uniforms; 00112 } 00113 00114 cell_batch_flush(cell); 00115 00116 vs->opcode = CELL_CMD_VS_EXECUTE; 00117 vs->nr_attrs = draw->vertex_fetch.nr_attrs; 00118 00119 (void) memcpy(vs->plane, draw->plane, sizeof(draw->plane)); 00120 vs->nr_planes = draw->nr_planes; 00121 00122 for (i = 0; i < draw->vs.queue_nr; i += SPU_VERTS_PER_BATCH) { 00123 const unsigned n = MIN2(SPU_VERTS_PER_BATCH, draw->vs.queue_nr - i); 00124 00125 for (j = 0; j < n; j++) { 00126 vs->elts[j] = draw->vs.queue[i + j].elt; 00127 vs->vOut[j] = (uintptr_t) draw->vs.queue[i + j].vertex; 00128 } 00129 00130 for (/* empty */; j < SPU_VERTS_PER_BATCH; j++) { 00131 vs->elts[j] = vs->elts[0]; 00132 vs->vOut[j] = (uintptr_t) draw->vs.queue[i + j].vertex; 00133 } 00134 00135 vs->num_elts = n; 00136 send_mbox_message(cell_global.spe_contexts[0], CELL_CMD_VS_EXECUTE); 00137 00138 cell_flush_int(cell, CELL_FLUSH_WAIT); 00139 } 00140 00141 draw->vs.post_nr = draw->vs.queue_nr; 00142 draw->vs.queue_nr = 0; 00143 #else 00144 assert(0); 00145 #endif 00146 }