#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
*
**************************************************************************/
+
+/**
+ * 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;
GLfloat color[4];
};
+/** XXXX probably merge into pipe_setup_state */
struct pipe_line_state
{
GLuint smooth:1;
GLfloat width;
};
+/** XXXX probably merge into pipe_setup_state */
struct pipe_point_state
{
GLuint smooth:1;
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 */
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;
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
*/
#include "imports.h"
+#include "pipe/p_defines.h"
#include "sp_context.h"
#include "sp_prim.h"
_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 );
}
#include "imports.h"
#include "vf/vf.h"
+#include "pipe/p_defines.h"
#include "sp_context.h"
#include "sp_prim.h"
{
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 );
}
#include "sp_context.h"
#include "sp_prim.h"
-
+#include "pipe/p_defines.h"
struct unfilled_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();
}
}
{
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;
*
**************************************************************************/
+#include "pipe/p_defines.h"
#include "sp_context.h"
#include "sp_state.h"
#include "sp_prim.h"
/* 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;
#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;
}
}
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;
}
}
/* _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
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;
}
}
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;
}
/* 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;
}
}
*
* _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 :