DRI2: Implement protocol for DRI2GetBuffersWithFormat

This change implements the protocol for DRI2GetBuffersWithFormat, but
the bulk of the differences are the changes to the extension / driver
interface to make this function work.  The old CreateBuffers and
DeleteBuffers routines are replaced with CreateBuffer and DeleteBuffer
(both singular).

This allows drivers to allocate buffers for a drawable one at a time.
As a result, 3D drivers can now allocate the (fake) front-buffer for a
window only when it is needed.  Since 3D drivers only ask for the
front-buffer on demand, the real front-buffer is always created.  This
allows CopyRegion impelemenations of SwapBuffers to continue working.
As with previous version of this code, if the client asks for the
front-buffer for a window, we instead give it the fake front-buffer.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian Høgsberg <krh@redhat.com>
This commit is contained in:
Ian Romanick 2009-04-24 12:49:19 -07:00
commit ff6c7764c2
5 changed files with 284 additions and 88 deletions

View file

@ -41,6 +41,7 @@ typedef struct {
unsigned int pitch;
unsigned int cpp;
unsigned int flags;
unsigned int format;
void *driverPrivate;
} DRI2BufferRec, *DRI2BufferPtr;
@ -58,8 +59,19 @@ typedef void (*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
typedef void (*DRI2WaitProcPtr)(WindowPtr pWin,
unsigned int sequence);
typedef DRI2BufferPtr (*DRI2CreateBufferProcPtr)(DrawablePtr pDraw,
unsigned int attachment,
unsigned int format);
typedef void (*DRI2DestroyBufferProcPtr)(DrawablePtr pDraw,
DRI2BufferPtr buffer);
/**
* Version of the DRI2InfoRec structure defined in this header
*/
#define DRI2INFOREC_VERSION 2
typedef struct {
unsigned int version; /* Version of this struct */
unsigned int version; /**< Version of this struct */
int fd;
const char *driverName;
const char *deviceName;
@ -69,6 +81,14 @@ typedef struct {
DRI2CopyRegionProcPtr CopyRegion;
DRI2WaitProcPtr Wait;
/**
* \name Fields added in version 2 of the structure.
*/
/*@{*/
DRI2CreateBufferProcPtr CreateBuffer;
DRI2DestroyBufferProcPtr DestroyBuffer;
/*@}*/
} DRI2InfoRec, *DRI2InfoPtr;
extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen,
@ -88,7 +108,7 @@ extern _X_EXPORT int DRI2CreateDrawable(DrawablePtr pDraw);
extern _X_EXPORT void DRI2DestroyDrawable(DrawablePtr pDraw);
extern _X_EXPORT DRI2BufferPtr DRI2GetBuffers(DrawablePtr pDraw,
extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffers(DrawablePtr pDraw,
int *width,
int *height,
unsigned int *attachments,
@ -118,4 +138,8 @@ extern _X_EXPORT int DRI2CopyRegion(DrawablePtr pDraw,
*/
extern _X_EXPORT void DRI2Version(int *major, int *minor);
extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffersWithFormat(DrawablePtr pDraw,
int *width, int *height, unsigned int *attachments, int count,
int *out_count);
#endif