From: Dave Airlie Date: Wed, 28 May 2008 00:20:14 +0000 (+1000) Subject: Merge branch 'r500-support' X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=261a15cf6389eba434d6857e78b524707803ed08;p=mesa.git Merge branch 'r500-support' Bring in all the r500 3D code into master should be as stable as the r300 code it is landing on top off. Conflicts: src/mesa/drivers/dri/r300/r300_reg.h src/mesa/drivers/dri/r300/r300_state.c src/mesa/drivers/dri/radeon/radeon_screen.c --- 261a15cf6389eba434d6857e78b524707803ed08 diff --cc src/mesa/drivers/dri/r300/r300_reg.h index d2a81750fb4,8b0da0db4e0..acdd72b74b4 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@@ -67,15 -67,16 +67,15 @@@ USE OR OTHER DEALINGS IN THE SOFTWARE /* * 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 diff --cc src/mesa/drivers/dri/r300/r300_state.c index aa0de4e7838,6f1f4aac74a..cb39ce01106 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@@ -1648,44 -1891,58 +1891,60 @@@ static inline void r300SetupVertexProgr } } - /* 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)