1 | /*
|
---|
2 | *
|
---|
3 | * Copyright (C) 2000 Keith Packard
|
---|
4 | * 2004 Eric Anholt
|
---|
5 | * 2005 Zack Rusin
|
---|
6 | *
|
---|
7 | * Permission to use, copy, modify, distribute, and sell this software and its
|
---|
8 | * documentation for any purpose is hereby granted without fee, provided that
|
---|
9 | * the above copyright notice appear in all copies and that both that
|
---|
10 | * copyright notice and this permission notice appear in supporting
|
---|
11 | * documentation, and that the name of copyright holders not be used in
|
---|
12 | * advertising or publicity pertaining to distribution of the software without
|
---|
13 | * specific, written prior permission. Copyright holders make no
|
---|
14 | * representations about the suitability of this software for any purpose. It
|
---|
15 | * is provided "as is" without express or implied warranty.
|
---|
16 | *
|
---|
17 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
---|
18 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
---|
19 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
---|
20 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
---|
21 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
---|
22 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
---|
23 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
24 | * SOFTWARE.
|
---|
25 | */
|
---|
26 |
|
---|
27 | /** @file
|
---|
28 | * This is the header containing the public API of EXA for exa drivers.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef EXA_H
|
---|
32 | #define EXA_H
|
---|
33 |
|
---|
34 | #include "scrnintstr.h"
|
---|
35 | #include "pixmapstr.h"
|
---|
36 | #include "windowstr.h"
|
---|
37 | #include "gcstruct.h"
|
---|
38 | #include "picturestr.h"
|
---|
39 | #include "fb.h"
|
---|
40 |
|
---|
41 | #define EXA_VERSION_MAJOR 2
|
---|
42 | #define EXA_VERSION_MINOR 4
|
---|
43 | #define EXA_VERSION_RELEASE 0
|
---|
44 |
|
---|
45 | typedef struct _ExaOffscreenArea ExaOffscreenArea;
|
---|
46 |
|
---|
47 | typedef void (*ExaOffscreenSaveProc) (ScreenPtr pScreen, ExaOffscreenArea *area);
|
---|
48 |
|
---|
49 | typedef enum _ExaOffscreenState {
|
---|
50 | ExaOffscreenAvail,
|
---|
51 | ExaOffscreenRemovable,
|
---|
52 | ExaOffscreenLocked
|
---|
53 | } ExaOffscreenState;
|
---|
54 |
|
---|
55 | struct _ExaOffscreenArea {
|
---|
56 | int base_offset; /* allocation base */
|
---|
57 | int offset; /* aligned offset */
|
---|
58 | int size; /* total allocation size */
|
---|
59 | unsigned last_use;
|
---|
60 | pointer privData;
|
---|
61 |
|
---|
62 | ExaOffscreenSaveProc save;
|
---|
63 |
|
---|
64 | ExaOffscreenState state;
|
---|
65 |
|
---|
66 | ExaOffscreenArea *next;
|
---|
67 |
|
---|
68 | unsigned eviction_cost;
|
---|
69 | };
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * The ExaDriver structure is allocated through exaDriverAlloc(), and then
|
---|
73 | * fllled in by drivers.
|
---|
74 | */
|
---|
75 | typedef struct _ExaDriver {
|
---|
76 | /**
|
---|
77 | * exa_major and exa_minor should be set by the driver to the version of
|
---|
78 | * EXA which the driver was compiled for (or configures itself at runtime
|
---|
79 | * to support). This allows EXA to extend the structure for new features
|
---|
80 | * without breaking ABI for drivers compiled against older versions.
|
---|
81 | */
|
---|
82 | int exa_major, exa_minor;
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * memoryBase is the address of the beginning of framebuffer memory.
|
---|
86 | * The visible screen should be within memoryBase to memoryBase +
|
---|
87 | * memorySize.
|
---|
88 | */
|
---|
89 | CARD8 *memoryBase;
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * offScreenBase is the offset from memoryBase of the beginning of the area
|
---|
93 | * to be managed by EXA's linear offscreen memory manager.
|
---|
94 | *
|
---|
95 | * In XFree86 DDX drivers, this is probably:
|
---|
96 | * (pScrn->displayWidth * cpp * pScrn->virtualY)
|
---|
97 | */
|
---|
98 | unsigned long offScreenBase;
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * memorySize is the length (in bytes) of framebuffer memory beginning
|
---|
102 | * from memoryBase.
|
---|
103 | *
|
---|
104 | * The offscreen memory manager will manage the area beginning at
|
---|
105 | * (memoryBase + offScreenBase), with a length of (memorySize -
|
---|
106 | * offScreenBase)
|
---|
107 | *
|
---|
108 | * In XFree86 DDX drivers, this is probably (pScrn->videoRam * 1024)
|
---|
109 | */
|
---|
110 | unsigned long memorySize;
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * pixmapOffsetAlign is the byte alignment necessary for pixmap offsets
|
---|
114 | * within framebuffer.
|
---|
115 | *
|
---|
116 | * Hardware typically has a required alignment of offsets, which may or may
|
---|
117 | * not be a power of two. EXA will ensure that pixmaps managed by the
|
---|
118 | * offscreen memory manager meet this alignment requirement.
|
---|
119 | */
|
---|
120 | int pixmapOffsetAlign;
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * pixmapPitchAlign is the byte alignment necessary for pixmap pitches
|
---|
124 | * within the framebuffer.
|
---|
125 | *
|
---|
126 | * Hardware typically has a required alignment of pitches for acceleration.
|
---|
127 | * For 3D hardware, Composite acceleration often requires that source and
|
---|
128 | * mask pixmaps (textures) have a power-of-two pitch, which can be demanded
|
---|
129 | * using EXA_OFFSCREEN_ALIGN_POT. These pitch requirements only apply to
|
---|
130 | * pixmaps managed by the offscreen memory manager. Thus, it is up to the
|
---|
131 | * driver to ensure that the visible screen has an appropriate pitch for
|
---|
132 | * acceleration.
|
---|
133 | */
|
---|
134 | int pixmapPitchAlign;
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * The flags field is bitfield of boolean values controlling EXA's behavior.
|
---|
138 | *
|
---|
139 | * The flags in clude EXA_OFFSCREEN_PIXMAPS, EXA_OFFSCREEN_ALIGN_POT, and
|
---|
140 | * EXA_TWO_BITBLT_DIRECTIONS.
|
---|
141 | */
|
---|
142 | int flags;
|
---|
143 |
|
---|
144 | /** @{ */
|
---|
145 | /**
|
---|
146 | * maxX controls the X coordinate limitation for rendering from the card.
|
---|
147 | * The driver should never receive a request for rendering beyond maxX
|
---|
148 | * in the X direction from the origin of a pixmap.
|
---|
149 | */
|
---|
150 | int maxX;
|
---|
151 |
|
---|
152 | /**
|
---|
153 | * maxY controls the Y coordinate limitation for rendering from the card.
|
---|
154 | * The driver should never receive a request for rendering beyond maxY
|
---|
155 | * in the Y direction from the origin of a pixmap.
|
---|
156 | */
|
---|
157 | int maxY;
|
---|
158 | /** @} */
|
---|
159 |
|
---|
160 | /* private */
|
---|
161 | ExaOffscreenArea *offScreenAreas;
|
---|
162 | Bool needsSync;
|
---|
163 | int lastMarker;
|
---|
164 |
|
---|
165 | /** @name Solid
|
---|
166 | * @{
|
---|
167 | */
|
---|
168 | /**
|
---|
169 | * PrepareSolid() sets up the driver for doing a solid fill.
|
---|
170 | * @param pPixmap Destination pixmap
|
---|
171 | * @param alu raster operation
|
---|
172 | * @param planemask write mask for the fill
|
---|
173 | * @param fg "foreground" color for the fill
|
---|
174 | *
|
---|
175 | * This call should set up the driver for doing a series of solid fills
|
---|
176 | * through the Solid() call. The alu raster op is one of the GX*
|
---|
177 | * graphics functions listed in X.h, and typically maps to a similar
|
---|
178 | * single-byte "ROP" setting in all hardware. The planemask controls
|
---|
179 | * which bits of the destination should be affected, and will only represent
|
---|
180 | * the bits up to the depth of pPixmap. The fg is the pixel value of the
|
---|
181 | * foreground color referred to in ROP descriptions.
|
---|
182 | *
|
---|
183 | * Note that many drivers will need to store some of the data in the driver
|
---|
184 | * private record, for sending to the hardware with each drawing command.
|
---|
185 | *
|
---|
186 | * The PrepareSolid() call is required of all drivers, but it may fail for any
|
---|
187 | * reason. Failure results in a fallback to software rendering.
|
---|
188 | */
|
---|
189 | Bool (*PrepareSolid) (PixmapPtr pPixmap,
|
---|
190 | int alu,
|
---|
191 | Pixel planemask,
|
---|
192 | Pixel fg);
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * Solid() performs a solid fill set up in the last PrepareSolid() call.
|
---|
196 | *
|
---|
197 | * @param pPixmap destination pixmap
|
---|
198 | * @param x1 left coordinate
|
---|
199 | * @param y1 top coordinate
|
---|
200 | * @param x2 right coordinate
|
---|
201 | * @param y2 bottom coordinate
|
---|
202 | *
|
---|
203 | * Performs the fill set up by the last PrepareSolid() call, covering the
|
---|
204 | * area from (x1,y1) to (x2,y2) in pPixmap. Note that the coordinates are
|
---|
205 | * in the coordinate space of the destination pixmap, so the driver will
|
---|
206 | * need to set up the hardware's offset and pitch for the destination
|
---|
207 | * coordinates according to the pixmap's offset and pitch within
|
---|
208 | * framebuffer. This likely means using exaGetPixmapOffset() and
|
---|
209 | * exaGetPixmapPitch().
|
---|
210 | *
|
---|
211 | * This call is required if PrepareSolid() ever succeeds.
|
---|
212 | */
|
---|
213 | void (*Solid) (PixmapPtr pPixmap, int x1, int y1, int x2, int y2);
|
---|
214 |
|
---|
215 | /**
|
---|
216 | * DoneSolid() finishes a set of solid fills.
|
---|
217 | *
|
---|
218 | * @param pPixmap destination pixmap.
|
---|
219 | *
|
---|
220 | * The DoneSolid() call is called at the end of a series of consecutive
|
---|
221 | * Solid() calls following a successful PrepareSolid(). This allows drivers
|
---|
222 | * to finish up emitting drawing commands that were buffered, or clean up
|
---|
223 | * state from PrepareSolid().
|
---|
224 | *
|
---|
225 | * This call is required if PrepareSolid() ever succeeds.
|
---|
226 | */
|
---|
227 | void (*DoneSolid) (PixmapPtr pPixmap);
|
---|
228 | /** @} */
|
---|
229 |
|
---|
230 | /** @name Copy
|
---|
231 | * @{
|
---|
232 | */
|
---|
233 | /**
|
---|
234 | * PrepareCopy() sets up the driver for doing a copy within video
|
---|
235 | * memory.
|
---|
236 | *
|
---|
237 | * @param pSrcPixmap source pixmap
|
---|
238 | * @param pDstPixmap destination pixmap
|
---|
239 | * @param dx X copy direction
|
---|
240 | * @param dy Y copy direction
|
---|
241 | * @param alu raster operation
|
---|
242 | * @param planemask write mask for the fill
|
---|
243 | *
|
---|
244 | * This call should set up the driver for doing a series of copies from the
|
---|
245 | * the pSrcPixmap to the pDstPixmap. The dx flag will be positive if the
|
---|
246 | * hardware should do the copy from the left to the right, and dy will be
|
---|
247 | * positive if the copy should be done from the top to the bottom. This
|
---|
248 | * is to deal with self-overlapping copies when pSrcPixmap == pDstPixmap.
|
---|
249 | * If your hardware can only support blits that are (left to right, top to
|
---|
250 | * bottom) or (right to left, bottom to top), then you should set
|
---|
251 | * #EXA_TWO_BITBLT_DIRECTIONS, and EXA will break down Copy operations to
|
---|
252 | * ones that meet those requirements. The alu raster op is one of the GX*
|
---|
253 | * graphics functions listed in X.h, and typically maps to a similar
|
---|
254 | * single-byte "ROP" setting in all hardware. The planemask controls which
|
---|
255 | * bits of the destination should be affected, and will only represent the
|
---|
256 | * bits up to the depth of pPixmap.
|
---|
257 | *
|
---|
258 | * Note that many drivers will need to store some of the data in the driver
|
---|
259 | * private record, for sending to the hardware with each drawing command.
|
---|
260 | *
|
---|
261 | * The PrepareCopy() call is required of all drivers, but it may fail for any
|
---|
262 | * reason. Failure results in a fallback to software rendering.
|
---|
263 | */
|
---|
264 | Bool (*PrepareCopy) (PixmapPtr pSrcPixmap,
|
---|
265 | PixmapPtr pDstPixmap,
|
---|
266 | int dx,
|
---|
267 | int dy,
|
---|
268 | int alu,
|
---|
269 | Pixel planemask);
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * Copy() performs a copy set up in the last PrepareCopy call.
|
---|
273 | *
|
---|
274 | * @param pDstPixmap destination pixmap
|
---|
275 | * @param srcX source X coordinate
|
---|
276 | * @param srcY source Y coordinate
|
---|
277 | * @param dstX destination X coordinate
|
---|
278 | * @param dstY destination Y coordinate
|
---|
279 | * @param width width of the rectangle to be copied
|
---|
280 | * @param height height of the rectangle to be copied.
|
---|
281 | *
|
---|
282 | * Performs the copy set up by the last PrepareCopy() call, copying the
|
---|
283 | * rectangle from (srcX, srcY) to (srcX + width, srcY + width) in the source
|
---|
284 | * pixmap to the same-sized rectangle at (dstX, dstY) in the destination
|
---|
285 | * pixmap. Those rectangles may overlap in memory, if
|
---|
286 | * pSrcPixmap == pDstPixmap. Note that this call does not receive the
|
---|
287 | * pSrcPixmap as an argument -- if it's needed in this function, it should
|
---|
288 | * be stored in the driver private during PrepareCopy(). As with Solid(),
|
---|
289 | * the coordinates are in the coordinate space of each pixmap, so the driver
|
---|
290 | * will need to set up source and destination pitches and offsets from those
|
---|
291 | * pixmaps, probably using exaGetPixmapOffset() and exaGetPixmapPitch().
|
---|
292 | *
|
---|
293 | * This call is required if PrepareCopy ever succeeds.
|
---|
294 | */
|
---|
295 | void (*Copy) (PixmapPtr pDstPixmap,
|
---|
296 | int srcX,
|
---|
297 | int srcY,
|
---|
298 | int dstX,
|
---|
299 | int dstY,
|
---|
300 | int width,
|
---|
301 | int height);
|
---|
302 |
|
---|
303 | /**
|
---|
304 | * DoneCopy() finishes a set of copies.
|
---|
305 | *
|
---|
306 | * @param pPixmap destination pixmap.
|
---|
307 | *
|
---|
308 | * The DoneCopy() call is called at the end of a series of consecutive
|
---|
309 | * Copy() calls following a successful PrepareCopy(). This allows drivers
|
---|
310 | * to finish up emitting drawing commands that were buffered, or clean up
|
---|
311 | * state from PrepareCopy().
|
---|
312 | *
|
---|
313 | * This call is required if PrepareCopy() ever succeeds.
|
---|
314 | */
|
---|
315 | void (*DoneCopy) (PixmapPtr pDstPixmap);
|
---|
316 | /** @} */
|
---|
317 |
|
---|
318 | /** @name Composite
|
---|
319 | * @{
|
---|
320 | */
|
---|
321 | /**
|
---|
322 | * CheckComposite() checks to see if a composite operation could be
|
---|
323 | * accelerated.
|
---|
324 | *
|
---|
325 | * @param op Render operation
|
---|
326 | * @param pSrcPicture source Picture
|
---|
327 | * @param pMaskPicture mask picture
|
---|
328 | * @param pDstPicture destination Picture
|
---|
329 | *
|
---|
330 | * The CheckComposite() call checks if the driver could handle acceleration
|
---|
331 | * of op with the given source, mask, and destination pictures. This allows
|
---|
332 | * drivers to check source and destination formats, supported operations,
|
---|
333 | * transformations, and component alpha state, and send operations it can't
|
---|
334 | * support to software rendering early on. This avoids costly pixmap
|
---|
335 | * migration to the wrong places when the driver can't accelerate
|
---|
336 | * operations. Note that because migration hasn't happened, the driver
|
---|
337 | * can't know during CheckComposite() what the offsets and pitches of the
|
---|
338 | * pixmaps are going to be.
|
---|
339 | *
|
---|
340 | * See PrepareComposite() for more details on likely issues that drivers
|
---|
341 | * will have in accelerating Composite operations.
|
---|
342 | *
|
---|
343 | * The CheckComposite() call is recommended if PrepareComposite() is
|
---|
344 | * implemented, but is not required.
|
---|
345 | */
|
---|
346 | Bool (*CheckComposite) (int op,
|
---|
347 | PicturePtr pSrcPicture,
|
---|
348 | PicturePtr pMaskPicture,
|
---|
349 | PicturePtr pDstPicture);
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * PrepareComposite() sets up the driver for doing a Composite operation
|
---|
353 | * described in the Render extension protocol spec.
|
---|
354 | *
|
---|
355 | * @param op Render operation
|
---|
356 | * @param pSrcPicture source Picture
|
---|
357 | * @param pMaskPicture mask picture
|
---|
358 | * @param pDstPicture destination Picture
|
---|
359 | * @param pSrc source pixmap
|
---|
360 | * @param pMask mask pixmap
|
---|
361 | * @param pDst destination pixmap
|
---|
362 | *
|
---|
363 | * This call should set up the driver for doing a series of Composite
|
---|
364 | * operations, as described in the Render protocol spec, with the given
|
---|
365 | * pSrcPicture, pMaskPicture, and pDstPicture. The pSrc, pMask, and
|
---|
366 | * pDst are the pixmaps containing the pixel data, and should be used for
|
---|
367 | * setting the offset and pitch used for the coordinate spaces for each of
|
---|
368 | * the Pictures.
|
---|
369 | *
|
---|
370 | * Notes on interpreting Picture structures:
|
---|
371 | * - The Picture structures will always have a valid pDrawable.
|
---|
372 | * - The Picture structures will never have alphaMap set.
|
---|
373 | * - The mask Picture (and therefore pMask) may be NULL, in which case the
|
---|
374 | * operation is simply src OP dst instead of src IN mask OP dst, and
|
---|
375 | * mask coordinates should be ignored.
|
---|
376 | * - pMarkPicture may have componentAlpha set, which greatly changes
|
---|
377 | * the behavior of the Composite operation. componentAlpha has no effect
|
---|
378 | * when set on pSrcPicture or pDstPicture.
|
---|
379 | * - The source and mask Pictures may have a transformation set
|
---|
380 | * (Picture->transform != NULL), which means that the source coordinates
|
---|
381 | * should be transformed by that transformation, resulting in scaling,
|
---|
382 | * rotation, etc. The PictureTransformPoint() call can transform
|
---|
383 | * coordinates for you. Transforms have no effect on Pictures when used
|
---|
384 | * as a destination.
|
---|
385 | * - The source and mask pictures may have a filter set. PictFilterNearest
|
---|
386 | * and PictFilterBilinear are defined in the Render protocol, but others
|
---|
387 | * may be encountered, and must be handled correctly (usually by
|
---|
388 | * PrepareComposite failing, and falling back to software). Filters have
|
---|
389 | * no effect on Pictures when used as a destination.
|
---|
390 | * - The source and mask Pictures may have repeating set, which must be
|
---|
391 | * respected. Many chipsets will be unable to support repeating on
|
---|
392 | * pixmaps that have a width or height that is not a power of two.
|
---|
393 | *
|
---|
394 | * If your hardware can't support source pictures (textures) with
|
---|
395 | * non-power-of-two pitches, you should set #EXA_OFFSCREEN_ALIGN_POT.
|
---|
396 | *
|
---|
397 | * Note that many drivers will need to store some of the data in the driver
|
---|
398 | * private record, for sending to the hardware with each drawing command.
|
---|
399 | *
|
---|
400 | * The PrepareComposite() call is not required. However, it is highly
|
---|
401 | * recommended for performance of antialiased font rendering and performance
|
---|
402 | * of cairo applications. Failure results in a fallback to software
|
---|
403 | * rendering.
|
---|
404 | */
|
---|
405 | Bool (*PrepareComposite) (int op,
|
---|
406 | PicturePtr pSrcPicture,
|
---|
407 | PicturePtr pMaskPicture,
|
---|
408 | PicturePtr pDstPicture,
|
---|
409 | PixmapPtr pSrc,
|
---|
410 | PixmapPtr pMask,
|
---|
411 | PixmapPtr pDst);
|
---|
412 |
|
---|
413 | /**
|
---|
414 | * Composite() performs a Composite operation set up in the last
|
---|
415 | * PrepareComposite() call.
|
---|
416 | *
|
---|
417 | * @param pDstPixmap destination pixmap
|
---|
418 | * @param srcX source X coordinate
|
---|
419 | * @param srcY source Y coordinate
|
---|
420 | * @param maskX source X coordinate
|
---|
421 | * @param maskY source Y coordinate
|
---|
422 | * @param dstX destination X coordinate
|
---|
423 | * @param dstY destination Y coordinate
|
---|
424 | * @param width destination rectangle width
|
---|
425 | * @param height destination rectangle height
|
---|
426 | *
|
---|
427 | * Performs the Composite operation set up by the last PrepareComposite()
|
---|
428 | * call, to the rectangle from (dstX, dstY) to (dstX + width, dstY + height)
|
---|
429 | * in the destination Pixmap. Note that if a transformation was set on
|
---|
430 | * the source or mask Pictures, the source rectangles may not be the same
|
---|
431 | * size as the destination rectangles and filtering. Getting the coordinate
|
---|
432 | * transformation right at the subpixel level can be tricky, and rendercheck
|
---|
433 | * can test this for you.
|
---|
434 | *
|
---|
435 | * This call is required if PrepareComposite() ever succeeds.
|
---|
436 | */
|
---|
437 | void (*Composite) (PixmapPtr pDst,
|
---|
438 | int srcX,
|
---|
439 | int srcY,
|
---|
440 | int maskX,
|
---|
441 | int maskY,
|
---|
442 | int dstX,
|
---|
443 | int dstY,
|
---|
444 | int width,
|
---|
445 | int height);
|
---|
446 |
|
---|
447 | /**
|
---|
448 | * DoneComposite() finishes a set of Composite operations.
|
---|
449 | *
|
---|
450 | * @param pPixmap destination pixmap.
|
---|
451 | *
|
---|
452 | * The DoneComposite() call is called at the end of a series of consecutive
|
---|
453 | * Composite() calls following a successful PrepareComposite(). This allows
|
---|
454 | * drivers to finish up emitting drawing commands that were buffered, or
|
---|
455 | * clean up state from PrepareComposite().
|
---|
456 | *
|
---|
457 | * This call is required if PrepareComposite() ever succeeds.
|
---|
458 | */
|
---|
459 | void (*DoneComposite) (PixmapPtr pDst);
|
---|
460 | /** @} */
|
---|
461 |
|
---|
462 | /**
|
---|
463 | * UploadToScreen() loads a rectangle of data from src into pDst.
|
---|
464 | *
|
---|
465 | * @param pDst destination pixmap
|
---|
466 | * @param x destination X coordinate.
|
---|
467 | * @param y destination Y coordinate
|
---|
468 | * @param width width of the rectangle to be copied
|
---|
469 | * @param height height of the rectangle to be copied
|
---|
470 | * @param src pointer to the beginning of the source data
|
---|
471 | * @param src_pitch pitch (in bytes) of the lines of source data.
|
---|
472 | *
|
---|
473 | * UploadToScreen() copies data in system memory beginning at src (with
|
---|
474 | * pitch src_pitch) into the destination pixmap from (x, y) to
|
---|
475 | * (x + width, y + height). This is typically done with hostdata uploads,
|
---|
476 | * where the CPU sets up a blit command on the hardware with instructions
|
---|
477 | * that the blit data will be fed through some sort of aperture on the card.
|
---|
478 | *
|
---|
479 | * If UploadToScreen() is performed asynchronously, it is up to the driver
|
---|
480 | * to call exaMarkSync(). This is in contrast to most other acceleration
|
---|
481 | * calls in EXA.
|
---|
482 | *
|
---|
483 | * UploadToScreen() can aid in pixmap migration, but is most important for
|
---|
484 | * the performance of exaGlyphs() (antialiased font drawing) by allowing
|
---|
485 | * pipelining of data uploads, avoiding a sync of the card after each glyph.
|
---|
486 | *
|
---|
487 | * @return TRUE if the driver successfully uploaded the data. FALSE
|
---|
488 | * indicates that EXA should fall back to doing the upload in software.
|
---|
489 | *
|
---|
490 | * UploadToScreen() is not required, but is recommended if Composite
|
---|
491 | * acceleration is supported.
|
---|
492 | */
|
---|
493 | Bool (*UploadToScreen) (PixmapPtr pDst,
|
---|
494 | int x,
|
---|
495 | int y,
|
---|
496 | int w,
|
---|
497 | int h,
|
---|
498 | char *src,
|
---|
499 | int src_pitch);
|
---|
500 |
|
---|
501 | /**
|
---|
502 | * UploadToScratch() is used to upload a pixmap to a scratch area for
|
---|
503 | * acceleration.
|
---|
504 | *
|
---|
505 | * @param pSrc source pixmap in host memory
|
---|
506 | * @param pDst fake, scratch pixmap to be set up in offscreen memory.
|
---|
507 | *
|
---|
508 | * The UploadToScratch() call was added to support Xati before Xati had
|
---|
509 | * support for hostdata uploads and before exaGlyphs() was written. It
|
---|
510 | * behaves incorrectly (uses an invalid pixmap as pDst),
|
---|
511 | * and UploadToScreen() should be implemented instead.
|
---|
512 | *
|
---|
513 | * Drivers implementing UploadToScratch() had to set up space (likely in a
|
---|
514 | * statically allocated area) in offscreen memory, copy pSrc to that
|
---|
515 | * scratch area, and adust pDst->devKind for the pitch and
|
---|
516 | * pDst->devPrivate.ptr for the pointer to that scratch area. The driver
|
---|
517 | * was responsible for syncing (as it was implemented using memcpy() in
|
---|
518 | * Xati), and only the data from the last UploadToScratch() was guaranteed
|
---|
519 | * to be valid at any given time.
|
---|
520 | *
|
---|
521 | * UploadToScratch() should not be implemented by drivers, and will likely
|
---|
522 | * be removed in a future version of EXA.
|
---|
523 | */
|
---|
524 | Bool (*UploadToScratch) (PixmapPtr pSrc,
|
---|
525 | PixmapPtr pDst);
|
---|
526 |
|
---|
527 | /**
|
---|
528 | * DownloadFromScreen() loads a rectangle of data from pSrc into dst
|
---|
529 | *
|
---|
530 | * @param pSrc source pixmap
|
---|
531 | * @param x source X coordinate.
|
---|
532 | * @param y source Y coordinate
|
---|
533 | * @param width width of the rectangle to be copied
|
---|
534 | * @param height height of the rectangle to be copied
|
---|
535 | * @param dst pointer to the beginning of the destination data
|
---|
536 | * @param dst_pitch pitch (in bytes) of the lines of destination data.
|
---|
537 | *
|
---|
538 | * DownloadFromScreen() copies data from offscreen memory in pSrc from
|
---|
539 | * (x, y) to (x + width, y + height), to system memory starting at
|
---|
540 | * dst (with pitch dst_pitch). This would usually be done
|
---|
541 | * using scatter-gather DMA, supported by a DRM call, or by blitting to AGP
|
---|
542 | * and then synchronously reading from AGP. Because the implementation
|
---|
543 | * might be synchronous, EXA leaves it up to the driver to call
|
---|
544 | * exaMarkSync() if DownloadFromScreen() was asynchronous. This is in
|
---|
545 | * contrast to most other acceleration calls in EXA.
|
---|
546 | *
|
---|
547 | * DownloadFromScreen() can aid in the largest bottleneck in pixmap
|
---|
548 | * migration, which is the read from framebuffer when evicting pixmaps from
|
---|
549 | * framebuffer memory. Thus, it is highly recommended, even though
|
---|
550 | * implementations are typically complicated.
|
---|
551 | *
|
---|
552 | * @return TRUE if the driver successfully downloaded the data. FALSE
|
---|
553 | * indicates that EXA should fall back to doing the download in software.
|
---|
554 | *
|
---|
555 | * DownloadFromScreen() is not required, but is highly recommended.
|
---|
556 | */
|
---|
557 | Bool (*DownloadFromScreen)(PixmapPtr pSrc,
|
---|
558 | int x, int y,
|
---|
559 | int w, int h,
|
---|
560 | char *dst, int dst_pitch);
|
---|
561 |
|
---|
562 | /**
|
---|
563 | * MarkSync() requests that the driver mark a synchronization point,
|
---|
564 | * returning an driver-defined integer marker which could be requested for
|
---|
565 | * synchronization to later in WaitMarker(). This might be used in the
|
---|
566 | * future to avoid waiting for full hardware stalls before accessing pixmap
|
---|
567 | * data with the CPU, but is not important in the current incarnation of
|
---|
568 | * EXA.
|
---|
569 | *
|
---|
570 | * Note that drivers should call exaMarkSync() when they have done some
|
---|
571 | * acceleration, rather than their own MarkSync() handler, as otherwise EXA
|
---|
572 | * will be unaware of the driver's acceleration and not sync to it during
|
---|
573 | * fallbacks.
|
---|
574 | *
|
---|
575 | * MarkSync() is optional.
|
---|
576 | */
|
---|
577 | int (*MarkSync) (ScreenPtr pScreen);
|
---|
578 |
|
---|
579 | /**
|
---|
580 | * WaitMarker() waits for all rendering before the given marker to have
|
---|
581 | * completed. If the driver does not implement MarkSync(), marker is
|
---|
582 | * meaningless, and all rendering by the hardware should be completed before
|
---|
583 | * WaitMarker() returns.
|
---|
584 | *
|
---|
585 | * Note that drivers should call exaWaitSync() to wait for all acceleration
|
---|
586 | * to finish, as otherwise EXA will be unaware of the driver having
|
---|
587 | * synchronized, resulting in excessive WaitMarker() calls.
|
---|
588 | *
|
---|
589 | * WaitMarker() is required of all drivers.
|
---|
590 | */
|
---|
591 | void (*WaitMarker) (ScreenPtr pScreen, int marker);
|
---|
592 |
|
---|
593 | /** @{ */
|
---|
594 | /**
|
---|
595 | * PrepareAccess() is called before CPU access to an offscreen pixmap.
|
---|
596 | *
|
---|
597 | * @param pPix the pixmap being accessed
|
---|
598 | * @param index the index of the pixmap being accessed.
|
---|
599 | *
|
---|
600 | * PrepareAccess() will be called before CPU access to an offscreen pixmap.
|
---|
601 | * This can be used to set up hardware surfaces for byteswapping or
|
---|
602 | * untiling, or to adjust the pixmap's devPrivate.ptr for the purpose of
|
---|
603 | * making CPU access use a different aperture.
|
---|
604 | *
|
---|
605 | * The index is one of #EXA_PREPARE_DEST, #EXA_PREPARE_SRC, or
|
---|
606 | * #EXA_PREPARE_MASK, indicating which pixmap is in question. Since only up
|
---|
607 | * to three pixmaps will have PrepareAccess() called on them per operation,
|
---|
608 | * drivers can have a small, statically-allocated space to maintain state
|
---|
609 | * for PrepareAccess() and FinishAccess() in. Note that the same pixmap may
|
---|
610 | * have PrepareAccess() called on it more than once, for example when doing
|
---|
611 | * a copy within the same pixmap (so it gets PrepareAccess as()
|
---|
612 | * #EXA_PREPARE_DEST and then as #EXA_PREPARE_SRC).
|
---|
613 | *
|
---|
614 | * PrepareAccess() may fail. An example might be the case of hardware that
|
---|
615 | * can set up 1 or 2 surfaces for CPU access, but not 3. If PrepareAccess()
|
---|
616 | * fails, EXA will migrate the pixmap to system memory.
|
---|
617 | * DownloadFromScreen() must be implemented and must not fail if a driver
|
---|
618 | * wishes to fail in PrepareAccess(). PrepareAccess() must not fail when
|
---|
619 | * pPix is the visible screen, because the visible screen can not be
|
---|
620 | * migrated.
|
---|
621 | *
|
---|
622 | * @return TRUE if PrepareAccess() successfully prepared the pixmap for CPU
|
---|
623 | * drawing.
|
---|
624 | * @return FALSE if PrepareAccess() is unsuccessful and EXA should use
|
---|
625 | * DownloadFromScreen() to migate the pixmap out.
|
---|
626 | */
|
---|
627 | Bool (*PrepareAccess)(PixmapPtr pPix, int index);
|
---|
628 |
|
---|
629 | /**
|
---|
630 | * FinishAccess() is called after CPU access to an offscreen pixmap.
|
---|
631 | *
|
---|
632 | * @param pPix the pixmap being accessed
|
---|
633 | * @param index the index of the pixmap being accessed.
|
---|
634 | *
|
---|
635 | * FinishAccess() will be called after finishing CPU access of an offscreen
|
---|
636 | * pixmap set up by PrepareAccess(). Note that the FinishAccess() will not be
|
---|
637 | * called if PrepareAccess() failed and the pixmap was migrated out.
|
---|
638 | */
|
---|
639 | void (*FinishAccess)(PixmapPtr pPix, int index);
|
---|
640 |
|
---|
641 | /**
|
---|
642 | * PixmapIsOffscreen() is an optional driver replacement to
|
---|
643 | * exaPixmapIsOffscreen(). Set to NULL if you want the standard behaviour
|
---|
644 | * of exaPixmapIsOffscreen().
|
---|
645 | *
|
---|
646 | * @param pPix the pixmap
|
---|
647 | * @return TRUE if the given drawable is in framebuffer memory.
|
---|
648 | *
|
---|
649 | * exaPixmapIsOffscreen() is used to determine if a pixmap is in offscreen
|
---|
650 | * memory, meaning that acceleration could probably be done to it, and that it
|
---|
651 | * will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it
|
---|
652 | * with the CPU.
|
---|
653 | *
|
---|
654 | *
|
---|
655 | */
|
---|
656 | Bool (*PixmapIsOffscreen)(PixmapPtr pPix);
|
---|
657 |
|
---|
658 | /** @name PrepareAccess() and FinishAccess() indices
|
---|
659 | * @{
|
---|
660 | */
|
---|
661 | /**
|
---|
662 | * EXA_PREPARE_DEST is the index for a pixmap that may be drawn to or
|
---|
663 | * read from.
|
---|
664 | */
|
---|
665 | #define EXA_PREPARE_DEST 0
|
---|
666 | /**
|
---|
667 | * EXA_PREPARE_SRC is the index for a pixmap that may be read from
|
---|
668 | */
|
---|
669 | #define EXA_PREPARE_SRC 1
|
---|
670 | /**
|
---|
671 | * EXA_PREPARE_SRC is the index for a second pixmap that may be read
|
---|
672 | * from.
|
---|
673 | */
|
---|
674 | #define EXA_PREPARE_MASK 2
|
---|
675 | /** @} */
|
---|
676 |
|
---|
677 | /**
|
---|
678 | * maxPitchPixels controls the pitch limitation for rendering from
|
---|
679 | * the card.
|
---|
680 | * The driver should never receive a request for rendering a pixmap
|
---|
681 | * that has a pitch (in pixels) beyond maxPitchPixels.
|
---|
682 | *
|
---|
683 | * Setting this field is optional -- if your hardware doesn't have
|
---|
684 | * a pitch limitation in pixels, don't set this. If neither this value
|
---|
685 | * nor maxPitchBytes is set, then maxPitchPixels is set to maxX.
|
---|
686 | * If set, it must not be smaller than maxX.
|
---|
687 | *
|
---|
688 | * @sa maxPitchBytes
|
---|
689 | */
|
---|
690 | int maxPitchPixels;
|
---|
691 |
|
---|
692 | /**
|
---|
693 | * maxPitchBytes controls the pitch limitation for rendering from
|
---|
694 | * the card.
|
---|
695 | * The driver should never receive a request for rendering a pixmap
|
---|
696 | * that has a pitch (in bytes) beyond maxPitchBytes.
|
---|
697 | *
|
---|
698 | * Setting this field is optional -- if your hardware doesn't have
|
---|
699 | * a pitch limitation in bytes, don't set this.
|
---|
700 | * If set, it must not be smaller than maxX * 4.
|
---|
701 | * There's no default value for maxPitchBytes.
|
---|
702 | *
|
---|
703 | * @sa maxPitchPixels
|
---|
704 | */
|
---|
705 | int maxPitchBytes;
|
---|
706 |
|
---|
707 | /* Hooks to allow driver to its own pixmap memory management */
|
---|
708 | void *(*CreatePixmap)(ScreenPtr pScreen, int size, int align);
|
---|
709 | void (*DestroyPixmap)(ScreenPtr pScreen, void *driverPriv);
|
---|
710 | Bool (*ModifyPixmapHeader)(PixmapPtr pPixmap, int width, int height,
|
---|
711 | int depth, int bitsPerPixel, int devKind,
|
---|
712 | pointer pPixData);
|
---|
713 |
|
---|
714 | /** @} */
|
---|
715 | } ExaDriverRec, *ExaDriverPtr;
|
---|
716 |
|
---|
717 | /** @name EXA driver flags
|
---|
718 | * @{
|
---|
719 | */
|
---|
720 | /**
|
---|
721 | * EXA_OFFSCREEN_PIXMAPS indicates to EXA that the driver can support
|
---|
722 | * offscreen pixmaps.
|
---|
723 | */
|
---|
724 | #define EXA_OFFSCREEN_PIXMAPS (1 << 0)
|
---|
725 |
|
---|
726 | /**
|
---|
727 | * EXA_OFFSCREEN_ALIGN_POT indicates to EXA that the driver needs pixmaps
|
---|
728 | * to have a power-of-two pitch.
|
---|
729 | */
|
---|
730 | #define EXA_OFFSCREEN_ALIGN_POT (1 << 1)
|
---|
731 |
|
---|
732 | /**
|
---|
733 | * EXA_TWO_BITBLT_DIRECTIONS indicates to EXA that the driver can only
|
---|
734 | * support copies that are (left-to-right, top-to-bottom) or
|
---|
735 | * (right-to-left, bottom-to-top).
|
---|
736 | */
|
---|
737 | #define EXA_TWO_BITBLT_DIRECTIONS (1 << 2)
|
---|
738 |
|
---|
739 | /**
|
---|
740 | * EXA_HANDLES_PIXMAPS indicates to EXA that the driver can handle
|
---|
741 | * all pixmap addressing and migration.
|
---|
742 | */
|
---|
743 | #define EXA_HANDLES_PIXMAPS (1 << 3)
|
---|
744 |
|
---|
745 | /** @} */
|
---|
746 |
|
---|
747 | ExaDriverPtr
|
---|
748 | exaDriverAlloc(void);
|
---|
749 |
|
---|
750 | Bool
|
---|
751 | exaDriverInit(ScreenPtr pScreen,
|
---|
752 | ExaDriverPtr pScreenInfo);
|
---|
753 |
|
---|
754 | void
|
---|
755 | exaDriverFini(ScreenPtr pScreen);
|
---|
756 |
|
---|
757 | void
|
---|
758 | exaMarkSync(ScreenPtr pScreen);
|
---|
759 | void
|
---|
760 | exaWaitSync(ScreenPtr pScreen);
|
---|
761 |
|
---|
762 | ExaOffscreenArea *
|
---|
763 | exaOffscreenAlloc(ScreenPtr pScreen, int size, int align,
|
---|
764 | Bool locked,
|
---|
765 | ExaOffscreenSaveProc save,
|
---|
766 | pointer privData);
|
---|
767 |
|
---|
768 | ExaOffscreenArea *
|
---|
769 | exaOffscreenFree(ScreenPtr pScreen, ExaOffscreenArea *area);
|
---|
770 |
|
---|
771 | void
|
---|
772 | ExaOffscreenMarkUsed (PixmapPtr pPixmap);
|
---|
773 |
|
---|
774 | unsigned long
|
---|
775 | exaGetPixmapOffset(PixmapPtr pPix);
|
---|
776 |
|
---|
777 | unsigned long
|
---|
778 | exaGetPixmapPitch(PixmapPtr pPix);
|
---|
779 |
|
---|
780 | unsigned long
|
---|
781 | exaGetPixmapSize(PixmapPtr pPix);
|
---|
782 |
|
---|
783 | void
|
---|
784 | exaEnableDisableFBAccess (int index, Bool enable);
|
---|
785 |
|
---|
786 | Bool
|
---|
787 | exaDrawableIsOffscreen (DrawablePtr pDrawable);
|
---|
788 |
|
---|
789 | /* in exa_migration.c */
|
---|
790 | void
|
---|
791 | exaMoveInPixmap (PixmapPtr pPixmap);
|
---|
792 |
|
---|
793 | void
|
---|
794 | exaMoveOutPixmap (PixmapPtr pPixmap);
|
---|
795 |
|
---|
796 | void *
|
---|
797 | exaGetPixmapDriverPrivate(PixmapPtr p);
|
---|
798 |
|
---|
799 | CARD32
|
---|
800 | exaGetPixmapFirstPixel (PixmapPtr pPixmap);
|
---|
801 |
|
---|
802 | /**
|
---|
803 | * Returns TRUE if the given planemask covers all the significant bits in the
|
---|
804 | * pixel values for pDrawable.
|
---|
805 | */
|
---|
806 | #define EXA_PM_IS_SOLID(_pDrawable, _pm) \
|
---|
807 | (((_pm) & FbFullMask((_pDrawable)->depth)) == \
|
---|
808 | FbFullMask((_pDrawable)->depth))
|
---|
809 |
|
---|
810 | #endif /* EXA_H */
|
---|