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
isl_gfx6_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_GFX_VER(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
isl_gfx6_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 | * |
93
* | uncompressed formats | 4 | * |
94
* +------------------------+--------+--------+
96
* * For these formats, the vertical alignment factor “j” is determined
98
* - j = 4 for any depth buffer
99
* - j = 2 for separate stencil buffer
100
* - j = 4 for any render target surface is multisampled (4x)
101
* - j = 2 for all other render target surface
103
* From the Sandrybridge PRM (2011-05), Volume 4, Part 1, Section 2.11.2
104
* SURFACE_STATE, Surface Vertical Alignment:
106
* - This field must be set to VALIGN_2 if the Surface Format is 96 bits
109
* - Value of 1 [VALIGN_4] is not supported for format YCRCB_NORMAL
110
* (0x182), YCRCB_SWAPUVY (0x183), YCRCB_SWAPUV (0x18f), YCRCB_SWAPY
114
if (isl_format_is_compressed(info->format)) {
115
/* Compressed formats have an alignment equal to their block size */
116
*image_align_el = isl_extent3d(1, 1, 1);
120
/* Separate stencil requires 4x2 alignment */
121
if (isl_surf_usage_is_stencil(info->usage) &&
122
info->format == ISL_FORMAT_R8_UINT) {
123
*image_align_el = isl_extent3d(4, 2, 1);
127
/* Depth or combined depth stencil surfaces require 4x4 alignment */
128
if (isl_surf_usage_is_depth_or_stencil(info->usage)) {
129
*image_align_el = isl_extent3d(4, 4, 1);
133
if (info->samples > 1) {
134
*image_align_el = isl_extent3d(4, 4, 1);
138
/* For everything else, 4x2 is always a valid alignment. Since this is
139
* also the smallest alignment we can specify, we use 4x2 for everything
140
* else because it uses the least memory.
142
*image_align_el = isl_extent3d(4, 2, 1);