17ec681f3Smrg/* 27ec681f3Smrg * Copyright 2015 Intel Corporation 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ec681f3Smrg * IN THE SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#include "isl_gfx4.h" 257ec681f3Smrg#include "isl_priv.h" 267ec681f3Smrg 277ec681f3Smrgbool 287ec681f3Smrgisl_gfx4_choose_msaa_layout(const struct isl_device *dev, 297ec681f3Smrg const struct isl_surf_init_info *info, 307ec681f3Smrg enum isl_tiling tiling, 317ec681f3Smrg enum isl_msaa_layout *msaa_layout) 327ec681f3Smrg{ 337ec681f3Smrg /* Gfx4 and Gfx5 do not support MSAA */ 347ec681f3Smrg assert(info->samples >= 1); 357ec681f3Smrg 367ec681f3Smrg *msaa_layout = ISL_MSAA_LAYOUT_NONE; 377ec681f3Smrg return true; 387ec681f3Smrg} 397ec681f3Smrg 407ec681f3Smrgvoid 417ec681f3Smrgisl_gfx4_filter_tiling(const struct isl_device *dev, 427ec681f3Smrg const struct isl_surf_init_info *restrict info, 437ec681f3Smrg isl_tiling_flags_t *flags) 447ec681f3Smrg{ 457ec681f3Smrg /* Gfx4-5 only support linear, X, and Y-tiling. */ 467ec681f3Smrg *flags &= (ISL_TILING_LINEAR_BIT | ISL_TILING_X_BIT | ISL_TILING_Y0_BIT); 477ec681f3Smrg 487ec681f3Smrg if (isl_surf_usage_is_depth_or_stencil(info->usage)) { 497ec681f3Smrg assert(!ISL_DEV_USE_SEPARATE_STENCIL(dev)); 507ec681f3Smrg 517ec681f3Smrg /* From the g35 PRM Vol. 2, 3DSTATE_DEPTH_BUFFER::Tile Walk: 527ec681f3Smrg * 537ec681f3Smrg * "The Depth Buffer, if tiled, must use Y-Major tiling" 547ec681f3Smrg * 557ec681f3Smrg * Errata Description Project 567ec681f3Smrg * BWT014 The Depth Buffer Must be Tiled, it cannot be linear. This 577ec681f3Smrg * field must be set to 1 on DevBW-A. [DevBW -A,B] 587ec681f3Smrg * 597ec681f3Smrg * In testing, the linear configuration doesn't seem to work on gfx4. 607ec681f3Smrg */ 617ec681f3Smrg *flags &= (ISL_GFX_VER(dev) == 4 && !ISL_DEV_IS_G4X(dev)) ? 627ec681f3Smrg ISL_TILING_Y0_BIT : (ISL_TILING_Y0_BIT | ISL_TILING_LINEAR_BIT); 637ec681f3Smrg } 647ec681f3Smrg 657ec681f3Smrg if (info->usage & ISL_SURF_USAGE_DISPLAY_BIT) { 667ec681f3Smrg /* Before Skylake, the display engine does not accept Y */ 677ec681f3Smrg *flags &= (ISL_TILING_LINEAR_BIT | ISL_TILING_X_BIT); 687ec681f3Smrg } 697ec681f3Smrg 707ec681f3Smrg assert(info->samples == 1); 717ec681f3Smrg 727ec681f3Smrg /* From the g35 PRM, Volume 1, 11.5.5, "Per-Stream Tile Format Support": 737ec681f3Smrg * 747ec681f3Smrg * "NOTE: 128BPE Format Color buffer ( render target ) MUST be either 757ec681f3Smrg * TileX or Linear." 767ec681f3Smrg * 777ec681f3Smrg * This is required all the way up to Sandy Bridge. 787ec681f3Smrg */ 797ec681f3Smrg if (isl_format_get_layout(info->format)->bpb >= 128) 807ec681f3Smrg *flags &= ~ISL_TILING_Y0_BIT; 817ec681f3Smrg} 827ec681f3Smrg 837ec681f3Smrgvoid 847ec681f3Smrgisl_gfx4_choose_image_alignment_el(const struct isl_device *dev, 857ec681f3Smrg const struct isl_surf_init_info *restrict info, 867ec681f3Smrg enum isl_tiling tiling, 877ec681f3Smrg enum isl_dim_layout dim_layout, 887ec681f3Smrg enum isl_msaa_layout msaa_layout, 897ec681f3Smrg struct isl_extent3d *image_align_el) 907ec681f3Smrg{ 917ec681f3Smrg assert(info->samples == 1); 927ec681f3Smrg assert(msaa_layout == ISL_MSAA_LAYOUT_NONE); 937ec681f3Smrg assert(!isl_tiling_is_std_y(tiling)); 947ec681f3Smrg 957ec681f3Smrg /* Note that neither the surface's horizontal nor vertical image alignment 967ec681f3Smrg * is programmable on gfx4 nor gfx5. 977ec681f3Smrg * 987ec681f3Smrg * From the G35 PRM (2008-01), Volume 1 Graphics Core, Section 6.17.3.4 997ec681f3Smrg * Alignment Unit Size: 1007ec681f3Smrg * 1017ec681f3Smrg * Note that the compressed formats are padded to a full compression 1027ec681f3Smrg * cell. 1037ec681f3Smrg * 1047ec681f3Smrg * +------------------------+--------+--------+ 1057ec681f3Smrg * | format | halign | valign | 1067ec681f3Smrg * +------------------------+--------+--------+ 1077ec681f3Smrg * | YUV 4:2:2 formats | 4 | 2 | 1087ec681f3Smrg * | uncompressed formats | 4 | 2 | 1097ec681f3Smrg * +------------------------+--------+--------+ 1107ec681f3Smrg */ 1117ec681f3Smrg 1127ec681f3Smrg if (isl_format_is_compressed(info->format)) { 1137ec681f3Smrg *image_align_el = isl_extent3d(1, 1, 1); 1147ec681f3Smrg return; 1157ec681f3Smrg } 1167ec681f3Smrg 1177ec681f3Smrg *image_align_el = isl_extent3d(4, 2, 1); 1187ec681f3Smrg} 119