summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe/sp_prim_setup.c
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-07-09 16:14:26 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-07-09 16:14:26 -0600
commit279ffe3f163fd6a5e7bfa108db14c81acbb06ece (patch)
tree109bb794f7d057a51d748350ca616e920f2a67da /src/mesa/pipe/softpipe/sp_prim_setup.c
parent9fbdf500788e78d63247a17226a75f7a079ae315 (diff)
New 'draw' module for primitive drawing (clipping, culling, etc).
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_prim_setup.c')
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_setup.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c
index 3f4602feb0..ea10ef53a0 100644
--- a/src/mesa/pipe/softpipe/sp_prim_setup.c
+++ b/src/mesa/pipe/softpipe/sp_prim_setup.c
@@ -32,8 +32,10 @@
#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"
@@ -66,7 +68,10 @@ struct edge {
* 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.
@@ -119,7 +124,9 @@ static inline GLint block( GLint x )
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.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 )
{
- 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:
@@ -462,15 +469,15 @@ static void subtriangle( struct setup_stage *setup,
/* 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;
@@ -495,12 +502,12 @@ static void subtriangle( struct setup_stage *setup,
/* 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) {
@@ -604,7 +611,7 @@ line_persp_coeff(struct setup_stage *setup, GLuint slot, GLuint i)
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 */
@@ -664,7 +671,7 @@ plot(struct setup_stage *setup, GLint x, GLint y)
/* 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;
@@ -767,7 +774,7 @@ setup_line(struct prim_stage *stage, struct prim_header *prim)
/* draw final quad */
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 );
/*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];
@@ -822,7 +829,7 @@ setup_point(struct prim_stage *stage, struct prim_header *prim)
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));
@@ -882,7 +889,7 @@ setup_point(struct prim_stage *stage, struct prim_header *prim)
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 );
}
}
}
@@ -900,7 +907,8 @@ struct prim_stage *prim_setup( struct softpipe_context *softpipe )
{
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;