Go to the source code of this file.
Functions | |
struct draw_context * | draw_create (void) |
void | draw_destroy (struct draw_context *draw) |
void | draw_flush (struct draw_context *draw) |
void | draw_set_mrd (struct draw_context *draw, double mrd) |
Specify the Minimum Resolvable Depth factor for polygon offset. | |
void | draw_set_rasterizer_state (struct draw_context *draw, const struct pipe_rasterizer_state *raster) |
Register new primitive rasterization/rendering state. | |
void | draw_set_driver_clipping (struct draw_context *draw, boolean bypass_clipping) |
void | draw_set_rasterize_stage (struct draw_context *draw, struct draw_stage *stage) |
Plug in the primitive rendering/rasterization stage (which is the last stage in the drawing pipeline). | |
void | draw_set_clip_state (struct draw_context *draw, const struct pipe_clip_state *clip) |
Set the draw module's clipping state. | |
void | draw_set_viewport_state (struct draw_context *draw, const struct pipe_viewport_state *viewport) |
Set the draw module's viewport state. | |
void | draw_set_vertex_buffers (struct draw_context *draw, unsigned count, const struct pipe_vertex_buffer *buffers) |
void | draw_set_vertex_elements (struct draw_context *draw, unsigned count, const struct pipe_vertex_element *elements) |
void | draw_set_mapped_vertex_buffer (struct draw_context *draw, unsigned attr, const void *buffer) |
Tell drawing context where to find mapped vertex buffers. | |
void | draw_set_mapped_constant_buffer (struct draw_context *draw, const void *buffer, unsigned size) |
void | draw_wide_point_threshold (struct draw_context *draw, float threshold) |
Tells the draw module to draw points with triangles if their size is greater than this threshold. | |
void | draw_wide_line_threshold (struct draw_context *draw, float threshold) |
Tells the draw module to draw lines with triangles if their width is greater than this threshold. | |
void | draw_enable_line_stipple (struct draw_context *draw, boolean enable) |
Tells the draw module whether or not to implement line stipple. | |
void | draw_enable_point_sprites (struct draw_context *draw, boolean enable) |
Tells draw module whether to convert points to quads for sprite mode. | |
void | draw_set_force_passthrough (struct draw_context *draw, boolean enable) |
int | draw_find_vs_output (const struct draw_context *draw, uint semantic_name, uint semantic_index) |
Ask the draw module for the location/slot of the given vertex attribute in a post-transformed vertex. | |
uint | draw_num_vs_outputs (const struct draw_context *draw) |
Return number of vertex shader outputs. | |
void | draw_set_render (struct draw_context *draw, struct vbuf_render *render) |
void | draw_set_edgeflags (struct draw_context *draw, const unsigned *edgeflag) |
void | draw_set_mapped_element_buffer_range (struct draw_context *draw, unsigned eltSize, unsigned min_index, unsigned max_index, const void *elements) |
Tell the drawing context about the index/element buffer to use (ala glDrawElements) If no element buffer is to be used (i.e. | |
void | draw_set_mapped_element_buffer (struct draw_context *draw, unsigned eltSize, const void *elements) |
void | draw_do_flush (struct draw_context *draw, unsigned flags) |
struct draw_context* draw_create | ( | void | ) | [read] |
Definition at line 43 of file draw_context.c.
References ASSIGN_4V, CALLOC_STRUCT, draw, draw_destroy(), draw_pipeline_init(), draw_pt_init(), draw_vs_init(), draw_context::nr_planes, draw_context::plane, and draw_context::reduced_prim.
00044 { 00045 struct draw_context *draw = CALLOC_STRUCT( draw_context ); 00046 if (draw == NULL) 00047 goto fail; 00048 00049 ASSIGN_4V( draw->plane[0], -1, 0, 0, 1 ); 00050 ASSIGN_4V( draw->plane[1], 1, 0, 0, 1 ); 00051 ASSIGN_4V( draw->plane[2], 0, -1, 0, 1 ); 00052 ASSIGN_4V( draw->plane[3], 0, 1, 0, 1 ); 00053 ASSIGN_4V( draw->plane[4], 0, 0, 1, 1 ); /* yes these are correct */ 00054 ASSIGN_4V( draw->plane[5], 0, 0, -1, 1 ); /* mesa's a bit wonky */ 00055 draw->nr_planes = 6; 00056 00057 00058 draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */ 00059 00060 00061 if (!draw_pipeline_init( draw )) 00062 goto fail; 00063 00064 if (!draw_pt_init( draw )) 00065 goto fail; 00066 00067 if (!draw_vs_init( draw )) 00068 goto fail; 00069 00070 return draw; 00071 00072 fail: 00073 draw_destroy( draw ); 00074 return NULL; 00075 }
void draw_destroy | ( | struct draw_context * | draw | ) |
Definition at line 78 of file draw_context.c.
References draw_pipeline_destroy(), draw_pt_destroy(), draw_vs_destroy(), and FREE.
00079 { 00080 if (!draw) 00081 return; 00082 00083 00084 00085 /* Not so fast -- we're just borrowing this at the moment. 00086 * 00087 if (draw->render) 00088 draw->render->destroy( draw->render ); 00089 */ 00090 00091 draw_pipeline_destroy( draw ); 00092 draw_pt_destroy( draw ); 00093 draw_vs_destroy( draw ); 00094 00095 FREE( draw ); 00096 }
void draw_do_flush | ( | struct draw_context * | draw, | |
unsigned | flags | |||
) |
Definition at line 400 of file draw_context.c.
References assert, draw_pipeline_flush(), FALSE, draw_context::flushing, draw_context::reduced_prim, draw_context::suspend_flushing, and TRUE.
00401 { 00402 if (!draw->suspend_flushing) 00403 { 00404 assert(!draw->flushing); /* catch inadvertant recursion */ 00405 00406 draw->flushing = TRUE; 00407 00408 draw_pipeline_flush( draw, flags ); 00409 00410 draw->reduced_prim = ~0; /* is reduced_prim needed any more? */ 00411 00412 draw->flushing = FALSE; 00413 } 00414 }
void draw_enable_line_stipple | ( | struct draw_context * | draw, | |
boolean | enable | |||
) |
Tells the draw module whether or not to implement line stipple.
Definition at line 269 of file draw_context.c.
References draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, draw_context::line_stipple, and draw_context::pipeline.
00270 { 00271 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00272 draw->pipeline.line_stipple = enable; 00273 }
void draw_enable_point_sprites | ( | struct draw_context * | draw, | |
boolean | enable | |||
) |
Tells draw module whether to convert points to quads for sprite mode.
Definition at line 280 of file draw_context.c.
References draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, draw_context::pipeline, and draw_context::point_sprite.
00281 { 00282 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00283 draw->pipeline.point_sprite = enable; 00284 }
int draw_find_vs_output | ( | const struct draw_context * | draw, | |
uint | semantic_name, | |||
uint | semantic_index | |||
) |
Ask the draw module for the location/slot of the given vertex attribute in a post-transformed vertex.
With this function, drivers that use the draw module should have no reason to track the current vertex shader.
Note that the draw module may sometimes generate vertices with extra attributes (such as texcoords for AA lines). The driver can call this function to find those attributes.
Zero is returned if the attribute is not found since this is a don't care / undefined situtation. Returning -1 would be a bit more work for the drivers.
Definition at line 311 of file draw_context.c.
References draw_context::extra_vp_outputs, draw_vertex_shader::info, tgsi_shader_info::num_outputs, tgsi_shader_info::output_semantic_index, tgsi_shader_info::output_semantic_name, draw_context::semantic_index, draw_context::semantic_name, draw_context::slot, draw_context::vertex_shader, and draw_context::vs.
00313 { 00314 const struct draw_vertex_shader *vs = draw->vs.vertex_shader; 00315 uint i; 00316 for (i = 0; i < vs->info.num_outputs; i++) { 00317 if (vs->info.output_semantic_name[i] == semantic_name && 00318 vs->info.output_semantic_index[i] == semantic_index) 00319 return i; 00320 } 00321 00322 /* XXX there may be more than one extra vertex attrib. 00323 * For example, simulated gl_FragCoord and gl_PointCoord. 00324 */ 00325 if (draw->extra_vp_outputs.semantic_name == semantic_name && 00326 draw->extra_vp_outputs.semantic_index == semantic_index) { 00327 return draw->extra_vp_outputs.slot; 00328 } 00329 return 0; 00330 }
void draw_flush | ( | struct draw_context * | draw | ) |
Definition at line 100 of file draw_context.c.
References draw_do_flush(), and DRAW_FLUSH_BACKEND.
00101 { 00102 draw_do_flush( draw, DRAW_FLUSH_BACKEND ); 00103 }
uint draw_num_vs_outputs | ( | const struct draw_context * | draw | ) |
Return number of vertex shader outputs.
Definition at line 337 of file draw_context.c.
References draw_context::extra_vp_outputs, draw_vertex_shader::info, tgsi_shader_info::num_outputs, draw_context::slot, draw_context::vertex_shader, and draw_context::vs.
00338 { 00339 uint count = draw->vs.vertex_shader->info.num_outputs; 00340 if (draw->extra_vp_outputs.slot > 0) 00341 count++; 00342 return count; 00343 }
void draw_set_clip_state | ( | struct draw_context * | draw, | |
const struct pipe_clip_state * | clip | |||
) |
Set the draw module's clipping state.
Definition at line 163 of file draw_context.c.
References assert, draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, pipe_clip_state::nr, draw_context::nr_planes, PIPE_MAX_CLIP_PLANES, draw_context::plane, and pipe_clip_state::ucp.
00165 { 00166 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00167 00168 assert(clip->nr <= PIPE_MAX_CLIP_PLANES); 00169 memcpy(&draw->plane[6], clip->ucp, clip->nr * sizeof(clip->ucp[0])); 00170 draw->nr_planes = 6 + clip->nr; 00171 }
void draw_set_driver_clipping | ( | struct draw_context * | draw, | |
boolean | bypass_clipping | |||
) |
Definition at line 135 of file draw_context.c.
References pipe_rasterizer_state::bypass_clipping, draw_context::bypass_clipping, draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, draw_context::driver, and draw_context::rasterizer.
00137 { 00138 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00139 00140 draw->driver.bypass_clipping = bypass_clipping; 00141 draw->bypass_clipping = (draw->rasterizer->bypass_clipping || 00142 draw->driver.bypass_clipping); 00143 }
void draw_set_edgeflags | ( | struct draw_context * | draw, | |
const unsigned * | edgeflag | |||
) |
void draw_set_force_passthrough | ( | struct draw_context * | draw, | |
boolean | enable | |||
) |
Definition at line 288 of file draw_context.c.
References draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, and draw_context::force_passthrough.
00289 { 00290 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00291 draw->force_passthrough = enable; 00292 }
void draw_set_mapped_constant_buffer | ( | struct draw_context * | draw, | |
const void * | buffer, | |||
unsigned | size | |||
) |
Definition at line 232 of file draw_context.c.
References draw_vs_set_constants(), draw_context::pt, and draw_context::user.
00235 { 00236 draw->pt.user.constants = buffer; 00237 draw_vs_set_constants( draw, (const float (*)[4])buffer, size ); 00238 }
void draw_set_mapped_element_buffer | ( | struct draw_context * | draw, | |
unsigned | eltSize, | |||
const void * | elements | |||
) |
Definition at line 387 of file draw_context.c.
References draw_context::pt, and draw_context::user.
00390 { 00391 draw->pt.user.elts = elements; 00392 draw->pt.user.eltSize = eltSize; 00393 draw->pt.user.min_index = 0; 00394 draw->pt.user.max_index = 0xffffffff; 00395 }
void draw_set_mapped_element_buffer_range | ( | struct draw_context * | draw, | |
unsigned | eltSize, | |||
unsigned | min_index, | |||
unsigned | max_index, | |||
const void * | elements | |||
) |
Tell the drawing context about the index/element buffer to use (ala glDrawElements) If no element buffer is to be used (i.e.
glDrawArrays) then this should be called with eltSize=0 and elements=NULL.
draw | the drawing context | |
eltSize | size of each element (1, 2 or 4 bytes) | |
elements | the element buffer ptr |
Definition at line 373 of file draw_context.c.
References draw_context::pt, and draw_context::user.
00378 { 00379 draw->pt.user.elts = elements; 00380 draw->pt.user.eltSize = eltSize; 00381 draw->pt.user.min_index = min_index; 00382 draw->pt.user.max_index = max_index; 00383 }
void draw_set_mapped_vertex_buffer | ( | struct draw_context * | draw, | |
unsigned | attr, | |||
const void * | buffer | |||
) |
Tell drawing context where to find mapped vertex buffers.
Definition at line 224 of file draw_context.c.
References draw_context::pt, and draw_context::user.
void draw_set_mrd | ( | struct draw_context * | draw, | |
double | mrd | |||
) |
Specify the Minimum Resolvable Depth factor for polygon offset.
This factor potentially depends on the number of Z buffer bits, the rasterization algorithm and the arithmetic performed on Z values between vertex shading and rasterization. It will vary from one driver to another.
Definition at line 113 of file draw_context.c.
References draw_context::mrd.
00114 { 00115 draw->mrd = mrd; 00116 }
void draw_set_rasterize_stage | ( | struct draw_context * | draw, | |
struct draw_stage * | stage | |||
) |
Plug in the primitive rendering/rasterization stage (which is the last stage in the drawing pipeline).
This is provided by the device driver.
Definition at line 151 of file draw_context.c.
References draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, draw_context::pipeline, and draw_context::rasterize.
00153 { 00154 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00155 00156 draw->pipeline.rasterize = stage; 00157 }
void draw_set_rasterizer_state | ( | struct draw_context * | draw, | |
const struct pipe_rasterizer_state * | raster | |||
) |
Register new primitive rasterization/rendering state.
This causes the drawing pipeline to be rebuilt.
Definition at line 123 of file draw_context.c.
References pipe_rasterizer_state::bypass_clipping, draw_context::bypass_clipping, draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, draw_context::driver, and draw_context::rasterizer.
00125 { 00126 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00127 00128 draw->rasterizer = raster; 00129 draw->bypass_clipping = 00130 ((draw->rasterizer && draw->rasterizer->bypass_clipping) || 00131 draw->driver.bypass_clipping); 00132 }
void draw_set_render | ( | struct draw_context * | draw, | |
struct vbuf_render * | render | |||
) |
Definition at line 347 of file draw_context.c.
References draw_context::render.
00349 { 00350 draw->render = render; 00351 }
void draw_set_vertex_buffers | ( | struct draw_context * | draw, | |
unsigned | count, | |||
const struct pipe_vertex_buffer * | buffers | |||
) |
Definition at line 197 of file draw_context.c.
References assert, draw_context::nr_vertex_buffers, PIPE_MAX_ATTRIBS, draw_context::pt, and draw_context::vertex_buffer.
00200 { 00201 assert(count <= PIPE_MAX_ATTRIBS); 00202 00203 memcpy(draw->pt.vertex_buffer, buffers, count * sizeof(buffers[0])); 00204 draw->pt.nr_vertex_buffers = count; 00205 }
void draw_set_vertex_elements | ( | struct draw_context * | draw, | |
unsigned | count, | |||
const struct pipe_vertex_element * | elements | |||
) |
Definition at line 209 of file draw_context.c.
References assert, draw_context::nr_vertex_elements, PIPE_MAX_ATTRIBS, draw_context::pt, and draw_context::vertex_element.
00212 { 00213 assert(count <= PIPE_MAX_ATTRIBS); 00214 00215 memcpy(draw->pt.vertex_element, elements, count * sizeof(elements[0])); 00216 draw->pt.nr_vertex_elements = count; 00217 }
void draw_set_viewport_state | ( | struct draw_context * | draw, | |
const struct pipe_viewport_state * | viewport | |||
) |
Set the draw module's viewport state.
Definition at line 177 of file draw_context.c.
References draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, draw_vs_set_viewport(), draw_context::identity_viewport, pipe_viewport_state::scale, pipe_viewport_state::translate, and draw_context::viewport.
00179 { 00180 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00181 draw->viewport = *viewport; /* struct copy */ 00182 draw->identity_viewport = (viewport->scale[0] == 1.0f && 00183 viewport->scale[1] == 1.0f && 00184 viewport->scale[2] == 1.0f && 00185 viewport->scale[3] == 1.0f && 00186 viewport->translate[0] == 0.0f && 00187 viewport->translate[1] == 0.0f && 00188 viewport->translate[2] == 0.0f && 00189 viewport->translate[3] == 0.0f); 00190 00191 draw_vs_set_viewport( draw, viewport ); 00192 }
void draw_wide_line_threshold | ( | struct draw_context * | draw, | |
float | threshold | |||
) |
Tells the draw module to draw lines with triangles if their width is greater than this threshold.
Definition at line 258 of file draw_context.c.
References draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, draw_context::pipeline, and draw_context::wide_line_threshold.
00259 { 00260 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00261 draw->pipeline.wide_line_threshold = threshold; 00262 }
void draw_wide_point_threshold | ( | struct draw_context * | draw, | |
float | threshold | |||
) |
Tells the draw module to draw points with triangles if their size is greater than this threshold.
Definition at line 246 of file draw_context.c.
References draw_do_flush(), DRAW_FLUSH_STATE_CHANGE, draw_context::pipeline, and draw_context::wide_point_threshold.
00247 { 00248 draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); 00249 draw->pipeline.wide_point_threshold = threshold; 00250 }