Also, added draw_convert_wide_points/lines() so a driver can tell the draw module whether to convert wide points/lines into triangles, or just pass them through.tags/mesa_20090313
| @@ -71,7 +71,7 @@ struct draw_context *draw_create( void ) | |||
| */ | |||
| { | |||
| uint i; | |||
| char *tmp = MALLOC( Elements(draw->vcache.vertex) * MAX_VERTEX_SIZE ); | |||
| char *tmp = (char*) MALLOC( Elements(draw->vcache.vertex) * MAX_VERTEX_SIZE ); | |||
| for (i = 0; i < Elements(draw->vcache.vertex); i++) | |||
| draw->vcache.vertex[i] = (struct vertex_header *)(tmp + i * MAX_VERTEX_SIZE); | |||
| @@ -82,6 +82,9 @@ struct draw_context *draw_create( void ) | |||
| draw->attrib_front1 = 0; | |||
| draw->attrib_back1 = 0; | |||
| draw->convert_wide_points = TRUE; | |||
| draw->convert_wide_lines = TRUE; | |||
| draw->prim = ~0; /* != any of PIPE_PRIM_x */ | |||
| draw_vertex_cache_invalidate( draw ); | |||
| @@ -217,6 +220,26 @@ draw_set_mapped_constant_buffer(struct draw_context *draw, | |||
| } | |||
| /** | |||
| * Tells the draw module whether to convert wide points (size != 1) | |||
| * into triangles. | |||
| */ | |||
| void | |||
| draw_convert_wide_points(struct draw_context *draw, boolean enable) | |||
| { | |||
| draw->convert_wide_points = enable; | |||
| } | |||
| /** | |||
| * Tells the draw module whether to convert wide lines (width != 1) | |||
| * into triangles. | |||
| */ | |||
| void | |||
| draw_convert_wide_lines(struct draw_context *draw, boolean enable) | |||
| { | |||
| draw->convert_wide_lines = enable; | |||
| } | |||
| @@ -89,6 +89,10 @@ void draw_set_rasterizer_state( struct draw_context *draw, | |||
| void draw_set_rasterize_stage( struct draw_context *draw, | |||
| struct draw_stage *stage ); | |||
| void draw_convert_wide_points(struct draw_context *draw, boolean enable); | |||
| void draw_convert_wide_lines(struct draw_context *draw, boolean enable); | |||
| struct draw_vertex_shader * | |||
| draw_create_vertex_shader(struct draw_context *draw, | |||
| @@ -195,6 +195,9 @@ struct draw_context | |||
| uint attrib_front0, attrib_back0; | |||
| uint attrib_front1, attrib_back1; | |||
| boolean convert_wide_points; /**< convert wide points to tris? */ | |||
| boolean convert_wide_lines; /**< convert side lines to tris? */ | |||
| boolean drawing; /**< do we presently have something queued for drawing? */ | |||
| unsigned prim; /**< current prim type: PIPE_PRIM_x */ | |||
| unsigned reduced_prim; | |||
| @@ -51,8 +51,8 @@ static void validate_begin( struct draw_stage *stage ) | |||
| * shorter pipelines for lines & points. | |||
| */ | |||
| if (draw->rasterizer->line_width != 1.0 || | |||
| draw->rasterizer->point_size != 1.0 || | |||
| if ((draw->rasterizer->line_width != 1.0 && draw->convert_wide_lines) || | |||
| (draw->rasterizer->point_size != 1.0 && draw->convert_wide_points) || | |||
| draw->rasterizer->point_sprite) { | |||
| draw->pipeline.wide->next = next; | |||
| next = draw->pipeline.wide; | |||
| @@ -148,6 +148,10 @@ emit_vertex( struct vbuf_stage *vbuf, | |||
| *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); | |||
| count++; | |||
| break; | |||
| case FORMAT_1F_PSIZE: | |||
| *vbuf->vertex_ptr++ = fui(vbuf->stage.draw->rasterizer->point_size); | |||
| count++; | |||
| break; | |||
| case FORMAT_2F: | |||
| *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); | |||
| *vbuf->vertex_ptr++ = fui(vertex->data[j][1]); | |||
| @@ -353,7 +357,7 @@ vbuf_alloc_vertices( struct draw_stage *stage, | |||
| /* Allocate a new vertex buffer */ | |||
| vbuf->vertex_size = new_vertex_size; | |||
| vbuf->max_vertices = vbuf->render->max_vertex_buffer_bytes / vbuf->vertex_size; | |||
| vbuf->vertices = vbuf->render->allocate_vertices(vbuf->render, | |||
| vbuf->vertices = (uint *) vbuf->render->allocate_vertices(vbuf->render, | |||
| (ushort) vbuf->vertex_size, | |||
| (ushort) vbuf->max_vertices); | |||
| vbuf->vertex_ptr = vbuf->vertices; | |||
| @@ -388,6 +392,7 @@ vbuf_end( struct draw_stage *stage ) | |||
| static void | |||
| vbuf_reset_stipple_counter( struct draw_stage *stage ) | |||
| { | |||
| (void) stage; | |||
| } | |||
| @@ -421,8 +426,8 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw, | |||
| assert(render->max_indices < UNDEFINED_VERTEX_ID); | |||
| vbuf->max_indices = render->max_indices; | |||
| vbuf->indices | |||
| = align_malloc( vbuf->max_indices * sizeof(vbuf->indices[0]), 16 ); | |||
| vbuf->indices = (ushort *) | |||
| align_malloc( vbuf->max_indices * sizeof(vbuf->indices[0]), 16 ); | |||
| vbuf->vertices = NULL; | |||
| vbuf->vertex_ptr = vbuf->vertices; | |||
| @@ -65,6 +65,8 @@ draw_compute_vertex_size(struct vertex_info *vinfo) | |||
| break; | |||
| case FORMAT_4UB: | |||
| /* fall-through */ | |||
| case FORMAT_1F_PSIZE: | |||
| /* fall-through */ | |||
| case FORMAT_1F: | |||
| vinfo->size += 1; | |||
| break; | |||
| @@ -41,12 +41,13 @@ struct draw_context; | |||
| * Vertex attribute format | |||
| */ | |||
| enum attrib_format { | |||
| FORMAT_OMIT, | |||
| FORMAT_OMIT, /**< don't emit the attribute */ | |||
| FORMAT_1F, | |||
| FORMAT_1F_PSIZE, /**< insert constant point size */ | |||
| FORMAT_2F, | |||
| FORMAT_3F, | |||
| FORMAT_4F, | |||
| FORMAT_4UB | |||
| FORMAT_4UB /**< XXX may need variations for RGBA vs BGRA, etc */ | |||
| }; | |||