[Mesa-dev] [PATCH 1/3] gallium/radeon: add micro_tile_mode to radeon_surf

Marek Olšák maraeo at gmail.com
Mon Jun 13 16:17:26 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

for easier access
---
 src/gallium/drivers/radeon/radeon_winsys.h         |  1 +
 src/gallium/winsys/amdgpu/drm/amdgpu_surface.c     | 15 +++++++++++
 src/gallium/winsys/radeon/drm/radeon_drm_surface.c | 30 +++++++++++++++++++---
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_winsys.h b/src/gallium/drivers/radeon/radeon_winsys.h
index c2d1f9e..bbf91a8 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -398,6 +398,7 @@ struct radeon_surf {
     uint32_t                    pipe_config;
     uint32_t                    num_banks;
     uint32_t                    macro_tile_index;
+    uint32_t                    micro_tile_mode; /* displayable, thin, depth, rotated */
 
     uint64_t                    dcc_size;
     uint64_t                    dcc_alignment;
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c b/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c
index 68a5820..081f0e1 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c
@@ -255,6 +255,20 @@ static int compute_level(struct amdgpu_winsys *ws,
    return 0;
 }
 
+#define   G_009910_MICRO_TILE_MODE(x)          (((x) >> 0) & 0x03)
+#define   G_009910_MICRO_TILE_MODE_NEW(x)      (((x) >> 22) & 0x07)
+
+static void set_micro_tile_mode(struct radeon_surf *surf,
+                                struct radeon_info *info)
+{
+   uint32_t tile_mode = info->si_tile_mode_array[surf->tiling_index[0]];
+
+   if (info->chip_class >= CIK)
+      surf->micro_tile_mode = G_009910_MICRO_TILE_MODE_NEW(tile_mode);
+   else
+      surf->micro_tile_mode = G_009910_MICRO_TILE_MODE(tile_mode);
+}
+
 static int amdgpu_surface_init(struct radeon_winsys *rws,
                                struct radeon_surf *surf)
 {
@@ -410,6 +424,7 @@ static int amdgpu_surface_init(struct radeon_winsys *rws,
       if (level == 0) {
          surf->bo_alignment = AddrSurfInfoOut.baseAlign;
          surf->pipe_config = AddrSurfInfoOut.pTileInfo->pipeConfig - 1;
+         set_micro_tile_mode(surf, &ws->info);
 
          /* For 2D modes only. */
          if (AddrSurfInfoOut.tileMode >= ADDR_TM_2D_TILED_THIN1) {
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
index 6fb8774..c6025ff 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
@@ -45,6 +45,27 @@ static unsigned cik_get_macro_tile_index(struct radeon_surf *surf)
 	return index;
 }
 
+#define   G_009910_MICRO_TILE_MODE(x)          (((x) >> 0) & 0x03)
+#define   G_009910_MICRO_TILE_MODE_NEW(x)      (((x) >> 22) & 0x07)
+
+static void set_micro_tile_mode(struct radeon_surf *surf,
+                                struct radeon_info *info)
+{
+    uint32_t tile_mode;
+
+    if (info->chip_class < SI) {
+        surf->micro_tile_mode = 0;
+        return;
+    }
+
+    tile_mode = info->si_tile_mode_array[surf->tiling_index[0]];
+
+    if (info->chip_class >= CIK)
+        surf->micro_tile_mode = G_009910_MICRO_TILE_MODE_NEW(tile_mode);
+    else
+        surf->micro_tile_mode = G_009910_MICRO_TILE_MODE(tile_mode);
+}
+
 static void surf_level_winsys_to_drm(struct radeon_surface_level *level_drm,
                                      const struct radeon_surf_level *level_ws)
 {
@@ -114,7 +135,8 @@ static void surf_winsys_to_drm(struct radeon_surface *surf_drm,
     }
 }
 
-static void surf_drm_to_winsys(struct radeon_surf *surf_ws,
+static void surf_drm_to_winsys(struct radeon_drm_winsys *ws,
+                               struct radeon_surf *surf_ws,
                                const struct radeon_surface *surf_drm)
 {
     int i;
@@ -153,6 +175,8 @@ static void surf_drm_to_winsys(struct radeon_surf *surf_ws,
         surf_ws->tiling_index[i] = surf_drm->tiling_index[i];
         surf_ws->stencil_tiling_index[i] = surf_drm->stencil_tiling_index[i];
     }
+
+    set_micro_tile_mode(surf_ws, &ws->info);
 }
 
 static int radeon_winsys_surface_init(struct radeon_winsys *rws,
@@ -168,7 +192,7 @@ static int radeon_winsys_surface_init(struct radeon_winsys *rws,
     if (r)
         return r;
 
-    surf_drm_to_winsys(surf_ws, &surf_drm);
+    surf_drm_to_winsys(ws, surf_ws, &surf_drm);
     return 0;
 }
 
@@ -185,7 +209,7 @@ static int radeon_winsys_surface_best(struct radeon_winsys *rws,
     if (r)
         return r;
 
-    surf_drm_to_winsys(surf_ws, &surf_drm);
+    surf_drm_to_winsys(ws, surf_ws, &surf_drm);
     return 0;
 }
 
-- 
2.7.4



More information about the mesa-dev mailing list