[PATCH] radeon: add si tiling support

Michel Dänzer michel at daenzer.net
Thu Apr 4 01:14:07 PDT 2013


On Mit, 2013-04-03 at 17:22 -0400, j.glisse at gmail.com wrote:
> From: Jerome Glisse <jglisse at redhat.com>
> 
> Signed-off-by: Jerome Glisse <jglisse at redhat.com>
> ---
>  include/drm/radeon_drm.h |  61 +++++
>  radeon/radeon_surface.c  | 663 +++++++++++++++++++++++++++++++++++++++++++----
>  radeon/radeon_surface.h  |  30 +++
>  3 files changed, 709 insertions(+), 45 deletions(-)
> 
> diff --git a/include/drm/radeon_drm.h b/include/drm/radeon_drm.h
> index 00d66b3..ff3ce3a 100644
> --- a/include/drm/radeon_drm.h
> +++ b/include/drm/radeon_drm.h
> @@ -509,6 +509,7 @@ typedef struct {
>  #define DRM_RADEON_GEM_SET_TILING      0x28
>  #define DRM_RADEON_GEM_GET_TILING      0x29
>  #define DRM_RADEON_GEM_BUSY            0x2a
> +#define DRM_RADEON_GEM_VA              0x2b
>  
>  #define DRM_IOCTL_RADEON_CP_INIT    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t)
>  #define DRM_IOCTL_RADEON_CP_START   DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_CP_START)

Changes which aren't related to SI tiling should go in separate patches.


> diff --git a/radeon/radeon_surface.c b/radeon/radeon_surface.c
> index 5935c23..dfdcbbc 100644
> --- a/radeon/radeon_surface.c
> +++ b/radeon/radeon_surface.c
> [...]
> @@ -1198,6 +1742,33 @@ static int si_surface_init(struct radeon_surface_manager *surf_man,
>      return r;
>  }
>  
> +/*
> + * depending on surface
> + */
> +static int si_surface_best(struct radeon_surface_manager *surf_man,
> +                           struct radeon_surface *surf)
> +{
> +    unsigned mode, tile_mode, stencil_tile_mode;
> +
> +    /* tiling mode */
> +    mode = (surf->flags >> RADEON_SURF_MODE_SHIFT) & RADEON_SURF_MODE_MASK;
> +
> +    if (surf->flags & RADEON_SURF_SBUFFER) {
> +        /* stencil force 2d tiling */
> +        surf->flags = RADEON_SURF_CLR(surf->flags, MODE);
> +        surf->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_1D, MODE);
> +    }
> +
> +    if (surf->flags & (RADEON_SURF_ZBUFFER | RADEON_SURF_SBUFFER)) {
> +        /* depth force 2d tiling */
> +        surf->flags = RADEON_SURF_CLR(surf->flags, MODE);
> +        surf->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_1D, MODE);
> +    }

The comments say 2D, but the code says 1D.


> @@ -104,6 +132,8 @@ struct radeon_surface {
>      uint64_t                    stencil_offset;
>      struct radeon_surface_level level[RADEON_SURF_MAX_LEVEL];
>      struct radeon_surface_level stencil_level[RADEON_SURF_MAX_LEVEL];
> +    uint32_t                    tiling_index[RADEON_SURF_MAX_LEVEL];
> +    uint32_t
> stencil_tiling_index[RADEON_SURF_MAX_LEVEL];
>  };

Either these new fields need to be guarded the same way stencil_level is
guarded by RADEON_SURF_SBUFFER, or the libdrm_radeon SONAME needs to be
bumped. Otherwise, radeonsi built against libdrm_radeon without this
patch will probably crash when running against libdrm_radeon with it.


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the dri-devel mailing list