1706f2543Smrg/* 2706f2543Smrg * 3706f2543Smrg * Copyright (C) 2000 Keith Packard 4706f2543Smrg * 2004 Eric Anholt 5706f2543Smrg * 2005 Zack Rusin 6706f2543Smrg * 7706f2543Smrg * Permission to use, copy, modify, distribute, and sell this software and its 8706f2543Smrg * documentation for any purpose is hereby granted without fee, provided that 9706f2543Smrg * the above copyright notice appear in all copies and that both that 10706f2543Smrg * copyright notice and this permission notice appear in supporting 11706f2543Smrg * documentation, and that the name of copyright holders not be used in 12706f2543Smrg * advertising or publicity pertaining to distribution of the software without 13706f2543Smrg * specific, written prior permission. Copyright holders make no 14706f2543Smrg * representations about the suitability of this software for any purpose. It 15706f2543Smrg * is provided "as is" without express or implied warranty. 16706f2543Smrg * 17706f2543Smrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 18706f2543Smrg * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 19706f2543Smrg * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 20706f2543Smrg * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 21706f2543Smrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 22706f2543Smrg * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 23706f2543Smrg * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 24706f2543Smrg * SOFTWARE. 25706f2543Smrg */ 26706f2543Smrg 27706f2543Smrg/** @file 28706f2543Smrg * This is the header containing the public API of EXA for exa drivers. 29706f2543Smrg */ 30706f2543Smrg 31706f2543Smrg#ifndef EXA_H 32706f2543Smrg#define EXA_H 33706f2543Smrg 34706f2543Smrg#include "scrnintstr.h" 35706f2543Smrg#include "pixmapstr.h" 36706f2543Smrg#include "windowstr.h" 37706f2543Smrg#include "gcstruct.h" 38706f2543Smrg#include "picturestr.h" 39706f2543Smrg#include "fb.h" 40706f2543Smrg 41706f2543Smrg#define EXA_VERSION_MAJOR 2 42706f2543Smrg#define EXA_VERSION_MINOR 5 43706f2543Smrg#define EXA_VERSION_RELEASE 0 44706f2543Smrg 45706f2543Smrgtypedef struct _ExaOffscreenArea ExaOffscreenArea; 46706f2543Smrg 47706f2543Smrgtypedef void (*ExaOffscreenSaveProc) (ScreenPtr pScreen, ExaOffscreenArea *area); 48706f2543Smrg 49706f2543Smrgtypedef enum _ExaOffscreenState { 50706f2543Smrg ExaOffscreenAvail, 51706f2543Smrg ExaOffscreenRemovable, 52706f2543Smrg ExaOffscreenLocked 53706f2543Smrg} ExaOffscreenState; 54706f2543Smrg 55706f2543Smrgstruct _ExaOffscreenArea { 56706f2543Smrg int base_offset; /* allocation base */ 57706f2543Smrg int offset; /* aligned offset */ 58706f2543Smrg int size; /* total allocation size */ 59706f2543Smrg unsigned last_use; 60706f2543Smrg pointer privData; 61706f2543Smrg 62706f2543Smrg ExaOffscreenSaveProc save; 63706f2543Smrg 64706f2543Smrg ExaOffscreenState state; 65706f2543Smrg 66706f2543Smrg ExaOffscreenArea *next; 67706f2543Smrg 68706f2543Smrg unsigned eviction_cost; 69706f2543Smrg 70706f2543Smrg ExaOffscreenArea *prev; /* Double-linked list for defragmentation */ 71706f2543Smrg int align; /* required alignment */ 72706f2543Smrg}; 73706f2543Smrg 74706f2543Smrg/** 75706f2543Smrg * The ExaDriver structure is allocated through exaDriverAlloc(), and then 76706f2543Smrg * fllled in by drivers. 77706f2543Smrg */ 78706f2543Smrgtypedef struct _ExaDriver { 79706f2543Smrg /** 80706f2543Smrg * exa_major and exa_minor should be set by the driver to the version of 81706f2543Smrg * EXA which the driver was compiled for (or configures itself at runtime 82706f2543Smrg * to support). This allows EXA to extend the structure for new features 83706f2543Smrg * without breaking ABI for drivers compiled against older versions. 84706f2543Smrg */ 85706f2543Smrg int exa_major, exa_minor; 86706f2543Smrg 87706f2543Smrg /** 88706f2543Smrg * memoryBase is the address of the beginning of framebuffer memory. 89706f2543Smrg * The visible screen should be within memoryBase to memoryBase + 90706f2543Smrg * memorySize. 91706f2543Smrg */ 92706f2543Smrg CARD8 *memoryBase; 93706f2543Smrg 94706f2543Smrg /** 95706f2543Smrg * offScreenBase is the offset from memoryBase of the beginning of the area 96706f2543Smrg * to be managed by EXA's linear offscreen memory manager. 97706f2543Smrg * 98706f2543Smrg * In XFree86 DDX drivers, this is probably: 99706f2543Smrg * (pScrn->displayWidth * cpp * pScrn->virtualY) 100706f2543Smrg */ 101706f2543Smrg unsigned long offScreenBase; 102706f2543Smrg 103706f2543Smrg /** 104706f2543Smrg * memorySize is the length (in bytes) of framebuffer memory beginning 105706f2543Smrg * from memoryBase. 106706f2543Smrg * 107706f2543Smrg * The offscreen memory manager will manage the area beginning at 108706f2543Smrg * (memoryBase + offScreenBase), with a length of (memorySize - 109706f2543Smrg * offScreenBase) 110706f2543Smrg * 111706f2543Smrg * In XFree86 DDX drivers, this is probably (pScrn->videoRam * 1024) 112706f2543Smrg */ 113706f2543Smrg unsigned long memorySize; 114706f2543Smrg 115706f2543Smrg /** 116706f2543Smrg * pixmapOffsetAlign is the byte alignment necessary for pixmap offsets 117706f2543Smrg * within framebuffer. 118706f2543Smrg * 119706f2543Smrg * Hardware typically has a required alignment of offsets, which may or may 120706f2543Smrg * not be a power of two. EXA will ensure that pixmaps managed by the 121706f2543Smrg * offscreen memory manager meet this alignment requirement. 122706f2543Smrg */ 123706f2543Smrg int pixmapOffsetAlign; 124706f2543Smrg 125706f2543Smrg /** 126706f2543Smrg * pixmapPitchAlign is the byte alignment necessary for pixmap pitches 127706f2543Smrg * within the framebuffer. 128706f2543Smrg * 129706f2543Smrg * Hardware typically has a required alignment of pitches for acceleration. 130706f2543Smrg * For 3D hardware, Composite acceleration often requires that source and 131706f2543Smrg * mask pixmaps (textures) have a power-of-two pitch, which can be demanded 132706f2543Smrg * using EXA_OFFSCREEN_ALIGN_POT. These pitch requirements only apply to 133706f2543Smrg * pixmaps managed by the offscreen memory manager. Thus, it is up to the 134706f2543Smrg * driver to ensure that the visible screen has an appropriate pitch for 135706f2543Smrg * acceleration. 136706f2543Smrg */ 137706f2543Smrg int pixmapPitchAlign; 138706f2543Smrg 139706f2543Smrg /** 140706f2543Smrg * The flags field is bitfield of boolean values controlling EXA's behavior. 141706f2543Smrg * 142706f2543Smrg * The flags in clude EXA_OFFSCREEN_PIXMAPS, EXA_OFFSCREEN_ALIGN_POT, and 143706f2543Smrg * EXA_TWO_BITBLT_DIRECTIONS. 144706f2543Smrg */ 145706f2543Smrg int flags; 146706f2543Smrg 147706f2543Smrg /** @{ */ 148706f2543Smrg /** 149706f2543Smrg * maxX controls the X coordinate limitation for rendering from the card. 150706f2543Smrg * The driver should never receive a request for rendering beyond maxX 151706f2543Smrg * in the X direction from the origin of a pixmap. 152706f2543Smrg */ 153706f2543Smrg int maxX; 154706f2543Smrg 155706f2543Smrg /** 156706f2543Smrg * maxY controls the Y coordinate limitation for rendering from the card. 157706f2543Smrg * The driver should never receive a request for rendering beyond maxY 158706f2543Smrg * in the Y direction from the origin of a pixmap. 159706f2543Smrg */ 160706f2543Smrg int maxY; 161706f2543Smrg /** @} */ 162706f2543Smrg 163706f2543Smrg /* private */ 164706f2543Smrg ExaOffscreenArea *offScreenAreas; 165706f2543Smrg Bool needsSync; 166706f2543Smrg int lastMarker; 167706f2543Smrg 168706f2543Smrg /** @name Solid 169706f2543Smrg * @{ 170706f2543Smrg */ 171706f2543Smrg /** 172706f2543Smrg * PrepareSolid() sets up the driver for doing a solid fill. 173706f2543Smrg * @param pPixmap Destination pixmap 174706f2543Smrg * @param alu raster operation 175706f2543Smrg * @param planemask write mask for the fill 176706f2543Smrg * @param fg "foreground" color for the fill 177706f2543Smrg * 178706f2543Smrg * This call should set up the driver for doing a series of solid fills 179706f2543Smrg * through the Solid() call. The alu raster op is one of the GX* 180706f2543Smrg * graphics functions listed in X.h, and typically maps to a similar 181706f2543Smrg * single-byte "ROP" setting in all hardware. The planemask controls 182706f2543Smrg * which bits of the destination should be affected, and will only represent 183706f2543Smrg * the bits up to the depth of pPixmap. The fg is the pixel value of the 184706f2543Smrg * foreground color referred to in ROP descriptions. 185706f2543Smrg * 186706f2543Smrg * Note that many drivers will need to store some of the data in the driver 187706f2543Smrg * private record, for sending to the hardware with each drawing command. 188706f2543Smrg * 189706f2543Smrg * The PrepareSolid() call is required of all drivers, but it may fail for any 190706f2543Smrg * reason. Failure results in a fallback to software rendering. 191706f2543Smrg */ 192706f2543Smrg Bool (*PrepareSolid) (PixmapPtr pPixmap, 193706f2543Smrg int alu, 194706f2543Smrg Pixel planemask, 195706f2543Smrg Pixel fg); 196706f2543Smrg 197706f2543Smrg /** 198706f2543Smrg * Solid() performs a solid fill set up in the last PrepareSolid() call. 199706f2543Smrg * 200706f2543Smrg * @param pPixmap destination pixmap 201706f2543Smrg * @param x1 left coordinate 202706f2543Smrg * @param y1 top coordinate 203706f2543Smrg * @param x2 right coordinate 204706f2543Smrg * @param y2 bottom coordinate 205706f2543Smrg * 206706f2543Smrg * Performs the fill set up by the last PrepareSolid() call, covering the 207706f2543Smrg * area from (x1,y1) to (x2,y2) in pPixmap. Note that the coordinates are 208706f2543Smrg * in the coordinate space of the destination pixmap, so the driver will 209706f2543Smrg * need to set up the hardware's offset and pitch for the destination 210706f2543Smrg * coordinates according to the pixmap's offset and pitch within 211706f2543Smrg * framebuffer. This likely means using exaGetPixmapOffset() and 212706f2543Smrg * exaGetPixmapPitch(). 213706f2543Smrg * 214706f2543Smrg * This call is required if PrepareSolid() ever succeeds. 215706f2543Smrg */ 216706f2543Smrg void (*Solid) (PixmapPtr pPixmap, int x1, int y1, int x2, int y2); 217706f2543Smrg 218706f2543Smrg /** 219706f2543Smrg * DoneSolid() finishes a set of solid fills. 220706f2543Smrg * 221706f2543Smrg * @param pPixmap destination pixmap. 222706f2543Smrg * 223706f2543Smrg * The DoneSolid() call is called at the end of a series of consecutive 224706f2543Smrg * Solid() calls following a successful PrepareSolid(). This allows drivers 225706f2543Smrg * to finish up emitting drawing commands that were buffered, or clean up 226706f2543Smrg * state from PrepareSolid(). 227706f2543Smrg * 228706f2543Smrg * This call is required if PrepareSolid() ever succeeds. 229706f2543Smrg */ 230706f2543Smrg void (*DoneSolid) (PixmapPtr pPixmap); 231706f2543Smrg /** @} */ 232706f2543Smrg 233706f2543Smrg /** @name Copy 234706f2543Smrg * @{ 235706f2543Smrg */ 236706f2543Smrg /** 237706f2543Smrg * PrepareCopy() sets up the driver for doing a copy within video 238706f2543Smrg * memory. 239706f2543Smrg * 240706f2543Smrg * @param pSrcPixmap source pixmap 241706f2543Smrg * @param pDstPixmap destination pixmap 242706f2543Smrg * @param dx X copy direction 243706f2543Smrg * @param dy Y copy direction 244706f2543Smrg * @param alu raster operation 245706f2543Smrg * @param planemask write mask for the fill 246706f2543Smrg * 247706f2543Smrg * This call should set up the driver for doing a series of copies from the 248706f2543Smrg * the pSrcPixmap to the pDstPixmap. The dx flag will be positive if the 249706f2543Smrg * hardware should do the copy from the left to the right, and dy will be 250706f2543Smrg * positive if the copy should be done from the top to the bottom. This 251706f2543Smrg * is to deal with self-overlapping copies when pSrcPixmap == pDstPixmap. 252706f2543Smrg * If your hardware can only support blits that are (left to right, top to 253706f2543Smrg * bottom) or (right to left, bottom to top), then you should set 254706f2543Smrg * #EXA_TWO_BITBLT_DIRECTIONS, and EXA will break down Copy operations to 255706f2543Smrg * ones that meet those requirements. The alu raster op is one of the GX* 256706f2543Smrg * graphics functions listed in X.h, and typically maps to a similar 257706f2543Smrg * single-byte "ROP" setting in all hardware. The planemask controls which 258706f2543Smrg * bits of the destination should be affected, and will only represent the 259706f2543Smrg * bits up to the depth of pPixmap. 260706f2543Smrg * 261706f2543Smrg * Note that many drivers will need to store some of the data in the driver 262706f2543Smrg * private record, for sending to the hardware with each drawing command. 263706f2543Smrg * 264706f2543Smrg * The PrepareCopy() call is required of all drivers, but it may fail for any 265706f2543Smrg * reason. Failure results in a fallback to software rendering. 266706f2543Smrg */ 267706f2543Smrg Bool (*PrepareCopy) (PixmapPtr pSrcPixmap, 268706f2543Smrg PixmapPtr pDstPixmap, 269706f2543Smrg int dx, 270706f2543Smrg int dy, 271706f2543Smrg int alu, 272706f2543Smrg Pixel planemask); 273706f2543Smrg 274706f2543Smrg /** 275706f2543Smrg * Copy() performs a copy set up in the last PrepareCopy call. 276706f2543Smrg * 277706f2543Smrg * @param pDstPixmap destination pixmap 278706f2543Smrg * @param srcX source X coordinate 279706f2543Smrg * @param srcY source Y coordinate 280706f2543Smrg * @param dstX destination X coordinate 281706f2543Smrg * @param dstY destination Y coordinate 282706f2543Smrg * @param width width of the rectangle to be copied 283706f2543Smrg * @param height height of the rectangle to be copied. 284706f2543Smrg * 285706f2543Smrg * Performs the copy set up by the last PrepareCopy() call, copying the 286706f2543Smrg * rectangle from (srcX, srcY) to (srcX + width, srcY + width) in the source 287706f2543Smrg * pixmap to the same-sized rectangle at (dstX, dstY) in the destination 288706f2543Smrg * pixmap. Those rectangles may overlap in memory, if 289706f2543Smrg * pSrcPixmap == pDstPixmap. Note that this call does not receive the 290706f2543Smrg * pSrcPixmap as an argument -- if it's needed in this function, it should 291706f2543Smrg * be stored in the driver private during PrepareCopy(). As with Solid(), 292706f2543Smrg * the coordinates are in the coordinate space of each pixmap, so the driver 293706f2543Smrg * will need to set up source and destination pitches and offsets from those 294706f2543Smrg * pixmaps, probably using exaGetPixmapOffset() and exaGetPixmapPitch(). 295706f2543Smrg * 296706f2543Smrg * This call is required if PrepareCopy ever succeeds. 297706f2543Smrg */ 298706f2543Smrg void (*Copy) (PixmapPtr pDstPixmap, 299706f2543Smrg int srcX, 300706f2543Smrg int srcY, 301706f2543Smrg int dstX, 302706f2543Smrg int dstY, 303706f2543Smrg int width, 304706f2543Smrg int height); 305706f2543Smrg 306706f2543Smrg /** 307706f2543Smrg * DoneCopy() finishes a set of copies. 308706f2543Smrg * 309706f2543Smrg * @param pPixmap destination pixmap. 310706f2543Smrg * 311706f2543Smrg * The DoneCopy() call is called at the end of a series of consecutive 312706f2543Smrg * Copy() calls following a successful PrepareCopy(). This allows drivers 313706f2543Smrg * to finish up emitting drawing commands that were buffered, or clean up 314706f2543Smrg * state from PrepareCopy(). 315706f2543Smrg * 316706f2543Smrg * This call is required if PrepareCopy() ever succeeds. 317706f2543Smrg */ 318706f2543Smrg void (*DoneCopy) (PixmapPtr pDstPixmap); 319706f2543Smrg /** @} */ 320706f2543Smrg 321706f2543Smrg /** @name Composite 322706f2543Smrg * @{ 323706f2543Smrg */ 324706f2543Smrg /** 325706f2543Smrg * CheckComposite() checks to see if a composite operation could be 326706f2543Smrg * accelerated. 327706f2543Smrg * 328706f2543Smrg * @param op Render operation 329706f2543Smrg * @param pSrcPicture source Picture 330706f2543Smrg * @param pMaskPicture mask picture 331706f2543Smrg * @param pDstPicture destination Picture 332706f2543Smrg * 333706f2543Smrg * The CheckComposite() call checks if the driver could handle acceleration 334706f2543Smrg * of op with the given source, mask, and destination pictures. This allows 335706f2543Smrg * drivers to check source and destination formats, supported operations, 336706f2543Smrg * transformations, and component alpha state, and send operations it can't 337706f2543Smrg * support to software rendering early on. This avoids costly pixmap 338706f2543Smrg * migration to the wrong places when the driver can't accelerate 339706f2543Smrg * operations. Note that because migration hasn't happened, the driver 340706f2543Smrg * can't know during CheckComposite() what the offsets and pitches of the 341706f2543Smrg * pixmaps are going to be. 342706f2543Smrg * 343706f2543Smrg * See PrepareComposite() for more details on likely issues that drivers 344706f2543Smrg * will have in accelerating Composite operations. 345706f2543Smrg * 346706f2543Smrg * The CheckComposite() call is recommended if PrepareComposite() is 347706f2543Smrg * implemented, but is not required. 348706f2543Smrg */ 349706f2543Smrg Bool (*CheckComposite) (int op, 350706f2543Smrg PicturePtr pSrcPicture, 351706f2543Smrg PicturePtr pMaskPicture, 352706f2543Smrg PicturePtr pDstPicture); 353706f2543Smrg 354706f2543Smrg /** 355706f2543Smrg * PrepareComposite() sets up the driver for doing a Composite operation 356706f2543Smrg * described in the Render extension protocol spec. 357706f2543Smrg * 358706f2543Smrg * @param op Render operation 359706f2543Smrg * @param pSrcPicture source Picture 360706f2543Smrg * @param pMaskPicture mask picture 361706f2543Smrg * @param pDstPicture destination Picture 362706f2543Smrg * @param pSrc source pixmap 363706f2543Smrg * @param pMask mask pixmap 364706f2543Smrg * @param pDst destination pixmap 365706f2543Smrg * 366706f2543Smrg * This call should set up the driver for doing a series of Composite 367706f2543Smrg * operations, as described in the Render protocol spec, with the given 368706f2543Smrg * pSrcPicture, pMaskPicture, and pDstPicture. The pSrc, pMask, and 369706f2543Smrg * pDst are the pixmaps containing the pixel data, and should be used for 370706f2543Smrg * setting the offset and pitch used for the coordinate spaces for each of 371706f2543Smrg * the Pictures. 372706f2543Smrg * 373706f2543Smrg * Notes on interpreting Picture structures: 374706f2543Smrg * - The Picture structures will always have a valid pDrawable. 375706f2543Smrg * - The Picture structures will never have alphaMap set. 376706f2543Smrg * - The mask Picture (and therefore pMask) may be NULL, in which case the 377706f2543Smrg * operation is simply src OP dst instead of src IN mask OP dst, and 378706f2543Smrg * mask coordinates should be ignored. 379706f2543Smrg * - pMarkPicture may have componentAlpha set, which greatly changes 380706f2543Smrg * the behavior of the Composite operation. componentAlpha has no effect 381706f2543Smrg * when set on pSrcPicture or pDstPicture. 382706f2543Smrg * - The source and mask Pictures may have a transformation set 383706f2543Smrg * (Picture->transform != NULL), which means that the source coordinates 384706f2543Smrg * should be transformed by that transformation, resulting in scaling, 385706f2543Smrg * rotation, etc. The PictureTransformPoint() call can transform 386706f2543Smrg * coordinates for you. Transforms have no effect on Pictures when used 387706f2543Smrg * as a destination. 388706f2543Smrg * - The source and mask pictures may have a filter set. PictFilterNearest 389706f2543Smrg * and PictFilterBilinear are defined in the Render protocol, but others 390706f2543Smrg * may be encountered, and must be handled correctly (usually by 391706f2543Smrg * PrepareComposite failing, and falling back to software). Filters have 392706f2543Smrg * no effect on Pictures when used as a destination. 393706f2543Smrg * - The source and mask Pictures may have repeating set, which must be 394706f2543Smrg * respected. Many chipsets will be unable to support repeating on 395706f2543Smrg * pixmaps that have a width or height that is not a power of two. 396706f2543Smrg * 397706f2543Smrg * If your hardware can't support source pictures (textures) with 398706f2543Smrg * non-power-of-two pitches, you should set #EXA_OFFSCREEN_ALIGN_POT. 399706f2543Smrg * 400706f2543Smrg * Note that many drivers will need to store some of the data in the driver 401706f2543Smrg * private record, for sending to the hardware with each drawing command. 402706f2543Smrg * 403706f2543Smrg * The PrepareComposite() call is not required. However, it is highly 404706f2543Smrg * recommended for performance of antialiased font rendering and performance 405706f2543Smrg * of cairo applications. Failure results in a fallback to software 406706f2543Smrg * rendering. 407706f2543Smrg */ 408706f2543Smrg Bool (*PrepareComposite) (int op, 409706f2543Smrg PicturePtr pSrcPicture, 410706f2543Smrg PicturePtr pMaskPicture, 411706f2543Smrg PicturePtr pDstPicture, 412706f2543Smrg PixmapPtr pSrc, 413706f2543Smrg PixmapPtr pMask, 414706f2543Smrg PixmapPtr pDst); 415706f2543Smrg 416706f2543Smrg /** 417706f2543Smrg * Composite() performs a Composite operation set up in the last 418706f2543Smrg * PrepareComposite() call. 419706f2543Smrg * 420706f2543Smrg * @param pDstPixmap destination pixmap 421706f2543Smrg * @param srcX source X coordinate 422706f2543Smrg * @param srcY source Y coordinate 423706f2543Smrg * @param maskX source X coordinate 424706f2543Smrg * @param maskY source Y coordinate 425706f2543Smrg * @param dstX destination X coordinate 426706f2543Smrg * @param dstY destination Y coordinate 427706f2543Smrg * @param width destination rectangle width 428706f2543Smrg * @param height destination rectangle height 429706f2543Smrg * 430706f2543Smrg * Performs the Composite operation set up by the last PrepareComposite() 431706f2543Smrg * call, to the rectangle from (dstX, dstY) to (dstX + width, dstY + height) 432706f2543Smrg * in the destination Pixmap. Note that if a transformation was set on 433706f2543Smrg * the source or mask Pictures, the source rectangles may not be the same 434706f2543Smrg * size as the destination rectangles and filtering. Getting the coordinate 435706f2543Smrg * transformation right at the subpixel level can be tricky, and rendercheck 436706f2543Smrg * can test this for you. 437706f2543Smrg * 438706f2543Smrg * This call is required if PrepareComposite() ever succeeds. 439706f2543Smrg */ 440706f2543Smrg void (*Composite) (PixmapPtr pDst, 441706f2543Smrg int srcX, 442706f2543Smrg int srcY, 443706f2543Smrg int maskX, 444706f2543Smrg int maskY, 445706f2543Smrg int dstX, 446706f2543Smrg int dstY, 447706f2543Smrg int width, 448706f2543Smrg int height); 449706f2543Smrg 450706f2543Smrg /** 451706f2543Smrg * DoneComposite() finishes a set of Composite operations. 452706f2543Smrg * 453706f2543Smrg * @param pPixmap destination pixmap. 454706f2543Smrg * 455706f2543Smrg * The DoneComposite() call is called at the end of a series of consecutive 456706f2543Smrg * Composite() calls following a successful PrepareComposite(). This allows 457706f2543Smrg * drivers to finish up emitting drawing commands that were buffered, or 458706f2543Smrg * clean up state from PrepareComposite(). 459706f2543Smrg * 460706f2543Smrg * This call is required if PrepareComposite() ever succeeds. 461706f2543Smrg */ 462706f2543Smrg void (*DoneComposite) (PixmapPtr pDst); 463706f2543Smrg /** @} */ 464706f2543Smrg 465706f2543Smrg /** 466706f2543Smrg * UploadToScreen() loads a rectangle of data from src into pDst. 467706f2543Smrg * 468706f2543Smrg * @param pDst destination pixmap 469706f2543Smrg * @param x destination X coordinate. 470706f2543Smrg * @param y destination Y coordinate 471706f2543Smrg * @param width width of the rectangle to be copied 472706f2543Smrg * @param height height of the rectangle to be copied 473706f2543Smrg * @param src pointer to the beginning of the source data 474706f2543Smrg * @param src_pitch pitch (in bytes) of the lines of source data. 475706f2543Smrg * 476706f2543Smrg * UploadToScreen() copies data in system memory beginning at src (with 477706f2543Smrg * pitch src_pitch) into the destination pixmap from (x, y) to 478706f2543Smrg * (x + width, y + height). This is typically done with hostdata uploads, 479706f2543Smrg * where the CPU sets up a blit command on the hardware with instructions 480706f2543Smrg * that the blit data will be fed through some sort of aperture on the card. 481706f2543Smrg * 482706f2543Smrg * If UploadToScreen() is performed asynchronously, it is up to the driver 483706f2543Smrg * to call exaMarkSync(). This is in contrast to most other acceleration 484706f2543Smrg * calls in EXA. 485706f2543Smrg * 486706f2543Smrg * UploadToScreen() can aid in pixmap migration, but is most important for 487706f2543Smrg * the performance of exaGlyphs() (antialiased font drawing) by allowing 488706f2543Smrg * pipelining of data uploads, avoiding a sync of the card after each glyph. 489706f2543Smrg * 490706f2543Smrg * @return TRUE if the driver successfully uploaded the data. FALSE 491706f2543Smrg * indicates that EXA should fall back to doing the upload in software. 492706f2543Smrg * 493706f2543Smrg * UploadToScreen() is not required, but is recommended if Composite 494706f2543Smrg * acceleration is supported. 495706f2543Smrg */ 496706f2543Smrg Bool (*UploadToScreen) (PixmapPtr pDst, 497706f2543Smrg int x, 498706f2543Smrg int y, 499706f2543Smrg int w, 500706f2543Smrg int h, 501706f2543Smrg char *src, 502706f2543Smrg int src_pitch); 503706f2543Smrg 504706f2543Smrg /** 505706f2543Smrg * UploadToScratch() is no longer used and will be removed next time the EXA 506706f2543Smrg * major version needs to be bumped. 507706f2543Smrg */ 508706f2543Smrg Bool (*UploadToScratch) (PixmapPtr pSrc, 509706f2543Smrg PixmapPtr pDst); 510706f2543Smrg 511706f2543Smrg /** 512706f2543Smrg * DownloadFromScreen() loads a rectangle of data from pSrc into dst 513706f2543Smrg * 514706f2543Smrg * @param pSrc source pixmap 515706f2543Smrg * @param x source X coordinate. 516706f2543Smrg * @param y source Y coordinate 517706f2543Smrg * @param width width of the rectangle to be copied 518706f2543Smrg * @param height height of the rectangle to be copied 519706f2543Smrg * @param dst pointer to the beginning of the destination data 520706f2543Smrg * @param dst_pitch pitch (in bytes) of the lines of destination data. 521706f2543Smrg * 522706f2543Smrg * DownloadFromScreen() copies data from offscreen memory in pSrc from 523706f2543Smrg * (x, y) to (x + width, y + height), to system memory starting at 524706f2543Smrg * dst (with pitch dst_pitch). This would usually be done 525706f2543Smrg * using scatter-gather DMA, supported by a DRM call, or by blitting to AGP 526706f2543Smrg * and then synchronously reading from AGP. Because the implementation 527706f2543Smrg * might be synchronous, EXA leaves it up to the driver to call 528706f2543Smrg * exaMarkSync() if DownloadFromScreen() was asynchronous. This is in 529706f2543Smrg * contrast to most other acceleration calls in EXA. 530706f2543Smrg * 531706f2543Smrg * DownloadFromScreen() can aid in the largest bottleneck in pixmap 532706f2543Smrg * migration, which is the read from framebuffer when evicting pixmaps from 533706f2543Smrg * framebuffer memory. Thus, it is highly recommended, even though 534706f2543Smrg * implementations are typically complicated. 535706f2543Smrg * 536706f2543Smrg * @return TRUE if the driver successfully downloaded the data. FALSE 537706f2543Smrg * indicates that EXA should fall back to doing the download in software. 538706f2543Smrg * 539706f2543Smrg * DownloadFromScreen() is not required, but is highly recommended. 540706f2543Smrg */ 541706f2543Smrg Bool (*DownloadFromScreen)(PixmapPtr pSrc, 542706f2543Smrg int x, int y, 543706f2543Smrg int w, int h, 544706f2543Smrg char *dst, int dst_pitch); 545706f2543Smrg 546706f2543Smrg /** 547706f2543Smrg * MarkSync() requests that the driver mark a synchronization point, 548706f2543Smrg * returning an driver-defined integer marker which could be requested for 549706f2543Smrg * synchronization to later in WaitMarker(). This might be used in the 550706f2543Smrg * future to avoid waiting for full hardware stalls before accessing pixmap 551706f2543Smrg * data with the CPU, but is not important in the current incarnation of 552706f2543Smrg * EXA. 553706f2543Smrg * 554706f2543Smrg * Note that drivers should call exaMarkSync() when they have done some 555706f2543Smrg * acceleration, rather than their own MarkSync() handler, as otherwise EXA 556706f2543Smrg * will be unaware of the driver's acceleration and not sync to it during 557706f2543Smrg * fallbacks. 558706f2543Smrg * 559706f2543Smrg * MarkSync() is optional. 560706f2543Smrg */ 561706f2543Smrg int (*MarkSync) (ScreenPtr pScreen); 562706f2543Smrg 563706f2543Smrg /** 564706f2543Smrg * WaitMarker() waits for all rendering before the given marker to have 565706f2543Smrg * completed. If the driver does not implement MarkSync(), marker is 566706f2543Smrg * meaningless, and all rendering by the hardware should be completed before 567706f2543Smrg * WaitMarker() returns. 568706f2543Smrg * 569706f2543Smrg * Note that drivers should call exaWaitSync() to wait for all acceleration 570706f2543Smrg * to finish, as otherwise EXA will be unaware of the driver having 571706f2543Smrg * synchronized, resulting in excessive WaitMarker() calls. 572706f2543Smrg * 573706f2543Smrg * WaitMarker() is required of all drivers. 574706f2543Smrg */ 575706f2543Smrg void (*WaitMarker) (ScreenPtr pScreen, int marker); 576706f2543Smrg 577706f2543Smrg /** @{ */ 578706f2543Smrg /** 579706f2543Smrg * PrepareAccess() is called before CPU access to an offscreen pixmap. 580706f2543Smrg * 581706f2543Smrg * @param pPix the pixmap being accessed 582706f2543Smrg * @param index the index of the pixmap being accessed. 583706f2543Smrg * 584706f2543Smrg * PrepareAccess() will be called before CPU access to an offscreen pixmap. 585706f2543Smrg * This can be used to set up hardware surfaces for byteswapping or 586706f2543Smrg * untiling, or to adjust the pixmap's devPrivate.ptr for the purpose of 587706f2543Smrg * making CPU access use a different aperture. 588706f2543Smrg * 589706f2543Smrg * The index is one of #EXA_PREPARE_DEST, #EXA_PREPARE_SRC, 590706f2543Smrg * #EXA_PREPARE_MASK, #EXA_PREPARE_AUX_DEST, #EXA_PREPARE_AUX_SRC, or 591706f2543Smrg * #EXA_PREPARE_AUX_MASK. Since only up to #EXA_NUM_PREPARE_INDICES pixmaps 592706f2543Smrg * will have PrepareAccess() called on them per operation, drivers can have 593706f2543Smrg * a small, statically-allocated space to maintain state for PrepareAccess() 594706f2543Smrg * and FinishAccess() in. Note that PrepareAccess() is only called once per 595706f2543Smrg * pixmap and operation, regardless of whether the pixmap is used as a 596706f2543Smrg * destination and/or source, and the index may not reflect the usage. 597706f2543Smrg * 598706f2543Smrg * PrepareAccess() may fail. An example might be the case of hardware that 599706f2543Smrg * can set up 1 or 2 surfaces for CPU access, but not 3. If PrepareAccess() 600706f2543Smrg * fails, EXA will migrate the pixmap to system memory. 601706f2543Smrg * DownloadFromScreen() must be implemented and must not fail if a driver 602706f2543Smrg * wishes to fail in PrepareAccess(). PrepareAccess() must not fail when 603706f2543Smrg * pPix is the visible screen, because the visible screen can not be 604706f2543Smrg * migrated. 605706f2543Smrg * 606706f2543Smrg * @return TRUE if PrepareAccess() successfully prepared the pixmap for CPU 607706f2543Smrg * drawing. 608706f2543Smrg * @return FALSE if PrepareAccess() is unsuccessful and EXA should use 609706f2543Smrg * DownloadFromScreen() to migate the pixmap out. 610706f2543Smrg */ 611706f2543Smrg Bool (*PrepareAccess)(PixmapPtr pPix, int index); 612706f2543Smrg 613706f2543Smrg /** 614706f2543Smrg * FinishAccess() is called after CPU access to an offscreen pixmap. 615706f2543Smrg * 616706f2543Smrg * @param pPix the pixmap being accessed 617706f2543Smrg * @param index the index of the pixmap being accessed. 618706f2543Smrg * 619706f2543Smrg * FinishAccess() will be called after finishing CPU access of an offscreen 620706f2543Smrg * pixmap set up by PrepareAccess(). Note that the FinishAccess() will not be 621706f2543Smrg * called if PrepareAccess() failed and the pixmap was migrated out. 622706f2543Smrg */ 623706f2543Smrg void (*FinishAccess)(PixmapPtr pPix, int index); 624706f2543Smrg 625706f2543Smrg /** 626706f2543Smrg * PixmapIsOffscreen() is an optional driver replacement to 627706f2543Smrg * exaPixmapHasGpuCopy(). Set to NULL if you want the standard behaviour 628706f2543Smrg * of exaPixmapHasGpuCopy(). 629706f2543Smrg * 630706f2543Smrg * @param pPix the pixmap 631706f2543Smrg * @return TRUE if the given drawable is in framebuffer memory. 632706f2543Smrg * 633706f2543Smrg * exaPixmapHasGpuCopy() is used to determine if a pixmap is in offscreen 634706f2543Smrg * memory, meaning that acceleration could probably be done to it, and that it 635706f2543Smrg * will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it 636706f2543Smrg * with the CPU. 637706f2543Smrg * 638706f2543Smrg * 639706f2543Smrg */ 640706f2543Smrg Bool (*PixmapIsOffscreen)(PixmapPtr pPix); 641706f2543Smrg 642706f2543Smrg /** @name PrepareAccess() and FinishAccess() indices 643706f2543Smrg * @{ 644706f2543Smrg */ 645706f2543Smrg /** 646706f2543Smrg * EXA_PREPARE_DEST is the index for a pixmap that may be drawn to or 647706f2543Smrg * read from. 648706f2543Smrg */ 649706f2543Smrg #define EXA_PREPARE_DEST 0 650706f2543Smrg /** 651706f2543Smrg * EXA_PREPARE_SRC is the index for a pixmap that may be read from 652706f2543Smrg */ 653706f2543Smrg #define EXA_PREPARE_SRC 1 654706f2543Smrg /** 655706f2543Smrg * EXA_PREPARE_SRC is the index for a second pixmap that may be read 656706f2543Smrg * from. 657706f2543Smrg */ 658706f2543Smrg #define EXA_PREPARE_MASK 2 659706f2543Smrg /** 660706f2543Smrg * EXA_PREPARE_AUX* are additional indices for other purposes, e.g. 661706f2543Smrg * separate alpha maps with Composite operations. 662706f2543Smrg */ 663706f2543Smrg #define EXA_PREPARE_AUX_DEST 3 664706f2543Smrg #define EXA_PREPARE_AUX_SRC 4 665706f2543Smrg #define EXA_PREPARE_AUX_MASK 5 666706f2543Smrg #define EXA_NUM_PREPARE_INDICES 6 667706f2543Smrg /** @} */ 668706f2543Smrg 669706f2543Smrg /** 670706f2543Smrg * maxPitchPixels controls the pitch limitation for rendering from 671706f2543Smrg * the card. 672706f2543Smrg * The driver should never receive a request for rendering a pixmap 673706f2543Smrg * that has a pitch (in pixels) beyond maxPitchPixels. 674706f2543Smrg * 675706f2543Smrg * Setting this field is optional -- if your hardware doesn't have 676706f2543Smrg * a pitch limitation in pixels, don't set this. If neither this value 677706f2543Smrg * nor maxPitchBytes is set, then maxPitchPixels is set to maxX. 678706f2543Smrg * If set, it must not be smaller than maxX. 679706f2543Smrg * 680706f2543Smrg * @sa maxPitchBytes 681706f2543Smrg */ 682706f2543Smrg int maxPitchPixels; 683706f2543Smrg 684706f2543Smrg /** 685706f2543Smrg * maxPitchBytes controls the pitch limitation for rendering from 686706f2543Smrg * the card. 687706f2543Smrg * The driver should never receive a request for rendering a pixmap 688706f2543Smrg * that has a pitch (in bytes) beyond maxPitchBytes. 689706f2543Smrg * 690706f2543Smrg * Setting this field is optional -- if your hardware doesn't have 691706f2543Smrg * a pitch limitation in bytes, don't set this. 692706f2543Smrg * If set, it must not be smaller than maxX * 4. 693706f2543Smrg * There's no default value for maxPitchBytes. 694706f2543Smrg * 695706f2543Smrg * @sa maxPitchPixels 696706f2543Smrg */ 697706f2543Smrg int maxPitchBytes; 698706f2543Smrg 699706f2543Smrg /* Hooks to allow driver to its own pixmap memory management */ 700706f2543Smrg void *(*CreatePixmap)(ScreenPtr pScreen, int size, int align); 701706f2543Smrg void (*DestroyPixmap)(ScreenPtr pScreen, void *driverPriv); 702706f2543Smrg /** 703706f2543Smrg * Returning a pixmap with non-NULL devPrivate.ptr implies a pixmap which is 704706f2543Smrg * not offscreen, which will never be accelerated and Prepare/FinishAccess won't 705706f2543Smrg * be called. 706706f2543Smrg */ 707706f2543Smrg Bool (*ModifyPixmapHeader)(PixmapPtr pPixmap, int width, int height, 708706f2543Smrg int depth, int bitsPerPixel, int devKind, 709706f2543Smrg pointer pPixData); 710706f2543Smrg 711706f2543Smrg /* hooks for drivers with tiling support: 712706f2543Smrg * driver MUST fill out new_fb_pitch with valid pitch of pixmap 713706f2543Smrg */ 714706f2543Smrg void *(*CreatePixmap2)(ScreenPtr pScreen, int width, int height, 715706f2543Smrg int depth, int usage_hint, int bitsPerPixel, 716706f2543Smrg int *new_fb_pitch); 717706f2543Smrg /** @} */ 718706f2543Smrg} ExaDriverRec, *ExaDriverPtr; 719706f2543Smrg 720706f2543Smrg/** @name EXA driver flags 721706f2543Smrg * @{ 722706f2543Smrg */ 723706f2543Smrg/** 724706f2543Smrg * EXA_OFFSCREEN_PIXMAPS indicates to EXA that the driver can support 725706f2543Smrg * offscreen pixmaps. 726706f2543Smrg */ 727706f2543Smrg#define EXA_OFFSCREEN_PIXMAPS (1 << 0) 728706f2543Smrg 729706f2543Smrg/** 730706f2543Smrg * EXA_OFFSCREEN_ALIGN_POT indicates to EXA that the driver needs pixmaps 731706f2543Smrg * to have a power-of-two pitch. 732706f2543Smrg */ 733706f2543Smrg#define EXA_OFFSCREEN_ALIGN_POT (1 << 1) 734706f2543Smrg 735706f2543Smrg/** 736706f2543Smrg * EXA_TWO_BITBLT_DIRECTIONS indicates to EXA that the driver can only 737706f2543Smrg * support copies that are (left-to-right, top-to-bottom) or 738706f2543Smrg * (right-to-left, bottom-to-top). 739706f2543Smrg */ 740706f2543Smrg#define EXA_TWO_BITBLT_DIRECTIONS (1 << 2) 741706f2543Smrg 742706f2543Smrg/** 743706f2543Smrg * EXA_HANDLES_PIXMAPS indicates to EXA that the driver can handle 744706f2543Smrg * all pixmap addressing and migration. 745706f2543Smrg */ 746706f2543Smrg#define EXA_HANDLES_PIXMAPS (1 << 3) 747706f2543Smrg 748706f2543Smrg/** 749706f2543Smrg * EXA_SUPPORTS_PREPARE_AUX indicates to EXA that the driver can handle the 750706f2543Smrg * EXA_PREPARE_AUX* indices in the Prepare/FinishAccess hooks. If there are no 751706f2543Smrg * such hooks, this flag has no effect. 752706f2543Smrg */ 753706f2543Smrg#define EXA_SUPPORTS_PREPARE_AUX (1 << 4) 754706f2543Smrg 755706f2543Smrg/** 756706f2543Smrg * EXA_SUPPORTS_OFFSCREEN_OVERLAPS indicates to EXA that the driver Copy hooks 757706f2543Smrg * can handle the source and destination occupying overlapping offscreen memory 758706f2543Smrg * areas. This allows the offscreen memory defragmentation code to defragment 759706f2543Smrg * areas where the defragmented position overlaps the fragmented position. 760706f2543Smrg * 761706f2543Smrg * Typically this is supported by traditional 2D engines but not by 3D engines. 762706f2543Smrg */ 763706f2543Smrg#define EXA_SUPPORTS_OFFSCREEN_OVERLAPS (1 << 5) 764706f2543Smrg 765706f2543Smrg/** 766706f2543Smrg * EXA_MIXED_PIXMAPS will hide unacceleratable pixmaps from drivers and manage the 767706f2543Smrg * problem known software fallbacks like trapezoids. This only migrates pixmaps one way 768706f2543Smrg * into a driver pixmap and then pins it. 769706f2543Smrg */ 770706f2543Smrg#define EXA_MIXED_PIXMAPS (1 << 6) 771706f2543Smrg 772706f2543Smrg/** @} */ 773706f2543Smrg 774706f2543Smrg/* in exa.c */ 775706f2543Smrgextern _X_EXPORT ExaDriverPtr 776706f2543SmrgexaDriverAlloc(void); 777706f2543Smrg 778706f2543Smrgextern _X_EXPORT Bool 779706f2543SmrgexaDriverInit(ScreenPtr pScreen, 780706f2543Smrg ExaDriverPtr pScreenInfo); 781706f2543Smrg 782706f2543Smrgextern _X_EXPORT void 783706f2543SmrgexaDriverFini(ScreenPtr pScreen); 784706f2543Smrg 785706f2543Smrgextern _X_EXPORT void 786706f2543SmrgexaMarkSync(ScreenPtr pScreen); 787706f2543Smrgextern _X_EXPORT void 788706f2543SmrgexaWaitSync(ScreenPtr pScreen); 789706f2543Smrg 790706f2543Smrgextern _X_EXPORT unsigned long 791706f2543SmrgexaGetPixmapOffset(PixmapPtr pPix); 792706f2543Smrg 793706f2543Smrgextern _X_EXPORT unsigned long 794706f2543SmrgexaGetPixmapPitch(PixmapPtr pPix); 795706f2543Smrg 796706f2543Smrgextern _X_EXPORT unsigned long 797706f2543SmrgexaGetPixmapSize(PixmapPtr pPix); 798706f2543Smrg 799706f2543Smrgextern _X_EXPORT void * 800706f2543SmrgexaGetPixmapDriverPrivate(PixmapPtr p); 801706f2543Smrg 802706f2543Smrg 803706f2543Smrg/* in exa_offscreen.c */ 804706f2543Smrgextern _X_EXPORT ExaOffscreenArea * 805706f2543SmrgexaOffscreenAlloc(ScreenPtr pScreen, int size, int align, 806706f2543Smrg Bool locked, 807706f2543Smrg ExaOffscreenSaveProc save, 808706f2543Smrg pointer privData); 809706f2543Smrg 810706f2543Smrgextern _X_EXPORT ExaOffscreenArea * 811706f2543SmrgexaOffscreenFree(ScreenPtr pScreen, ExaOffscreenArea *area); 812706f2543Smrg 813706f2543Smrgextern _X_EXPORT void 814706f2543SmrgExaOffscreenMarkUsed (PixmapPtr pPixmap); 815706f2543Smrg 816706f2543Smrgextern _X_EXPORT void 817706f2543SmrgexaEnableDisableFBAccess (int index, Bool enable); 818706f2543Smrg 819706f2543Smrgextern _X_EXPORT Bool 820706f2543SmrgexaDrawableIsOffscreen (DrawablePtr pDrawable); 821706f2543Smrg 822706f2543Smrg/* in exa.c */ 823706f2543Smrgextern _X_EXPORT void 824706f2543SmrgexaMoveInPixmap (PixmapPtr pPixmap); 825706f2543Smrg 826706f2543Smrgextern _X_EXPORT void 827706f2543SmrgexaMoveOutPixmap (PixmapPtr pPixmap); 828706f2543Smrg 829706f2543Smrg 830706f2543Smrg/* in exa_unaccel.c */ 831706f2543Smrgextern _X_EXPORT CARD32 832706f2543SmrgexaGetPixmapFirstPixel (PixmapPtr pPixmap); 833706f2543Smrg 834706f2543Smrg 835706f2543Smrg/** 836706f2543Smrg * Returns TRUE if the given planemask covers all the significant bits in the 837706f2543Smrg * pixel values for pDrawable. 838706f2543Smrg */ 839706f2543Smrg#define EXA_PM_IS_SOLID(_pDrawable, _pm) \ 840706f2543Smrg (((_pm) & FbFullMask((_pDrawable)->depth)) == \ 841706f2543Smrg FbFullMask((_pDrawable)->depth)) 842706f2543Smrg 843706f2543Smrg#endif /* EXA_H */ 844