From 2091abd0a70ca332326b6be8b3f3102f50eaabb3 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 28 Jan 2014 09:55:24 -0500 Subject: [PATCH] XXX: Program RASTER_CONFIG for harvested GPUs --- src/gallium/drivers/radeonsi/si_state.c | 86 +++++++++++++++++++++-- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 7 ++ src/gallium/winsys/radeon/drm/radeon_winsys.h | 2 + 3 files changed, 90 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 42dfbc5..1d8929b 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -3136,6 +3136,17 @@ void si_init_state_functions(struct si_context *sctx) sctx->b.b.draw_vbo = si_draw_vbo; } +static unsigned pkr_mask_to_map(unsigned mask) +{ + switch(mask & 0x3) { + case 0x0: + case 0x1: return 0x0; + case 0x2: return 0x3; + case 0x3: return 0x2; + } + return 0; +} + void si_init_config(struct si_context *sctx) { struct si_pm4_state *pm4 = si_pm4_alloc_state(sctx); @@ -3203,24 +3214,89 @@ void si_init_config(struct si_context *sctx) break; } } else { + unsigned raster_config = 0; + unsigned default_rb_mask = 0; + unsigned rb_mask = sctx->screen->b.info.si_backend_enabled_mask; switch (sctx->screen->b.family) { case CHIP_TAHITI: case CHIP_PITCAIRN: - si_pm4_set_reg(pm4, R_028350_PA_SC_RASTER_CONFIG, 0x2a00126a); + raster_config = 0x2a00126a; break; case CHIP_VERDE: - si_pm4_set_reg(pm4, R_028350_PA_SC_RASTER_CONFIG, 0x0000124a); + raster_config = 0x0000124a; break; case CHIP_OLAND: - si_pm4_set_reg(pm4, R_028350_PA_SC_RASTER_CONFIG, 0x00000082); + raster_config = 0x00000082; break; case CHIP_HAINAN: - si_pm4_set_reg(pm4, R_028350_PA_SC_RASTER_CONFIG, 0x00000000); + raster_config = 0x00000000; break; default: - si_pm4_set_reg(pm4, R_028350_PA_SC_RASTER_CONFIG, 0x00000000); + raster_config = 0x00000000; break; } + unsigned sh_per_se = 2; + unsigned pkr_mask = (sh_per_se | 0x1); + fprintf(stderr, "Default raster_config = 0x%x\n", raster_config); + if (rb_mask) { + /* XXX: I can't figure out what the *_XSEL and *_YSEL + * fields are for, so I'm leaving them as their default + * values. */ + unsigned se0_pkr0 = rb_mask & pkr_mask; + unsigned se0_pkr1 = (rb_mask >>= sh_per_se) & pkr_mask; + unsigned se1_pkr0 = (rb_mask >>= sh_per_se) & pkr_mask; + unsigned se1_pkr1 = (rb_mask >>= sh_per_se) & pkr_mask; + unsigned se_map = 0; + unsigned se0_pkr_map = 0; + unsigned se1_pkr_map = 0; + unsigned se0_pkr0_rb_map = 0; + unsigned se0_pkr1_rb_map = 0; + unsigned se1_pkr0_rb_map = 0; + unsigned se1_pkr1_rb_map = 0; + if (!se0_pkr0 && !se0_pkr1) { + /* se0 disabled */ + se_map |= 0x1; + } + if (se1_pkr0 || se1_pkr1) { + /* se1 enabled */ + se_map |= 0x2; + } + if (!se0_pkr0) { + /* se0 pkr0 disabled */ + se0_pkr_map |= 0x1; + } + if (se0_pkr1) { + /* se0 pkr1 enabled */ + se0_pkr_map |= 0x2; + } + if (!se1_pkr0) { + /* se1 pkr1 disabled */ + se1_pkr_map |= 0x1; + } + if (se1_pkr1) { + /* se1 pkr1 enabled */ + se1_pkr_map |= 0x2; + } + + se0_pkr0_rb_map = pkr_mask_to_map(se0_pkr0); + se0_pkr1_rb_map = pkr_mask_to_map(se0_pkr1); + se1_pkr0_rb_map = pkr_mask_to_map(se1_pkr0); + se1_pkr1_rb_map = pkr_mask_to_map(se1_pkr1); + + assert(!se0_pkr0 || !se1_pkr0 || (se0_pkr0_rb_map == se1_pkr0_rb_map)); + assert(!se0_pkr1 || !se1_pkr1 || (se0_pkr1_rb_map == se1_pkr1_rb_map)); + raster_config &= C_028350_RB_MAP_PKR0; + raster_config |= S_028350_RB_MAP_PKR0(se0_pkr0_rb_map); + raster_config &= C_028350_RB_MAP_PKR1; + raster_config |= S_028350_RB_MAP_PKR1(se0_pkr1_rb_map); + raster_config &= C_028350_PKR_MAP; + raster_config |= S_028350_PKR_MAP(se0_pkr_map); + raster_config &= C_028350_SE_MAP; + raster_config |= S_028350_SE_MAP(se_map); + } + fprintf(stderr, "rb mask = %u\n", sctx->screen->b.info.si_backend_enabled_mask); + fprintf(stderr, "Final raster_config = 0x%x\n", raster_config); + si_pm4_set_reg(pm4, R_028350_PA_SC_RASTER_CONFIG, raster_config); } si_pm4_set_reg(pm4, R_028204_PA_SC_WINDOW_SCISSOR_TL, S_028204_WINDOW_OFFSET_DISABLE(1)); diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c index 427ee7d..2aa1cbe 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c @@ -97,6 +97,10 @@ #define RADEON_INFO_RING_WORKING 0x15 #endif +#ifndef RADEON_INFO_SI_BACKEND_ENABLED_MASK +#define RADEON_INFO_SI_BACKEND_ENABLED_MASK 0x19 +#endif + #ifndef RADEON_CS_RING_UVD #define RADEON_CS_RING_UVD 3 #endif @@ -361,6 +365,9 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws) ws->info.gart_size = gem_info.gart_size; ws->info.vram_size = gem_info.vram_size; + radeon_get_drm_value(ws->fd, RADEON_INFO_SI_BACKEND_ENABLED_MASK, NULL, + &ws->info.si_backend_enabled_mask); + ws->num_cpus = sysconf(_SC_NPROCESSORS_ONLN); /* Generation-specific queries. */ diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h index 55f60d3..358cbc6 100644 --- a/src/gallium/winsys/radeon/drm/radeon_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h @@ -198,6 +198,8 @@ struct radeon_info { boolean si_tile_mode_array_valid; uint32_t si_tile_mode_array[32]; + uint32_t si_backend_enabled_mask; + boolean cik_macrotile_mode_array_valid; uint32_t cik_macrotile_mode_array[16]; -- 1.8.1.5