summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/draw
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-07-09 16:14:26 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-07-09 16:14:26 -0600
commit279ffe3f163fd6a5e7bfa108db14c81acbb06ece (patch)
tree109bb794f7d057a51d748350ca616e920f2a67da /src/mesa/pipe/draw
parent9fbdf500788e78d63247a17226a75f7a079ae315 (diff)
New 'draw' module for primitive drawing (clipping, culling, etc).
Diffstat (limited to 'src/mesa/pipe/draw')
-rw-r--r--src/mesa/pipe/draw/draw_clip.c35
-rw-r--r--src/mesa/pipe/draw/draw_context.h32
-rw-r--r--src/mesa/pipe/draw/draw_cull.c21
-rw-r--r--src/mesa/pipe/draw/draw_flatshade.c31
-rw-r--r--src/mesa/pipe/draw/draw_offset.c24
-rw-r--r--src/mesa/pipe/draw/draw_private.h138
-rw-r--r--src/mesa/pipe/draw/draw_twoside.c24
-rw-r--r--src/mesa/pipe/draw/draw_unfilled.c17
-rw-r--r--src/mesa/pipe/draw/draw_vb.c92
9 files changed, 261 insertions, 153 deletions
diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c
index 304c43c3f4..10a6c1b823 100644
--- a/src/mesa/pipe/draw/draw_clip.c
+++ b/src/mesa/pipe/draw/draw_clip.c
@@ -28,18 +28,18 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "imports.h"
-#include "macros.h"
+#include "main/macros.h"
+#include "draw_private.h"
-#include "sp_context.h"
-#include "sp_prim.h"
struct clipper {
- struct prim_stage stage;
+ struct prim_stage stage; /**< base class */
GLuint active_user_planes;
+ GLfloat (*plane)[4];
};
+
/* This is a bit confusing:
*/
static INLINE struct clipper *clipper_stage( struct prim_stage *stage )
@@ -75,7 +75,7 @@ static void interp( struct clipper *clip,
const struct vertex_header *out,
const struct vertex_header *in )
{
- const GLuint nr_attrs = clip->stage.softpipe->nr_attrs;
+ const GLuint nr_attrs = clip->stage.draw->nr_attrs;
GLuint j;
/* Vertex header.
@@ -96,8 +96,8 @@ static void interp( struct clipper *clip,
*/
{
const GLfloat *pos = dst->clip;
- const GLfloat *scale = clip->stage.softpipe->viewport.scale;
- const GLfloat *trans = clip->stage.softpipe->viewport.translate;
+ const GLfloat *scale = clip->stage.draw->viewport.scale;
+ const GLfloat *trans = clip->stage.draw->viewport.translate;
GLfloat oow;
oow = 1.0 / pos[3];
@@ -225,7 +225,7 @@ do_clip_tri( struct prim_stage *stage,
while (clipmask && n >= 3) {
GLuint plane_idx = ffs(clipmask)-1;
- const GLfloat *plane = clipper->stage.softpipe->plane[plane_idx];
+ const GLfloat *plane = clipper->plane[plane_idx];
struct vertex_header *vert_prev = inlist[0];
GLfloat dp_prev = dot4( vert_prev->clip, plane );
GLuint outcount = 0;
@@ -314,7 +314,7 @@ do_clip_line( struct prim_stage *stage,
while (clipmask) {
GLuint plane_idx = ffs(clipmask)-1;
- const GLfloat *plane = clipper->stage.softpipe->plane[plane_idx];
+ const GLfloat *plane = clipper->plane[plane_idx];
clipmask &= ~(1<<plane_idx);
@@ -353,7 +353,7 @@ do_clip_line( struct prim_stage *stage,
static void clip_begin( struct prim_stage *stage )
{
struct clipper *clipper = clipper_stage(stage);
- GLuint nr = stage->softpipe->nr_planes;
+ GLuint nr = stage->draw->nr_planes;
/* Hacky bitmask to use when we hit CLIP_USER_BIT:
*/
@@ -379,6 +379,7 @@ clip_line( struct prim_stage *stage,
header->v[1]->clipmask);
if (clipmask == 0) {
+ /* no clipping needed */
stage->next->line( stage->next, header );
}
else if ((header->v[0]->clipmask &
@@ -397,6 +398,7 @@ clip_tri( struct prim_stage *stage,
header->v[2]->clipmask);
if (clipmask == 0) {
+ /* no clipping needed */
stage->next->tri( stage->next, header );
}
else if ((header->v[0]->clipmask &
@@ -406,24 +408,31 @@ clip_tri( struct prim_stage *stage,
}
}
+
static void clip_end( struct prim_stage *stage )
{
stage->next->end( stage->next );
}
-struct prim_stage *prim_clip( struct softpipe_context *softpipe )
+/**
+ * Allocate a new clipper stage.
+ * \return pointer to new stage object
+ */
+struct prim_stage *prim_clip( struct draw_context *draw )
{
struct clipper *clipper = CALLOC_STRUCT(clipper);
prim_alloc_tmps( &clipper->stage, MAX_CLIPPED_VERTICES );
- clipper->stage.softpipe = softpipe;
+ clipper->stage.draw = draw;
clipper->stage.begin = clip_begin;
clipper->stage.point = clip_point;
clipper->stage.line = clip_line;
clipper->stage.tri = clip_tri;
clipper->stage.end = clip_end;
+ clipper->plane = draw->plane;
+
return &clipper->stage;
}
diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h
index a138f812fa..85f2ace75f 100644
--- a/src/mesa/pipe/draw/draw_context.h
+++ b/src/mesa/pipe/draw/draw_context.h
@@ -26,25 +26,42 @@
*
**************************************************************************/
+/**
+ * \brief Public interface into the drawing module.
+ */
+
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#ifndef G_DRAW_H
-#define G_DRAW_H
+
+#ifndef DRAW_CONTEXT_H
+#define DRAW_CONTEXT_H
+
#include "glheader.h"
#include "pipe/p_state.h"
+struct vertex_buffer;
struct draw_context;
+struct prim_stage;
+
-struct draw_context *draw_create( struct softpipe_context *softpipe );
+struct draw_context *draw_create( void );
void draw_destroy( struct draw_context *draw );
-void draw_set_viewport( struct draw_context *draw,
- const GLfloat *scale,
- const GLfloat *translate );
+void draw_set_viewport_state( struct draw_context *draw,
+ const struct pipe_viewport_state *viewport );
+
+void draw_set_clip_state( struct draw_context *pipe,
+ const struct pipe_clip_state *clip );
+
+void draw_set_setup_state( struct draw_context *draw,
+ const struct pipe_setup_state *setup );
+
+void draw_set_setup_stage( struct draw_context *draw,
+ struct prim_stage *stage );
void draw_set_vertex_attributes( struct draw_context *draw,
const GLuint *attrs,
@@ -53,4 +70,5 @@ void draw_set_vertex_attributes( struct draw_context *draw,
void draw_vb(struct draw_context *draw,
struct vertex_buffer *VB );
-#endif
+
+#endif /* DRAW_CONTEXT_H */
diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c
index 63099fbee0..d27d33a40d 100644
--- a/src/mesa/pipe/draw/draw_cull.c
+++ b/src/mesa/pipe/draw/draw_cull.c
@@ -27,11 +27,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "imports.h"
+#include "main/imports.h"
#include "pipe/p_defines.h"
-#include "sp_context.h"
-#include "sp_prim.h"
+#include "draw_private.h"
@@ -52,7 +51,7 @@ static void cull_begin( struct prim_stage *stage )
{
struct cull_stage *cull = cull_stage(stage);
- cull->mode = stage->softpipe->setup.cull_mode;
+ cull->mode = stage->draw->setup.cull_mode;
stage->next->begin( stage->next );
}
@@ -76,10 +75,13 @@ static void cull_tri( struct prim_stage *stage,
_mesa_printf("%s %f\n", __FUNCTION__, header->det );
if (header->det != 0) {
+ /* non-zero area */
GLuint mode = (header->det < 0) ? PIPE_WINDING_CW : PIPE_WINDING_CCW;
- if ((mode & cull_stage(stage)->mode) == 0)
+ if ((mode & cull_stage(stage)->mode) == 0) {
+ /* triangle is not culled, pass to next stage */
stage->next->tri( stage->next, header );
+ }
}
}
@@ -97,18 +99,23 @@ static void cull_point( struct prim_stage *stage,
stage->next->point( stage->next, header );
}
+
static void cull_end( struct prim_stage *stage )
{
stage->next->end( stage->next );
}
-struct prim_stage *prim_cull( struct softpipe_context *softpipe )
+
+/**
+ * Create a new polygon culling stage.
+ */
+struct prim_stage *prim_cull( struct draw_context *draw )
{
struct cull_stage *cull = CALLOC_STRUCT(cull_stage);
prim_alloc_tmps( &cull->stage, 0 );
- cull->stage.softpipe = softpipe;
+ cull->stage.draw = draw;
cull->stage.next = NULL;
cull->stage.begin = cull_begin;
cull->stage.point = cull_point;
diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c
index 3a7d9de466..004b5bdc96 100644
--- a/src/mesa/pipe/draw/draw_flatshade.c
+++ b/src/mesa/pipe/draw/draw_flatshade.c
@@ -27,12 +27,9 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "imports.h"
-#include "vf/vf.h"
-
-#include "sp_context.h"
-#include "sp_prim.h"
+#include "main/imports.h"
+#include "draw_private.h"
struct flatshade_stage {
@@ -67,11 +64,12 @@ static INLINE void copy_attr( GLuint attr,
}
}
-static void copy_colors( struct prim_stage *stage,
- struct vertex_header *dst,
- const struct vertex_header *src )
+
+static INLINE void copy_colors( struct prim_stage *stage,
+ struct vertex_header *dst,
+ const struct vertex_header *src )
{
- struct flatshade_stage *flatshade = flatshade_stage(stage);
+ const struct flatshade_stage *flatshade = flatshade_stage(stage);
const GLuint *lookup = flatshade->lookup;
copy_attr( lookup[VF_ATTRIB_COLOR0], dst, src );
@@ -81,8 +79,8 @@ static void copy_colors( struct prim_stage *stage,
}
-
-/* Flatshade tri. Required for clipping and when unfilled tris are
+/**
+ * Flatshade tri. Required for clipping and when unfilled tris are
* active, otherwise handled by hardware.
*/
static void flatshade_tri( struct prim_stage *stage,
@@ -102,7 +100,8 @@ static void flatshade_tri( struct prim_stage *stage,
}
-/* Flatshade line. Required for clipping.
+/**
+ * Flatshade line. Required for clipping.
*/
static void flatshade_line( struct prim_stage *stage,
struct prim_header *header )
@@ -124,18 +123,20 @@ static void flatshade_point( struct prim_stage *stage,
stage->next->point( stage->next, header );
}
+
static void flatshade_end( struct prim_stage *stage )
{
stage->next->end( stage->next );
}
-struct prim_stage *prim_flatshade( struct softpipe_context *softpipe )
+
+struct prim_stage *prim_flatshade( struct draw_context *draw )
{
struct flatshade_stage *flatshade = CALLOC_STRUCT(flatshade_stage);
prim_alloc_tmps( &flatshade->stage, 2 );
- flatshade->stage.softpipe = softpipe;
+ flatshade->stage.draw = draw;
flatshade->stage.next = NULL;
flatshade->stage.begin = flatshade_begin;
flatshade->stage.point = flatshade_point;
@@ -143,7 +144,7 @@ struct prim_stage *prim_flatshade( struct softpipe_context *softpipe )
flatshade->stage.tri = flatshade_tri;
flatshade->stage.end = flatshade_end;
- flatshade->lookup = softpipe->vf_attr_to_slot;
+ flatshade->lookup = draw->vf_attr_to_slot;
return &flatshade->stage;
}
diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c
index 5fd6ac911a..0fa8cf29d3 100644
--- a/src/mesa/pipe/draw/draw_offset.c
+++ b/src/mesa/pipe/draw/draw_offset.c
@@ -27,11 +27,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "imports.h"
-#include "macros.h"
-#include "sp_context.h"
-#include "sp_prim.h"
+#include "main/imports.h"
+#include "main/macros.h"
+#include "draw_private.h"
@@ -56,14 +55,15 @@ static void offset_begin( struct prim_stage *stage )
{
struct offset_stage *offset = offset_stage(stage);
- offset->units = stage->softpipe->setup.offset_units;
- offset->scale = stage->softpipe->setup.offset_scale;
+ offset->units = stage->draw->setup.offset_units;
+ offset->scale = stage->draw->setup.offset_scale;
stage->next->begin( stage->next );
}
-/* Offset tri. Some hardware can handle this, but not usually when
+/**
+ * Offset tri Z. Some hardware can handle this, but not usually when
* doing unfilled rendering.
*/
static void do_offset_tri( struct prim_stage *stage,
@@ -92,8 +92,8 @@ static void do_offset_tri( struct prim_stage *stage,
GLfloat bc = b * inv_det;
GLfloat zoffset;
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
+ ac = FABSF(ac);
+ bc = FABSF(bc);
zoffset = offset->units + MAX2( ac, bc ) * offset->scale;
@@ -115,7 +115,7 @@ static void offset_tri( struct prim_stage *stage,
tmp.v[1] = dup_vert(stage, header->v[1], 1);
tmp.v[2] = dup_vert(stage, header->v[2], 2);
- do_offset_tri( stage->next, &tmp );
+ do_offset_tri( stage, &tmp );
}
@@ -139,13 +139,13 @@ static void offset_end( struct prim_stage *stage )
stage->next->end( stage->next );
}
-struct prim_stage *prim_offset( struct softpipe_context *softpipe )
+struct prim_stage *prim_offset( struct draw_context *draw )
{
struct offset_stage *offset = CALLOC_STRUCT(offset_stage);
prim_alloc_tmps( &offset->stage, 3 );
- offset->stage.softpipe = softpipe;
+ offset->stage.draw = draw;
offset->stage.next = NULL;
offset->stage.begin = offset_begin;
offset->stage.point = offset_point;
diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h
index b6cbaae085..ac25628a08 100644
--- a/src/mesa/pipe/draw/draw_private.h
+++ b/src/mesa/pipe/draw/draw_private.h
@@ -25,32 +25,63 @@
*
**************************************************************************/
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
+/**
+ * Private data structures, etc for the draw module.
*/
-#ifndef G_PRIM_H
-#define G_PRIM_H
-#include "glheader.h"
-#include "sp_headers.h"
+/**
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Brian Paul
+ */
+
-struct softpipe_context;
+#ifndef DRAW_PRIVATE_H
+#define DRAW_PRIVATE_H
-struct prim_stage *prim_setup( struct softpipe_context *context );
-struct prim_stage *prim_unfilled( struct softpipe_context *context );
-struct prim_stage *prim_twoside( struct softpipe_context *context );
-struct prim_stage *prim_offset( struct softpipe_context *context );
-struct prim_stage *prim_clip( struct softpipe_context *context );
-struct prim_stage *prim_flatshade( struct softpipe_context *context );
-struct prim_stage *prim_cull( struct softpipe_context *context );
+#include "main/glheader.h"
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "vf/vf.h"
-/* Internal structs and helpers for the primitive clip/setup pipeline:
+
+/**
+ * Basic vertex info.
+ * Carry some useful information around with the vertices in the prim pipe.
*/
-struct prim_stage {
- struct softpipe_context *softpipe;
+struct vertex_header {
+ GLuint clipmask:12;
+ GLuint edgeflag:1;
+ GLuint pad:19;
- struct prim_stage *next;
+ GLfloat clip[4];
+
+ GLfloat data[][4]; /* Note variable size */
+};
+
+
+/**
+ * Basic info for a point/line/triangle primitive.
+ */
+struct prim_header {
+ GLfloat det; /**< front/back face determinant */
+ struct vertex_header *v[3]; /**< 1 to 3 vertex pointers */
+};
+
+
+
+struct draw_context;
+
+/**
+ * Base class for all primitive drawing stages.
+ */
+struct prim_stage
+{
+ struct draw_context *draw; /**< parent context */
+
+ struct prim_stage *next; /**< next stage in pipeline */
struct vertex_header **tmp;
GLuint nr_tmps;
@@ -70,8 +101,72 @@ struct prim_stage {
};
+/**
+ * Private context for the drawing module.
+ */
+struct draw_context
+{
+ struct {
+ struct prim_stage *first; /**< one of the following */
+
+ /* stages (in logical order) */
+ struct prim_stage *flatshade;
+ struct prim_stage *clip;
+ struct prim_stage *cull;
+ struct prim_stage *twoside;
+ struct prim_stage *offset;
+ struct prim_stage *unfilled;
+ struct prim_stage *setup; /* aka render/rasterize */
+ } pipeline;
+
+ /* pipe state that we need: */
+ struct pipe_setup_state setup;
+ struct pipe_viewport_state viewport;
+
+ /* Clip derived state:
+ */
+ GLfloat plane[12][4];
+ GLuint nr_planes;
+
+ GLuint vf_attr_to_slot[PIPE_ATTRIB_MAX];
+
+ struct vf_attr_map attrs[VF_ATTRIB_MAX];
+ GLuint nr_attrs;
+ GLuint vertex_size; /**< in bytes */
+ struct vertex_fetch *vf;
+
+ GLubyte *verts;
+ GLuint nr_vertices;
+ GLboolean in_vb;
+
+ GLenum prim; /**< GL_POINTS, GL_LINE_STRIP, GL_QUADS, etc */
+
+ /* Helper for tnl:
+ */
+ GLvector4f header;
+};
+
+
-/* Get a writeable copy of a vertex:
+extern struct prim_stage *prim_unfilled( struct draw_context *context );
+extern struct prim_stage *prim_twoside( struct draw_context *context );
+extern struct prim_stage *prim_offset( struct draw_context *context );
+extern struct prim_stage *prim_clip( struct draw_context *context );
+extern struct prim_stage *prim_flatshade( struct draw_context *context );
+extern struct prim_stage *prim_cull( struct draw_context *context );
+
+
+extern void prim_free_tmps( struct prim_stage *stage );
+extern void prim_alloc_tmps( struct prim_stage *stage, GLuint nr );
+
+
+
+/**
+ * Get a writeable copy of a vertex.
+ * \param stage drawing stage info
+ * \param vert the vertex to copy (source)
+ * \param idx index into stage's tmp[] array to put the copy (dest)
+ * \return pointer to the copied vertex
*/
static INLINE struct vertex_header *
dup_vert( struct prim_stage *stage,
@@ -79,12 +174,9 @@ dup_vert( struct prim_stage *stage,
GLuint idx )
{
struct vertex_header *tmp = stage->tmp[idx];
- memcpy(tmp, vert, stage->softpipe->prim.vertex_size );
+ memcpy(tmp, vert, stage->draw->vertex_size );
return tmp;
}
-void prim_free_tmps( struct prim_stage *stage );
-void prim_alloc_tmps( struct prim_stage *stage, GLuint nr );
-
-#endif
+#endif /* DRAW_PRIVATE_H */
diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c
index 5e9f218d1e..88e164ec5e 100644
--- a/src/mesa/pipe/draw/draw_twoside.c
+++ b/src/mesa/pipe/draw/draw_twoside.c
@@ -27,12 +27,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "imports.h"
-#include "vf/vf.h"
+#include "main/imports.h"
#include "pipe/p_defines.h"
-#include "sp_context.h"
-#include "sp_prim.h"
+#include "draw_private.h"
struct twoside_stage {
@@ -53,7 +51,7 @@ static void twoside_begin( struct prim_stage *stage )
{
struct twoside_stage *twoside = twoside_stage(stage);
- twoside->facing = (stage->softpipe->setup.front_winding == PIPE_WINDING_CW) ? -1 : 1;
+ twoside->facing = (stage->draw->setup.front_winding == PIPE_WINDING_CW) ? -1 : 1;
stage->next->begin( stage->next );
}
@@ -97,9 +95,11 @@ static void twoside_tri( struct prim_stage *stage,
struct twoside_stage *twoside = twoside_stage(stage);
if (header->det * twoside->facing < 0) {
+ /* this is a back-facing triangle */
struct prim_header tmp;
tmp.det = header->det;
+ /* copy back colors to front color slots */
tmp.v[0] = copy_bfc(twoside, header->v[0], 0);
tmp.v[1] = copy_bfc(twoside, header->v[1], 1);
tmp.v[2] = copy_bfc(twoside, header->v[2], 2);
@@ -115,6 +115,7 @@ static void twoside_tri( struct prim_stage *stage,
static void twoside_line( struct prim_stage *stage,
struct prim_header *header )
{
+ /* pass-through */
stage->next->line( stage->next, header );
}
@@ -122,23 +123,28 @@ static void twoside_line( struct prim_stage *stage,
static void twoside_point( struct prim_stage *stage,
struct prim_header *header )
{
+ /* pass-through */
stage->next->point( stage->next, header );
}
+
static void twoside_end( struct prim_stage *stage )
{
+ /* pass-through */
stage->next->end( stage->next );
}
-
-struct prim_stage *prim_twoside( struct softpipe_context *softpipe )
+/**
+ * Create twoside pipeline stage.
+ */
+struct prim_stage *prim_twoside( struct draw_context *draw )
{
struct twoside_stage *twoside = CALLOC_STRUCT(twoside_stage);
prim_alloc_tmps( &twoside->stage, 3 );
- twoside->stage.softpipe = softpipe;
+ twoside->stage.draw = draw;
twoside->stage.next = NULL;
twoside->stage.begin = twoside_begin;
twoside->stage.point = twoside_point;
@@ -146,7 +152,7 @@ struct prim_stage *prim_twoside( struct softpipe_context *softpipe )
twoside->stage.tri = twoside_tri;
twoside->stage.end = twoside_end;
- twoside->lookup = softpipe->vf_attr_to_slot;
+ twoside->lookup = draw->vf_attr_to_slot;
return &twoside->stage;
}
diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c
index ab0dab09d4..a1d9d14352 100644
--- a/src/mesa/pipe/draw/draw_unfilled.c
+++ b/src/mesa/pipe/draw/draw_unfilled.c
@@ -27,11 +27,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "imports.h"
-#include "sp_context.h"
-#include "sp_prim.h"
+#include "main/imports.h"
#include "pipe/p_defines.h"
+#include "draw_private.h"
struct unfilled_stage {
@@ -51,8 +50,8 @@ static void unfilled_begin( struct prim_stage *stage )
{
struct unfilled_stage *unfilled = unfilled_stage(stage);
- unfilled->mode[0] = stage->softpipe->setup.fill_ccw;
- unfilled->mode[1] = stage->softpipe->setup.fill_cw;
+ unfilled->mode[0] = stage->draw->setup.fill_ccw;
+ unfilled->mode[1] = stage->draw->setup.fill_cw;
stage->next->begin( stage->next );
}
@@ -128,14 +127,14 @@ static void unfilled_tri( struct prim_stage *stage,
}
static void unfilled_line( struct prim_stage *stage,
- struct prim_header *header )
+ struct prim_header *header )
{
stage->next->line( stage->next, header );
}
static void unfilled_point( struct prim_stage *stage,
- struct prim_header *header )
+ struct prim_header *header )
{
stage->next->point( stage->next, header );
}
@@ -146,13 +145,13 @@ static void unfilled_end( struct prim_stage *stage )
stage->next->end( stage->next );
}
-struct prim_stage *prim_unfilled( struct softpipe_context *softpipe )
+struct prim_stage *prim_unfilled( struct draw_context *draw )
{
struct unfilled_stage *unfilled = CALLOC_STRUCT(unfilled_stage);
prim_alloc_tmps( &unfilled->stage, 0 );
- unfilled->stage.softpipe = softpipe;
+ unfilled->stage.draw = draw;
unfilled->stage.next = NULL;
unfilled->stage.tmp = NULL;
unfilled->stage.begin = unfilled_begin;
diff --git a/src/mesa/pipe/draw/draw_vb.c b/src/mesa/pipe/draw/draw_vb.c
index 3fc30dd203..66573a93fe 100644
--- a/src/mesa/pipe/draw/draw_vb.c
+++ b/src/mesa/pipe/draw/draw_vb.c
@@ -31,41 +31,22 @@
*/
#include "imports.h"
+#include "macros.h"
#include "tnl/t_context.h"
#include "vf/vf.h"
-#include "sp_context.h"
-#include "sp_prim.h"
-#include "sp_headers.h"
-#include "sp_draw.h"
+#include "pipe/softpipe/sp_context.h"
+#include "pipe/softpipe/sp_headers.h"
+#include "draw_private.h"
+#include "draw_context.h"
+
/* This file is a temporary set of hooks to allow us to use the tnl/
* and vf/ modules until we have replacements in pipe.
*/
-struct draw_context
-{
- struct softpipe_context *softpipe;
-
- struct vf_attr_map attrs[VF_ATTRIB_MAX];
- GLuint nr_attrs;
- GLuint vertex_size;
- struct vertex_fetch *vf;
-
- GLubyte *verts;
- GLuint nr_vertices;
- GLboolean in_vb;
-
- GLenum prim;
-
- /* Helper for tnl:
- */
- GLvector4f header;
-};
-
-
static struct vertex_header *get_vertex( struct draw_context *pipe,
GLuint i )
{
@@ -80,7 +61,7 @@ static void draw_allocate_vertices( struct draw_context *draw,
draw->nr_vertices = nr_vertices;
draw->verts = MALLOC( nr_vertices * draw->vertex_size );
- draw->softpipe->prim.first->begin( draw->softpipe->prim.first );
+ draw->pipeline.first->begin( draw->pipeline.first );
}
static void draw_set_prim( struct draw_context *draw,
@@ -149,7 +130,7 @@ static void draw_indexed_prim( struct draw_context *draw,
const GLuint *elts,
GLuint count )
{
- struct prim_stage * const first = draw->softpipe->prim.first;
+ struct prim_stage * const first = draw->pipeline.first;
struct prim_header prim;
GLuint i;
@@ -299,7 +280,7 @@ static void draw_prim( struct draw_context *draw,
GLuint start,
GLuint count )
{
- struct prim_stage * const first = draw->softpipe->prim.first;
+ struct prim_stage * const first = draw->pipeline.first;
struct prim_header prim;
GLuint i;
@@ -442,7 +423,7 @@ static void draw_prim( struct draw_context *draw,
static void draw_release_vertices( struct draw_context *draw )
{
- draw->softpipe->prim.first->end( draw->softpipe->prim.first );
+ draw->pipeline.first->end( draw->pipeline.first );
FREE(draw->verts);
draw->verts = NULL;
@@ -636,35 +617,6 @@ void draw_vb(struct draw_context *draw,
draw->in_vb = 0;
}
-void draw_set_viewport( struct draw_context *draw,
- const GLfloat *scale,
- const GLfloat *translate )
-{
- assert(!draw->in_vb);
- vf_set_vp_scale_translate( draw->vf, scale, translate );
-}
-
-
-
-struct draw_context *draw_create( struct softpipe_context *softpipe )
-{
- struct draw_context *draw = CALLOC_STRUCT( draw_context );
- draw->softpipe = softpipe;
- draw->vf = vf_create( GL_TRUE );
-
- return draw;
-}
-
-
-void draw_destroy( struct draw_context *draw )
-{
- if (draw->header.storage)
- ALIGN_FREE( draw->header.storage );
-
- vf_destroy( draw->vf );
-
- FREE( draw );
-}
#define EMIT_ATTR( ATTR, STYLE ) \
do { \
@@ -695,3 +647,27 @@ void draw_set_vertex_attributes( struct draw_context *draw,
}
+#define MAX_VERTEX_SIZE ((2 + FRAG_ATTRIB_MAX) * 4 * sizeof(GLfloat))
+
+void prim_alloc_tmps( struct prim_stage *stage, GLuint nr )
+{
+ stage->nr_tmps = nr;
+
+ if (nr) {
+ GLubyte *store = MALLOC(MAX_VERTEX_SIZE * nr);
+ GLuint i;
+
+ stage->tmp = MALLOC(sizeof(struct vertex_header *) * nr);
+
+ for (i = 0; i < nr; i++)
+ stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
+ }
+}
+
+void prim_free_tmps( struct prim_stage *stage )
+{
+ if (stage->tmp) {
+ FREE(stage->tmp[0]);
+ FREE(stage->tmp);
+ }
+}