Path: blob/21.2-virgl/src/panfrost/vulkan/panvk_varyings.c
4560 views
/*1* Copyright (C) 2021 Collabora Ltd.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, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*/2223#include "panvk_private.h"24#include "panvk_varyings.h"2526#include "pan_pool.h"2728unsigned29panvk_varyings_buf_count(const struct panvk_device *dev,30struct panvk_varyings_info *varyings)31{32const struct panfrost_device *pdev = &dev->physical_device->pdev;3334return util_bitcount(varyings->buf_mask) + (pan_is_bifrost(pdev) ? 1 : 0);35}3637void38panvk_varyings_alloc(struct panvk_varyings_info *varyings,39struct pan_pool *varying_mem_pool,40unsigned vertex_count)41{42for (unsigned i = 0; i < PANVK_VARY_BUF_MAX; i++) {43if (!(varyings->buf_mask & (1 << i))) continue;4445unsigned buf_idx = panvk_varying_buf_index(varyings, i);46unsigned size = varyings->buf[buf_idx].stride * vertex_count;47if (!size)48continue;4950struct panfrost_ptr ptr =51pan_pool_alloc_aligned(varying_mem_pool, size, 64);5253varyings->buf[buf_idx].size = size;54varyings->buf[buf_idx].address = ptr.gpu;55varyings->buf[buf_idx].cpu = ptr.cpu;56}57}585960