Path: blob/21.2-virgl/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
4566 views
/*1* Copyright © 2008 Jérôme Glisse2* Copyright © 2011 Marek Olšák <[email protected]>3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining6* a copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,14* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES15* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND16* NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS17* AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,19* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*22* The above copyright notice and this permission notice (including the23* next paragraph) shall be included in all copies or substantial portions24* of the Software.25*/2627#ifndef RADEON_DRM_BO_H28#define RADEON_DRM_BO_H2930#include "radeon_drm_winsys.h"31#include "os/os_thread.h"32#include "pipebuffer/pb_slab.h"3334struct radeon_bo {35struct pb_buffer base;36union {37struct {38struct pb_cache_entry cache_entry;3940void *ptr;41mtx_t map_mutex;42unsigned map_count;43bool use_reusable_pool;44} real;45struct {46struct pb_slab_entry entry;47struct radeon_bo *real;4849unsigned num_fences;50unsigned max_fences;51struct radeon_bo **fences;52} slab;53} u;5455struct radeon_drm_winsys *rws;56void *user_ptr; /* from buffer_from_ptr */5758uint32_t handle; /* 0 for slab entries */59uint32_t flink_name;60uint64_t va;61uint32_t hash;62enum radeon_bo_domain initial_domain;6364/* how many command streams is this bo referenced in? */65int num_cs_references;6667/* how many command streams, which are being emitted in a separate68* thread, is this bo referenced in? */69int num_active_ioctls;70};7172struct radeon_slab {73struct pb_slab base;74struct radeon_bo *buffer;75struct radeon_bo *entries;76};7778void radeon_bo_destroy(void *winsys, struct pb_buffer *_buf);79bool radeon_bo_can_reclaim(void *winsys, struct pb_buffer *_buf);80void radeon_drm_bo_init_functions(struct radeon_drm_winsys *ws);8182bool radeon_bo_can_reclaim_slab(void *priv, struct pb_slab_entry *entry);83struct pb_slab *radeon_bo_slab_alloc(void *priv, unsigned heap,84unsigned entry_size,85unsigned group_index);86void radeon_bo_slab_free(void *priv, struct pb_slab *slab);8788static inline89void radeon_ws_bo_reference(struct radeon_bo **dst, struct radeon_bo *src)90{91pb_reference((struct pb_buffer**)dst, (struct pb_buffer*)src);92}9394void *radeon_bo_do_map(struct radeon_bo *bo);9596#endif979899