(Stephane Marchesin, me) add hyperz support to radeon and r200 drivers. Only fast...
[mesa.git] / src / mesa / drivers / dri / r300 / r200_context.h
1 /* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
2 /*
3 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
4
5 The Weather Channel (TM) funded Tungsten Graphics to develop the
6 initial release of the Radeon 8500 driver under the XFree86 license.
7 This notice must be preserved.
8
9 Permission is hereby granted, free of charge, to any person obtaining
10 a copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sublicense, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
16
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial
19 portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
25 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 **************************************************************************/
30
31 /*
32 * Authors:
33 * Keith Whitwell <keith@tungstengraphics.com>
34 */
35
36 #ifndef __R200_CONTEXT_H__
37 #define __R200_CONTEXT_H__
38
39 #ifdef GLX_DIRECT_RENDERING
40
41 #include "tnl/t_vertex.h"
42 #include "drm.h"
43 #include "radeon_drm.h"
44 #include "dri_util.h"
45 #include "texmem.h"
46
47 #include "macros.h"
48 #include "mtypes.h"
49 #include "colormac.h"
50 #include "r200_reg.h"
51 #include "radeon_context.h"
52
53 #define ENABLE_HW_3D_TEXTURE 1 /* XXX this is temporary! */
54
55 struct r200_context;
56 typedef struct r200_context r200ContextRec;
57 typedef struct r200_context *r200ContextPtr;
58
59 #include "mm.h"
60
61 /* The blit width for texture uploads
62 */
63 #define BLIT_WIDTH_BYTES 1024
64
65 /* Use the templated vertex format:
66 */
67 #define COLOR_IS_RGBA
68 #define TAG(x) r200##x
69 #include "tnl_dd/t_dd_vertex.h"
70 #undef TAG
71
72 typedef void (*r200_tri_func) (r200ContextPtr,
73 r200Vertex *, r200Vertex *, r200Vertex *);
74
75 typedef void (*r200_line_func) (r200ContextPtr, r200Vertex *, r200Vertex *);
76
77 typedef void (*r200_point_func) (r200ContextPtr, r200Vertex *);
78
79 struct r200_depthbuffer_state {
80 GLfloat scale;
81 };
82
83 struct r200_stencilbuffer_state {
84 GLboolean hwBuffer;
85 GLuint clear; /* rb3d_stencilrefmask value */
86 };
87
88 struct r200_stipple_state {
89 GLuint mask[32];
90 };
91
92 #define TEX_0 0x1
93 #define TEX_1 0x2
94 #define TEX_2 0x4
95 #define TEX_3 0x8
96 #define TEX_4 0x10
97 #define TEX_5 0x20
98 #define TEX_ALL 0x3f
99
100 typedef struct r200_tex_obj r200TexObj, *r200TexObjPtr;
101
102 /* Texture object in locally shared texture space.
103 */
104 struct r200_tex_obj {
105 driTextureObject base;
106
107 GLuint bufAddr; /* Offset to start of locally
108 shared texture block */
109
110 GLuint dirty_state; /* Flags (1 per texunit) for
111 whether or not this texobj
112 has dirty hardware state
113 (pp_*) that needs to be
114 brought into the
115 texunit. */
116
117 drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
118 /* Six, for the cube faces */
119
120 GLuint pp_txfilter; /* hardware register values */
121 GLuint pp_txformat;
122 GLuint pp_txformat_x;
123 GLuint pp_txoffset; /* Image location in texmem.
124 All cube faces follow. */
125 GLuint pp_txsize; /* npot only */
126 GLuint pp_txpitch; /* npot only */
127 GLuint pp_border_color;
128 GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
129
130 GLboolean border_fallback;
131 };
132
133 struct r200_texture_env_state {
134 r200TexObjPtr texobj;
135 GLenum format;
136 GLenum envMode;
137 };
138
139 #define R200_MAX_TEXTURE_UNITS 6
140
141 struct r200_texture_state {
142 struct r200_texture_env_state unit[R200_MAX_TEXTURE_UNITS];
143 };
144
145 struct r200_state_atom {
146 struct r200_state_atom *next, *prev;
147 const char *name; /* for debug */
148 int cmd_size; /* size in bytes */
149 GLuint idx;
150 int *cmd; /* one or more cmd's */
151 int *lastcmd; /* one or more cmd's */
152 int *savedcmd; /* one or more cmd's */
153 GLboolean dirty;
154 GLboolean(*check) (GLcontext *, int); /* is this state active? */
155 };
156
157 /* Trying to keep these relatively short as the variables are becoming
158 * extravagently long. Drop the driver name prefix off the front of
159 * everything - I think we know which driver we're in by now, and keep the
160 * prefix to 3 letters unless absolutely impossible.
161 */
162
163 #define CTX_CMD_0 0
164 #define CTX_PP_MISC 1
165 #define CTX_PP_FOG_COLOR 2
166 #define CTX_RE_SOLID_COLOR 3
167 #define CTX_RB3D_BLENDCNTL 4
168 #define CTX_RB3D_DEPTHOFFSET 5
169 #define CTX_RB3D_DEPTHPITCH 6
170 #define CTX_RB3D_ZSTENCILCNTL 7
171 #define CTX_CMD_1 8
172 #define CTX_PP_CNTL 9
173 #define CTX_RB3D_CNTL 10
174 #define CTX_RB3D_COLOROFFSET 11
175 #define CTX_CMD_2 12 /* why */
176 #define CTX_RB3D_COLORPITCH 13 /* why */
177 #define CTX_STATE_SIZE_OLDDRM 14
178 #define CTX_CMD_3 14
179 #define CTX_RB3D_BLENDCOLOR 15
180 #define CTX_RB3D_ABLENDCNTL 16
181 #define CTX_RB3D_CBLENDCNTL 17
182 #define CTX_STATE_SIZE_NEWDRM 18
183
184 #define SET_CMD_0 0
185 #define SET_SE_CNTL 1
186 #define SET_RE_CNTL 2 /* replace se_coord_fmt */
187 #define SET_STATE_SIZE 3
188
189 #define VTE_CMD_0 0
190 #define VTE_SE_VTE_CNTL 1
191 #define VTE_STATE_SIZE 2
192
193 #define LIN_CMD_0 0
194 #define LIN_RE_LINE_PATTERN 1
195 #define LIN_RE_LINE_STATE 2
196 #define LIN_CMD_1 3
197 #define LIN_SE_LINE_WIDTH 4
198 #define LIN_STATE_SIZE 5
199
200 #define MSK_CMD_0 0
201 #define MSK_RB3D_STENCILREFMASK 1
202 #define MSK_RB3D_ROPCNTL 2
203 #define MSK_RB3D_PLANEMASK 3
204 #define MSK_STATE_SIZE 4
205
206 #define VPT_CMD_0 0
207 #define VPT_SE_VPORT_XSCALE 1
208 #define VPT_SE_VPORT_XOFFSET 2
209 #define VPT_SE_VPORT_YSCALE 3
210 #define VPT_SE_VPORT_YOFFSET 4
211 #define VPT_SE_VPORT_ZSCALE 5
212 #define VPT_SE_VPORT_ZOFFSET 6
213 #define VPT_STATE_SIZE 7
214
215 #define ZBS_CMD_0 0
216 #define ZBS_SE_ZBIAS_FACTOR 1
217 #define ZBS_SE_ZBIAS_CONSTANT 2
218 #define ZBS_STATE_SIZE 3
219
220 #define MSC_CMD_0 0
221 #define MSC_RE_MISC 1
222 #define MSC_STATE_SIZE 2
223
224 #define TAM_CMD_0 0
225 #define TAM_DEBUG3 1
226 #define TAM_STATE_SIZE 2
227
228 #define TEX_CMD_0 0
229 #define TEX_PP_TXFILTER 1 /*2c00 */
230 #define TEX_PP_TXFORMAT 2 /*2c04 */
231 #define TEX_PP_TXFORMAT_X 3 /*2c08 */
232 #define TEX_PP_TXSIZE 4 /*2c0c */
233 #define TEX_PP_TXPITCH 5 /*2c10 */
234 #define TEX_PP_BORDER_COLOR 6 /*2c14 */
235 #define TEX_CMD_1 7
236 #define TEX_PP_TXOFFSET 8 /*2d00 */
237 #define TEX_STATE_SIZE 9
238
239 #define CUBE_CMD_0 0 /* 1 register follows */
240 #define CUBE_PP_CUBIC_FACES 1 /* 0x2c18 */
241 #define CUBE_CMD_1 2 /* 5 registers follow */
242 #define CUBE_PP_CUBIC_OFFSET_F1 3 /* 0x2d04 */
243 #define CUBE_PP_CUBIC_OFFSET_F2 4 /* 0x2d08 */
244 #define CUBE_PP_CUBIC_OFFSET_F3 5 /* 0x2d0c */
245 #define CUBE_PP_CUBIC_OFFSET_F4 6 /* 0x2d10 */
246 #define CUBE_PP_CUBIC_OFFSET_F5 7 /* 0x2d14 */
247 #define CUBE_STATE_SIZE 8
248
249 #define PIX_CMD_0 0
250 #define PIX_PP_TXCBLEND 1
251 #define PIX_PP_TXCBLEND2 2
252 #define PIX_PP_TXABLEND 3
253 #define PIX_PP_TXABLEND2 4
254 #define PIX_STATE_SIZE 5
255
256 #define TF_CMD_0 0
257 #define TF_TFACTOR_0 1
258 #define TF_TFACTOR_1 2
259 #define TF_TFACTOR_2 3
260 #define TF_TFACTOR_3 4
261 #define TF_TFACTOR_4 5
262 #define TF_TFACTOR_5 6
263 #define TF_STATE_SIZE 7
264
265 #define TCL_CMD_0 0
266 #define TCL_LIGHT_MODEL_CTL_0 1
267 #define TCL_LIGHT_MODEL_CTL_1 2
268 #define TCL_PER_LIGHT_CTL_0 3
269 #define TCL_PER_LIGHT_CTL_1 4
270 #define TCL_PER_LIGHT_CTL_2 5
271 #define TCL_PER_LIGHT_CTL_3 6
272 #define TCL_CMD_1 7
273 #define TCL_UCP_VERT_BLEND_CTL 8
274 #define TCL_STATE_SIZE 9
275
276 #define MSL_CMD_0 0
277 #define MSL_MATRIX_SELECT_0 1
278 #define MSL_MATRIX_SELECT_1 2
279 #define MSL_MATRIX_SELECT_2 3
280 #define MSL_MATRIX_SELECT_3 4
281 #define MSL_MATRIX_SELECT_4 5
282 #define MSL_STATE_SIZE 6
283
284 #define TCG_CMD_0 0
285 #define TCG_TEX_PROC_CTL_2 1
286 #define TCG_TEX_PROC_CTL_3 2
287 #define TCG_TEX_PROC_CTL_0 3
288 #define TCG_TEX_PROC_CTL_1 4
289 #define TCG_TEX_CYL_WRAP_CTL 5
290 #define TCG_STATE_SIZE 6
291
292 #define MTL_CMD_0 0
293 #define MTL_EMMISSIVE_RED 1
294 #define MTL_EMMISSIVE_GREEN 2
295 #define MTL_EMMISSIVE_BLUE 3
296 #define MTL_EMMISSIVE_ALPHA 4
297 #define MTL_AMBIENT_RED 5
298 #define MTL_AMBIENT_GREEN 6
299 #define MTL_AMBIENT_BLUE 7
300 #define MTL_AMBIENT_ALPHA 8
301 #define MTL_DIFFUSE_RED 9
302 #define MTL_DIFFUSE_GREEN 10
303 #define MTL_DIFFUSE_BLUE 11
304 #define MTL_DIFFUSE_ALPHA 12
305 #define MTL_SPECULAR_RED 13
306 #define MTL_SPECULAR_GREEN 14
307 #define MTL_SPECULAR_BLUE 15
308 #define MTL_SPECULAR_ALPHA 16
309 #define MTL_CMD_1 17
310 #define MTL_SHININESS 18
311 #define MTL_STATE_SIZE 19
312
313 #define VAP_CMD_0 0
314 #define VAP_SE_VAP_CNTL 1
315 #define VAP_STATE_SIZE 2
316
317 /* Replaces a lot of packet info from radeon
318 */
319 #define VTX_CMD_0 0
320 #define VTX_VTXFMT_0 1
321 #define VTX_VTXFMT_1 2
322 #define VTX_TCL_OUTPUT_VTXFMT_0 3
323 #define VTX_TCL_OUTPUT_VTXFMT_1 4
324 #define VTX_CMD_1 5
325 #define VTX_TCL_OUTPUT_COMPSEL 6
326 #define VTX_CMD_2 7
327 #define VTX_STATE_CNTL 8
328 #define VTX_STATE_SIZE 9
329
330 #define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\
331 R200_VTX_COLOR_MASK)
332
333 /**
334 * Given the \c R200_SE_VTX_FMT_1 for the current vertex state, determine
335 * how many components are in texture coordinate \c n.
336 */
337 #define VTX_TEXn_COUNT(v,n) (((v) >> (3 * n)) & 0x07)
338
339 #define MAT_CMD_0 0
340 #define MAT_ELT_0 1
341 #define MAT_STATE_SIZE 17
342
343 #define GRD_CMD_0 0
344 #define GRD_VERT_GUARD_CLIP_ADJ 1
345 #define GRD_VERT_GUARD_DISCARD_ADJ 2
346 #define GRD_HORZ_GUARD_CLIP_ADJ 3
347 #define GRD_HORZ_GUARD_DISCARD_ADJ 4
348 #define GRD_STATE_SIZE 5
349
350 /* position changes frequently when lighting in modelpos - separate
351 * out to new state item?
352 */
353 #define LIT_CMD_0 0
354 #define LIT_AMBIENT_RED 1
355 #define LIT_AMBIENT_GREEN 2
356 #define LIT_AMBIENT_BLUE 3
357 #define LIT_AMBIENT_ALPHA 4
358 #define LIT_DIFFUSE_RED 5
359 #define LIT_DIFFUSE_GREEN 6
360 #define LIT_DIFFUSE_BLUE 7
361 #define LIT_DIFFUSE_ALPHA 8
362 #define LIT_SPECULAR_RED 9
363 #define LIT_SPECULAR_GREEN 10
364 #define LIT_SPECULAR_BLUE 11
365 #define LIT_SPECULAR_ALPHA 12
366 #define LIT_POSITION_X 13
367 #define LIT_POSITION_Y 14
368 #define LIT_POSITION_Z 15
369 #define LIT_POSITION_W 16
370 #define LIT_DIRECTION_X 17
371 #define LIT_DIRECTION_Y 18
372 #define LIT_DIRECTION_Z 19
373 #define LIT_DIRECTION_W 20
374 #define LIT_ATTEN_QUADRATIC 21
375 #define LIT_ATTEN_LINEAR 22
376 #define LIT_ATTEN_CONST 23
377 #define LIT_ATTEN_XXX 24
378 #define LIT_CMD_1 25
379 #define LIT_SPOT_DCD 26
380 #define LIT_SPOT_DCM 27
381 #define LIT_SPOT_EXPONENT 28
382 #define LIT_SPOT_CUTOFF 29
383 #define LIT_SPECULAR_THRESH 30
384 #define LIT_RANGE_CUTOFF 31 /* ? */
385 #define LIT_ATTEN_CONST_INV 32
386 #define LIT_STATE_SIZE 33
387
388 /* Fog
389 */
390 #define FOG_CMD_0 0
391 #define FOG_R 1
392 #define FOG_C 2
393 #define FOG_D 3
394 #define FOG_PAD 4
395 #define FOG_STATE_SIZE 5
396
397 /* UCP
398 */
399 #define UCP_CMD_0 0
400 #define UCP_X 1
401 #define UCP_Y 2
402 #define UCP_Z 3
403 #define UCP_W 4
404 #define UCP_STATE_SIZE 5
405
406 /* GLT - Global ambient
407 */
408 #define GLT_CMD_0 0
409 #define GLT_RED 1
410 #define GLT_GREEN 2
411 #define GLT_BLUE 3
412 #define GLT_ALPHA 4
413 #define GLT_STATE_SIZE 5
414
415 /* EYE
416 */
417 #define EYE_CMD_0 0
418 #define EYE_X 1
419 #define EYE_Y 2
420 #define EYE_Z 3
421 #define EYE_RESCALE_FACTOR 4
422 #define EYE_STATE_SIZE 5
423
424 /* CST - constant state
425 */
426 #define CST_CMD_0 0
427 #define CST_PP_CNTL_X 1
428 #define CST_CMD_1 2
429 #define CST_RB3D_DEPTHXY_OFFSET 3
430 #define CST_CMD_2 4
431 #define CST_RE_AUX_SCISSOR_CNTL 5
432 #define CST_CMD_3 6
433 #define CST_RE_SCISSOR_TL_0 7
434 #define CST_RE_SCISSOR_BR_0 8
435 #define CST_CMD_4 9
436 #define CST_SE_VAP_CNTL_STATUS 10
437 #define CST_CMD_5 11
438 #define CST_RE_POINTSIZE 12
439 #define CST_CMD_6 13
440 #define CST_SE_TCL_INPUT_VTX_0 14
441 #define CST_SE_TCL_INPUT_VTX_1 15
442 #define CST_SE_TCL_INPUT_VTX_2 16
443 #define CST_SE_TCL_INPUT_VTX_3 17
444 #define CST_STATE_SIZE 18
445
446 struct r200_hw_state {
447 /* Head of the linked list of state atoms. */
448 struct r200_state_atom atomlist;
449
450 /* Hardware state, stored as cmdbuf commands:
451 * -- Need to doublebuffer for
452 * - reviving state after loss of context
453 * - eliding noop statechange loops? (except line stipple count)
454 */
455 struct r200_state_atom ctx;
456 struct r200_state_atom set;
457 struct r200_state_atom vte;
458 struct r200_state_atom lin;
459 struct r200_state_atom msk;
460 struct r200_state_atom vpt;
461 struct r200_state_atom vap;
462 struct r200_state_atom vtx;
463 struct r200_state_atom tcl;
464 struct r200_state_atom msl;
465 struct r200_state_atom tcg;
466 struct r200_state_atom msc;
467 struct r200_state_atom cst;
468 struct r200_state_atom tam;
469 struct r200_state_atom tf;
470 struct r200_state_atom tex[6];
471 struct r200_state_atom cube[6];
472 struct r200_state_atom zbs;
473 struct r200_state_atom mtl[2];
474 struct r200_state_atom mat[9];
475 struct r200_state_atom lit[8]; /* includes vec, scl commands */
476 struct r200_state_atom ucp[6];
477 struct r200_state_atom pix[6]; /* pixshader stages */
478 struct r200_state_atom eye; /* eye pos */
479 struct r200_state_atom grd; /* guard band clipping */
480 struct r200_state_atom fog;
481 struct r200_state_atom glt;
482
483 int max_state_size; /* Number of bytes necessary for a full state emit. */
484 GLboolean is_dirty, all_dirty;
485 };
486
487 struct r200_colorbuffer_state {
488 int roundEnable;
489 };
490
491 struct r200_state {
492 /* Derived state for internal purposes:
493 */
494 struct r200_colorbuffer_state color;
495 struct r200_depthbuffer_state depth;
496 struct r200_stencilbuffer_state stencil;
497 struct r200_stipple_state stipple;
498 struct r200_texture_state texture;
499 };
500
501 /* Need refcounting on dma buffers:
502 */
503 struct r200_dma_buffer {
504 int refcount; /* the number of retained regions in buf */
505 drmBufPtr buf;
506 };
507
508 #define GET_START(rvb) (rmesa->radeon.radeonScreen->gart_buffer_offset + \
509 (rvb)->address - rmesa->dma.buf0_address + \
510 (rvb)->start)
511
512 /* A retained region, eg vertices for indexed vertices.
513 */
514 struct r200_dma_region {
515 struct r200_dma_buffer *buf;
516 char *address; /* == buf->address */
517 int start, end, ptr; /* offsets from start of buf */
518 int aos_start;
519 int aos_stride;
520 int aos_size;
521 };
522
523 struct r200_dma {
524 /* Active dma region. Allocations for vertices and retained
525 * regions come from here. Also used for emitting random vertices,
526 * these may be flushed by calling flush_current();
527 */
528 struct r200_dma_region current;
529
530 void (*flush) (r200ContextPtr);
531
532 char *buf0_address; /* start of buf[0], for index calcs */
533 GLuint nr_released_bufs; /* flush after so many buffers released */
534 };
535
536 #define R200_CMD_BUF_SZ (8*1024)
537
538 struct r200_store {
539 GLuint statenr;
540 GLuint primnr;
541 char cmd_buf[R200_CMD_BUF_SZ];
542 int cmd_used;
543 int elts_start;
544 };
545
546 /* r200_tcl.c
547 */
548 struct r200_tcl_info {
549 GLuint vertex_format;
550 GLint last_offset;
551 GLuint hw_primitive;
552
553 struct r200_dma_region *aos_components[8];
554 GLuint nr_aos_components;
555
556 GLuint *Elts;
557
558 struct r200_dma_region indexed_verts;
559 struct r200_dma_region obj;
560 struct r200_dma_region rgba;
561 struct r200_dma_region spec;
562 struct r200_dma_region fog;
563 struct r200_dma_region tex[R200_MAX_TEXTURE_UNITS];
564 struct r200_dma_region norm;
565 };
566
567 /* r200_swtcl.c
568 */
569 struct r200_swtcl_info {
570 GLuint RenderIndex;
571
572 /**
573 * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is
574 * installed in the Mesa state vector.
575 */
576 GLuint vertex_size;
577
578 /**
579 * Attributes instructing the Mesa TCL pipeline where / how to put vertex
580 * data in the hardware buffer.
581 */
582 struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
583
584 /**
585 * Number of elements of \c ::vertex_attrs that are actually used.
586 */
587 GLuint vertex_attr_count;
588
589 /**
590 * Cached pointer to the buffer where Mesa will store vertex data.
591 */
592 GLubyte *verts;
593
594 /* Fallback rasterization functions
595 */
596 r200_point_func draw_point;
597 r200_line_func draw_line;
598 r200_tri_func draw_tri;
599
600 GLuint hw_primitive;
601 GLenum render_primitive;
602 GLuint numverts;
603
604 /**
605 * Offset of the 4UB color data within a hardware (swtcl) vertex.
606 */
607 GLuint coloroffset;
608
609 /**
610 * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
611 */
612 GLuint specoffset;
613
614 /**
615 * Should Mesa project vertex data or will the hardware do it?
616 */
617 GLboolean needproj;
618
619 struct r200_dma_region indexed_verts;
620 };
621
622 struct r200_ioctl {
623 GLuint vertex_offset;
624 GLuint vertex_size;
625 };
626
627 #define R200_MAX_PRIMS 64
628
629 /* Want to keep a cache of these around. Each is parameterized by
630 * only a single value which has only a small range. Only expect a
631 * few, so just rescan the list each time?
632 */
633 struct dynfn {
634 struct dynfn *next, *prev;
635 int key[2];
636 char *code;
637 };
638
639 struct dfn_lists {
640 struct dynfn Vertex2f;
641 struct dynfn Vertex2fv;
642 struct dynfn Vertex3f;
643 struct dynfn Vertex3fv;
644 struct dynfn Color4ub;
645 struct dynfn Color4ubv;
646 struct dynfn Color3ub;
647 struct dynfn Color3ubv;
648 struct dynfn Color4f;
649 struct dynfn Color4fv;
650 struct dynfn Color3f;
651 struct dynfn Color3fv;
652 struct dynfn SecondaryColor3ubEXT;
653 struct dynfn SecondaryColor3ubvEXT;
654 struct dynfn SecondaryColor3fEXT;
655 struct dynfn SecondaryColor3fvEXT;
656 struct dynfn Normal3f;
657 struct dynfn Normal3fv;
658 struct dynfn TexCoord3f;
659 struct dynfn TexCoord3fv;
660 struct dynfn TexCoord2f;
661 struct dynfn TexCoord2fv;
662 struct dynfn TexCoord1f;
663 struct dynfn TexCoord1fv;
664 struct dynfn MultiTexCoord3fARB;
665 struct dynfn MultiTexCoord3fvARB;
666 struct dynfn MultiTexCoord2fARB;
667 struct dynfn MultiTexCoord2fvARB;
668 struct dynfn MultiTexCoord1fARB;
669 struct dynfn MultiTexCoord1fvARB;
670 };
671
672 struct dfn_generators {
673 struct dynfn *(*Vertex2f) (GLcontext *, const int *);
674 struct dynfn *(*Vertex2fv) (GLcontext *, const int *);
675 struct dynfn *(*Vertex3f) (GLcontext *, const int *);
676 struct dynfn *(*Vertex3fv) (GLcontext *, const int *);
677 struct dynfn *(*Color4ub) (GLcontext *, const int *);
678 struct dynfn *(*Color4ubv) (GLcontext *, const int *);
679 struct dynfn *(*Color3ub) (GLcontext *, const int *);
680 struct dynfn *(*Color3ubv) (GLcontext *, const int *);
681 struct dynfn *(*Color4f) (GLcontext *, const int *);
682 struct dynfn *(*Color4fv) (GLcontext *, const int *);
683 struct dynfn *(*Color3f) (GLcontext *, const int *);
684 struct dynfn *(*Color3fv) (GLcontext *, const int *);
685 struct dynfn *(*SecondaryColor3ubEXT) (GLcontext *, const int *);
686 struct dynfn *(*SecondaryColor3ubvEXT) (GLcontext *, const int *);
687 struct dynfn *(*SecondaryColor3fEXT) (GLcontext *, const int *);
688 struct dynfn *(*SecondaryColor3fvEXT) (GLcontext *, const int *);
689 struct dynfn *(*Normal3f) (GLcontext *, const int *);
690 struct dynfn *(*Normal3fv) (GLcontext *, const int *);
691 struct dynfn *(*TexCoord3f) (GLcontext *, const int *);
692 struct dynfn *(*TexCoord3fv) (GLcontext *, const int *);
693 struct dynfn *(*TexCoord2f) (GLcontext *, const int *);
694 struct dynfn *(*TexCoord2fv) (GLcontext *, const int *);
695 struct dynfn *(*TexCoord1f) (GLcontext *, const int *);
696 struct dynfn *(*TexCoord1fv) (GLcontext *, const int *);
697 struct dynfn *(*MultiTexCoord3fARB) (GLcontext *, const int *);
698 struct dynfn *(*MultiTexCoord3fvARB) (GLcontext *, const int *);
699 struct dynfn *(*MultiTexCoord2fARB) (GLcontext *, const int *);
700 struct dynfn *(*MultiTexCoord2fvARB) (GLcontext *, const int *);
701 struct dynfn *(*MultiTexCoord1fARB) (GLcontext *, const int *);
702 struct dynfn *(*MultiTexCoord1fvARB) (GLcontext *, const int *);
703 };
704
705 struct r200_prim {
706 GLuint start;
707 GLuint end;
708 GLuint prim;
709 };
710
711 /* A maximum total of 29 elements per vertex: 3 floats for position, 3
712 * floats for normal, 4 floats for color, 4 bytes for secondary color,
713 * 3 floats for each texture unit (18 floats total).
714 *
715 * we maybe need add. 4 to prevent segfault if someone specifies
716 * GL_TEXTURE6/GL_TEXTURE7 (esp. for the codegen-path) (FIXME: )
717 *
718 * The position data is never actually stored here, so 3 elements could be
719 * trimmed out of the buffer.
720 */
721
722 #define R200_MAX_VERTEX_SIZE ((3*6)+11)
723
724 struct r200_vbinfo {
725 GLint counter, initial_counter;
726 GLint *dmaptr;
727 void (*notify) (void);
728 GLint vertex_size;
729
730 union {
731 float f;
732 int i;
733 r200_color_t color;
734 } vertex[R200_MAX_VERTEX_SIZE];
735
736 GLfloat *normalptr;
737 GLfloat *floatcolorptr;
738 r200_color_t *colorptr;
739 GLfloat *floatspecptr;
740 r200_color_t *specptr;
741 GLfloat *texcoordptr[8]; /* 6 (TMU) + 2 for r200_vtxfmt_c.c when GL_TEXTURE6/7 */
742
743 GLenum *prim; /* &ctx->Driver.CurrentExecPrimitive */
744 GLuint primflags;
745 GLboolean enabled; /* *_NO_VTXFMT / *_NO_TCL env vars */
746 GLboolean installed;
747 GLboolean fell_back;
748 GLboolean recheck;
749 GLint nrverts;
750 GLuint vtxfmt_0, vtxfmt_1;
751
752 GLuint installed_vertex_format;
753 GLuint installed_color_3f_sz;
754
755 struct r200_prim primlist[R200_MAX_PRIMS];
756 int nrprims;
757
758 struct dfn_lists dfn_cache;
759 struct dfn_generators codegen;
760 GLvertexformat vtxfmt;
761 };
762
763 /**
764 * R200 context structure.
765 */
766 struct r200_context {
767 struct radeon_context radeon; /* parent class, must be first */
768
769 /* Driver and hardware state management
770 */
771 struct r200_hw_state hw;
772 struct r200_state state;
773
774 /* Texture object bookkeeping
775 */
776 unsigned nr_heaps;
777 driTexHeap *texture_heaps[R200_NR_TEX_HEAPS];
778 driTextureObject swapped;
779 int texture_depth;
780 float initialMaxAnisotropy;
781
782 /* Rasterization and vertex state:
783 */
784 GLuint NewGLState;
785
786 /* Vertex buffers
787 */
788 struct r200_ioctl ioctl;
789 struct r200_dma dma;
790 struct r200_store store;
791 GLboolean save_on_next_unlock;
792
793 /* Clientdata textures;
794 */
795 GLuint prefer_gart_client_texturing;
796
797 /* TCL stuff
798 */
799 GLmatrix TexGenMatrix[R200_MAX_TEXTURE_UNITS];
800 GLboolean recheck_texgen[R200_MAX_TEXTURE_UNITS];
801 GLboolean TexGenNeedNormals[R200_MAX_TEXTURE_UNITS];
802 GLuint TexMatEnabled;
803 GLuint TexMatCompSel;
804 GLuint TexGenEnabled;
805 GLuint TexGenInputs;
806 GLuint TexGenCompSel;
807 GLmatrix tmpmat;
808
809 /* r200_tcl.c
810 */
811 struct r200_tcl_info tcl;
812
813 /* r200_swtcl.c
814 */
815 struct r200_swtcl_info swtcl;
816
817 /* r200_vtxfmt.c
818 */
819 struct r200_vbinfo vb;
820 };
821
822 #define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx))
823
824 extern void r200DestroyContext(__DRIcontextPrivate * driContextPriv);
825 extern GLboolean r200CreateContext(const __GLcontextModes * glVisual,
826 __DRIcontextPrivate * driContextPriv,
827 void *sharedContextPrivate);
828
829 #endif
830 #endif /* __R200_CONTEXT_H__ */