Go to the source code of this file.
Data Structures | |
struct | cell_vertex_shader_state |
Cell vertex shader state, subclass of pipe_shader_state. More... | |
struct | cell_fragment_shader_state |
Cell fragment shader state, subclass of pipe_shader_state. More... | |
struct | cell_blend_state |
Cell blend state atom, subclass of pipe_blend_state. More... | |
struct | cell_depth_stencil_alpha_state |
Cell depth/stencil/alpha state atom, subclass of pipe_depth_stencil_alpha_state. More... | |
struct | cell_context |
Per-context state, subclass of pipe_context. More... | |
Functions | |
static struct cell_context * | cell_context (struct pipe_context *pipe) |
struct pipe_context * | cell_create_context (struct pipe_screen *screen, struct cell_winsys *cws) |
void | cell_vertex_shader_queue_flush (struct draw_context *draw) |
Run the vertex shader on all vertices in the vertex queue. | |
void | cell_update_vertex_fetch (struct draw_context *draw) |
static struct cell_context* cell_context | ( | struct pipe_context * | pipe | ) | [static, read] |
Definition at line 175 of file cell_context.h.
00176 { 00177 return (struct cell_context *) pipe; 00178 }
struct pipe_context* cell_create_context | ( | struct pipe_screen * | screen, | |
struct cell_winsys * | cws | |||
) | [read] |
Definition at line 98 of file cell_context.c.
References align_malloc(), pipe_context::begin_query, cell_clear_surface(), cell_destroy_context(), cell_draw_create(), cell_flush(), cell_init_batch_buffers(), cell_init_draw_functions(), cell_init_shader_functions(), cell_init_state_functions(), cell_init_surface_functions(), cell_init_texture_functions(), cell_init_vbuf(), cell_init_vertex_functions(), cell_start_spus(), pipe_context::clear, cell_context::debug_flags, debug_get_flags_option(), pipe_context::destroy, cell_context::draw, draw_set_rasterize_stage(), draw_wide_line_threshold(), draw_wide_point_threshold(), pipe_context::end_query, pipe_context::flush, cell_context::num_spus, cell_context::pipe, pipe_context::screen, cell_context::vbuf, pipe_screen::winsys, pipe_context::winsys, and cell_context::winsys.
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 }
void cell_update_vertex_fetch | ( | struct draw_context * | draw | ) |
Definition at line 261 of file cell_vertex_fetch.c.
References align(), assert, cell_context::attrib_fetch, cell_context::attrib_fetch_offsets, draw_context::driver_private, emit_fetch(), offset(), PIPE_MAX_ATTRIBS, spe_allocate_register(), spe_bi(), spe_init_func(), SPE_INST_SIZE, pipe_vertex_element::src_format, and draw_context::vertex_element.
00262 { 00263 #if 0 00264 struct cell_context *const cell = 00265 (struct cell_context *) draw->driver_private; 00266 struct spe_function *p = &cell->attrib_fetch; 00267 unsigned function_index[PIPE_MAX_ATTRIBS]; 00268 unsigned unique_attr_formats; 00269 int out_ptr; 00270 int in_ptr; 00271 int shuf_ptr; 00272 unsigned i; 00273 unsigned j; 00274 00275 00276 /* Determine how many unique input attribute formats there are. At the 00277 * same time, store the index of the lowest numbered attribute that has 00278 * the same format as any non-unique format. 00279 */ 00280 unique_attr_formats = 1; 00281 function_index[0] = 0; 00282 for (i = 1; i < draw->vertex_fetch.nr_attrs; i++) { 00283 const enum pipe_format curr_fmt = draw->vertex_element[i].src_format; 00284 00285 for (j = 0; j < i; j++) { 00286 if (curr_fmt == draw->vertex_element[j].src_format) { 00287 break; 00288 } 00289 } 00290 00291 if (j == i) { 00292 unique_attr_formats++; 00293 } 00294 00295 function_index[i] = j; 00296 } 00297 00298 00299 /* Each fetch function can be a maximum of 34 instructions (note: this is 00300 * actually a slight over-estimate). 00301 */ 00302 spe_init_func(p, 34 * SPE_INST_SIZE * unique_attr_formats); 00303 00304 00305 /* Allocate registers for the function's input parameters. 00306 */ 00307 out_ptr = spe_allocate_register(p, 3); 00308 in_ptr = spe_allocate_register(p, 4); 00309 shuf_ptr = spe_allocate_register(p, 5); 00310 00311 00312 /* Generate code for the individual attribute fetch functions. 00313 */ 00314 for (i = 0; i < draw->vertex_fetch.nr_attrs; i++) { 00315 unsigned offset; 00316 00317 if (function_index[i] == i) { 00318 cell->attrib_fetch_offsets[i] = (unsigned) ((void *) p->csr 00319 - (void *) p->store); 00320 00321 offset = 0; 00322 emit_fetch(p, in_ptr, &offset, out_ptr, shuf_ptr, 00323 draw->vertex_element[i].src_format); 00324 spe_bi(p, 0, 0, 0); 00325 00326 /* Round up to the next 16-byte boundary. 00327 */ 00328 if ((((unsigned) p->store) & 0x0f) != 0) { 00329 const unsigned align = ((unsigned) p->store) & 0x0f; 00330 p->store = (uint32_t *) (((void *) p->store) + align); 00331 } 00332 } else { 00333 /* Use the same function entry-point as a previously seen attribute 00334 * with the same format. 00335 */ 00336 cell->attrib_fetch_offsets[i] = 00337 cell->attrib_fetch_offsets[function_index[i]]; 00338 } 00339 } 00340 #else 00341 assert(0); 00342 #endif 00343 }
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 }