struct clipper {
- struct prim_stage stage; /**< base class */
+ struct draw_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 )
+static INLINE struct clipper *clipper_stage( struct draw_stage *stage )
{
return (struct clipper *)stage;
}
#if 0
-static INLINE void do_tri( struct prim_stage *next,
+static INLINE void do_tri( struct draw_stage *next,
struct prim_header *header )
{
GLuint i;
#endif
-static void emit_poly( struct prim_stage *stage,
+static void emit_poly( struct draw_stage *stage,
struct vertex_header **inlist,
GLuint n )
{
#if 0
-static void emit_poly( struct prim_stage *stage )
+static void emit_poly( struct draw_stage *stage )
{
GLuint i;
/* Clip a triangle against the viewport and user clip planes.
*/
static void
-do_clip_tri( struct prim_stage *stage,
+do_clip_tri( struct draw_stage *stage,
struct prim_header *header,
GLuint clipmask )
{
/* Clip a line against the viewport and user clip planes.
*/
static void
-do_clip_line( struct prim_stage *stage,
+do_clip_line( struct draw_stage *stage,
struct prim_header *header,
GLuint clipmask )
{
}
-static void clip_begin( struct prim_stage *stage )
+static void clip_begin( struct draw_stage *stage )
{
struct clipper *clipper = clipper_stage(stage);
GLuint nr = stage->draw->nr_planes;
static void
-clip_point( struct prim_stage *stage,
+clip_point( struct draw_stage *stage,
struct prim_header *header )
{
if (header->v[0]->clipmask == 0)
static void
-clip_line( struct prim_stage *stage,
+clip_line( struct draw_stage *stage,
struct prim_header *header )
{
GLuint clipmask = (header->v[0]->clipmask |
static void
-clip_tri( struct prim_stage *stage,
+clip_tri( struct draw_stage *stage,
struct prim_header *header )
{
GLuint clipmask = (header->v[0]->clipmask |
}
-static void clip_end( struct prim_stage *stage )
+static void clip_end( struct draw_stage *stage )
{
stage->next->end( stage->next );
}
* Allocate a new clipper stage.
* \return pointer to new stage object
*/
-struct prim_stage *prim_clip( struct draw_context *draw )
+struct draw_stage *draw_clip_stage( struct draw_context *draw )
{
struct clipper *clipper = CALLOC_STRUCT(clipper);
- prim_alloc_tmps( &clipper->stage, MAX_CLIPPED_VERTICES );
+ draw_alloc_tmps( &clipper->stage, MAX_CLIPPED_VERTICES );
clipper->stage.draw = draw;
clipper->stage.begin = clip_begin;
struct draw_context *draw = CALLOC_STRUCT( draw_context );
/* create pipeline stages */
- draw->pipeline.unfilled = prim_unfilled( draw );
- draw->pipeline.twoside = prim_twoside( draw );
- draw->pipeline.offset = prim_offset( draw );
- draw->pipeline.clip = prim_clip( draw );
- draw->pipeline.flatshade = prim_flatshade( draw );
- draw->pipeline.cull = prim_cull( draw );
+ draw->pipeline.unfilled = draw_unfilled_stage( draw );
+ draw->pipeline.twoside = draw_twoside_stage( draw );
+ draw->pipeline.offset = draw_offset_stage( draw );
+ draw->pipeline.clip = draw_clip_stage( draw );
+ draw->pipeline.flatshade = draw_flatshade_stage( draw );
+ draw->pipeline.cull = draw_cull_stage( draw );
ASSIGN_4V( draw->plane[0], -1, 0, 0, 1 );
ASSIGN_4V( draw->plane[1], 1, 0, 0, 1 );
*/
static void validate_pipeline( struct draw_context *draw )
{
- struct prim_stage *next = draw->pipeline.setup;
+ struct draw_stage *next = draw->pipeline.setup;
/*
* NOTE: we build up the pipeline in end-to-start order.
* This is provided by the device driver.
*/
void draw_set_setup_stage( struct draw_context *draw,
- struct prim_stage *stage )
+ struct draw_stage *stage )
{
draw->pipeline.setup = stage;
}
struct vertex_buffer;
struct draw_context;
-struct prim_stage;
+struct draw_stage;
struct draw_context *draw_create( void );
const struct pipe_setup_state *setup );
void draw_set_setup_stage( struct draw_context *draw,
- struct prim_stage *stage );
+ struct draw_stage *stage );
void draw_set_vertex_attributes( struct draw_context *draw,
const GLuint *attrs,
struct cull_stage {
- struct prim_stage stage;
+ struct draw_stage stage;
GLuint mode; /**< one of PIPE_WINDING_x */
};
-static INLINE struct cull_stage *cull_stage( struct prim_stage *stage )
+static INLINE struct cull_stage *cull_stage( struct draw_stage *stage )
{
return (struct cull_stage *)stage;
}
-static void cull_begin( struct prim_stage *stage )
+static void cull_begin( struct draw_stage *stage )
{
struct cull_stage *cull = cull_stage(stage);
}
-static void cull_tri( struct prim_stage *stage,
+static void cull_tri( struct draw_stage *stage,
struct prim_header *header )
{
/* Window coords: */
}
-static void cull_line( struct prim_stage *stage,
+static void cull_line( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->line( stage->next, header );
}
-static void cull_point( struct prim_stage *stage,
+static void cull_point( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->point( stage->next, header );
}
-static void cull_end( struct prim_stage *stage )
+static void cull_end( struct draw_stage *stage )
{
stage->next->end( stage->next );
}
/**
* Create a new polygon culling stage.
*/
-struct prim_stage *prim_cull( struct draw_context *draw )
+struct draw_stage *draw_cull_stage( struct draw_context *draw )
{
struct cull_stage *cull = CALLOC_STRUCT(cull_stage);
- prim_alloc_tmps( &cull->stage, 0 );
+ draw_alloc_tmps( &cull->stage, 0 );
cull->stage.draw = draw;
cull->stage.next = NULL;
struct flatshade_stage {
- struct prim_stage stage;
+ struct draw_stage stage;
const GLuint *lookup;
};
-static INLINE struct flatshade_stage *flatshade_stage( struct prim_stage *stage )
+static INLINE struct flatshade_stage *flatshade_stage( struct draw_stage *stage )
{
return (struct flatshade_stage *)stage;
}
-static void flatshade_begin( struct prim_stage *stage )
+static void flatshade_begin( struct draw_stage *stage )
{
stage->next->begin( stage->next );
}
}
-static INLINE void copy_colors( struct prim_stage *stage,
+static INLINE void copy_colors( struct draw_stage *stage,
struct vertex_header *dst,
const struct vertex_header *src )
{
* Flatshade tri. Required for clipping and when unfilled tris are
* active, otherwise handled by hardware.
*/
-static void flatshade_tri( struct prim_stage *stage,
+static void flatshade_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct prim_header tmp;
/**
* Flatshade line. Required for clipping.
*/
-static void flatshade_line( struct prim_stage *stage,
+static void flatshade_line( struct draw_stage *stage,
struct prim_header *header )
{
struct prim_header tmp;
}
-static void flatshade_point( struct prim_stage *stage,
- struct prim_header *header )
+static void flatshade_point( struct draw_stage *stage,
+ struct prim_header *header )
{
stage->next->point( stage->next, header );
}
-static void flatshade_end( struct prim_stage *stage )
+static void flatshade_end( struct draw_stage *stage )
{
stage->next->end( stage->next );
}
-struct prim_stage *prim_flatshade( struct draw_context *draw )
+/**
+ * Create flatshading drawing stage.
+ */
+struct draw_stage *draw_flatshade_stage( struct draw_context *draw )
{
struct flatshade_stage *flatshade = CALLOC_STRUCT(flatshade_stage);
- prim_alloc_tmps( &flatshade->stage, 2 );
+ draw_alloc_tmps( &flatshade->stage, 2 );
flatshade->stage.draw = draw;
flatshade->stage.next = NULL;
struct offset_stage {
- struct prim_stage stage;
+ struct draw_stage stage;
GLfloat scale;
GLfloat units;
-static INLINE struct offset_stage *offset_stage( struct prim_stage *stage )
+static INLINE struct offset_stage *offset_stage( struct draw_stage *stage )
{
return (struct offset_stage *) stage;
}
-static void offset_begin( struct prim_stage *stage )
+static void offset_begin( struct draw_stage *stage )
{
struct offset_stage *offset = offset_stage(stage);
GLfloat mrd = 1.0 / 65535.0; /* XXX this depends on depthbuffer bits! */
* Offset tri Z. Some hardware can handle this, but not usually when
* doing unfilled rendering.
*/
-static void do_offset_tri( struct prim_stage *stage,
+static void do_offset_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct offset_stage *offset = offset_stage(stage);
}
-static void offset_tri( struct prim_stage *stage,
+static void offset_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct prim_header tmp;
-static void offset_line( struct prim_stage *stage,
+static void offset_line( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->line( stage->next, header );
}
-static void offset_point( struct prim_stage *stage,
+static void offset_point( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->point( stage->next, header );
}
-static void offset_end( struct prim_stage *stage )
+static void offset_end( struct draw_stage *stage )
{
stage->next->end( stage->next );
}
-struct prim_stage *prim_offset( struct draw_context *draw )
+
+/**
+ * Create polygon offset drawing stage.
+ */
+struct draw_stage *draw_offset_stage( struct draw_context *draw )
{
struct offset_stage *offset = CALLOC_STRUCT(offset_stage);
- prim_alloc_tmps( &offset->stage, 3 );
+ draw_alloc_tmps( &offset->stage, 3 );
offset->stage.draw = draw;
offset->stage.next = NULL;
/**
* Base class for all primitive drawing stages.
*/
-struct prim_stage
+struct draw_stage
{
struct draw_context *draw; /**< parent context */
- struct prim_stage *next; /**< next stage in pipeline */
+ struct draw_stage *next; /**< next stage in pipeline */
struct vertex_header **tmp;
GLuint nr_tmps;
- void (*begin)( struct prim_stage * );
+ void (*begin)( struct draw_stage * );
- void (*point)( struct prim_stage *,
+ void (*point)( struct draw_stage *,
struct prim_header * );
- void (*line)( struct prim_stage *,
+ void (*line)( struct draw_stage *,
struct prim_header * );
- void (*tri)( struct prim_stage *,
+ void (*tri)( struct draw_stage *,
struct prim_header * );
- void (*end)( struct prim_stage * );
+ void (*end)( struct draw_stage * );
};
struct draw_context
{
struct {
- struct prim_stage *first; /**< one of the following */
+ struct draw_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 */
+ struct draw_stage *flatshade;
+ struct draw_stage *clip;
+ struct draw_stage *cull;
+ struct draw_stage *twoside;
+ struct draw_stage *offset;
+ struct draw_stage *unfilled;
+ struct draw_stage *setup; /* aka render/rasterize */
} pipeline;
/* pipe state that we need: */
-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 struct draw_stage *draw_unfilled_stage( struct draw_context *context );
+extern struct draw_stage *draw_twoside_stage( struct draw_context *context );
+extern struct draw_stage *draw_offset_stage( struct draw_context *context );
+extern struct draw_stage *draw_clip_stage( struct draw_context *context );
+extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
+extern struct draw_stage *draw_cull_stage( struct draw_context *context );
-extern void prim_free_tmps( struct prim_stage *stage );
-extern void prim_alloc_tmps( struct prim_stage *stage, GLuint nr );
+extern void draw_free_tmps( struct draw_stage *stage );
+extern void draw_alloc_tmps( struct draw_stage *stage, GLuint nr );
* \return pointer to the copied vertex
*/
static INLINE struct vertex_header *
-dup_vert( struct prim_stage *stage,
+dup_vert( struct draw_stage *stage,
const struct vertex_header *vert,
GLuint idx )
{
struct twoside_stage {
- struct prim_stage stage;
+ struct draw_stage stage;
GLfloat facing;
const GLuint *lookup;
};
-static INLINE struct twoside_stage *twoside_stage( struct prim_stage *stage )
+static INLINE struct twoside_stage *twoside_stage( struct draw_stage *stage )
{
return (struct twoside_stage *)stage;
}
-static void twoside_begin( struct prim_stage *stage )
+static void twoside_begin( struct draw_stage *stage )
{
struct twoside_stage *twoside = twoside_stage(stage);
/* Twoside tri:
*/
-static void twoside_tri( struct prim_stage *stage,
+static void twoside_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct twoside_stage *twoside = twoside_stage(stage);
}
-static void twoside_line( struct prim_stage *stage,
+static void twoside_line( struct draw_stage *stage,
struct prim_header *header )
{
/* pass-through */
}
-static void twoside_point( struct prim_stage *stage,
+static void twoside_point( struct draw_stage *stage,
struct prim_header *header )
{
/* pass-through */
}
-static void twoside_end( struct prim_stage *stage )
+static void twoside_end( struct draw_stage *stage )
{
/* pass-through */
stage->next->end( stage->next );
/**
* Create twoside pipeline stage.
*/
-struct prim_stage *prim_twoside( struct draw_context *draw )
+struct draw_stage *draw_twoside_stage( struct draw_context *draw )
{
struct twoside_stage *twoside = CALLOC_STRUCT(twoside_stage);
- prim_alloc_tmps( &twoside->stage, 3 );
+ draw_alloc_tmps( &twoside->stage, 3 );
twoside->stage.draw = draw;
twoside->stage.next = NULL;
struct unfilled_stage {
- struct prim_stage stage;
+ struct draw_stage stage;
/** [0] = front face, [1] = back face.
* legal values: PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE,
};
-static INLINE struct unfilled_stage *unfilled_stage( struct prim_stage *stage )
+static INLINE struct unfilled_stage *unfilled_stage( struct draw_stage *stage )
{
return (struct unfilled_stage *)stage;
}
-static void unfilled_begin( struct prim_stage *stage )
+static void unfilled_begin( struct draw_stage *stage )
{
struct unfilled_stage *unfilled = unfilled_stage(stage);
stage->next->begin( stage->next );
}
-static void point( struct prim_stage *stage,
+static void point( struct draw_stage *stage,
struct vertex_header *v0 )
{
struct prim_header tmp;
stage->next->point( stage->next, &tmp );
}
-static void line( struct prim_stage *stage,
+static void line( struct draw_stage *stage,
struct vertex_header *v0,
struct vertex_header *v1 )
{
}
-static void points( struct prim_stage *stage,
+static void points( struct draw_stage *stage,
struct prim_header *header )
{
struct vertex_header *v0 = header->v[0];
}
-static void lines( struct prim_stage *stage,
+static void lines( struct draw_stage *stage,
struct prim_header *header )
{
struct vertex_header *v0 = header->v[0];
* Note edgeflags in the vertex struct is not sufficient as we will
* need to manipulate them when decomposing primitives???
*/
-static void unfilled_tri( struct prim_stage *stage,
+static void unfilled_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct unfilled_stage *unfilled = unfilled_stage(stage);
}
}
-static void unfilled_line( struct prim_stage *stage,
+static void unfilled_line( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->line( stage->next, header );
}
-static void unfilled_point( struct prim_stage *stage,
+static void unfilled_point( struct draw_stage *stage,
struct prim_header *header )
{
stage->next->point( stage->next, header );
}
-static void unfilled_end( struct prim_stage *stage )
+static void unfilled_end( struct draw_stage *stage )
{
stage->next->end( stage->next );
}
-struct prim_stage *prim_unfilled( struct draw_context *draw )
+
+/**
+ * Create unfilled triangle stage.
+ */
+struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
{
struct unfilled_stage *unfilled = CALLOC_STRUCT(unfilled_stage);
- prim_alloc_tmps( &unfilled->stage, 0 );
+ draw_alloc_tmps( &unfilled->stage, 0 );
unfilled->stage.draw = draw;
unfilled->stage.next = NULL;
-static void do_quad( struct prim_stage *first,
+static void do_quad( struct draw_stage *first,
struct vertex_header *v0,
struct vertex_header *v1,
struct vertex_header *v2,
const GLuint *elts,
GLuint count )
{
- struct prim_stage * const first = draw->pipeline.first;
+ struct draw_stage * const first = draw->pipeline.first;
struct prim_header prim;
GLuint i;
GLuint start,
GLuint count )
{
- struct prim_stage * const first = draw->pipeline.first;
+ struct draw_stage * const first = draw->pipeline.first;
struct prim_header prim;
GLuint i;
#define MAX_VERTEX_SIZE ((2 + FRAG_ATTRIB_MAX) * 4 * sizeof(GLfloat))
-void prim_alloc_tmps( struct prim_stage *stage, GLuint nr )
+void draw_alloc_tmps( struct draw_stage *stage, GLuint nr )
{
stage->nr_tmps = nr;
}
}
-void prim_free_tmps( struct prim_stage *stage )
+void draw_free_tmps( struct draw_stage *stage )
{
if (stage->tmp) {
FREE(stage->tmp[0]);
softpipe->draw = draw_create();
draw_set_setup_stage(softpipe->draw, prim_setup(softpipe));
+ /*
+ * XXX we could plug GL selection/feedback into the drawing pipeline
+ * by specifying a different setup/render stage.
+ */
+
return &softpipe->pipe;
}
struct softpipe_surface;
struct draw_context;
-struct prim_stage;
+struct draw_stage;
enum interp_mode {
*
**************************************************************************/
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
+/**
+ * \brief Primitive rasterization/rendering (points, lines, triangles)
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ * \author Brian Paul
*/
+
#include "imports.h"
#include "macros.h"
/**
- * Triangle setup info (derived from prim_stage).
+ * Triangle setup info (derived from draw_stage).
* Also used for line drawing (taking some liberties).
*/
struct setup_stage {
- struct prim_stage stage; /**< This must be first (base class) */
+ struct draw_stage stage; /**< This must be first (base class) */
/*XXX NEW */
struct softpipe_context *softpipe;
/**
* Basically a cast wrapper.
*/
-static inline struct setup_stage *setup_stage( struct prim_stage *stage )
+static inline struct setup_stage *setup_stage( struct draw_stage *stage )
{
return (struct setup_stage *)stage;
}
-static void setup_begin( struct prim_stage *stage )
+static void setup_begin( struct draw_stage *stage )
{
struct setup_stage *setup = setup_stage(stage);
/**
* Do setup for triangle rasterization, then render the triangle.
*/
-static void setup_tri( struct prim_stage *stage,
+static void setup_tri( struct draw_stage *stage,
struct prim_header *prim )
{
struct setup_stage *setup = setup_stage( stage );
setup->span.y_flags = 0;
setup->span.right[0] = 0;
setup->span.right[1] = 0;
-// setup->span.z_mode = tri_z_mode( setup->ctx );
+ /* setup->span.z_mode = tri_z_mode( setup->ctx ); */
-// init_constant_attribs( setup );
+ /* init_constant_attribs( setup ); */
if (setup->oneoverarea < 0.0) {
/* emaj on left:
* XXX no scissoring yet.
*/
static void
-setup_line(struct prim_stage *stage, struct prim_header *prim)
+setup_line(struct draw_stage *stage, struct prim_header *prim)
{
const struct vertex_header *v0 = prim->v[0];
const struct vertex_header *v1 = prim->v[1];
* XXX could optimize a lot for 1-pixel points.
*/
static void
-setup_point(struct prim_stage *stage, struct prim_header *prim)
+setup_point(struct draw_stage *stage, struct prim_header *prim)
{
struct setup_stage *setup = setup_stage( stage );
/*XXX this should be a vertex attrib! */
-static void setup_end( struct prim_stage *stage )
+static void setup_end( struct draw_stage *stage )
{
}
/**
* Create a new primitive setup/render stage.
*/
-struct prim_stage *prim_setup( struct softpipe_context *softpipe )
+struct draw_stage *prim_setup( struct softpipe_context *softpipe )
{
struct setup_stage *setup = CALLOC_STRUCT(setup_stage);
#include "s_context.h"
-extern struct prim_stage *prim_setup( struct softpipe_context *softpipe );
+extern struct draw_stage *prim_setup( struct softpipe_context *softpipe );
#if 0 /* UNUSED? */
#if 0
static void validate_prim_pipe( struct softpipe_context *softpipe )
{
- struct prim_stage *next = softpipe->prim.setup;
+ struct draw_stage *next = softpipe->prim.setup;
/* TODO: make the current primitive part of the state and build
* shorter pipelines for lines & points.