diff options
author | Aapo Tahkola <[email protected]> | 2005-05-18 08:22:36 +0000 |
---|---|---|
committer | Aapo Tahkola <[email protected]> | 2005-05-18 08:22:36 +0000 |
commit | e53fc72f67c2ba7f273a78740bb15de37f96baeb (patch) | |
tree | bbe51da192bec635fda5a008a818cdf2c8b8fbb9 /src | |
parent | bd565e4bb7c4cff44d6fe7ac422ac7a6219f07dd (diff) |
Polygon mode fixes.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_reg.h | 21 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_render.c | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_state.c | 173 |
3 files changed, 81 insertions, 120 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index 040e69517b5..70fbd2fe45f 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -430,12 +430,17 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_POINTSIZE_MAX (R300_POINTSIZE_Y_MASK / 6) /* The line width is given in multiples of 6. - R300_LINE_CNT_UNK1 must be on to obtain expected results. */ + In default mode lines are classified as vertical lines. + HO: horizontal + VE: vertical or horizontal + HO & VE: no classification +*/ #define R300_RE_LINE_CNT 0x4234 # define R300_LINESIZE_SHIFT 0 # define R300_LINESIZE_MASK (0xFFFF << 0) /* GUESS */ # define R300_LINESIZE_MAX (R300_LINESIZE_MASK / 6) -# define R300_LINE_CNT_UNK1 (1 << 17) +# define R300_LINE_CNT_HO (1 << 16) +# define R300_LINE_CNT_VE (1 << 17) /* Linestipple factor. 3a088889 == 1.0, 3baaaaa9 == 10.0 */ #define R300_RE_LINE_STIPPLE_FACTOR 0x4238 @@ -444,8 +449,15 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_RE_SHADE_MODEL_SMOOTH 0x3aaaa # define R300_RE_SHADE_MODEL_FLAT 0x39595 - +/* Dangerous */ #define R300_RE_POLYGON_MODE 0x4288 +# define R300_PM_ENABLED (1 << 0) +# define R300_PM_FRONT_POINT (0 << 0) +# define R300_PM_BACK_POINT (0 << 0) +# define R300_PM_FRONT_LINE (1 << 4) +# define R300_PM_FRONT_FILL (1 << 5) +# define R300_PM_BACK_LINE (1 << 7) +# define R300_PM_BACK_FILL (1 << 8) /* Not sure why there are duplicate of factor and constant values. My best guess so far is that there are seperate zbiases for test and write. @@ -649,6 +661,7 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_TX_WIDTHMASK_MASK (2047 << 0) # define R300_TX_HEIGHTMASK_SHIFT 11 # define R300_TX_HEIGHTMASK_MASK (2047 << 11) +# define R300_TX_UNK23 (1 << 23) # define R300_TX_SIZE_SHIFT 26 /* largest of width, height */ # define R300_TX_SIZE_MASK (15 << 26) #define R300_TX_FORMAT_0 0x44C0 @@ -679,6 +692,8 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_TX_FORMAT_B8G8_B8G8 0x14 /* no swizzle */ # define R300_TX_FORMAT_G8R8_G8B8 0x15 /* no swizzle */ /* 0x16 - some 16 bit green format.. ?? */ +# define R300_TX_FORMAT_UNK25 (1 << 25) /* no swizzle */ + /* gap */ /* Floating point formats */ /* Note - hardware supports both 16 and 32 bit floating point */ diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index ac9d1550264..147beae9f75 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -765,6 +765,13 @@ static GLboolean r300_run_tcl_render(GLcontext *ctx, vp = CURRENT_VERTEX_SHADER(ctx); if(vp->translated == GL_FALSE) translate_vertex_shader(vp); + if(vp->translated == GL_FALSE){ + fprintf(stderr, "Failing back to sw-tcl\n"); + debug_vp(ctx, vp); + hw_tcl_on=future_hw_tcl_on=0; + r300ResetHwState(rmesa); + return GL_TRUE; + } r300_setup_textures(ctx); r300_setup_rs_unit(ctx); diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index b1c1bdef237..d611ec06e2a 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); } /* ============================================================= |