3. DRI aware DDX driver

The first step to build a DRI driver is to make the XFree86 2D driver DRI aware. The 2D driver can be found at xc/programs/Xserver/hw/xfree86/drivers/zzz/.

The header zzz_dri.h defines ZZZDRIRec. It also defines several macros which control among several things the layout of the AGP memory.

The ZZZDRIRec structure holds driver screen-specific data which is initialized by ZZZDRIScreenInit and attached to the DRIInfo structure. This structure usually contains information such as:

#ifndef _ZZZ_DRI_H
#define _ZZZ_DRI_H

#include "xf86drm.h"
#include "zzz_common.h"

/* DRI Driver defaults */
#define ZZZ_DEFAULT_AGP_MODE     1
#define ZZZ_DEFAULT_AGP_SIZE     8 /* MB (must be a power of 2 and > 4MB) */
#define ZZZ_DEFAULT_BUFFER_SIZE  2 /* MB (must be page aligned) */
#define ZZZ_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */

#define ZZZ_DEFAULT_CP_TIMEOUT   10000  /* usecs */

#define ZZZ_AGP_MAX_MODE         4

typedef struct {
    /* DRI screen private data */
    int           deviceID;	/* PCI device ID */
    int           width;	/* Width in pixels of display */
    int           height;	/* Height in scanlines of display */
    int           depth;	/* Depth of display (8, 15, 16, 24) */
    int           bpp;		/* Bit depth of display (8, 16, 24, 32) */

    int           IsPCI;	/* Current card is a PCI card */
    int           AGPMode;

    int           frontOffset;  /* Start of front buffer */
    int           frontPitch;
    int           backOffset;   /* Start of shared back buffer */
    int           backPitch;
    int           depthOffset;  /* Start of shared depth buffer */
    int           depthPitch;
    int           textureOffset;/* Start of texture data in frame buffer */
    int           textureSize;
    int           log2TexGran;

    /* MMIO register data */
    drmHandle     registerHandle;
    drmSize       registerSize;

    /* AGP Texture data */
    drmHandle     agpTexHandle;
    drmSize       agpTexMapSize;
    int           log2AGPTexGran;
    int           agpTexOffset;
    unsigned int  sarea_priv_offset;

#endif /* _ZZZ_DRI_H */

The header zzz_dripriv.h defines two structures ZZZConfigPrivRec and ZZZDRIContextRec.

ZZZConfigPrivRec holds driver private data for each of the visuals supported by the hardware which is initialized in ZZZInitVisualConfigs. This structure is not used by most drivers.

ZZZDRIContextRec holds driver private information for each running context which is created and destroyed by ZZZCreateContext and ZZZDestroyContext. This structure is not used by most drivers. For an usage example see the Radeon driver which can optionally have a per-context SAREA.

#ifndef _ZZZ_DRIPRIV_H
#define _ZZZ_DRIPRIV_H

#include "GL/glxint.h"
#include "xf86drm.h"
#include "zzz_common.h"

extern void GlxSetVisualConfigs(
    int nconfigs,
    __GLXvisualConfig *configs,
    void **configprivs );

typedef struct {
    /* Nothing here yet */
    int dummy;
} ZZZConfigPrivRec, *ZZZConfigPrivPtr;

typedef struct {
    /* Nothing here yet */
    int dummy;
} ZZZDRIContextRec, *ZZZDRIContextPtr;

#endif /* _ZZZ_DRIPRIV_H */

Include before the definition of the SRCS, OBJS, INCLUDES and DEFINES the necessary additions in seperate variables.

#if BuildXF86DRI
DRISRCS = zzz_dri.c
DRIOBJS = zzz_dri.o


Then appended the value of each one to the respective original variable.





For each file added you need to include a manifest line.