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 info
->has_graphics
&& /* disable DCC on compute-only chips */
662 !(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
) &&
663 !(surf
->flags
& RADEON_SURF_DISABLE_DCC
) &&
665 ((config
->info
.array_size
== 1 && config
->info
.depth
== 1) ||
666 config
->info
.levels
== 1);
668 AddrSurfInfoIn
.flags
.noStencil
= (surf
->flags
& RADEON_SURF_SBUFFER
) == 0;
669 AddrSurfInfoIn
.flags
.compressZ
= !!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
);
671 /* On GFX7-GFX8, the DB uses the same pitch and tile mode (except tilesplit)
672 * for Z and stencil. This can cause a number of problems which we work
675 * - a depth part that is incompatible with mipmapped texturing
676 * - at least on Stoney, entirely incompatible Z/S aspects (e.g.
677 * incorrect tiling applied to the stencil part, stencil buffer
678 * memory accesses that go out of bounds) even without mipmapping
680 * Some piglit tests that are prone to different types of related
682 * ./bin/ext_framebuffer_multisample-upsample 2 stencil
683 * ./bin/framebuffer-blit-levels {draw,read} stencil
684 * ./bin/ext_framebuffer_multisample-unaligned-blit N {depth,stencil} {msaa,upsample,downsample}
685 * ./bin/fbo-depth-array fs-writes-{depth,stencil} / {depth,stencil}-{clear,layered-clear,draw}
686 * ./bin/depthstencil-render-miplevels 1024 d=s=z24_s8
688 int stencil_tile_idx
= -1;
690 if (AddrSurfInfoIn
.flags
.depth
&& !AddrSurfInfoIn
.flags
.noStencil
&&
691 (config
->info
.levels
> 1 || info
->family
== CHIP_STONEY
)) {
692 /* Compute stencilTileIdx that is compatible with the (depth)
693 * tileIdx. This degrades the depth surface if necessary to
694 * ensure that a matching stencilTileIdx exists. */
695 AddrSurfInfoIn
.flags
.matchStencilTileCfg
= 1;
697 /* Keep the depth mip-tail compatible with texturing. */
698 AddrSurfInfoIn
.flags
.noStencil
= 1;
701 /* Set preferred macrotile parameters. This is usually required
702 * for shared resources. This is for 2D tiling only. */
703 if (AddrSurfInfoIn
.tileMode
>= ADDR_TM_2D_TILED_THIN1
&&
704 surf
->u
.legacy
.bankw
&& surf
->u
.legacy
.bankh
&&
705 surf
->u
.legacy
.mtilea
&& surf
->u
.legacy
.tile_split
) {
706 /* If any of these parameters are incorrect, the calculation
708 AddrTileInfoIn
.banks
= surf
->u
.legacy
.num_banks
;
709 AddrTileInfoIn
.bankWidth
= surf
->u
.legacy
.bankw
;
710 AddrTileInfoIn
.bankHeight
= surf
->u
.legacy
.bankh
;
711 AddrTileInfoIn
.macroAspectRatio
= surf
->u
.legacy
.mtilea
;
712 AddrTileInfoIn
.tileSplitBytes
= surf
->u
.legacy
.tile_split
;
713 AddrTileInfoIn
.pipeConfig
= surf
->u
.legacy
.pipe_config
+ 1; /* +1 compared to GB_TILE_MODE */
714 AddrSurfInfoIn
.flags
.opt4Space
= 0;
715 AddrSurfInfoIn
.pTileInfo
= &AddrTileInfoIn
;
717 /* If AddrSurfInfoIn.pTileInfo is set, Addrlib doesn't set
718 * the tile index, because we are expected to know it if
719 * we know the other parameters.
721 * This is something that can easily be fixed in Addrlib.
722 * For now, just figure it out here.
723 * Note that only 2D_TILE_THIN1 is handled here.
725 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
726 assert(AddrSurfInfoIn
.tileMode
== ADDR_TM_2D_TILED_THIN1
);
728 if (info
->chip_class
== GFX6
) {
729 if (AddrSurfInfoIn
.tileType
== ADDR_DISPLAYABLE
) {
731 AddrSurfInfoIn
.tileIndex
= 11; /* 16bpp */
733 AddrSurfInfoIn
.tileIndex
= 12; /* 32bpp */
736 AddrSurfInfoIn
.tileIndex
= 14; /* 8bpp */
737 else if (surf
->bpe
== 2)
738 AddrSurfInfoIn
.tileIndex
= 15; /* 16bpp */
739 else if (surf
->bpe
== 4)
740 AddrSurfInfoIn
.tileIndex
= 16; /* 32bpp */
742 AddrSurfInfoIn
.tileIndex
= 17; /* 64bpp (and 128bpp) */
746 if (AddrSurfInfoIn
.tileType
== ADDR_DISPLAYABLE
)
747 AddrSurfInfoIn
.tileIndex
= 10; /* 2D displayable */
749 AddrSurfInfoIn
.tileIndex
= 14; /* 2D non-displayable */
751 /* Addrlib doesn't set this if tileIndex is forced like above. */
752 AddrSurfInfoOut
.macroModeIndex
= cik_get_macro_tile_index(surf
);
756 surf
->has_stencil
= !!(surf
->flags
& RADEON_SURF_SBUFFER
);
757 surf
->num_dcc_levels
= 0;
760 surf
->dcc_alignment
= 1;
761 surf
->htile_size
= 0;
762 surf
->htile_slice_size
= 0;
763 surf
->htile_alignment
= 1;
765 const bool only_stencil
= (surf
->flags
& RADEON_SURF_SBUFFER
) &&
766 !(surf
->flags
& RADEON_SURF_ZBUFFER
);
768 /* Calculate texture layout information. */
770 for (level
= 0; level
< config
->info
.levels
; level
++) {
771 r
= gfx6_compute_level(addrlib
, config
, surf
, false, level
, compressed
,
772 &AddrSurfInfoIn
, &AddrSurfInfoOut
,
773 &AddrDccIn
, &AddrDccOut
, &AddrHtileIn
, &AddrHtileOut
);
780 /* Check that we actually got a TC-compatible HTILE if
781 * we requested it (only for level 0, since we're not
782 * supporting HTILE on higher mip levels anyway). */
783 assert(AddrSurfInfoOut
.tcCompatible
||
784 !AddrSurfInfoIn
.flags
.tcCompatible
||
785 AddrSurfInfoIn
.flags
.matchStencilTileCfg
);
787 if (AddrSurfInfoIn
.flags
.matchStencilTileCfg
) {
788 if (!AddrSurfInfoOut
.tcCompatible
) {
789 AddrSurfInfoIn
.flags
.tcCompatible
= 0;
790 surf
->flags
&= ~RADEON_SURF_TC_COMPATIBLE_HTILE
;
793 AddrSurfInfoIn
.flags
.matchStencilTileCfg
= 0;
794 AddrSurfInfoIn
.tileIndex
= AddrSurfInfoOut
.tileIndex
;
795 stencil_tile_idx
= AddrSurfInfoOut
.stencilTileIdx
;
797 assert(stencil_tile_idx
>= 0);
800 r
= gfx6_surface_settings(addrlib
, info
, config
,
801 &AddrSurfInfoOut
, surf
);
807 /* Calculate texture layout information for stencil. */
808 if (surf
->flags
& RADEON_SURF_SBUFFER
) {
809 AddrSurfInfoIn
.tileIndex
= stencil_tile_idx
;
810 AddrSurfInfoIn
.bpp
= 8;
811 AddrSurfInfoIn
.flags
.depth
= 0;
812 AddrSurfInfoIn
.flags
.stencil
= 1;
813 AddrSurfInfoIn
.flags
.tcCompatible
= 0;
814 /* This will be ignored if AddrSurfInfoIn.pTileInfo is NULL. */
815 AddrTileInfoIn
.tileSplitBytes
= surf
->u
.legacy
.stencil_tile_split
;
817 for (level
= 0; level
< config
->info
.levels
; level
++) {
818 r
= gfx6_compute_level(addrlib
, config
, surf
, true, level
, compressed
,
819 &AddrSurfInfoIn
, &AddrSurfInfoOut
,
820 &AddrDccIn
, &AddrDccOut
,
825 /* DB uses the depth pitch for both stencil and depth. */
827 if (surf
->u
.legacy
.stencil_level
[level
].nblk_x
!=
828 surf
->u
.legacy
.level
[level
].nblk_x
)
829 surf
->u
.legacy
.stencil_adjusted
= true;
831 surf
->u
.legacy
.level
[level
].nblk_x
=
832 surf
->u
.legacy
.stencil_level
[level
].nblk_x
;
837 r
= gfx6_surface_settings(addrlib
, info
, config
,
838 &AddrSurfInfoOut
, surf
);
843 /* For 2D modes only. */
844 if (AddrSurfInfoOut
.tileMode
>= ADDR_TM_2D_TILED_THIN1
) {
845 surf
->u
.legacy
.stencil_tile_split
=
846 AddrSurfInfoOut
.pTileInfo
->tileSplitBytes
;
853 if (config
->info
.samples
>= 2 && AddrSurfInfoIn
.flags
.color
) {
854 ADDR_COMPUTE_FMASK_INFO_INPUT fin
= {0};
855 ADDR_COMPUTE_FMASK_INFO_OUTPUT fout
= {0};
856 ADDR_TILEINFO fmask_tile_info
= {};
858 fin
.size
= sizeof(fin
);
859 fout
.size
= sizeof(fout
);
861 fin
.tileMode
= AddrSurfInfoOut
.tileMode
;
862 fin
.pitch
= AddrSurfInfoOut
.pitch
;
863 fin
.height
= config
->info
.height
;
864 fin
.numSlices
= AddrSurfInfoIn
.numSlices
;
865 fin
.numSamples
= AddrSurfInfoIn
.numSamples
;
866 fin
.numFrags
= AddrSurfInfoIn
.numFrags
;
868 fout
.pTileInfo
= &fmask_tile_info
;
870 r
= AddrComputeFmaskInfo(addrlib
, &fin
, &fout
);
874 surf
->fmask_size
= fout
.fmaskBytes
;
875 surf
->fmask_alignment
= fout
.baseAlign
;
876 surf
->fmask_tile_swizzle
= 0;
878 surf
->u
.legacy
.fmask
.slice_tile_max
=
879 (fout
.pitch
* fout
.height
) / 64;
880 if (surf
->u
.legacy
.fmask
.slice_tile_max
)
881 surf
->u
.legacy
.fmask
.slice_tile_max
-= 1;
883 surf
->u
.legacy
.fmask
.tiling_index
= fout
.tileIndex
;
884 surf
->u
.legacy
.fmask
.bankh
= fout
.pTileInfo
->bankHeight
;
885 surf
->u
.legacy
.fmask
.pitch_in_pixels
= fout
.pitch
;
886 surf
->u
.legacy
.fmask
.slice_size
= fout
.sliceSize
;
888 /* Compute tile swizzle for FMASK. */
889 if (config
->info
.fmask_surf_index
&&
890 !(surf
->flags
& RADEON_SURF_SHAREABLE
)) {
891 ADDR_COMPUTE_BASE_SWIZZLE_INPUT xin
= {0};
892 ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT xout
= {0};
894 xin
.size
= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_INPUT
);
895 xout
.size
= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT
);
897 /* This counter starts from 1 instead of 0. */
898 xin
.surfIndex
= p_atomic_inc_return(config
->info
.fmask_surf_index
);
899 xin
.tileIndex
= fout
.tileIndex
;
900 xin
.macroModeIndex
= fout
.macroModeIndex
;
901 xin
.pTileInfo
= fout
.pTileInfo
;
902 xin
.tileMode
= fin
.tileMode
;
904 int r
= AddrComputeBaseSwizzle(addrlib
, &xin
, &xout
);
908 assert(xout
.tileSwizzle
<=
909 u_bit_consecutive(0, sizeof(surf
->tile_swizzle
) * 8));
910 surf
->fmask_tile_swizzle
= xout
.tileSwizzle
;
914 /* Recalculate the whole DCC miptree size including disabled levels.
915 * This is what addrlib does, but calling addrlib would be a lot more
918 if (surf
->dcc_size
&& config
->info
.levels
> 1) {
919 /* The smallest miplevels that are never compressed by DCC
920 * still read the DCC buffer via TC if the base level uses DCC,
921 * and for some reason the DCC buffer needs to be larger if
922 * the miptree uses non-zero tile_swizzle. Otherwise there are
925 * "dcc_alignment * 4" was determined by trial and error.
927 surf
->dcc_size
= align64(surf
->surf_size
>> 8,
928 surf
->dcc_alignment
* 4);
931 /* Make sure HTILE covers the whole miptree, because the shader reads
932 * TC-compatible HTILE even for levels where it's disabled by DB.
934 if (surf
->htile_size
&& config
->info
.levels
> 1 &&
935 surf
->flags
& RADEON_SURF_TC_COMPATIBLE_HTILE
) {
936 /* MSAA can't occur with levels > 1, so ignore the sample count. */
937 const unsigned total_pixels
= surf
->surf_size
/ surf
->bpe
;
938 const unsigned htile_block_size
= 8 * 8;
939 const unsigned htile_element_size
= 4;
941 surf
->htile_size
= (total_pixels
/ htile_block_size
) *
943 surf
->htile_size
= align(surf
->htile_size
, surf
->htile_alignment
);
946 surf
->is_linear
= surf
->u
.legacy
.level
[0].mode
== RADEON_SURF_MODE_LINEAR_ALIGNED
;
947 surf
->is_displayable
= surf
->is_linear
||
948 surf
->micro_tile_mode
== RADEON_MICRO_MODE_DISPLAY
||
949 surf
->micro_tile_mode
== RADEON_MICRO_MODE_ROTATED
;
951 /* The rotated micro tile mode doesn't work if both CMASK and RB+ are
952 * used at the same time. This case is not currently expected to occur
953 * because we don't use rotated. Enforce this restriction on all chips
954 * to facilitate testing.
956 if (surf
->micro_tile_mode
== RADEON_MICRO_MODE_ROTATED
) {
957 assert(!"rotate micro tile mode is unsupported");
961 ac_compute_cmask(info
, config
, surf
);
965 /* This is only called when expecting a tiled layout. */
967 gfx9_get_preferred_swizzle_mode(ADDR_HANDLE addrlib
,
968 ADDR2_COMPUTE_SURFACE_INFO_INPUT
*in
,
969 bool is_fmask
, AddrSwizzleMode
*swizzle_mode
)
971 ADDR_E_RETURNCODE ret
;
972 ADDR2_GET_PREFERRED_SURF_SETTING_INPUT sin
= {0};
973 ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT sout
= {0};
975 sin
.size
= sizeof(ADDR2_GET_PREFERRED_SURF_SETTING_INPUT
);
976 sout
.size
= sizeof(ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT
);
978 sin
.flags
= in
->flags
;
979 sin
.resourceType
= in
->resourceType
;
980 sin
.format
= in
->format
;
981 sin
.resourceLoction
= ADDR_RSRC_LOC_INVIS
;
982 /* TODO: We could allow some of these: */
983 sin
.forbiddenBlock
.micro
= 1; /* don't allow the 256B swizzle modes */
984 sin
.forbiddenBlock
.var
= 1; /* don't allow the variable-sized swizzle modes */
985 sin
.forbiddenBlock
.linear
= 1; /* don't allow linear swizzle modes */
987 sin
.width
= in
->width
;
988 sin
.height
= in
->height
;
989 sin
.numSlices
= in
->numSlices
;
990 sin
.numMipLevels
= in
->numMipLevels
;
991 sin
.numSamples
= in
->numSamples
;
992 sin
.numFrags
= in
->numFrags
;
995 sin
.flags
.display
= 0;
1000 ret
= Addr2GetPreferredSurfaceSetting(addrlib
, &sin
, &sout
);
1004 *swizzle_mode
= sout
.swizzleMode
;
1008 static bool gfx9_is_dcc_capable(const struct radeon_info
*info
, unsigned sw_mode
)
1010 if (info
->chip_class
>= GFX10
)
1011 return sw_mode
== ADDR_SW_64KB_Z_X
|| sw_mode
== ADDR_SW_64KB_R_X
;
1013 return sw_mode
!= ADDR_SW_LINEAR
;
1016 static int gfx9_compute_miptree(ADDR_HANDLE addrlib
,
1017 const struct radeon_info
*info
,
1018 const struct ac_surf_config
*config
,
1019 struct radeon_surf
*surf
, bool compressed
,
1020 ADDR2_COMPUTE_SURFACE_INFO_INPUT
*in
)
1022 ADDR2_MIP_INFO mip_info
[RADEON_SURF_MAX_LEVELS
] = {};
1023 ADDR2_COMPUTE_SURFACE_INFO_OUTPUT out
= {0};
1024 ADDR_E_RETURNCODE ret
;
1026 out
.size
= sizeof(ADDR2_COMPUTE_SURFACE_INFO_OUTPUT
);
1027 out
.pMipInfo
= mip_info
;
1029 ret
= Addr2ComputeSurfaceInfo(addrlib
, in
, &out
);
1033 if (in
->flags
.stencil
) {
1034 surf
->u
.gfx9
.stencil
.swizzle_mode
= in
->swizzleMode
;
1035 surf
->u
.gfx9
.stencil
.epitch
= out
.epitchIsHeight
? out
.mipChainHeight
- 1 :
1036 out
.mipChainPitch
- 1;
1037 surf
->surf_alignment
= MAX2(surf
->surf_alignment
, out
.baseAlign
);
1038 surf
->u
.gfx9
.stencil_offset
= align(surf
->surf_size
, out
.baseAlign
);
1039 surf
->surf_size
= surf
->u
.gfx9
.stencil_offset
+ out
.surfSize
;
1043 surf
->u
.gfx9
.surf
.swizzle_mode
= in
->swizzleMode
;
1044 surf
->u
.gfx9
.surf
.epitch
= out
.epitchIsHeight
? out
.mipChainHeight
- 1 :
1045 out
.mipChainPitch
- 1;
1047 /* CMASK fast clear uses these even if FMASK isn't allocated.
1048 * FMASK only supports the Z swizzle modes, whose numbers are multiples of 4.
1050 surf
->u
.gfx9
.fmask
.swizzle_mode
= surf
->u
.gfx9
.surf
.swizzle_mode
& ~0x3;
1051 surf
->u
.gfx9
.fmask
.epitch
= surf
->u
.gfx9
.surf
.epitch
;
1053 surf
->u
.gfx9
.surf_slice_size
= out
.sliceSize
;
1054 surf
->u
.gfx9
.surf_pitch
= out
.pitch
;
1055 surf
->u
.gfx9
.surf_height
= out
.height
;
1056 surf
->surf_size
= out
.surfSize
;
1057 surf
->surf_alignment
= out
.baseAlign
;
1059 if (in
->swizzleMode
== ADDR_SW_LINEAR
) {
1060 for (unsigned i
= 0; i
< in
->numMipLevels
; i
++)
1061 surf
->u
.gfx9
.offset
[i
] = mip_info
[i
].offset
;
1064 if (in
->flags
.depth
) {
1065 assert(in
->swizzleMode
!= ADDR_SW_LINEAR
);
1068 ADDR2_COMPUTE_HTILE_INFO_INPUT hin
= {0};
1069 ADDR2_COMPUTE_HTILE_INFO_OUTPUT hout
= {0};
1071 hin
.size
= sizeof(ADDR2_COMPUTE_HTILE_INFO_INPUT
);
1072 hout
.size
= sizeof(ADDR2_COMPUTE_HTILE_INFO_OUTPUT
);
1074 hin
.hTileFlags
.pipeAligned
= !in
->flags
.metaPipeUnaligned
;
1075 hin
.hTileFlags
.rbAligned
= !in
->flags
.metaRbUnaligned
;
1076 hin
.depthFlags
= in
->flags
;
1077 hin
.swizzleMode
= in
->swizzleMode
;
1078 hin
.unalignedWidth
= in
->width
;
1079 hin
.unalignedHeight
= in
->height
;
1080 hin
.numSlices
= in
->numSlices
;
1081 hin
.numMipLevels
= in
->numMipLevels
;
1082 hin
.firstMipIdInTail
= out
.firstMipIdInTail
;
1084 ret
= Addr2ComputeHtileInfo(addrlib
, &hin
, &hout
);
1088 surf
->u
.gfx9
.htile
.rb_aligned
= hin
.hTileFlags
.rbAligned
;
1089 surf
->u
.gfx9
.htile
.pipe_aligned
= hin
.hTileFlags
.pipeAligned
;
1090 surf
->htile_size
= hout
.htileBytes
;
1091 surf
->htile_slice_size
= hout
.sliceSize
;
1092 surf
->htile_alignment
= hout
.baseAlign
;
1094 /* Compute tile swizzle for the color surface.
1095 * All *_X and *_T modes can use the swizzle.
1097 if (config
->info
.surf_index
&&
1098 in
->swizzleMode
>= ADDR_SW_64KB_Z_T
&&
1099 !out
.mipChainInTail
&&
1100 !(surf
->flags
& RADEON_SURF_SHAREABLE
) &&
1101 !in
->flags
.display
) {
1102 ADDR2_COMPUTE_PIPEBANKXOR_INPUT xin
= {0};
1103 ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT xout
= {0};
1105 xin
.size
= sizeof(ADDR2_COMPUTE_PIPEBANKXOR_INPUT
);
1106 xout
.size
= sizeof(ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT
);
1108 xin
.surfIndex
= p_atomic_inc_return(config
->info
.surf_index
) - 1;
1109 xin
.flags
= in
->flags
;
1110 xin
.swizzleMode
= in
->swizzleMode
;
1111 xin
.resourceType
= in
->resourceType
;
1112 xin
.format
= in
->format
;
1113 xin
.numSamples
= in
->numSamples
;
1114 xin
.numFrags
= in
->numFrags
;
1116 ret
= Addr2ComputePipeBankXor(addrlib
, &xin
, &xout
);
1120 assert(xout
.pipeBankXor
<=
1121 u_bit_consecutive(0, sizeof(surf
->tile_swizzle
) * 8));
1122 surf
->tile_swizzle
= xout
.pipeBankXor
;
1126 if (info
->has_graphics
&&
1127 !(surf
->flags
& RADEON_SURF_DISABLE_DCC
) &&
1129 gfx9_is_dcc_capable(info
, in
->swizzleMode
)) {
1130 ADDR2_COMPUTE_DCCINFO_INPUT din
= {0};
1131 ADDR2_COMPUTE_DCCINFO_OUTPUT dout
= {0};
1132 ADDR2_META_MIP_INFO meta_mip_info
[RADEON_SURF_MAX_LEVELS
] = {};
1134 din
.size
= sizeof(ADDR2_COMPUTE_DCCINFO_INPUT
);
1135 dout
.size
= sizeof(ADDR2_COMPUTE_DCCINFO_OUTPUT
);
1136 dout
.pMipInfo
= meta_mip_info
;
1138 din
.dccKeyFlags
.pipeAligned
= !in
->flags
.metaPipeUnaligned
;
1139 din
.dccKeyFlags
.rbAligned
= !in
->flags
.metaRbUnaligned
;
1140 din
.colorFlags
= in
->flags
;
1141 din
.resourceType
= in
->resourceType
;
1142 din
.swizzleMode
= in
->swizzleMode
;
1144 din
.unalignedWidth
= in
->width
;
1145 din
.unalignedHeight
= in
->height
;
1146 din
.numSlices
= in
->numSlices
;
1147 din
.numFrags
= in
->numFrags
;
1148 din
.numMipLevels
= in
->numMipLevels
;
1149 din
.dataSurfaceSize
= out
.surfSize
;
1150 din
.firstMipIdInTail
= out
.firstMipIdInTail
;
1152 ret
= Addr2ComputeDccInfo(addrlib
, &din
, &dout
);
1156 surf
->u
.gfx9
.dcc
.rb_aligned
= din
.dccKeyFlags
.rbAligned
;
1157 surf
->u
.gfx9
.dcc
.pipe_aligned
= din
.dccKeyFlags
.pipeAligned
;
1158 surf
->dcc_size
= dout
.dccRamSize
;
1159 surf
->dcc_alignment
= dout
.dccRamBaseAlign
;
1160 surf
->num_dcc_levels
= in
->numMipLevels
;
1162 /* Disable DCC for levels that are in the mip tail.
1164 * There are two issues that this is intended to
1167 * 1. Multiple mip levels may share a cache line. This
1168 * can lead to corruption when switching between
1169 * rendering to different mip levels because the
1170 * RBs don't maintain coherency.
1172 * 2. Texturing with metadata after rendering sometimes
1173 * fails with corruption, probably for a similar
1176 * Working around these issues for all levels in the
1177 * mip tail may be overly conservative, but it's what
1180 * Alternative solutions that also work but are worse:
1181 * - Disable DCC entirely.
1182 * - Flush TC L2 after rendering.
1184 for (unsigned i
= 0; i
< in
->numMipLevels
; i
++) {
1185 if (meta_mip_info
[i
].inMiptail
) {
1186 surf
->num_dcc_levels
= i
;
1191 if (!surf
->num_dcc_levels
)
1194 surf
->u
.gfx9
.display_dcc_size
= surf
->dcc_size
;
1195 surf
->u
.gfx9
.display_dcc_alignment
= surf
->dcc_alignment
;
1196 surf
->u
.gfx9
.display_dcc_pitch_max
= dout
.pitch
- 1;
1198 /* Compute displayable DCC. */
1199 if (in
->flags
.display
&&
1200 surf
->num_dcc_levels
&&
1201 info
->use_display_dcc_with_retile_blit
) {
1202 /* Compute displayable DCC info. */
1203 din
.dccKeyFlags
.pipeAligned
= 0;
1204 din
.dccKeyFlags
.rbAligned
= 0;
1206 assert(din
.numSlices
== 1);
1207 assert(din
.numMipLevels
== 1);
1208 assert(din
.numFrags
== 1);
1209 assert(surf
->tile_swizzle
== 0);
1210 assert(surf
->u
.gfx9
.dcc
.pipe_aligned
||
1211 surf
->u
.gfx9
.dcc
.rb_aligned
);
1213 ret
= Addr2ComputeDccInfo(addrlib
, &din
, &dout
);
1217 surf
->u
.gfx9
.display_dcc_size
= dout
.dccRamSize
;
1218 surf
->u
.gfx9
.display_dcc_alignment
= dout
.dccRamBaseAlign
;
1219 surf
->u
.gfx9
.display_dcc_pitch_max
= dout
.pitch
- 1;
1220 assert(surf
->u
.gfx9
.display_dcc_size
<= surf
->dcc_size
);
1222 /* Compute address mapping from non-displayable to displayable DCC. */
1223 ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT addrin
= {};
1224 addrin
.size
= sizeof(addrin
);
1225 addrin
.colorFlags
.color
= 1;
1226 addrin
.swizzleMode
= din
.swizzleMode
;
1227 addrin
.resourceType
= din
.resourceType
;
1228 addrin
.bpp
= din
.bpp
;
1229 addrin
.unalignedWidth
= din
.unalignedWidth
;
1230 addrin
.unalignedHeight
= din
.unalignedHeight
;
1231 addrin
.numSlices
= 1;
1232 addrin
.numMipLevels
= 1;
1233 addrin
.numFrags
= 1;
1235 ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT addrout
= {};
1236 addrout
.size
= sizeof(addrout
);
1238 surf
->u
.gfx9
.dcc_retile_num_elements
=
1239 DIV_ROUND_UP(in
->width
, dout
.compressBlkWidth
) *
1240 DIV_ROUND_UP(in
->height
, dout
.compressBlkHeight
) * 2;
1241 /* Align the size to 4 (for the compute shader). */
1242 surf
->u
.gfx9
.dcc_retile_num_elements
=
1243 align(surf
->u
.gfx9
.dcc_retile_num_elements
, 4);
1245 surf
->u
.gfx9
.dcc_retile_map
=
1246 malloc(surf
->u
.gfx9
.dcc_retile_num_elements
* 4);
1247 if (!surf
->u
.gfx9
.dcc_retile_map
)
1248 return ADDR_OUTOFMEMORY
;
1251 surf
->u
.gfx9
.dcc_retile_use_uint16
= true;
1253 for (unsigned y
= 0; y
< in
->height
; y
+= dout
.compressBlkHeight
) {
1256 for (unsigned x
= 0; x
< in
->width
; x
+= dout
.compressBlkWidth
) {
1259 /* Compute src DCC address */
1260 addrin
.dccKeyFlags
.pipeAligned
= surf
->u
.gfx9
.dcc
.pipe_aligned
;
1261 addrin
.dccKeyFlags
.rbAligned
= surf
->u
.gfx9
.dcc
.rb_aligned
;
1264 ret
= Addr2ComputeDccAddrFromCoord(addrlib
, &addrin
, &addrout
);
1268 surf
->u
.gfx9
.dcc_retile_map
[index
* 2] = addrout
.addr
;
1269 if (addrout
.addr
> USHRT_MAX
)
1270 surf
->u
.gfx9
.dcc_retile_use_uint16
= false;
1272 /* Compute dst DCC address */
1273 addrin
.dccKeyFlags
.pipeAligned
= 0;
1274 addrin
.dccKeyFlags
.rbAligned
= 0;
1277 ret
= Addr2ComputeDccAddrFromCoord(addrlib
, &addrin
, &addrout
);
1281 surf
->u
.gfx9
.dcc_retile_map
[index
* 2 + 1] = addrout
.addr
;
1282 if (addrout
.addr
> USHRT_MAX
)
1283 surf
->u
.gfx9
.dcc_retile_use_uint16
= false;
1285 assert(index
* 2 + 1 < surf
->u
.gfx9
.dcc_retile_num_elements
);
1289 /* Fill the remaining pairs with the last one (for the compute shader). */
1290 for (unsigned i
= index
* 2; i
< surf
->u
.gfx9
.dcc_retile_num_elements
; i
++)
1291 surf
->u
.gfx9
.dcc_retile_map
[i
] = surf
->u
.gfx9
.dcc_retile_map
[i
- 2];
1296 if (in
->numSamples
> 1) {
1297 ADDR2_COMPUTE_FMASK_INFO_INPUT fin
= {0};
1298 ADDR2_COMPUTE_FMASK_INFO_OUTPUT fout
= {0};
1300 fin
.size
= sizeof(ADDR2_COMPUTE_FMASK_INFO_INPUT
);
1301 fout
.size
= sizeof(ADDR2_COMPUTE_FMASK_INFO_OUTPUT
);
1303 ret
= gfx9_get_preferred_swizzle_mode(addrlib
, in
,
1304 true, &fin
.swizzleMode
);
1308 fin
.unalignedWidth
= in
->width
;
1309 fin
.unalignedHeight
= in
->height
;
1310 fin
.numSlices
= in
->numSlices
;
1311 fin
.numSamples
= in
->numSamples
;
1312 fin
.numFrags
= in
->numFrags
;
1314 ret
= Addr2ComputeFmaskInfo(addrlib
, &fin
, &fout
);
1318 surf
->u
.gfx9
.fmask
.swizzle_mode
= fin
.swizzleMode
;
1319 surf
->u
.gfx9
.fmask
.epitch
= fout
.pitch
- 1;
1320 surf
->fmask_size
= fout
.fmaskBytes
;
1321 surf
->fmask_alignment
= fout
.baseAlign
;
1323 /* Compute tile swizzle for the FMASK surface. */
1324 if (config
->info
.fmask_surf_index
&&
1325 fin
.swizzleMode
>= ADDR_SW_64KB_Z_T
&&
1326 !(surf
->flags
& RADEON_SURF_SHAREABLE
)) {
1327 ADDR2_COMPUTE_PIPEBANKXOR_INPUT xin
= {0};
1328 ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT xout
= {0};
1330 xin
.size
= sizeof(ADDR2_COMPUTE_PIPEBANKXOR_INPUT
);
1331 xout
.size
= sizeof(ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT
);
1333 /* This counter starts from 1 instead of 0. */
1334 xin
.surfIndex
= p_atomic_inc_return(config
->info
.fmask_surf_index
);
1335 xin
.flags
= in
->flags
;
1336 xin
.swizzleMode
= fin
.swizzleMode
;
1337 xin
.resourceType
= in
->resourceType
;
1338 xin
.format
= in
->format
;
1339 xin
.numSamples
= in
->numSamples
;
1340 xin
.numFrags
= in
->numFrags
;
1342 ret
= Addr2ComputePipeBankXor(addrlib
, &xin
, &xout
);
1346 assert(xout
.pipeBankXor
<=
1347 u_bit_consecutive(0, sizeof(surf
->fmask_tile_swizzle
) * 8));
1348 surf
->fmask_tile_swizzle
= xout
.pipeBankXor
;
1352 /* CMASK -- on GFX10 only for FMASK */
1353 if (in
->swizzleMode
!= ADDR_SW_LINEAR
&&
1354 (info
->chip_class
<= GFX9
|| in
->numSamples
> 1)) {
1355 ADDR2_COMPUTE_CMASK_INFO_INPUT cin
= {0};
1356 ADDR2_COMPUTE_CMASK_INFO_OUTPUT cout
= {0};
1358 cin
.size
= sizeof(ADDR2_COMPUTE_CMASK_INFO_INPUT
);
1359 cout
.size
= sizeof(ADDR2_COMPUTE_CMASK_INFO_OUTPUT
);
1361 if (in
->numSamples
> 1) {
1362 /* FMASK is always aligned. */
1363 cin
.cMaskFlags
.pipeAligned
= 1;
1364 cin
.cMaskFlags
.rbAligned
= 1;
1366 cin
.cMaskFlags
.pipeAligned
= !in
->flags
.metaPipeUnaligned
;
1367 cin
.cMaskFlags
.rbAligned
= !in
->flags
.metaRbUnaligned
;
1369 cin
.colorFlags
= in
->flags
;
1370 cin
.resourceType
= in
->resourceType
;
1371 cin
.unalignedWidth
= in
->width
;
1372 cin
.unalignedHeight
= in
->height
;
1373 cin
.numSlices
= in
->numSlices
;
1375 if (in
->numSamples
> 1)
1376 cin
.swizzleMode
= surf
->u
.gfx9
.fmask
.swizzle_mode
;
1378 cin
.swizzleMode
= in
->swizzleMode
;
1380 ret
= Addr2ComputeCmaskInfo(addrlib
, &cin
, &cout
);
1384 surf
->u
.gfx9
.cmask
.rb_aligned
= cin
.cMaskFlags
.rbAligned
;
1385 surf
->u
.gfx9
.cmask
.pipe_aligned
= cin
.cMaskFlags
.pipeAligned
;
1386 surf
->cmask_size
= cout
.cmaskBytes
;
1387 surf
->cmask_alignment
= cout
.baseAlign
;
1394 static int gfx9_compute_surface(ADDR_HANDLE addrlib
,
1395 const struct radeon_info
*info
,
1396 const struct ac_surf_config
*config
,
1397 enum radeon_surf_mode mode
,
1398 struct radeon_surf
*surf
)
1401 ADDR2_COMPUTE_SURFACE_INFO_INPUT AddrSurfInfoIn
= {0};
1404 AddrSurfInfoIn
.size
= sizeof(ADDR2_COMPUTE_SURFACE_INFO_INPUT
);
1406 compressed
= surf
->blk_w
== 4 && surf
->blk_h
== 4;
1408 /* The format must be set correctly for the allocation of compressed
1409 * textures to work. In other cases, setting the bpp is sufficient. */
1411 switch (surf
->bpe
) {
1413 AddrSurfInfoIn
.format
= ADDR_FMT_BC1
;
1416 AddrSurfInfoIn
.format
= ADDR_FMT_BC3
;
1422 switch (surf
->bpe
) {
1424 assert(!(surf
->flags
& RADEON_SURF_ZBUFFER
));
1425 AddrSurfInfoIn
.format
= ADDR_FMT_8
;
1428 assert(surf
->flags
& RADEON_SURF_ZBUFFER
||
1429 !(surf
->flags
& RADEON_SURF_SBUFFER
));
1430 AddrSurfInfoIn
.format
= ADDR_FMT_16
;
1433 assert(surf
->flags
& RADEON_SURF_ZBUFFER
||
1434 !(surf
->flags
& RADEON_SURF_SBUFFER
));
1435 AddrSurfInfoIn
.format
= ADDR_FMT_32
;
1438 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
1439 AddrSurfInfoIn
.format
= ADDR_FMT_32_32
;
1442 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
1443 AddrSurfInfoIn
.format
= ADDR_FMT_32_32_32
;
1446 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
1447 AddrSurfInfoIn
.format
= ADDR_FMT_32_32_32_32
;
1452 AddrSurfInfoIn
.bpp
= surf
->bpe
* 8;
1455 bool is_color_surface
= !(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
);
1456 AddrSurfInfoIn
.flags
.color
= is_color_surface
&&
1457 !(surf
->flags
& RADEON_SURF_NO_RENDER_TARGET
);
1458 AddrSurfInfoIn
.flags
.depth
= (surf
->flags
& RADEON_SURF_ZBUFFER
) != 0;
1459 AddrSurfInfoIn
.flags
.display
= get_display_flag(config
, surf
);
1460 /* flags.texture currently refers to TC-compatible HTILE */
1461 AddrSurfInfoIn
.flags
.texture
= is_color_surface
||
1462 surf
->flags
& RADEON_SURF_TC_COMPATIBLE_HTILE
;
1463 AddrSurfInfoIn
.flags
.opt4space
= 1;
1465 AddrSurfInfoIn
.numMipLevels
= config
->info
.levels
;
1466 AddrSurfInfoIn
.numSamples
= MAX2(1, config
->info
.samples
);
1467 AddrSurfInfoIn
.numFrags
= AddrSurfInfoIn
.numSamples
;
1469 if (!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
))
1470 AddrSurfInfoIn
.numFrags
= MAX2(1, config
->info
.storage_samples
);
1472 /* GFX9 doesn't support 1D depth textures, so allocate all 1D textures
1473 * as 2D to avoid having shader variants for 1D vs 2D, so all shaders
1474 * must sample 1D textures as 2D. */
1476 AddrSurfInfoIn
.resourceType
= ADDR_RSRC_TEX_3D
;
1477 else if (info
->chip_class
!= GFX9
&& config
->is_1d
)
1478 AddrSurfInfoIn
.resourceType
= ADDR_RSRC_TEX_1D
;
1480 AddrSurfInfoIn
.resourceType
= ADDR_RSRC_TEX_2D
;
1482 AddrSurfInfoIn
.width
= config
->info
.width
;
1483 AddrSurfInfoIn
.height
= config
->info
.height
;
1486 AddrSurfInfoIn
.numSlices
= config
->info
.depth
;
1487 else if (config
->is_cube
)
1488 AddrSurfInfoIn
.numSlices
= 6;
1490 AddrSurfInfoIn
.numSlices
= config
->info
.array_size
;
1492 /* This is propagated to HTILE/DCC/CMASK. */
1493 AddrSurfInfoIn
.flags
.metaPipeUnaligned
= 0;
1494 AddrSurfInfoIn
.flags
.metaRbUnaligned
= 0;
1496 /* The display hardware can only read DCC with RB_ALIGNED=0 and
1497 * PIPE_ALIGNED=0. PIPE_ALIGNED really means L2CACHE_ALIGNED.
1499 * The CB block requires RB_ALIGNED=1 except 1 RB chips.
1500 * PIPE_ALIGNED is optional, but PIPE_ALIGNED=0 requires L2 flushes
1501 * after rendering, so PIPE_ALIGNED=1 is recommended.
1503 if (info
->use_display_dcc_unaligned
&& is_color_surface
&&
1504 AddrSurfInfoIn
.flags
.display
) {
1505 AddrSurfInfoIn
.flags
.metaPipeUnaligned
= 1;
1506 AddrSurfInfoIn
.flags
.metaRbUnaligned
= 1;
1510 case RADEON_SURF_MODE_LINEAR_ALIGNED
:
1511 assert(config
->info
.samples
<= 1);
1512 assert(!(surf
->flags
& RADEON_SURF_Z_OR_SBUFFER
));
1513 AddrSurfInfoIn
.swizzleMode
= ADDR_SW_LINEAR
;
1516 case RADEON_SURF_MODE_1D
:
1517 case RADEON_SURF_MODE_2D
:
1518 if (surf
->flags
& (RADEON_SURF_IMPORTED
| RADEON_SURF_FORCE_SWIZZLE_MODE
)) {
1519 AddrSurfInfoIn
.swizzleMode
= surf
->u
.gfx9
.surf
.swizzle_mode
;
1523 r
= gfx9_get_preferred_swizzle_mode(addrlib
, &AddrSurfInfoIn
,
1524 false, &AddrSurfInfoIn
.swizzleMode
);
1533 surf
->u
.gfx9
.resource_type
= AddrSurfInfoIn
.resourceType
;
1534 surf
->has_stencil
= !!(surf
->flags
& RADEON_SURF_SBUFFER
);
1536 surf
->num_dcc_levels
= 0;
1537 surf
->surf_size
= 0;
1538 surf
->fmask_size
= 0;
1540 surf
->htile_size
= 0;
1541 surf
->htile_slice_size
= 0;
1542 surf
->u
.gfx9
.surf_offset
= 0;
1543 surf
->u
.gfx9
.stencil_offset
= 0;
1544 surf
->cmask_size
= 0;
1545 surf
->u
.gfx9
.dcc_retile_use_uint16
= false;
1546 surf
->u
.gfx9
.dcc_retile_num_elements
= 0;
1547 surf
->u
.gfx9
.dcc_retile_map
= NULL
;
1549 /* Calculate texture layout information. */
1550 r
= gfx9_compute_miptree(addrlib
, info
, config
, surf
, compressed
,
1555 /* Calculate texture layout information for stencil. */
1556 if (surf
->flags
& RADEON_SURF_SBUFFER
) {
1557 AddrSurfInfoIn
.flags
.stencil
= 1;
1558 AddrSurfInfoIn
.bpp
= 8;
1559 AddrSurfInfoIn
.format
= ADDR_FMT_8
;
1561 if (!AddrSurfInfoIn
.flags
.depth
) {
1562 r
= gfx9_get_preferred_swizzle_mode(addrlib
, &AddrSurfInfoIn
,
1563 false, &AddrSurfInfoIn
.swizzleMode
);
1567 AddrSurfInfoIn
.flags
.depth
= 0;
1569 r
= gfx9_compute_miptree(addrlib
, info
, config
, surf
, compressed
,
1575 surf
->is_linear
= surf
->u
.gfx9
.surf
.swizzle_mode
== ADDR_SW_LINEAR
;
1577 /* Query whether the surface is displayable. */
1578 bool displayable
= false;
1579 if (!config
->is_3d
&& !config
->is_cube
) {
1580 r
= Addr2IsValidDisplaySwizzleMode(addrlib
, surf
->u
.gfx9
.surf
.swizzle_mode
,
1581 surf
->bpe
* 8, &displayable
);
1585 /* Display needs unaligned DCC. */
1586 if (info
->use_display_dcc_unaligned
&&
1587 surf
->num_dcc_levels
&&
1588 (surf
->u
.gfx9
.dcc
.pipe_aligned
||
1589 surf
->u
.gfx9
.dcc
.rb_aligned
))
1590 displayable
= false;
1592 surf
->is_displayable
= displayable
;
1594 switch (surf
->u
.gfx9
.surf
.swizzle_mode
) {
1596 case ADDR_SW_256B_S
:
1598 case ADDR_SW_64KB_S
:
1600 case ADDR_SW_64KB_S_T
:
1601 case ADDR_SW_4KB_S_X
:
1602 case ADDR_SW_64KB_S_X
:
1603 case ADDR_SW_VAR_S_X
:
1604 surf
->micro_tile_mode
= RADEON_MICRO_MODE_THIN
;
1608 case ADDR_SW_LINEAR
:
1609 case ADDR_SW_256B_D
:
1611 case ADDR_SW_64KB_D
:
1613 case ADDR_SW_64KB_D_T
:
1614 case ADDR_SW_4KB_D_X
:
1615 case ADDR_SW_64KB_D_X
:
1616 case ADDR_SW_VAR_D_X
:
1617 surf
->micro_tile_mode
= RADEON_MICRO_MODE_DISPLAY
;
1620 /* R = rotated (gfx9), render target (gfx10). */
1621 case ADDR_SW_256B_R
:
1623 case ADDR_SW_64KB_R
:
1625 case ADDR_SW_64KB_R_T
:
1626 case ADDR_SW_4KB_R_X
:
1627 case ADDR_SW_64KB_R_X
:
1628 case ADDR_SW_VAR_R_X
:
1629 /* The rotated micro tile mode doesn't work if both CMASK and RB+ are
1630 * used at the same time. We currently do not use rotated
1633 assert(info
->chip_class
>= GFX10
||
1634 !"rotate micro tile mode is unsupported");
1635 surf
->micro_tile_mode
= RADEON_MICRO_MODE_ROTATED
;
1640 case ADDR_SW_64KB_Z
:
1642 case ADDR_SW_64KB_Z_T
:
1643 case ADDR_SW_4KB_Z_X
:
1644 case ADDR_SW_64KB_Z_X
:
1645 case ADDR_SW_VAR_Z_X
:
1646 surf
->micro_tile_mode
= RADEON_MICRO_MODE_DEPTH
;
1656 free(surf
->u
.gfx9
.dcc_retile_map
);
1657 surf
->u
.gfx9
.dcc_retile_map
= NULL
;
1661 int ac_compute_surface(ADDR_HANDLE addrlib
, const struct radeon_info
*info
,
1662 const struct ac_surf_config
*config
,
1663 enum radeon_surf_mode mode
,
1664 struct radeon_surf
*surf
)
1668 r
= surf_config_sanity(config
, surf
->flags
);
1672 if (info
->chip_class
>= GFX9
)
1673 return gfx9_compute_surface(addrlib
, info
, config
, mode
, surf
);
1675 return gfx6_compute_surface(addrlib
, info
, config
, mode
, surf
);