Path: blob/21.2-virgl/src/freedreno/fdl/freedreno_layout.c
4561 views
/*1* Copyright (C) 2018 Rob Clark <[email protected]>2* Copyright © 2018 Google, Inc.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,20* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*23* Authors:24* Rob Clark <[email protected]>25*/2627#include <stdio.h>2829#include "freedreno_layout.h"3031void32fdl_layout_buffer(struct fdl_layout *layout, uint32_t size)33{34layout->width0 = size;35layout->height0 = 1;36layout->depth0 = 1;37layout->cpp = 1;38layout->cpp_shift = 0;39layout->size = size;40layout->format = PIPE_FORMAT_R8_UINT;41layout->nr_samples = 1;42}4344const char *45fdl_tile_mode_desc(const struct fdl_layout *layout, int level)46{47if (fdl_ubwc_enabled(layout, level))48return "UBWC";49else if (fdl_tile_mode(layout, level) == 0) /* TILE6_LINEAR and friends */50return "linear";51else52return "tiled";53}5455void56fdl_dump_layout(struct fdl_layout *layout)57{58for (uint32_t level = 0;59level < ARRAY_SIZE(layout->slices) && layout->slices[level].size0;60level++) {61struct fdl_slice *slice = &layout->slices[level];62struct fdl_slice *ubwc_slice = &layout->ubwc_slices[level];6364fprintf(65stderr,66"%s: %ux%ux%u@%ux%u:\t%2u: stride=%4u, size=%6u,%6u, "67"aligned_height=%3u, offset=0x%x,0x%x, layersz %5u,%5u %s\n",68util_format_name(layout->format), u_minify(layout->width0, level),69u_minify(layout->height0, level), u_minify(layout->depth0, level),70layout->cpp, layout->nr_samples, level, fdl_pitch(layout, level),71slice->size0, ubwc_slice->size0,72slice->size0 / fdl_pitch(layout, level), slice->offset,73ubwc_slice->offset, layout->layer_size, layout->ubwc_layer_size,74fdl_tile_mode_desc(layout, level));75}76}777879