void r300_translate_vertex_shader(struct r300_context* r300, struct r300_vertex_shader* vs) { struct r300_vertex_program_compiler compiler; struct tgsi_to_rc ttr; /* Initialize. */ r300_shader_read_vs_outputs(&vs->info, &vs->outputs); /* Setup the compiler */ rc_init(&compiler.Base); compiler.Base.Debug = DBG_ON(r300, DBG_VP); compiler.code = &vs->code; compiler.UserData = vs; if (compiler.Base.Debug) { debug_printf("r300: Initial vertex program\n"); tgsi_dump(vs->state.tokens, 0); } /* Translate TGSI to our internal representation */ ttr.compiler = &compiler.Base; ttr.info = &vs->info; ttr.use_half_swizzles = FALSE; r300_tgsi_to_rc(&ttr, vs->state.tokens); compiler.RequiredOutputs = ~(~0 << (vs->info.num_outputs+1)); compiler.SetHwInputOutput = &set_vertex_inputs_outputs; /* Insert the WPOS output. */ r300_insert_wpos(&compiler, &vs->outputs); r300_shader_vap_output_fmt(vs); r300_stream_locations_notcl(&vs->outputs, vs->stream_loc_notcl); /* Invoke the compiler */ r3xx_compile_vertex_program(&compiler); if (compiler.Base.Error) { /* XXX We should fallback using Draw. */ fprintf(stderr, "r300 VP: Compiler error\n"); abort(); } /* And, finally... */ rc_destroy(&compiler.Base); vs->translated = TRUE; }
void r300_init_vs_outputs(struct r300_context *r300, struct r300_vertex_shader *vs) { tgsi_scan_shader(vs->state.tokens, &vs->info); r300_shader_read_vs_outputs(r300, &vs->info, &vs->outputs); }