1*61046927SAndroid Build Coastguard Worker /*
2*61046927SAndroid Build Coastguard Worker * Copyright 2015 Intel Corporation
3*61046927SAndroid Build Coastguard Worker *
4*61046927SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a
5*61046927SAndroid Build Coastguard Worker * copy of this software and associated documentation files (the "Software"),
6*61046927SAndroid Build Coastguard Worker * to deal in the Software without restriction, including without limitation
7*61046927SAndroid Build Coastguard Worker * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*61046927SAndroid Build Coastguard Worker * and/or sell copies of the Software, and to permit persons to whom the
9*61046927SAndroid Build Coastguard Worker * Software is furnished to do so, subject to the following conditions:
10*61046927SAndroid Build Coastguard Worker *
11*61046927SAndroid Build Coastguard Worker * The above copyright notice and this permission notice (including the next
12*61046927SAndroid Build Coastguard Worker * paragraph) shall be included in all copies or substantial portions of the
13*61046927SAndroid Build Coastguard Worker * Software.
14*61046927SAndroid Build Coastguard Worker *
15*61046927SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*61046927SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*61046927SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18*61046927SAndroid Build Coastguard Worker * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*61046927SAndroid Build Coastguard Worker * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*61046927SAndroid Build Coastguard Worker * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*61046927SAndroid Build Coastguard Worker * IN THE SOFTWARE.
22*61046927SAndroid Build Coastguard Worker */
23*61046927SAndroid Build Coastguard Worker
24*61046927SAndroid Build Coastguard Worker #include "isl_gfx4.h"
25*61046927SAndroid Build Coastguard Worker #include "isl_priv.h"
26*61046927SAndroid Build Coastguard Worker
27*61046927SAndroid Build Coastguard Worker bool
isl_gfx4_choose_msaa_layout(const struct isl_device * dev,const struct isl_surf_init_info * info,enum isl_tiling tiling,enum isl_msaa_layout * msaa_layout)28*61046927SAndroid Build Coastguard Worker isl_gfx4_choose_msaa_layout(const struct isl_device *dev,
29*61046927SAndroid Build Coastguard Worker const struct isl_surf_init_info *info,
30*61046927SAndroid Build Coastguard Worker enum isl_tiling tiling,
31*61046927SAndroid Build Coastguard Worker enum isl_msaa_layout *msaa_layout)
32*61046927SAndroid Build Coastguard Worker {
33*61046927SAndroid Build Coastguard Worker /* Gfx4 and Gfx5 do not support MSAA */
34*61046927SAndroid Build Coastguard Worker assert(info->samples >= 1);
35*61046927SAndroid Build Coastguard Worker
36*61046927SAndroid Build Coastguard Worker *msaa_layout = ISL_MSAA_LAYOUT_NONE;
37*61046927SAndroid Build Coastguard Worker return true;
38*61046927SAndroid Build Coastguard Worker }
39*61046927SAndroid Build Coastguard Worker
40*61046927SAndroid Build Coastguard Worker void
isl_gfx4_filter_tiling(const struct isl_device * dev,const struct isl_surf_init_info * restrict info,isl_tiling_flags_t * flags)41*61046927SAndroid Build Coastguard Worker isl_gfx4_filter_tiling(const struct isl_device *dev,
42*61046927SAndroid Build Coastguard Worker const struct isl_surf_init_info *restrict info,
43*61046927SAndroid Build Coastguard Worker isl_tiling_flags_t *flags)
44*61046927SAndroid Build Coastguard Worker {
45*61046927SAndroid Build Coastguard Worker /* Gfx4-5 only support linear, X, and Y-tiling. */
46*61046927SAndroid Build Coastguard Worker *flags &= (ISL_TILING_LINEAR_BIT | ISL_TILING_X_BIT | ISL_TILING_Y0_BIT);
47*61046927SAndroid Build Coastguard Worker
48*61046927SAndroid Build Coastguard Worker if (isl_surf_usage_is_depth_or_stencil(info->usage)) {
49*61046927SAndroid Build Coastguard Worker assert(!ISL_DEV_USE_SEPARATE_STENCIL(dev));
50*61046927SAndroid Build Coastguard Worker
51*61046927SAndroid Build Coastguard Worker /* From the g35 PRM Vol. 2, 3DSTATE_DEPTH_BUFFER::Tile Walk:
52*61046927SAndroid Build Coastguard Worker *
53*61046927SAndroid Build Coastguard Worker * "The Depth Buffer, if tiled, must use Y-Major tiling"
54*61046927SAndroid Build Coastguard Worker *
55*61046927SAndroid Build Coastguard Worker * Errata Description Project
56*61046927SAndroid Build Coastguard Worker * BWT014 The Depth Buffer Must be Tiled, it cannot be linear. This
57*61046927SAndroid Build Coastguard Worker * field must be set to 1 on DevBW-A. [DevBW -A,B]
58*61046927SAndroid Build Coastguard Worker *
59*61046927SAndroid Build Coastguard Worker * In testing, the linear configuration doesn't seem to work on I965. We
60*61046927SAndroid Build Coastguard Worker * choose to be consistent and require tiling for gfx4-5.
61*61046927SAndroid Build Coastguard Worker */
62*61046927SAndroid Build Coastguard Worker *flags &= ISL_TILING_Y0_BIT;
63*61046927SAndroid Build Coastguard Worker }
64*61046927SAndroid Build Coastguard Worker
65*61046927SAndroid Build Coastguard Worker if (info->usage & ISL_SURF_USAGE_DISPLAY_BIT) {
66*61046927SAndroid Build Coastguard Worker /* Before Skylake, the display engine does not accept Y */
67*61046927SAndroid Build Coastguard Worker *flags &= (ISL_TILING_LINEAR_BIT | ISL_TILING_X_BIT);
68*61046927SAndroid Build Coastguard Worker }
69*61046927SAndroid Build Coastguard Worker
70*61046927SAndroid Build Coastguard Worker assert(info->samples == 1);
71*61046927SAndroid Build Coastguard Worker
72*61046927SAndroid Build Coastguard Worker /* From the g35 PRM, Volume 1, 11.5.5, "Per-Stream Tile Format Support":
73*61046927SAndroid Build Coastguard Worker *
74*61046927SAndroid Build Coastguard Worker * "NOTE: 128BPE Format Color buffer ( render target ) MUST be either
75*61046927SAndroid Build Coastguard Worker * TileX or Linear."
76*61046927SAndroid Build Coastguard Worker *
77*61046927SAndroid Build Coastguard Worker * This is required all the way up to Sandy Bridge.
78*61046927SAndroid Build Coastguard Worker */
79*61046927SAndroid Build Coastguard Worker if (isl_format_get_layout(info->format)->bpb >= 128)
80*61046927SAndroid Build Coastguard Worker *flags &= ~ISL_TILING_Y0_BIT;
81*61046927SAndroid Build Coastguard Worker }
82*61046927SAndroid Build Coastguard Worker
83*61046927SAndroid Build Coastguard Worker void
isl_gfx4_choose_image_alignment_el(const struct isl_device * dev,const struct isl_surf_init_info * restrict info,enum isl_tiling tiling,enum isl_dim_layout dim_layout,enum isl_msaa_layout msaa_layout,struct isl_extent3d * image_align_el)84*61046927SAndroid Build Coastguard Worker isl_gfx4_choose_image_alignment_el(const struct isl_device *dev,
85*61046927SAndroid Build Coastguard Worker const struct isl_surf_init_info *restrict info,
86*61046927SAndroid Build Coastguard Worker enum isl_tiling tiling,
87*61046927SAndroid Build Coastguard Worker enum isl_dim_layout dim_layout,
88*61046927SAndroid Build Coastguard Worker enum isl_msaa_layout msaa_layout,
89*61046927SAndroid Build Coastguard Worker struct isl_extent3d *image_align_el)
90*61046927SAndroid Build Coastguard Worker {
91*61046927SAndroid Build Coastguard Worker assert(info->samples == 1);
92*61046927SAndroid Build Coastguard Worker assert(msaa_layout == ISL_MSAA_LAYOUT_NONE);
93*61046927SAndroid Build Coastguard Worker assert(!isl_tiling_is_std_y(tiling));
94*61046927SAndroid Build Coastguard Worker
95*61046927SAndroid Build Coastguard Worker /* Note that neither the surface's horizontal nor vertical image alignment
96*61046927SAndroid Build Coastguard Worker * is programmable on gfx4 nor gfx5.
97*61046927SAndroid Build Coastguard Worker *
98*61046927SAndroid Build Coastguard Worker * From the G35 PRM (2008-01), Volume 1 Graphics Core, Section 6.17.3.4
99*61046927SAndroid Build Coastguard Worker * Alignment Unit Size:
100*61046927SAndroid Build Coastguard Worker *
101*61046927SAndroid Build Coastguard Worker * Note that the compressed formats are padded to a full compression
102*61046927SAndroid Build Coastguard Worker * cell.
103*61046927SAndroid Build Coastguard Worker *
104*61046927SAndroid Build Coastguard Worker * +------------------------+--------+--------+
105*61046927SAndroid Build Coastguard Worker * | format | halign | valign |
106*61046927SAndroid Build Coastguard Worker * +------------------------+--------+--------+
107*61046927SAndroid Build Coastguard Worker * | YUV 4:2:2 formats | 4 | 2 |
108*61046927SAndroid Build Coastguard Worker * | uncompressed formats | 4 | 2 |
109*61046927SAndroid Build Coastguard Worker * +------------------------+--------+--------+
110*61046927SAndroid Build Coastguard Worker */
111*61046927SAndroid Build Coastguard Worker
112*61046927SAndroid Build Coastguard Worker if (isl_format_is_compressed(info->format)) {
113*61046927SAndroid Build Coastguard Worker *image_align_el = isl_extent3d(1, 1, 1);
114*61046927SAndroid Build Coastguard Worker return;
115*61046927SAndroid Build Coastguard Worker }
116*61046927SAndroid Build Coastguard Worker
117*61046927SAndroid Build Coastguard Worker *image_align_el = isl_extent3d(4, 2, 1);
118*61046927SAndroid Build Coastguard Worker }
119