#ifndef I810CONTEXT_INC
#define I810CONTEXT_INC
typedef struct i810_context_t i810Context;
typedef struct i810_context_t *i810ContextPtr;
typedef struct i810_texture_object_t *i810TextureObjectPtr;
#include "mtypes.h"
#include "mm.h"
#include "i810screen.h"
#include "i810tex.h"
#define I810_FALLBACK_TEXTURE 0x1
#define I810_FALLBACK_DRAW_BUFFER 0x2
#define I810_FALLBACK_READ_BUFFER 0x4
#define I810_FALLBACK_COLORMASK 0x8
#define I810_FALLBACK_SPECULAR 0x20
#define I810_FALLBACK_LOGICOP 0x40
#define I810_FALLBACK_RENDERMODE 0x80
#define I810_FALLBACK_STENCIL 0x100
#define I810_FALLBACK_BLEND_EQ 0x200
#define I810_FALLBACK_BLEND_FUNC 0x400
#ifndef PCI_CHIP_I810
#define PCI_CHIP_I810 0x7121
#define PCI_CHIP_I810_DC100 0x7123
#define PCI_CHIP_I810_E 0x7125
#define PCI_CHIP_I815 0x1132
#endif
#define IS_I810(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I810 || \
imesa->i810Screen->deviceID == PCI_CHIP_I810_DC100 || \
imesa->i810Screen->deviceID == PCI_CHIP_I810_E)
#define IS_I815(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I815)
#define I810_UPLOAD_TEX(i) (I810_UPLOAD_TEX0<<(i))
#define TAG(x) i810##x
#include "tnl_dd/t_dd_vertex.h"
#undef TAG
typedef void (*i810_tri_func)( i810ContextPtr, i810Vertex *, i810Vertex *,
i810Vertex * );
typedef void (*i810_line_func)( i810ContextPtr, i810Vertex *, i810Vertex * );
typedef void (*i810_point_func)( i810ContextPtr, i810Vertex * );
struct i810_context_t {
GLint refcount;
GLcontext *glCtx;
unsigned nr_heaps;
driTexHeap * texture_heaps[1];
driTextureObject swapped;
struct i810_texture_object_t *CurrentTexObj[2];
GLuint Fallback;
struct gl_client_array UbyteColor;
struct gl_client_array UbyteSecondaryColor;
GLuint new_state;
GLuint SetupNewInputs;
GLuint SetupIndex;
GLuint RenderIndex;
GLmatrix ViewportMatrix;
GLenum render_primitive;
GLenum reduced_primitive;
GLuint hw_primitive;
GLubyte *verts;
drmBufPtr vertex_buffer;
char *vertex_addr;
GLuint vertex_low;
GLuint vertex_high;
GLuint vertex_last_prim;
GLboolean upload_cliprects;
i810_point_func draw_point;
i810_line_func draw_line;
i810_tri_func draw_tri;
GLuint dirty;
GLuint Setup[I810_CTX_SETUP_SIZE];
GLuint BufferSetup[I810_DEST_SETUP_SIZE];
int vertex_size;
int vertex_stride_shift;
unsigned int lastStamp;
GLboolean stipple_in_hw;
GLenum TexEnvImageFmt[2];
GLuint LcsCullMode;
GLuint LcsLineWidth;
GLuint LcsPointSize;
GLushort ClearColor;
GLuint needClip;
GLframebuffer *glBuffer;
GLboolean doPageFlip;
char *drawMap;
char *readMap;
int drawX;
int drawY;
GLuint numClipRects;
XF86DRIClipRectPtr pClipRects;
int lastSwap;
int texAge;
int ctxAge;
int dirtyAge;
GLboolean scissor;
XF86DRIClipRectRec draw_rect;
XF86DRIClipRectRec scissor_rect;
drmContext hHWContext;
drmLock *driHwLock;
int driFd;
__DRIdrawablePrivate *driDrawable;
__DRIscreenPrivate *driScreen;
i810ScreenPrivate *i810Screen;
I810SAREAPtr sarea;
};
#define I810_CONTEXT(ctx) ((i810ContextPtr)(ctx->DriverCtx))
#define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
#define GET_ENQUEUE_AGE( imesa ) imesa->sarea->last_enqueue
#define LOCK_HARDWARE( imesa ) \
do { \
char __ret=0; \
DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
(DRM_LOCK_HELD|imesa->hHWContext), __ret); \
if (__ret) \
i810GetLock( imesa, 0 ); \
} while (0)
#define UNLOCK_HARDWARE(imesa) \
DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
#define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
LOCK_HARDWARE( imesa ); \
i810RegetLockQuiescent( imesa ); \
} while(0)
extern void i810GetLock( i810ContextPtr imesa, GLuint flags );
extern void i810EmitHwStateLocked( i810ContextPtr imesa );
extern void i810EmitScissorValues( i810ContextPtr imesa, int box_nr, int emit );
extern void i810EmitDrawingRectangle( i810ContextPtr imesa );
extern void i810XMesaSetBackClipRects( i810ContextPtr imesa );
extern void i810XMesaSetFrontClipRects( i810ContextPtr imesa );
#define SUBPIXEL_X -.5
#define SUBPIXEL_Y -.5
#define DO_DEBUG 1
#if DO_DEBUG
extern int I810_DEBUG;
#else
#define I810_DEBUG 0
#endif
#define DEBUG_TEXTURE 0x1
#define DEBUG_STATE 0x2
#define DEBUG_IOCTL 0x4
#define DEBUG_PRIMS 0x8
#define DEBUG_VERTS 0x10
#define DEBUG_FALLBACKS 0x20
#define DEBUG_VERBOSE 0x40
#define DEBUG_DRI 0x80
#define DEBUG_DMA 0x100
#define DEBUG_SANITY 0x200
#define DEBUG_SYNC 0x400
#define DEBUG_SLEEP 0x800
#endif