Go to the source code of this file.
Data Structures | |
struct | pt_fetch |
Functions | |
void | draw_pt_fetch_prepare (struct pt_fetch *fetch, unsigned vertex_size) |
void | draw_pt_fetch_run (struct pt_fetch *fetch, const unsigned *elts, unsigned count, char *verts) |
void | draw_pt_fetch_run_linear (struct pt_fetch *fetch, unsigned start, unsigned count, char *verts) |
struct pt_fetch * | draw_pt_fetch_create (struct draw_context *draw) |
void | draw_pt_fetch_destroy (struct pt_fetch *fetch) |
struct pt_fetch* draw_pt_fetch_create | ( | struct draw_context * | draw | ) | [read] |
Definition at line 205 of file draw_pt_fetch.c.
References pt_fetch::cache, CALLOC_STRUCT, pt_fetch::draw, FREE, and translate_cache_create().
00206 { 00207 struct pt_fetch *fetch = CALLOC_STRUCT(pt_fetch); 00208 if (!fetch) 00209 return NULL; 00210 00211 fetch->draw = draw; 00212 fetch->cache = translate_cache_create(); 00213 if (!fetch->cache) { 00214 FREE(fetch); 00215 return NULL; 00216 } 00217 00218 return fetch; 00219 }
void draw_pt_fetch_destroy | ( | struct pt_fetch * | fetch | ) |
Definition at line 221 of file draw_pt_fetch.c.
References pt_fetch::cache, FREE, and translate_cache_destroy().
00222 { 00223 if (fetch->cache) 00224 translate_cache_destroy(fetch->cache); 00225 00226 FREE(fetch); 00227 }
void draw_pt_fetch_prepare | ( | struct pt_fetch * | fetch, | |
unsigned | vertex_size | |||
) |
Definition at line 58 of file draw_pt_fetch.c.
References assert, pt_fetch::cache, pt_fetch::draw, draw, translate_key::element, pipe_rasterizer_state::fill_ccw, pipe_rasterizer_state::fill_cw, translate_element::input_buffer, translate_element::input_format, translate_element::input_offset, translate::key, pt_fetch::need_edgeflags, translate_key::nr_elements, draw_context::nr_vertex_buffers, draw_context::nr_vertex_elements, translate_element::output_format, translate_element::output_offset, translate_key::output_stride, PIPE_FORMAT_R32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT, PIPE_POLYGON_MODE_FILL, draw_context::pt, draw_context::rasterizer, translate::set_buffer, pipe_vertex_element::src_format, pipe_vertex_element::src_offset, pt_fetch::translate, translate_cache_find(), translate_key_compare(), translate_key_sanitize(), UNDEFINED_VERTEX_ID, draw_context::user, pipe_vertex_element::vertex_buffer_index, draw_context::vertex_element, and pt_fetch::vertex_size.
00060 { 00061 struct draw_context *draw = fetch->draw; 00062 unsigned i, nr = 0; 00063 unsigned dst_offset = 0; 00064 struct translate_key key; 00065 00066 fetch->vertex_size = vertex_size; 00067 00068 /* Always emit/leave space for a vertex header. 00069 * 00070 * It's worth considering whether the vertex headers should contain 00071 * a pointer to the 'data', rather than having it inline. 00072 * Something to look at after we've fully switched over to the pt 00073 * paths. 00074 */ 00075 { 00076 /* Need to set header->vertex_id = 0xffff somehow. 00077 */ 00078 key.element[nr].input_format = PIPE_FORMAT_R32_FLOAT; 00079 key.element[nr].input_buffer = draw->pt.nr_vertex_buffers; 00080 key.element[nr].input_offset = 0; 00081 key.element[nr].output_format = PIPE_FORMAT_R32_FLOAT; 00082 key.element[nr].output_offset = dst_offset; 00083 dst_offset += 1 * sizeof(float); 00084 nr++; 00085 00086 00087 /* Just leave the clip[] array untouched. 00088 */ 00089 dst_offset += 4 * sizeof(float); 00090 } 00091 00092 00093 for (i = 0; i < draw->pt.nr_vertex_elements; i++) { 00094 key.element[nr].input_format = draw->pt.vertex_element[i].src_format; 00095 key.element[nr].input_buffer = draw->pt.vertex_element[i].vertex_buffer_index; 00096 key.element[nr].input_offset = draw->pt.vertex_element[i].src_offset; 00097 key.element[nr].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT; 00098 key.element[nr].output_offset = dst_offset; 00099 00100 dst_offset += 4 * sizeof(float); 00101 nr++; 00102 } 00103 00104 assert(dst_offset <= vertex_size); 00105 00106 key.nr_elements = nr; 00107 key.output_stride = vertex_size; 00108 00109 00110 if (!fetch->translate || 00111 translate_key_compare(&fetch->translate->key, &key) != 0) 00112 { 00113 translate_key_sanitize(&key); 00114 fetch->translate = translate_cache_find(fetch->cache, &key); 00115 00116 { 00117 static struct vertex_header vh = { 0, 1, 0, UNDEFINED_VERTEX_ID, { .0f, .0f, .0f, .0f } }; 00118 fetch->translate->set_buffer(fetch->translate, 00119 draw->pt.nr_vertex_buffers, 00120 &vh, 00121 0); 00122 } 00123 } 00124 00125 fetch->need_edgeflags = ((draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL || 00126 draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) && 00127 draw->pt.user.edgeflag); 00128 }
void draw_pt_fetch_run | ( | struct pt_fetch * | fetch, | |
const unsigned * | elts, | |||
unsigned | count, | |||
char * | verts | |||
) |
Definition at line 133 of file draw_pt_fetch.c.
References pipe_vertex_buffer::buffer_offset, pt_fetch::draw, draw, draw_pt_get_edgeflag(), vertex_header::edgeflag, pt_fetch::need_edgeflags, draw_context::nr_vertex_buffers, pipe_vertex_buffer::pitch, draw_context::pt, translate::set_buffer, pt_fetch::translate, draw_context::user, draw_context::vertex_buffer, and pt_fetch::vertex_size.
00137 { 00138 struct draw_context *draw = fetch->draw; 00139 struct translate *translate = fetch->translate; 00140 unsigned i; 00141 00142 for (i = 0; i < draw->pt.nr_vertex_buffers; i++) { 00143 translate->set_buffer(translate, 00144 i, 00145 ((char *)draw->pt.user.vbuffer[i] + 00146 draw->pt.vertex_buffer[i].buffer_offset), 00147 draw->pt.vertex_buffer[i].pitch ); 00148 } 00149 00150 translate->run_elts( translate, 00151 elts, 00152 count, 00153 verts ); 00154 00155 /* Edgeflags are hard to fit into a translate program, populate 00156 * them separately if required. In the setup above they are 00157 * defaulted to one, so only need this if there is reason to change 00158 * that default: 00159 */ 00160 if (fetch->need_edgeflags) { 00161 for (i = 0; i < count; i++) { 00162 struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size); 00163 vh->edgeflag = draw_pt_get_edgeflag( draw, elts[i] ); 00164 } 00165 } 00166 }
void draw_pt_fetch_run_linear | ( | struct pt_fetch * | fetch, | |
unsigned | start, | |||
unsigned | count, | |||
char * | verts | |||
) |
Definition at line 169 of file draw_pt_fetch.c.
References pipe_vertex_buffer::buffer_offset, pt_fetch::draw, draw, draw_pt_get_edgeflag(), vertex_header::edgeflag, pt_fetch::need_edgeflags, draw_context::nr_vertex_buffers, pipe_vertex_buffer::pitch, draw_context::pt, translate::set_buffer, pt_fetch::translate, draw_context::user, draw_context::vertex_buffer, and pt_fetch::vertex_size.
00173 { 00174 struct draw_context *draw = fetch->draw; 00175 struct translate *translate = fetch->translate; 00176 unsigned i; 00177 00178 for (i = 0; i < draw->pt.nr_vertex_buffers; i++) { 00179 translate->set_buffer(translate, 00180 i, 00181 ((char *)draw->pt.user.vbuffer[i] + 00182 draw->pt.vertex_buffer[i].buffer_offset), 00183 draw->pt.vertex_buffer[i].pitch ); 00184 } 00185 00186 translate->run( translate, 00187 start, 00188 count, 00189 verts ); 00190 00191 /* Edgeflags are hard to fit into a translate program, populate 00192 * them separately if required. In the setup above they are 00193 * defaulted to one, so only need this if there is reason to change 00194 * that default: 00195 */ 00196 if (fetch->need_edgeflags) { 00197 for (i = 0; i < count; i++) { 00198 struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size); 00199 vh->edgeflag = draw_pt_get_edgeflag( draw, start + i ); 00200 } 00201 } 00202 }