diff options
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_cmdbuf.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_ioctl.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_reg.h | 19 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_state.c | 126 |
5 files changed, 92 insertions, 62 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index bf018daeb7..586abdec4f 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -385,7 +385,7 @@ void r300InitCmdBuf(r300ContextPtr r300) ALLOC_STATE( unk4BC8, always, 4, "unk4BC8", 0 ); r300->hw.unk4BC8.cmd[0] = cmducs(0x4BC8, 3); ALLOC_STATE( at, always, R300_AT_CMDSIZE, "at", 0 ); - r300->hw.at.cmd[R300_AT_CMD_0] = cmducs(R300_PP_ALPHA_TEST, 1); + r300->hw.at.cmd[R300_AT_CMD_0] = cmducs(R300_PP_ALPHA_TEST, 2); ALLOC_STATE( unk4BD8, always, 2, "unk4BD8", 0 ); r300->hw.unk4BD8.cmd[0] = cmducs(0x4BD8, 1); ALLOC_STATE( fpp, variable, R300_FPP_CMDSIZE, "fpp", 0 ); diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index f0a186d396..068fdfcdca 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -309,7 +309,8 @@ struct r300_state_atom { #define R300_AT_CMD_0 0 #define R300_AT_ALPHA_TEST 1 -#define R300_AT_CMDSIZE 2 +#define R300_AT_UNKNOWN 2 +#define R300_AT_CMDSIZE 3 #define R300_BLD_CMD_0 0 #define R300_BLD_CBLEND 1 diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 16528e0100..2bf70783f9 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -90,8 +90,8 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) r300->hw.vir[1].cmd[1] = 0xF688F688; R300_STATECHANGE(r300, vic); - r300->hw.vic.cmd[R300_VIR_CNTL_0] = 0x00000001; - r300->hw.vic.cmd[R300_VIR_CNTL_1] = 0x00000405; + r300->hw.vic.cmd[R300_VIC_CNTL_0] = 0x00000001; + r300->hw.vic.cmd[R300_VIC_CNTL_1] = 0x00000405; R300_STATECHANGE(r300, vof); r300->hw.vof.cmd[R300_VOF_CNTL_0] = R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index d07eb75a01..083ba9b1b6 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -1049,6 +1049,7 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_COLOR_ENDIAN_WORD_SWAP (1 << 18) /* GUESS */ # define R300_COLOR_ENDIAN_DWORD_SWAP (2 << 18) /* GUESS */ # define R300_COLOR_UNKNOWN_22_23 (3 << 22) /* GUESS: Format? */ + /* if format then it is (6<<21) - RGBA8 */ #define R300_RB3D_COLORPITCH1 0x4E3C /* GUESS */ #define R300_RB3D_COLORPITCH2 0x4E40 /* GUESS */ #define R300_RB3D_COLORPITCH3 0x4E44 /* GUESS */ @@ -1071,7 +1072,12 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_RB3D_Z_WRITE_ONLY 0x00000006 # define R300_STENCIL_ENABLE 0x00000000 /* UNKNOWN yet.. */ -#define R300_RB3D_ZSTENCILCNTL_1 0x4F04 +# define R300_RB3D_Z_TEST 0x00000012 +# define R300_RB3D_Z_TEST_AND_WRITE 0x00000016 +# define R300_RB3D_Z_WRITE_ONLY 0x00000006 +# define R300_STENCIL_ENABLE (0<<1) /* UNKNOWN yet.. */ + +#define R300_RB3D_ZSTENCIL_CNTL_1 0x4F04 /* functions */ # define R300_ZS_NEVER 0 # define R300_ZS_LESS 1 @@ -1094,14 +1100,17 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_RB3D_ZS1_DEPTH_FUNC_SHIFT 0 + /* front and back refer to operations done for front + and back faces - newer Radeons can perform different + functions */ # define R300_RB3D_ZS1_FRONT_FUNC_SHIFT 3 # define R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT 6 # define R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT 9 # define R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT 12 -# define R300_RB3D_ZS1_STENCIL_FUNC_SHIFT 15 -# define R300_RB3D_ZS1_STENCIL_FAIL_OP_SHIFT 18 -# define R300_RB3D_ZS1_STENCIL_ZPASS_OP_SHIFT 21 -# define R300_RB3D_ZS1_STENCIL_ZFAIL_OP_SHIFT 24 +# define R300_RB3D_ZS1_BACK_FUNC_SHIFT 15 +# define R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT 18 +# define R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT 21 +# define R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT 24 diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index cc6328b240..048f62572c 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -472,11 +472,22 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state) break; case GL_STENCIL_TEST: + + { + static int stencil=1; + if(stencil){ + fprintf(stderr, "%s:%s - do not know how to enable stencil. Help me !\n", + __FILE__, __FUNCTION__); + stencil=0; + } + } + if (r300->state.hw_stencil) { + //fprintf(stderr, "Stencil %s\n", state ? "enabled" : "disabled"); R300_STATECHANGE(r300, zs); if (state) { r300->hw.zs.cmd[R300_ZS_CNTL_0] |= - R300_STENCIL_ENABLE; + R300_STENCIL_ENABLE; } else { r300->hw.zs.cmd[R300_ZS_CNTL_0] &= ~R300_STENCIL_ENABLE; @@ -614,68 +625,38 @@ static void r300PointSize(GLcontext * ctx, GLfloat size) * Stencil */ -static void r300StencilFunc(GLcontext * ctx, GLenum func, - GLint ref, GLuint mask) -{ - r300ContextPtr rmesa = R300_CONTEXT(ctx); - GLuint refmask = ((ctx->Stencil.Ref[0] << R300_RB3D_ZS2_STENCIL_REF_SHIFT) | - (ctx->Stencil. - ValueMask[0] << R300_RB3D_ZS2_STENCIL_MASK_SHIFT)); - - R200_STATECHANGE(rmesa, zs); - - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_RB3D_ZS1_STENCIL_FUNC_SHIFT); - rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~((R300_ZS_MASK << R300_RB3D_ZS2_STENCIL_REF_SHIFT) | - (R300_ZS_MASK << R300_RB3D_ZS2_STENCIL_MASK_SHIFT)); - - switch (ctx->Stencil.Function[0]) { + static int translate_stencil_func(int func) + { + switch (func) { case GL_NEVER: - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= - R300_ZS_NEVER << R300_RB3D_ZS1_STENCIL_FUNC_SHIFT; + return R300_ZS_NEVER; break; case GL_LESS: - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= - R300_ZS_LESS << R300_RB3D_ZS1_STENCIL_FUNC_SHIFT; + return R300_ZS_LESS; break; case GL_EQUAL: - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= - R300_ZS_EQUAL << R300_RB3D_ZS1_STENCIL_FUNC_SHIFT; + return R300_ZS_EQUAL; break; case GL_LEQUAL: - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= - R300_ZS_LEQUAL << R300_RB3D_ZS1_STENCIL_FUNC_SHIFT; + return R300_ZS_LEQUAL; break; case GL_GREATER: - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= - R300_ZS_GREATER << R300_RB3D_ZS1_STENCIL_FUNC_SHIFT; + return R300_ZS_GREATER; break; case GL_NOTEQUAL: - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= - R300_ZS_NOTEQUAL << R300_RB3D_ZS1_STENCIL_FUNC_SHIFT; + return R300_ZS_NOTEQUAL; break; case GL_GEQUAL: - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= - R300_ZS_GEQUAL << R300_RB3D_ZS1_STENCIL_FUNC_SHIFT; + return R300_ZS_GEQUAL; break; case GL_ALWAYS: - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= - R300_ZS_ALWAYS << R300_RB3D_ZS1_STENCIL_FUNC_SHIFT; + return R300_ZS_ALWAYS; break; } - - rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= refmask; -} - -static void r300StencilMask(GLcontext * ctx, GLuint mask) -{ - r300ContextPtr rmesa = R300_CONTEXT(ctx); - - R200_STATECHANGE(rmesa, zs); - rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~(R300_ZS_MASK << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT); - rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= ctx->Stencil.WriteMask[0] << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT; -} - -static int translate_stencil_op(int op) + return 0; + } + + static int translate_stencil_op(int op) { switch (op) { case GL_KEEP: @@ -697,21 +678,56 @@ static int translate_stencil_op(int op) } } +static void r300StencilFunc(GLcontext * ctx, GLenum func, + GLint ref, GLuint mask) +{ + r300ContextPtr rmesa = R300_CONTEXT(ctx); + GLuint refmask = ((ctx->Stencil.Ref[0] << R300_RB3D_ZS2_STENCIL_REF_SHIFT) | + (ctx->Stencil. + ValueMask[0] << R300_RB3D_ZS2_STENCIL_MASK_SHIFT)); + GLuint func; + + R200_STATECHANGE(rmesa, zs); + + rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= ~( + (R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) + | (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT)); + rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~((R300_ZS_MASK << R300_RB3D_ZS2_STENCIL_REF_SHIFT) | + (R300_ZS_MASK << R300_RB3D_ZS2_STENCIL_MASK_SHIFT)); + + func = translate_stencil_func(ctx->Stencil.Function[0]); + + rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= (func << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) + | (func << R300_RB3D_ZS1_BACK_FUNC_SHIFT); + rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= refmask; +} + +static void r300StencilMask(GLcontext * ctx, GLuint mask) +{ + r300ContextPtr rmesa = R300_CONTEXT(ctx); + + R200_STATECHANGE(rmesa, zs); + rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~(R300_ZS_MASK << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT); + rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= ctx->Stencil.WriteMask[0] << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT; +} + + static void r300StencilOp(GLcontext * ctx, GLenum fail, GLenum zfail, GLenum zpass) { r300ContextPtr rmesa = R300_CONTEXT(ctx); R200_STATECHANGE(rmesa, zs); - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= ~((R300_ZS_MASK << R300_RB3D_ZS1_STENCIL_FAIL_OP_SHIFT) - | (R300_ZS_MASK << R300_RB3D_ZS1_STENCIL_ZPASS_OP_SHIFT) - | (R300_ZS_MASK << R300_RB3D_ZS1_STENCIL_ZFAIL_OP_SHIFT) - ); + /* It is easier to mask what's left.. */ + rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= (R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT); rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= - (translate_stencil_op(ctx->Stencil.FailFunc[0]) << R300_RB3D_ZS1_STENCIL_FAIL_OP_SHIFT) - |(translate_stencil_op(ctx->Stencil.ZFailFunc[0]) << R300_RB3D_ZS1_STENCIL_ZFAIL_OP_SHIFT) - |(translate_stencil_op(ctx->Stencil.ZPassFunc[0]) << R300_RB3D_ZS1_STENCIL_ZPASS_OP_SHIFT); + (translate_stencil_op(ctx->Stencil.FailFunc[0]) << R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) + |(translate_stencil_op(ctx->Stencil.ZFailFunc[0]) << R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT) + |(translate_stencil_op(ctx->Stencil.ZPassFunc[0]) << R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT) + |(translate_stencil_op(ctx->Stencil.FailFunc[0]) << R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT) + |(translate_stencil_op(ctx->Stencil.ZFailFunc[0]) << R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT) + |(translate_stencil_op(ctx->Stencil.ZPassFunc[0]) << R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT); } @@ -1689,6 +1705,7 @@ void r300ResetHwState(r300ContextPtr r300) r300->hw.at.cmd[R300_AT_ALPHA_TEST] = 0; #endif + r300->hw.at.cmd[R300_AT_UNKNOWN] = 0; r300->hw.unk4BD8.cmd[1] = 0; r300->hw.unk4E00.cmd[1] = 0; @@ -1728,6 +1745,9 @@ void r300ResetHwState(r300ContextPtr r300) r300->hw.unk4F10.cmd[3] = 0x00000003; r300->hw.unk4F10.cmd[4] = 0x00000000; + /* experiment a bit */ + r300->hw.unk4F10.cmd[2] = 0x00000001; // depthbuffer format? + r300->hw.zb.cmd[R300_ZB_OFFSET] = r300->radeon.radeonScreen->depthOffset + r300->radeon.radeonScreen->fbLocation; |