/*1* Copyright 2015 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#include "isl_gfx4.h"24#include "isl_priv.h"2526bool27isl_gfx4_choose_msaa_layout(const struct isl_device *dev,28const struct isl_surf_init_info *info,29enum isl_tiling tiling,30enum isl_msaa_layout *msaa_layout)31{32/* Gfx4 and Gfx5 do not support MSAA */33assert(info->samples >= 1);3435*msaa_layout = ISL_MSAA_LAYOUT_NONE;36return true;37}3839void40isl_gfx4_filter_tiling(const struct isl_device *dev,41const struct isl_surf_init_info *restrict info,42isl_tiling_flags_t *flags)43{44/* Gfx4-5 only support linear, X, and Y-tiling. */45*flags &= (ISL_TILING_LINEAR_BIT | ISL_TILING_X_BIT | ISL_TILING_Y0_BIT);4647if (isl_surf_usage_is_depth_or_stencil(info->usage)) {48assert(!ISL_DEV_USE_SEPARATE_STENCIL(dev));4950/* From the g35 PRM Vol. 2, 3DSTATE_DEPTH_BUFFER::Tile Walk:51*52* "The Depth Buffer, if tiled, must use Y-Major tiling"53*54* Errata Description Project55* BWT014 The Depth Buffer Must be Tiled, it cannot be linear. This56* field must be set to 1 on DevBW-A. [DevBW -A,B]57*58* In testing, the linear configuration doesn't seem to work on gfx4.59*/60*flags &= (ISL_GFX_VER(dev) == 4 && !ISL_DEV_IS_G4X(dev)) ?61ISL_TILING_Y0_BIT : (ISL_TILING_Y0_BIT | ISL_TILING_LINEAR_BIT);62}6364if (info->usage & (ISL_SURF_USAGE_DISPLAY_ROTATE_90_BIT |65ISL_SURF_USAGE_DISPLAY_ROTATE_180_BIT |66ISL_SURF_USAGE_DISPLAY_ROTATE_270_BIT)) {67assert(*flags & ISL_SURF_USAGE_DISPLAY_BIT);68isl_finishme("%s:%s: handle rotated display surfaces",69__FILE__, __func__);70}7172if (info->usage & (ISL_SURF_USAGE_DISPLAY_FLIP_X_BIT |73ISL_SURF_USAGE_DISPLAY_FLIP_Y_BIT)) {74assert(*flags & ISL_SURF_USAGE_DISPLAY_BIT);75isl_finishme("%s:%s: handle flipped display surfaces",76__FILE__, __func__);77}7879if (info->usage & ISL_SURF_USAGE_DISPLAY_BIT) {80/* Before Skylake, the display engine does not accept Y */81*flags &= (ISL_TILING_LINEAR_BIT | ISL_TILING_X_BIT);82}8384assert(info->samples == 1);8586/* From the g35 PRM, Volume 1, 11.5.5, "Per-Stream Tile Format Support":87*88* "NOTE: 128BPE Format Color buffer ( render target ) MUST be either89* TileX or Linear."90*91* This is required all the way up to Sandy Bridge.92*/93if (isl_format_get_layout(info->format)->bpb >= 128)94*flags &= ~ISL_TILING_Y0_BIT;95}9697void98isl_gfx4_choose_image_alignment_el(const struct isl_device *dev,99const struct isl_surf_init_info *restrict info,100enum isl_tiling tiling,101enum isl_dim_layout dim_layout,102enum isl_msaa_layout msaa_layout,103struct isl_extent3d *image_align_el)104{105assert(info->samples == 1);106assert(msaa_layout == ISL_MSAA_LAYOUT_NONE);107assert(!isl_tiling_is_std_y(tiling));108109/* Note that neither the surface's horizontal nor vertical image alignment110* is programmable on gfx4 nor gfx5.111*112* From the G35 PRM (2008-01), Volume 1 Graphics Core, Section 6.17.3.4113* Alignment Unit Size:114*115* Note that the compressed formats are padded to a full compression116* cell.117*118* +------------------------+--------+--------+119* | format | halign | valign |120* +------------------------+--------+--------+121* | YUV 4:2:2 formats | 4 | 2 |122* | uncompressed formats | 4 | 2 |123* +------------------------+--------+--------+124*/125126if (isl_format_is_compressed(info->format)) {127*image_align_el = isl_extent3d(1, 1, 1);128return;129}130131*image_align_el = isl_extent3d(4, 2, 1);132}133134135