exa.h revision 4642e01f
105b261ecSmrg/* 205b261ecSmrg * 305b261ecSmrg * Copyright (C) 2000 Keith Packard 405b261ecSmrg * 2004 Eric Anholt 505b261ecSmrg * 2005 Zack Rusin 605b261ecSmrg * 705b261ecSmrg * Permission to use, copy, modify, distribute, and sell this software and its 805b261ecSmrg * documentation for any purpose is hereby granted without fee, provided that 905b261ecSmrg * the above copyright notice appear in all copies and that both that 1005b261ecSmrg * copyright notice and this permission notice appear in supporting 1105b261ecSmrg * documentation, and that the name of copyright holders not be used in 1205b261ecSmrg * advertising or publicity pertaining to distribution of the software without 1305b261ecSmrg * specific, written prior permission. Copyright holders make no 1405b261ecSmrg * representations about the suitability of this software for any purpose. It 1505b261ecSmrg * is provided "as is" without express or implied warranty. 1605b261ecSmrg * 1705b261ecSmrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 1805b261ecSmrg * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 1905b261ecSmrg * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 2005b261ecSmrg * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 2105b261ecSmrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 2205b261ecSmrg * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 2305b261ecSmrg * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 2405b261ecSmrg * SOFTWARE. 2505b261ecSmrg */ 2605b261ecSmrg 2705b261ecSmrg/** @file 2805b261ecSmrg * This is the header containing the public API of EXA for exa drivers. 2905b261ecSmrg */ 3005b261ecSmrg 3105b261ecSmrg#ifndef EXA_H 3205b261ecSmrg#define EXA_H 3305b261ecSmrg 3405b261ecSmrg#include "scrnintstr.h" 3505b261ecSmrg#include "pixmapstr.h" 3605b261ecSmrg#include "windowstr.h" 3705b261ecSmrg#include "gcstruct.h" 3805b261ecSmrg#include "picturestr.h" 3905b261ecSmrg#include "fb.h" 4005b261ecSmrg 4105b261ecSmrg#define EXA_VERSION_MAJOR 2 424642e01fSmrg#define EXA_VERSION_MINOR 4 4305b261ecSmrg#define EXA_VERSION_RELEASE 0 4405b261ecSmrg 4505b261ecSmrgtypedef struct _ExaOffscreenArea ExaOffscreenArea; 4605b261ecSmrg 4705b261ecSmrgtypedef void (*ExaOffscreenSaveProc) (ScreenPtr pScreen, ExaOffscreenArea *area); 4805b261ecSmrg 4905b261ecSmrgtypedef enum _ExaOffscreenState { 5005b261ecSmrg ExaOffscreenAvail, 5105b261ecSmrg ExaOffscreenRemovable, 5205b261ecSmrg ExaOffscreenLocked 5305b261ecSmrg} ExaOffscreenState; 5405b261ecSmrg 5505b261ecSmrgstruct _ExaOffscreenArea { 5605b261ecSmrg int base_offset; /* allocation base */ 5705b261ecSmrg int offset; /* aligned offset */ 5805b261ecSmrg int size; /* total allocation size */ 594642e01fSmrg unsigned last_use; 6005b261ecSmrg pointer privData; 6105b261ecSmrg 6205b261ecSmrg ExaOffscreenSaveProc save; 6305b261ecSmrg 6405b261ecSmrg ExaOffscreenState state; 6505b261ecSmrg 6605b261ecSmrg ExaOffscreenArea *next; 674642e01fSmrg 684642e01fSmrg unsigned eviction_cost; 6905b261ecSmrg}; 7005b261ecSmrg 7105b261ecSmrg/** 7205b261ecSmrg * The ExaDriver structure is allocated through exaDriverAlloc(), and then 7305b261ecSmrg * fllled in by drivers. 7405b261ecSmrg */ 7505b261ecSmrgtypedef struct _ExaDriver { 7605b261ecSmrg /** 7705b261ecSmrg * exa_major and exa_minor should be set by the driver to the version of 7805b261ecSmrg * EXA which the driver was compiled for (or configures itself at runtime 7905b261ecSmrg * to support). This allows EXA to extend the structure for new features 8005b261ecSmrg * without breaking ABI for drivers compiled against older versions. 8105b261ecSmrg */ 8205b261ecSmrg int exa_major, exa_minor; 8305b261ecSmrg 8405b261ecSmrg /** 8505b261ecSmrg * memoryBase is the address of the beginning of framebuffer memory. 8605b261ecSmrg * The visible screen should be within memoryBase to memoryBase + 8705b261ecSmrg * memorySize. 8805b261ecSmrg */ 8905b261ecSmrg CARD8 *memoryBase; 9005b261ecSmrg 9105b261ecSmrg /** 9205b261ecSmrg * offScreenBase is the offset from memoryBase of the beginning of the area 9305b261ecSmrg * to be managed by EXA's linear offscreen memory manager. 9405b261ecSmrg * 9505b261ecSmrg * In XFree86 DDX drivers, this is probably: 9605b261ecSmrg * (pScrn->displayWidth * cpp * pScrn->virtualY) 9705b261ecSmrg */ 9805b261ecSmrg unsigned long offScreenBase; 9905b261ecSmrg 10005b261ecSmrg /** 10105b261ecSmrg * memorySize is the length (in bytes) of framebuffer memory beginning 10205b261ecSmrg * from memoryBase. 10305b261ecSmrg * 10405b261ecSmrg * The offscreen memory manager will manage the area beginning at 10505b261ecSmrg * (memoryBase + offScreenBase), with a length of (memorySize - 10605b261ecSmrg * offScreenBase) 10705b261ecSmrg * 10805b261ecSmrg * In XFree86 DDX drivers, this is probably (pScrn->videoRam * 1024) 10905b261ecSmrg */ 11005b261ecSmrg unsigned long memorySize; 11105b261ecSmrg 11205b261ecSmrg /** 11305b261ecSmrg * pixmapOffsetAlign is the byte alignment necessary for pixmap offsets 11405b261ecSmrg * within framebuffer. 11505b261ecSmrg * 11605b261ecSmrg * Hardware typically has a required alignment of offsets, which may or may 11705b261ecSmrg * not be a power of two. EXA will ensure that pixmaps managed by the 11805b261ecSmrg * offscreen memory manager meet this alignment requirement. 11905b261ecSmrg */ 12005b261ecSmrg int pixmapOffsetAlign; 12105b261ecSmrg 12205b261ecSmrg /** 12305b261ecSmrg * pixmapPitchAlign is the byte alignment necessary for pixmap pitches 12405b261ecSmrg * within the framebuffer. 12505b261ecSmrg * 12605b261ecSmrg * Hardware typically has a required alignment of pitches for acceleration. 12705b261ecSmrg * For 3D hardware, Composite acceleration often requires that source and 12805b261ecSmrg * mask pixmaps (textures) have a power-of-two pitch, which can be demanded 12905b261ecSmrg * using EXA_OFFSCREEN_ALIGN_POT. These pitch requirements only apply to 13005b261ecSmrg * pixmaps managed by the offscreen memory manager. Thus, it is up to the 13105b261ecSmrg * driver to ensure that the visible screen has an appropriate pitch for 13205b261ecSmrg * acceleration. 13305b261ecSmrg */ 13405b261ecSmrg int pixmapPitchAlign; 13505b261ecSmrg 13605b261ecSmrg /** 13705b261ecSmrg * The flags field is bitfield of boolean values controlling EXA's behavior. 13805b261ecSmrg * 13905b261ecSmrg * The flags in clude EXA_OFFSCREEN_PIXMAPS, EXA_OFFSCREEN_ALIGN_POT, and 14005b261ecSmrg * EXA_TWO_BITBLT_DIRECTIONS. 14105b261ecSmrg */ 14205b261ecSmrg int flags; 14305b261ecSmrg 14405b261ecSmrg /** @{ */ 14505b261ecSmrg /** 14605b261ecSmrg * maxX controls the X coordinate limitation for rendering from the card. 14705b261ecSmrg * The driver should never receive a request for rendering beyond maxX 14805b261ecSmrg * in the X direction from the origin of a pixmap. 14905b261ecSmrg */ 15005b261ecSmrg int maxX; 15105b261ecSmrg 15205b261ecSmrg /** 15305b261ecSmrg * maxY controls the Y coordinate limitation for rendering from the card. 15405b261ecSmrg * The driver should never receive a request for rendering beyond maxY 15505b261ecSmrg * in the Y direction from the origin of a pixmap. 15605b261ecSmrg */ 15705b261ecSmrg int maxY; 15805b261ecSmrg /** @} */ 15905b261ecSmrg 16005b261ecSmrg /* private */ 16105b261ecSmrg ExaOffscreenArea *offScreenAreas; 16205b261ecSmrg Bool needsSync; 16305b261ecSmrg int lastMarker; 16405b261ecSmrg 16505b261ecSmrg /** @name Solid 16605b261ecSmrg * @{ 16705b261ecSmrg */ 16805b261ecSmrg /** 16905b261ecSmrg * PrepareSolid() sets up the driver for doing a solid fill. 17005b261ecSmrg * @param pPixmap Destination pixmap 17105b261ecSmrg * @param alu raster operation 17205b261ecSmrg * @param planemask write mask for the fill 17305b261ecSmrg * @param fg "foreground" color for the fill 17405b261ecSmrg * 17505b261ecSmrg * This call should set up the driver for doing a series of solid fills 17605b261ecSmrg * through the Solid() call. The alu raster op is one of the GX* 17705b261ecSmrg * graphics functions listed in X.h, and typically maps to a similar 17805b261ecSmrg * single-byte "ROP" setting in all hardware. The planemask controls 17905b261ecSmrg * which bits of the destination should be affected, and will only represent 18005b261ecSmrg * the bits up to the depth of pPixmap. The fg is the pixel value of the 18105b261ecSmrg * foreground color referred to in ROP descriptions. 18205b261ecSmrg * 18305b261ecSmrg * Note that many drivers will need to store some of the data in the driver 18405b261ecSmrg * private record, for sending to the hardware with each drawing command. 18505b261ecSmrg * 18605b261ecSmrg * The PrepareSolid() call is required of all drivers, but it may fail for any 18705b261ecSmrg * reason. Failure results in a fallback to software rendering. 18805b261ecSmrg */ 18905b261ecSmrg Bool (*PrepareSolid) (PixmapPtr pPixmap, 19005b261ecSmrg int alu, 19105b261ecSmrg Pixel planemask, 19205b261ecSmrg Pixel fg); 19305b261ecSmrg 19405b261ecSmrg /** 19505b261ecSmrg * Solid() performs a solid fill set up in the last PrepareSolid() call. 19605b261ecSmrg * 19705b261ecSmrg * @param pPixmap destination pixmap 19805b261ecSmrg * @param x1 left coordinate 19905b261ecSmrg * @param y1 top coordinate 20005b261ecSmrg * @param x2 right coordinate 20105b261ecSmrg * @param y2 bottom coordinate 20205b261ecSmrg * 20305b261ecSmrg * Performs the fill set up by the last PrepareSolid() call, covering the 20405b261ecSmrg * area from (x1,y1) to (x2,y2) in pPixmap. Note that the coordinates are 20505b261ecSmrg * in the coordinate space of the destination pixmap, so the driver will 20605b261ecSmrg * need to set up the hardware's offset and pitch for the destination 20705b261ecSmrg * coordinates according to the pixmap's offset and pitch within 20805b261ecSmrg * framebuffer. This likely means using exaGetPixmapOffset() and 20905b261ecSmrg * exaGetPixmapPitch(). 21005b261ecSmrg * 21105b261ecSmrg * This call is required if PrepareSolid() ever succeeds. 21205b261ecSmrg */ 21305b261ecSmrg void (*Solid) (PixmapPtr pPixmap, int x1, int y1, int x2, int y2); 21405b261ecSmrg 21505b261ecSmrg /** 21605b261ecSmrg * DoneSolid() finishes a set of solid fills. 21705b261ecSmrg * 21805b261ecSmrg * @param pPixmap destination pixmap. 21905b261ecSmrg * 22005b261ecSmrg * The DoneSolid() call is called at the end of a series of consecutive 22105b261ecSmrg * Solid() calls following a successful PrepareSolid(). This allows drivers 22205b261ecSmrg * to finish up emitting drawing commands that were buffered, or clean up 22305b261ecSmrg * state from PrepareSolid(). 22405b261ecSmrg * 22505b261ecSmrg * This call is required if PrepareSolid() ever succeeds. 22605b261ecSmrg */ 22705b261ecSmrg void (*DoneSolid) (PixmapPtr pPixmap); 22805b261ecSmrg /** @} */ 22905b261ecSmrg 23005b261ecSmrg /** @name Copy 23105b261ecSmrg * @{ 23205b261ecSmrg */ 23305b261ecSmrg /** 23405b261ecSmrg * PrepareCopy() sets up the driver for doing a copy within video 23505b261ecSmrg * memory. 23605b261ecSmrg * 23705b261ecSmrg * @param pSrcPixmap source pixmap 23805b261ecSmrg * @param pDstPixmap destination pixmap 23905b261ecSmrg * @param dx X copy direction 24005b261ecSmrg * @param dy Y copy direction 24105b261ecSmrg * @param alu raster operation 24205b261ecSmrg * @param planemask write mask for the fill 24305b261ecSmrg * 24405b261ecSmrg * This call should set up the driver for doing a series of copies from the 24505b261ecSmrg * the pSrcPixmap to the pDstPixmap. The dx flag will be positive if the 24605b261ecSmrg * hardware should do the copy from the left to the right, and dy will be 24705b261ecSmrg * positive if the copy should be done from the top to the bottom. This 24805b261ecSmrg * is to deal with self-overlapping copies when pSrcPixmap == pDstPixmap. 24905b261ecSmrg * If your hardware can only support blits that are (left to right, top to 25005b261ecSmrg * bottom) or (right to left, bottom to top), then you should set 25105b261ecSmrg * #EXA_TWO_BITBLT_DIRECTIONS, and EXA will break down Copy operations to 25205b261ecSmrg * ones that meet those requirements. The alu raster op is one of the GX* 25305b261ecSmrg * graphics functions listed in X.h, and typically maps to a similar 25405b261ecSmrg * single-byte "ROP" setting in all hardware. The planemask controls which 25505b261ecSmrg * bits of the destination should be affected, and will only represent the 25605b261ecSmrg * bits up to the depth of pPixmap. 25705b261ecSmrg * 25805b261ecSmrg * Note that many drivers will need to store some of the data in the driver 25905b261ecSmrg * private record, for sending to the hardware with each drawing command. 26005b261ecSmrg * 26105b261ecSmrg * The PrepareCopy() call is required of all drivers, but it may fail for any 26205b261ecSmrg * reason. Failure results in a fallback to software rendering. 26305b261ecSmrg */ 26405b261ecSmrg Bool (*PrepareCopy) (PixmapPtr pSrcPixmap, 26505b261ecSmrg PixmapPtr pDstPixmap, 26605b261ecSmrg int dx, 26705b261ecSmrg int dy, 26805b261ecSmrg int alu, 26905b261ecSmrg Pixel planemask); 27005b261ecSmrg 27105b261ecSmrg /** 27205b261ecSmrg * Copy() performs a copy set up in the last PrepareCopy call. 27305b261ecSmrg * 27405b261ecSmrg * @param pDstPixmap destination pixmap 27505b261ecSmrg * @param srcX source X coordinate 27605b261ecSmrg * @param srcY source Y coordinate 27705b261ecSmrg * @param dstX destination X coordinate 27805b261ecSmrg * @param dstY destination Y coordinate 27905b261ecSmrg * @param width width of the rectangle to be copied 28005b261ecSmrg * @param height height of the rectangle to be copied. 28105b261ecSmrg * 28205b261ecSmrg * Performs the copy set up by the last PrepareCopy() call, copying the 28305b261ecSmrg * rectangle from (srcX, srcY) to (srcX + width, srcY + width) in the source 28405b261ecSmrg * pixmap to the same-sized rectangle at (dstX, dstY) in the destination 28505b261ecSmrg * pixmap. Those rectangles may overlap in memory, if 28605b261ecSmrg * pSrcPixmap == pDstPixmap. Note that this call does not receive the 28705b261ecSmrg * pSrcPixmap as an argument -- if it's needed in this function, it should 28805b261ecSmrg * be stored in the driver private during PrepareCopy(). As with Solid(), 28905b261ecSmrg * the coordinates are in the coordinate space of each pixmap, so the driver 29005b261ecSmrg * will need to set up source and destination pitches and offsets from those 29105b261ecSmrg * pixmaps, probably using exaGetPixmapOffset() and exaGetPixmapPitch(). 29205b261ecSmrg * 29305b261ecSmrg * This call is required if PrepareCopy ever succeeds. 29405b261ecSmrg */ 29505b261ecSmrg void (*Copy) (PixmapPtr pDstPixmap, 29605b261ecSmrg int srcX, 29705b261ecSmrg int srcY, 29805b261ecSmrg int dstX, 29905b261ecSmrg int dstY, 30005b261ecSmrg int width, 30105b261ecSmrg int height); 30205b261ecSmrg 30305b261ecSmrg /** 30405b261ecSmrg * DoneCopy() finishes a set of copies. 30505b261ecSmrg * 30605b261ecSmrg * @param pPixmap destination pixmap. 30705b261ecSmrg * 30805b261ecSmrg * The DoneCopy() call is called at the end of a series of consecutive 30905b261ecSmrg * Copy() calls following a successful PrepareCopy(). This allows drivers 31005b261ecSmrg * to finish up emitting drawing commands that were buffered, or clean up 31105b261ecSmrg * state from PrepareCopy(). 31205b261ecSmrg * 31305b261ecSmrg * This call is required if PrepareCopy() ever succeeds. 31405b261ecSmrg */ 31505b261ecSmrg void (*DoneCopy) (PixmapPtr pDstPixmap); 31605b261ecSmrg /** @} */ 31705b261ecSmrg 31805b261ecSmrg /** @name Composite 31905b261ecSmrg * @{ 32005b261ecSmrg */ 32105b261ecSmrg /** 32205b261ecSmrg * CheckComposite() checks to see if a composite operation could be 32305b261ecSmrg * accelerated. 32405b261ecSmrg * 32505b261ecSmrg * @param op Render operation 32605b261ecSmrg * @param pSrcPicture source Picture 32705b261ecSmrg * @param pMaskPicture mask picture 32805b261ecSmrg * @param pDstPicture destination Picture 32905b261ecSmrg * 33005b261ecSmrg * The CheckComposite() call checks if the driver could handle acceleration 33105b261ecSmrg * of op with the given source, mask, and destination pictures. This allows 33205b261ecSmrg * drivers to check source and destination formats, supported operations, 33305b261ecSmrg * transformations, and component alpha state, and send operations it can't 33405b261ecSmrg * support to software rendering early on. This avoids costly pixmap 33505b261ecSmrg * migration to the wrong places when the driver can't accelerate 33605b261ecSmrg * operations. Note that because migration hasn't happened, the driver 33705b261ecSmrg * can't know during CheckComposite() what the offsets and pitches of the 33805b261ecSmrg * pixmaps are going to be. 33905b261ecSmrg * 34005b261ecSmrg * See PrepareComposite() for more details on likely issues that drivers 34105b261ecSmrg * will have in accelerating Composite operations. 34205b261ecSmrg * 34305b261ecSmrg * The CheckComposite() call is recommended if PrepareComposite() is 34405b261ecSmrg * implemented, but is not required. 34505b261ecSmrg */ 34605b261ecSmrg Bool (*CheckComposite) (int op, 34705b261ecSmrg PicturePtr pSrcPicture, 34805b261ecSmrg PicturePtr pMaskPicture, 34905b261ecSmrg PicturePtr pDstPicture); 35005b261ecSmrg 35105b261ecSmrg /** 35205b261ecSmrg * PrepareComposite() sets up the driver for doing a Composite operation 35305b261ecSmrg * described in the Render extension protocol spec. 35405b261ecSmrg * 35505b261ecSmrg * @param op Render operation 35605b261ecSmrg * @param pSrcPicture source Picture 35705b261ecSmrg * @param pMaskPicture mask picture 35805b261ecSmrg * @param pDstPicture destination Picture 35905b261ecSmrg * @param pSrc source pixmap 36005b261ecSmrg * @param pMask mask pixmap 36105b261ecSmrg * @param pDst destination pixmap 36205b261ecSmrg * 36305b261ecSmrg * This call should set up the driver for doing a series of Composite 36405b261ecSmrg * operations, as described in the Render protocol spec, with the given 36505b261ecSmrg * pSrcPicture, pMaskPicture, and pDstPicture. The pSrc, pMask, and 36605b261ecSmrg * pDst are the pixmaps containing the pixel data, and should be used for 36705b261ecSmrg * setting the offset and pitch used for the coordinate spaces for each of 36805b261ecSmrg * the Pictures. 36905b261ecSmrg * 37005b261ecSmrg * Notes on interpreting Picture structures: 37105b261ecSmrg * - The Picture structures will always have a valid pDrawable. 37205b261ecSmrg * - The Picture structures will never have alphaMap set. 37305b261ecSmrg * - The mask Picture (and therefore pMask) may be NULL, in which case the 37405b261ecSmrg * operation is simply src OP dst instead of src IN mask OP dst, and 37505b261ecSmrg * mask coordinates should be ignored. 37605b261ecSmrg * - pMarkPicture may have componentAlpha set, which greatly changes 37705b261ecSmrg * the behavior of the Composite operation. componentAlpha has no effect 37805b261ecSmrg * when set on pSrcPicture or pDstPicture. 37905b261ecSmrg * - The source and mask Pictures may have a transformation set 38005b261ecSmrg * (Picture->transform != NULL), which means that the source coordinates 38105b261ecSmrg * should be transformed by that transformation, resulting in scaling, 38205b261ecSmrg * rotation, etc. The PictureTransformPoint() call can transform 38305b261ecSmrg * coordinates for you. Transforms have no effect on Pictures when used 38405b261ecSmrg * as a destination. 38505b261ecSmrg * - The source and mask pictures may have a filter set. PictFilterNearest 38605b261ecSmrg * and PictFilterBilinear are defined in the Render protocol, but others 38705b261ecSmrg * may be encountered, and must be handled correctly (usually by 38805b261ecSmrg * PrepareComposite failing, and falling back to software). Filters have 38905b261ecSmrg * no effect on Pictures when used as a destination. 39005b261ecSmrg * - The source and mask Pictures may have repeating set, which must be 39105b261ecSmrg * respected. Many chipsets will be unable to support repeating on 39205b261ecSmrg * pixmaps that have a width or height that is not a power of two. 39305b261ecSmrg * 39405b261ecSmrg * If your hardware can't support source pictures (textures) with 39505b261ecSmrg * non-power-of-two pitches, you should set #EXA_OFFSCREEN_ALIGN_POT. 39605b261ecSmrg * 39705b261ecSmrg * Note that many drivers will need to store some of the data in the driver 39805b261ecSmrg * private record, for sending to the hardware with each drawing command. 39905b261ecSmrg * 40005b261ecSmrg * The PrepareComposite() call is not required. However, it is highly 40105b261ecSmrg * recommended for performance of antialiased font rendering and performance 40205b261ecSmrg * of cairo applications. Failure results in a fallback to software 40305b261ecSmrg * rendering. 40405b261ecSmrg */ 40505b261ecSmrg Bool (*PrepareComposite) (int op, 40605b261ecSmrg PicturePtr pSrcPicture, 40705b261ecSmrg PicturePtr pMaskPicture, 40805b261ecSmrg PicturePtr pDstPicture, 40905b261ecSmrg PixmapPtr pSrc, 41005b261ecSmrg PixmapPtr pMask, 41105b261ecSmrg PixmapPtr pDst); 41205b261ecSmrg 41305b261ecSmrg /** 41405b261ecSmrg * Composite() performs a Composite operation set up in the last 41505b261ecSmrg * PrepareComposite() call. 41605b261ecSmrg * 41705b261ecSmrg * @param pDstPixmap destination pixmap 41805b261ecSmrg * @param srcX source X coordinate 41905b261ecSmrg * @param srcY source Y coordinate 42005b261ecSmrg * @param maskX source X coordinate 42105b261ecSmrg * @param maskY source Y coordinate 42205b261ecSmrg * @param dstX destination X coordinate 42305b261ecSmrg * @param dstY destination Y coordinate 42405b261ecSmrg * @param width destination rectangle width 42505b261ecSmrg * @param height destination rectangle height 42605b261ecSmrg * 42705b261ecSmrg * Performs the Composite operation set up by the last PrepareComposite() 42805b261ecSmrg * call, to the rectangle from (dstX, dstY) to (dstX + width, dstY + height) 42905b261ecSmrg * in the destination Pixmap. Note that if a transformation was set on 43005b261ecSmrg * the source or mask Pictures, the source rectangles may not be the same 43105b261ecSmrg * size as the destination rectangles and filtering. Getting the coordinate 43205b261ecSmrg * transformation right at the subpixel level can be tricky, and rendercheck 43305b261ecSmrg * can test this for you. 43405b261ecSmrg * 43505b261ecSmrg * This call is required if PrepareComposite() ever succeeds. 43605b261ecSmrg */ 43705b261ecSmrg void (*Composite) (PixmapPtr pDst, 43805b261ecSmrg int srcX, 43905b261ecSmrg int srcY, 44005b261ecSmrg int maskX, 44105b261ecSmrg int maskY, 44205b261ecSmrg int dstX, 44305b261ecSmrg int dstY, 44405b261ecSmrg int width, 44505b261ecSmrg int height); 44605b261ecSmrg 44705b261ecSmrg /** 44805b261ecSmrg * DoneComposite() finishes a set of Composite operations. 44905b261ecSmrg * 45005b261ecSmrg * @param pPixmap destination pixmap. 45105b261ecSmrg * 45205b261ecSmrg * The DoneComposite() call is called at the end of a series of consecutive 45305b261ecSmrg * Composite() calls following a successful PrepareComposite(). This allows 45405b261ecSmrg * drivers to finish up emitting drawing commands that were buffered, or 45505b261ecSmrg * clean up state from PrepareComposite(). 45605b261ecSmrg * 45705b261ecSmrg * This call is required if PrepareComposite() ever succeeds. 45805b261ecSmrg */ 45905b261ecSmrg void (*DoneComposite) (PixmapPtr pDst); 46005b261ecSmrg /** @} */ 46105b261ecSmrg 46205b261ecSmrg /** 46305b261ecSmrg * UploadToScreen() loads a rectangle of data from src into pDst. 46405b261ecSmrg * 46505b261ecSmrg * @param pDst destination pixmap 46605b261ecSmrg * @param x destination X coordinate. 46705b261ecSmrg * @param y destination Y coordinate 46805b261ecSmrg * @param width width of the rectangle to be copied 46905b261ecSmrg * @param height height of the rectangle to be copied 47005b261ecSmrg * @param src pointer to the beginning of the source data 47105b261ecSmrg * @param src_pitch pitch (in bytes) of the lines of source data. 47205b261ecSmrg * 47305b261ecSmrg * UploadToScreen() copies data in system memory beginning at src (with 47405b261ecSmrg * pitch src_pitch) into the destination pixmap from (x, y) to 47505b261ecSmrg * (x + width, y + height). This is typically done with hostdata uploads, 47605b261ecSmrg * where the CPU sets up a blit command on the hardware with instructions 47705b261ecSmrg * that the blit data will be fed through some sort of aperture on the card. 47805b261ecSmrg * 47905b261ecSmrg * If UploadToScreen() is performed asynchronously, it is up to the driver 48005b261ecSmrg * to call exaMarkSync(). This is in contrast to most other acceleration 48105b261ecSmrg * calls in EXA. 48205b261ecSmrg * 48305b261ecSmrg * UploadToScreen() can aid in pixmap migration, but is most important for 48405b261ecSmrg * the performance of exaGlyphs() (antialiased font drawing) by allowing 48505b261ecSmrg * pipelining of data uploads, avoiding a sync of the card after each glyph. 48605b261ecSmrg * 48705b261ecSmrg * @return TRUE if the driver successfully uploaded the data. FALSE 48805b261ecSmrg * indicates that EXA should fall back to doing the upload in software. 48905b261ecSmrg * 49005b261ecSmrg * UploadToScreen() is not required, but is recommended if Composite 49105b261ecSmrg * acceleration is supported. 49205b261ecSmrg */ 49305b261ecSmrg Bool (*UploadToScreen) (PixmapPtr pDst, 49405b261ecSmrg int x, 49505b261ecSmrg int y, 49605b261ecSmrg int w, 49705b261ecSmrg int h, 49805b261ecSmrg char *src, 49905b261ecSmrg int src_pitch); 50005b261ecSmrg 50105b261ecSmrg /** 50205b261ecSmrg * UploadToScratch() is used to upload a pixmap to a scratch area for 50305b261ecSmrg * acceleration. 50405b261ecSmrg * 50505b261ecSmrg * @param pSrc source pixmap in host memory 50605b261ecSmrg * @param pDst fake, scratch pixmap to be set up in offscreen memory. 50705b261ecSmrg * 50805b261ecSmrg * The UploadToScratch() call was added to support Xati before Xati had 50905b261ecSmrg * support for hostdata uploads and before exaGlyphs() was written. It 51005b261ecSmrg * behaves incorrectly (uses an invalid pixmap as pDst), 51105b261ecSmrg * and UploadToScreen() should be implemented instead. 51205b261ecSmrg * 51305b261ecSmrg * Drivers implementing UploadToScratch() had to set up space (likely in a 51405b261ecSmrg * statically allocated area) in offscreen memory, copy pSrc to that 51505b261ecSmrg * scratch area, and adust pDst->devKind for the pitch and 51605b261ecSmrg * pDst->devPrivate.ptr for the pointer to that scratch area. The driver 51705b261ecSmrg * was responsible for syncing (as it was implemented using memcpy() in 51805b261ecSmrg * Xati), and only the data from the last UploadToScratch() was guaranteed 51905b261ecSmrg * to be valid at any given time. 52005b261ecSmrg * 52105b261ecSmrg * UploadToScratch() should not be implemented by drivers, and will likely 52205b261ecSmrg * be removed in a future version of EXA. 52305b261ecSmrg */ 52405b261ecSmrg Bool (*UploadToScratch) (PixmapPtr pSrc, 52505b261ecSmrg PixmapPtr pDst); 52605b261ecSmrg 52705b261ecSmrg /** 52805b261ecSmrg * DownloadFromScreen() loads a rectangle of data from pSrc into dst 52905b261ecSmrg * 53005b261ecSmrg * @param pSrc source pixmap 53105b261ecSmrg * @param x source X coordinate. 53205b261ecSmrg * @param y source Y coordinate 53305b261ecSmrg * @param width width of the rectangle to be copied 53405b261ecSmrg * @param height height of the rectangle to be copied 53505b261ecSmrg * @param dst pointer to the beginning of the destination data 53605b261ecSmrg * @param dst_pitch pitch (in bytes) of the lines of destination data. 53705b261ecSmrg * 53805b261ecSmrg * DownloadFromScreen() copies data from offscreen memory in pSrc from 53905b261ecSmrg * (x, y) to (x + width, y + height), to system memory starting at 54005b261ecSmrg * dst (with pitch dst_pitch). This would usually be done 54105b261ecSmrg * using scatter-gather DMA, supported by a DRM call, or by blitting to AGP 54205b261ecSmrg * and then synchronously reading from AGP. Because the implementation 54305b261ecSmrg * might be synchronous, EXA leaves it up to the driver to call 54405b261ecSmrg * exaMarkSync() if DownloadFromScreen() was asynchronous. This is in 54505b261ecSmrg * contrast to most other acceleration calls in EXA. 54605b261ecSmrg * 54705b261ecSmrg * DownloadFromScreen() can aid in the largest bottleneck in pixmap 54805b261ecSmrg * migration, which is the read from framebuffer when evicting pixmaps from 54905b261ecSmrg * framebuffer memory. Thus, it is highly recommended, even though 55005b261ecSmrg * implementations are typically complicated. 55105b261ecSmrg * 55205b261ecSmrg * @return TRUE if the driver successfully downloaded the data. FALSE 55305b261ecSmrg * indicates that EXA should fall back to doing the download in software. 55405b261ecSmrg * 55505b261ecSmrg * DownloadFromScreen() is not required, but is highly recommended. 55605b261ecSmrg */ 55705b261ecSmrg Bool (*DownloadFromScreen)(PixmapPtr pSrc, 55805b261ecSmrg int x, int y, 55905b261ecSmrg int w, int h, 56005b261ecSmrg char *dst, int dst_pitch); 56105b261ecSmrg 56205b261ecSmrg /** 56305b261ecSmrg * MarkSync() requests that the driver mark a synchronization point, 56405b261ecSmrg * returning an driver-defined integer marker which could be requested for 56505b261ecSmrg * synchronization to later in WaitMarker(). This might be used in the 56605b261ecSmrg * future to avoid waiting for full hardware stalls before accessing pixmap 56705b261ecSmrg * data with the CPU, but is not important in the current incarnation of 56805b261ecSmrg * EXA. 56905b261ecSmrg * 57005b261ecSmrg * Note that drivers should call exaMarkSync() when they have done some 57105b261ecSmrg * acceleration, rather than their own MarkSync() handler, as otherwise EXA 57205b261ecSmrg * will be unaware of the driver's acceleration and not sync to it during 57305b261ecSmrg * fallbacks. 57405b261ecSmrg * 57505b261ecSmrg * MarkSync() is optional. 57605b261ecSmrg */ 57705b261ecSmrg int (*MarkSync) (ScreenPtr pScreen); 57805b261ecSmrg 57905b261ecSmrg /** 58005b261ecSmrg * WaitMarker() waits for all rendering before the given marker to have 58105b261ecSmrg * completed. If the driver does not implement MarkSync(), marker is 58205b261ecSmrg * meaningless, and all rendering by the hardware should be completed before 58305b261ecSmrg * WaitMarker() returns. 58405b261ecSmrg * 58505b261ecSmrg * Note that drivers should call exaWaitSync() to wait for all acceleration 58605b261ecSmrg * to finish, as otherwise EXA will be unaware of the driver having 58705b261ecSmrg * synchronized, resulting in excessive WaitMarker() calls. 58805b261ecSmrg * 58905b261ecSmrg * WaitMarker() is required of all drivers. 59005b261ecSmrg */ 59105b261ecSmrg void (*WaitMarker) (ScreenPtr pScreen, int marker); 59205b261ecSmrg 59305b261ecSmrg /** @{ */ 59405b261ecSmrg /** 59505b261ecSmrg * PrepareAccess() is called before CPU access to an offscreen pixmap. 59605b261ecSmrg * 59705b261ecSmrg * @param pPix the pixmap being accessed 59805b261ecSmrg * @param index the index of the pixmap being accessed. 59905b261ecSmrg * 60005b261ecSmrg * PrepareAccess() will be called before CPU access to an offscreen pixmap. 60105b261ecSmrg * This can be used to set up hardware surfaces for byteswapping or 60205b261ecSmrg * untiling, or to adjust the pixmap's devPrivate.ptr for the purpose of 60305b261ecSmrg * making CPU access use a different aperture. 60405b261ecSmrg * 60505b261ecSmrg * The index is one of #EXA_PREPARE_DEST, #EXA_PREPARE_SRC, or 60605b261ecSmrg * #EXA_PREPARE_MASK, indicating which pixmap is in question. Since only up 60705b261ecSmrg * to three pixmaps will have PrepareAccess() called on them per operation, 60805b261ecSmrg * drivers can have a small, statically-allocated space to maintain state 60905b261ecSmrg * for PrepareAccess() and FinishAccess() in. Note that the same pixmap may 61005b261ecSmrg * have PrepareAccess() called on it more than once, for example when doing 61105b261ecSmrg * a copy within the same pixmap (so it gets PrepareAccess as() 61205b261ecSmrg * #EXA_PREPARE_DEST and then as #EXA_PREPARE_SRC). 61305b261ecSmrg * 61405b261ecSmrg * PrepareAccess() may fail. An example might be the case of hardware that 61505b261ecSmrg * can set up 1 or 2 surfaces for CPU access, but not 3. If PrepareAccess() 61605b261ecSmrg * fails, EXA will migrate the pixmap to system memory. 61705b261ecSmrg * DownloadFromScreen() must be implemented and must not fail if a driver 61805b261ecSmrg * wishes to fail in PrepareAccess(). PrepareAccess() must not fail when 61905b261ecSmrg * pPix is the visible screen, because the visible screen can not be 62005b261ecSmrg * migrated. 62105b261ecSmrg * 62205b261ecSmrg * @return TRUE if PrepareAccess() successfully prepared the pixmap for CPU 62305b261ecSmrg * drawing. 62405b261ecSmrg * @return FALSE if PrepareAccess() is unsuccessful and EXA should use 62505b261ecSmrg * DownloadFromScreen() to migate the pixmap out. 62605b261ecSmrg */ 62705b261ecSmrg Bool (*PrepareAccess)(PixmapPtr pPix, int index); 62805b261ecSmrg 62905b261ecSmrg /** 63005b261ecSmrg * FinishAccess() is called after CPU access to an offscreen pixmap. 63105b261ecSmrg * 63205b261ecSmrg * @param pPix the pixmap being accessed 63305b261ecSmrg * @param index the index of the pixmap being accessed. 63405b261ecSmrg * 63505b261ecSmrg * FinishAccess() will be called after finishing CPU access of an offscreen 63605b261ecSmrg * pixmap set up by PrepareAccess(). Note that the FinishAccess() will not be 63705b261ecSmrg * called if PrepareAccess() failed and the pixmap was migrated out. 63805b261ecSmrg */ 63905b261ecSmrg void (*FinishAccess)(PixmapPtr pPix, int index); 64005b261ecSmrg 64105b261ecSmrg /** 64205b261ecSmrg * PixmapIsOffscreen() is an optional driver replacement to 64305b261ecSmrg * exaPixmapIsOffscreen(). Set to NULL if you want the standard behaviour 64405b261ecSmrg * of exaPixmapIsOffscreen(). 64505b261ecSmrg * 64605b261ecSmrg * @param pPix the pixmap 64705b261ecSmrg * @return TRUE if the given drawable is in framebuffer memory. 64805b261ecSmrg * 64905b261ecSmrg * exaPixmapIsOffscreen() is used to determine if a pixmap is in offscreen 65005b261ecSmrg * memory, meaning that acceleration could probably be done to it, and that it 65105b261ecSmrg * will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it 65205b261ecSmrg * with the CPU. 65305b261ecSmrg * 65405b261ecSmrg * 65505b261ecSmrg */ 65605b261ecSmrg Bool (*PixmapIsOffscreen)(PixmapPtr pPix); 65705b261ecSmrg 65805b261ecSmrg /** @name PrepareAccess() and FinishAccess() indices 65905b261ecSmrg * @{ 66005b261ecSmrg */ 66105b261ecSmrg /** 66205b261ecSmrg * EXA_PREPARE_DEST is the index for a pixmap that may be drawn to or 66305b261ecSmrg * read from. 66405b261ecSmrg */ 66505b261ecSmrg #define EXA_PREPARE_DEST 0 66605b261ecSmrg /** 66705b261ecSmrg * EXA_PREPARE_SRC is the index for a pixmap that may be read from 66805b261ecSmrg */ 66905b261ecSmrg #define EXA_PREPARE_SRC 1 67005b261ecSmrg /** 67105b261ecSmrg * EXA_PREPARE_SRC is the index for a second pixmap that may be read 67205b261ecSmrg * from. 67305b261ecSmrg */ 67405b261ecSmrg #define EXA_PREPARE_MASK 2 6754642e01fSmrg /** 6764642e01fSmrg * EXA_PREPARE_AUX* are additional indices for other purposes, e.g. 6774642e01fSmrg * separate alpha maps with Composite operations. 6784642e01fSmrg */ 6794642e01fSmrg #define EXA_PREPARE_AUX0 3 6804642e01fSmrg #define EXA_PREPARE_AUX1 4 6814642e01fSmrg #define EXA_PREPARE_AUX2 5 68205b261ecSmrg /** @} */ 6834642e01fSmrg 6844642e01fSmrg /** 6854642e01fSmrg * maxPitchPixels controls the pitch limitation for rendering from 6864642e01fSmrg * the card. 6874642e01fSmrg * The driver should never receive a request for rendering a pixmap 6884642e01fSmrg * that has a pitch (in pixels) beyond maxPitchPixels. 6894642e01fSmrg * 6904642e01fSmrg * Setting this field is optional -- if your hardware doesn't have 6914642e01fSmrg * a pitch limitation in pixels, don't set this. If neither this value 6924642e01fSmrg * nor maxPitchBytes is set, then maxPitchPixels is set to maxX. 6934642e01fSmrg * If set, it must not be smaller than maxX. 6944642e01fSmrg * 6954642e01fSmrg * @sa maxPitchBytes 6964642e01fSmrg */ 6974642e01fSmrg int maxPitchPixels; 6984642e01fSmrg 6994642e01fSmrg /** 7004642e01fSmrg * maxPitchBytes controls the pitch limitation for rendering from 7014642e01fSmrg * the card. 7024642e01fSmrg * The driver should never receive a request for rendering a pixmap 7034642e01fSmrg * that has a pitch (in bytes) beyond maxPitchBytes. 7044642e01fSmrg * 7054642e01fSmrg * Setting this field is optional -- if your hardware doesn't have 7064642e01fSmrg * a pitch limitation in bytes, don't set this. 7074642e01fSmrg * If set, it must not be smaller than maxX * 4. 7084642e01fSmrg * There's no default value for maxPitchBytes. 7094642e01fSmrg * 7104642e01fSmrg * @sa maxPitchPixels 7114642e01fSmrg */ 7124642e01fSmrg int maxPitchBytes; 7134642e01fSmrg 7144642e01fSmrg /* Hooks to allow driver to its own pixmap memory management */ 7154642e01fSmrg void *(*CreatePixmap)(ScreenPtr pScreen, int size, int align); 7164642e01fSmrg void (*DestroyPixmap)(ScreenPtr pScreen, void *driverPriv); 7174642e01fSmrg Bool (*ModifyPixmapHeader)(PixmapPtr pPixmap, int width, int height, 7184642e01fSmrg int depth, int bitsPerPixel, int devKind, 7194642e01fSmrg pointer pPixData); 7204642e01fSmrg 72105b261ecSmrg /** @} */ 72205b261ecSmrg} ExaDriverRec, *ExaDriverPtr; 72305b261ecSmrg 72405b261ecSmrg/** @name EXA driver flags 72505b261ecSmrg * @{ 72605b261ecSmrg */ 72705b261ecSmrg/** 72805b261ecSmrg * EXA_OFFSCREEN_PIXMAPS indicates to EXA that the driver can support 72905b261ecSmrg * offscreen pixmaps. 73005b261ecSmrg */ 73105b261ecSmrg#define EXA_OFFSCREEN_PIXMAPS (1 << 0) 73205b261ecSmrg 73305b261ecSmrg/** 73405b261ecSmrg * EXA_OFFSCREEN_ALIGN_POT indicates to EXA that the driver needs pixmaps 73505b261ecSmrg * to have a power-of-two pitch. 73605b261ecSmrg */ 73705b261ecSmrg#define EXA_OFFSCREEN_ALIGN_POT (1 << 1) 73805b261ecSmrg 73905b261ecSmrg/** 74005b261ecSmrg * EXA_TWO_BITBLT_DIRECTIONS indicates to EXA that the driver can only 74105b261ecSmrg * support copies that are (left-to-right, top-to-bottom) or 74205b261ecSmrg * (right-to-left, bottom-to-top). 74305b261ecSmrg */ 74405b261ecSmrg#define EXA_TWO_BITBLT_DIRECTIONS (1 << 2) 7454642e01fSmrg 7464642e01fSmrg/** 7474642e01fSmrg * EXA_HANDLES_PIXMAPS indicates to EXA that the driver can handle 7484642e01fSmrg * all pixmap addressing and migration. 7494642e01fSmrg */ 7504642e01fSmrg#define EXA_HANDLES_PIXMAPS (1 << 3) 7514642e01fSmrg 7524642e01fSmrg/** 7534642e01fSmrg * EXA_SUPPORTS_PREPARE_AUX indicates to EXA that the driver can handle the 7544642e01fSmrg * EXA_PREPARE_AUX* indices in the Prepare/FinishAccess hooks. If there are no 7554642e01fSmrg * such hooks, this flag has no effect. 7564642e01fSmrg */ 7574642e01fSmrg#define EXA_SUPPORTS_PREPARE_AUX (1 << 4) 7584642e01fSmrg 75905b261ecSmrg/** @} */ 76005b261ecSmrg 7614642e01fSmrg/* in exa.c */ 76205b261ecSmrgExaDriverPtr 76305b261ecSmrgexaDriverAlloc(void); 76405b261ecSmrg 76505b261ecSmrgBool 7664642e01fSmrgexaDriverInit(ScreenPtr pScreen, 76705b261ecSmrg ExaDriverPtr pScreenInfo); 76805b261ecSmrg 76905b261ecSmrgvoid 7704642e01fSmrgexaDriverFini(ScreenPtr pScreen); 77105b261ecSmrg 77205b261ecSmrgvoid 77305b261ecSmrgexaMarkSync(ScreenPtr pScreen); 77405b261ecSmrgvoid 77505b261ecSmrgexaWaitSync(ScreenPtr pScreen); 77605b261ecSmrg 7774642e01fSmrgunsigned long 7784642e01fSmrgexaGetPixmapOffset(PixmapPtr pPix); 7794642e01fSmrg 7804642e01fSmrgunsigned long 7814642e01fSmrgexaGetPixmapPitch(PixmapPtr pPix); 7824642e01fSmrg 7834642e01fSmrgunsigned long 7844642e01fSmrgexaGetPixmapSize(PixmapPtr pPix); 7854642e01fSmrg 7864642e01fSmrgvoid * 7874642e01fSmrgexaGetPixmapDriverPrivate(PixmapPtr p); 7884642e01fSmrg 7894642e01fSmrg 7904642e01fSmrg/* in exa_offscreen.c */ 79105b261ecSmrgExaOffscreenArea * 79205b261ecSmrgexaOffscreenAlloc(ScreenPtr pScreen, int size, int align, 79305b261ecSmrg Bool locked, 79405b261ecSmrg ExaOffscreenSaveProc save, 79505b261ecSmrg pointer privData); 79605b261ecSmrg 79705b261ecSmrgExaOffscreenArea * 79805b261ecSmrgexaOffscreenFree(ScreenPtr pScreen, ExaOffscreenArea *area); 79905b261ecSmrg 80005b261ecSmrgvoid 80105b261ecSmrgExaOffscreenMarkUsed (PixmapPtr pPixmap); 80205b261ecSmrg 80305b261ecSmrgvoid 80405b261ecSmrgexaEnableDisableFBAccess (int index, Bool enable); 80505b261ecSmrg 8064642e01fSmrgBool 8074642e01fSmrgexaDrawableIsOffscreen (DrawablePtr pDrawable); 8084642e01fSmrg 8094642e01fSmrg/* in exa_migration.c */ 81005b261ecSmrgvoid 81105b261ecSmrgexaMoveInPixmap (PixmapPtr pPixmap); 81205b261ecSmrg 81305b261ecSmrgvoid 81405b261ecSmrgexaMoveOutPixmap (PixmapPtr pPixmap); 81505b261ecSmrg 8164642e01fSmrg 8174642e01fSmrg/* in exa_unaccel.c */ 8184642e01fSmrgCARD32 8194642e01fSmrgexaGetPixmapFirstPixel (PixmapPtr pPixmap); 8204642e01fSmrg 8214642e01fSmrg 82205b261ecSmrg/** 82305b261ecSmrg * Returns TRUE if the given planemask covers all the significant bits in the 82405b261ecSmrg * pixel values for pDrawable. 82505b261ecSmrg */ 82605b261ecSmrg#define EXA_PM_IS_SOLID(_pDrawable, _pm) \ 82705b261ecSmrg (((_pm) & FbFullMask((_pDrawable)->depth)) == \ 82805b261ecSmrg FbFullMask((_pDrawable)->depth)) 82905b261ecSmrg 83005b261ecSmrg#endif /* EXA_H */ 831