draw_vs.h File Reference

Include dependency graph for draw_vs.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  draw_varient_input
struct  draw_varient_output
struct  draw_varient_element
struct  draw_vs_varient_key
struct  draw_vs_varient
struct  draw_vertex_shader
 Private version of the compiled vertex_shader. More...

Defines

#define MAX_TGSI_VERTICES   4

Functions

struct draw_vs_varientdraw_vs_lookup_varient (struct draw_vertex_shader *base, const struct draw_vs_varient_key *key)
struct draw_vertex_shaderdraw_create_vs_exec (struct draw_context *draw, const struct pipe_shader_state *templ)
struct draw_vertex_shaderdraw_create_vs_sse (struct draw_context *draw, const struct pipe_shader_state *templ)
struct draw_vertex_shaderdraw_create_vs_llvm (struct draw_context *draw, const struct pipe_shader_state *templ)
struct draw_vs_varientdraw_vs_varient_aos_sse (struct draw_vertex_shader *vs, const struct draw_vs_varient_key *key)
struct translatedraw_vs_get_fetch (struct draw_context *draw, struct translate_key *key)
struct translatedraw_vs_get_emit (struct draw_context *draw, struct translate_key *key)
struct draw_vs_varientdraw_vs_varient_generic (struct draw_vertex_shader *vs, const struct draw_vs_varient_key *key)
static int draw_vs_varient_keysize (const struct draw_vs_varient_key *key)
static int draw_vs_varient_key_compare (const struct draw_vs_varient_key *a, const struct draw_vs_varient_key *b)
struct aos_machine * draw_vs_aos_machine (void)
void draw_vs_aos_machine_destroy (struct aos_machine *machine)
void draw_vs_aos_machine_constants (struct aos_machine *machine, const float(*constants)[4])
void draw_vs_aos_machine_viewport (struct aos_machine *machine, const struct pipe_viewport_state *viewport)


Define Documentation

#define MAX_TGSI_VERTICES   4

Definition at line 216 of file draw_vs.h.


Function Documentation

struct draw_vertex_shader* draw_create_vs_exec ( struct draw_context draw,
const struct pipe_shader_state templ 
) [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 }

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 }

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

Definition at line 217 of file draw_vs_sse.c.

00220 {
00221    return (void *) 0;

struct aos_machine* draw_vs_aos_machine ( void   )  [read]

Definition at line 319 of file draw_vs_aos_machine.c.

00320 {
00321    return NULL;
00322 }

void draw_vs_aos_machine_constants ( struct aos_machine *  machine,
const float *  constants[4] 
)

Definition at line 310 of file draw_vs_aos_machine.c.

00312 {
00313 }

void draw_vs_aos_machine_destroy ( struct aos_machine *  machine  ) 

Definition at line 315 of file draw_vs_aos_machine.c.

00316 {
00317 }

void draw_vs_aos_machine_viewport ( struct aos_machine *  machine,
const struct pipe_viewport_state viewport 
)

Definition at line 305 of file draw_vs_aos_machine.c.

00307 {
00308 }

struct translate* draw_vs_get_emit ( struct draw_context draw,
struct translate_key key 
) [read]

Definition at line 253 of file draw_vs.c.

References draw_context::emit, draw_context::emit_cache, translate::key, translate_cache_find(), translate_key_compare(), translate_key_sanitize(), and draw_context::vs.

00255 {
00256    if (!draw->vs.emit ||
00257        translate_key_compare(&draw->vs.emit->key, key) != 0) 
00258    {
00259       translate_key_sanitize(key);
00260       draw->vs.emit = translate_cache_find(draw->vs.emit_cache, key);
00261    }
00262    
00263    return draw->vs.emit;
00264 }

struct translate* draw_vs_get_fetch ( struct draw_context draw,
struct translate_key key 
) [read]

Definition at line 239 of file draw_vs.c.

References draw_context::fetch, draw_context::fetch_cache, translate::key, translate_cache_find(), translate_key_compare(), translate_key_sanitize(), and draw_context::vs.

00241 {
00242    if (!draw->vs.fetch ||
00243        translate_key_compare(&draw->vs.fetch->key, key) != 0) 
00244    {
00245       translate_key_sanitize(key);
00246       draw->vs.fetch = translate_cache_find(draw->vs.fetch_cache, key);
00247    }
00248    
00249    return draw->vs.fetch;
00250 }

struct draw_vs_varient* draw_vs_lookup_varient ( struct draw_vertex_shader base,
const struct draw_vs_varient_key key 
) [read]

Definition at line 202 of file draw_vs.c.

References draw_vertex_shader::create_varient, draw_vs_varient::destroy, draw_vs_varient_key_compare(), Elements, draw_vs_varient::key, draw_vertex_shader::last_varient, draw_vertex_shader::nr_varients, and draw_vertex_shader::varient.

00204 {
00205    struct draw_vs_varient *varient;
00206    unsigned i;
00207 
00208    /* Lookup existing varient: 
00209     */
00210    for (i = 0; i < vs->nr_varients; i++)
00211       if (draw_vs_varient_key_compare(key, &vs->varient[i]->key) == 0)
00212          return vs->varient[i];
00213    
00214    /* Else have to create a new one: 
00215     */
00216    varient = vs->create_varient( vs, key );
00217    if (varient == NULL)
00218       return NULL;
00219 
00220    /* Add it to our list, could be smarter: 
00221     */
00222    if (vs->nr_varients < Elements(vs->varient)) {
00223       vs->varient[vs->nr_varients++] = varient;
00224    }
00225    else {
00226       vs->last_varient++;
00227       vs->last_varient %= Elements(vs->varient);
00228       vs->varient[vs->last_varient]->destroy(vs->varient[vs->last_varient]);
00229       vs->varient[vs->last_varient] = varient;
00230    }
00231 
00232    /* Done 
00233     */
00234    return varient;
00235 }

struct draw_vs_varient* draw_vs_varient_aos_sse ( struct draw_vertex_shader vs,
const struct draw_vs_varient_key key 
) [read]

struct draw_vs_varient* draw_vs_varient_generic ( struct draw_vertex_shader vs,
const struct draw_vs_varient_key key 
) [read]

Definition at line 256 of file draw_vs_varient.c.

References assert, draw_vs_varient_generic::base, draw_varient_input::buffer, CALLOC_STRUCT, draw_vs_varient::destroy, draw_vertex_shader::draw, draw_vs_varient_generic::draw, draw_translate_vinfo_format(), draw_vs_get_emit(), draw_vs_get_fetch(), draw_vs_varient_key::element, translate_key::element, draw_vs_varient_generic::emit, EMIT_1F_PSIZE, draw_vs_varient_generic::fetch, draw_varient_output::format, draw_varient_input::format, draw_varient_element::in, draw_vertex_shader::info, translate_element::input_buffer, translate_element::input_format, translate_element::input_offset, draw_vs_varient::key, MAX2, translate_key::nr_elements, draw_vs_varient_key::nr_inputs, draw_vs_varient_key::nr_outputs, tgsi_shader_info::num_outputs, draw_varient_output::offset, draw_varient_input::offset, draw_varient_element::out, translate_element::output_format, translate_element::output_offset, draw_vs_varient_key::output_stride, translate_key::output_stride, PIPE_FORMAT_R32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT, draw_vs_varient::set_buffer, draw_vs_varient_generic::temp_vertex_stride, draw_vs_varient::vs, draw_varient_output::vs_output, vsvg_destroy(), vsvg_run_elts(), vsvg_run_linear(), and vsvg_set_buffer().

00258 {
00259    unsigned i;
00260    struct translate_key fetch, emit;
00261 
00262    struct draw_vs_varient_generic *vsvg = CALLOC_STRUCT( draw_vs_varient_generic );
00263    if (vsvg == NULL)
00264       return NULL;
00265 
00266    vsvg->base.key = *key;
00267    vsvg->base.vs = vs;
00268    vsvg->base.set_buffer    = vsvg_set_buffer;
00269    vsvg->base.run_elts      = vsvg_run_elts;
00270    vsvg->base.run_linear    = vsvg_run_linear;
00271    vsvg->base.destroy       = vsvg_destroy;
00272 
00273    vsvg->draw = vs->draw;
00274 
00275    vsvg->temp_vertex_stride = MAX2(key->nr_inputs,
00276                                    vsvg->base.vs->info.num_outputs) * 4 * sizeof(float);
00277 
00278    /* Build free-standing fetch and emit functions:
00279     */
00280    fetch.nr_elements = key->nr_inputs;
00281    fetch.output_stride = vsvg->temp_vertex_stride;
00282    for (i = 0; i < key->nr_inputs; i++) {
00283       fetch.element[i].input_format = key->element[i].in.format;
00284       fetch.element[i].input_buffer = key->element[i].in.buffer;
00285       fetch.element[i].input_offset = key->element[i].in.offset;
00286       fetch.element[i].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
00287       fetch.element[i].output_offset = i * 4 * sizeof(float);
00288       assert(fetch.element[i].output_offset < fetch.output_stride);
00289    }
00290 
00291 
00292    emit.nr_elements = key->nr_outputs;
00293    emit.output_stride = key->output_stride;
00294    for (i = 0; i < key->nr_outputs; i++) {
00295       if (key->element[i].out.format != EMIT_1F_PSIZE)
00296       {      
00297          emit.element[i].input_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
00298          emit.element[i].input_buffer = 0;
00299          emit.element[i].input_offset = key->element[i].out.vs_output * 4 * sizeof(float);
00300          emit.element[i].output_format = draw_translate_vinfo_format(key->element[i].out.format);
00301          emit.element[i].output_offset = key->element[i].out.offset;
00302          assert(emit.element[i].input_offset <= fetch.output_stride);
00303       }
00304       else {
00305          emit.element[i].input_format = PIPE_FORMAT_R32_FLOAT;
00306          emit.element[i].input_buffer = 1;
00307          emit.element[i].input_offset = 0;
00308          emit.element[i].output_format = PIPE_FORMAT_R32_FLOAT;
00309          emit.element[i].output_offset = key->element[i].out.offset;
00310       }
00311    }
00312 
00313    vsvg->fetch = draw_vs_get_fetch( vs->draw, &fetch );
00314    vsvg->emit = draw_vs_get_emit( vs->draw, &emit );
00315 
00316    return &vsvg->base;
00317 }

static int draw_vs_varient_key_compare ( const struct draw_vs_varient_key a,
const struct draw_vs_varient_key b 
) [static]

Definition at line 198 of file draw_vs.h.

References draw_vs_varient_keysize().

00200 {
00201    int keysize = draw_vs_varient_keysize(a);
00202    return memcmp(a, b, keysize);
00203 }

static int draw_vs_varient_keysize ( const struct draw_vs_varient_key key  )  [static]

Definition at line 193 of file draw_vs.h.

References draw_vs_varient_key::nr_elements.

00194 {
00195    return 2 * sizeof(int) + key->nr_elements * sizeof(struct draw_varient_element);
00196 }


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