New 'draw' module for primitive drawing (clipping, culling, etc).

This commit is contained in:
Brian
2007-07-09 16:14:26 -06:00
parent 9fbdf50078
commit 279ffe3f16
21 changed files with 372 additions and 338 deletions

View File

@@ -28,18 +28,18 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com> /* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/ */
#include "imports.h" #include "main/macros.h"
#include "macros.h" #include "draw_private.h"
#include "sp_context.h"
#include "sp_prim.h"
struct clipper { struct clipper {
struct prim_stage stage; struct prim_stage stage; /**< base class */
GLuint active_user_planes; GLuint active_user_planes;
GLfloat (*plane)[4];
}; };
/* This is a bit confusing: /* This is a bit confusing:
*/ */
static INLINE struct clipper *clipper_stage( struct prim_stage *stage ) 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 *out,
const struct vertex_header *in ) 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; GLuint j;
/* Vertex header. /* Vertex header.
@@ -96,8 +96,8 @@ static void interp( struct clipper *clip,
*/ */
{ {
const GLfloat *pos = dst->clip; const GLfloat *pos = dst->clip;
const GLfloat *scale = clip->stage.softpipe->viewport.scale; const GLfloat *scale = clip->stage.draw->viewport.scale;
const GLfloat *trans = clip->stage.softpipe->viewport.translate; const GLfloat *trans = clip->stage.draw->viewport.translate;
GLfloat oow; GLfloat oow;
oow = 1.0 / pos[3]; oow = 1.0 / pos[3];
@@ -225,7 +225,7 @@ do_clip_tri( struct prim_stage *stage,
while (clipmask && n >= 3) { while (clipmask && n >= 3) {
GLuint plane_idx = ffs(clipmask)-1; 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]; struct vertex_header *vert_prev = inlist[0];
GLfloat dp_prev = dot4( vert_prev->clip, plane ); GLfloat dp_prev = dot4( vert_prev->clip, plane );
GLuint outcount = 0; GLuint outcount = 0;
@@ -314,7 +314,7 @@ do_clip_line( struct prim_stage *stage,
while (clipmask) { while (clipmask) {
GLuint plane_idx = ffs(clipmask)-1; 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); clipmask &= ~(1<<plane_idx);
@@ -353,7 +353,7 @@ do_clip_line( struct prim_stage *stage,
static void clip_begin( struct prim_stage *stage ) static void clip_begin( struct prim_stage *stage )
{ {
struct clipper *clipper = clipper_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: /* Hacky bitmask to use when we hit CLIP_USER_BIT:
*/ */
@@ -379,6 +379,7 @@ clip_line( struct prim_stage *stage,
header->v[1]->clipmask); header->v[1]->clipmask);
if (clipmask == 0) { if (clipmask == 0) {
/* no clipping needed */
stage->next->line( stage->next, header ); stage->next->line( stage->next, header );
} }
else if ((header->v[0]->clipmask & else if ((header->v[0]->clipmask &
@@ -397,6 +398,7 @@ clip_tri( struct prim_stage *stage,
header->v[2]->clipmask); header->v[2]->clipmask);
if (clipmask == 0) { if (clipmask == 0) {
/* no clipping needed */
stage->next->tri( stage->next, header ); stage->next->tri( stage->next, header );
} }
else if ((header->v[0]->clipmask & else if ((header->v[0]->clipmask &
@@ -406,24 +408,31 @@ clip_tri( struct prim_stage *stage,
} }
} }
static void clip_end( struct prim_stage *stage ) static void clip_end( struct prim_stage *stage )
{ {
stage->next->end( stage->next ); 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); struct clipper *clipper = CALLOC_STRUCT(clipper);
prim_alloc_tmps( &clipper->stage, MAX_CLIPPED_VERTICES ); prim_alloc_tmps( &clipper->stage, MAX_CLIPPED_VERTICES );
clipper->stage.softpipe = softpipe; clipper->stage.draw = draw;
clipper->stage.begin = clip_begin; clipper->stage.begin = clip_begin;
clipper->stage.point = clip_point; clipper->stage.point = clip_point;
clipper->stage.line = clip_line; clipper->stage.line = clip_line;
clipper->stage.tri = clip_tri; clipper->stage.tri = clip_tri;
clipper->stage.end = clip_end; clipper->stage.end = clip_end;
clipper->plane = draw->plane;
return &clipper->stage; return &clipper->stage;
} }

View File

@@ -26,25 +26,42 @@
* *
**************************************************************************/ **************************************************************************/
/**
* \brief Public interface into the drawing module.
*/
/* Authors: Keith Whitwell <keith@tungstengraphics.com> /* 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 "glheader.h"
#include "pipe/p_state.h" #include "pipe/p_state.h"
struct vertex_buffer;
struct draw_context; 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_destroy( struct draw_context *draw );
void draw_set_viewport( struct draw_context *draw, void draw_set_viewport_state( struct draw_context *draw,
const GLfloat *scale, const struct pipe_viewport_state *viewport );
const GLfloat *translate );
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, void draw_set_vertex_attributes( struct draw_context *draw,
const GLuint *attrs, const GLuint *attrs,
@@ -53,4 +70,5 @@ void draw_set_vertex_attributes( struct draw_context *draw,
void draw_vb(struct draw_context *draw, void draw_vb(struct draw_context *draw,
struct vertex_buffer *VB ); struct vertex_buffer *VB );
#endif
#endif /* DRAW_CONTEXT_H */

View File

@@ -27,11 +27,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com> /* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/ */
#include "imports.h"
#include "main/imports.h"
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
#include "sp_context.h" #include "draw_private.h"
#include "sp_prim.h"
@@ -52,7 +51,7 @@ static void cull_begin( struct prim_stage *stage )
{ {
struct cull_stage *cull = cull_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 ); stage->next->begin( stage->next );
} }
@@ -76,12 +75,15 @@ static void cull_tri( struct prim_stage *stage,
_mesa_printf("%s %f\n", __FUNCTION__, header->det ); _mesa_printf("%s %f\n", __FUNCTION__, header->det );
if (header->det != 0) { if (header->det != 0) {
/* non-zero area */
GLuint mode = (header->det < 0) ? PIPE_WINDING_CW : PIPE_WINDING_CCW; 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->tri( stage->next, header );
} }
} }
}
static void cull_line( struct prim_stage *stage, static void cull_line( struct prim_stage *stage,
@@ -97,18 +99,23 @@ static void cull_point( struct prim_stage *stage,
stage->next->point( stage->next, header ); stage->next->point( stage->next, header );
} }
static void cull_end( struct prim_stage *stage ) static void cull_end( struct prim_stage *stage )
{ {
stage->next->end( stage->next ); 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); struct cull_stage *cull = CALLOC_STRUCT(cull_stage);
prim_alloc_tmps( &cull->stage, 0 ); prim_alloc_tmps( &cull->stage, 0 );
cull->stage.softpipe = softpipe; cull->stage.draw = draw;
cull->stage.next = NULL; cull->stage.next = NULL;
cull->stage.begin = cull_begin; cull->stage.begin = cull_begin;
cull->stage.point = cull_point; cull->stage.point = cull_point;

View File

@@ -27,12 +27,9 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com> /* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/ */
#include "imports.h"
#include "vf/vf.h" #include "main/imports.h"
#include "draw_private.h"
#include "sp_context.h"
#include "sp_prim.h"
struct flatshade_stage { struct flatshade_stage {
@@ -67,11 +64,12 @@ static INLINE void copy_attr( GLuint attr,
} }
} }
static void copy_colors( struct prim_stage *stage,
static INLINE void copy_colors( struct prim_stage *stage,
struct vertex_header *dst, struct vertex_header *dst,
const struct vertex_header *src ) 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; const GLuint *lookup = flatshade->lookup;
copy_attr( lookup[VF_ATTRIB_COLOR0], dst, src ); 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. * active, otherwise handled by hardware.
*/ */
static void flatshade_tri( struct prim_stage *stage, 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, static void flatshade_line( struct prim_stage *stage,
struct prim_header *header ) struct prim_header *header )
@@ -124,18 +123,20 @@ static void flatshade_point( struct prim_stage *stage,
stage->next->point( stage->next, header ); stage->next->point( stage->next, header );
} }
static void flatshade_end( struct prim_stage *stage ) static void flatshade_end( struct prim_stage *stage )
{ {
stage->next->end( stage->next ); 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); struct flatshade_stage *flatshade = CALLOC_STRUCT(flatshade_stage);
prim_alloc_tmps( &flatshade->stage, 2 ); prim_alloc_tmps( &flatshade->stage, 2 );
flatshade->stage.softpipe = softpipe; flatshade->stage.draw = draw;
flatshade->stage.next = NULL; flatshade->stage.next = NULL;
flatshade->stage.begin = flatshade_begin; flatshade->stage.begin = flatshade_begin;
flatshade->stage.point = flatshade_point; 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.tri = flatshade_tri;
flatshade->stage.end = flatshade_end; flatshade->stage.end = flatshade_end;
flatshade->lookup = softpipe->vf_attr_to_slot; flatshade->lookup = draw->vf_attr_to_slot;
return &flatshade->stage; return &flatshade->stage;
} }

View File

@@ -27,11 +27,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com> /* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/ */
#include "imports.h"
#include "macros.h"
#include "sp_context.h" #include "main/imports.h"
#include "sp_prim.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); struct offset_stage *offset = offset_stage(stage);
offset->units = stage->softpipe->setup.offset_units; offset->units = stage->draw->setup.offset_units;
offset->scale = stage->softpipe->setup.offset_scale; offset->scale = stage->draw->setup.offset_scale;
stage->next->begin( stage->next ); 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. * doing unfilled rendering.
*/ */
static void do_offset_tri( struct prim_stage *stage, 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 bc = b * inv_det;
GLfloat zoffset; GLfloat zoffset;
if ( ac < 0.0f ) ac = -ac; ac = FABSF(ac);
if ( bc < 0.0f ) bc = -bc; bc = FABSF(bc);
zoffset = offset->units + MAX2( ac, bc ) * offset->scale; 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[1] = dup_vert(stage, header->v[1], 1);
tmp.v[2] = dup_vert(stage, header->v[2], 2); 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 ); 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); struct offset_stage *offset = CALLOC_STRUCT(offset_stage);
prim_alloc_tmps( &offset->stage, 3 ); prim_alloc_tmps( &offset->stage, 3 );
offset->stage.softpipe = softpipe; offset->stage.draw = draw;
offset->stage.next = NULL; offset->stage.next = NULL;
offset->stage.begin = offset_begin; offset->stage.begin = offset_begin;
offset->stage.point = offset_point; offset->stage.point = offset_point;

View File

@@ -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>
struct softpipe_context; * Brian Paul
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 );
/* Internal structs and helpers for the primitive clip/setup pipeline:
*/ */
struct prim_stage {
struct softpipe_context *softpipe;
struct prim_stage *next;
#ifndef DRAW_PRIVATE_H
#define DRAW_PRIVATE_H
#include "main/glheader.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "vf/vf.h"
/**
* Basic vertex info.
* 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 */
};
/**
* 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; struct vertex_header **tmp;
GLuint nr_tmps; 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 */
/* Get a writeable copy of a vertex: /* 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;
};
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 * static INLINE struct vertex_header *
dup_vert( struct prim_stage *stage, dup_vert( struct prim_stage *stage,
@@ -79,12 +174,9 @@ dup_vert( struct prim_stage *stage,
GLuint idx ) GLuint idx )
{ {
struct vertex_header *tmp = stage->tmp[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; return tmp;
} }
void prim_free_tmps( struct prim_stage *stage );
void prim_alloc_tmps( struct prim_stage *stage, GLuint nr );
#endif /* DRAW_PRIVATE_H */
#endif

View File

@@ -27,12 +27,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com> /* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/ */
#include "imports.h"
#include "vf/vf.h"
#include "main/imports.h"
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
#include "sp_context.h" #include "draw_private.h"
#include "sp_prim.h"
struct twoside_stage { struct twoside_stage {
@@ -53,7 +51,7 @@ static void twoside_begin( struct prim_stage *stage )
{ {
struct twoside_stage *twoside = twoside_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 ); stage->next->begin( stage->next );
} }
@@ -97,9 +95,11 @@ static void twoside_tri( struct prim_stage *stage,
struct twoside_stage *twoside = twoside_stage(stage); struct twoside_stage *twoside = twoside_stage(stage);
if (header->det * twoside->facing < 0) { if (header->det * twoside->facing < 0) {
/* this is a back-facing triangle */
struct prim_header tmp; struct prim_header tmp;
tmp.det = header->det; tmp.det = header->det;
/* copy back colors to front color slots */
tmp.v[0] = copy_bfc(twoside, header->v[0], 0); tmp.v[0] = copy_bfc(twoside, header->v[0], 0);
tmp.v[1] = copy_bfc(twoside, header->v[1], 1); tmp.v[1] = copy_bfc(twoside, header->v[1], 1);
tmp.v[2] = copy_bfc(twoside, header->v[2], 2); 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, static void twoside_line( struct prim_stage *stage,
struct prim_header *header ) struct prim_header *header )
{ {
/* pass-through */
stage->next->line( stage->next, header ); 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, static void twoside_point( struct prim_stage *stage,
struct prim_header *header ) struct prim_header *header )
{ {
/* pass-through */
stage->next->point( stage->next, header ); stage->next->point( stage->next, header );
} }
static void twoside_end( struct prim_stage *stage ) static void twoside_end( struct prim_stage *stage )
{ {
/* pass-through */
stage->next->end( stage->next ); 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); struct twoside_stage *twoside = CALLOC_STRUCT(twoside_stage);
prim_alloc_tmps( &twoside->stage, 3 ); prim_alloc_tmps( &twoside->stage, 3 );
twoside->stage.softpipe = softpipe; twoside->stage.draw = draw;
twoside->stage.next = NULL; twoside->stage.next = NULL;
twoside->stage.begin = twoside_begin; twoside->stage.begin = twoside_begin;
twoside->stage.point = twoside_point; 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.tri = twoside_tri;
twoside->stage.end = twoside_end; twoside->stage.end = twoside_end;
twoside->lookup = softpipe->vf_attr_to_slot; twoside->lookup = draw->vf_attr_to_slot;
return &twoside->stage; return &twoside->stage;
} }

View File

@@ -27,11 +27,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com> /* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/ */
#include "imports.h"
#include "sp_context.h" #include "main/imports.h"
#include "sp_prim.h"
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
#include "draw_private.h"
struct unfilled_stage { struct unfilled_stage {
@@ -51,8 +50,8 @@ static void unfilled_begin( struct prim_stage *stage )
{ {
struct unfilled_stage *unfilled = unfilled_stage(stage); struct unfilled_stage *unfilled = unfilled_stage(stage);
unfilled->mode[0] = stage->softpipe->setup.fill_ccw; unfilled->mode[0] = stage->draw->setup.fill_ccw;
unfilled->mode[1] = stage->softpipe->setup.fill_cw; unfilled->mode[1] = stage->draw->setup.fill_cw;
stage->next->begin( stage->next ); stage->next->begin( stage->next );
} }
@@ -146,13 +145,13 @@ static void unfilled_end( struct prim_stage *stage )
stage->next->end( stage->next ); 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); struct unfilled_stage *unfilled = CALLOC_STRUCT(unfilled_stage);
prim_alloc_tmps( &unfilled->stage, 0 ); prim_alloc_tmps( &unfilled->stage, 0 );
unfilled->stage.softpipe = softpipe; unfilled->stage.draw = draw;
unfilled->stage.next = NULL; unfilled->stage.next = NULL;
unfilled->stage.tmp = NULL; unfilled->stage.tmp = NULL;
unfilled->stage.begin = unfilled_begin; unfilled->stage.begin = unfilled_begin;

View File

@@ -31,41 +31,22 @@
*/ */
#include "imports.h" #include "imports.h"
#include "macros.h"
#include "tnl/t_context.h" #include "tnl/t_context.h"
#include "vf/vf.h" #include "vf/vf.h"
#include "sp_context.h" #include "pipe/softpipe/sp_context.h"
#include "sp_prim.h" #include "pipe/softpipe/sp_headers.h"
#include "sp_headers.h" #include "draw_private.h"
#include "sp_draw.h" #include "draw_context.h"
/* This file is a temporary set of hooks to allow us to use the tnl/ /* This file is a temporary set of hooks to allow us to use the tnl/
* and vf/ modules until we have replacements in pipe. * 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, static struct vertex_header *get_vertex( struct draw_context *pipe,
GLuint i ) GLuint i )
{ {
@@ -80,7 +61,7 @@ static void draw_allocate_vertices( struct draw_context *draw,
draw->nr_vertices = nr_vertices; draw->nr_vertices = nr_vertices;
draw->verts = MALLOC( nr_vertices * draw->vertex_size ); 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, 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, const GLuint *elts,
GLuint count ) GLuint count )
{ {
struct prim_stage * const first = draw->softpipe->prim.first; struct prim_stage * const first = draw->pipeline.first;
struct prim_header prim; struct prim_header prim;
GLuint i; GLuint i;
@@ -299,7 +280,7 @@ static void draw_prim( struct draw_context *draw,
GLuint start, GLuint start,
GLuint count ) GLuint count )
{ {
struct prim_stage * const first = draw->softpipe->prim.first; struct prim_stage * const first = draw->pipeline.first;
struct prim_header prim; struct prim_header prim;
GLuint i; GLuint i;
@@ -442,7 +423,7 @@ static void draw_prim( struct draw_context *draw,
static void draw_release_vertices( 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); FREE(draw->verts);
draw->verts = NULL; draw->verts = NULL;
@@ -636,35 +617,6 @@ void draw_vb(struct draw_context *draw,
draw->in_vb = 0; 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 ) \ #define EMIT_ATTR( ATTR, STYLE ) \
do { \ 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);
}
}

View File

@@ -48,6 +48,8 @@
#define PIPE_MAX_SAMPLERS 8 #define PIPE_MAX_SAMPLERS 8
#define PIPE_MAX_CLIP_PLANES 6 #define PIPE_MAX_CLIP_PLANES 6
#define PIPE_MAX_CONSTANT 32 #define PIPE_MAX_CONSTANT 32
#define PIPE_ATTRIB_MAX 32
/* fwd decl */ /* fwd decl */

View File

@@ -29,14 +29,14 @@
* Keith Whitwell <keith@tungstengraphics.com> * Keith Whitwell <keith@tungstengraphics.com>
*/ */
#include "imports.h" #include "main/imports.h"
#include "macros.h" #include "main/macros.h"
#include "pipe/draw/draw_context.h"
#include "sp_context.h" #include "sp_context.h"
#include "sp_clear.h" #include "sp_clear.h"
#include "sp_prim.h"
#include "sp_state.h" #include "sp_state.h"
#include "sp_draw.h" #include "sp_prim_setup.h"
static void softpipe_destroy( struct pipe_context *pipe ) static void softpipe_destroy( struct pipe_context *pipe )
{ {
@@ -44,7 +44,7 @@ static void softpipe_destroy( struct pipe_context *pipe )
draw_destroy( softpipe->draw ); draw_destroy( softpipe->draw );
FREE( softpipe ); free( softpipe );
} }
@@ -59,6 +59,7 @@ static void softpipe_draw_vb( struct pipe_context *pipe,
draw_vb( softpipe->draw, VB ); draw_vb( softpipe->draw, VB );
} }
struct pipe_context *softpipe_create( void ) struct pipe_context *softpipe_create( void )
{ {
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context); struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
@@ -81,64 +82,17 @@ struct pipe_context *softpipe_create( void )
softpipe->pipe.draw_vb = softpipe_draw_vb; softpipe->pipe.draw_vb = softpipe_draw_vb;
softpipe->pipe.clear = softpipe_clear; softpipe->pipe.clear = softpipe_clear;
softpipe->quad.shade = sp_quad_shade_stage(softpipe);
softpipe->prim.setup = prim_setup( softpipe ); softpipe->quad.alpha_test = sp_quad_alpha_test_stage(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.blend = sp_quad_blend_stage(softpipe); softpipe->quad.blend = sp_quad_blend_stage(softpipe);
softpipe->quad.depth_test = sp_quad_depth_test_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->quad.output = sp_quad_output_stage(softpipe);
softpipe->draw = draw_create( softpipe ); /*
* Create drawing context and plug our render/setup stage into it.
ASSIGN_4V( softpipe->plane[0], -1, 0, 0, 1 ); */
ASSIGN_4V( softpipe->plane[1], 1, 0, 0, 1 ); softpipe->draw = draw_create();
ASSIGN_4V( softpipe->plane[2], 0, -1, 0, 1 ); draw_set_setup_stage(softpipe->draw, prim_setup(softpipe));
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;
return &softpipe->pipe; 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);
}
}

View File

@@ -55,7 +55,6 @@ enum interp_mode {
#define G_NEW_SETUP 0x2 #define G_NEW_SETUP 0x2
#define G_NEW_FS 0x4 #define G_NEW_FS 0x4
#define G_NEW_BLEND 0x8 #define G_NEW_BLEND 0x8
#define G_NEW_POINT 0x10
#define G_NEW_CLIP 0x20 #define G_NEW_CLIP 0x20
#define G_NEW_SCISSOR 0x40 #define G_NEW_SCISSOR 0x40
#define G_NEW_STIPPLE 0x80 #define G_NEW_STIPPLE 0x80
@@ -66,12 +65,9 @@ enum interp_mode {
#define G_NEW_TEXTURE 0x1000 #define G_NEW_TEXTURE 0x1000
#define PIPE_ATTRIB_MAX 32
struct softpipe_context { struct softpipe_context {
struct pipe_context pipe; struct pipe_context pipe;
/* The most recent drawing state as set by the driver: /* The most recent drawing state as set by the driver:
*/ */
struct pipe_alpha_test_state alpha_test; struct pipe_alpha_test_state alpha_test;
@@ -90,11 +86,6 @@ struct softpipe_context {
struct pipe_viewport_state viewport; struct pipe_viewport_state viewport;
GLuint dirty; GLuint dirty;
/* Clip derived state:
*/
GLfloat plane[12][4];
GLuint nr_planes;
/* Setup derived state. TODO: this should be passed in the program /* Setup derived state. TODO: this should be passed in the program
* tokens as parameters to DECL instructions. * tokens as parameters to DECL instructions.
* *
@@ -119,24 +110,6 @@ struct softpipe_context {
*/ */
GLubyte stipple_masks[16][16]; 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 * Software quad rendering pipeline
*/ */

View File

@@ -34,27 +34,6 @@
#define PRIM_LINE 2 #define PRIM_LINE 2
#define PRIM_TRI 3 #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 rasterizer generates 2x2 quads of fragment and feeds them to
* the current fp_machine (see below). * the current fp_machine (see below).

View File

@@ -32,8 +32,10 @@
#include "macros.h" #include "macros.h"
#include "sp_context.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_quad.h"
#include "sp_prim_setup.h"
@@ -66,7 +68,10 @@ struct edge {
* Also used for line drawing (taking some liberties). * Also used for line drawing (taking some liberties).
*/ */
struct setup_stage { 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 /* Vertices are just an array of floats making up each attribute in
* turn. Currently fixed at 4 floats, but should change in time. * turn. Currently fixed at 4 floats, but should change in time.
@@ -119,7 +124,9 @@ static inline GLint block( GLint x )
static void setup_begin( struct prim_stage *stage ) 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;
} }
@@ -133,7 +140,7 @@ static void run_shader_block( struct setup_stage *setup,
setup->quad.y0 = y; setup->quad.y0 = y;
setup->quad.mask = mask; setup->quad.mask = mask;
quad_emit(setup->stage.softpipe, &setup->quad); quad_emit(setup->/*stage.*/softpipe, &setup->quad);
} }
@@ -387,7 +394,7 @@ static void tri_persp_coeff( struct setup_stage *setup,
*/ */
static void setup_tri_coefficients( struct setup_stage *setup ) 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; GLuint slot, j;
/* z and w are done by linear interpolation: /* z and w are done by linear interpolation:
@@ -462,15 +469,15 @@ static void subtriangle( struct setup_stage *setup,
/* scissor y: /* scissor y:
*/ */
if (setup->stage.softpipe->setup.scissor) { if (setup->/*stage.*/softpipe->setup.scissor) {
start_y = sy; start_y = sy;
finish_y = start_y + lines; finish_y = start_y + lines;
if (start_y < setup->stage.softpipe->scissor.miny) if (start_y < setup->/*stage.*/softpipe->scissor.miny)
start_y = setup->stage.softpipe->scissor.miny; start_y = setup->/*stage.*/softpipe->scissor.miny;
if (finish_y > setup->stage.softpipe->scissor.maxy) if (finish_y > setup->/*stage.*/softpipe->scissor.maxy)
finish_y = setup->stage.softpipe->scissor.maxy; finish_y = setup->/*stage.*/softpipe->scissor.maxy;
start_y -= sy; start_y -= sy;
finish_y -= sy; finish_y -= sy;
@@ -495,12 +502,12 @@ static void subtriangle( struct setup_stage *setup,
/* scissor x: /* scissor x:
*/ */
if (setup->stage.softpipe->setup.scissor) { if (setup->/*stage.*/softpipe->setup.scissor) {
if (left < setup->stage.softpipe->scissor.minx) if (left < setup->/*stage.*/softpipe->scissor.minx)
left = setup->stage.softpipe->scissor.minx; left = setup->/*stage.*/softpipe->scissor.minx;
if (right > setup->stage.softpipe->scissor.maxx) if (right > setup->/*stage.*/softpipe->scissor.maxx)
right = setup->stage.softpipe->scissor.maxx; right = setup->/*stage.*/softpipe->scissor.maxx;
} }
if (left < right) { if (left < right) {
@@ -604,7 +611,7 @@ line_persp_coeff(struct setup_stage *setup, GLuint slot, GLuint i)
static INLINE void static INLINE void
setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim) 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; GLuint slot, j;
/* use setup->vmin, vmax to point to vertices */ /* use setup->vmin, vmax to point to vertices */
@@ -664,7 +671,7 @@ plot(struct setup_stage *setup, GLint x, GLint y)
/* flush prev quad, start new quad */ /* flush prev quad, start new quad */
if (setup->quad.x0 != -1) 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.x0 = quadX;
setup->quad.y0 = quadY; setup->quad.y0 = quadY;
@@ -767,7 +774,7 @@ setup_line(struct prim_stage *stage, struct prim_header *prim)
/* draw final quad */ /* draw final quad */
if (setup->quad.mask) { if (setup->quad.mask) {
quad_emit(setup->stage.softpipe, &setup->quad); quad_emit(setup->/*stage.*/softpipe, &setup->quad);
} }
} }
@@ -782,8 +789,8 @@ setup_point(struct prim_stage *stage, struct prim_header *prim)
{ {
struct setup_stage *setup = setup_stage( stage ); struct setup_stage *setup = setup_stage( stage );
/*XXX this should be a vertex attrib! */ /*XXX this should be a vertex attrib! */
GLfloat halfSize = 0.5 * setup->stage.softpipe->setup.point_size; GLfloat halfSize = 0.5 * setup->/*stage.*/softpipe->setup.point_size;
GLboolean round = setup->stage.softpipe->setup.point_smooth; GLboolean round = setup->/*stage.*/softpipe->setup.point_smooth;
const struct vertex_header *v0 = prim->v[0]; const struct vertex_header *v0 = prim->v[0];
const GLfloat x = v0->data[FRAG_ATTRIB_WPOS][0]; const GLfloat x = v0->data[FRAG_ATTRIB_WPOS][0];
const GLfloat y = v0->data[FRAG_ATTRIB_WPOS][1]; const GLfloat y = v0->data[FRAG_ATTRIB_WPOS][1];
@@ -822,7 +829,7 @@ setup_point(struct prim_stage *stage, struct prim_header *prim)
setup->quad.x0 = x - ix; setup->quad.x0 = x - ix;
setup->quad.y0 = y - iy; setup->quad.y0 = y - iy;
setup->quad.mask = (1 << ix) << (2 * iy); setup->quad.mask = (1 << ix) << (2 * iy);
quad_emit(setup->stage.softpipe, &setup->quad); quad_emit(setup->/*stage.*/softpipe, &setup->quad);
} }
else { else {
const GLint ixmin = block((GLint) (x - halfSize)); const GLint ixmin = block((GLint) (x - halfSize));
@@ -882,7 +889,7 @@ setup_point(struct prim_stage *stage, struct prim_header *prim)
if (setup->quad.mask) { if (setup->quad.mask) {
setup->quad.x0 = ix; setup->quad.x0 = ix;
setup->quad.y0 = iy; setup->quad.y0 = iy;
quad_emit( setup->stage.softpipe, &setup->quad ); quad_emit( setup->/*stage.*/softpipe, &setup->quad );
} }
} }
} }
@@ -900,7 +907,8 @@ struct prim_stage *prim_setup( struct softpipe_context *softpipe )
{ {
struct setup_stage *setup = CALLOC_STRUCT(setup_stage); 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.begin = setup_begin;
setup->stage.point = setup_point; setup->stage.point = setup_point;
setup->stage.line = setup_line; setup->stage.line = setup_line;

View File

@@ -37,11 +37,16 @@
#include "glheader.h" #include "glheader.h"
#include "imports.h" #include "imports.h"
#if 0
#include "s_tri_public.h" #include "s_tri_public.h"
#endif
#include "s_context.h" #include "s_context.h"
extern struct prim_stage *prim_setup( struct softpipe_context *softpipe );
#if 0 /* UNUSED? */
struct tri_context; struct tri_context;
struct fp_context; struct fp_context;
struct be_context; struct be_context;
@@ -117,5 +122,6 @@ void tri_rasterize_spans( struct tri_context *tri );
#endif
#endif #endif
#endif #endif

View File

@@ -31,8 +31,6 @@
#include "sp_context.h" #include "sp_context.h"
#include "sp_state.h" #include "sp_state.h"
#include "sp_draw.h"
void softpipe_set_blend_state( struct pipe_context *pipe, void softpipe_set_blend_state( struct pipe_context *pipe,

View File

@@ -31,8 +31,7 @@
#include "sp_context.h" #include "sp_context.h"
#include "sp_state.h" #include "sp_state.h"
#include "sp_draw.h" #include "pipe/draw/draw_context.h"
void softpipe_set_clip_state( struct pipe_context *pipe, void softpipe_set_clip_state( struct pipe_context *pipe,
@@ -40,10 +39,8 @@ void softpipe_set_clip_state( struct pipe_context *pipe,
{ {
struct softpipe_context *softpipe = softpipe_context(pipe); struct softpipe_context *softpipe = softpipe_context(pipe);
memcpy(&softpipe->plane[6], clip->ucp, clip->nr * sizeof(clip->ucp[0])); /* pass the clip state to the draw module */
draw_set_clip_state(softpipe->draw, clip);
softpipe->nr_planes = 6 + clip->nr;
softpipe->dirty |= G_NEW_CLIP;
} }
@@ -57,13 +54,32 @@ void softpipe_set_viewport_state( struct pipe_context *pipe,
struct softpipe_context *softpipe = softpipe_context(pipe); struct softpipe_context *softpipe = softpipe_context(pipe);
softpipe->viewport = *viewport; /* struct copy */ 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. /* Using tnl/ and vf/ modules is temporary while getting started.
* Full pipe will have vertex shader, vertex fetch of its own. * 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;
}

View File

@@ -25,17 +25,17 @@
* *
**************************************************************************/ **************************************************************************/
#include "glheader.h" #include "main/glheader.h"
#include "macros.h" #include "main/macros.h"
#include "enums.h" #include "main/enums.h"
#include "program.h" #include "shader/program.h"
#include "vf/vf.h" #include "vf/vf.h"
#include "pipe/draw/draw_context.h"
#include "sp_context.h" #include "sp_context.h"
#include "sp_draw.h"
#include "sp_state.h" #include "sp_state.h"
#define EMIT_ATTR( ATTR, FRAG_ATTR, INTERP ) \ #define EMIT_ATTR( ATTR, FRAG_ATTR, INTERP ) \
do { \ do { \
slot_to_vf_attr[softpipe->nr_attrs] = ATTR; \ slot_to_vf_attr[softpipe->nr_attrs] = ATTR; \
@@ -77,8 +77,8 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
softpipe->nr_attrs = 0; softpipe->nr_attrs = 0;
memset(slot_to_vf_attr, 0, sizeof(slot_to_vf_attr)); 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->fp_attr_to_slot, 0, sizeof(softpipe->fp_attr_to_slot));
memset(softpipe->vf_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. /* TODO - Figure out if we need to do perspective divide, etc.
*/ */

View File

@@ -28,11 +28,11 @@
/* Authors: /* Authors:
* Brian Paul * Brian Paul
*/ */
#include "imports.h" #include "imports.h"
#include "sp_context.h" #include "sp_context.h"
#include "sp_state.h" #include "sp_state.h"
#include "sp_draw.h"

View File

@@ -28,11 +28,10 @@
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
#include "sp_context.h" #include "sp_context.h"
#include "sp_state.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 ) static void validate_prim_pipe( struct softpipe_context *softpipe )
{ {
struct prim_stage *next = softpipe->prim.setup; struct prim_stage *next = softpipe->prim.setup;
@@ -87,6 +86,7 @@ static void validate_prim_pipe( struct softpipe_context *softpipe )
softpipe->prim.first = next; softpipe->prim.first = next;
} }
#endif
@@ -95,29 +95,15 @@ void softpipe_set_setup_state( struct pipe_context *pipe,
{ {
struct softpipe_context *softpipe = softpipe_context(pipe); 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) ); memcpy( &softpipe->setup, setup, sizeof(*setup) );
#if 0
validate_prim_pipe( softpipe ); validate_prim_pipe( softpipe );
#endif
softpipe->dirty |= G_NEW_SETUP; 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;
}

View File

@@ -157,14 +157,6 @@ VF_SOURCES = \
SOFTPIPE_SOURCES = \ SOFTPIPE_SOURCES = \
pipe/softpipe/sp_clear.c \ pipe/softpipe/sp_clear.c \
pipe/softpipe/sp_context.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.c \
pipe/softpipe/sp_quad_alpha_test.c \ pipe/softpipe/sp_quad_alpha_test.c \
pipe/softpipe/sp_quad_blend.c \ pipe/softpipe/sp_quad_blend.c \
@@ -177,7 +169,18 @@ SOFTPIPE_SOURCES = \
pipe/softpipe/sp_state_fs.c \ pipe/softpipe/sp_state_fs.c \
pipe/softpipe/sp_state_sampler.c \ pipe/softpipe/sp_state_sampler.c \
pipe/softpipe/sp_state_setup.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 = \ TGSICORE_SOURCES = \
pipe/tgsi/core/tgsi_build.c \ pipe/tgsi/core/tgsi_build.c \
@@ -355,6 +358,7 @@ SOLO_SOURCES = \
$(VBO_SOURCES) \ $(VBO_SOURCES) \
$(VF_SOURCES) \ $(VF_SOURCES) \
$(SOFTPIPE_SOURCES) \ $(SOFTPIPE_SOURCES) \
$(DRAW_SOURCES) \
$(TGSICORE_SOURCES) \ $(TGSICORE_SOURCES) \
$(TGSIMESA_SOURCES) \ $(TGSIMESA_SOURCES) \
$(STATETRACKER_SOURCES) \ $(STATETRACKER_SOURCES) \