summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/draw/draw_context.h5
-rw-r--r--src/mesa/pipe/draw/draw_vb.c61
-rw-r--r--src/mesa/pipe/p_context.h5
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c20
4 files changed, 89 insertions, 2 deletions
diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h
index c298d4f46d..be0a18d6d7 100644
--- a/src/mesa/pipe/draw/draw_context.h
+++ b/src/mesa/pipe/draw/draw_context.h
@@ -70,5 +70,10 @@ void draw_set_vertex_attributes( struct draw_context *draw,
void draw_vb(struct draw_context *draw,
struct vertex_buffer *VB );
+void draw_vertices(struct draw_context *draw,
+ GLuint mode,
+ GLuint numVertex, const GLfloat *verts,
+ GLuint numAttribs, const GLuint attribs[]);
+
#endif /* DRAW_CONTEXT_H */
diff --git a/src/mesa/pipe/draw/draw_vb.c b/src/mesa/pipe/draw/draw_vb.c
index ac126c5baa..f9c10e5f97 100644
--- a/src/mesa/pipe/draw/draw_vb.c
+++ b/src/mesa/pipe/draw/draw_vb.c
@@ -57,7 +57,7 @@ static void draw_allocate_vertices( struct draw_context *draw,
GLuint nr_vertices )
{
draw->nr_vertices = nr_vertices;
- draw->verts = MALLOC( nr_vertices * draw->vertex_size );
+ draw->verts = (GLubyte *) malloc( nr_vertices * draw->vertex_size );
draw->pipeline.first->begin( draw->pipeline.first );
}
@@ -453,7 +453,7 @@ static void draw_release_vertices( struct draw_context *draw )
{
draw->pipeline.first->end( draw->pipeline.first );
- FREE(draw->verts);
+ free(draw->verts);
draw->verts = NULL;
}
@@ -647,6 +647,63 @@ void draw_vb(struct draw_context *draw,
/**
+ * XXX Temporary mechanism to draw simple vertex arrays.
+ * All attribs are GLfloat[4]. Arrays are interleaved, in GL-speak.
+ */
+void
+draw_vertices(struct draw_context *draw,
+ GLuint mode,
+ GLuint numVerts, const GLfloat *vertices,
+ GLuint numAttrs, const GLuint attribs[])
+{
+ /*GLuint first, incr;*/
+ GLuint i, j;
+
+ assert(mode <= GL_POLYGON);
+
+ draw->vertex_size
+ = sizeof(struct vertex_header) + numAttrs * 4 * sizeof(GLfloat);
+
+ /*draw_prim_info(mode, &first, &incr);*/
+ draw_allocate_vertices( draw, numVerts );
+ if (draw->prim != mode)
+ draw_set_prim( draw, mode );
+
+ /* setup attr info */
+ draw->nr_attrs = numAttrs + 2;
+ draw->attrs[0].attrib = VF_ATTRIB_VERTEX_HEADER;
+ draw->attrs[0].format = EMIT_1F;
+ draw->attrs[1].attrib = VF_ATTRIB_CLIP_POS;
+ draw->attrs[1].format = EMIT_4F;
+ for (j = 0; j < numAttrs; j++) {
+ draw->vf_attr_to_slot[attribs[j]] = 2+j;
+ draw->attrs[2+j].attrib = attribs[j];
+ draw->attrs[2+j].format = EMIT_4F;
+ }
+
+ /* build vertices */
+ for (i = 0; i < numVerts; i++) {
+ struct vertex_header *v
+ = (struct vertex_header *) (draw->verts + i * draw->vertex_size);
+ v->clipmask = 0x0;
+ v->edgeflag = 0;
+ for (j = 0; j < numAttrs; j++) {
+ COPY_4FV(v->data[j], vertices + (i * numAttrs + j) * 4);
+ }
+ }
+
+ /* draw */
+ draw_prim(draw, 0, numVerts);
+
+ /* clean up */
+ draw_release_vertices( draw );
+ draw->verts = NULL;
+ draw->in_vb = 0;
+}
+
+
+
+/**
* Accumulate another attribute's info.
* Note the "- 2" factor here. We need this because the vertex->data[]
* array does not include the first two attributes we emit (VERTEX_HEADER
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 2ce2781771..0972fd58b5 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -55,6 +55,11 @@ struct pipe_context {
void (*draw_vb)( struct pipe_context *pipe,
struct vertex_buffer *VB );
+ void (*draw_vertices)( struct pipe_context *pipe,
+ GLuint mode,
+ GLuint numVertex, const GLfloat *verts,
+ GLuint numAttribs, const GLuint attribs[]);
+
/** Clear framebuffer */
void (*clear)(struct pipe_context *pipe, GLboolean color, GLboolean depth,
GLboolean stencil);
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 434e18308a..9fba9605e8 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -102,6 +102,25 @@ static void softpipe_draw_vb( struct pipe_context *pipe,
}
+static void
+softpipe_draw_vertices(struct pipe_context *pipe,
+ GLuint mode,
+ GLuint numVertex, const GLfloat *verts,
+ GLuint numAttribs, const GLuint attribs[])
+{
+ struct softpipe_context *softpipe = softpipe_context( pipe );
+
+ if (softpipe->dirty)
+ softpipe_update_derived( softpipe );
+
+ /* XXX move mapping/unmapping to higher/coarser level? */
+ map_surfaces(softpipe);
+ draw_vertices(softpipe->draw, mode, numVertex, verts, numAttribs, attribs);
+ unmap_surfaces(softpipe);
+}
+
+
+
static void softpipe_reset_occlusion_counter(struct pipe_context *pipe)
{
struct softpipe_context *softpipe = softpipe_context( pipe );
@@ -137,6 +156,7 @@ struct pipe_context *softpipe_create( void )
softpipe->pipe.set_texture_state = softpipe_set_texture_state;
softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
softpipe->pipe.draw_vb = softpipe_draw_vb;
+ softpipe->pipe.draw_vertices = softpipe_draw_vertices;
softpipe->pipe.clear = softpipe_clear;
softpipe->pipe.reset_occlusion_counter = softpipe_reset_occlusion_counter;
softpipe->pipe.get_occlusion_counter = softpipe_get_occlusion_counter;