summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Skeggs <darktama@iinet.net.au>2005-06-08 15:05:19 +0000
committerBen Skeggs <darktama@iinet.net.au>2005-06-08 15:05:19 +0000
commit2d2f5a4b19a95477e1cf6915963fe9fdbfc461f7 (patch)
tree3ad1a2814e38c9a851cfc04a67e33e0d42a51249 /src
parentee7ad16f3f06140ebbeb195540c15b7016003d62 (diff)
- Secondary colour
- Calculate tc_count in EmitArrays (enabled units != nr texcoords).
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog.c23
-rw-r--r--src/mesa/drivers/dri/r300/r300_ioctl.c2
-rw-r--r--src/mesa/drivers/dri/r300/r300_maos.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_reg.h7
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c59
5 files changed, 64 insertions, 31 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c
index 599facee31..19dab8f84b 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog.c
@@ -941,24 +941,29 @@ void init_program(struct r300_fragment_program *rp)
/* Work out what temps the Mesa inputs correspond to, this must match
* what setup_rs_unit does, which shouldn't be a problem as rs_unit
* configures itself based on the fragprog's InputsRead
+ *
+ * I'm using get_hw_temp() here now rather than doing this manually.
+ * This depends on get_hw_temp() allocating registers in order, starting
+ * at 0 (which it currently does).
*/
/* Texcoords come first */
for (i=0;i<rp->ctx->Const.MaxTextureUnits;i++) {
- if (InputsRead & (FRAG_BIT_TEX0 << i)) {
- rp->hwreg_in_use |= (1<<fp_reg);
- rp->inputs[FRAG_ATTRIB_TEX0+i] = fp_reg++;
- }
+ if (InputsRead & (FRAG_BIT_TEX0 << i))
+ rp->inputs[FRAG_ATTRIB_TEX0+i] = get_hw_temp(rp);
}
InputsRead &= ~FRAG_BITS_TEX_ANY;
/* Then primary colour */
- if (InputsRead & FRAG_BIT_COL0) {
- rp->hwreg_in_use |= (1<<fp_reg);
- rp->inputs[FRAG_ATTRIB_COL0] = fp_reg++;
- }
+ if (InputsRead & FRAG_BIT_COL0)
+ rp->inputs[FRAG_ATTRIB_COL0] = get_hw_temp(rp);
InputsRead &= ~FRAG_BIT_COL0;
-
+
+ /* Secondary color */
+ if (InputsRead & FRAG_BIT_COL1)
+ rp->inputs[FRAG_ATTRIB_COL1] = get_hw_temp(rp);
+ InputsRead &= ~FRAG_BIT_COL1;
+
/* Anything else */
if (InputsRead) {
WARN_ONCE("Don't know how to handle inputs 0x%x\n", InputsRead);
diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c
index 676565112c..6f8a7129e0 100644
--- a/src/mesa/drivers/dri/r300/r300_ioctl.c
+++ b/src/mesa/drivers/dri/r300/r300_ioctl.c
@@ -143,7 +143,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
R300_STATECHANGE(r300, rc);
/* The second constant is needed to get glxgears display anything .. */
- r300->hw.rc.cmd[1] = R300_RS_CNTL_0_UNKNOWN_7 | R300_RS_CNTL_0_UNKNOWN_18;
+ r300->hw.rc.cmd[1] = (1 << R300_RS_CNTL_CI_CNT_SHIFT) | R300_RS_CNTL_0_UNKNOWN_18;
r300->hw.rc.cmd[2] = 0;
R300_STATECHANGE(r300, rr);
diff --git a/src/mesa/drivers/dri/r300/r300_maos.c b/src/mesa/drivers/dri/r300/r300_maos.c
index d9a10b0a06..946bf09ae6 100644
--- a/src/mesa/drivers/dri/r300/r300_maos.c
+++ b/src/mesa/drivers/dri/r300/r300_maos.c
@@ -385,6 +385,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
}
#endif
+ r300->state.texture.tc_count = 0;
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
if (inputs & (_TNL_BIT_TEX0 << i)) {
CONFIGURE_AOS(i_tex[i], AOS_FORMAT_FLOAT,
@@ -393,6 +394,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
count);
vic_1 |= R300_INPUT_CNTL_TC0 << i;
+ r300->state.texture.tc_count++;
}
}
@@ -536,6 +538,8 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
if(inputs & _TNL_BIT_COLOR0)
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
+ if(inputs & _TNL_BIT_COLOR1)
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
for(i=0;i < ctx->Const.MaxTextureUnits;i++)
if(inputs & (_TNL_BIT_TEX0<<i))
diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h
index 7b9fd1c955..2dd3cb67cb 100644
--- a/src/mesa/drivers/dri/r300/r300_reg.h
+++ b/src/mesa/drivers/dri/r300/r300_reg.h
@@ -502,7 +502,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
#define R300_RS_CNTL_0 0x4300
# define R300_RS_CNTL_TC_CNT_SHIFT 2
# define R300_RS_CNTL_TC_CNT_MASK (7 << 2)
-# define R300_RS_CNTL_0_UNKNOWN_7 (1 << 7) /* Number of color interpolators used (shifted by 7) */
+# define R300_RS_CNTL_CI_CNT_SHIFT 7 /* number of color interpolators used */
# define R300_RS_CNTL_0_UNKNOWN_18 (1 << 18)
/* Guess: RS_CNTL_1 holds the index of the highest used RS_ROUTE_n register. */
#define R300_RS_CNTL_1 0x4304
@@ -562,6 +562,11 @@ I am fairly certain that they are correct unless stated otherwise in comments.
# define R300_RS_ROUTE_0_COLOR (1 << 14)
# define R300_RS_ROUTE_0_COLOR_DEST_SHIFT 17
# define R300_RS_ROUTE_0_COLOR_DEST_MASK (31 << 17) /* GUESS */
+/* As above, but for secondary color */
+# define R300_RS_ROUTE_1_COLOR1 (1 << 14)
+# define R300_RS_ROUTE_1_COLOR1_DEST_SHIFT 17
+# define R300_RS_ROUTE_1_COLOR1_DEST_MASK (31 << 17)
+# define R300_RS_ROUTE_1_UNKNOWN11 (1 << 11)
/* END */
/* BEGIN: Scissors and cliprects
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 4cadfd3f02..72418154c4 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1030,8 +1030,6 @@ void r300_setup_textures(GLcontext *ctx)
R300_STATECHANGE(r300, tex.unknown4);
R300_STATECHANGE(r300, tex.border_color);
- r300->state.texture.tc_count=0;
-
r300->hw.txe.cmd[R300_TXE_ENABLE]=0x0;
mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
@@ -1053,7 +1051,6 @@ void r300_setup_textures(GLcontext *ctx)
if(TMU_ENABLED(ctx, i)) {
t=r300->state.texture.unit[i].texobj;
//fprintf(stderr, "format=%08x\n", r300->state.texture.unit[i].format);
- r300->state.texture.tc_count++;
if(t == NULL){
fprintf(stderr, "Texture unit %d enabled, but corresponding texobj is NULL, using default object.\n", i);
@@ -1102,7 +1099,6 @@ void r300_setup_textures(GLcontext *ctx)
void r300_setup_rs_unit(GLcontext *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
- int i, vp_reg, fp_reg, in_texcoords;
/* I'm still unsure if these are needed */
GLuint interp_magic[8] = {
0x00,
@@ -1116,7 +1112,10 @@ void r300_setup_rs_unit(GLcontext *ctx)
};
GLuint OutputsWritten;
GLuint InputsRead;
-
+ int vp_reg, fp_reg, high_rr;
+ int in_texcoords, col_interp_nr;
+ int i;
+
if(hw_tcl_on)
OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
else
@@ -1128,13 +1127,14 @@ void r300_setup_rs_unit(GLcontext *ctx)
fprintf(stderr, "No ctx->FragmentProgram._Current!!\n");
return; /* This should only ever happen once.. */
}
- /* This needs to be rewritten - it is a hack at best */
+
R300_STATECHANGE(r300, ri);
R300_STATECHANGE(r300, rc);
R300_STATECHANGE(r300, rr);
- vp_reg = fp_reg = in_texcoords = 0;
+ vp_reg = fp_reg = in_texcoords = col_interp_nr = high_rr = 0;
r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0;
+ r300->hw.rr.cmd[R300_RR_ROUTE_1] = 0;
for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
if (OutputsWritten & (hw_tcl_on ? (1 << (VERT_RESULT_TEX0+i)) : (_TNL_BIT_TEX0<<i)))
@@ -1151,7 +1151,8 @@ void r300_setup_rs_unit(GLcontext *ctx)
| R300_RS_ROUTE_ENABLE
| i /* source INTERP */
| (fp_reg << R300_RS_ROUTE_DEST_SHIFT);
-
+ high_rr = fp_reg;
+
if (OutputsWritten & (hw_tcl_on ? (1 << (VERT_RESULT_TEX0+i)) : (_TNL_BIT_TEX0<<i))) {
vp_reg++;
} else {
@@ -1168,25 +1169,34 @@ void r300_setup_rs_unit(GLcontext *ctx)
if (InputsRead & FRAG_BIT_COL0) {
if (!(OutputsWritten & (hw_tcl_on ? (1<<VERT_RESULT_COL0) : _TNL_BIT_COLOR0)))
fprintf(stderr, "fragprog wants col0, vp doesn't provide it\n");
+
r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0
| R300_RS_ROUTE_0_COLOR
- | (fp_reg << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
+ | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
InputsRead &= ~FRAG_BIT_COL0;
+ col_interp_nr++;
}
-
+
+ if (InputsRead & FRAG_BIT_COL1) {
+ if (!(OutputsWritten & (hw_tcl_on ? (1<<VERT_RESULT_COL1) : _TNL_BIT_COLOR1)))
+ fprintf(stderr, "fragprog wants col1, vp doesn't provide it\n");
+
+ r300->hw.rr.cmd[R300_RR_ROUTE_1] |= R300_RS_ROUTE_1_UNKNOWN11
+ | R300_RS_ROUTE_1_COLOR1
+ | (fp_reg++ << R300_RS_ROUTE_1_COLOR1_DEST_SHIFT);
+ InputsRead &= ~FRAG_BIT_COL1;
+ if (high_rr < 1) high_rr = 1;
+ col_interp_nr++;
+ }
+
r300->hw.rc.cmd[1] = 0
| (in_texcoords << R300_RS_CNTL_TC_CNT_SHIFT)
- | R300_RS_CNTL_0_UNKNOWN_7
+ | (col_interp_nr << R300_RS_CNTL_CI_CNT_SHIFT)
| R300_RS_CNTL_0_UNKNOWN_18;
-
- if (r300->state.texture.tc_count > 0) {
- r300->hw.rr.cmd[R300_RR_CMD_0] = cmducs(R300_RS_ROUTE_0, fp_reg);
- r300->hw.rc.cmd[2] = 0xC0 | (fp_reg-1); /* index of highest RS_ROUTE used*/
- } else {
- r300->hw.rr.cmd[R300_RR_CMD_0] = cmducs(R300_RS_ROUTE_0, 1);
- r300->hw.rc.cmd[2] = 0x0;
- }
+ assert(high_rr >= 0);
+ r300->hw.rr.cmd[R300_RR_CMD_0] = cmducs(R300_RS_ROUTE_0, high_rr+1);
+ r300->hw.rc.cmd[2] = 0xC0 | high_rr;
if (InputsRead)
WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n", InputsRead);
@@ -1388,7 +1398,16 @@ void r300GenerateSimpleVertexShader(r300ContextPtr r300)
VSF_TMP(0)
)
o_reg += 2;
-
+
+ if (r300->state.render_inputs & _TNL_BIT_COLOR1) {
+ WRITE_OP(
+ EASY_VSF_OP(MUL, o_reg++, ALL, RESULT),
+ VSF_REG(r300->state.vap_reg.i_color[1]),
+ VSF_ATTR_UNITY(r300->state.vap_reg.i_color[1]),
+ VSF_UNITY(r300->state.vap_reg.i_color[1])
+ )
+ }
+
/* Pass through texture coordinates, if any */
for(i=0;i < r300->radeon.glCtx->Const.MaxTextureUnits;i++)
if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)){