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