/*
* Vertex Array Processing (VAP) Control
- * Stolen from r200 code from Christoph Brill (It's a guess!)
*/
#define R300_VAP_CNTL 0x2080
- # define R300_VAP_CNTL__PVS_NUM_SLOTS__SHIFT 0
- # define R300_VAP_CNTL__PVS_NUM_CNTRLS__SHIFT 4
- # define R300_VAP_CNTL__PVS_NUM_FPUS__SHIFT 8
- # define R300_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT 18
- # define R500_VAP_CNTL__VAP_NO_RENDER (1<<17)
- # define R300_VAP_CNTL__DX_CLIP_SPACE_DEF (1<<22)
- # define R500_VAP_CNTL__TCL_STATE_OPTIMIZATION (1<<23)
+ # define R300_PVS_NUM_SLOTS_SHIFT 0
+ # define R300_PVS_NUM_CNTLRS_SHIFT 4
+ # define R300_PVS_NUM_FPUS_SHIFT 8
+ # define R300_VF_MAX_VTX_NUM_SHIFT 18
+ # define R300_GL_CLIP_SPACE_DEF (0 << 22)
+ # define R300_DX_CLIP_SPACE_DEF (1 << 22)
+ # define R500_TCL_STATE_OPTIMIZATION (1 << 23)
/* This register is written directly and also starts data section
* in many 3d CP_PACKET3's
}
}
- /* FIXME: move near the MIN2 define. */
-#define MIN3(a,b,c) ((a)<(b) ? MIN2(a, c): MIN2(b, c))
+#define MIN3(a, b, c) ((a) < (b) ? MIN2(a, c) : MIN2(b, c))
- /* FIXME: need to add a structure for per-card/chipset values; they are
- * currently hard-coded. */
-static void r300VapCntl(r300ContextPtr rmesa, GLuint input_count, GLuint output_count, GLuint temp_count)
++
+static void r300VapCntl(r300ContextPtr rmesa, GLuint input_count,
+ GLuint output_count, GLuint temp_count)
{
- int cmd_reserved = 0;
- int cmd_written = 0;
- drm_radeon_cmd_header_t *cmd = NULL;
-
- int vtx_mem_size = 72; /* FIXME: R3XX vs R5XX */
-
- /* Flush PVS engine before changing PVS_NUM_SLOTS, PVS_NUM_CNTRLS.
- * See r500 docs 6.5.2 */
- reg_start(R300_VAP_PVS_WAITIDLE, 0);
- e32(0x00000000);
-
- /* avoid division by zero */
- if (input_count == 0)
- input_count = 1;
- if (output_count == 0)
- output_count = 1;
- if (temp_count == 0)
- temp_count = 1;
-
- int pvs_num_slots =
- MIN3(10, vtx_mem_size / input_count, vtx_mem_size / output_count);
- int pvs_num_cntrls = MIN2(6, vtx_mem_size / temp_count);
-
- R300_STATECHANGE(rmesa, vap_cntl);
- rmesa->hw.vap_cntl.cmd[1] =
- (pvs_num_slots << R300_VAP_CNTL__PVS_NUM_SLOTS__SHIFT) |
- (pvs_num_cntrls << R300_VAP_CNTL__PVS_NUM_CNTRLS__SHIFT) |
- (4 << R300_VAP_CNTL__PVS_NUM_FPUS__SHIFT) |
- (12 << R300_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT) |
- R500_VAP_CNTL__TCL_STATE_OPTIMIZATION;
+ int vtx_mem_size;
+ int pvs_num_slots;
+ int pvs_num_cntrls;
+
+ /* Flush PVS engine before changing PVS_NUM_SLOTS, PVS_NUM_CNTRLS.
+ * See r500 docs 6.5.2 - done in emit */
+
+ /* avoid division by zero */
+ if (input_count == 0) input_count = 1;
+ if (output_count == 0) output_count = 1;
+ if (temp_count == 0) temp_count = 1;
+
+ if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+ vtx_mem_size = 128;
+ else
+ vtx_mem_size = 72;
+
+ pvs_num_slots = MIN3(10, vtx_mem_size/input_count, vtx_mem_size/output_count);
+ pvs_num_cntrls = MIN2(6, vtx_mem_size/temp_count);
+
+ R300_STATECHANGE(rmesa, vap_cntl);
+ if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
+ 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[R300_VAP_CNTL_INSTR] |= R500_TCL_STATE_OPTIMIZATION;
+ } else
+ /* not sure about non-tcl */
+ 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[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[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[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[R300_VAP_CNTL_INSTR] |= (8 << R300_PVS_NUM_FPUS_SHIFT);
+ else
+ rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (4 << R300_PVS_NUM_FPUS_SHIFT);
+
}
static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa)