2 * Copyright © 2011 Red Hat All Rights Reserved.
3 * Copyright © 2017 Advanced Micro Devices, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
18 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * The above copyright notice and this permission notice (including the
24 * next paragraph) shall be included in all copies or substantial portions
28 #include "ac_surface.h"
29 #include "amd_family.h"
30 #include "addrlib/src/amdgpu_asic_addr.h"
31 #include "ac_gpu_info.h"
32 #include "util/macros.h"
33 #include "util/u_atomic.h"
34 #include "util/u_math.h"
40 #include <amdgpu_drm.h>
42 #include "addrlib/inc/addrinterface.h"
44 #ifndef CIASICIDGFXENGINE_SOUTHERNISLAND
45 #define CIASICIDGFXENGINE_SOUTHERNISLAND 0x0000000A
48 #ifndef CIASICIDGFXENGINE_ARCTICISLAND
49 #define CIASICIDGFXENGINE_ARCTICISLAND 0x0000000D
52 static void *ADDR_API
allocSysMem(const ADDR_ALLOCSYSMEM_INPUT
* pInput
)
54 return malloc(pInput
->sizeInBytes
);
57 static ADDR_E_RETURNCODE ADDR_API
freeSysMem(const ADDR_FREESYSMEM_INPUT
* pInput
)
59 free(pInput
->pVirtAddr
);
63 ADDR_HANDLE
amdgpu_addr_create(const struct radeon_info
*info
,
64 const struct amdgpu_gpu_info
*amdinfo
,
65 uint64_t *max_alignment
)
67 ADDR_CREATE_INPUT addrCreateInput
= {0};
68 ADDR_CREATE_OUTPUT addrCreateOutput
= {0};
69 ADDR_REGISTER_VALUE regValue
= {0};
70 ADDR_CREATE_FLAGS createFlags
= {{0}};
71 ADDR_GET_MAX_ALIGNMENTS_OUTPUT addrGetMaxAlignmentsOutput
= {0};
72 ADDR_E_RETURNCODE addrRet
;
74 addrCreateInput
.size
= sizeof(ADDR_CREATE_INPUT
);
75 addrCreateOutput
.size
= sizeof(ADDR_CREATE_OUTPUT
);
77 regValue
.gbAddrConfig
= amdinfo
->gb_addr_cfg
;
78 createFlags
.value
= 0;
80 addrCreateInput
.chipFamily
= info
->family_id
;
81 addrCreateInput
.chipRevision
= info
->chip_external_rev
;
83 if (addrCreateInput
.chipFamily
== FAMILY_UNKNOWN
)
86 if (addrCreateInput
.chipFamily
>= FAMILY_AI
) {
87 addrCreateInput
.chipEngine
= CIASICIDGFXENGINE_ARCTICISLAND
;
88 regValue
.blockVarSizeLog2
= 0;
90 regValue
.noOfBanks
= amdinfo
->mc_arb_ramcfg
& 0x3;
91 regValue
.noOfRanks
= (amdinfo
->mc_arb_ramcfg
& 0x4) >> 2;
93 regValue
.backendDisables
= amdinfo
->enabled_rb_pipes_mask
;
94 regValue
.pTileConfig
= amdinfo
->gb_tile_mode
;
95 regValue
.noOfEntries
= ARRAY_SIZE(amdinfo
->gb_tile_mode
);
96 if (addrCreateInput
.chipFamily
== FAMILY_SI
) {
97 regValue
.pMacroTileConfig
= NULL
;
98 regValue
.noOfMacroEntries
= 0;
100 regValue
.pMacroTileConfig
= amdinfo
->gb_macro_tile_mode
;
101 regValue
.noOfMacroEntries
= ARRAY_SIZE(amdinfo
->gb_macro_tile_mode
);
104 createFlags
.useTileIndex
= 1;
105 createFlags
.useHtileSliceAlign
= 1;
107 addrCreateInput
.chipEngine
= CIASICIDGFXENGINE_SOUTHERNISLAND
;
110 addrCreateInput
.callbacks
.allocSysMem
= allocSysMem
;
111 addrCreateInput
.callbacks
.freeSysMem
= freeSysMem
;
112 addrCreateInput
.callbacks
.debugPrint
= 0;
113 addrCreateInput
.createFlags
= createFlags
;
114 addrCreateInput
.regValue
= regValue
;
116 addrRet
= AddrCreate(&addrCreateInput
, &addrCreateOutput
);
117 if (addrRet
!= ADDR_OK
)
121 addrRet
= AddrGetMaxAlignments(addrCreateOutput
.hLib
, &addrGetMaxAlignmentsOutput
);
122 if (addrRet
== ADDR_OK
){
123 *max_alignment
= addrGetMaxAlignmentsOutput
.baseAlign
;
126 return addrCreateOutput
.hLib
;
129 static int surf_config_sanity(const struct ac_surf_config
*config
,
132 /* FMASK is allocated together with the color surface and can't be
133 * allocated separately.
135 assert(!(flags
& RADEON_SURF_FMASK
));
136 if (flags
& RADEON_SURF_FMASK
)
139 /* all dimension must be at least 1 ! */
140 if (!config
->info
.width
|| !config
->info
.height
|| !config
->info
.depth
||
141 !config
->info
.array_size
|| !config
->info
.levels
)
144 switch (config
->info
.samples
) {
152 if (flags
& RADEON_SURF_Z_OR_SBUFFER
)
159 if (!(flags
& RADEON_SURF_Z_OR_SBUFFER
)) {
160 switch (config
->info
.storage_samples
) {
172 if (config
->is_3d
&& config
->info
.array_size
> 1)
174 if (config
->is_cube
&& config
->info
.depth
> 1)
180 static int gfx6_compute_level(ADDR_HANDLE addrlib
,
181 const struct ac_surf_config
*config
,
182 struct radeon_surf
*surf
, bool is_stencil
,
183 unsigned level
, bool compressed
,
184 ADDR_COMPUTE_SURFACE_INFO_INPUT
*AddrSurfInfoIn
,
185 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
*AddrSurfInfoOut
,
186 ADDR_COMPUTE_DCCINFO_INPUT
*AddrDccIn
,
187 ADDR_COMPUTE_DCCINFO_OUTPUT
*AddrDccOut
,
188 ADDR_COMPUTE_HTILE_INFO_INPUT
*AddrHtileIn
,
189 ADDR_COMPUTE_HTILE_INFO_OUTPUT
*AddrHtileOut
)
191 struct legacy_surf_level
*surf_level
;
192 ADDR_E_RETURNCODE ret
;
194 AddrSurfInfoIn
->mipLevel
= level
;
195 AddrSurfInfoIn
->width
= u_minify(config
->info
.width
, level
);
196 AddrSurfInfoIn
->height
= u_minify(config
->info
.height
, level
);
198 /* Make GFX6 linear surfaces compatible with GFX9 for hybrid graphics,
199 * because GFX9 needs linear alignment of 256 bytes.
201 if (config
->info
.levels
== 1 &&
202 AddrSurfInfoIn
->tileMode
== ADDR_TM_LINEAR_ALIGNED
&&
203 AddrSurfInfoIn
->bpp
&&
204 util_is_power_of_two_or_zero(AddrSurfInfoIn
->bpp
)) {
205 unsigned alignment
= 256 / (AddrSurfInfoIn
->bpp
/ 8);
207 AddrSurfInfoIn
->width
= align(AddrSurfInfoIn
->width
, alignment
);
211 AddrSurfInfoIn
->numSlices
= u_minify(config
->info
.depth
, level
);
212 else if (config
->is_cube
)
213 AddrSurfInfoIn
->numSlices
= 6;
215 AddrSurfInfoIn
->numSlices
= config
->info
.array_size
;
218 /* Set the base level pitch. This is needed for calculation
219 * of non-zero levels. */
221 AddrSurfInfoIn
->basePitch
= surf
->u
.legacy
.stencil_level
[0].nblk_x
;
223 AddrSurfInfoIn
->basePitch
= surf
->u
.legacy
.level
[0].nblk_x
;
225 /* Convert blocks to pixels for compressed formats. */
227 AddrSurfInfoIn
->basePitch
*= surf
->blk_w
;
230 ret
= AddrComputeSurfaceInfo(addrlib
,
233 if (ret
!= ADDR_OK
) {
237 surf_level
= is_stencil
? &surf
->u
.legacy
.stencil_level
[level
] : &surf
->u
.legacy
.level
[level
];
238 surf_level
->offset
= align64(surf
->surf_size
, AddrSurfInfoOut
->baseAlign
);
239 surf_level
->slice_size_dw
= AddrSurfInfoOut
->sliceSize
/ 4;
240 surf_level
->nblk_x
= AddrSurfInfoOut
->pitch
;
241 surf_level
->nblk_y
= AddrSurfInfoOut
->height
;
243 switch (AddrSurfInfoOut
->tileMode
) {
244 case ADDR_TM_LINEAR_ALIGNED
:
245 surf_level
->mode
= RADEON_SURF_MODE_LINEAR_ALIGNED
;
247 case ADDR_TM_1D_TILED_THIN1
:
248 surf_level
->mode
= RADEON_SURF_MODE_1D
;
250 case ADDR_TM_2D_TILED_THIN1
:
251 surf_level
->mode
= RADEON_SURF_MODE_2D
;
258 surf
->u
.legacy
.stencil_tiling_index
[level
] = AddrSurfInfoOut
->tileIndex
;
260 surf
->u
.legacy
.tiling_index
[level
] = AddrSurfInfoOut
->tileIndex
;
262 surf
->surf_size
= surf_level
->offset
+ AddrSurfInfoOut
->surfSize
;
264 /* Clear DCC fields at the beginning. */
265 surf_level
->dcc_offset
= 0;
267 /* The previous level's flag tells us if we can use DCC for this level. */
268 if (AddrSurfInfoIn
->flags
.dccCompatible
&&
269 (level
== 0 || AddrDccOut
->subLvlCompressible
)) {
270 bool prev_level_clearable
= level
== 0 ||
271 AddrDccOut
->dccRamSizeAligned
;
273 AddrDccIn
->colorSurfSize
= AddrSurfInfoOut
->surfSize
;
274 AddrDccIn
->tileMode
= AddrSurfInfoOut
->tileMode
;
275 AddrDccIn
->tileInfo
= *AddrSurfInfoOut
->pTileInfo
;
276 AddrDccIn
->tileIndex
= AddrSurfInfoOut
->tileIndex
;
277 AddrDccIn
->macroModeIndex
= AddrSurfInfoOut
->macroModeIndex
;
279 ret
= AddrComputeDccInfo(addrlib
,
283 if (ret
== ADDR_OK
) {
284 surf_level
->dcc_offset
= surf
->dcc_size
;
285 surf
->num_dcc_levels
= level
+ 1;
286 surf
->dcc_size
= surf_level
->dcc_offset
+ AddrDccOut
->dccRamSize
;
287 surf
->dcc_alignment
= MAX2(surf
->dcc_alignment
, AddrDccOut
->dccRamBaseAlign
);
289 /* If the DCC size of a subresource (1 mip level or 1 slice)
290 * is not aligned, the DCC memory layout is not contiguous for
291 * that subresource, which means we can't use fast clear.
293 * We only do fast clears for whole mipmap levels. If we did
294 * per-slice fast clears, the same restriction would apply.
295 * (i.e. only compute the slice size and see if it's aligned)
297 * The last level can be non-contiguous and still be clearable
298 * if it's interleaved with the next level that doesn't exist.
300 if (AddrDccOut
->dccRamSizeAligned
||
301 (prev_level_clearable
&& level
== config
->info
.levels
- 1))
302 surf_level
->dcc_fast_clear_size
= AddrDccOut
->dccFastClearSize
;
304 surf_level
->dcc_fast_clear_size
= 0;
306 /* Compute the DCC slice size because addrlib doesn't
307 * provide this info. As DCC memory is linear (each
308 * slice is the same size) it's easy to compute.
310 surf
->dcc_slice_size
= AddrDccOut
->dccRamSize
/ config
->info
.array_size
;
312 /* For arrays, we have to compute the DCC info again
313 * with one slice size to get a correct fast clear
316 if (config
->info
.array_size
> 1) {
317 AddrDccIn
->colorSurfSize
= AddrSurfInfoOut
->sliceSize
;
318 AddrDccIn
->tileMode
= AddrSurfInfoOut
->tileMode
;
319 AddrDccIn
->tileInfo
= *AddrSurfInfoOut
->pTileInfo
;
320 AddrDccIn
->tileIndex
= AddrSurfInfoOut
->tileIndex
;
321 AddrDccIn
->macroModeIndex
= AddrSurfInfoOut
->macroModeIndex
;
323 ret
= AddrComputeDccInfo(addrlib
,
324 AddrDccIn
, AddrDccOut
);
325 if (ret
== ADDR_OK
) {
326 /* If the DCC memory isn't properly
327 * aligned, the data are interleaved
330 if (AddrDccOut
->dccRamSizeAligned
)
331 surf_level
->dcc_slice_fast_clear_size
= AddrDccOut
->dccFastClearSize
;
333 surf_level
->dcc_slice_fast_clear_size
= 0;
336 surf_level
->dcc_slice_fast_clear_size
= surf_level
->dcc_fast_clear_size
;
341 /* TC-compatible HTILE. */
343 AddrSurfInfoIn
->flags
.depth
&&
344 surf_level
->mode
== RADEON_SURF_MODE_2D
&&
346 AddrHtileIn
->flags
.tcCompatible
= AddrSurfInfoIn
->flags
.tcCompatible
;
347 AddrHtileIn
->pitch
= AddrSurfInfoOut
->pitch
;
348 AddrHtileIn
->height
= AddrSurfInfoOut
->height
;
349 AddrHtileIn
->numSlices
= AddrSurfInfoOut
->depth
;
350 AddrHtileIn
->blockWidth
= ADDR_HTILE_BLOCKSIZE_8
;
351 AddrHtileIn
->blockHeight
= ADDR_HTILE_BLOCKSIZE_8
;
352 AddrHtileIn
->pTileInfo
= AddrSurfInfoOut
->pTileInfo
;
353 AddrHtileIn
->tileIndex
= AddrSurfInfoOut
->tileIndex
;
354 AddrHtileIn
->macroModeIndex
= AddrSurfInfoOut
->macroModeIndex
;
356 ret
= AddrComputeHtileInfo(addrlib
,
360 if (ret
== ADDR_OK
) {
361 surf
->htile_size
= AddrHtileOut
->htileBytes
;
362 surf
->htile_slice_size
= AddrHtileOut
->sliceSize
;
363 surf
->htile_alignment
= AddrHtileOut
->baseAlign
;
370 #define G_009910_MICRO_TILE_MODE(x) (((x) >> 0) & 0x03)
371 #define V_009910_ADDR_SURF_THICK_MICRO_TILING 0x03
372 #define G_009910_MICRO_TILE_MODE_NEW(x) (((x) >> 22) & 0x07)
374 static void gfx6_set_micro_tile_mode(struct radeon_surf
*surf
,
375 const struct radeon_info
*info
)
377 uint32_t tile_mode
= info
->si_tile_mode_array
[surf
->u
.legacy
.tiling_index
[0]];
379 if (info
->chip_class
>= GFX7
)
380 surf
->micro_tile_mode
= G_009910_MICRO_TILE_MODE_NEW(tile_mode
);
382 surf
->micro_tile_mode
= G_009910_MICRO_TILE_MODE(tile_mode
);
385 static unsigned cik_get_macro_tile_index(struct radeon_surf
*surf
)
387 unsigned index
, tileb
;
389 tileb
= 8 * 8 * surf
->bpe
;
390 tileb
= MIN2(surf
->u
.legacy
.tile_split
, tileb
);
392 for (index
= 0; tileb
> 64; index
++)
399 static bool get_display_flag(const struct ac_surf_config
*config
,
400 const struct radeon_surf
*surf
)
402 unsigned num_channels
= config
->info
.num_channels
;
403 unsigned bpe
= surf
->bpe
;
405 if (!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
) &&
406 surf
->flags
& RADEON_SURF_SCANOUT
&&
407 config
->info
.samples
<= 1 &&
408 surf
->blk_w
<= 2 && surf
->blk_h
== 1) {
410 if (surf
->blk_w
== 2 && surf
->blk_h
== 1)
413 if (/* RGBA8 or RGBA16F */
414 (bpe
>= 4 && bpe
<= 8 && num_channels
== 4) ||
415 /* R5G6B5 or R5G5B5A1 */
416 (bpe
== 2 && num_channels
>= 3) ||
418 (bpe
== 1 && num_channels
== 1))
425 * This must be called after the first level is computed.
427 * Copy surface-global settings like pipe/bank config from level 0 surface
428 * computation, and compute tile swizzle.
430 static int gfx6_surface_settings(ADDR_HANDLE addrlib
,
431 const struct radeon_info
*info
,
432 const struct ac_surf_config
*config
,
433 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* csio
,
434 struct radeon_surf
*surf
)
436 surf
->surf_alignment
= csio
->baseAlign
;
437 surf
->u
.legacy
.pipe_config
= csio
->pTileInfo
->pipeConfig
- 1;
438 gfx6_set_micro_tile_mode(surf
, info
);
440 /* For 2D modes only. */
441 if (csio
->tileMode
>= ADDR_TM_2D_TILED_THIN1
) {
442 surf
->u
.legacy
.bankw
= csio
->pTileInfo
->bankWidth
;
443 surf
->u
.legacy
.bankh
= csio
->pTileInfo
->bankHeight
;
444 surf
->u
.legacy
.mtilea
= csio
->pTileInfo
->macroAspectRatio
;
445 surf
->u
.legacy
.tile_split
= csio
->pTileInfo
->tileSplitBytes
;
446 surf
->u
.legacy
.num_banks
= csio
->pTileInfo
->banks
;
447 surf
->u
.legacy
.macro_tile_index
= csio
->macroModeIndex
;
449 surf
->u
.legacy
.macro_tile_index
= 0;
452 /* Compute tile swizzle. */
453 /* TODO: fix tile swizzle with mipmapping for GFX6 */
454 if ((info
->chip_class
>= GFX7
|| config
->info
.levels
== 1) &&
455 config
->info
.surf_index
&&
456 surf
->u
.legacy
.level
[0].mode
== RADEON_SURF_MODE_2D
&&
457 !(surf
->flags
& (RADEON_SURF_Z_OR_SBUFFER
| RADEON_SURF_SHAREABLE
)) &&
458 !get_display_flag(config
, surf
)) {
459 ADDR_COMPUTE_BASE_SWIZZLE_INPUT AddrBaseSwizzleIn
= {0};
460 ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT AddrBaseSwizzleOut
= {0};
462 AddrBaseSwizzleIn
.size
= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_INPUT
);
463 AddrBaseSwizzleOut
.size
= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT
);
465 AddrBaseSwizzleIn
.surfIndex
= p_atomic_inc_return(config
->info
.surf_index
) - 1;
466 AddrBaseSwizzleIn
.tileIndex
= csio
->tileIndex
;
467 AddrBaseSwizzleIn
.macroModeIndex
= csio
->macroModeIndex
;
468 AddrBaseSwizzleIn
.pTileInfo
= csio
->pTileInfo
;
469 AddrBaseSwizzleIn
.tileMode
= csio
->tileMode
;
471 int r
= AddrComputeBaseSwizzle(addrlib
, &AddrBaseSwizzleIn
,
472 &AddrBaseSwizzleOut
);
476 assert(AddrBaseSwizzleOut
.tileSwizzle
<=
477 u_bit_consecutive(0, sizeof(surf
->tile_swizzle
) * 8));
478 surf
->tile_swizzle
= AddrBaseSwizzleOut
.tileSwizzle
;
483 static void ac_compute_cmask(const struct radeon_info
*info
,
484 const struct ac_surf_config
*config
,
485 struct radeon_surf
*surf
)
487 unsigned pipe_interleave_bytes
= info
->pipe_interleave_bytes
;
488 unsigned num_pipes
= info
->num_tile_pipes
;
489 unsigned cl_width
, cl_height
;
491 if (surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
)
494 assert(info
->chip_class
<= GFX8
);
509 case 16: /* Hawaii */
518 unsigned base_align
= num_pipes
* pipe_interleave_bytes
;
520 unsigned width
= align(surf
->u
.legacy
.level
[0].nblk_x
, cl_width
*8);
521 unsigned height
= align(surf
->u
.legacy
.level
[0].nblk_y
, cl_height
*8);
522 unsigned slice_elements
= (width
* height
) / (8*8);
524 /* Each element of CMASK is a nibble. */
525 unsigned slice_bytes
= slice_elements
/ 2;
527 surf
->u
.legacy
.cmask_slice_tile_max
= (width
* height
) / (128*128);
528 if (surf
->u
.legacy
.cmask_slice_tile_max
)
529 surf
->u
.legacy
.cmask_slice_tile_max
-= 1;
533 num_layers
= config
->info
.depth
;
534 else if (config
->is_cube
)
537 num_layers
= config
->info
.array_size
;
539 surf
->cmask_alignment
= MAX2(256, base_align
);
540 surf
->cmask_slice_size
= align(slice_bytes
, base_align
);
541 surf
->cmask_size
= surf
->cmask_slice_size
* num_layers
;
545 * Fill in the tiling information in \p surf based on the given surface config.
547 * The following fields of \p surf must be initialized by the caller:
548 * blk_w, blk_h, bpe, flags.
550 static int gfx6_compute_surface(ADDR_HANDLE addrlib
,
551 const struct radeon_info
*info
,
552 const struct ac_surf_config
*config
,
553 enum radeon_surf_mode mode
,
554 struct radeon_surf
*surf
)
558 ADDR_COMPUTE_SURFACE_INFO_INPUT AddrSurfInfoIn
= {0};
559 ADDR_COMPUTE_SURFACE_INFO_OUTPUT AddrSurfInfoOut
= {0};
560 ADDR_COMPUTE_DCCINFO_INPUT AddrDccIn
= {0};
561 ADDR_COMPUTE_DCCINFO_OUTPUT AddrDccOut
= {0};
562 ADDR_COMPUTE_HTILE_INFO_INPUT AddrHtileIn
= {0};
563 ADDR_COMPUTE_HTILE_INFO_OUTPUT AddrHtileOut
= {0};
564 ADDR_TILEINFO AddrTileInfoIn
= {0};
565 ADDR_TILEINFO AddrTileInfoOut
= {0};
568 AddrSurfInfoIn
.size
= sizeof(ADDR_COMPUTE_SURFACE_INFO_INPUT
);
569 AddrSurfInfoOut
.size
= sizeof(ADDR_COMPUTE_SURFACE_INFO_OUTPUT
);
570 AddrDccIn
.size
= sizeof(ADDR_COMPUTE_DCCINFO_INPUT
);
571 AddrDccOut
.size
= sizeof(ADDR_COMPUTE_DCCINFO_OUTPUT
);
572 AddrHtileIn
.size
= sizeof(ADDR_COMPUTE_HTILE_INFO_INPUT
);
573 AddrHtileOut
.size
= sizeof(ADDR_COMPUTE_HTILE_INFO_OUTPUT
);
574 AddrSurfInfoOut
.pTileInfo
= &AddrTileInfoOut
;
576 compressed
= surf
->blk_w
== 4 && surf
->blk_h
== 4;
578 /* MSAA requires 2D tiling. */
579 if (config
->info
.samples
> 1)
580 mode
= RADEON_SURF_MODE_2D
;
582 /* DB doesn't support linear layouts. */
583 if (surf
->flags
& (RADEON_SURF_Z_OR_SBUFFER
) &&
584 mode
< RADEON_SURF_MODE_1D
)
585 mode
= RADEON_SURF_MODE_1D
;
587 /* Set the requested tiling mode. */
589 case RADEON_SURF_MODE_LINEAR_ALIGNED
:
590 AddrSurfInfoIn
.tileMode
= ADDR_TM_LINEAR_ALIGNED
;
592 case RADEON_SURF_MODE_1D
:
593 AddrSurfInfoIn
.tileMode
= ADDR_TM_1D_TILED_THIN1
;
595 case RADEON_SURF_MODE_2D
:
596 AddrSurfInfoIn
.tileMode
= ADDR_TM_2D_TILED_THIN1
;
602 /* The format must be set correctly for the allocation of compressed
603 * textures to work. In other cases, setting the bpp is sufficient.
608 AddrSurfInfoIn
.format
= ADDR_FMT_BC1
;
611 AddrSurfInfoIn
.format
= ADDR_FMT_BC3
;
618 AddrDccIn
.bpp
= AddrSurfInfoIn
.bpp
= surf
->bpe
* 8;
621 AddrDccIn
.numSamples
= AddrSurfInfoIn
.numSamples
=
622 MAX2(1, config
->info
.samples
);
623 AddrSurfInfoIn
.tileIndex
= -1;
625 if (!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
)) {
626 AddrDccIn
.numSamples
= AddrSurfInfoIn
.numFrags
=
627 MAX2(1, config
->info
.storage_samples
);
630 /* Set the micro tile type. */
631 if (surf
->flags
& RADEON_SURF_SCANOUT
)
632 AddrSurfInfoIn
.tileType
= ADDR_DISPLAYABLE
;
633 else if (surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
)
634 AddrSurfInfoIn
.tileType
= ADDR_DEPTH_SAMPLE_ORDER
;
636 AddrSurfInfoIn
.tileType
= ADDR_NON_DISPLAYABLE
;
638 AddrSurfInfoIn
.flags
.color
= !(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
);
639 AddrSurfInfoIn
.flags
.depth
= (surf
->flags
& RADEON_SURF_ZBUFFER
) != 0;
640 AddrSurfInfoIn
.flags
.cube
= config
->is_cube
;
641 AddrSurfInfoIn
.flags
.display
= get_display_flag(config
, surf
);
642 AddrSurfInfoIn
.flags
.pow2Pad
= config
->info
.levels
> 1;
643 AddrSurfInfoIn
.flags
.tcCompatible
= (surf
->flags
& RADEON_SURF_TC_COMPATIBLE_HTILE
) != 0;
645 /* Only degrade the tile mode for space if TC-compatible HTILE hasn't been
646 * requested, because TC-compatible HTILE requires 2D tiling.
648 AddrSurfInfoIn
.flags
.opt4Space
= !AddrSurfInfoIn
.flags
.tcCompatible
&&
649 !AddrSurfInfoIn
.flags
.fmask
&&
650 config
->info
.samples
<= 1 &&
651 (surf
->flags
& RADEON_SURF_OPTIMIZE_FOR_SPACE
);
654 * - If we add MSAA support, keep in mind that CB can't decompress 8bpp
656 * - Mipmapped array textures have low performance (discovered by a closed
659 AddrSurfInfoIn
.flags
.dccCompatible
=
660 info
->chip_class
>= GFX8
&&
661 !(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
) &&
662 !(surf
->flags
& RADEON_SURF_DISABLE_DCC
) &&
664 ((config
->info
.array_size
== 1 && config
->info
.depth
== 1) ||
665 config
->info
.levels
== 1);
667 AddrSurfInfoIn
.flags
.noStencil
= (surf
->flags
& RADEON_SURF_SBUFFER
) == 0;
668 AddrSurfInfoIn
.flags
.compressZ
= !!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
);
670 /* On GFX7-GFX8, the DB uses the same pitch and tile mode (except tilesplit)
671 * for Z and stencil. This can cause a number of problems which we work
674 * - a depth part that is incompatible with mipmapped texturing
675 * - at least on Stoney, entirely incompatible Z/S aspects (e.g.
676 * incorrect tiling applied to the stencil part, stencil buffer
677 * memory accesses that go out of bounds) even without mipmapping
679 * Some piglit tests that are prone to different types of related
681 * ./bin/ext_framebuffer_multisample-upsample 2 stencil
682 * ./bin/framebuffer-blit-levels {draw,read} stencil
683 * ./bin/ext_framebuffer_multisample-unaligned-blit N {depth,stencil} {msaa,upsample,downsample}
684 * ./bin/fbo-depth-array fs-writes-{depth,stencil} / {depth,stencil}-{clear,layered-clear,draw}
685 * ./bin/depthstencil-render-miplevels 1024 d=s=z24_s8
687 int stencil_tile_idx
= -1;
689 if (AddrSurfInfoIn
.flags
.depth
&& !AddrSurfInfoIn
.flags
.noStencil
&&
690 (config
->info
.levels
> 1 || info
->family
== CHIP_STONEY
)) {
691 /* Compute stencilTileIdx that is compatible with the (depth)
692 * tileIdx. This degrades the depth surface if necessary to
693 * ensure that a matching stencilTileIdx exists. */
694 AddrSurfInfoIn
.flags
.matchStencilTileCfg
= 1;
696 /* Keep the depth mip-tail compatible with texturing. */
697 AddrSurfInfoIn
.flags
.noStencil
= 1;
700 /* Set preferred macrotile parameters. This is usually required
701 * for shared resources. This is for 2D tiling only. */
702 if (AddrSurfInfoIn
.tileMode
>= ADDR_TM_2D_TILED_THIN1
&&
703 surf
->u
.legacy
.bankw
&& surf
->u
.legacy
.bankh
&&
704 surf
->u
.legacy
.mtilea
&& surf
->u
.legacy
.tile_split
) {
705 /* If any of these parameters are incorrect, the calculation
707 AddrTileInfoIn
.banks
= surf
->u
.legacy
.num_banks
;
708 AddrTileInfoIn
.bankWidth
= surf
->u
.legacy
.bankw
;
709 AddrTileInfoIn
.bankHeight
= surf
->u
.legacy
.bankh
;
710 AddrTileInfoIn
.macroAspectRatio
= surf
->u
.legacy
.mtilea
;
711 AddrTileInfoIn
.tileSplitBytes
= surf
->u
.legacy
.tile_split
;
712 AddrTileInfoIn
.pipeConfig
= surf
->u
.legacy
.pipe_config
+ 1; /* +1 compared to GB_TILE_MODE */
713 AddrSurfInfoIn
.flags
.opt4Space
= 0;
714 AddrSurfInfoIn
.pTileInfo
= &AddrTileInfoIn
;
716 /* If AddrSurfInfoIn.pTileInfo is set, Addrlib doesn't set
717 * the tile index, because we are expected to know it if
718 * we know the other parameters.
720 * This is something that can easily be fixed in Addrlib.
721 * For now, just figure it out here.
722 * Note that only 2D_TILE_THIN1 is handled here.
724 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
725 assert(AddrSurfInfoIn
.tileMode
== ADDR_TM_2D_TILED_THIN1
);
727 if (info
->chip_class
== GFX6
) {
728 if (AddrSurfInfoIn
.tileType
== ADDR_DISPLAYABLE
) {
730 AddrSurfInfoIn
.tileIndex
= 11; /* 16bpp */
732 AddrSurfInfoIn
.tileIndex
= 12; /* 32bpp */
735 AddrSurfInfoIn
.tileIndex
= 14; /* 8bpp */
736 else if (surf
->bpe
== 2)
737 AddrSurfInfoIn
.tileIndex
= 15; /* 16bpp */
738 else if (surf
->bpe
== 4)
739 AddrSurfInfoIn
.tileIndex
= 16; /* 32bpp */
741 AddrSurfInfoIn
.tileIndex
= 17; /* 64bpp (and 128bpp) */
745 if (AddrSurfInfoIn
.tileType
== ADDR_DISPLAYABLE
)
746 AddrSurfInfoIn
.tileIndex
= 10; /* 2D displayable */
748 AddrSurfInfoIn
.tileIndex
= 14; /* 2D non-displayable */
750 /* Addrlib doesn't set this if tileIndex is forced like above. */
751 AddrSurfInfoOut
.macroModeIndex
= cik_get_macro_tile_index(surf
);
755 surf
->has_stencil
= !!(surf
->flags
& RADEON_SURF_SBUFFER
);
756 surf
->num_dcc_levels
= 0;
759 surf
->dcc_alignment
= 1;
760 surf
->htile_size
= 0;
761 surf
->htile_slice_size
= 0;
762 surf
->htile_alignment
= 1;
764 const bool only_stencil
= (surf
->flags
& RADEON_SURF_SBUFFER
) &&
765 !(surf
->flags
& RADEON_SURF_ZBUFFER
);
767 /* Calculate texture layout information. */
769 for (level
= 0; level
< config
->info
.levels
; level
++) {
770 r
= gfx6_compute_level(addrlib
, config
, surf
, false, level
, compressed
,
771 &AddrSurfInfoIn
, &AddrSurfInfoOut
,
772 &AddrDccIn
, &AddrDccOut
, &AddrHtileIn
, &AddrHtileOut
);
779 /* Check that we actually got a TC-compatible HTILE if
780 * we requested it (only for level 0, since we're not
781 * supporting HTILE on higher mip levels anyway). */
782 assert(AddrSurfInfoOut
.tcCompatible
||
783 !AddrSurfInfoIn
.flags
.tcCompatible
||
784 AddrSurfInfoIn
.flags
.matchStencilTileCfg
);
786 if (AddrSurfInfoIn
.flags
.matchStencilTileCfg
) {
787 if (!AddrSurfInfoOut
.tcCompatible
) {
788 AddrSurfInfoIn
.flags
.tcCompatible
= 0;
789 surf
->flags
&= ~RADEON_SURF_TC_COMPATIBLE_HTILE
;
792 AddrSurfInfoIn
.flags
.matchStencilTileCfg
= 0;
793 AddrSurfInfoIn
.tileIndex
= AddrSurfInfoOut
.tileIndex
;
794 stencil_tile_idx
= AddrSurfInfoOut
.stencilTileIdx
;
796 assert(stencil_tile_idx
>= 0);
799 r
= gfx6_surface_settings(addrlib
, info
, config
,
800 &AddrSurfInfoOut
, surf
);
806 /* Calculate texture layout information for stencil. */
807 if (surf
->flags
& RADEON_SURF_SBUFFER
) {
808 AddrSurfInfoIn
.tileIndex
= stencil_tile_idx
;
809 AddrSurfInfoIn
.bpp
= 8;
810 AddrSurfInfoIn
.flags
.depth
= 0;
811 AddrSurfInfoIn
.flags
.stencil
= 1;
812 AddrSurfInfoIn
.flags
.tcCompatible
= 0;
813 /* This will be ignored if AddrSurfInfoIn.pTileInfo is NULL. */
814 AddrTileInfoIn
.tileSplitBytes
= surf
->u
.legacy
.stencil_tile_split
;
816 for (level
= 0; level
< config
->info
.levels
; level
++) {
817 r
= gfx6_compute_level(addrlib
, config
, surf
, true, level
, compressed
,
818 &AddrSurfInfoIn
, &AddrSurfInfoOut
,
819 &AddrDccIn
, &AddrDccOut
,
824 /* DB uses the depth pitch for both stencil and depth. */
826 if (surf
->u
.legacy
.stencil_level
[level
].nblk_x
!=
827 surf
->u
.legacy
.level
[level
].nblk_x
)
828 surf
->u
.legacy
.stencil_adjusted
= true;
830 surf
->u
.legacy
.level
[level
].nblk_x
=
831 surf
->u
.legacy
.stencil_level
[level
].nblk_x
;
836 r
= gfx6_surface_settings(addrlib
, info
, config
,
837 &AddrSurfInfoOut
, surf
);
842 /* For 2D modes only. */
843 if (AddrSurfInfoOut
.tileMode
>= ADDR_TM_2D_TILED_THIN1
) {
844 surf
->u
.legacy
.stencil_tile_split
=
845 AddrSurfInfoOut
.pTileInfo
->tileSplitBytes
;
852 if (config
->info
.samples
>= 2 && AddrSurfInfoIn
.flags
.color
) {
853 ADDR_COMPUTE_FMASK_INFO_INPUT fin
= {0};
854 ADDR_COMPUTE_FMASK_INFO_OUTPUT fout
= {0};
855 ADDR_TILEINFO fmask_tile_info
= {};
857 fin
.size
= sizeof(fin
);
858 fout
.size
= sizeof(fout
);
860 fin
.tileMode
= AddrSurfInfoOut
.tileMode
;
861 fin
.pitch
= AddrSurfInfoOut
.pitch
;
862 fin
.height
= config
->info
.height
;
863 fin
.numSlices
= AddrSurfInfoIn
.numSlices
;
864 fin
.numSamples
= AddrSurfInfoIn
.numSamples
;
865 fin
.numFrags
= AddrSurfInfoIn
.numFrags
;
867 fout
.pTileInfo
= &fmask_tile_info
;
869 r
= AddrComputeFmaskInfo(addrlib
, &fin
, &fout
);
873 surf
->fmask_size
= fout
.fmaskBytes
;
874 surf
->fmask_alignment
= fout
.baseAlign
;
875 surf
->fmask_tile_swizzle
= 0;
877 surf
->u
.legacy
.fmask
.slice_tile_max
=
878 (fout
.pitch
* fout
.height
) / 64;
879 if (surf
->u
.legacy
.fmask
.slice_tile_max
)
880 surf
->u
.legacy
.fmask
.slice_tile_max
-= 1;
882 surf
->u
.legacy
.fmask
.tiling_index
= fout
.tileIndex
;
883 surf
->u
.legacy
.fmask
.bankh
= fout
.pTileInfo
->bankHeight
;
884 surf
->u
.legacy
.fmask
.pitch_in_pixels
= fout
.pitch
;
885 surf
->u
.legacy
.fmask
.slice_size
= fout
.sliceSize
;
887 /* Compute tile swizzle for FMASK. */
888 if (config
->info
.fmask_surf_index
&&
889 !(surf
->flags
& RADEON_SURF_SHAREABLE
)) {
890 ADDR_COMPUTE_BASE_SWIZZLE_INPUT xin
= {0};
891 ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT xout
= {0};
893 xin
.size
= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_INPUT
);
894 xout
.size
= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT
);
896 /* This counter starts from 1 instead of 0. */
897 xin
.surfIndex
= p_atomic_inc_return(config
->info
.fmask_surf_index
);
898 xin
.tileIndex
= fout
.tileIndex
;
899 xin
.macroModeIndex
= fout
.macroModeIndex
;
900 xin
.pTileInfo
= fout
.pTileInfo
;
901 xin
.tileMode
= fin
.tileMode
;
903 int r
= AddrComputeBaseSwizzle(addrlib
, &xin
, &xout
);
907 assert(xout
.tileSwizzle
<=
908 u_bit_consecutive(0, sizeof(surf
->tile_swizzle
) * 8));
909 surf
->fmask_tile_swizzle
= xout
.tileSwizzle
;
913 /* Recalculate the whole DCC miptree size including disabled levels.
914 * This is what addrlib does, but calling addrlib would be a lot more
917 if (surf
->dcc_size
&& config
->info
.levels
> 1) {
918 /* The smallest miplevels that are never compressed by DCC
919 * still read the DCC buffer via TC if the base level uses DCC,
920 * and for some reason the DCC buffer needs to be larger if
921 * the miptree uses non-zero tile_swizzle. Otherwise there are
924 * "dcc_alignment * 4" was determined by trial and error.
926 surf
->dcc_size
= align64(surf
->surf_size
>> 8,
927 surf
->dcc_alignment
* 4);
930 /* Make sure HTILE covers the whole miptree, because the shader reads
931 * TC-compatible HTILE even for levels where it's disabled by DB.
933 if (surf
->htile_size
&& config
->info
.levels
> 1 &&
934 surf
->flags
& RADEON_SURF_TC_COMPATIBLE_HTILE
) {
935 /* MSAA can't occur with levels > 1, so ignore the sample count. */
936 const unsigned total_pixels
= surf
->surf_size
/ surf
->bpe
;
937 const unsigned htile_block_size
= 8 * 8;
938 const unsigned htile_element_size
= 4;
940 surf
->htile_size
= (total_pixels
/ htile_block_size
) *
942 surf
->htile_size
= align(surf
->htile_size
, surf
->htile_alignment
);
945 surf
->is_linear
= surf
->u
.legacy
.level
[0].mode
== RADEON_SURF_MODE_LINEAR_ALIGNED
;
946 surf
->is_displayable
= surf
->is_linear
||
947 surf
->micro_tile_mode
== RADEON_MICRO_MODE_DISPLAY
||
948 surf
->micro_tile_mode
== RADEON_MICRO_MODE_ROTATED
;
950 /* The rotated micro tile mode doesn't work if both CMASK and RB+ are
951 * used at the same time. This case is not currently expected to occur
952 * because we don't use rotated. Enforce this restriction on all chips
953 * to facilitate testing.
955 if (surf
->micro_tile_mode
== RADEON_MICRO_MODE_ROTATED
) {
956 assert(!"rotate micro tile mode is unsupported");
960 ac_compute_cmask(info
, config
, surf
);
964 /* This is only called when expecting a tiled layout. */
966 gfx9_get_preferred_swizzle_mode(ADDR_HANDLE addrlib
,
967 ADDR2_COMPUTE_SURFACE_INFO_INPUT
*in
,
968 bool is_fmask
, AddrSwizzleMode
*swizzle_mode
)
970 ADDR_E_RETURNCODE ret
;
971 ADDR2_GET_PREFERRED_SURF_SETTING_INPUT sin
= {0};
972 ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT sout
= {0};
974 sin
.size
= sizeof(ADDR2_GET_PREFERRED_SURF_SETTING_INPUT
);
975 sout
.size
= sizeof(ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT
);
977 sin
.flags
= in
->flags
;
978 sin
.resourceType
= in
->resourceType
;
979 sin
.format
= in
->format
;
980 sin
.resourceLoction
= ADDR_RSRC_LOC_INVIS
;
981 /* TODO: We could allow some of these: */
982 sin
.forbiddenBlock
.micro
= 1; /* don't allow the 256B swizzle modes */
983 sin
.forbiddenBlock
.var
= 1; /* don't allow the variable-sized swizzle modes */
984 sin
.forbiddenBlock
.linear
= 1; /* don't allow linear swizzle modes */
986 sin
.width
= in
->width
;
987 sin
.height
= in
->height
;
988 sin
.numSlices
= in
->numSlices
;
989 sin
.numMipLevels
= in
->numMipLevels
;
990 sin
.numSamples
= in
->numSamples
;
991 sin
.numFrags
= in
->numFrags
;
994 sin
.flags
.display
= 0;
999 ret
= Addr2GetPreferredSurfaceSetting(addrlib
, &sin
, &sout
);
1003 *swizzle_mode
= sout
.swizzleMode
;
1007 static int gfx9_compute_miptree(ADDR_HANDLE addrlib
,
1008 const struct radeon_info
*info
,
1009 const struct ac_surf_config
*config
,
1010 struct radeon_surf
*surf
, bool compressed
,
1011 ADDR2_COMPUTE_SURFACE_INFO_INPUT
*in
)
1013 ADDR2_MIP_INFO mip_info
[RADEON_SURF_MAX_LEVELS
] = {};
1014 ADDR2_COMPUTE_SURFACE_INFO_OUTPUT out
= {0};
1015 ADDR_E_RETURNCODE ret
;
1017 out
.size
= sizeof(ADDR2_COMPUTE_SURFACE_INFO_OUTPUT
);
1018 out
.pMipInfo
= mip_info
;
1020 ret
= Addr2ComputeSurfaceInfo(addrlib
, in
, &out
);
1024 if (in
->flags
.stencil
) {
1025 surf
->u
.gfx9
.stencil
.swizzle_mode
= in
->swizzleMode
;
1026 surf
->u
.gfx9
.stencil
.epitch
= out
.epitchIsHeight
? out
.mipChainHeight
- 1 :
1027 out
.mipChainPitch
- 1;
1028 surf
->surf_alignment
= MAX2(surf
->surf_alignment
, out
.baseAlign
);
1029 surf
->u
.gfx9
.stencil_offset
= align(surf
->surf_size
, out
.baseAlign
);
1030 surf
->surf_size
= surf
->u
.gfx9
.stencil_offset
+ out
.surfSize
;
1034 surf
->u
.gfx9
.surf
.swizzle_mode
= in
->swizzleMode
;
1035 surf
->u
.gfx9
.surf
.epitch
= out
.epitchIsHeight
? out
.mipChainHeight
- 1 :
1036 out
.mipChainPitch
- 1;
1038 /* CMASK fast clear uses these even if FMASK isn't allocated.
1039 * FMASK only supports the Z swizzle modes, whose numbers are multiples of 4.
1041 surf
->u
.gfx9
.fmask
.swizzle_mode
= surf
->u
.gfx9
.surf
.swizzle_mode
& ~0x3;
1042 surf
->u
.gfx9
.fmask
.epitch
= surf
->u
.gfx9
.surf
.epitch
;
1044 surf
->u
.gfx9
.surf_slice_size
= out
.sliceSize
;
1045 surf
->u
.gfx9
.surf_pitch
= out
.pitch
;
1046 surf
->u
.gfx9
.surf_height
= out
.height
;
1047 surf
->surf_size
= out
.surfSize
;
1048 surf
->surf_alignment
= out
.baseAlign
;
1050 if (in
->swizzleMode
== ADDR_SW_LINEAR
) {
1051 for (unsigned i
= 0; i
< in
->numMipLevels
; i
++)
1052 surf
->u
.gfx9
.offset
[i
] = mip_info
[i
].offset
;
1055 if (in
->flags
.depth
) {
1056 assert(in
->swizzleMode
!= ADDR_SW_LINEAR
);
1059 ADDR2_COMPUTE_HTILE_INFO_INPUT hin
= {0};
1060 ADDR2_COMPUTE_HTILE_INFO_OUTPUT hout
= {0};
1062 hin
.size
= sizeof(ADDR2_COMPUTE_HTILE_INFO_INPUT
);
1063 hout
.size
= sizeof(ADDR2_COMPUTE_HTILE_INFO_OUTPUT
);
1065 hin
.hTileFlags
.pipeAligned
= !in
->flags
.metaPipeUnaligned
;
1066 hin
.hTileFlags
.rbAligned
= !in
->flags
.metaRbUnaligned
;
1067 hin
.depthFlags
= in
->flags
;
1068 hin
.swizzleMode
= in
->swizzleMode
;
1069 hin
.unalignedWidth
= in
->width
;
1070 hin
.unalignedHeight
= in
->height
;
1071 hin
.numSlices
= in
->numSlices
;
1072 hin
.numMipLevels
= in
->numMipLevels
;
1073 hin
.firstMipIdInTail
= out
.firstMipIdInTail
;
1075 ret
= Addr2ComputeHtileInfo(addrlib
, &hin
, &hout
);
1079 surf
->u
.gfx9
.htile
.rb_aligned
= hin
.hTileFlags
.rbAligned
;
1080 surf
->u
.gfx9
.htile
.pipe_aligned
= hin
.hTileFlags
.pipeAligned
;
1081 surf
->htile_size
= hout
.htileBytes
;
1082 surf
->htile_slice_size
= hout
.sliceSize
;
1083 surf
->htile_alignment
= hout
.baseAlign
;
1085 /* Compute tile swizzle for the color surface.
1086 * All *_X and *_T modes can use the swizzle.
1088 if (config
->info
.surf_index
&&
1089 in
->swizzleMode
>= ADDR_SW_64KB_Z_T
&&
1090 !out
.mipChainInTail
&&
1091 !(surf
->flags
& RADEON_SURF_SHAREABLE
) &&
1092 !in
->flags
.display
) {
1093 ADDR2_COMPUTE_PIPEBANKXOR_INPUT xin
= {0};
1094 ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT xout
= {0};
1096 xin
.size
= sizeof(ADDR2_COMPUTE_PIPEBANKXOR_INPUT
);
1097 xout
.size
= sizeof(ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT
);
1099 xin
.surfIndex
= p_atomic_inc_return(config
->info
.surf_index
) - 1;
1100 xin
.flags
= in
->flags
;
1101 xin
.swizzleMode
= in
->swizzleMode
;
1102 xin
.resourceType
= in
->resourceType
;
1103 xin
.format
= in
->format
;
1104 xin
.numSamples
= in
->numSamples
;
1105 xin
.numFrags
= in
->numFrags
;
1107 ret
= Addr2ComputePipeBankXor(addrlib
, &xin
, &xout
);
1111 assert(xout
.pipeBankXor
<=
1112 u_bit_consecutive(0, sizeof(surf
->tile_swizzle
) * 8));
1113 surf
->tile_swizzle
= xout
.pipeBankXor
;
1117 if (!(surf
->flags
& RADEON_SURF_DISABLE_DCC
) &&
1119 in
->swizzleMode
!= ADDR_SW_LINEAR
) {
1120 ADDR2_COMPUTE_DCCINFO_INPUT din
= {0};
1121 ADDR2_COMPUTE_DCCINFO_OUTPUT dout
= {0};
1122 ADDR2_META_MIP_INFO meta_mip_info
[RADEON_SURF_MAX_LEVELS
] = {};
1124 din
.size
= sizeof(ADDR2_COMPUTE_DCCINFO_INPUT
);
1125 dout
.size
= sizeof(ADDR2_COMPUTE_DCCINFO_OUTPUT
);
1126 dout
.pMipInfo
= meta_mip_info
;
1128 din
.dccKeyFlags
.pipeAligned
= !in
->flags
.metaPipeUnaligned
;
1129 din
.dccKeyFlags
.rbAligned
= !in
->flags
.metaRbUnaligned
;
1130 din
.colorFlags
= in
->flags
;
1131 din
.resourceType
= in
->resourceType
;
1132 din
.swizzleMode
= in
->swizzleMode
;
1134 din
.unalignedWidth
= in
->width
;
1135 din
.unalignedHeight
= in
->height
;
1136 din
.numSlices
= in
->numSlices
;
1137 din
.numFrags
= in
->numFrags
;
1138 din
.numMipLevels
= in
->numMipLevels
;
1139 din
.dataSurfaceSize
= out
.surfSize
;
1140 din
.firstMipIdInTail
= out
.firstMipIdInTail
;
1142 ret
= Addr2ComputeDccInfo(addrlib
, &din
, &dout
);
1146 surf
->u
.gfx9
.dcc
.rb_aligned
= din
.dccKeyFlags
.rbAligned
;
1147 surf
->u
.gfx9
.dcc
.pipe_aligned
= din
.dccKeyFlags
.pipeAligned
;
1148 surf
->dcc_size
= dout
.dccRamSize
;
1149 surf
->dcc_alignment
= dout
.dccRamBaseAlign
;
1150 surf
->num_dcc_levels
= in
->numMipLevels
;
1152 /* Disable DCC for levels that are in the mip tail.
1154 * There are two issues that this is intended to
1157 * 1. Multiple mip levels may share a cache line. This
1158 * can lead to corruption when switching between
1159 * rendering to different mip levels because the
1160 * RBs don't maintain coherency.
1162 * 2. Texturing with metadata after rendering sometimes
1163 * fails with corruption, probably for a similar
1166 * Working around these issues for all levels in the
1167 * mip tail may be overly conservative, but it's what
1170 * Alternative solutions that also work but are worse:
1171 * - Disable DCC entirely.
1172 * - Flush TC L2 after rendering.
1174 for (unsigned i
= 0; i
< in
->numMipLevels
; i
++) {
1175 if (meta_mip_info
[i
].inMiptail
) {
1176 surf
->num_dcc_levels
= i
;
1181 if (!surf
->num_dcc_levels
)
1184 surf
->u
.gfx9
.display_dcc_size
= surf
->dcc_size
;
1185 surf
->u
.gfx9
.display_dcc_alignment
= surf
->dcc_alignment
;
1186 surf
->u
.gfx9
.display_dcc_pitch_max
= dout
.pitch
- 1;
1188 /* Compute displayable DCC. */
1189 if (in
->flags
.display
&&
1190 surf
->num_dcc_levels
&&
1191 info
->use_display_dcc_with_retile_blit
) {
1192 /* Compute displayable DCC info. */
1193 din
.dccKeyFlags
.pipeAligned
= 0;
1194 din
.dccKeyFlags
.rbAligned
= 0;
1196 assert(din
.numSlices
== 1);
1197 assert(din
.numMipLevels
== 1);
1198 assert(din
.numFrags
== 1);
1199 assert(surf
->tile_swizzle
== 0);
1200 assert(surf
->u
.gfx9
.dcc
.pipe_aligned
||
1201 surf
->u
.gfx9
.dcc
.rb_aligned
);
1203 ret
= Addr2ComputeDccInfo(addrlib
, &din
, &dout
);
1207 surf
->u
.gfx9
.display_dcc_size
= dout
.dccRamSize
;
1208 surf
->u
.gfx9
.display_dcc_alignment
= dout
.dccRamBaseAlign
;
1209 surf
->u
.gfx9
.display_dcc_pitch_max
= dout
.pitch
- 1;
1210 assert(surf
->u
.gfx9
.display_dcc_size
<= surf
->dcc_size
);
1212 /* Compute address mapping from non-displayable to displayable DCC. */
1213 ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT addrin
= {};
1214 addrin
.size
= sizeof(addrin
);
1215 addrin
.colorFlags
.color
= 1;
1216 addrin
.swizzleMode
= din
.swizzleMode
;
1217 addrin
.resourceType
= din
.resourceType
;
1218 addrin
.bpp
= din
.bpp
;
1219 addrin
.unalignedWidth
= din
.unalignedWidth
;
1220 addrin
.unalignedHeight
= din
.unalignedHeight
;
1221 addrin
.numSlices
= 1;
1222 addrin
.numMipLevels
= 1;
1223 addrin
.numFrags
= 1;
1225 ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT addrout
= {};
1226 addrout
.size
= sizeof(addrout
);
1228 surf
->u
.gfx9
.dcc_retile_num_elements
=
1229 DIV_ROUND_UP(in
->width
, dout
.compressBlkWidth
) *
1230 DIV_ROUND_UP(in
->height
, dout
.compressBlkHeight
) * 2;
1231 /* Align the size to 4 (for the compute shader). */
1232 surf
->u
.gfx9
.dcc_retile_num_elements
=
1233 align(surf
->u
.gfx9
.dcc_retile_num_elements
, 4);
1235 surf
->u
.gfx9
.dcc_retile_map
=
1236 malloc(surf
->u
.gfx9
.dcc_retile_num_elements
* 4);
1237 if (!surf
->u
.gfx9
.dcc_retile_map
)
1238 return ADDR_OUTOFMEMORY
;
1241 surf
->u
.gfx9
.dcc_retile_use_uint16
= true;
1243 for (unsigned y
= 0; y
< in
->height
; y
+= dout
.compressBlkHeight
) {
1246 for (unsigned x
= 0; x
< in
->width
; x
+= dout
.compressBlkWidth
) {
1249 /* Compute src DCC address */
1250 addrin
.dccKeyFlags
.pipeAligned
= surf
->u
.gfx9
.dcc
.pipe_aligned
;
1251 addrin
.dccKeyFlags
.rbAligned
= surf
->u
.gfx9
.dcc
.rb_aligned
;
1254 ret
= Addr2ComputeDccAddrFromCoord(addrlib
, &addrin
, &addrout
);
1258 surf
->u
.gfx9
.dcc_retile_map
[index
* 2] = addrout
.addr
;
1259 if (addrout
.addr
> USHRT_MAX
)
1260 surf
->u
.gfx9
.dcc_retile_use_uint16
= false;
1262 /* Compute dst DCC address */
1263 addrin
.dccKeyFlags
.pipeAligned
= 0;
1264 addrin
.dccKeyFlags
.rbAligned
= 0;
1267 ret
= Addr2ComputeDccAddrFromCoord(addrlib
, &addrin
, &addrout
);
1271 surf
->u
.gfx9
.dcc_retile_map
[index
* 2 + 1] = addrout
.addr
;
1272 if (addrout
.addr
> USHRT_MAX
)
1273 surf
->u
.gfx9
.dcc_retile_use_uint16
= false;
1275 assert(index
* 2 + 1 < surf
->u
.gfx9
.dcc_retile_num_elements
);
1279 /* Fill the remaining pairs with the last one (for the compute shader). */
1280 for (unsigned i
= index
* 2; i
< surf
->u
.gfx9
.dcc_retile_num_elements
; i
++)
1281 surf
->u
.gfx9
.dcc_retile_map
[i
] = surf
->u
.gfx9
.dcc_retile_map
[i
- 2];
1286 if (in
->numSamples
> 1) {
1287 ADDR2_COMPUTE_FMASK_INFO_INPUT fin
= {0};
1288 ADDR2_COMPUTE_FMASK_INFO_OUTPUT fout
= {0};
1290 fin
.size
= sizeof(ADDR2_COMPUTE_FMASK_INFO_INPUT
);
1291 fout
.size
= sizeof(ADDR2_COMPUTE_FMASK_INFO_OUTPUT
);
1293 ret
= gfx9_get_preferred_swizzle_mode(addrlib
, in
,
1294 true, &fin
.swizzleMode
);
1298 fin
.unalignedWidth
= in
->width
;
1299 fin
.unalignedHeight
= in
->height
;
1300 fin
.numSlices
= in
->numSlices
;
1301 fin
.numSamples
= in
->numSamples
;
1302 fin
.numFrags
= in
->numFrags
;
1304 ret
= Addr2ComputeFmaskInfo(addrlib
, &fin
, &fout
);
1308 surf
->u
.gfx9
.fmask
.swizzle_mode
= fin
.swizzleMode
;
1309 surf
->u
.gfx9
.fmask
.epitch
= fout
.pitch
- 1;
1310 surf
->fmask_size
= fout
.fmaskBytes
;
1311 surf
->fmask_alignment
= fout
.baseAlign
;
1313 /* Compute tile swizzle for the FMASK surface. */
1314 if (config
->info
.fmask_surf_index
&&
1315 fin
.swizzleMode
>= ADDR_SW_64KB_Z_T
&&
1316 !(surf
->flags
& RADEON_SURF_SHAREABLE
)) {
1317 ADDR2_COMPUTE_PIPEBANKXOR_INPUT xin
= {0};
1318 ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT xout
= {0};
1320 xin
.size
= sizeof(ADDR2_COMPUTE_PIPEBANKXOR_INPUT
);
1321 xout
.size
= sizeof(ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT
);
1323 /* This counter starts from 1 instead of 0. */
1324 xin
.surfIndex
= p_atomic_inc_return(config
->info
.fmask_surf_index
);
1325 xin
.flags
= in
->flags
;
1326 xin
.swizzleMode
= fin
.swizzleMode
;
1327 xin
.resourceType
= in
->resourceType
;
1328 xin
.format
= in
->format
;
1329 xin
.numSamples
= in
->numSamples
;
1330 xin
.numFrags
= in
->numFrags
;
1332 ret
= Addr2ComputePipeBankXor(addrlib
, &xin
, &xout
);
1336 assert(xout
.pipeBankXor
<=
1337 u_bit_consecutive(0, sizeof(surf
->fmask_tile_swizzle
) * 8));
1338 surf
->fmask_tile_swizzle
= xout
.pipeBankXor
;
1343 if (in
->swizzleMode
!= ADDR_SW_LINEAR
) {
1344 ADDR2_COMPUTE_CMASK_INFO_INPUT cin
= {0};
1345 ADDR2_COMPUTE_CMASK_INFO_OUTPUT cout
= {0};
1347 cin
.size
= sizeof(ADDR2_COMPUTE_CMASK_INFO_INPUT
);
1348 cout
.size
= sizeof(ADDR2_COMPUTE_CMASK_INFO_OUTPUT
);
1350 if (in
->numSamples
> 1) {
1351 /* FMASK is always aligned. */
1352 cin
.cMaskFlags
.pipeAligned
= 1;
1353 cin
.cMaskFlags
.rbAligned
= 1;
1355 cin
.cMaskFlags
.pipeAligned
= !in
->flags
.metaPipeUnaligned
;
1356 cin
.cMaskFlags
.rbAligned
= !in
->flags
.metaRbUnaligned
;
1358 cin
.colorFlags
= in
->flags
;
1359 cin
.resourceType
= in
->resourceType
;
1360 cin
.unalignedWidth
= in
->width
;
1361 cin
.unalignedHeight
= in
->height
;
1362 cin
.numSlices
= in
->numSlices
;
1364 if (in
->numSamples
> 1)
1365 cin
.swizzleMode
= surf
->u
.gfx9
.fmask
.swizzle_mode
;
1367 cin
.swizzleMode
= in
->swizzleMode
;
1369 ret
= Addr2ComputeCmaskInfo(addrlib
, &cin
, &cout
);
1373 surf
->u
.gfx9
.cmask
.rb_aligned
= cin
.cMaskFlags
.rbAligned
;
1374 surf
->u
.gfx9
.cmask
.pipe_aligned
= cin
.cMaskFlags
.pipeAligned
;
1375 surf
->cmask_size
= cout
.cmaskBytes
;
1376 surf
->cmask_alignment
= cout
.baseAlign
;
1383 static int gfx9_compute_surface(ADDR_HANDLE addrlib
,
1384 const struct radeon_info
*info
,
1385 const struct ac_surf_config
*config
,
1386 enum radeon_surf_mode mode
,
1387 struct radeon_surf
*surf
)
1390 ADDR2_COMPUTE_SURFACE_INFO_INPUT AddrSurfInfoIn
= {0};
1393 AddrSurfInfoIn
.size
= sizeof(ADDR2_COMPUTE_SURFACE_INFO_INPUT
);
1395 compressed
= surf
->blk_w
== 4 && surf
->blk_h
== 4;
1397 /* The format must be set correctly for the allocation of compressed
1398 * textures to work. In other cases, setting the bpp is sufficient. */
1400 switch (surf
->bpe
) {
1402 AddrSurfInfoIn
.format
= ADDR_FMT_BC1
;
1405 AddrSurfInfoIn
.format
= ADDR_FMT_BC3
;
1411 switch (surf
->bpe
) {
1413 assert(!(surf
->flags
& RADEON_SURF_ZBUFFER
));
1414 AddrSurfInfoIn
.format
= ADDR_FMT_8
;
1417 assert(surf
->flags
& RADEON_SURF_ZBUFFER
||
1418 !(surf
->flags
& RADEON_SURF_SBUFFER
));
1419 AddrSurfInfoIn
.format
= ADDR_FMT_16
;
1422 assert(surf
->flags
& RADEON_SURF_ZBUFFER
||
1423 !(surf
->flags
& RADEON_SURF_SBUFFER
));
1424 AddrSurfInfoIn
.format
= ADDR_FMT_32
;
1427 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
1428 AddrSurfInfoIn
.format
= ADDR_FMT_32_32
;
1431 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
1432 AddrSurfInfoIn
.format
= ADDR_FMT_32_32_32
;
1435 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
1436 AddrSurfInfoIn
.format
= ADDR_FMT_32_32_32_32
;
1441 AddrSurfInfoIn
.bpp
= surf
->bpe
* 8;
1444 bool is_color_surface
= !(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
);
1445 AddrSurfInfoIn
.flags
.color
= is_color_surface
&&
1446 !(surf
->flags
& RADEON_SURF_NO_RENDER_TARGET
);
1447 AddrSurfInfoIn
.flags
.depth
= (surf
->flags
& RADEON_SURF_ZBUFFER
) != 0;
1448 AddrSurfInfoIn
.flags
.display
= get_display_flag(config
, surf
);
1449 /* flags.texture currently refers to TC-compatible HTILE */
1450 AddrSurfInfoIn
.flags
.texture
= is_color_surface
||
1451 surf
->flags
& RADEON_SURF_TC_COMPATIBLE_HTILE
;
1452 AddrSurfInfoIn
.flags
.opt4space
= 1;
1454 AddrSurfInfoIn
.numMipLevels
= config
->info
.levels
;
1455 AddrSurfInfoIn
.numSamples
= MAX2(1, config
->info
.samples
);
1456 AddrSurfInfoIn
.numFrags
= AddrSurfInfoIn
.numSamples
;
1458 if (!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
))
1459 AddrSurfInfoIn
.numFrags
= MAX2(1, config
->info
.storage_samples
);
1461 /* GFX9 doesn't support 1D depth textures, so allocate all 1D textures
1462 * as 2D to avoid having shader variants for 1D vs 2D, so all shaders
1463 * must sample 1D textures as 2D. */
1465 AddrSurfInfoIn
.resourceType
= ADDR_RSRC_TEX_3D
;
1467 AddrSurfInfoIn
.resourceType
= ADDR_RSRC_TEX_2D
;
1469 AddrSurfInfoIn
.width
= config
->info
.width
;
1470 AddrSurfInfoIn
.height
= config
->info
.height
;
1473 AddrSurfInfoIn
.numSlices
= config
->info
.depth
;
1474 else if (config
->is_cube
)
1475 AddrSurfInfoIn
.numSlices
= 6;
1477 AddrSurfInfoIn
.numSlices
= config
->info
.array_size
;
1479 /* This is propagated to HTILE/DCC/CMASK. */
1480 AddrSurfInfoIn
.flags
.metaPipeUnaligned
= 0;
1481 AddrSurfInfoIn
.flags
.metaRbUnaligned
= 0;
1483 /* The display hardware can only read DCC with RB_ALIGNED=0 and
1484 * PIPE_ALIGNED=0. PIPE_ALIGNED really means L2CACHE_ALIGNED.
1486 * The CB block requires RB_ALIGNED=1 except 1 RB chips.
1487 * PIPE_ALIGNED is optional, but PIPE_ALIGNED=0 requires L2 flushes
1488 * after rendering, so PIPE_ALIGNED=1 is recommended.
1490 if (info
->use_display_dcc_unaligned
&& is_color_surface
&&
1491 AddrSurfInfoIn
.flags
.display
) {
1492 AddrSurfInfoIn
.flags
.metaPipeUnaligned
= 1;
1493 AddrSurfInfoIn
.flags
.metaRbUnaligned
= 1;
1497 case RADEON_SURF_MODE_LINEAR_ALIGNED
:
1498 assert(config
->info
.samples
<= 1);
1499 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
1500 AddrSurfInfoIn
.swizzleMode
= ADDR_SW_LINEAR
;
1503 case RADEON_SURF_MODE_1D
:
1504 case RADEON_SURF_MODE_2D
:
1505 if (surf
->flags
& RADEON_SURF_IMPORTED
) {
1506 AddrSurfInfoIn
.swizzleMode
= surf
->u
.gfx9
.surf
.swizzle_mode
;
1510 r
= gfx9_get_preferred_swizzle_mode(addrlib
, &AddrSurfInfoIn
,
1511 false, &AddrSurfInfoIn
.swizzleMode
);
1520 surf
->u
.gfx9
.resource_type
= AddrSurfInfoIn
.resourceType
;
1521 surf
->has_stencil
= !!(surf
->flags
& RADEON_SURF_SBUFFER
);
1523 surf
->num_dcc_levels
= 0;
1524 surf
->surf_size
= 0;
1525 surf
->fmask_size
= 0;
1527 surf
->htile_size
= 0;
1528 surf
->htile_slice_size
= 0;
1529 surf
->u
.gfx9
.surf_offset
= 0;
1530 surf
->u
.gfx9
.stencil_offset
= 0;
1531 surf
->cmask_size
= 0;
1532 surf
->u
.gfx9
.dcc_retile_use_uint16
= false;
1533 surf
->u
.gfx9
.dcc_retile_num_elements
= 0;
1534 surf
->u
.gfx9
.dcc_retile_map
= NULL
;
1536 /* Calculate texture layout information. */
1537 r
= gfx9_compute_miptree(addrlib
, info
, config
, surf
, compressed
,
1542 /* Calculate texture layout information for stencil. */
1543 if (surf
->flags
& RADEON_SURF_SBUFFER
) {
1544 AddrSurfInfoIn
.flags
.stencil
= 1;
1545 AddrSurfInfoIn
.bpp
= 8;
1546 AddrSurfInfoIn
.format
= ADDR_FMT_8
;
1548 if (!AddrSurfInfoIn
.flags
.depth
) {
1549 r
= gfx9_get_preferred_swizzle_mode(addrlib
, &AddrSurfInfoIn
,
1550 false, &AddrSurfInfoIn
.swizzleMode
);
1554 AddrSurfInfoIn
.flags
.depth
= 0;
1556 r
= gfx9_compute_miptree(addrlib
, info
, config
, surf
, compressed
,
1562 surf
->is_linear
= surf
->u
.gfx9
.surf
.swizzle_mode
== ADDR_SW_LINEAR
;
1564 /* Query whether the surface is displayable. */
1565 bool displayable
= false;
1566 if (!config
->is_3d
&& !config
->is_cube
) {
1567 r
= Addr2IsValidDisplaySwizzleMode(addrlib
, surf
->u
.gfx9
.surf
.swizzle_mode
,
1568 surf
->bpe
* 8, &displayable
);
1572 /* Display needs unaligned DCC. */
1573 if (info
->use_display_dcc_unaligned
&&
1574 surf
->num_dcc_levels
&&
1575 (surf
->u
.gfx9
.dcc
.pipe_aligned
||
1576 surf
->u
.gfx9
.dcc
.rb_aligned
))
1577 displayable
= false;
1579 surf
->is_displayable
= displayable
;
1581 switch (surf
->u
.gfx9
.surf
.swizzle_mode
) {
1583 case ADDR_SW_256B_S
:
1585 case ADDR_SW_64KB_S
:
1587 case ADDR_SW_64KB_S_T
:
1588 case ADDR_SW_4KB_S_X
:
1589 case ADDR_SW_64KB_S_X
:
1590 case ADDR_SW_VAR_S_X
:
1591 surf
->micro_tile_mode
= RADEON_MICRO_MODE_THIN
;
1595 case ADDR_SW_LINEAR
:
1596 case ADDR_SW_256B_D
:
1598 case ADDR_SW_64KB_D
:
1600 case ADDR_SW_64KB_D_T
:
1601 case ADDR_SW_4KB_D_X
:
1602 case ADDR_SW_64KB_D_X
:
1603 case ADDR_SW_VAR_D_X
:
1604 surf
->micro_tile_mode
= RADEON_MICRO_MODE_DISPLAY
;
1608 case ADDR_SW_256B_R
:
1610 case ADDR_SW_64KB_R
:
1612 case ADDR_SW_64KB_R_T
:
1613 case ADDR_SW_4KB_R_X
:
1614 case ADDR_SW_64KB_R_X
:
1615 case ADDR_SW_VAR_R_X
:
1616 /* The rotated micro tile mode doesn't work if both CMASK and RB+ are
1617 * used at the same time. This case is not currently expected to occur
1618 * because we don't use rotated. Enforce this restriction on all chips
1619 * to facilitate testing.
1621 assert(!"rotate micro tile mode is unsupported");
1627 case ADDR_SW_64KB_Z
:
1629 case ADDR_SW_64KB_Z_T
:
1630 case ADDR_SW_4KB_Z_X
:
1631 case ADDR_SW_64KB_Z_X
:
1632 case ADDR_SW_VAR_Z_X
:
1633 surf
->micro_tile_mode
= RADEON_MICRO_MODE_DEPTH
;
1643 free(surf
->u
.gfx9
.dcc_retile_map
);
1644 surf
->u
.gfx9
.dcc_retile_map
= NULL
;
1648 int ac_compute_surface(ADDR_HANDLE addrlib
, const struct radeon_info
*info
,
1649 const struct ac_surf_config
*config
,
1650 enum radeon_surf_mode mode
,
1651 struct radeon_surf
*surf
)
1655 r
= surf_config_sanity(config
, surf
->flags
);
1659 if (info
->chip_class
>= GFX9
)
1660 return gfx9_compute_surface(addrlib
, info
, config
, mode
, surf
);
1662 return gfx6_compute_surface(addrlib
, info
, config
, mode
, surf
);