r500: Fix blend color.
authorNicolai Haehnle <nhaehnle@gmail.com>
Sat, 5 Jul 2008 07:31:44 +0000 (09:31 +0200)
committerNicolai Haehnle <nhaehnle@gmail.com>
Sat, 5 Jul 2008 16:04:09 +0000 (18:04 +0200)
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_state.c

index d378045b9834fc1987513a608d3a221587ebbced..4dc31614492c28b5485c624691e98662c7344735 100644 (file)
@@ -405,7 +405,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
                ALLOC_STATE(ri, always, R500_RI_CMDSIZE, 0);
                r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(R500_RS_IP_0, 16);
                for (i = 0; i < 8; i++) {
-                       r300->hw.ri.cmd[R300_RI_CMD_0 + i +1] = 
+                       r300->hw.ri.cmd[R300_RI_CMD_0 + i +1] =
                          (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_S_SHIFT) |
                           (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_T_SHIFT) |
                           (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_R_SHIFT) |
@@ -470,8 +470,13 @@ void r300InitCmdBuf(r300ContextPtr r300)
        r300->hw.bld.cmd[R300_BLD_CMD_0] = cmdpacket0(R300_RB3D_CBLEND, 2);
        ALLOC_STATE(cmk, always, R300_CMK_CMDSIZE, 0);
        r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(RB3D_COLOR_CHANNEL_MASK, 1);
-       ALLOC_STATE(blend_color, always, 4, 0);
-       r300->hw.blend_color.cmd[0] = cmdpacket0(R300_RB3D_BLEND_COLOR, 3);
+       if (is_r500) {
+               ALLOC_STATE(blend_color, always, 3, 0);
+               r300->hw.blend_color.cmd[0] = cmdpacket0(R500_RB3D_CONSTANT_COLOR_AR, 2);
+       } else {
+               ALLOC_STATE(blend_color, always, 2, 0);
+               r300->hw.blend_color.cmd[0] = cmdpacket0(R300_RB3D_BLEND_COLOR, 1);
+       }
        ALLOC_STATE(cb, always, R300_CB_CMDSIZE, 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);
index 592ee9ccc1024e473b0c40ef1f9aa9fb59bc3679..0f7c179de84c203f742b61425e11eb36ddda058d 100644 (file)
@@ -70,20 +70,28 @@ extern void _tnl_UpdateFixedFunctionProgram(GLcontext * ctx);
 
 static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
 {
-       GLubyte color[4];
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
 
        R300_STATECHANGE(rmesa, blend_color);
 
-       CLAMPED_FLOAT_TO_UBYTE(color[0], cf[0]);
-       CLAMPED_FLOAT_TO_UBYTE(color[1], cf[1]);
-       CLAMPED_FLOAT_TO_UBYTE(color[2], cf[2]);
-       CLAMPED_FLOAT_TO_UBYTE(color[3], cf[3]);
+       if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+               GLuint r = IROUND(cf[0]*1023.0f);
+               GLuint g = IROUND(cf[1]*1023.0f);
+               GLuint b = IROUND(cf[2]*1023.0f);
+               GLuint a = IROUND(cf[3]*1023.0f);
 
-       rmesa->hw.blend_color.cmd[1] = PACK_COLOR_8888(color[3], color[0],
-                                                      color[1], color[2]);
-       rmesa->hw.blend_color.cmd[2] = 0;
-       rmesa->hw.blend_color.cmd[3] = 0;
+               rmesa->hw.blend_color.cmd[1] = r | (a << 16);
+               rmesa->hw.blend_color.cmd[2] = b | (g << 16);
+       } else {
+               GLubyte color[4];
+               CLAMPED_FLOAT_TO_UBYTE(color[0], cf[0]);
+               CLAMPED_FLOAT_TO_UBYTE(color[1], cf[1]);
+               CLAMPED_FLOAT_TO_UBYTE(color[2], cf[2]);
+               CLAMPED_FLOAT_TO_UBYTE(color[3], cf[3]);
+
+               rmesa->hw.blend_color.cmd[1] = PACK_COLOR_8888(color[3], color[0],
+                                                       color[1], color[2]);
+       }
 }
 
 /**