anv: add new gem/drm helpers
[mesa.git] / src / intel / isl / isl_gen12.c
1 /*
2 * Copyright (c) 2018 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include "isl_gen9.h"
25 #include "isl_gen12.h"
26 #include "isl_priv.h"
27
28 void
29 isl_gen12_choose_image_alignment_el(const struct isl_device *dev,
30 const struct isl_surf_init_info *restrict info,
31 enum isl_tiling tiling,
32 enum isl_dim_layout dim_layout,
33 enum isl_msaa_layout msaa_layout,
34 struct isl_extent3d *image_align_el)
35 {
36 /* Handled by isl_choose_image_alignment_el */
37 assert(info->format != ISL_FORMAT_HIZ);
38
39 const struct isl_format_layout *fmtl = isl_format_get_layout(info->format);
40 if (fmtl->txc == ISL_TXC_CCS) {
41 /* This CCS compresses a 2D-view of the entire surface. */
42 assert(info->levels == 1 && info->array_len == 1 && info->depth == 1);
43 *image_align_el = isl_extent3d(1, 1, 1);
44 return;
45 }
46
47 if (isl_surf_usage_is_depth(info->usage)) {
48 /* The alignment parameters for depth buffers are summarized in the
49 * following table:
50 *
51 * Surface Format | MSAA | Align Width | Align Height
52 * -----------------+-------------+-------------+--------------
53 * D16_UNORM | 1x, 4x, 16x | 8 | 8
54 * ----------------+-------------+-------------+--------------
55 * D16_UNORM | 2x, 8x | 16 | 4
56 * ----------------+-------------+-------------+--------------
57 * other | any | 8 | 4
58 * -----------------+-------------+-------------+--------------
59 */
60 assert(isl_is_pow2(info->samples));
61 *image_align_el =
62 info->format != ISL_FORMAT_R16_UNORM ?
63 isl_extent3d(8, 4, 1) :
64 (info->samples == 2 || info->samples == 8 ?
65 isl_extent3d(16, 4, 1) : isl_extent3d(8, 8, 1));
66 } else if (isl_surf_usage_is_stencil(info->usage)) {
67 *image_align_el = isl_extent3d(16, 8, 1);
68 } else {
69 isl_gen9_choose_image_alignment_el(dev, info, tiling, dim_layout,
70 msaa_layout, image_align_el);
71 }
72 }