r300/r500: emit flush inside vap_cntl state atom
authorDave Airlie <airlied@redhat.com>
Tue, 27 May 2008 07:08:03 +0000 (17:08 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 27 May 2008 07:08:03 +0000 (17:08 +1000)
Not sure if this is a good or bad plan, it certainly doesn't make things worse here.

src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_ioctl.c
src/mesa/drivers/dri/r300/r300_state.c

index fc1b95b..535866e 100644 (file)
@@ -319,8 +319,10 @@ void r300InitCmdBuf(r300ContextPtr r300)
        /* Initialize state atoms */
        ALLOC_STATE(vpt, always, R300_VPT_CMDSIZE, 0);
        r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmdpacket0(R300_SE_VPORT_XSCALE, 6);
-       ALLOC_STATE(vap_cntl, always, 2, 0);
-       r300->hw.vap_cntl.cmd[0] = cmdpacket0(R300_VAP_CNTL, 1);
+       ALLOC_STATE(vap_cntl, always, R300_VAP_CNTL_SIZE, 0);
+       r300->hw.vap_cntl.cmd[R300_VAP_CNTL_FLUSH] = cmdpacket0(R300_VAP_PVS_STATE_FLUSH_REG, 1);
+       r300->hw.vap_cntl.cmd[R300_VAP_CNTL_FLUSH_1] = 0;
+       r300->hw.vap_cntl.cmd[R300_VAP_CNTL_CMD] = cmdpacket0(R300_VAP_CNTL, 1);
        if (is_r500) {
            ALLOC_STATE(vap_index_offset, always, 2, 0);
            r300->hw.vap_index_offset.cmd[0] = cmdpacket0(R500_VAP_INDEX_OFFSET, 1);
index eba93e4..53882b6 100644 (file)
@@ -427,6 +427,12 @@ struct r300_state_atom {
 #define R300_ZB_PITCH          2
 #define R300_ZB_CMDSIZE                3
 
+#define R300_VAP_CNTL_FLUSH     0
+#define R300_VAP_CNTL_FLUSH_1   1
+#define R300_VAP_CNTL_CMD       2
+#define R300_VAP_CNTL_INSTR     3
+#define R300_VAP_CNTL_SIZE      4
+
 #define R300_VPI_CMD_0         0
 #define R300_VPI_INSTR_0       1
 #define R300_VPI_CMDSIZE       1025    /* 256 16 byte instructions */
index cc85d45..b022545 100644 (file)
@@ -412,6 +412,8 @@ static void r300EmitClearState(GLcontext * ctx)
                    R500_ALU_RGBA_A_SWIZ_0);
        }
 
+       reg_start(R300_VAP_PVS_STATE_FLUSH_REG, 0);
+       e32(0x00000000);
        if (has_tcl) {
            vap_cntl = ((10 << R300_PVS_NUM_SLOTS_SHIFT) |
                        (5 << R300_PVS_NUM_CNTLRS_SHIFT) |
index 4092fcc..8857673 100644 (file)
@@ -1905,9 +1905,7 @@ static void r300VapCntl(r300ContextPtr rmesa, GLuint input_count, GLuint output_
     int pvs_num_cntrls;
 
     /* Flush PVS engine before changing PVS_NUM_SLOTS, PVS_NUM_CNTRLS.
-     * See r500 docs 6.5.2 */
-    reg_start(R300_VAP_PVS_STATE_FLUSH_REG, 0);
-    e32(0x00000000);
+     * See r500 docs 6.5.2 - done in emit */
 
     /* avoid division by zero */
     if (input_count == 0) input_count = 1;
@@ -1924,31 +1922,31 @@ static void r300VapCntl(r300ContextPtr rmesa, GLuint input_count, GLuint output_
 
     R300_STATECHANGE(rmesa, vap_cntl);
     if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
-       rmesa->hw.vap_cntl.cmd[1] = 
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] = 
            (pvs_num_slots << R300_PVS_NUM_SLOTS_SHIFT) |
            (pvs_num_cntrls << R300_PVS_NUM_CNTLRS_SHIFT) |
            (12 << R300_VF_MAX_VTX_NUM_SHIFT);
        if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
-           rmesa->hw.vap_cntl.cmd[1] |= R500_TCL_STATE_OPTIMIZATION;
+           rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= R500_TCL_STATE_OPTIMIZATION;
     } else
        /* not sure about non-tcl */
-       rmesa->hw.vap_cntl.cmd[1] = ((10 << R300_PVS_NUM_SLOTS_SHIFT) |
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] = ((10 << R300_PVS_NUM_SLOTS_SHIFT) |
                                    (5 << R300_PVS_NUM_CNTLRS_SHIFT) |
                                    (5 << R300_VF_MAX_VTX_NUM_SHIFT));
 
     if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV515)
-       rmesa->hw.vap_cntl.cmd[1] |= (2 << R300_PVS_NUM_FPUS_SHIFT);
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (2 << R300_PVS_NUM_FPUS_SHIFT);
     else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV530) ||
             (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV560))
-       rmesa->hw.vap_cntl.cmd[1] |= (5 << R300_PVS_NUM_FPUS_SHIFT);
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (5 << R300_PVS_NUM_FPUS_SHIFT);
     else if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R420)
-       rmesa->hw.vap_cntl.cmd[1] |= (6 << R300_PVS_NUM_FPUS_SHIFT);
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (6 << R300_PVS_NUM_FPUS_SHIFT);
     else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R520) ||
             (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R580) ||
             (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV570))
-       rmesa->hw.vap_cntl.cmd[1] |= (8 << R300_PVS_NUM_FPUS_SHIFT);
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (8 << R300_PVS_NUM_FPUS_SHIFT);
     else
-       rmesa->hw.vap_cntl.cmd[1] |= (4 << R300_PVS_NUM_FPUS_SHIFT);
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (4 << R300_PVS_NUM_FPUS_SHIFT);
 
 }
 
@@ -2362,6 +2360,7 @@ static void r300ResetHwState(r300ContextPtr r300)
 
        r300->hw.zb_hiz_pitch.cmd[1] = 0;
 
+       r300VapCntl(r300, 0, 0, 0);
        if (has_tcl) {
                r300->hw.vps.cmd[R300_VPS_ZERO_0] = 0;
                r300->hw.vps.cmd[R300_VPS_ZERO_1] = 0;