Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a5xx/fd5_resource.c
4574 views
/*1* Copyright (C) 2018 Rob Clark <[email protected]>2*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, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#include "fd5_resource.h"2728static void29setup_lrz(struct fd_resource *rsc)30{31struct fd_screen *screen = fd_screen(rsc->b.b.screen);32unsigned lrz_pitch = align(DIV_ROUND_UP(rsc->b.b.width0, 8), 64);33unsigned lrz_height = DIV_ROUND_UP(rsc->b.b.height0, 8);3435/* LRZ buffer is super-sampled: */36switch (rsc->b.b.nr_samples) {37case 4:38lrz_pitch *= 2;39FALLTHROUGH;40case 2:41lrz_height *= 2;42}4344unsigned size = lrz_pitch * lrz_height * 2;4546size += 0x1000; /* for GRAS_LRZ_FAST_CLEAR_BUFFER */4748rsc->lrz_height = lrz_height;49rsc->lrz_width = lrz_pitch;50rsc->lrz_pitch = lrz_pitch;51rsc->lrz = fd_bo_new(screen->dev, size, 0, "lrz");52}5354uint32_t55fd5_setup_slices(struct fd_resource *rsc)56{57struct pipe_resource *prsc = &rsc->b.b;5859if (FD_DBG(LRZ) && has_depth(rsc->b.b.format))60setup_lrz(rsc);6162fdl5_layout(&rsc->layout, prsc->format, fd_resource_nr_samples(prsc),63prsc->width0, prsc->height0, prsc->depth0, prsc->last_level + 1,64prsc->array_size, prsc->target == PIPE_TEXTURE_3D);6566return rsc->layout.size;67}686970