cell_vertex_shader.c

Go to the documentation of this file.
00001 /*
00002  * (C) Copyright IBM Corporation 2008
00003  * All Rights Reserved.
00004  *
00005  * Permission is hereby granted, free of charge, to any person obtaining a
00006  * copy of this software and associated documentation files (the "Software"),
00007  * to deal in the Software without restriction, including without limitation
00008  * on the rights to use, copy, modify, merge, publish, distribute, sub
00009  * license, and/or sell copies of the Software, and to permit persons to whom
00010  * the Software is furnished to do so, subject to the following conditions:
00011  *
00012  * The above copyright notice and this permission notice (including the next
00013  * paragraph) shall be included in all copies or substantial portions of the
00014  * Software.
00015  *
00016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
00019  * AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
00020  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
00021  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
00022  * USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00032 #include "pipe/p_defines.h"
00033 #include "pipe/p_context.h"
00034 #include "pipe/p_winsys.h"
00035 #include "util/u_math.h"
00036 
00037 #include "cell_context.h"
00038 #include "cell_draw_arrays.h"
00039 #include "cell_flush.h"
00040 #include "cell_spu.h"
00041 #include "cell_batch.h"
00042 
00043 #include "cell/common.h"
00044 #include "draw/draw_context.h"
00045 #include "draw/draw_private.h"
00046 
00051 void
00052 cell_vertex_shader_queue_flush(struct draw_context *draw)
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 }

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