draw_vs_exec.c File Reference

Include dependency graph for draw_vs_exec.c:

Go to the source code of this file.

Data Structures

struct  exec_vertex_shader

Functions

static struct exec_vertex_shaderexec_vertex_shader (struct draw_vertex_shader *vs)
static void vs_exec_prepare (struct draw_vertex_shader *shader, struct draw_context *draw)
static void vs_exec_run_linear (struct draw_vertex_shader *shader, const float(*input)[4], float(*output)[4], const float(*constants)[4], unsigned count, unsigned input_stride, unsigned output_stride)
static void vs_exec_delete (struct draw_vertex_shader *dvs)
struct draw_vertex_shaderdraw_create_vs_exec (struct draw_context *draw, const struct pipe_shader_state *state)


Function Documentation

struct draw_vertex_shader* draw_create_vs_exec ( struct draw_context draw,
const struct pipe_shader_state state 
) [read]

Definition at line 172 of file draw_vs_exec.c.

References exec_vertex_shader::base, CALLOC_STRUCT, draw_vertex_shader::create_varient, draw_vertex_shader::delete, draw_vertex_shader::draw, FREE, draw_vertex_shader::info, draw_context::machine, exec_vertex_shader::machine, draw_vertex_shader::prepare, draw_vertex_shader::run_linear, draw_vertex_shader::state, tgsi_dup_tokens(), tgsi_scan_shader(), pipe_shader_state::tokens, draw_context::vs, vs_exec_delete(), vs_exec_prepare(), and vs_exec_run_linear().

00174 {
00175    struct exec_vertex_shader *vs = CALLOC_STRUCT( exec_vertex_shader );
00176 
00177    if (vs == NULL) 
00178       return NULL;
00179 
00180    /* we make a private copy of the tokens */
00181    vs->base.state.tokens = tgsi_dup_tokens(state->tokens);
00182    if (!vs->base.state.tokens) {
00183       FREE(vs);
00184       return NULL;
00185    }
00186 
00187    tgsi_scan_shader(state->tokens, &vs->base.info);
00188 
00189    vs->base.draw = draw;
00190    vs->base.prepare = vs_exec_prepare;
00191    vs->base.run_linear = vs_exec_run_linear;
00192    vs->base.delete = vs_exec_delete;
00193    vs->base.create_varient = draw_vs_varient_generic;
00194    vs->machine = &draw->vs.machine;
00195 
00196    return &vs->base;
00197 }

static struct exec_vertex_shader* exec_vertex_shader ( struct draw_vertex_shader vs  )  [static, read]

Definition at line 51 of file draw_vs_exec.c.

00052 {
00053    return (struct exec_vertex_shader *)vs;
00054 }

static void vs_exec_delete ( struct draw_vertex_shader dvs  )  [static]

Definition at line 164 of file draw_vs_exec.c.

References FREE, draw_vertex_shader::state, and pipe_shader_state::tokens.

00165 {
00166    FREE((void*) dvs->state.tokens);
00167    FREE( dvs );
00168 }

static void vs_exec_prepare ( struct draw_vertex_shader shader,
struct draw_context draw 
) [static]

Definition at line 60 of file draw_vs_exec.c.

References exec_vertex_shader(), exec_vertex_shader::machine, PIPE_MAX_SAMPLERS, draw_vertex_shader::state, tgsi_exec_machine_bind_shader(), and pipe_shader_state::tokens.

00062 {
00063    struct exec_vertex_shader *evs = exec_vertex_shader(shader);
00064 
00065    /* specify the vertex program to interpret/execute */
00066    tgsi_exec_machine_bind_shader(evs->machine,
00067                                  shader->state.tokens,
00068                                  PIPE_MAX_SAMPLERS,
00069                                  NULL /*samplers*/ );
00070 
00071 }

static void vs_exec_run_linear ( struct draw_vertex_shader shader,
const float *  input[4],
float *  output[4],
const float *  constants[4],
unsigned  count,
unsigned  input_stride,
unsigned  output_stride 
) [static]

Definition at line 81 of file draw_vs_exec.c.

References tgsi_exec_machine::Consts, debug_printf(), exec_vertex_shader(), tgsi_exec_channel::f, draw_vertex_shader::info, tgsi_exec_machine::Inputs, exec_vertex_shader::machine, MAX_TGSI_VERTICES, MIN2, tgsi_shader_info::num_inputs, tgsi_shader_info::num_outputs, tgsi_exec_machine::Outputs, tgsi_exec_machine_run(), tgsi_set_exec_mask(), and tgsi_exec_vector::xyzw.

00088 {
00089    struct exec_vertex_shader *evs = exec_vertex_shader(shader);
00090    struct tgsi_exec_machine *machine = evs->machine;
00091    unsigned int i, j;
00092    unsigned slot;
00093 
00094    machine->Consts = constants;
00095 
00096    for (i = 0; i < count; i += MAX_TGSI_VERTICES) {
00097       unsigned int max_vertices = MIN2(MAX_TGSI_VERTICES, count - i);
00098 
00099       /* Swizzle inputs.  
00100        */
00101       for (j = 0; j < max_vertices; j++) {
00102 #if 0
00103          debug_printf("%d) Input vert:\n", i + j);
00104          for (slot = 0; slot < shader->info.num_inputs; slot++) {
00105             debug_printf("\t%d: %f %f %f %f\n", slot,
00106                          input[slot][0],
00107                          input[slot][1],
00108                          input[slot][2],
00109                          input[slot][3]);
00110          }
00111 #endif
00112 
00113          for (slot = 0; slot < shader->info.num_inputs; slot++) {
00114             machine->Inputs[slot].xyzw[0].f[j] = input[slot][0];
00115             machine->Inputs[slot].xyzw[1].f[j] = input[slot][1];
00116             machine->Inputs[slot].xyzw[2].f[j] = input[slot][2];
00117             machine->Inputs[slot].xyzw[3].f[j] = input[slot][3];
00118          }
00119 
00120          input = (const float (*)[4])((const char *)input + input_stride);
00121       } 
00122 
00123       tgsi_set_exec_mask(machine,
00124                          1,
00125                          max_vertices > 1,
00126                          max_vertices > 2,
00127                          max_vertices > 3);
00128 
00129       /* run interpreter */
00130       tgsi_exec_machine_run( machine );
00131 
00132       /* Unswizzle all output results.  
00133        */
00134       for (j = 0; j < max_vertices; j++) {
00135          for (slot = 0; slot < shader->info.num_outputs; slot++) {
00136             output[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
00137             output[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
00138             output[slot][2] = machine->Outputs[slot].xyzw[2].f[j];
00139             output[slot][3] = machine->Outputs[slot].xyzw[3].f[j];
00140 
00141          }
00142 
00143 #if 0
00144          debug_printf("%d) Post xform vert:\n", i + j);
00145          for (slot = 0; slot < shader->info.num_outputs; slot++) {
00146             debug_printf("\t%d: %f %f %f %f\n", slot,
00147                          output[slot][0],
00148                          output[slot][1],
00149                          output[slot][2],
00150                          output[slot][3]);
00151          }
00152 #endif
00153 
00154          output = (float (*)[4])((char *)output + output_stride);
00155       } 
00156 
00157    }
00158 }


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