1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2018 Rob Clark <robclark@freedesktop.org> 3bf215546Sopenharmony_ci * Copyright © 2018 Google, Inc. 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 10bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci * Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22bf215546Sopenharmony_ci * SOFTWARE. 23bf215546Sopenharmony_ci * 24bf215546Sopenharmony_ci * Authors: 25bf215546Sopenharmony_ci * Rob Clark <robclark@freedesktop.org> 26bf215546Sopenharmony_ci */ 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#include <stdio.h> 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#include "freedreno_layout.h" 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_civoid 33bf215546Sopenharmony_cifdl_layout_buffer(struct fdl_layout *layout, uint32_t size) 34bf215546Sopenharmony_ci{ 35bf215546Sopenharmony_ci layout->width0 = size; 36bf215546Sopenharmony_ci layout->height0 = 1; 37bf215546Sopenharmony_ci layout->depth0 = 1; 38bf215546Sopenharmony_ci layout->cpp = 1; 39bf215546Sopenharmony_ci layout->cpp_shift = 0; 40bf215546Sopenharmony_ci layout->size = size; 41bf215546Sopenharmony_ci layout->format = PIPE_FORMAT_R8_UINT; 42bf215546Sopenharmony_ci layout->nr_samples = 1; 43bf215546Sopenharmony_ci} 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ciconst char * 46bf215546Sopenharmony_cifdl_tile_mode_desc(const struct fdl_layout *layout, int level) 47bf215546Sopenharmony_ci{ 48bf215546Sopenharmony_ci if (fdl_ubwc_enabled(layout, level)) 49bf215546Sopenharmony_ci return "UBWC"; 50bf215546Sopenharmony_ci else if (fdl_tile_mode(layout, level) == 0) /* TILE6_LINEAR and friends */ 51bf215546Sopenharmony_ci return "linear"; 52bf215546Sopenharmony_ci else 53bf215546Sopenharmony_ci return "tiled"; 54bf215546Sopenharmony_ci} 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_civoid 57bf215546Sopenharmony_cifdl_dump_layout(struct fdl_layout *layout) 58bf215546Sopenharmony_ci{ 59bf215546Sopenharmony_ci for (uint32_t level = 0; 60bf215546Sopenharmony_ci level < ARRAY_SIZE(layout->slices) && layout->slices[level].size0; 61bf215546Sopenharmony_ci level++) { 62bf215546Sopenharmony_ci struct fdl_slice *slice = &layout->slices[level]; 63bf215546Sopenharmony_ci struct fdl_slice *ubwc_slice = &layout->ubwc_slices[level]; 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci fprintf( 66bf215546Sopenharmony_ci stderr, 67bf215546Sopenharmony_ci "%s: %ux%ux%u@%ux%u:\t%2u: stride=%4u, size=%6u,%6u, " 68bf215546Sopenharmony_ci "aligned_height=%3u, offset=0x%x,0x%x, layersz %5u,%5u %s\n", 69bf215546Sopenharmony_ci util_format_name(layout->format), u_minify(layout->width0, level), 70bf215546Sopenharmony_ci u_minify(layout->height0, level), u_minify(layout->depth0, level), 71bf215546Sopenharmony_ci layout->cpp, layout->nr_samples, level, fdl_pitch(layout, level), 72bf215546Sopenharmony_ci slice->size0, ubwc_slice->size0, 73bf215546Sopenharmony_ci slice->size0 / fdl_pitch(layout, level), slice->offset, 74bf215546Sopenharmony_ci ubwc_slice->offset, layout->layer_size, layout->ubwc_layer_size, 75bf215546Sopenharmony_ci fdl_tile_mode_desc(layout, level)); 76bf215546Sopenharmony_ci } 77bf215546Sopenharmony_ci} 78