2 * Copyright © 2008 Jérôme Glisse
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * 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:
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
16 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
17 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 * The above copyright notice and this permission notice (including the
22 * next paragraph) shall be included in all copies or substantial portions
27 * Jérôme Glisse <glisse@freedesktop.org>
36 #define RADEON_BO_FLAGS_MACRO_TILE 1
37 #define RADEON_BO_FLAGS_MICRO_TILE 2
39 struct radeon_bo_manager;
48 struct radeon_bo_manager *bom;
52 struct radeon_bo_funcs {
53 struct radeon_bo *(*bo_open)(struct radeon_bo_manager *bom,
58 void (*bo_ref)(struct radeon_bo *bo);
59 void (*bo_unref)(struct radeon_bo *bo);
60 int (*bo_map)(struct radeon_bo *bo, int write);
61 int (*bo_unmap)(struct radeon_bo *bo);
64 struct radeon_bo_manager {
65 struct radeon_bo_funcs *funcs;
69 static inline void _radeon_bo_debug(struct radeon_bo *bo,
75 fprintf(stderr, "%02d %p 0x%08X 0x%08X [%s %s %d]\n",
76 opcode, bo, bo->size, bo->cref, file, func, line);
79 static inline struct radeon_bo *_radeon_bo_open(struct radeon_bo_manager *bom,
89 bo = bom->funcs->bo_open(bom, handle, size, alignment, flags);
90 #ifdef RADEON_BO_TRACK_OPEN
92 _radeon_bo_debug(bo, 1, file, func, line);
98 static inline void _radeon_bo_ref(struct radeon_bo *bo,
104 #ifdef RADEON_BO_TRACK_REF
105 _radeon_bo_debug(bo, 2, file, func, line);
107 bo->bom->funcs->bo_ref(bo);
110 static inline void _radeon_bo_unref(struct radeon_bo *bo,
116 #ifdef RADEON_BO_TRACK_REF
117 _radeon_bo_debug(bo, 3, file, func, line);
119 bo->bom->funcs->bo_unref(bo);
122 static inline int _radeon_bo_map(struct radeon_bo *bo,
128 #ifdef RADEON_BO_TRACK_MAP
129 _radeon_bo_debug(bo, 4, file, func, line);
131 return bo->bom->funcs->bo_map(bo, write);
134 static inline int _radeon_bo_unmap(struct radeon_bo *bo,
139 #ifdef RADEON_BO_TRACK_MAP
140 _radeon_bo_debug(bo, 5, file, func, line);
142 return bo->bom->funcs->bo_unmap(bo);
145 #define radeon_bo_open(bom, h, s, a, f)\
146 _radeon_bo_open(bom, h, s, a, f, __FILE__, __FUNCTION__, __LINE__)
147 #define radeon_bo_ref(bo)\
148 _radeon_bo_ref(bo, __FILE__, __FUNCTION__, __LINE__)
149 #define radeon_bo_unref(bo)\
150 _radeon_bo_unref(bo, __FILE__, __FUNCTION__, __LINE__)
151 #define radeon_bo_map(bo, w)\
152 _radeon_bo_map(bo, w, __FILE__, __FUNCTION__, __LINE__)
153 #define radeon_bo_unmap(bo)\
154 _radeon_bo_unmap(bo, __FILE__, __FUNCTION__, __LINE__)
155 #define radeon_bo_debug(bo, opcode)\
156 _radeon_bo_debug(bo, opcode, __FILE__, __FUNCTION__, __LINE__)