1afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace/* 2afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * Copyright 2015 Intel Corporation 3afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 4afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * Permission is hereby granted, free of charge, to any person obtaining a 5afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * copy of this software and associated documentation files (the "Software"), 6afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * to deal in the Software without restriction, including without limitation 7afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * and/or sell copies of the Software, and to permit persons to whom the 9afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * Software is furnished to do so, subject to the following conditions: 10afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 11afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * The above copyright notice and this permission notice (including the next 12afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * paragraph) shall be included in all copies or substantial portions of the 13afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * Software. 14afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 15afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * IN THE SOFTWARE. 22afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace */ 23afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 24afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace#include "isl_gen6.h" 25afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace#include "isl_priv.h" 26afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 27afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versacebool 285b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikovisl_gen6_choose_msaa_layout(const struct isl_device *dev, 295b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikov const struct isl_surf_init_info *info, 305b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikov enum isl_tiling tiling, 315b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikov enum isl_msaa_layout *msaa_layout) 32afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace{ 33afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace assert(ISL_DEV_GEN(dev) == 6); 34afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace assert(info->samples >= 1); 35afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 36afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (info->samples == 1) { 37afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace *msaa_layout = ISL_MSAA_LAYOUT_NONE; 3884f9ef1de4680b48d646841965f963ea2b724ab2Emil Velikov return true; 39afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace } 40afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 415637f3f1202b46ff02c80e743dd84752a040685aJason Ekstrand if (!isl_format_supports_multisampling(dev->info, info->format)) 42afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return false; 43afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 44afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace /* From the Sandybridge PRM, Volume 4 Part 1 p85, SURFACE_STATE, Number of 45afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * Multisamples: 46afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 47afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * If this field is any value other than MULTISAMPLECOUNT_1 the 48afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * following restrictions apply: 49afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 50afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * - the Surface Type must be SURFTYPE_2D 51afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * - [...] 52afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace */ 53afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (info->dim != ISL_SURF_DIM_2D) 54afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return false; 55afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 56afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace /* More obvious restrictions */ 57afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (isl_surf_usage_is_display(info->usage)) 58afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return false; 59afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (tiling == ISL_TILING_LINEAR) 60afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return false; 61afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (info->levels > 1) 62afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return false; 63afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 64afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace *msaa_layout = ISL_MSAA_LAYOUT_INTERLEAVED; 65afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return true; 66afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace} 67afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 68afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versacevoid 695b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikovisl_gen6_choose_image_alignment_el(const struct isl_device *dev, 705b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikov const struct isl_surf_init_info *restrict info, 715b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikov enum isl_tiling tiling, 725b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikov enum isl_dim_layout dim_layout, 735b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikov enum isl_msaa_layout msaa_layout, 745b1efb65ce0282071d98bc471c8dc05dcafe08faEmil Velikov struct isl_extent3d *image_align_el) 75afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace{ 7633dc8549fb9b227a57a84aac53f17bd099da38f4Jason Ekstrand /* Handled by isl_choose_image_alignment_el */ 7733dc8549fb9b227a57a84aac53f17bd099da38f4Jason Ekstrand assert(info->format != ISL_FORMAT_HIZ); 7833dc8549fb9b227a57a84aac53f17bd099da38f4Jason Ekstrand 79afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace /* Note that the surface's horizontal image alignment is not programmable 80afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * on Sandybridge. 81afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 82afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * From the Sandybridge PRM (2011-05), Volume 1, Part 1, Section 7.18.3.4 83afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * Alignment Unit Size: 84afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 85afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * Note that the compressed formats are padded to a full compression cell. 86afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 87afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * +------------------------+--------+--------+ 88afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * | format | halign | valign | 89afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * +------------------------+--------+--------+ 90afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * | YUV 4:2:2 formats | 4 | * | 91afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * | uncompressed formats | 4 | * | 92afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * +------------------------+--------+--------+ 93afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 94afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * * For these formats, the vertical alignment factor “j” is determined 95afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * as follows: 96afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * - j = 4 for any depth buffer 97afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * - j = 2 for separate stencil buffer 98afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * - j = 4 for any render target surface is multisampled (4x) 99afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * - j = 2 for all other render target surface 100afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 101afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * From the Sandrybridge PRM (2011-05), Volume 4, Part 1, Section 2.11.2 102afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * SURFACE_STATE, Surface Vertical Alignment: 103afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 104afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * - This field must be set to VALIGN_2 if the Surface Format is 96 bits 105afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * per element (BPE). 106afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * 107afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * - Value of 1 [VALIGN_4] is not supported for format YCRCB_NORMAL 108afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * (0x182), YCRCB_SWAPUVY (0x183), YCRCB_SWAPUV (0x18f), YCRCB_SWAPY 109afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace * (0x190) 110afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace */ 111afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 112afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (isl_format_is_compressed(info->format)) { 1130bebaeacd74acfafc97c0f66cdcd50369d85ab26Chad Versace *image_align_el = isl_extent3d(1, 1, 1); 114afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return; 115afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace } 116afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 117afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (isl_format_is_yuv(info->format)) { 1180bebaeacd74acfafc97c0f66cdcd50369d85ab26Chad Versace *image_align_el = isl_extent3d(4, 2, 1); 119afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return; 120afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace } 121afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 122afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (info->samples > 1) { 1230bebaeacd74acfafc97c0f66cdcd50369d85ab26Chad Versace *image_align_el = isl_extent3d(4, 4, 1); 124afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return; 125afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace } 126afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 127afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (isl_surf_usage_is_depth_or_stencil(info->usage) && 128afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace !ISL_DEV_USE_SEPARATE_STENCIL(dev)) { 129afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace /* interleaved depthstencil buffer */ 1300bebaeacd74acfafc97c0f66cdcd50369d85ab26Chad Versace *image_align_el = isl_extent3d(4, 4, 1); 131afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return; 132afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace } 133afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 134afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (isl_surf_usage_is_depth(info->usage)) { 135afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace /* separate depth buffer */ 1360bebaeacd74acfafc97c0f66cdcd50369d85ab26Chad Versace *image_align_el = isl_extent3d(4, 4, 1); 137afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return; 138afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace } 139afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 140afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace if (isl_surf_usage_is_stencil(info->usage)) { 141afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace /* separate stencil buffer */ 1420bebaeacd74acfafc97c0f66cdcd50369d85ab26Chad Versace *image_align_el = isl_extent3d(4, 2, 1); 143afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace return; 144afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace } 145afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace 1460bebaeacd74acfafc97c0f66cdcd50369d85ab26Chad Versace *image_align_el = isl_extent3d(4, 2, 1); 147afdadec77f57b42d0c7f1f44c5ab87b636d38010Chad Versace} 148