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.
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 dri_bo *(*bo_alloc)(dri_bufmgr *bufmgr_ctx, const char *name,
52 unsigned long size, unsigned int alignment);
54 /** Takes a reference on a buffer object */
55 void (*bo_reference)(dri_bo *bo);
58 * Releases a reference on a buffer object, freeing the data if
61 void (*bo_unreference)(dri_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)(dri_bo *buf, int write_enable);
72 /** Reduces the refcount on the userspace mapping of the buffer object. */
73 int (*bo_unmap)(dri_bo *buf);
76 * Write data into an object.
78 * This is an optional function, if missing,
79 * dri_bo will map/memcpy/unmap.
81 int (*bo_subdata) (dri_bo *buf, 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 * dri_bo will map/memcpy/unmap.
90 int (*bo_get_subdata) (dri_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) (dri_bo *bo);
102 * Tears down the buffer manager instance.
104 void (*destroy)(dri_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 reloc_buf Buffer to write the relocation into.
113 * \param read_domains GEM read domains which the buffer will be read into
114 * by the command that this relocation is part of.
115 * \param write_domains GEM read domains which the buffer will be dirtied
116 * in by the command that this relocation is part of.
117 * \param delta Constant value to be added to the relocation target's
119 * \param offset Byte offset within batch_buf of the relocated pointer.
120 * \param target Buffer whose offset should be written into the relocation
123 int (*bo_emit_reloc)(dri_bo *reloc_buf,
124 uint32_t read_domains, uint32_t write_domain,
125 uint32_t delta, uint32_t offset, dri_bo *target);
127 /** Executes the command buffer pointed to by bo. */
128 int (*bo_exec)(dri_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) (dri_bo *buf, 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) (dri_bo *buf);
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) (dri_bo *bo, uint32_t *tiling_mode);
153 * Get the current tiling (and resulting swizzling) mode for the bo.
155 * \param buf Buffer to get tiling mode for
156 * \param tiling_mode returned tiling mode
157 * \param swizzle_mode returned swizzling mode
159 int (*bo_get_tiling) (dri_bo *bo, uint32_t *tiling_mode,
160 uint32_t *swizzle_mode);
162 * Create a visible name for a buffer which can be used by other apps
164 * \param buf Buffer to create a name for
165 * \param name Returned name
167 int (*bo_flink) (dri_bo *buf, uint32_t *name);
169 int (*check_aperture_space)(dri_bo **bo_array, int count);
170 int debug; /**< Enables verbose debugging printouts */
173 #endif /* INTEL_BUFMGR_PRIV_H */