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