summaryrefslogtreecommitdiff
path: root/xc/lib/GL/mesa/src/drv/i810/i810context.h
blob: 6a7ffa968b5d4197cbac15b9af22686a6014823d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
 * GLX Hardware Device Driver for Intel i810
 * Copyright (C) 1999 Keith Whitwell
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */


#ifndef I810CONTEXT_INC
#define I810CONTEXT_INC

typedef struct i810_context_t i810Context;
typedef struct i810_context_t *i810ContextPtr;

#include <X11/Xlibint.h>
#include "dri_tmm.h"
#include "dri_mesaint.h"
#include "dri_mesa.h"
#include "xmesaP.h"

#include "types.h"
#include "i810_init.h"
#include "drm.h"

#include "i810tex.h"
#include "i810vb.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_STIPPLE        0x10  
#define I810_FALLBACK_SPECULAR       0x20 



/* for i810ctx.new_state - manage GL->driver state changes
 */
#define I810_NEW_TEXTURE 0x1

/* for i810ctx.dirty - manage driver->hw state changes, including
 * lost contexts.
 */
#define I810_WAIT_AGE          0x1
#define I810_UPLOAD_TEX0IMAGE  0x2
#define I810_UPLOAD_TEX1IMAGE  0x4
#define I810_UPLOAD_CTX        0x8
#define I810_UPLOAD_BUFFERS    0x10
#define I810_REFRESH_RING      0x20
#define I810_EMIT_CLIPRECT     0x40


typedef void (*i810_interp_func)( GLfloat t, 
				  GLfloat *result,
				  const GLfloat *in,
				  const GLfloat *out );
				 


struct i810_context_t {
   GLint refcount;

   GLcontext *glCtx;

   i810TextureObjectPtr CurrentTexObj[2];

   struct i810_texture_object_t TexObjList;
   struct i810_texture_object_t SwappedOut; 

   int TextureMode;

   /* Hardware state
    */
   GLuint Setup[I810_CTX_SETUP_SIZE];
   GLuint BufferSetup[I810_DEST_SETUP_SIZE];
   GLuint ClipSetup[I810_CLIP_SETUP_SIZE];
   

   /* Support for CVA and the fast paths.
    */
   GLuint setupdone;
   GLuint setupindex;
   GLuint renderindex;
   GLuint using_fast_path;
   i810_interp_func interp;

   /* Shortcircuit some state changes.
    */
   points_func PointsFunc;
   line_func LineFunc;
   triangle_func TriangleFunc;
   quad_func QuadFunc;

   /* Manage our own state */
   GLuint new_state; 

   /* Manage hardware state */
   GLuint dirty;
   memHeap_t *texHeap;

   /* One of the few bits of hardware state that can't be calculated
    * completely on the fly:
    */
   GLuint LcsCullMode;

   /* Funny mesa mirrors
    */
   GLushort MonoColor;
   GLushort ClearColor;

   /* DRI stuff
    */
   drmBufPtr  dma_buffer;
   drmBufPtr  vertex_dma_buffer;

   GLframebuffer *glBuffer;
   
   /* Two flags to keep track of fallbacks.
    */
   GLuint IndirectTriangles;
   GLuint Fallback;


   GLuint needClip;

   /* These refer to the current draw (front vs. back) buffer:
    */
   char *drawMap;		/* draw buffer address in virtual mem */
   char *readMap;	
   int drawX;			/* origin of drawable in draw buffer */
   int drawY;
   GLuint numClipRects;		/* cliprects for that buffer */
   XF86DRIClipRectPtr pClipRects;

   int lastSwap;
   int secondLastSwap;
   int texAge;
   int ctxAge;
   int dirtyAge;
   int any_contend;		/* throttle me harder */

   int scissor;

   int lines_are_tris;		/* not used */
   int horiz_line_stipple;
   int vert_line_stipple;

   int poly_stipple;

   drm_clip_rect_t draw_rect;
   drm_clip_rect_t scissor_rect;

   drmContext hHWContext;
   drmLock *driHwLock;
   int driFd;
   Display *display;

   __DRIdrawablePrivate *driDrawable;
   __DRIscreenPrivate *driScreen;
   i810ScreenPrivate *i810Screen; 
   drm_i810_sarea_t *sarea;
};


/* To remove all debugging, make sure I810_DEBUG is defined as a
 * preprocessor symbol, and equal to zero.  
 */
#define I810_DEBUG 0   
#ifndef I810_DEBUG
#warning "Debugging enabled - expect reduced performance"
extern int I810_DEBUG;
#endif

#define DEBUG_VERBOSE_2D     0x1
#define DEBUG_VERBOSE_RING   0x8
#define DEBUG_VERBOSE_OUTREG 0x10
#define DEBUG_ALWAYS_SYNC    0x40
#define DEBUG_VERBOSE_MSG    0x80
#define DEBUG_NO_OUTRING     0x100
#define DEBUG_NO_OUTREG      0x200
#define DEBUG_VERBOSE_API    0x400
#define DEBUG_VALIDATE_RING  0x800
#define DEBUG_VERBOSE_LRU    0x1000
#define DEBUG_VERBOSE_DRI    0x2000
#define DEBUG_VERBOSE_IOCTL  0x4000



extern GLuint i810DDRegisterPipelineStages( struct gl_pipeline_stage *out,
					   const struct gl_pipeline_stage *in,
					   GLuint nr );

extern GLboolean i810DDBuildPrecalcPipeline( GLcontext *ctx );



#endif