draw_vs_llvm.c File Reference

Include dependency graph for draw_vs_llvm.c:

Go to the source code of this file.

Data Structures

struct  draw_llvm_vertex_shader

Functions

static void vs_llvm_prepare (struct draw_vertex_shader *base, struct draw_context *draw)
static void vs_llvm_run_linear (struct draw_vertex_shader *base, const float(*input)[4], float(*output)[4], const float(*constants)[4], unsigned count, unsigned input_stride, unsigned output_stride)
static void vs_llvm_delete (struct draw_vertex_shader *base)
struct draw_vertex_shaderdraw_create_vs_llvm (struct draw_context *draw, const struct pipe_shader_state *templ)


Function Documentation

struct draw_vertex_shader* draw_create_vs_llvm ( struct draw_context draw,
const struct pipe_shader_state templ 
) [read]

Definition at line 99 of file draw_vs_llvm.c.

References draw_llvm_vertex_shader::base, CALLOC_STRUCT, draw_vertex_shader::create_varient, draw_vertex_shader::delete, draw_vertex_shader::draw, draw_context::engine, FREE, gallivm_cpu_engine_create(), gallivm_cpu_jit_compile(), gallivm_global_cpu_engine(), gallivm_ir_compile(), gallivm_ir_delete(), gallivm_ir_fill_from_tgsi(), gallivm_ir_new(), gallivm_ir_set_components(), gallivm_ir_set_layout(), GALLIVM_SOA, GALLIVM_VS, draw_vertex_shader::info, draw_llvm_vertex_shader::llvm_prog, draw_context::machine, draw_llvm_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_llvm_delete(), vs_llvm_prepare(), and vs_llvm_run_linear().

00101 {
00102    struct draw_llvm_vertex_shader *vs;
00103 
00104    vs = CALLOC_STRUCT( draw_llvm_vertex_shader );
00105    if (vs == NULL)
00106       return NULL;
00107 
00108    /* we make a private copy of the tokens */
00109    vs->base.state.tokens = tgsi_dup_tokens(templ->tokens);
00110    if (!vs->base.state.tokens) {
00111       FREE(vs);
00112       return NULL;
00113    }
00114 
00115    tgsi_scan_shader(vs->base.state.tokens, &vs->base.info);
00116 
00117    vs->base.draw = draw;
00118    vs->base.prepare = vs_llvm_prepare;
00119    vs->base.create_varient = draw_vs_varient_generic;
00120    vs->base.run_linear = vs_llvm_run_linear;
00121    vs->base.delete = vs_llvm_delete;
00122    vs->machine = &draw->vs.machine;
00123 
00124    {
00125       struct gallivm_ir *ir = gallivm_ir_new(GALLIVM_VS);
00126       gallivm_ir_set_layout(ir, GALLIVM_SOA);
00127       gallivm_ir_set_components(ir, 4);
00128       gallivm_ir_fill_from_tgsi(ir, vs->base.state.tokens);
00129       vs->llvm_prog = gallivm_ir_compile(ir);
00130       gallivm_ir_delete(ir);
00131    }
00132 
00133    draw->vs.engine = gallivm_global_cpu_engine();
00134 
00135    /* XXX: Why are there two versions of this?  Shouldn't creating the
00136     *      engine be a separate operation to compiling a shader?
00137     */
00138    if (!draw->vs.engine) {
00139       draw->vs.engine = gallivm_cpu_engine_create(vs->llvm_prog);
00140    }
00141    else {
00142       gallivm_cpu_jit_compile(draw->vs.engine, vs->llvm_prog);
00143    }
00144 
00145    return &vs->base;
00146 }

static void vs_llvm_delete ( struct draw_vertex_shader base  )  [static]

Definition at line 83 of file draw_vs_llvm.c.

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

00084 {
00085    struct draw_llvm_vertex_shader *shader =
00086       (struct draw_llvm_vertex_shader *)base;
00087 
00088    /* Do something to free compiled shader:
00089     */
00090 
00091    FREE( (void*) shader->base.state.tokens );
00092    FREE( shader );
00093 }

static void vs_llvm_prepare ( struct draw_vertex_shader base,
struct draw_context draw 
) [static]

Definition at line 55 of file draw_vs_llvm.c.

00057 {
00058 }

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

Definition at line 64 of file draw_vs_llvm.c.

References gallivm_cpu_vs_exec(), draw_vertex_shader::info, draw_llvm_vertex_shader::llvm_prog, draw_llvm_vertex_shader::machine, tgsi_shader_info::num_inputs, and tgsi_shader_info::num_outputs.

00071 {
00072    struct draw_llvm_vertex_shader *shader =
00073       (struct draw_llvm_vertex_shader *)base;
00074 
00075    gallivm_cpu_vs_exec(shader->llvm_prog, shader->machine,
00076                        input, base->info.num_inputs, output, base->info.num_outputs,
00077                        constants, count, input_stride, output_stride);
00078 }


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