summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300/r300_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/r300/r300_state.c')
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c173
1 files changed, 56 insertions, 117 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index b1c1bdef23..d611ec06e2 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -514,6 +514,56 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state)
}
+static void r300UpdatePolygonMode(GLcontext *ctx)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ uint32_t hw_mode=0;
+
+ if (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL) {
+ GLenum f, b;
+
+ if (ctx->Polygon.FrontFace == GL_CCW) {
+ f = ctx->Polygon.FrontMode;
+ b = ctx->Polygon.BackMode;
+ } else {
+ f = ctx->Polygon.BackMode;
+ b = ctx->Polygon.FrontMode;
+ }
+
+ hw_mode |= R300_PM_ENABLED;
+
+ switch (f) {
+ case GL_LINE:
+ hw_mode |= R300_PM_FRONT_LINE;
+ break;
+ case GL_POINT: /* noop */
+ hw_mode |= R300_PM_FRONT_POINT;
+ break;
+ case GL_FILL:
+ hw_mode |= R300_PM_FRONT_FILL;
+ break;
+ }
+
+ switch (b) {
+ case GL_LINE:
+ hw_mode |= R300_PM_BACK_LINE;
+ break;
+ case GL_POINT: /* noop */
+ hw_mode |= R300_PM_BACK_POINT;
+ break;
+ case GL_FILL:
+ hw_mode |= R300_PM_BACK_FILL;
+ break;
+ }
+ }
+
+ if (r300->hw.unk4288.cmd[1] != hw_mode) {
+ R300_STATECHANGE(r300, unk4288);
+ r300->hw.unk4288.cmd[1] = hw_mode;
+ }
+}
+
/**
* Change the culling mode.
*
@@ -537,6 +587,7 @@ static void r300FrontFace(GLcontext* ctx, GLenum mode)
(void)mode;
r300UpdateCulling(ctx);
+ r300UpdatePolygonMode(ctx);
}
@@ -651,127 +702,15 @@ static void r300LineWidth(GLcontext *ctx, GLfloat widthf)
R300_STATECHANGE(r300, lcntl);
r300->hw.lcntl.cmd[1] = (int)(widthf * 6.0);
- /* Doesnt look very good without this... */
- r300->hw.lcntl.cmd[1] |= R300_LINE_CNT_UNK1;
+ r300->hw.lcntl.cmd[1] |= R300_LINE_CNT_VE;
}
-/*
-
-glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); : 00000091 ( 1001 0001)
-glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); : 00000001 ( 1)
-
-glPolygonMode(GL_FRONT, GL_LINE); : 00000111 (1 0001 0001)
-glPolygonMode(GL_FRONT, GL_POINT); : 00000101 (1 0000 0001)
-
-glPolygonMode(GL_BACK, GL_LINE); : 000000a1 ( 1010 0001)
-glPolygonMode(GL_BACK, GL_POINT); : 00000021 ( 10 0001)
-
-*/
-
-/* exclusive */
-#define PM_NOT_BACK (1<<8)
-#define PM_NOT_FRONT (1<<5)
-
-#define PM_FRONT_LINE (1<<4)
-#define PM_BACK_LINE (1<<7)
-
static void r300PolygonMode(GLcontext *ctx, GLenum face, GLenum mode)
{
- r300ContextPtr r300 = R300_CONTEXT(ctx);
- unsigned long hw_mode=0;
-
- //hw_mode=r300->hw.unk4288.cmd[1];
- hw_mode |= 1; /* enables point mode by default */
-
- switch (ctx->Polygon.FrontMode) {
- case GL_LINE:
- hw_mode &= ~PM_NOT_FRONT;
- hw_mode |= PM_FRONT_LINE;
- break;
- case GL_POINT:
- hw_mode &= ~PM_NOT_FRONT;
- hw_mode &= ~PM_FRONT_LINE;
- break;
- /* I dont think fgl properly handles these... In any case, test program is needed */
- case GL_FILL:
- break;
- }
-
- switch (ctx->Polygon.BackMode) {
- case GL_LINE:
- hw_mode &= ~PM_NOT_BACK;
- hw_mode |= PM_BACK_LINE;
- break;
- case GL_POINT:
- hw_mode &= ~PM_NOT_BACK;
- hw_mode &= ~PM_BACK_LINE;
- break;
- case GL_FILL:
- break;
- }
-
- if(hw_mode == 1)
- hw_mode = 0;
-
-#if 0
- switch (face) {
- case GL_FRONT:
- //fprintf(stderr, "front\n");
- hw_mode &= ~PM_NOT_FRONT;
- switch (mode) {
- case GL_LINE:
- hw_mode |= PM_FRONT_LINE;
- break;
- case GL_POINT:
- hw_mode &= ~PM_FRONT_LINE;
- break;
- case GL_FILL:
- break;
- }
- break;
-
- case GL_BACK:
- //fprintf(stderr, "back\n");
- hw_mode &= ~PM_NOT_BACK;
- switch (mode) {
- case GL_LINE:
- hw_mode |= PM_BACK_LINE;
- break;
- case GL_POINT:
- hw_mode &= ~PM_BACK_LINE;
- break;
- case GL_FILL:
- break;
- }
- break;
-
- case GL_FRONT_AND_BACK:
- //fprintf(stderr, "front and back\n");
- hw_mode &= ~PM_NOT_FRONT;
- hw_mode &= ~PM_NOT_BACK;
- switch (mode) {
- case GL_LINE:
- hw_mode |= PM_FRONT_LINE;
- hw_mode |= PM_BACK_LINE;
- break;
- case GL_POINT:
- hw_mode &= ~PM_FRONT_LINE;
- hw_mode &= ~PM_BACK_LINE;
- break;
- case GL_FILL:
- hw_mode = 0;
- break;
- }
- break;
- }
-#endif
-
- //if( front and back fill) hw_mode=0;
-
- if(r300->hw.unk4288.cmd[1] != hw_mode){
- R300_STATECHANGE(r300, unk4288);
- r300->hw.unk4288.cmd[1] = hw_mode;
- }
+ (void)face;
+ (void)mode;
+
+ r300UpdatePolygonMode(ctx);
}
/* =============================================================