ac/radeonsi: add ac_compute_surface to automatically switch gfx6 vs. gfx9
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 10 May 2017 18:40:14 +0000 (20:40 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 18 May 2017 09:48:52 +0000 (11:48 +0200)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_surface.c
src/amd/common/ac_surface.h
src/gallium/winsys/amdgpu/drm/amdgpu_surface.c

index 8b6d3b10a2fa786f98748fc266b460fd5fde5eab..b20d8189cc8687fd546479c6e3e8443c7d7a81f6 100644 (file)
@@ -362,10 +362,10 @@ static unsigned cik_get_macro_tile_index(struct radeon_surf *surf)
  * The following fields of \p surf must be initialized by the caller:
  * blk_w, blk_h, bpe, flags.
  */
-int gfx6_compute_surface(ADDR_HANDLE addrlib,
-                        const struct ac_surf_config *config,
-                        enum radeon_surf_mode mode,
-                        struct radeon_surf *surf)
+static int gfx6_compute_surface(ADDR_HANDLE addrlib,
+                               const struct ac_surf_config *config,
+                               enum radeon_surf_mode mode,
+                               struct radeon_surf *surf)
 {
        unsigned level;
        bool compressed;
@@ -847,10 +847,10 @@ static int gfx9_compute_miptree(ADDR_HANDLE addrlib,
        return 0;
 }
 
-int gfx9_compute_surface(ADDR_HANDLE addrlib,
-                        const struct ac_surf_config *config,
-                        enum radeon_surf_mode mode,
-                        struct radeon_surf *surf)
+static int gfx9_compute_surface(ADDR_HANDLE addrlib,
+                               const struct ac_surf_config *config,
+                               enum radeon_surf_mode mode,
+                               struct radeon_surf *surf)
 {
        bool compressed;
        ADDR2_COMPUTE_SURFACE_INFO_INPUT AddrSurfInfoIn = {0};
@@ -1010,3 +1010,14 @@ int gfx9_compute_surface(ADDR_HANDLE addrlib,
 
        return 0;
 }
+
+int ac_compute_surface(ADDR_HANDLE addrlib,
+                      const struct ac_surf_config *config,
+                      enum radeon_surf_mode mode,
+                      struct radeon_surf *surf)
+{
+       if (config->chip_class >= GFX9)
+               return gfx9_compute_surface(addrlib, config, mode, surf);
+       else
+               return gfx6_compute_surface(addrlib, config, mode, surf);
+}
index 9a9697b77de60b0671a984f8ed65db61f01d83d0..73649c76a10c96eb924d74478a2c0088cd1f4a58 100644 (file)
@@ -204,13 +204,9 @@ struct ac_surf_config {
 ADDR_HANDLE amdgpu_addr_create(enum radeon_family family,
                               const struct amdgpu_gpu_info *info);
 
-int gfx6_compute_surface(ADDR_HANDLE addrlib,
-                        const struct ac_surf_config *config,
-                        enum radeon_surf_mode mode,
-                        struct radeon_surf *surf);
-int gfx9_compute_surface(ADDR_HANDLE addrlib,
-                        const struct ac_surf_config *config,
-                        enum radeon_surf_mode mode,
-                        struct radeon_surf *surf);
+int ac_compute_surface(ADDR_HANDLE addrlib,
+                      const struct ac_surf_config * config,
+                      enum radeon_surf_mode mode,
+                      struct radeon_surf *surf);
 
 #endif /* AC_SURFACE_H */
index 76596e8daf6c102c123858b974a312d221ef81f9..ca391e0c4ea538f0fa72f9f0ac50d3f0dbf3a7b1 100644 (file)
@@ -113,10 +113,7 @@ static int amdgpu_surface_init(struct radeon_winsys *rws,
    config.pipe_interleave_bytes = ws->info.pipe_interleave_bytes;
    config.amdinfo = &ws->amdinfo;
 
-   if (ws->info.chip_class >= GFX9)
-      return gfx9_compute_surface(ws->addrlib, &config, mode, surf);
-   else
-      return gfx6_compute_surface(ws->addrlib, &config, mode, surf);
+   return ac_compute_surface(ws->addrlib, &config, mode, surf);
 }
 
 void amdgpu_surface_init_functions(struct amdgpu_winsys *ws)