00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "brw_context.h"
00034 #include "brw_vs.h"
00035 #include "brw_util.h"
00036 #include "brw_state.h"
00037
00038
00039 static void do_vs_prog( struct brw_context *brw,
00040 const struct brw_vertex_program *vp,
00041 struct brw_vs_prog_key *key )
00042 {
00043 unsigned program_size;
00044 const unsigned *program;
00045 struct brw_vs_compile c;
00046
00047 memset(&c, 0, sizeof(c));
00048 memcpy(&c.key, key, sizeof(*key));
00049
00050 brw_init_compile(&c.func);
00051 c.vp = vp;
00052
00053 c.prog_data.outputs_written = vp->info.num_outputs;
00054 c.prog_data.inputs_read = vp->info.num_inputs;
00055
00056 #if 0
00057 if (c.key.copy_edgeflag) {
00058 c.prog_data.outputs_written |= 1<<VERT_RESULT_EDGE;
00059 c.prog_data.inputs_read |= 1<<VERT_ATTRIB_EDGEFLAG;
00060 }
00061 #endif
00062
00063
00064
00065 brw_vs_emit(&c);
00066
00067
00068
00069 program = brw_get_program(&c.func, &program_size);
00070
00071
00072
00073 brw->vs.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_VS_PROG],
00074 &c.key,
00075 sizeof(c.key),
00076 program,
00077 program_size,
00078 &c.prog_data,
00079 &brw->vs.prog_data);
00080 }
00081
00082
00083 static void brw_upload_vs_prog( struct brw_context *brw )
00084 {
00085 struct brw_vs_prog_key key;
00086 const struct brw_vertex_program *vp = brw->attribs.VertexProgram;
00087
00088 assert(vp);
00089
00090 memset(&key, 0, sizeof(key));
00091
00092
00093
00094
00095 key.program_string_id = vp->id;
00096 key.nr_userclip = brw->attribs.Clip.nr;
00097 key.copy_edgeflag = (brw->attribs.Raster->fill_cw != PIPE_POLYGON_MODE_FILL ||
00098 brw->attribs.Raster->fill_ccw != PIPE_POLYGON_MODE_FILL);
00099
00100
00101
00102 if (brw_search_cache(&brw->cache[BRW_VS_PROG],
00103 &key, sizeof(key),
00104 &brw->vs.prog_data,
00105 &brw->vs.prog_gs_offset))
00106 return;
00107
00108 do_vs_prog(brw, vp, &key);
00109 }
00110
00111
00112
00113
00114 const struct brw_tracked_state brw_vs_prog = {
00115 .dirty = {
00116 .brw = BRW_NEW_VS,
00117 .cache = 0
00118 },
00119 .update = brw_upload_vs_prog
00120 };