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 const struct isl_format_layout
*fmtl
= isl_format_get_layout(info
->format
);
35 assert(ISL_DEV_GEN(dev
) == 6);
36 assert(info
->samples
>= 1);
38 if (info
->samples
== 1) {
39 *msaa_layout
= ISL_MSAA_LAYOUT_NONE
;
43 /* From the Sandybridge PRM, Volume 4 Part 1 p72, SURFACE_STATE, Surface
46 * If Number of Multisamples is set to a value other than
47 * MULTISAMPLECOUNT_1, this field cannot be set to the following
50 * - any format with greater than 64 bits per element
51 * - any compressed texture format (BC*)
56 if (isl_format_is_compressed(info
->format
))
58 if (isl_format_is_yuv(info
->format
))
61 /* From the Sandybridge PRM, Volume 4 Part 1 p85, SURFACE_STATE, Number of
64 * If this field is any value other than MULTISAMPLECOUNT_1 the
65 * following restrictions apply:
67 * - the Surface Type must be SURFTYPE_2D
70 if (info
->dim
!= ISL_SURF_DIM_2D
)
73 /* More obvious restrictions */
74 if (isl_surf_usage_is_display(info
->usage
))
76 if (tiling
== ISL_TILING_LINEAR
)
81 *msaa_layout
= ISL_MSAA_LAYOUT_INTERLEAVED
;
86 gen6_choose_lod_alignment_el(const struct isl_device
*dev
,
87 const struct isl_surf_init_info
*restrict info
,
88 enum isl_tiling tiling
,
89 enum isl_msaa_layout msaa_layout
,
90 struct isl_extent3d
*lod_align_el
)
92 /* Note that the surface's horizontal image alignment is not programmable
95 * From the Sandybridge PRM (2011-05), Volume 1, Part 1, Section 7.18.3.4
96 * Alignment Unit Size:
98 * Note that the compressed formats are padded to a full compression cell.
100 * +------------------------+--------+--------+
101 * | format | halign | valign |
102 * +------------------------+--------+--------+
103 * | YUV 4:2:2 formats | 4 | * |
104 * | uncompressed formats | 4 | * |
105 * +------------------------+--------+--------+
107 * * For these formats, the vertical alignment factor ājā is determined
109 * - j = 4 for any depth buffer
110 * - j = 2 for separate stencil buffer
111 * - j = 4 for any render target surface is multisampled (4x)
112 * - j = 2 for all other render target surface
114 * From the Sandrybridge PRM (2011-05), Volume 4, Part 1, Section 2.11.2
115 * SURFACE_STATE, Surface Vertical Alignment:
117 * - This field must be set to VALIGN_2 if the Surface Format is 96 bits
120 * - Value of 1 [VALIGN_4] is not supported for format YCRCB_NORMAL
121 * (0x182), YCRCB_SWAPUVY (0x183), YCRCB_SWAPUV (0x18f), YCRCB_SWAPY
125 if (isl_format_is_compressed(info
->format
)) {
126 *lod_align_el
= isl_extent3d(1, 1, 1);
130 if (isl_format_is_yuv(info
->format
)) {
131 *lod_align_el
= isl_extent3d(4, 2, 1);
135 if (info
->samples
> 1) {
136 *lod_align_el
= isl_extent3d(4, 4, 1);
140 if (isl_surf_usage_is_depth_or_stencil(info
->usage
) &&
141 !ISL_DEV_USE_SEPARATE_STENCIL(dev
)) {
142 /* interleaved depthstencil buffer */
143 *lod_align_el
= isl_extent3d(4, 4, 1);
147 if (isl_surf_usage_is_depth(info
->usage
)) {
148 /* separate depth buffer */
149 *lod_align_el
= isl_extent3d(4, 4, 1);
153 if (isl_surf_usage_is_stencil(info
->usage
)) {
154 /* separate stencil buffer */
155 *lod_align_el
= isl_extent3d(4, 2, 1);
159 *lod_align_el
= isl_extent3d(4, 2, 1);