From: Ben Skeggs Date: Wed, 8 Jun 2005 15:05:19 +0000 (+0000) Subject: - Secondary colour X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2d2f5a4b19a95477e1cf6915963fe9fdbfc461f7;p=mesa.git - Secondary colour - Calculate tc_count in EmitArrays (enabled units != nr texcoords). --- diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c index 599facee31a..19dab8f84b6 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;ictx->Const.MaxTextureUnits;i++) { - if (InputsRead & (FRAG_BIT_TEX0 << i)) { - rp->hwreg_in_use |= (1<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<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 676565112c0..6f8a7129e06 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 d9a10b0a068..946bf09ae6d 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<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;iConst.MaxTextureUnits;i++) { if (OutputsWritten & (hw_tcl_on ? (1 << (VERT_RESULT_TEX0+i)) : (_TNL_BIT_TEX0<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<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<