summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/pipe/p_defines.h15
-rw-r--r--src/mesa/pipe/p_state.h55
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_cull.c5
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_twoside.c3
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_unfilled.c12
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_alpha_test.c8
-rw-r--r--src/mesa/pipe/softpipe/sp_state_setup.c5
-rw-r--r--src/mesa/state_tracker/st_atom_setup.c62
8 files changed, 84 insertions, 81 deletions
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
index 550240e647..75573107ff 100644
--- a/src/mesa/pipe/p_defines.h
+++ b/src/mesa/pipe/p_defines.h
@@ -89,16 +89,13 @@
#define PIPE_POLYGON_MODE_LINE 1
#define PIPE_POLYGON_MODE_POINT 2
-/** Polygon cull mode */
-#define PIPE_POLYGON_CULL_NONE 0
-#define PIPE_POLYGON_CULL_FRONT 1
-#define PIPE_POLYGON_CULL_BACK 2
-#define PIPE_POLYGON_CULL_BOTH 3
-
-/** Polygon front winding order */
-#define PIPE_POLYGON_FRONT_CW 0
-#define PIPE_POLYGON_FRONT_CCW 1
+/** Polygon front/back window, also for culling */
+#define PIPE_WINDING_NONE 0
+#define PIPE_WINDING_CW 1
+#define PIPE_WINDING_CCW 2
+#define PIPE_WINDING_BOTH (PIPE_WINDING_CW | PIPE_WINDING_CCW)
+/** Stencil ops */
#define PIPE_STENCIL_OP_KEEP 0
#define PIPE_STENCIL_OP_ZERO 1
#define PIPE_STENCIL_OP_REPLACE 2
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index 8e68fac1bd..b841181cf0 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -25,38 +25,43 @@
*
**************************************************************************/
+
+/**
+ * Abstract graphics pipe state objects.
+ *
+ * Basic notes:
+ * 1. Want compact representations, so we use bitfields.
+ * 2. Put bitfields before other (GLfloat) fields.
+ */
+
+
#ifndef PIPE_STATE_H
#define PIPE_STATE_H
#include "mtypes.h"
-#define WINDING_NONE 0
-#define WINDING_CW 1
-#define WINDING_CCW 2
-#define WINDING_BOTH (WINDING_CW | WINDING_CCW)
-#define FILL_POINT 1
-#define FILL_LINE 2
-#define FILL_TRI 3
-
-struct pipe_setup_state {
+/**
+ * Primitive (point/line/tri) setup info
+ */
+struct pipe_setup_state
+{
GLuint flatshade:1;
GLuint light_twoside:1;
- GLuint front_winding:2;
+ GLuint front_winding:2; /**< PIPE_WINDING_x */
- GLuint cull_mode:2;
+ GLuint cull_mode:2; /**< PIPE_WINDING_x */
- GLuint fill_cw:2;
- GLuint fill_ccw:2;
+ GLuint fill_cw:2; /**< PIPE_POLYGON_MODE_x */
+ GLuint fill_ccw:2; /**< PIPE_POLYGON_MODE_x */
GLuint offset_cw:1;
GLuint offset_ccw:1;
GLuint scissor:1;
GLuint poly_stipple:1;
-
- GLuint pad:18;
+ GLuint poly_smooth:1;
GLfloat offset_units;
GLfloat offset_scale;
@@ -137,6 +142,7 @@ struct pipe_clear_color_state
GLfloat color[4];
};
+/** XXXX probably merge into pipe_setup_state */
struct pipe_line_state
{
GLuint smooth:1;
@@ -146,6 +152,7 @@ struct pipe_line_state
GLfloat width;
};
+/** XXXX probably merge into pipe_setup_state */
struct pipe_point_state
{
GLuint smooth:1;
@@ -154,16 +161,6 @@ struct pipe_point_state
GLfloat attenuation[3];
};
-struct pipe_polygon_state {
- GLuint cull_mode:2; /**< PIPE_POLYGON_CULL_x */
- GLuint front_winding:1; /**< PIPE_POLYGON_FRONT_CCW,CW */
- GLuint front_mode:2; /**< PIPE_POLYGON_MODE_x */
- GLuint back_mode:2; /**< PIPE_POLYGON_MODE_x */
- GLuint stipple:1; /**< enable */
- GLuint smooth:1; /**< enable */
- /* XXX Polygon offset? */
-};
-
struct pipe_stencil_state {
GLuint front_enabled:1;
GLuint front_func:3; /**< PIPE_FUNC_x */
@@ -215,6 +212,10 @@ struct pipe_sampler_state
GLuint wrap_r:3; /**< PIPE_TEX_WRAP_x */
GLuint min_filter:3; /**< PIPE_TEX_FILTER_x */
GLuint mag_filter:1; /**< PIPE_TEX_FILTER_LINEAR or _NEAREST */
+ GLuint compare:1; /**< shadow/depth compare enabled? */
+ GLenum compare_mode:1; /**< PIPE_TEX_COMPARE_x */
+ GLenum compare_func:3; /**< PIPE_FUNC_x */
+ GLfloat shadow_ambient; /**< shadow test fail color/intensity */
GLfloat min_lod;
GLfloat max_lod;
GLfloat lod_bias;
@@ -223,10 +224,6 @@ struct pipe_sampler_state
GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
#endif
GLfloat max_anisotropy;
- GLuint compare:1; /**< shadow/depth compare enabled? */
- GLenum compare_mode:1; /**< PIPE_TEX_COMPARE_x */
- GLenum compare_func:3; /**< PIPE_FUNC_x */
- GLfloat shadow_ambient; /**< shadow test fail color/intensity */
};
#endif
diff --git a/src/mesa/pipe/softpipe/sp_prim_cull.c b/src/mesa/pipe/softpipe/sp_prim_cull.c
index 16920d478a..63099fbee0 100644
--- a/src/mesa/pipe/softpipe/sp_prim_cull.c
+++ b/src/mesa/pipe/softpipe/sp_prim_cull.c
@@ -29,6 +29,7 @@
*/
#include "imports.h"
+#include "pipe/p_defines.h"
#include "sp_context.h"
#include "sp_prim.h"
@@ -75,8 +76,8 @@ static void cull_tri( struct prim_stage *stage,
_mesa_printf("%s %f\n", __FUNCTION__, header->det );
if (header->det != 0) {
- GLuint mode = (header->det < 0) ? WINDING_CW : WINDING_CCW;
-
+ GLuint mode = (header->det < 0) ? PIPE_WINDING_CW : PIPE_WINDING_CCW;
+
if ((mode & cull_stage(stage)->mode) == 0)
stage->next->tri( stage->next, header );
}
diff --git a/src/mesa/pipe/softpipe/sp_prim_twoside.c b/src/mesa/pipe/softpipe/sp_prim_twoside.c
index 8ac0b5c130..5e9f218d1e 100644
--- a/src/mesa/pipe/softpipe/sp_prim_twoside.c
+++ b/src/mesa/pipe/softpipe/sp_prim_twoside.c
@@ -30,6 +30,7 @@
#include "imports.h"
#include "vf/vf.h"
+#include "pipe/p_defines.h"
#include "sp_context.h"
#include "sp_prim.h"
@@ -52,7 +53,7 @@ static void twoside_begin( struct prim_stage *stage )
{
struct twoside_stage *twoside = twoside_stage(stage);
- twoside->facing = (stage->softpipe->setup.front_winding == WINDING_CW) ? -1 : 1;
+ twoside->facing = (stage->softpipe->setup.front_winding == PIPE_WINDING_CW) ? -1 : 1;
stage->next->begin( stage->next );
}
diff --git a/src/mesa/pipe/softpipe/sp_prim_unfilled.c b/src/mesa/pipe/softpipe/sp_prim_unfilled.c
index 73147337fd..ab0dab09d4 100644
--- a/src/mesa/pipe/softpipe/sp_prim_unfilled.c
+++ b/src/mesa/pipe/softpipe/sp_prim_unfilled.c
@@ -31,7 +31,7 @@
#include "sp_context.h"
#include "sp_prim.h"
-
+#include "pipe/p_defines.h"
struct unfilled_stage {
@@ -113,17 +113,17 @@ static void unfilled_tri( struct prim_stage *stage,
GLuint mode = unfilled->mode[header->det < 0];
switch (mode) {
- case FILL_TRI:
+ case PIPE_POLYGON_MODE_FILL:
stage->next->tri( stage->next, header );
break;
-
- case FILL_LINE:
+ case PIPE_POLYGON_MODE_LINE:
lines( stage, header );
break;
-
- case GL_POINT:
+ case PIPE_POLYGON_MODE_POINT:
points( stage, header );
break;
+ default:
+ abort();
}
}
diff --git a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c b/src/mesa/pipe/softpipe/sp_quad_alpha_test.c
index f7cebca6ea..0059b3abf4 100644
--- a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c
+++ b/src/mesa/pipe/softpipe/sp_quad_alpha_test.c
@@ -16,16 +16,8 @@ alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
GLuint j;
- struct softpipe_surface *sps = softpipe_surface(softpipe->framebuffer.zbuf);
const GLfloat ref = softpipe->alpha_test.ref;
-#if 0
- assert(sps); /* shouldn't get here if there's no zbuffer */
-#else
- if (!sps)
- return;
-#endif
-
switch (softpipe->alpha_test.func) {
case PIPE_FUNC_NEVER:
quad->mask = 0x0;
diff --git a/src/mesa/pipe/softpipe/sp_state_setup.c b/src/mesa/pipe/softpipe/sp_state_setup.c
index 7be7d7fe40..a249ceb992 100644
--- a/src/mesa/pipe/softpipe/sp_state_setup.c
+++ b/src/mesa/pipe/softpipe/sp_state_setup.c
@@ -25,6 +25,7 @@
*
**************************************************************************/
+#include "pipe/p_defines.h"
#include "sp_context.h"
#include "sp_state.h"
#include "sp_prim.h"
@@ -39,8 +40,8 @@ static void validate_prim_pipe( struct softpipe_context *softpipe )
/* TODO: make the current primitive part of the state and build
* shorter pipelines for lines & points.
*/
- if (softpipe->setup.fill_cw != FILL_TRI ||
- softpipe->setup.fill_ccw != FILL_TRI) {
+ if (softpipe->setup.fill_cw != PIPE_POLYGON_MODE_FILL ||
+ softpipe->setup.fill_ccw != PIPE_POLYGON_MODE_FILL) {
softpipe->prim.unfilled->next = next;
next = softpipe->prim.unfilled;
diff --git a/src/mesa/state_tracker/st_atom_setup.c b/src/mesa/state_tracker/st_atom_setup.c
index d88d403c1d..fcda2b3a41 100644
--- a/src/mesa/state_tracker/st_atom_setup.c
+++ b/src/mesa/state_tracker/st_atom_setup.c
@@ -33,15 +33,21 @@
#include "st_context.h"
#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
#include "st_atom.h"
static GLuint translate_fill( GLenum mode )
{
switch (mode) {
- case GL_POINT: return FILL_POINT;
- case GL_LINE: return FILL_LINE;
- case GL_FILL: return FILL_TRI;
- default: assert(0); return 0;
+ case GL_POINT:
+ return PIPE_POLYGON_MODE_POINT;
+ case GL_LINE:
+ return PIPE_POLYGON_MODE_LINE;
+ case GL_FILL:
+ return PIPE_POLYGON_MODE_FILL;
+ default:
+ assert(0);
+ return 0;
}
}
@@ -49,10 +55,15 @@ static GLboolean get_offset_flag( GLuint fill_mode,
const struct gl_polygon_attrib *Polygon )
{
switch (fill_mode) {
- case FILL_POINT: return Polygon->OffsetPoint;
- case FILL_LINE: return Polygon->OffsetLine;
- case FILL_TRI: return Polygon->OffsetFill;
- default: assert(0); return 0;
+ case PIPE_POLYGON_MODE_POINT:
+ return Polygon->OffsetPoint;
+ case PIPE_POLYGON_MODE_LINE:
+ return Polygon->OffsetLine;
+ case PIPE_POLYGON_MODE_FILL:
+ return Polygon->OffsetFill;
+ default:
+ assert(0);
+ return 0;
}
}
@@ -67,13 +78,13 @@ static void update_setup_state( struct st_context *st )
/* _NEW_POLYGON, _NEW_BUFFERS
*/
{
- setup.front_winding = WINDING_CW;
+ setup.front_winding = PIPE_WINDING_CW;
if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0)
- setup.front_winding ^= WINDING_BOTH;
+ setup.front_winding ^= PIPE_WINDING_BOTH;
if (ctx->Polygon.FrontFace != GL_CCW)
- setup.front_winding ^= WINDING_BOTH;
+ setup.front_winding ^= PIPE_WINDING_BOTH;
}
/* _NEW_LIGHT
@@ -90,18 +101,23 @@ static void update_setup_state( struct st_context *st )
ctx->Light.Model.TwoSide)
setup.light_twoside = 1;
+ if (ctx->Polygon.SmoothFlag)
+ setup.poly_smooth = 1;
+
+ if (ctx->Polygon.StippleFlag)
+ setup.poly_stipple = 1;
/* _NEW_POLYGON
*/
if (ctx->Polygon.CullFlag) {
if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
- setup.cull_mode = WINDING_BOTH;
+ setup.cull_mode = PIPE_WINDING_BOTH;
}
else if (ctx->Polygon.CullFaceMode == GL_FRONT) {
setup.cull_mode = setup.front_winding;
}
else {
- setup.cull_mode = setup.front_winding ^ WINDING_BOTH;
+ setup.cull_mode = setup.front_winding ^ PIPE_WINDING_BOTH;
}
}
@@ -111,7 +127,7 @@ static void update_setup_state( struct st_context *st )
GLuint fill_front = translate_fill( ctx->Polygon.FrontMode );
GLuint fill_back = translate_fill( ctx->Polygon.BackMode );
- if (setup.front_winding == WINDING_CW) {
+ if (setup.front_winding == PIPE_WINDING_CW) {
setup.fill_cw = fill_front;
setup.fill_ccw = fill_back;
}
@@ -122,11 +138,11 @@ static void update_setup_state( struct st_context *st )
/* Simplify when culling is active:
*/
- if (setup.cull_mode & WINDING_CW) {
+ if (setup.cull_mode & PIPE_WINDING_CW) {
setup.fill_cw = setup.fill_ccw;
}
- if (setup.cull_mode & WINDING_CCW) {
+ if (setup.cull_mode & PIPE_WINDING_CCW) {
setup.fill_ccw = setup.fill_cw;
}
}
@@ -136,19 +152,17 @@ static void update_setup_state( struct st_context *st )
*
* _NEW_POLYGON
*/
- if (setup.fill_cw != FILL_TRI)
- setup.offset_cw = get_offset_flag( setup.fill_cw,
- &ctx->Polygon );
+ if (setup.fill_cw != PIPE_POLYGON_MODE_FILL)
+ setup.offset_cw = get_offset_flag( setup.fill_cw, &ctx->Polygon );
- if (setup.fill_ccw != FILL_TRI)
- setup.offset_ccw = get_offset_flag( setup.fill_ccw,
- &ctx->Polygon );
+ if (setup.fill_ccw != PIPE_POLYGON_MODE_FILL)
+ setup.offset_ccw = get_offset_flag( setup.fill_ccw, &ctx->Polygon );
/* _NEW_BUFFERS, _NEW_POLYGON
*/
- if (setup.fill_cw != FILL_TRI ||
- setup.fill_ccw != FILL_TRI)
+ if (setup.fill_cw != PIPE_POLYGON_MODE_FILL ||
+ setup.fill_ccw != PIPE_POLYGON_MODE_FILL)
{
GLfloat mrd = (ctx->DrawBuffer ?
ctx->DrawBuffer->_MRD :