2 * Copyright © 2008 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
29 * @file intel_bufmgr_priv.h
31 * Private definitions of Intel-specific bufmgr functions and structures.
34 #ifndef INTEL_BUFMGR_PRIV_H
35 #define INTEL_BUFMGR_PRIV_H
38 * Context for a buffer manager instance.
40 * Contains public methods followed by private storage for the buffer manager.
42 struct _drm_intel_bufmgr {
44 * Allocate a buffer object.
46 * Buffer objects are not necessarily initially mapped into CPU virtual
47 * address space or graphics device aperture. They must be mapped using
48 * bo_map() to be used by the CPU, and validated for use using bo_validate()
49 * to be used from the graphics device.
51 drm_intel_bo *(*bo_alloc)(drm_intel_bufmgr *bufmgr, const char *name,
52 unsigned long size, unsigned int alignment);
54 /** Takes a reference on a buffer object */
55 void (*bo_reference)(drm_intel_bo *bo);
58 * Releases a reference on a buffer object, freeing the data if
61 void (*bo_unreference)(drm_intel_bo *bo);
64 * Maps the buffer into userspace.
66 * This function will block waiting for any existing execution on the
67 * buffer to complete, first. The resulting mapping is available at
70 int (*bo_map)(drm_intel_bo *bo, int write_enable);
72 /** Reduces the refcount on the userspace mapping of the buffer object. */
73 int (*bo_unmap)(drm_intel_bo *bo);
76 * Write data into an object.
78 * This is an optional function, if missing,
79 * drm_intel_bo will map/memcpy/unmap.
81 int (*bo_subdata)(drm_intel_bo *bo, unsigned long offset,
82 unsigned long size, const void *data);
85 * Read data from an object
87 * This is an optional function, if missing,
88 * drm_intel_bo will map/memcpy/unmap.
90 int (*bo_get_subdata)(drm_intel_bo *bo, unsigned long offset,
91 unsigned long size, void *data);
94 * Waits for rendering to an object by the GPU to have completed.
96 * This is not required for any access to the BO by bo_map, bo_subdata, etc.
97 * It is merely a way for the driver to implement glFinish.
99 void (*bo_wait_rendering)(drm_intel_bo *bo);
102 * Tears down the buffer manager instance.
104 void (*destroy)(drm_intel_bufmgr *bufmgr);
107 * Add relocation entry in reloc_buf, which will be updated with the
108 * target buffer's real offset on on command submission.
110 * Relocations remain in place for the lifetime of the buffer object.
112 * \param bo Buffer to write the relocation into.
113 * \param offset Byte offset within reloc_bo of the pointer to target_bo.
114 * \param target_bo Buffer whose offset should be written into the
116 * \param target_offset Constant value to be added to target_bo's offset in
118 * \param read_domains GEM read domains which the buffer will be read into
119 * by the command that this relocation is part of.
120 * \param write_domains GEM read domains which the buffer will be dirtied
121 * in by the command that this relocation is part of.
123 int (*bo_emit_reloc)(drm_intel_bo *bo, uint32_t offset,
124 drm_intel_bo *target_bo, uint32_t target_offset,
125 uint32_t read_domains, uint32_t write_domain);
127 /** Executes the command buffer pointed to by bo. */
128 int (*bo_exec)(drm_intel_bo *bo, int used,
129 drm_clip_rect_t *cliprects, int num_cliprects,
133 * Pin a buffer to the aperture and fix the offset until unpinned
135 * \param buf Buffer to pin
136 * \param alignment Required alignment for aperture, in bytes
138 int (*bo_pin)(drm_intel_bo *bo, uint32_t alignment);
140 * Unpin a buffer from the aperture, allowing it to be removed
142 * \param buf Buffer to unpin
144 int (*bo_unpin)(drm_intel_bo *bo);
146 * Ask that the buffer be placed in tiling mode
148 * \param buf Buffer to set tiling mode for
149 * \param tiling_mode desired, and returned tiling mode
151 int (*bo_set_tiling)(drm_intel_bo *bo, uint32_t *tiling_mode,
154 * Get the current tiling (and resulting swizzling) mode for the bo.
156 * \param buf Buffer to get tiling mode for
157 * \param tiling_mode returned tiling mode
158 * \param swizzle_mode returned swizzling mode
160 int (*bo_get_tiling)(drm_intel_bo *bo, uint32_t *tiling_mode,
161 uint32_t *swizzle_mode);
163 * Create a visible name for a buffer which can be used by other apps
165 * \param buf Buffer to create a name for
166 * \param name Returned name
168 int (*bo_flink)(drm_intel_bo *bo, uint32_t *name);
170 int (*check_aperture_space)(drm_intel_bo **bo_array, int count);
171 int debug; /**< Enables verbose debugging printouts */
174 #endif /* INTEL_BUFMGR_PRIV_H */