2 * Copyright 2015 Intel Corporation
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:
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
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
28 gen6_choose_msaa_layout(const struct isl_device
*dev
,
29 const struct isl_surf_init_info
*info
,
30 enum isl_tiling tiling
,
31 enum isl_msaa_layout
*msaa_layout
)
33 assert(ISL_DEV_GEN(dev
) == 6);
34 assert(info
->samples
>= 1);
36 if (info
->samples
== 1) {
37 *msaa_layout
= ISL_MSAA_LAYOUT_NONE
;
41 if (!isl_format_supports_multisampling(dev
->info
, info
->format
))
44 /* From the Sandybridge PRM, Volume 4 Part 1 p85, SURFACE_STATE, Number of
47 * If this field is any value other than MULTISAMPLECOUNT_1 the
48 * following restrictions apply:
50 * - the Surface Type must be SURFTYPE_2D
53 if (info
->dim
!= ISL_SURF_DIM_2D
)
56 /* More obvious restrictions */
57 if (isl_surf_usage_is_display(info
->usage
))
59 if (tiling
== ISL_TILING_LINEAR
)
64 *msaa_layout
= ISL_MSAA_LAYOUT_INTERLEAVED
;
69 gen6_choose_image_alignment_el(const struct isl_device
*dev
,
70 const struct isl_surf_init_info
*restrict info
,
71 enum isl_tiling tiling
,
72 enum isl_dim_layout dim_layout
,
73 enum isl_msaa_layout msaa_layout
,
74 struct isl_extent3d
*image_align_el
)
76 /* Handled by isl_choose_image_alignment_el */
77 assert(info
->format
!= ISL_FORMAT_HIZ
);
79 /* Note that the surface's horizontal image alignment is not programmable
82 * From the Sandybridge PRM (2011-05), Volume 1, Part 1, Section 7.18.3.4
83 * Alignment Unit Size:
85 * Note that the compressed formats are padded to a full compression cell.
87 * +------------------------+--------+--------+
88 * | format | halign | valign |
89 * +------------------------+--------+--------+
90 * | YUV 4:2:2 formats | 4 | * |
91 * | uncompressed formats | 4 | * |
92 * +------------------------+--------+--------+
94 * * For these formats, the vertical alignment factor ājā is determined
96 * - j = 4 for any depth buffer
97 * - j = 2 for separate stencil buffer
98 * - j = 4 for any render target surface is multisampled (4x)
99 * - j = 2 for all other render target surface
101 * From the Sandrybridge PRM (2011-05), Volume 4, Part 1, Section 2.11.2
102 * SURFACE_STATE, Surface Vertical Alignment:
104 * - This field must be set to VALIGN_2 if the Surface Format is 96 bits
107 * - Value of 1 [VALIGN_4] is not supported for format YCRCB_NORMAL
108 * (0x182), YCRCB_SWAPUVY (0x183), YCRCB_SWAPUV (0x18f), YCRCB_SWAPY
112 if (isl_format_is_compressed(info
->format
)) {
113 *image_align_el
= isl_extent3d(1, 1, 1);
117 if (isl_format_is_yuv(info
->format
)) {
118 *image_align_el
= isl_extent3d(4, 2, 1);
122 if (info
->samples
> 1) {
123 *image_align_el
= isl_extent3d(4, 4, 1);
127 if (isl_surf_usage_is_depth_or_stencil(info
->usage
) &&
128 !ISL_DEV_USE_SEPARATE_STENCIL(dev
)) {
129 /* interleaved depthstencil buffer */
130 *image_align_el
= isl_extent3d(4, 4, 1);
134 if (isl_surf_usage_is_depth(info
->usage
)) {
135 /* separate depth buffer */
136 *image_align_el
= isl_extent3d(4, 4, 1);
140 if (isl_surf_usage_is_stencil(info
->usage
)) {
141 /* separate stencil buffer */
142 *image_align_el
= isl_extent3d(4, 2, 1);
146 *image_align_el
= isl_extent3d(4, 2, 1);