Path: blob/21.2-virgl/src/gallium/drivers/lima/lima_bo.h
4565 views
/*1* Copyright (C) 2018-2019 Lima Project2*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 shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*21*/2223#ifndef H_LIMA_BO24#define H_LIMA_BO2526#include <stdbool.h>27#include <stdint.h>2829#include "util/u_atomic.h"30#include "util/list.h"3132struct lima_bo {33struct lima_screen *screen;34struct list_head time_list;35struct list_head size_list;36int refcnt;37bool cacheable;38time_t free_time;3940uint32_t size;41uint32_t flags;42uint32_t handle;43uint64_t offset;44uint32_t flink_name;4546void *map;47uint32_t va;48};4950bool lima_bo_table_init(struct lima_screen *screen);51void lima_bo_table_fini(struct lima_screen *screen);52bool lima_bo_cache_init(struct lima_screen *screen);53void lima_bo_cache_fini(struct lima_screen *screen);5455struct lima_bo *lima_bo_create(struct lima_screen *screen, uint32_t size,56uint32_t flags);57void lima_bo_unreference(struct lima_bo *bo);5859static inline void lima_bo_reference(struct lima_bo *bo)60{61p_atomic_inc(&bo->refcnt);62}6364void *lima_bo_map(struct lima_bo *bo);65void lima_bo_unmap(struct lima_bo *bo);6667bool lima_bo_export(struct lima_bo *bo, struct winsys_handle *handle);68struct lima_bo *lima_bo_import(struct lima_screen *screen,69struct winsys_handle *handle);7071bool lima_bo_wait(struct lima_bo *bo, uint32_t op, uint64_t timeout_ns);7273#endif747576