r500: make tri-param work
authorDave Airlie <airlied@redhat.com>
Mon, 5 May 2008 08:05:59 +0000 (18:05 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 5 May 2008 08:05:59 +0000 (18:05 +1000)
This makes constant work which are 32-bit on r500 unlike r300.

Switch MOV to using MAD no idea if we might have negative things MAX 0,-5 is
likely to do the wrong thing..

src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r500_fragprog.c

index 75f8910c3ea74814cba9048bd1c17f257c3b90cd..806e2755c538162407f7a0d6796d1bc75aa21fe1 100644 (file)
@@ -54,7 +54,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_state.h"
 
 // Set this to 1 for extremely verbose debugging of command buffers
-#define DEBUG_CMDBUF           0
+#define DEBUG_CMDBUF           1
 
 /**
  * Send the current command buffer via ioctl to the hardware.
index b79b5e99f69e851a5c76ce4da2005af9995dc2c2..a083db9bbce6dbecc5b6ebd73981b5487d3019a5 100644 (file)
@@ -2453,10 +2453,10 @@ static void r500SetupPixelShader(r300ContextPtr rmesa)
 
        R300_STATECHANGE(rmesa, r500fp_const);
        for (i = 0; i < fp->const_nr; i++) {
-               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = r300PackFloat24(fp->constant[i][0]);
-               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = r300PackFloat24(fp->constant[i][1]);
-               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat24(fp->constant[i][2]);
-               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = r300PackFloat24(fp->constant[i][3]);
+               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = r300PackFloat32(fp->constant[i][0]);
+               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = r300PackFloat32(fp->constant[i][1]);
+               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat32(fp->constant[i][2]);
+               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = r300PackFloat32(fp->constant[i][3]);
        }
        bump_r500fp_const_count(rmesa->hw.r500fp_const.cmd, fp->const_nr * 4);
 
index b08beb617ff5c8b168038f29b1ab69d94edca169..5d4412bb1fa05c9168504cab112fb9de6d2b36c7 100644 (file)
@@ -158,6 +158,8 @@ static GLuint make_src(struct r500_fragment_program *fp, struct prog_src_registe
                         * fragments don't get loaded right otherwise! */
                        reg = 0x0;
                        break;
+               case PROGRAM_STATE_VAR:
+               case PROGRAM_NAMED_PARAM:
                case PROGRAM_CONSTANT:
                        reg = emit_const4fv(fp, fp->mesa_program.Base.Parameters->
                                  ParameterValues[src.Index]);
@@ -440,8 +442,9 @@ static GLboolean parse_program(struct r500_fragment_program *fp)
                                break;
                        case OPCODE_MOV:
                                src[0] = make_src(fp, fpi->SrcReg[0]);
-                               /* We use MAX, but MIN, CND, and CMP also work.
-                                * Just remember to disable the OMOD! */
+
+                               /* changed to use MAD - not sure if we
+                                  ever have negative things which max will fail on */
                                fp->inst[counter].inst0 = R500_INST_TYPE_ALU
                                        | mask;
                                fp->inst[counter].inst1 = R500_RGB_ADDR0(src[0]);
@@ -449,14 +452,17 @@ static GLboolean parse_program(struct r500_fragment_program *fp)
                                fp->inst[counter].inst3 = R500_ALU_RGB_SEL_A_SRC0
                                        | R500_ALU_RGB_R_SWIZ_A_R | R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B
                                        | R500_ALU_RGB_SEL_B_SRC0
-                                       | R500_ALU_RGB_R_SWIZ_B_R | R500_ALU_RGB_G_SWIZ_B_G | R500_ALU_RGB_B_SWIZ_B_B
-                                       | R500_ALU_RGB_OMOD_DISABLE;
-                               fp->inst[counter].inst4 = R500_ALPHA_OP_MAX
+                                 | R500_ALU_RGB_R_SWIZ_B_1 | R500_ALU_RGB_G_SWIZ_B_1 | R500_ALU_RGB_B_SWIZ_B_1;
+
+                               fp->inst[counter].inst4 = R500_ALPHA_OP_MAD
                                        | R500_ALPHA_ADDRD(dest)
-                                       | R500_ALPHA_SEL_A_SRC0 | R500_ALPHA_SEL_B_SRC0
-                                       | R500_ALPHA_OMOD_DISABLE;
-                               fp->inst[counter].inst5 = R500_ALU_RGBA_OP_MAX
-                                       | R500_ALU_RGBA_ADDRD(dest);
+                                       | R500_ALPHA_SEL_A_SRC0 | R500_ALPHA_SEL_B_SRC0 
+                                 | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_1;
+
+                               fp->inst[counter].inst5 = R500_ALU_RGBA_OP_MAD
+                                       | R500_ALU_RGBA_ADDRD(dest)
+                                 | R500_ALU_RGBA_R_SWIZ_0 | R500_ALU_RGBA_G_SWIZ_0
+                                 | R500_ALU_RGBA_B_SWIZ_0 | R500_ALU_RGBA_A_SWIZ_0;
                                break;
                        case OPCODE_MUL:
                                src[0] = make_src(fp, fpi->SrcReg[0]);
@@ -593,7 +599,7 @@ static void init_program(r300ContextPtr r300, struct r500_fragment_program *fp)
        fp->cur_node = 0;
        fp->first_node_has_tex = 0;
        fp->const_nr = 0;
-       fp->max_temp_idx = 0;
+       fp->max_temp_idx = 64;
        fp->node[0].alu_end = -1;
        fp->node[0].tex_end = -1;