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