summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorNian Wu <[email protected]>2007-03-02 09:01:27 -0500
committerNian Wu <[email protected]>2007-03-02 09:01:27 -0500
commit180c0d70c43abe694e8b601159e02baf9af7b042 (patch)
treea098b09cfceeae037d6d05ef5d48b4bd08490164 /src/mesa/drivers
parent6a47e350656b1090e399144ff6a0cdabe94842e7 (diff)
parent95577064040ceeaaf7b0a460f91eac951cf8af18 (diff)
Merge git://proxy01.pd.intel.com:9419/git/mesa/mesa into crestline
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.c18
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog.c314
-rw-r--r--src/mesa/drivers/dri/r300/r300_ioctl.c2
-rw-r--r--src/mesa/drivers/dri/r300/r300_reg.h16
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c14
-rw-r--r--src/mesa/drivers/dri/r300/radeon_mm.c2
6 files changed, 179 insertions, 187 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
index ace9b667240..2c7b5aa011f 100644
--- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c
+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
@@ -292,13 +292,13 @@ void r300InitCmdBuf(r300ContextPtr r300)
ALLOC_STATE( vpt, always, R300_VPT_CMDSIZE, "vpt", 0 );
r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmdpacket0(R300_SE_VPORT_XSCALE, 6);
ALLOC_STATE( unk2080, always, 2, "unk2080", 0 );
- r300->hw.unk2080.cmd[0] = cmdpacket0(0x2080, 1);
+ r300->hw.unk2080.cmd[0] = cmdpacket0(R300_VAP_CNTL, 1);
ALLOC_STATE( vte, always, 3, "vte", 0 );
r300->hw.vte.cmd[0] = cmdpacket0(R300_SE_VTE_CNTL, 2);
ALLOC_STATE( unk2134, always, 3, "unk2134", 0 );
r300->hw.unk2134.cmd[0] = cmdpacket0(0x2134, 2);
ALLOC_STATE( unk2140, always, 2, "unk2140", 0 );
- r300->hw.unk2140.cmd[0] = cmdpacket0(0x2140, 1);
+ r300->hw.unk2140.cmd[0] = cmdpacket0(R300_VAP_CNTL_STATUS, 1);
ALLOC_STATE( vir[0], variable, R300_VIR_CMDSIZE, "vir/0", 0 );
r300->hw.vir[0].cmd[R300_VIR_CMD_0] = cmdpacket0(R300_VAP_INPUT_ROUTE_0_0, 1);
ALLOC_STATE( vir[1], variable, R300_VIR_CMDSIZE, "vir/1", 1 );
@@ -308,11 +308,11 @@ void r300InitCmdBuf(r300ContextPtr r300)
ALLOC_STATE( unk21DC, always, 2, "unk21DC", 0 );
r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1);
ALLOC_STATE( unk221C, always, 2, "unk221C", 0 );
- r300->hw.unk221C.cmd[0] = cmdpacket0(0x221C, 1);
+ r300->hw.unk221C.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_221C, 1);
ALLOC_STATE( unk2220, always, 5, "unk2220", 0 );
r300->hw.unk2220.cmd[0] = cmdpacket0(0x2220, 4);
ALLOC_STATE( unk2288, always, 2, "unk2288", 0 );
- r300->hw.unk2288.cmd[0] = cmdpacket0(0x2288, 1);
+ r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1);
ALLOC_STATE( vof, always, R300_VOF_CMDSIZE, "vof", 0 );
r300->hw.vof.cmd[R300_VOF_CMD_0] = cmdpacket0(R300_VAP_OUTPUT_VTX_FMT_0, 2);
ALLOC_STATE( pvs, always, R300_PVS_CMDSIZE, "pvs", 0 );
@@ -336,9 +336,9 @@ void r300InitCmdBuf(r300ContextPtr r300)
ALLOC_STATE( unk4260, always, 4, "unk4260", 0 );
r300->hw.unk4260.cmd[0] = cmdpacket0(0x4260, 3);
ALLOC_STATE( unk4274, always, 5, "unk4274", 0 );
- r300->hw.unk4274.cmd[0] = cmdpacket0(0x4274, 4);
+ r300->hw.unk4274.cmd[0] = cmdpacket0(R300_RE_SHADE, 4);
ALLOC_STATE( unk4288, always, 4, "unk4288", 0 );
- r300->hw.unk4288.cmd[0] = cmdpacket0(0x4288, 3);
+ r300->hw.unk4288.cmd[0] = cmdpacket0(R300_RE_POLYGON_MODE, 3);
ALLOC_STATE( fogp, always, 3, "fogp", 0 );
r300->hw.fogp.cmd[0] = cmdpacket0(R300_RE_FOG_SCALE, 2);
ALLOC_STATE( unk42A0, always, 2, "unk42A0", 0 );
@@ -346,7 +346,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
ALLOC_STATE( zbs, always, R300_ZBS_CMDSIZE, "zbs", 0 );
r300->hw.zbs.cmd[R300_ZBS_CMD_0] = cmdpacket0(R300_RE_ZBIAS_T_FACTOR, 4);
ALLOC_STATE( unk42B4, always, 2, "unk42B4", 0 );
- r300->hw.unk42B4.cmd[0] = cmdpacket0(0x42B4, 1);
+ r300->hw.unk42B4.cmd[0] = cmdpacket0(R300_RE_OCCLUSION_CNTL, 1);
ALLOC_STATE( cul, always, R300_CUL_CMDSIZE, "cul", 0 );
r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(R300_RE_CULL_CNTL, 1);
ALLOC_STATE( unk42C0, always, 3, "unk42C0", 0 );
@@ -393,7 +393,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
ALLOC_STATE( cmk, always, R300_CMK_CMDSIZE, "cmk", 0 );
r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(R300_RB3D_COLORMASK, 1);
ALLOC_STATE( unk4E10, always, 4, "unk4E10", 0 );
- r300->hw.unk4E10.cmd[0] = cmdpacket0(0x4E10, 3);
+ r300->hw.unk4E10.cmd[0] = cmdpacket0(R300_RB3D_BLEND_COLOR, 3);
ALLOC_STATE( cb, always, R300_CB_CMDSIZE, "cb", 0 );
r300->hw.cb.cmd[R300_CB_CMD_0] = cmdpacket0(R300_RB3D_COLOROFFSET0, 1);
r300->hw.cb.cmd[R300_CB_CMD_1] = cmdpacket0(R300_RB3D_COLORPITCH0, 1);
@@ -406,7 +406,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
ALLOC_STATE( zs, always, R300_ZS_CMDSIZE, "zstencil", 0 );
r300->hw.zs.cmd[R300_ZS_CMD_0] = cmdpacket0(R300_RB3D_ZSTENCIL_CNTL_0, 3);
ALLOC_STATE( unk4F10, always, 5, "unk4F10", 0 );
- r300->hw.unk4F10.cmd[0] = cmdpacket0(0x4F10, 4);
+ r300->hw.unk4F10.cmd[0] = cmdpacket0(R300_RB3D_ZSTENCIL_FORMAT, 4);
ALLOC_STATE( zb, always, R300_ZB_CMDSIZE, "zb", 0 );
r300->hw.zb.cmd[R300_ZB_CMD_0] = cmdpacket0(R300_RB3D_DEPTHOFFSET, 2);
ALLOC_STATE( unk4F28, always, 2, "unk4F28", 0 );
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c
index 8e45bd54030..a1c634a54d0 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog.c
@@ -1214,8 +1214,8 @@ static void make_sin_const(struct r300_fragment_program *rp)
cnstv[3] = 0.2225; // weight
rp->const_sin[0] = emit_const4fv(rp, cnstv);
- cnstv[0] = 0.5;
- cnstv[1] = -1.5;
+ cnstv[0] = 0.75;
+ cnstv[1] = 0.0;
cnstv[2] = 0.159154943; // 1/(2*PI)
cnstv[3] = 6.283185307; // 2*PI
rp->const_sin[1] = emit_const4fv(rp, cnstv);
@@ -1227,7 +1227,7 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
struct gl_fragment_program *mp = &rp->mesa_program;
const struct prog_instruction *inst = mp->Base.Instructions;
struct prog_instruction *fpi;
- GLuint src[3], dest, temp;
+ GLuint src[3], dest, temp[2];
GLuint cnst;
int flags, mask = 0;
GLfloat cnstv[4] = {0.0, 0.0, 0.0, 0.0};
@@ -1277,70 +1277,63 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
/*
* cos using a parabola (see SIN):
* cos(x):
- * x += PI/2
- * x = (x/(2*PI))+0.5
+ * x = (x/(2*PI))+0.75
* x = frac(x)
* x = (x*2*PI)-PI
* result = sin(x)
*/
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
make_sin_const(rp);
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
/* add 0.5*PI and do range reduction */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(rp->const_sin[0], Z, Z, Z, Z), //PI
- pfs_half,
- swizzle(keep(src[0]), X, X, X, X),
- 0);
-
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
+ swizzle(src[0], X, X, X, X),
swizzle(rp->const_sin[1], Z, Z, Z, Z),
- pfs_half,
+ swizzle(rp->const_sin[1], X, X, X, X),
0);
- emit_arith(rp, PFS_OP_FRC, temp, WRITEMASK_X,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_FRC, temp[0], WRITEMASK_X,
+ swizzle(temp[0], X, X, X, X),
undef,
undef,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Z,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Z,
+ swizzle(temp[0], X, X, X, X),
swizzle(rp->const_sin[1], W, W, W, W), //2*PI
negate(swizzle(rp->const_sin[0], Z, Z, Z, Z)), //-PI
0);
/* SIN */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y,
- swizzle(temp, Z, Z, Z, Z),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y,
+ swizzle(temp[0], Z, Z, Z, Z),
rp->const_sin[0],
pfs_zero,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(temp, Y, Y, Y, Y),
- absolute(swizzle(temp, Z, Z, Z, Z)),
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
+ swizzle(temp[0], Y, Y, Y, Y),
+ absolute(swizzle(temp[0], Z, Z, Z, Z)),
+ swizzle(temp[0], X, X, X, X),
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Y,
- swizzle(temp, X, X, X, X),
- absolute(swizzle(temp, X, X, X, X)),
- negate(swizzle(temp, X, X, X, X)),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Y,
+ swizzle(temp[0], X, X, X, X),
+ absolute(swizzle(temp[0], X, X, X, X)),
+ negate(swizzle(temp[0], X, X, X, X)),
0);
emit_arith(rp, PFS_OP_MAD, dest, mask,
- swizzle(temp, Y, Y, Y, Y),
+ swizzle(temp[0], Y, Y, Y, Y),
swizzle(rp->const_sin[0], W, W, W, W),
- swizzle(temp, X, X, X, X),
+ swizzle(temp[0], X, X, X, X),
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_DP3:
src[0] = t_src(rp, fpi->SrcReg[0]);
@@ -1363,15 +1356,15 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
* DP4 dest, temp, src1
*/
#if 0
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
src[0].s_swz = SWIZZLE_ONE;
- emit_arith(rp, PFS_OP_MAD, temp, mask,
+ emit_arith(rp, PFS_OP_MAD, temp[0], mask,
src[0], pfs_one, pfs_zero,
0);
emit_arith(rp, PFS_OP_DP4, dest, mask,
- temp, src[1], undef,
+ temp[0], src[1], undef,
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
#else
emit_arith(rp, PFS_OP_DP4, dest, mask,
swizzle(src[0], X, Y, Z, ONE), src[1],
@@ -1408,17 +1401,17 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
break;
case OPCODE_FLR:
src[0] = t_src(rp, fpi->SrcReg[0]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
/* FRC temp, src0
* MAD dest, src0, 1.0, -temp
*/
- emit_arith(rp, PFS_OP_FRC, temp, mask,
+ emit_arith(rp, PFS_OP_FRC, temp[0], mask,
keep(src[0]), undef, undef,
0);
emit_arith(rp, PFS_OP_MAD, dest, mask,
- src[0], pfs_one, negate(temp),
+ src[0], pfs_one, negate(temp[0]),
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_FRC:
src[0] = t_src(rp, fpi->SrcReg[0]);
@@ -1450,44 +1443,44 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
*/
cnstv[0] = cnstv[1] = cnstv[2] = cnstv[3] = 0.50001;
src[0] = t_src(rp, fpi->SrcReg[0]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
cnst = emit_const4fv(rp, cnstv);
- emit_arith(rp, PFS_OP_CMP, temp,
+ emit_arith(rp, PFS_OP_CMP, temp[0],
WRITEMASK_X | WRITEMASK_Y,
src[0], pfs_zero, src[0], flags);
- emit_arith(rp, PFS_OP_MIN, temp, WRITEMASK_Z,
+ emit_arith(rp, PFS_OP_MIN, temp[0], WRITEMASK_Z,
swizzle(keep(src[0]), W, W, W, W),
cnst, undef, flags);
- emit_arith(rp, PFS_OP_LG2, temp, WRITEMASK_W,
- swizzle(temp, Y, Y, Y, Y),
+ emit_arith(rp, PFS_OP_LG2, temp[0], WRITEMASK_W,
+ swizzle(temp[0], Y, Y, Y, Y),
undef, undef, flags);
- emit_arith(rp, PFS_OP_MAX, temp, WRITEMASK_Z,
- temp, negate(cnst), undef, flags);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W,
- temp, swizzle(temp, Z, Z, Z, Z),
+ emit_arith(rp, PFS_OP_MAX, temp[0], WRITEMASK_Z,
+ temp[0], negate(cnst), undef, flags);
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_W,
+ temp[0], swizzle(temp[0], Z, Z, Z, Z),
pfs_zero, flags);
- emit_arith(rp, PFS_OP_EX2, temp, WRITEMASK_W,
- temp, undef, undef, flags);
+ emit_arith(rp, PFS_OP_EX2, temp[0], WRITEMASK_W,
+ temp[0], undef, undef, flags);
emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_Y,
- swizzle(keep(temp), X, X, X, X),
+ swizzle(keep(temp[0]), X, X, X, X),
pfs_one, pfs_zero, flags);
#if 0
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- temp, pfs_one, pfs_half, flags);
- emit_arith(rp, PFS_OP_CMPH, temp, WRITEMASK_Z,
- swizzle(keep(temp), W, W, W, W),
- pfs_zero, swizzle(keep(temp), X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
+ temp[0], pfs_one, pfs_half, flags);
+ emit_arith(rp, PFS_OP_CMPH, temp[0], WRITEMASK_Z,
+ swizzle(keep(temp[0]), W, W, W, W),
+ pfs_zero, swizzle(keep(temp[0]), X, X, X, X),
flags);
#else
- emit_arith(rp, PFS_OP_CMP, temp, WRITEMASK_Z,
+ emit_arith(rp, PFS_OP_CMP, temp[0], WRITEMASK_Z,
pfs_zero,
- swizzle(keep(temp), W, W, W, W),
- negate(swizzle(keep(temp), X, X, X, X)),
+ swizzle(keep(temp[0]), W, W, W, W),
+ negate(swizzle(keep(temp[0]), X, X, X, X)),
flags);
#endif
emit_arith(rp, PFS_OP_CMP, dest, WRITEMASK_Z,
- pfs_zero, temp,
- negate(swizzle(keep(temp), Y, Y, Y, Y)),
+ pfs_zero, temp[0],
+ negate(swizzle(keep(temp[0]), Y, Y, Y, Y)),
flags);
emit_arith(rp, PFS_OP_MAD, dest,
WRITEMASK_X | WRITEMASK_W,
@@ -1495,7 +1488,7 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
pfs_one,
pfs_zero,
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_LRP:
src[0] = t_src(rp, fpi->SrcReg[0]);
@@ -1506,14 +1499,14 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
* MAD temp, -tmp0, tmp2, tmp2
* MAD result, tmp0, tmp1, temp
*/
- temp = get_temp_reg(rp);
- emit_arith(rp, PFS_OP_MAD, temp, mask,
+ temp[0] = get_temp_reg(rp);
+ emit_arith(rp, PFS_OP_MAD, temp[0], mask,
negate(keep(src[0])), keep(src[2]), src[2],
0);
emit_arith(rp, PFS_OP_MAD, dest, mask,
- src[0], src[1], temp,
+ src[0], src[1], temp[0],
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_MAD:
src[0] = t_src(rp, fpi->SrcReg[0]);
@@ -1554,17 +1547,17 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
case OPCODE_POW:
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
src[1] = t_scalar_src(rp, fpi->SrcReg[1]);
- temp = get_temp_reg(rp);
- emit_arith(rp, PFS_OP_LG2, temp, WRITEMASK_W,
+ temp[0] = get_temp_reg(rp);
+ emit_arith(rp, PFS_OP_LG2, temp[0], WRITEMASK_W,
src[0], undef, undef,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W,
- temp, src[1], pfs_zero,
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_W,
+ temp[0], src[1], pfs_zero,
0);
emit_arith(rp, PFS_OP_EX2, dest, fpi->DstReg.WriteMask,
- temp, undef, undef,
+ temp[0], undef, undef,
0);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_RCP:
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
@@ -1580,107 +1573,91 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
break;
case OPCODE_SCS:
/*
- * cos using a parabola (see SIN):
- * cos(x):
- * x += PI/2
- * x = (x/(2*PI))+0.5
- * x = frac(x)
- * x = (x*2*PI)-PI
- * result = sin(x)
+ * scs using a parabola :
+ * scs(x):
+ * result.x = sin(-abs(x)+0.5*PI) (cos)
+ * result.y = sin(x) (sin)
+ *
*/
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
+ temp[1] = get_temp_reg(rp);
make_sin_const(rp);
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
- /* add 0.5*PI and do range reduction */
+ /* x = -abs(x)+0.5*PI */
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Z,
+ swizzle(rp->const_sin[0], Z, Z, Z, Z), //PI
+ pfs_half,
+ negate(abs(swizzle(keep(src[0]), X, X, X, X))),
+ 0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X|WRITEMASK_Y,
- swizzle(rp->const_sin[0], Z, Z, Z, Z),
- rp->const_sin[1],
+ /* C*x (sin) */
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_W,
+ swizzle(rp->const_sin[0], Y, Y, Y, Y),
swizzle(keep(src[0]), X, X, X, X),
+ pfs_zero,
0);
- emit_arith(rp, PFS_OP_CMP, temp, WRITEMASK_W,
- swizzle(rp->const_sin[0], Z, Z, Z, Z),
- negate(pfs_half),
- swizzle(keep(src[0]), X, X, X, X),
+ /* B*x, C*x (cos) */
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y,
+ swizzle(temp[0], Z, Z, Z, Z),
+ rp->const_sin[0],
+ pfs_zero,
0);
- emit_arith(rp, PFS_OP_CMP, temp, WRITEMASK_Z,
- swizzle(temp, X, X, X, X),
- swizzle(temp, Y, Y, Y, Y),
- swizzle(temp, W, W, W, W),
+ /* B*x (sin) */
+ emit_arith(rp, PFS_OP_MAD, temp[1], WRITEMASK_W,
+ swizzle(rp->const_sin[0], X, X, X, X),
+ keep(src[0]),
+ pfs_zero,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y,
- swizzle(temp, Z, Z, Z, Z),
- rp->const_sin[0],
- pfs_zero,
+ /* y = B*x + C*x*abs(x) (sin)*/
+ emit_arith(rp, PFS_OP_MAD, temp[1], WRITEMASK_Z,
+ absolute(src[0]),
+ swizzle(temp[0], W, W, W, W),
+ swizzle(temp[1], W, W, W, W),
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W,
- swizzle(temp, Y, Y, Y, Y),
- absolute(swizzle(temp, Z, Z, Z, Z)),
- swizzle(temp, X, X, X, X),
+ /* y = B*x + C*x*abs(x) (cos)*/
+ emit_arith(rp, PFS_OP_MAD, temp[1], WRITEMASK_W,
+ swizzle(temp[0], Y, Y, Y, Y),
+ absolute(swizzle(temp[0], Z, Z, Z, Z)),
+ swizzle(temp[0], X, X, X, X),
0);
- if(mask & WRITEMASK_Y)
- {
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y,
- swizzle(keep(src[0]), X, X, X, X),
- rp->const_sin[0],
- pfs_zero,
- 0);
-
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(temp, Y, Y, Y, Y),
- absolute(swizzle(keep(src[0]), X, X, X, X)),
- swizzle(temp, X, X, X, X),
- 0);
- }
+ /* y*abs(y) - y (cos), y*abs(y) - y (sin) */
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y,
+ swizzle(temp[1], W, Z, Y, X),
+ absolute(swizzle(temp[1], W, Z, Y, X)),
+ negate(swizzle(temp[1], W, Z, Y, X)),
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Z,
- swizzle(temp, W, W, W, W),
- absolute(swizzle(temp, W, W, W, W)),
- negate(swizzle(temp, W, W, W, W)),
0);
- emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_X,
- swizzle(temp, Z, Z, Z, Z),
+ /* dest.xy = mad(temp.xy, P, temp2.wz) */
+ emit_arith(rp, PFS_OP_MAD, dest, mask & (WRITEMASK_X | WRITEMASK_Y),
+ temp[0],
swizzle(rp->const_sin[0], W, W, W, W),
- swizzle(temp, W, W, W, W),
+ swizzle(temp[1], W, Z, Y, X),
flags);
- if(mask & WRITEMASK_Y)
- {
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W,
- swizzle(temp, X, X, X, X),
- absolute(swizzle(temp, X, X, X, X)),
- negate(swizzle(temp, X, X, X, X)),
- 0);
-
- emit_arith(rp, PFS_OP_MAD, dest, WRITEMASK_Y,
- swizzle(temp, W, W, W, W),
- swizzle(rp->const_sin[0], W, W, W, W),
- swizzle(temp, X, X, X, X),
- flags);
- }
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
+ free_temp(rp, temp[1]);
break;
case OPCODE_SGE:
src[0] = t_src(rp, fpi->SrcReg[0]);
src[1] = t_src(rp, fpi->SrcReg[1]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
/* temp = src0 - src1
* dest.c = (temp.c < 0.0) ? 0 : 1
*/
- emit_arith(rp, PFS_OP_MAD, temp, mask,
+ emit_arith(rp, PFS_OP_MAD, temp[0], mask,
src[0], pfs_one, negate(src[1]),
0);
emit_arith(rp, PFS_OP_CMP, dest, mask,
- pfs_one, pfs_zero, temp,
+ pfs_one, pfs_zero, temp[0],
0);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_SIN:
/*
@@ -1690,73 +1667,74 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
* itself squared.
*/
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
make_sin_const(rp);
src[0] = t_scalar_src(rp, fpi->SrcReg[0]);
+
/* do range reduction */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
swizzle(keep(src[0]), X, X, X, X),
swizzle(rp->const_sin[1], Z, Z, Z, Z),
pfs_half,
0);
- emit_arith(rp, PFS_OP_FRC, temp, WRITEMASK_X,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_FRC, temp[0], WRITEMASK_X,
+ swizzle(temp[0], X, X, X, X),
undef,
undef,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Z,
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Z,
+ swizzle(temp[0], X, X, X, X),
swizzle(rp->const_sin[1], W, W, W, W), //2*PI
negate(swizzle(rp->const_sin[0], Z, Z, Z, Z)), //PI
0);
/* SIN */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X | WRITEMASK_Y,
- swizzle(temp, Z, Z, Z, Z),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X | WRITEMASK_Y,
+ swizzle(temp[0], Z, Z, Z, Z),
rp->const_sin[0],
pfs_zero,
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_X,
- swizzle(temp, Y, Y, Y, Y),
- absolute(swizzle(temp, Z, Z, Z, Z)),
- swizzle(temp, X, X, X, X),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_X,
+ swizzle(temp[0], Y, Y, Y, Y),
+ absolute(swizzle(temp[0], Z, Z, Z, Z)),
+ swizzle(temp[0], X, X, X, X),
0);
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_Y,
- swizzle(temp, X, X, X, X),
- absolute(swizzle(temp, X, X, X, X)),
- negate(swizzle(temp, X, X, X, X)),
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_Y,
+ swizzle(temp[0], X, X, X, X),
+ absolute(swizzle(temp[0], X, X, X, X)),
+ negate(swizzle(temp[0], X, X, X, X)),
0);
emit_arith(rp, PFS_OP_MAD, dest, mask,
- swizzle(temp, Y, Y, Y, Y),
+ swizzle(temp[0], Y, Y, Y, Y),
swizzle(rp->const_sin[0], W, W, W, W),
- swizzle(temp, X, X, X, X),
+ swizzle(temp[0], X, X, X, X),
flags);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_SLT:
src[0] = t_src(rp, fpi->SrcReg[0]);
src[1] = t_src(rp, fpi->SrcReg[1]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
/* temp = src0 - src1
* dest.c = (temp.c < 0.0) ? 1 : 0
*/
- emit_arith(rp, PFS_OP_MAD, temp, mask,
+ emit_arith(rp, PFS_OP_MAD, temp[0], mask,
src[0], pfs_one, negate(src[1]),
0);
emit_arith(rp, PFS_OP_CMP, dest, mask,
- pfs_zero, pfs_one, temp,
+ pfs_zero, pfs_one, temp[0],
0);
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
case OPCODE_SUB:
src[0] = t_src(rp, fpi->SrcReg[0]);
@@ -1777,9 +1755,9 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
case OPCODE_XPD: {
src[0] = t_src(rp, fpi->SrcReg[0]);
src[1] = t_src(rp, fpi->SrcReg[1]);
- temp = get_temp_reg(rp);
+ temp[0] = get_temp_reg(rp);
/* temp = src0.zxy * src1.yzx */
- emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_XYZ,
+ emit_arith(rp, PFS_OP_MAD, temp[0], WRITEMASK_XYZ,
swizzle(keep(src[0]), Z, X, Y, W),
swizzle(keep(src[1]), Y, Z, X, W),
pfs_zero,
@@ -1790,10 +1768,10 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
emit_arith(rp, PFS_OP_MAD, dest, mask & WRITEMASK_XYZ,
swizzle(src[0], Y, Z, X, W),
swizzle(src[1], Z, X, Y, W),
- negate(temp),
+ negate(temp[0]),
flags);
/* cleanup */
- free_temp(rp, temp);
+ free_temp(rp, temp[0]);
break;
}
default:
diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c
index c5ad0260457..6fa34ee482a 100644
--- a/src/mesa/drivers/dri/r300/r300_ioctl.c
+++ b/src/mesa/drivers/dri/r300/r300_ioctl.c
@@ -228,7 +228,7 @@ static void r300EmitClearState(GLcontext * ctx)
e32(0);
R300_STATECHANGE(r300, unk221C);
- reg_start(0x221C, 0);
+ reg_start(R300_VAP_UNKNOWN_221C, 0);
e32(R300_221C_CLEAR);
R300_STATECHANGE(r300, ps);
diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h
index 9f636ec1d2e..69bc994cf66 100644
--- a/src/mesa/drivers/dri/r300/r300_reg.h
+++ b/src/mesa/drivers/dri/r300/r300_reg.h
@@ -63,6 +63,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R300_SE_VPORT_ZOFFSET 0x1DAC
+/*
+ * Vertex Array Processing (VAP) Control
+ * Stolen from r200 code from Christoph Brill (It's a guess!)
+ */
+#define R300_VAP_CNTL 0x2080
+
/* This register is written directly and also starts data section
* in many 3d CP_PACKET3's
*/
@@ -135,7 +141,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* gap */
-#define R300_VAP_CNTL 0x2140
+#define R300_VAP_CNTL_STATUS 0x2140
# define R300_VC_NO_SWAP (0 << 0)
# define R300_VC_16BIT_SWAP (1 << 0)
# define R300_VC_32BIT_SWAP (2 << 0)
@@ -538,6 +544,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Some sort of scale or clamp value for texcoordless textures. */
#define R300_RE_UNK4238 0x4238
+/* Something shade related */
+#define R300_RE_SHADE 0x4274
+
#define R300_RE_SHADE_MODEL 0x4278
# define R300_RE_SHADE_MODEL_SMOOTH 0x3aaaa
# define R300_RE_SHADE_MODEL_FLAT 0x39595
@@ -1273,6 +1282,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_BLEND_MASK (63)
# define R300_SRC_BLEND_SHIFT (16)
# define R300_DST_BLEND_SHIFT (24)
+#define R300_RB3D_BLEND_COLOR 0x4E10
#define R300_RB3D_COLORMASK 0x4E0C
# define R300_COLORMASK0_B (1<<0)
# define R300_COLORMASK0_G (1<<1)
@@ -1378,6 +1388,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* 16 bit format or some aditional bit ? */
# define R300_DEPTH_FORMAT_UNK32 (32 << 0)
+#define R300_RB3D_EARLY_Z 0x4F14
+# define R300_EARLY_Z_DISABLE (0 << 0)
+# define R300_EARLY_Z_ENABLE (1 << 0)
+
/* gap */
#define R300_RB3D_DEPTHOFFSET 0x4F20
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index b30ece160a0..0e33e51ef3b 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -328,24 +328,24 @@ static void r300UpdateCulling(GLcontext* ctx)
static void update_early_z(GLcontext *ctx)
{
- /* updates register 0x4f14
- if depth test is not enabled it should be 0x00000000
- if depth is enabled and alpha not it should be 0x00000001
- if depth and alpha is enabled it should be 0x00000000
+ /* updates register R300_RB3D_EARLY_Z (0x4F14)
+ if depth test is not enabled it should be R300_EARLY_Z_DISABLE
+ if depth is enabled and alpha not it should be R300_EARLY_Z_ENABLE
+ if depth and alpha is enabled it should be R300_EARLY_Z_DISABLE
*/
r300ContextPtr r300 = R300_CONTEXT(ctx);
R300_STATECHANGE(r300, unk4F10);
if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS)
/* disable early Z */
- r300->hw.unk4F10.cmd[2] = 0x00000000;
+ r300->hw.unk4F10.cmd[2] = R300_EARLY_Z_DISABLE;
else {
if (ctx->Depth.Test && ctx->Depth.Func != GL_NEVER)
/* enable early Z */
- r300->hw.unk4F10.cmd[2] = 0x00000001;
+ r300->hw.unk4F10.cmd[2] = R300_EARLY_Z_ENABLE;
else
/* disable early Z */
- r300->hw.unk4F10.cmd[2] = 0x00000000;
+ r300->hw.unk4F10.cmd[2] = R300_EARLY_Z_DISABLE;
}
}
diff --git a/src/mesa/drivers/dri/r300/radeon_mm.c b/src/mesa/drivers/dri/r300/radeon_mm.c
index f86a1b4e72e..32ed1f43939 100644
--- a/src/mesa/drivers/dri/r300/radeon_mm.c
+++ b/src/mesa/drivers/dri/r300/radeon_mm.c
@@ -283,7 +283,7 @@ static void emit_lin_cp(r300ContextPtr rmesa, unsigned long dst, unsigned long s
size -= cp_size;
}
- reg_start(0x4e4c,0);
+ reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
e32(0x0000000a);
reg_start(0x342c,0);