Add r6xx/r7xx tiling support to the ddx
cover Add r6xx/r7xx tiling support to the ddx
These patches along with the drm and mesa patches enable tiling on r6xx/r7xx hardware.
Alex
PATCH 1/2 r6xx/r7xx: add support for tiling with kms
Requires radeon drm 2.5.0 and updated mesa.
Signed-off-by Alex Deucher <[email protected]>
--- src/drmmode_display.c | 7 ++- src/r600_exa.c | 3 + src/r600_state.h | 3 + src/r6xx_accel.c | 12 ++++-- src/radeon.h | 6 +++ src/radeon_dri2.c | 10 ++++- src/radeon_exa.c | 26 ++++++++++-- src/radeon_kms.c | 99 ++++++++++++++++++++++++++++++++++++++++++------ 8 files changed, 140 insertions(+), 26 deletions(-)
src/drmmode_display.c +5 -2
@@ -1099,8 +1099,11 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)if (!info->front_bo) goto fail; -if (info->allowColorTiling) - tiling_flags |=RADEON_TILING_MACRO ; +/* no tiled scanout on r6xx+ yet */ +if (info->allowColorTiling) { +if (info->ChipFamily <CHIP_FAMILY_R600 ) + tiling_flags |=RADEON_TILING_MACRO ; + }#if X_BYTE_ORDER ==X_BIG_ENDIAN switch (cpp) {case 4 :
src/r600_exa.c +3 -0
@@ -2305,6 +2305,9 @@ R600DrawInit(ScreenPtr pScreen) info->accel_state->exa->FinishAccess = RADEONFinishAccess_CS; info->accel_state->exa->UploadToScreen = R600UploadToScreenCS; info->accel_state->exa->DownloadFromScreen = R600DownloadFromScreenCS; +#if (EXA_VERSION_MAJOR ==2 &&EXA_VERSION_MINOR >=5 ) + info->accel_state->exa->CreatePixmap2 = RADEONEXACreatePixmap2; +#endif } else#endif #endif
src/r600_state.h +3 -0
@@ -339,6 +339,9 @@ R600SetAccelState(ScrnInfoPtr pScrn,extern Bool RADEONPrepareAccess_CS (PixmapPtr pPix,int index);extern void RADEONFinishAccess_CS (PixmapPtr pPix,int index);extern void *RADEONEXACreatePixmap (ScreenPtr pScreen,int size,int align); +extern void *RADEONEXACreatePixmap2 (ScreenPtr pScreen,int width,int height, +int depth,int usage_hint,int bitsPerPixel, +int *new_pitch);extern void RADEONEXADestroyPixmap (ScreenPtr pScreen,void *driverPriv);extern struct radeon_bo *radeon_get_pixmap_bo (PixmapPtr pPix);extern Bool RADEONEXAPixmapIsOffscreen (PixmapPtr pPix);
src/r6xx_accel.c +8 -4
@@ -282,16 +282,21 @@ set_render_target(ScrnInfoPtr pScrn, drmBufPtr ib, cb_config_t *cb_conf, uint32_EREG (ib, (CB_COLOR0_FRAG + (4 * cb_conf->id)), (0 >>8 ));// FMASK per-tile data base/256 RELOC_BATCH (cb_conf->bo,0 , domain);END_BATCH (); -BEGIN_BATCH (12 ); +BEGIN_BATCH (9 );// pitch only for ARRAY_LINEAR_GENERAL, other tiling modes require addrlib EREG (ib, (CB_COLOR0_SIZE + (4 * cb_conf->id)), ((pitch << PITCH_TILE_MAX_shift) | (slice << SLICE_TILE_MAX_shift)));EREG (ib, (CB_COLOR0_VIEW + (4 * cb_conf->id)), ((0 << SLICE_START_shift) | (0 << SLICE_MAX_shift))); -EREG (ib, (CB_COLOR0_INFO + (4 * cb_conf->id)), cb_color_info);EREG (ib, (CB_COLOR0_MASK + (4 * cb_conf->id)), ((0 << CMASK_BLOCK_MAX_shift) | (0 << FMASK_TILE_MAX_shift)));END_BATCH (); + +BEGIN_BATCH (3 +2 ); +EREG (ib, (CB_COLOR0_INFO + (4 * cb_conf->id)), cb_color_info); +RELOC_BATCH (cb_conf->bo,0 , domain); +END_BATCH (); + }void
@@ -905,7 +910,7 @@ set_default_state(ScrnInfoPtr pScrn, drmBufPtr ib)sq_setup (pScrn, ib, &sq_conf); -BEGIN_BATCH (59 ); +BEGIN_BATCH (56 );EREG (ib,SQ_VTX_BASE_VTX_LOC ,0 );EREG (ib,SQ_VTX_START_INST_LOC ,0 );
@@ -921,7 +926,6 @@ set_default_state(ScrnInfoPtr pScrn, drmBufPtr ib)E32 (ib,0 );// SQ_GS_VERT_ITEMSIZE // DB -EREG (ib,DB_DEPTH_INFO ,0 );EREG (ib,DB_STENCIL_CLEAR ,0 );EREG (ib,DB_DEPTH_CLEAR ,0 );EREG (ib,DB_STENCILREFMASK ,0 );
src/radeon.h +6 -0
@@ -1036,6 +1036,12 @@ typedef struct {uint64_t vram_size;uint64_t gart_size;drmmode_rec drmmode; +/* r6xx+ tile config */ +uint32_t tile_config; +int group_bytes; +int num_channels; +int num_banks; +int r7xx_bank_op;#else /* fake bool */ Bool cs;
src/radeon_dri2.c +8 -2
@@ -101,7 +101,10 @@ radeon_dri2_create_buffers(DrawablePtr drawable,switch (attachments[i]) {case DRI2BufferDepth:case DRI2BufferDepthStencil: - flags =RADEON_CREATE_PIXMAP_TILING_MACRO |RADEON_CREATE_PIXMAP_TILING_MICRO ; +if (info->ChipFamily >=CHIP_FAMILY_R600 ) + flags =RADEON_CREATE_PIXMAP_TILING_MACRO ; +else + flags =RADEON_CREATE_PIXMAP_TILING_MACRO |RADEON_CREATE_PIXMAP_TILING_MICRO ;break ;case DRI2BufferBackLeft:case DRI2BufferBackRight:
@@ -183,7 +186,10 @@ radeon_dri2_create_buffer(DrawablePtr drawable,switch (attachment) {case DRI2BufferDepth:case DRI2BufferDepthStencil: - flags =RADEON_CREATE_PIXMAP_TILING_MACRO |RADEON_CREATE_PIXMAP_TILING_MICRO ; +if (info->ChipFamily >=CHIP_FAMILY_R600 ) + flags =RADEON_CREATE_PIXMAP_TILING_MACRO ; +else + flags =RADEON_CREATE_PIXMAP_TILING_MACRO |RADEON_CREATE_PIXMAP_TILING_MICRO ;break ;case DRI2BufferBackLeft:case DRI2BufferBackRight:
src/radeon_exa.c +21 -5
@@ -461,11 +461,27 @@ void *RADEONEXACreatePixmap2(ScreenPtr pScreen, int width, int height, tiling &= ~RADEON_TILING_MACRO ; } -if (tiling) { - height =RADEON_ALIGN (height,16 ); - pixmap_align =256 ; - }else - pixmap_align =64 ; +if (info->ChipFamily >=CHIP_FAMILY_R600 ) { +int bpe = bitsPerPixel /8 ; + +if (tiling &RADEON_TILING_MACRO ) { + height =RADEON_ALIGN (height, info->num_banks *8 ); + pixmap_align =MAX (info->num_banks, + (((info->group_bytes /8 ) / bpe) * info->num_banks)) *8 * bpe; + }else if (tiling &RADEON_TILING_MICRO ) { + height =RADEON_ALIGN (height,8 ); + pixmap_align =MAX (8 , (info->group_bytes / (8 * bpe))) * bpe; + }else { + height =RADEON_ALIGN (height,8 ); + pixmap_align =256 ;/* 8 * bpe */ + } + }else { +if (tiling) { + height =RADEON_ALIGN (height,16 ); + pixmap_align =256 ; + }else + pixmap_align =64 ; + } padded_width = ((width * bitsPerPixel +FB_MASK ) >>FB_SHIFT ) *sizeof (FbBits); padded_width =RADEON_ALIGN (padded_width, pixmap_align);
src/radeon_kms.c +86 -13
124 lines not on this page · raw message
Signature · 1 line
1.5.6.3
PATCH 2/2 r6xx/r7xx: default to micro (1D) tiling for now
SW de-tiling used in the r600c 3D driver has issues with certain configurations.
Signed-off-by Alex Deucher <[email protected]>
--- src/radeon_dri2.c | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 deletions(-)
src/radeon_dri2.c +25 -7
@@ -102,7 +102,10 @@ radeon_dri2_create_buffers(DrawablePtr drawable,case DRI2BufferDepth:case DRI2BufferDepthStencil:if (info->ChipFamily >=CHIP_FAMILY_R600 ) - flags =RADEON_CREATE_PIXMAP_TILING_MACRO ; +/* macro is the preferred setting, but the 2D detiling for software +* fallbacks in mesa still has issues on some configurations +*/ + flags =RADEON_CREATE_PIXMAP_TILING_MICRO ;else flags =RADEON_CREATE_PIXMAP_TILING_MACRO |RADEON_CREATE_PIXMAP_TILING_MICRO ;break ;
@@ -110,7 +113,13 @@ radeon_dri2_create_buffers(DrawablePtr drawable,case DRI2BufferBackRight:case DRI2BufferFakeFrontLeft:case DRI2BufferFakeFrontRight: - flags =RADEON_CREATE_PIXMAP_TILING_MACRO ; +if (info->ChipFamily >=CHIP_FAMILY_R600 ) +/* macro is the preferred setting, but the 2D detiling for software +* fallbacks in mesa still has issues on some configurations +*/ + flags =RADEON_CREATE_PIXMAP_TILING_MICRO ; +else + flags =RADEON_CREATE_PIXMAP_TILING_MACRO ;break ;default : flags =0 ;
@@ -186,16 +195,25 @@ radeon_dri2_create_buffer(DrawablePtr drawable,switch (attachment) {case DRI2BufferDepth:case DRI2BufferDepthStencil: -if (info->ChipFamily >=CHIP_FAMILY_R600 ) - flags =RADEON_CREATE_PIXMAP_TILING_MACRO ; -else - flags =RADEON_CREATE_PIXMAP_TILING_MACRO |RADEON_CREATE_PIXMAP_TILING_MICRO ; +/* macro is the preferred setting, but the 2D detiling for software +* fallbacks in mesa still has issues on some configurations +*/ +if (info->ChipFamily >=CHIP_FAMILY_R600 ) + flags =RADEON_CREATE_PIXMAP_TILING_MICRO ; +else + flags =RADEON_CREATE_PIXMAP_TILING_MACRO |RADEON_CREATE_PIXMAP_TILING_MICRO ;break ;case DRI2BufferBackLeft:case DRI2BufferBackRight:case DRI2BufferFakeFrontLeft:case DRI2BufferFakeFrontRight: - flags =RADEON_CREATE_PIXMAP_TILING_MACRO ; +if (info->ChipFamily >=CHIP_FAMILY_R600 ) +/* macro is the preferred setting, but the 2D detiling for software +* fallbacks in mesa still has issues on some configurations +*/ + flags =RADEON_CREATE_PIXMAP_TILING_MICRO ; +else + flags =RADEON_CREATE_PIXMAP_TILING_MACRO ;break ;default : flags =0 ;
Signature · 1 line
1.5.6.3