/* 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 )
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.
*/
{
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];
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;
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);
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:
*/
header->v[1]->clipmask);
if (clipmask == 0) {
+ /* no clipping needed */
stage->next->line( stage->next, header );
}
else if ((header->v[0]->clipmask &
header->v[2]->clipmask);
if (clipmask == 0) {
+ /* no clipping needed */
stage->next->tri( stage->next, header );
}
else if ((header->v[0]->clipmask &
}
}
+
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;
}
*
**************************************************************************/
+/**
+ * \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,
void draw_vb(struct draw_context *draw,
struct vertex_buffer *VB );
-#endif
+
+#endif /* DRAW_CONTEXT_H */
/* 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"
{
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 );
}
_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 );
+ }
}
}
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;
/* 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 {
}
}
-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 );
}
-
-/* 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,
}
-/* Flatshade line. Required for clipping.
+/**
+ * Flatshade line. Required for clipping.
*/
static void flatshade_line( struct prim_stage *stage,
struct prim_header *header )
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;
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;
}
/* 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"
{
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,
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;
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 );
}
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;
*
**************************************************************************/
-/* 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;
};
+/**
+ * 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,
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 */
/* 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 {
{
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 );
}
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);
static void twoside_line( struct prim_stage *stage,
struct prim_header *header )
{
+ /* pass-through */
stage->next->line( stage->next, header );
}
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;
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;
}
/* 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 {
{
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 );
}
}
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 );
}
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;
*/
#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 )
{
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,
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;
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;
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;
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 { \
}
+#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);
+ }
+}
#define PIPE_MAX_SAMPLERS 8
#define PIPE_MAX_CLIP_PLANES 6
#define PIPE_MAX_CONSTANT 32
+#define PIPE_ATTRIB_MAX 32
+
/* fwd decl */
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "imports.h"
-#include "macros.h"
-
+#include "main/imports.h"
+#include "main/macros.h"
+#include "pipe/draw/draw_context.h"
#include "sp_context.h"
#include "sp_clear.h"
-#include "sp_prim.h"
#include "sp_state.h"
-#include "sp_draw.h"
+#include "sp_prim_setup.h"
+
static void softpipe_destroy( struct pipe_context *pipe )
{
draw_destroy( softpipe->draw );
- FREE( softpipe );
+ free( softpipe );
}
draw_vb( softpipe->draw, VB );
}
+
struct pipe_context *softpipe_create( void )
{
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
softpipe->pipe.draw_vb = softpipe_draw_vb;
softpipe->pipe.clear = softpipe_clear;
-
- softpipe->prim.setup = prim_setup( softpipe );
- softpipe->prim.unfilled = prim_unfilled( softpipe );
- softpipe->prim.twoside = prim_twoside( softpipe );
- softpipe->prim.offset = prim_offset( softpipe );
- softpipe->prim.clip = prim_clip( softpipe );
- softpipe->prim.flatshade = prim_flatshade( softpipe );
- softpipe->prim.cull = prim_cull( softpipe );
-
+ softpipe->quad.shade = sp_quad_shade_stage(softpipe);
+ softpipe->quad.alpha_test = sp_quad_alpha_test_stage(softpipe);
softpipe->quad.blend = sp_quad_blend_stage(softpipe);
softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe);
- softpipe->quad.shade = sp_quad_shade_stage(softpipe);
softpipe->quad.output = sp_quad_output_stage(softpipe);
- softpipe->draw = draw_create( softpipe );
-
- ASSIGN_4V( softpipe->plane[0], -1, 0, 0, 1 );
- ASSIGN_4V( softpipe->plane[1], 1, 0, 0, 1 );
- ASSIGN_4V( softpipe->plane[2], 0, -1, 0, 1 );
- ASSIGN_4V( softpipe->plane[3], 0, 1, 0, 1 );
- ASSIGN_4V( softpipe->plane[4], 0, 0, 1, 1 ); /* yes these are correct */
- ASSIGN_4V( softpipe->plane[5], 0, 0, -1, 1 ); /* mesa's a bit wonky */
- softpipe->nr_planes = 6;
+ /*
+ * Create drawing context and plug our render/setup stage into it.
+ */
+ softpipe->draw = draw_create();
+ draw_set_setup_stage(softpipe->draw, prim_setup(softpipe));
return &softpipe->pipe;
}
-
-
-
-
-
-
-#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);
- }
-}
-
-
-
-
-
#define G_NEW_SETUP 0x2
#define G_NEW_FS 0x4
#define G_NEW_BLEND 0x8
-#define G_NEW_POINT 0x10
#define G_NEW_CLIP 0x20
#define G_NEW_SCISSOR 0x40
#define G_NEW_STIPPLE 0x80
#define G_NEW_TEXTURE 0x1000
-#define PIPE_ATTRIB_MAX 32
-
struct softpipe_context {
struct pipe_context pipe;
-
/* The most recent drawing state as set by the driver:
*/
struct pipe_alpha_test_state alpha_test;
struct pipe_viewport_state viewport;
GLuint dirty;
- /* Clip derived state:
- */
- GLfloat plane[12][4];
- GLuint nr_planes;
-
/* Setup derived state. TODO: this should be passed in the program
* tokens as parameters to DECL instructions.
*
*/
GLubyte stipple_masks[16][16];
-
- /* The software clipper/setup engine.
- */
- struct {
- struct prim_stage *setup;
- struct prim_stage *unfilled;
- struct prim_stage *twoside;
- struct prim_stage *clip;
- struct prim_stage *flatshade;
- struct prim_stage *offset;
- struct prim_stage *cull;
-
- struct prim_stage *first;
-
- GLenum prim;
- GLuint vertex_size;
- } prim;
-
/*
* Software quad rendering pipeline
*/
#define PRIM_LINE 2
#define PRIM_TRI 3
-struct prim_header {
- GLfloat det;
- struct vertex_header *v[3];
-};
-
-/* Carry some useful information around with the vertices in the prim
- * pipe.
- */
-struct vertex_header {
- GLuint clipmask:12;
- GLuint edgeflag:1;
- GLuint pad:19;
-
- GLfloat clip[4];
-
- GLfloat data[][4]; /* Note variable size */
-};
-
-
-
-
/* The rasterizer generates 2x2 quads of fragment and feeds them to
* the current fp_machine (see below).
#include "macros.h"
#include "sp_context.h"
-#include "sp_prim.h"
+#include "sp_headers.h"
+#include "pipe/draw/draw_private.h"
#include "sp_quad.h"
+#include "sp_prim_setup.h"
* Also used for line drawing (taking some liberties).
*/
struct setup_stage {
- struct prim_stage stage; /**< This must be first */
+ struct prim_stage stage; /**< This must be first (base class) */
+
+ /*XXX NEW */
+ struct softpipe_context *softpipe;
/* Vertices are just an array of floats making up each attribute in
* turn. Currently fixed at 4 floats, but should change in time.
static void setup_begin( struct prim_stage *stage )
{
- setup_stage(stage)->quad.nr_attrs = stage->softpipe->nr_frag_attrs;
+ struct setup_stage *setup = setup_stage(stage);
+
+ setup->quad.nr_attrs = setup->softpipe->nr_frag_attrs;
}
setup->quad.y0 = y;
setup->quad.mask = mask;
- quad_emit(setup->stage.softpipe, &setup->quad);
+ quad_emit(setup->/*stage.*/softpipe, &setup->quad);
}
*/
static void setup_tri_coefficients( struct setup_stage *setup )
{
- const enum interp_mode *interp = setup->stage.softpipe->interp;
+ const enum interp_mode *interp = setup->/*stage.*/softpipe->interp;
GLuint slot, j;
/* z and w are done by linear interpolation:
/* scissor y:
*/
- if (setup->stage.softpipe->setup.scissor) {
+ if (setup->/*stage.*/softpipe->setup.scissor) {
start_y = sy;
finish_y = start_y + lines;
- if (start_y < setup->stage.softpipe->scissor.miny)
- start_y = setup->stage.softpipe->scissor.miny;
+ if (start_y < setup->/*stage.*/softpipe->scissor.miny)
+ start_y = setup->/*stage.*/softpipe->scissor.miny;
- if (finish_y > setup->stage.softpipe->scissor.maxy)
- finish_y = setup->stage.softpipe->scissor.maxy;
+ if (finish_y > setup->/*stage.*/softpipe->scissor.maxy)
+ finish_y = setup->/*stage.*/softpipe->scissor.maxy;
start_y -= sy;
finish_y -= sy;
/* scissor x:
*/
- if (setup->stage.softpipe->setup.scissor) {
- if (left < setup->stage.softpipe->scissor.minx)
- left = setup->stage.softpipe->scissor.minx;
+ if (setup->/*stage.*/softpipe->setup.scissor) {
+ if (left < setup->/*stage.*/softpipe->scissor.minx)
+ left = setup->/*stage.*/softpipe->scissor.minx;
- if (right > setup->stage.softpipe->scissor.maxx)
- right = setup->stage.softpipe->scissor.maxx;
+ if (right > setup->/*stage.*/softpipe->scissor.maxx)
+ right = setup->/*stage.*/softpipe->scissor.maxx;
}
if (left < right) {
static INLINE void
setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
{
- const enum interp_mode *interp = setup->stage.softpipe->interp;
+ const enum interp_mode *interp = setup->/*stage.*/softpipe->interp;
GLuint slot, j;
/* use setup->vmin, vmax to point to vertices */
/* flush prev quad, start new quad */
if (setup->quad.x0 != -1)
- quad_emit(setup->stage.softpipe, &setup->quad);
+ quad_emit(setup->/*stage.*/softpipe, &setup->quad);
setup->quad.x0 = quadX;
setup->quad.y0 = quadY;
/* draw final quad */
if (setup->quad.mask) {
- quad_emit(setup->stage.softpipe, &setup->quad);
+ quad_emit(setup->/*stage.*/softpipe, &setup->quad);
}
}
{
struct setup_stage *setup = setup_stage( stage );
/*XXX this should be a vertex attrib! */
- GLfloat halfSize = 0.5 * setup->stage.softpipe->setup.point_size;
- GLboolean round = setup->stage.softpipe->setup.point_smooth;
+ GLfloat halfSize = 0.5 * setup->/*stage.*/softpipe->setup.point_size;
+ GLboolean round = setup->/*stage.*/softpipe->setup.point_smooth;
const struct vertex_header *v0 = prim->v[0];
const GLfloat x = v0->data[FRAG_ATTRIB_WPOS][0];
const GLfloat y = v0->data[FRAG_ATTRIB_WPOS][1];
setup->quad.x0 = x - ix;
setup->quad.y0 = y - iy;
setup->quad.mask = (1 << ix) << (2 * iy);
- quad_emit(setup->stage.softpipe, &setup->quad);
+ quad_emit(setup->/*stage.*/softpipe, &setup->quad);
}
else {
const GLint ixmin = block((GLint) (x - halfSize));
if (setup->quad.mask) {
setup->quad.x0 = ix;
setup->quad.y0 = iy;
- quad_emit( setup->stage.softpipe, &setup->quad );
+ quad_emit( setup->/*stage.*/softpipe, &setup->quad );
}
}
}
{
struct setup_stage *setup = CALLOC_STRUCT(setup_stage);
- setup->stage.softpipe = softpipe;
+ setup->softpipe = softpipe;
+ setup->stage.draw = softpipe->draw;
setup->stage.begin = setup_begin;
setup->stage.point = setup_point;
setup->stage.line = setup_line;
#include "glheader.h"
#include "imports.h"
+#if 0
#include "s_tri_public.h"
+#endif
#include "s_context.h"
+extern struct prim_stage *prim_setup( struct softpipe_context *softpipe );
+
+#if 0 /* UNUSED? */
struct tri_context;
struct fp_context;
struct be_context;
+#endif
#endif
#endif
#include "sp_context.h"
#include "sp_state.h"
-#include "sp_draw.h"
-
void softpipe_set_blend_state( struct pipe_context *pipe,
#include "sp_context.h"
#include "sp_state.h"
-#include "sp_draw.h"
-
+#include "pipe/draw/draw_context.h"
void softpipe_set_clip_state( struct pipe_context *pipe,
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- memcpy(&softpipe->plane[6], clip->ucp, clip->nr * sizeof(clip->ucp[0]));
-
- softpipe->nr_planes = 6 + clip->nr;
- softpipe->dirty |= G_NEW_CLIP;
+ /* pass the clip state to the draw module */
+ draw_set_clip_state(softpipe->draw, clip);
}
struct softpipe_context *softpipe = softpipe_context(pipe);
softpipe->viewport = *viewport; /* struct copy */
+ softpipe->dirty |= G_NEW_VIEWPORT;
+
+ /* pass the viewport info to the draw module */
+ draw_set_viewport_state(softpipe->draw, viewport);
/* Using tnl/ and vf/ modules is temporary while getting started.
* Full pipe will have vertex shader, vertex fetch of its own.
*/
- draw_set_viewport( softpipe->draw, viewport->scale, viewport->translate );
- softpipe->dirty |= G_NEW_VIEWPORT;
}
+void softpipe_set_scissor_state( struct pipe_context *pipe,
+ const struct pipe_scissor_state *scissor )
+{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+
+ memcpy( &softpipe->scissor, scissor, sizeof(*scissor) );
+ softpipe->dirty |= G_NEW_SCISSOR;
+}
+
+
+void softpipe_set_polygon_stipple( struct pipe_context *pipe,
+ const struct pipe_poly_stipple *stipple )
+{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+ memcpy( &softpipe->poly_stipple, stipple, sizeof(*stipple) );
+ softpipe->dirty |= G_NEW_STIPPLE;
+}
*
**************************************************************************/
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
-#include "program.h"
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/enums.h"
+#include "shader/program.h"
#include "vf/vf.h"
-
+#include "pipe/draw/draw_context.h"
#include "sp_context.h"
-#include "sp_draw.h"
#include "sp_state.h"
+
#define EMIT_ATTR( ATTR, FRAG_ATTR, INTERP ) \
do { \
slot_to_vf_attr[softpipe->nr_attrs] = ATTR; \
softpipe->nr_attrs = 0;
memset(slot_to_vf_attr, 0, sizeof(slot_to_vf_attr));
- memset(softpipe->fp_attr_to_slot, 0, sizeof(softpipe->vf_attr_to_slot));
- memset(softpipe->vf_attr_to_slot, 0, sizeof(softpipe->fp_attr_to_slot));
+ memset(softpipe->fp_attr_to_slot, 0, sizeof(softpipe->fp_attr_to_slot));
+ memset(softpipe->vf_attr_to_slot, 0, sizeof(softpipe->vf_attr_to_slot));
/* TODO - Figure out if we need to do perspective divide, etc.
*/
/* Authors:
* Brian Paul
*/
+
#include "imports.h"
#include "sp_context.h"
#include "sp_state.h"
-#include "sp_draw.h"
#include "pipe/p_defines.h"
#include "sp_context.h"
#include "sp_state.h"
-#include "sp_prim.h"
-
-
+#include "pipe/draw/draw_context.h"
+#if 0
static void validate_prim_pipe( struct softpipe_context *softpipe )
{
struct prim_stage *next = softpipe->prim.setup;
softpipe->prim.first = next;
}
+#endif
{
struct softpipe_context *softpipe = softpipe_context(pipe);
+ /* pass-through to draw module */
+ draw_set_setup_state(softpipe->draw, setup);
+
memcpy( &softpipe->setup, setup, sizeof(*setup) );
+#if 0
validate_prim_pipe( softpipe );
+#endif
softpipe->dirty |= G_NEW_SETUP;
}
-
-void softpipe_set_scissor_state( struct pipe_context *pipe,
- const struct pipe_scissor_state *scissor )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- memcpy( &softpipe->scissor, scissor, sizeof(*scissor) );
- softpipe->dirty |= G_NEW_SCISSOR;
-}
-
-
-void softpipe_set_polygon_stipple( struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- memcpy( &softpipe->poly_stipple, stipple, sizeof(*stipple) );
- softpipe->dirty |= G_NEW_STIPPLE;
-}
SOFTPIPE_SOURCES = \
pipe/softpipe/sp_clear.c \
pipe/softpipe/sp_context.c \
- pipe/softpipe/sp_draw.c \
- pipe/softpipe/sp_prim_clip.c \
- pipe/softpipe/sp_prim_cull.c \
- pipe/softpipe/sp_prim_flatshade.c \
- pipe/softpipe/sp_prim_offset.c \
- pipe/softpipe/sp_prim_setup.c \
- pipe/softpipe/sp_prim_twoside.c \
- pipe/softpipe/sp_prim_unfilled.c \
pipe/softpipe/sp_quad.c \
pipe/softpipe/sp_quad_alpha_test.c \
pipe/softpipe/sp_quad_blend.c \
pipe/softpipe/sp_state_fs.c \
pipe/softpipe/sp_state_sampler.c \
pipe/softpipe/sp_state_setup.c \
- pipe/softpipe/sp_state_surface.c
+ pipe/softpipe/sp_state_surface.c \
+ pipe/softpipe/sp_prim_setup.c
+
+DRAW_SOURCES = \
+ pipe/draw/draw_clip.c \
+ pipe/draw/draw_context.c\
+ pipe/draw/draw_cull.c \
+ pipe/draw/draw_flatshade.c \
+ pipe/draw/draw_offset.c \
+ pipe/draw/draw_twoside.c \
+ pipe/draw/draw_unfilled.c \
+ pipe/draw/draw_vb.c
TGSICORE_SOURCES = \
pipe/tgsi/core/tgsi_build.c \
$(VBO_SOURCES) \
$(VF_SOURCES) \
$(SOFTPIPE_SOURCES) \
+ $(DRAW_SOURCES) \
$(TGSICORE_SOURCES) \
$(TGSIMESA_SOURCES) \
$(STATETRACKER_SOURCES) \