radeon_drm_bo.h revision 6ccab620a0e7364ab6c0d902b3ddf58ee988f7fa
1/* 2 * Copyright © 2008 Jérôme Glisse 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining 6 * a copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sub license, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * 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 WARRANTIES 15 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS 17 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 * USE OR OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * The above copyright notice and this permission notice (including the 23 * next paragraph) shall be included in all copies or substantial portions 24 * of the Software. 25 */ 26/* 27 * Authors: 28 * Jérôme Glisse <glisse@freedesktop.org> 29 */ 30#ifndef RADEON_DRM_BUFFER_H 31#define RADEON_DRM_BUFFER_H 32 33#include "radeon_winsys.h" 34#include "pipebuffer/pb_bufmgr.h" 35 36#define RADEON_PB_USAGE_CACHE (1 << 28) 37#define RADEON_PB_USAGE_DOMAIN_GTT (1 << 29) 38#define RADEON_PB_USAGE_DOMAIN_VRAM (1 << 30) 39 40struct radeon_bomgr; 41 42struct radeon_bo { 43 struct pb_buffer base; 44 struct radeon_bomgr *mgr; 45 46 void *ptr; 47 uint32_t size; 48 uint32_t handle; 49 uint32_t name; 50 51 int cref; 52 53 boolean flinked; 54 uint32_t flink; 55}; 56 57struct pb_manager *radeon_bomgr_create(struct radeon_drm_winsys *rws); 58struct pb_buffer *radeon_bomgr_create_bo_from_handle(struct pb_manager *_mgr, 59 uint32_t handle); 60boolean radeon_bomgr_get_handle(struct pb_buffer *_buf, 61 struct winsys_handle *whandle); 62void radeon_bomgr_init_functions(struct radeon_drm_winsys *ws); 63 64void radeon_bo_unref(struct radeon_bo *buf); 65 66 67static INLINE void radeon_bo_ref(struct radeon_bo *bo) 68{ 69 p_atomic_inc(&bo->cref); 70} 71 72static INLINE struct pb_buffer * 73pb_buffer(struct r300_winsys_bo *buffer) 74{ 75 return (struct pb_buffer *)buffer; 76} 77 78#endif 79