1 /* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
3 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
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.
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:
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.
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.
29 **************************************************************************/
33 * Keith Whitwell <keith@tungstengraphics.com>
36 #ifndef __R200_CONTEXT_H__
37 #define __R200_CONTEXT_H__
39 #include "tnl/t_vertex.h"
41 #include "radeon_drm.h"
50 #define ENABLE_HW_3D_TEXTURE 1 /* XXX this is temporary! */
53 typedef struct r200_context r200ContextRec
;
54 typedef struct r200_context
*r200ContextPtr
;
56 #include "r200_lock.h"
57 #include "r200_screen.h"
60 /* Flags for software fallback cases */
61 /* See correponding strings in r200_swtcl.c */
62 #define R200_FALLBACK_TEXTURE 0x01
63 #define R200_FALLBACK_DRAW_BUFFER 0x02
64 #define R200_FALLBACK_STENCIL 0x04
65 #define R200_FALLBACK_RENDER_MODE 0x08
66 #define R200_FALLBACK_DISABLE 0x10
67 #define R200_FALLBACK_BORDER_MODE 0x20
69 /* The blit width for texture uploads
71 #define BLIT_WIDTH_BYTES 1024
73 /* Use the templated vertex format:
76 #define TAG(x) r200##x
77 #include "tnl_dd/t_dd_vertex.h"
80 typedef void (*r200_tri_func
)( r200ContextPtr
,
85 typedef void (*r200_line_func
)( r200ContextPtr
,
89 typedef void (*r200_point_func
)( r200ContextPtr
,
93 struct r200_colorbuffer_state
{
96 GLint drawOffset
, drawPitch
;
102 struct r200_depthbuffer_state
{
108 struct r200_pixel_state
{
109 GLint readOffset
, readPitch
;
113 struct r200_scissor_state
{
114 drm_clip_rect_t rect
;
117 GLuint numClipRects
; /* Cliprects active */
118 GLuint numAllocedClipRects
; /* Cliprects available */
119 drm_clip_rect_t
*pClipRects
;
122 struct r200_stencilbuffer_state
{
124 GLuint clear
; /* rb3d_stencilrefmask value */
127 struct r200_stipple_state
{
141 typedef struct r200_tex_obj r200TexObj
, *r200TexObjPtr
;
143 /* Texture object in locally shared texture space.
145 struct r200_tex_obj
{
146 driTextureObject base
;
148 GLuint bufAddr
; /* Offset to start of locally
149 shared texture block */
151 GLuint dirty_state
; /* Flags (1 per texunit) for
152 whether or not this texobj
153 has dirty hardware state
154 (pp_*) that needs to be
158 drm_radeon_tex_image_t image
[6][RADEON_MAX_TEXTURE_LEVELS
];
159 /* Six, for the cube faces */
161 GLuint pp_txfilter
; /* hardware register values */
163 GLuint pp_txformat_x
;
164 GLuint pp_txoffset
; /* Image location in texmem.
165 All cube faces follow. */
166 GLuint pp_txsize
; /* npot only */
167 GLuint pp_txpitch
; /* npot only */
168 GLuint pp_border_color
;
169 GLuint pp_cubic_faces
; /* cube face 1,2,3,4 log2 sizes */
171 GLboolean border_fallback
;
173 GLuint tile_bits
; /* hw texture tile bits used on this texture */
177 struct r200_texture_env_state
{
178 r200TexObjPtr texobj
;
183 #define R200_MAX_TEXTURE_UNITS 6
185 struct r200_texture_state
{
186 struct r200_texture_env_state unit
[R200_MAX_TEXTURE_UNITS
];
190 struct r200_state_atom
{
191 struct r200_state_atom
*next
, *prev
;
192 const char *name
; /* for debug */
193 int cmd_size
; /* size in bytes */
195 int *cmd
; /* one or more cmd's */
196 int *lastcmd
; /* one or more cmd's */
198 GLboolean (*check
)( GLcontext
*, int ); /* is this state active? */
203 /* Trying to keep these relatively short as the variables are becoming
204 * extravagently long. Drop the driver name prefix off the front of
205 * everything - I think we know which driver we're in by now, and keep the
206 * prefix to 3 letters unless absolutely impossible.
210 #define CTX_PP_MISC 1
211 #define CTX_PP_FOG_COLOR 2
212 #define CTX_RE_SOLID_COLOR 3
213 #define CTX_RB3D_BLENDCNTL 4
214 #define CTX_RB3D_DEPTHOFFSET 5
215 #define CTX_RB3D_DEPTHPITCH 6
216 #define CTX_RB3D_ZSTENCILCNTL 7
218 #define CTX_PP_CNTL 9
219 #define CTX_RB3D_CNTL 10
220 #define CTX_RB3D_COLOROFFSET 11
221 #define CTX_CMD_2 12 /* why */
222 #define CTX_RB3D_COLORPITCH 13 /* why */
223 #define CTX_STATE_SIZE_OLDDRM 14
225 #define CTX_RB3D_BLENDCOLOR 15
226 #define CTX_RB3D_ABLENDCNTL 16
227 #define CTX_RB3D_CBLENDCNTL 17
228 #define CTX_STATE_SIZE_NEWDRM 18
231 #define SET_SE_CNTL 1
232 #define SET_RE_CNTL 2 /* replace se_coord_fmt */
233 #define SET_STATE_SIZE 3
236 #define VTE_SE_VTE_CNTL 1
237 #define VTE_STATE_SIZE 2
240 #define LIN_RE_LINE_PATTERN 1
241 #define LIN_RE_LINE_STATE 2
243 #define LIN_SE_LINE_WIDTH 4
244 #define LIN_STATE_SIZE 5
247 #define MSK_RB3D_STENCILREFMASK 1
248 #define MSK_RB3D_ROPCNTL 2
249 #define MSK_RB3D_PLANEMASK 3
250 #define MSK_STATE_SIZE 4
253 #define VPT_SE_VPORT_XSCALE 1
254 #define VPT_SE_VPORT_XOFFSET 2
255 #define VPT_SE_VPORT_YSCALE 3
256 #define VPT_SE_VPORT_YOFFSET 4
257 #define VPT_SE_VPORT_ZSCALE 5
258 #define VPT_SE_VPORT_ZOFFSET 6
259 #define VPT_STATE_SIZE 7
262 #define ZBS_SE_ZBIAS_FACTOR 1
263 #define ZBS_SE_ZBIAS_CONSTANT 2
264 #define ZBS_STATE_SIZE 3
267 #define MSC_RE_MISC 1
268 #define MSC_STATE_SIZE 2
272 #define TAM_STATE_SIZE 2
275 #define TEX_PP_TXFILTER 1 /*2c00*/
276 #define TEX_PP_TXFORMAT 2 /*2c04*/
277 #define TEX_PP_TXFORMAT_X 3 /*2c08*/
278 #define TEX_PP_TXSIZE 4 /*2c0c*/
279 #define TEX_PP_TXPITCH 5 /*2c10*/
280 #define TEX_PP_BORDER_COLOR 6 /*2c14*/
282 #define TEX_PP_TXOFFSET 8 /*2d00 */
283 #define TEX_STATE_SIZE 9
285 #define CUBE_CMD_0 0 /* 1 register follows */
286 #define CUBE_PP_CUBIC_FACES 1 /* 0x2c18 */
287 #define CUBE_CMD_1 2 /* 5 registers follow */
288 #define CUBE_PP_CUBIC_OFFSET_F1 3 /* 0x2d04 */
289 #define CUBE_PP_CUBIC_OFFSET_F2 4 /* 0x2d08 */
290 #define CUBE_PP_CUBIC_OFFSET_F3 5 /* 0x2d0c */
291 #define CUBE_PP_CUBIC_OFFSET_F4 6 /* 0x2d10 */
292 #define CUBE_PP_CUBIC_OFFSET_F5 7 /* 0x2d14 */
293 #define CUBE_STATE_SIZE 8
296 #define PIX_PP_TXCBLEND 1
297 #define PIX_PP_TXCBLEND2 2
298 #define PIX_PP_TXABLEND 3
299 #define PIX_PP_TXABLEND2 4
300 #define PIX_STATE_SIZE 5
303 #define TF_TFACTOR_0 1
304 #define TF_TFACTOR_1 2
305 #define TF_TFACTOR_2 3
306 #define TF_TFACTOR_3 4
307 #define TF_TFACTOR_4 5
308 #define TF_TFACTOR_5 6
309 #define TF_STATE_SIZE 7
312 #define TCL_LIGHT_MODEL_CTL_0 1
313 #define TCL_LIGHT_MODEL_CTL_1 2
314 #define TCL_PER_LIGHT_CTL_0 3
315 #define TCL_PER_LIGHT_CTL_1 4
316 #define TCL_PER_LIGHT_CTL_2 5
317 #define TCL_PER_LIGHT_CTL_3 6
319 #define TCL_UCP_VERT_BLEND_CTL 8
320 #define TCL_STATE_SIZE 9
323 #define MSL_MATRIX_SELECT_0 1
324 #define MSL_MATRIX_SELECT_1 2
325 #define MSL_MATRIX_SELECT_2 3
326 #define MSL_MATRIX_SELECT_3 4
327 #define MSL_MATRIX_SELECT_4 5
328 #define MSL_STATE_SIZE 6
331 #define TCG_TEX_PROC_CTL_2 1
332 #define TCG_TEX_PROC_CTL_3 2
333 #define TCG_TEX_PROC_CTL_0 3
334 #define TCG_TEX_PROC_CTL_1 4
335 #define TCG_TEX_CYL_WRAP_CTL 5
336 #define TCG_STATE_SIZE 6
339 #define MTL_EMMISSIVE_RED 1
340 #define MTL_EMMISSIVE_GREEN 2
341 #define MTL_EMMISSIVE_BLUE 3
342 #define MTL_EMMISSIVE_ALPHA 4
343 #define MTL_AMBIENT_RED 5
344 #define MTL_AMBIENT_GREEN 6
345 #define MTL_AMBIENT_BLUE 7
346 #define MTL_AMBIENT_ALPHA 8
347 #define MTL_DIFFUSE_RED 9
348 #define MTL_DIFFUSE_GREEN 10
349 #define MTL_DIFFUSE_BLUE 11
350 #define MTL_DIFFUSE_ALPHA 12
351 #define MTL_SPECULAR_RED 13
352 #define MTL_SPECULAR_GREEN 14
353 #define MTL_SPECULAR_BLUE 15
354 #define MTL_SPECULAR_ALPHA 16
356 #define MTL_SHININESS 18
357 #define MTL_STATE_SIZE 19
360 #define VAP_SE_VAP_CNTL 1
361 #define VAP_STATE_SIZE 2
363 /* Replaces a lot of packet info from radeon
366 #define VTX_VTXFMT_0 1
367 #define VTX_VTXFMT_1 2
368 #define VTX_TCL_OUTPUT_VTXFMT_0 3
369 #define VTX_TCL_OUTPUT_VTXFMT_1 4
371 #define VTX_TCL_OUTPUT_COMPSEL 6
373 #define VTX_STATE_CNTL 8
374 #define VTX_STATE_SIZE 9
377 #define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\
381 * Given the \c R200_SE_VTX_FMT_1 for the current vertex state, determine
382 * how many components are in texture coordinate \c n.
384 #define VTX_TEXn_COUNT(v,n) (((v) >> (3 * n)) & 0x07)
388 #define MAT_STATE_SIZE 17
391 #define GRD_VERT_GUARD_CLIP_ADJ 1
392 #define GRD_VERT_GUARD_DISCARD_ADJ 2
393 #define GRD_HORZ_GUARD_CLIP_ADJ 3
394 #define GRD_HORZ_GUARD_DISCARD_ADJ 4
395 #define GRD_STATE_SIZE 5
397 /* position changes frequently when lighting in modelpos - separate
398 * out to new state item?
401 #define LIT_AMBIENT_RED 1
402 #define LIT_AMBIENT_GREEN 2
403 #define LIT_AMBIENT_BLUE 3
404 #define LIT_AMBIENT_ALPHA 4
405 #define LIT_DIFFUSE_RED 5
406 #define LIT_DIFFUSE_GREEN 6
407 #define LIT_DIFFUSE_BLUE 7
408 #define LIT_DIFFUSE_ALPHA 8
409 #define LIT_SPECULAR_RED 9
410 #define LIT_SPECULAR_GREEN 10
411 #define LIT_SPECULAR_BLUE 11
412 #define LIT_SPECULAR_ALPHA 12
413 #define LIT_POSITION_X 13
414 #define LIT_POSITION_Y 14
415 #define LIT_POSITION_Z 15
416 #define LIT_POSITION_W 16
417 #define LIT_DIRECTION_X 17
418 #define LIT_DIRECTION_Y 18
419 #define LIT_DIRECTION_Z 19
420 #define LIT_DIRECTION_W 20
421 #define LIT_ATTEN_QUADRATIC 21
422 #define LIT_ATTEN_LINEAR 22
423 #define LIT_ATTEN_CONST 23
424 #define LIT_ATTEN_XXX 24
426 #define LIT_SPOT_DCD 26
427 #define LIT_SPOT_DCM 27
428 #define LIT_SPOT_EXPONENT 28
429 #define LIT_SPOT_CUTOFF 29
430 #define LIT_SPECULAR_THRESH 30
431 #define LIT_RANGE_CUTOFF 31 /* ? */
432 #define LIT_ATTEN_CONST_INV 32
433 #define LIT_STATE_SIZE 33
442 #define FOG_STATE_SIZE 5
451 #define UCP_STATE_SIZE 5
453 /* GLT - Global ambient
460 #define GLT_STATE_SIZE 5
468 #define EYE_RESCALE_FACTOR 4
469 #define EYE_STATE_SIZE 5
471 /* CST - constant state
474 #define CST_PP_CNTL_X 1
476 #define CST_RB3D_DEPTHXY_OFFSET 3
478 #define CST_RE_AUX_SCISSOR_CNTL 5
480 #define CST_RE_SCISSOR_TL_0 7
481 #define CST_RE_SCISSOR_BR_0 8
483 #define CST_SE_VAP_CNTL_STATUS 10
485 #define CST_RE_POINTSIZE 12
487 #define CST_SE_TCL_INPUT_VTX_0 14
488 #define CST_SE_TCL_INPUT_VTX_1 15
489 #define CST_SE_TCL_INPUT_VTX_2 16
490 #define CST_SE_TCL_INPUT_VTX_3 17
491 #define CST_STATE_SIZE 18
494 #define PRF_PP_TRI_PERF 1
495 #define PRF_PP_PERF_CNTL 2
496 #define PRF_STATE_SIZE 3
499 struct r200_hw_state
{
500 /* Head of the linked list of state atoms. */
501 struct r200_state_atom atomlist
;
503 /* Hardware state, stored as cmdbuf commands:
504 * -- Need to doublebuffer for
505 * - reviving state after loss of context
506 * - eliding noop statechange loops? (except line stipple count)
508 struct r200_state_atom ctx
;
509 struct r200_state_atom set
;
510 struct r200_state_atom vte
;
511 struct r200_state_atom lin
;
512 struct r200_state_atom msk
;
513 struct r200_state_atom vpt
;
514 struct r200_state_atom vap
;
515 struct r200_state_atom vtx
;
516 struct r200_state_atom tcl
;
517 struct r200_state_atom msl
;
518 struct r200_state_atom tcg
;
519 struct r200_state_atom msc
;
520 struct r200_state_atom cst
;
521 struct r200_state_atom tam
;
522 struct r200_state_atom tf
;
523 struct r200_state_atom tex
[6];
524 struct r200_state_atom cube
[6];
525 struct r200_state_atom zbs
;
526 struct r200_state_atom mtl
[2];
527 struct r200_state_atom mat
[9];
528 struct r200_state_atom lit
[8]; /* includes vec, scl commands */
529 struct r200_state_atom ucp
[6];
530 struct r200_state_atom pix
[6]; /* pixshader stages */
531 struct r200_state_atom eye
; /* eye pos */
532 struct r200_state_atom grd
; /* guard band clipping */
533 struct r200_state_atom fog
;
534 struct r200_state_atom glt
;
535 struct r200_state_atom prf
;
537 int max_state_size
; /* Number of bytes necessary for a full state emit. */
538 GLboolean is_dirty
, all_dirty
;
542 /* Derived state for internal purposes:
544 struct r200_colorbuffer_state color
;
545 struct r200_depthbuffer_state depth
;
547 struct r200_pixel_state pixel
;
549 struct r200_scissor_state scissor
;
550 struct r200_stencilbuffer_state stencil
;
551 struct r200_stipple_state stipple
;
552 struct r200_texture_state texture
;
556 /* Need refcounting on dma buffers:
558 struct r200_dma_buffer
{
559 int refcount
; /* the number of retained regions in buf */
563 #define GET_START(rvb) (rmesa->r200Screen->gart_buffer_offset + \
564 (rvb)->address - rmesa->dma.buf0_address + \
567 /* A retained region, eg vertices for indexed vertices.
569 struct r200_dma_region
{
570 struct r200_dma_buffer
*buf
;
571 char *address
; /* == buf->address */
572 int start
, end
, ptr
; /* offsets from start of buf */
580 /* Active dma region. Allocations for vertices and retained
581 * regions come from here. Also used for emitting random vertices,
582 * these may be flushed by calling flush_current();
584 struct r200_dma_region current
;
586 void (*flush
)( r200ContextPtr
);
588 char *buf0_address
; /* start of buf[0], for index calcs */
589 GLuint nr_released_bufs
; /* flush after so many buffers released */
592 struct r200_dri_mirror
{
593 __DRIcontextPrivate
*context
; /* DRI context */
594 __DRIscreenPrivate
*screen
; /* DRI screen */
595 __DRIdrawablePrivate
*drawable
; /* DRI drawable bound to this ctx */
597 drm_context_t hwContext
;
598 drm_hw_lock_t
*hwLock
;
604 #define R200_CMD_BUF_SZ (8*1024)
609 char cmd_buf
[R200_CMD_BUF_SZ
];
617 struct r200_tcl_info
{
618 GLuint vertex_format
;
622 struct r200_dma_region
*aos_components
[8];
623 GLuint nr_aos_components
;
627 struct r200_dma_region indexed_verts
;
628 struct r200_dma_region obj
;
629 struct r200_dma_region rgba
;
630 struct r200_dma_region spec
;
631 struct r200_dma_region fog
;
632 struct r200_dma_region tex
[R200_MAX_TEXTURE_UNITS
];
633 struct r200_dma_region norm
;
639 struct r200_swtcl_info
{
643 * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is
644 * installed in the Mesa state vector.
649 * Attributes instructing the Mesa TCL pipeline where / how to put vertex
650 * data in the hardware buffer.
652 struct tnl_attr_map vertex_attrs
[VERT_ATTRIB_MAX
];
655 * Number of elements of \c ::vertex_attrs that are actually used.
657 GLuint vertex_attr_count
;
660 * Cached pointer to the buffer where Mesa will store vertex data.
664 /* Fallback rasterization functions
666 r200_point_func draw_point
;
667 r200_line_func draw_line
;
668 r200_tri_func draw_tri
;
671 GLenum render_primitive
;
675 * Offset of the 4UB color data within a hardware (swtcl) vertex.
680 * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
685 * Should Mesa project vertex data or will the hardware do it?
689 struct r200_dma_region indexed_verts
;
694 GLuint vertex_offset
;
700 #define R200_MAX_PRIMS 64
703 /* Want to keep a cache of these around. Each is parameterized by
704 * only a single value which has only a small range. Only expect a
705 * few, so just rescan the list each time?
708 struct dynfn
*next
, *prev
;
714 struct dynfn Vertex2f
;
715 struct dynfn Vertex2fv
;
716 struct dynfn Vertex3f
;
717 struct dynfn Vertex3fv
;
718 struct dynfn Color4ub
;
719 struct dynfn Color4ubv
;
720 struct dynfn Color3ub
;
721 struct dynfn Color3ubv
;
722 struct dynfn Color4f
;
723 struct dynfn Color4fv
;
724 struct dynfn Color3f
;
725 struct dynfn Color3fv
;
726 struct dynfn SecondaryColor3ubEXT
;
727 struct dynfn SecondaryColor3ubvEXT
;
728 struct dynfn SecondaryColor3fEXT
;
729 struct dynfn SecondaryColor3fvEXT
;
730 struct dynfn Normal3f
;
731 struct dynfn Normal3fv
;
732 struct dynfn TexCoord3f
;
733 struct dynfn TexCoord3fv
;
734 struct dynfn TexCoord2f
;
735 struct dynfn TexCoord2fv
;
736 struct dynfn TexCoord1f
;
737 struct dynfn TexCoord1fv
;
738 struct dynfn MultiTexCoord3fARB
;
739 struct dynfn MultiTexCoord3fvARB
;
740 struct dynfn MultiTexCoord2fARB
;
741 struct dynfn MultiTexCoord2fvARB
;
742 struct dynfn MultiTexCoord1fARB
;
743 struct dynfn MultiTexCoord1fvARB
;
744 struct dynfn FogCoordfEXT
;
745 struct dynfn FogCoordfvEXT
;
748 struct dfn_generators
{
749 struct dynfn
*(*Vertex2f
)( GLcontext
*, const int * );
750 struct dynfn
*(*Vertex2fv
)( GLcontext
*, const int * );
751 struct dynfn
*(*Vertex3f
)( GLcontext
*, const int * );
752 struct dynfn
*(*Vertex3fv
)( GLcontext
*, const int * );
753 struct dynfn
*(*Color4ub
)( GLcontext
*, const int * );
754 struct dynfn
*(*Color4ubv
)( GLcontext
*, const int * );
755 struct dynfn
*(*Color3ub
)( GLcontext
*, const int * );
756 struct dynfn
*(*Color3ubv
)( GLcontext
*, const int * );
757 struct dynfn
*(*Color4f
)( GLcontext
*, const int * );
758 struct dynfn
*(*Color4fv
)( GLcontext
*, const int * );
759 struct dynfn
*(*Color3f
)( GLcontext
*, const int * );
760 struct dynfn
*(*Color3fv
)( GLcontext
*, const int * );
761 struct dynfn
*(*SecondaryColor3ubEXT
)( GLcontext
*, const int * );
762 struct dynfn
*(*SecondaryColor3ubvEXT
)( GLcontext
*, const int * );
763 struct dynfn
*(*SecondaryColor3fEXT
)( GLcontext
*, const int * );
764 struct dynfn
*(*SecondaryColor3fvEXT
)( GLcontext
*, const int * );
765 struct dynfn
*(*Normal3f
)( GLcontext
*, const int * );
766 struct dynfn
*(*Normal3fv
)( GLcontext
*, const int * );
767 struct dynfn
*(*TexCoord3f
)( GLcontext
*, const int * );
768 struct dynfn
*(*TexCoord3fv
)( GLcontext
*, const int * );
769 struct dynfn
*(*TexCoord2f
)( GLcontext
*, const int * );
770 struct dynfn
*(*TexCoord2fv
)( GLcontext
*, const int * );
771 struct dynfn
*(*TexCoord1f
)( GLcontext
*, const int * );
772 struct dynfn
*(*TexCoord1fv
)( GLcontext
*, const int * );
773 struct dynfn
*(*MultiTexCoord3fARB
)( GLcontext
*, const int * );
774 struct dynfn
*(*MultiTexCoord3fvARB
)( GLcontext
*, const int * );
775 struct dynfn
*(*MultiTexCoord2fARB
)( GLcontext
*, const int * );
776 struct dynfn
*(*MultiTexCoord2fvARB
)( GLcontext
*, const int * );
777 struct dynfn
*(*MultiTexCoord1fARB
)( GLcontext
*, const int * );
778 struct dynfn
*(*MultiTexCoord1fvARB
)( GLcontext
*, const int * );
779 struct dynfn
*(*FogCoordfEXT
)( GLcontext
*, const int * );
780 struct dynfn
*(*FogCoordfvEXT
)( GLcontext
*, const int * );
791 /* A maximum total of 29 elements per vertex: 3 floats for position, 3
792 * floats for normal, 4 floats for color, 4 bytes for secondary color,
793 * 3 floats for each texture unit (18 floats total).
795 * we maybe need add. 4 to prevent segfault if someone specifies
796 * GL_TEXTURE6/GL_TEXTURE7 (esp. for the codegen-path) (FIXME: )
798 * The position data is never actually stored here, so 3 elements could be
799 * trimmed out of the buffer.
802 #define R200_MAX_VERTEX_SIZE ((3*6)+11)
805 GLint counter
, initial_counter
;
807 void (*notify
)( void );
810 union { float f
; int i
; r200_color_t color
; } vertex
[R200_MAX_VERTEX_SIZE
];
813 GLfloat
*floatcolorptr
;
815 r200_color_t
*colorptr
;
816 GLfloat
*floatspecptr
;
817 r200_color_t
*specptr
;
818 GLfloat
*texcoordptr
[8]; /* 6 (TMU) + 2 for r200_vtxfmt_c.c when GL_TEXTURE6/7 */
821 GLenum
*prim
; /* &ctx->Driver.CurrentExecPrimitive */
823 GLboolean enabled
; /* *_NO_VTXFMT / *_NO_TCL env vars */
828 GLuint vtxfmt_0
, vtxfmt_1
;
830 GLuint installed_vertex_format
;
831 GLuint installed_color_3f_sz
;
833 struct r200_prim primlist
[R200_MAX_PRIMS
];
836 struct dfn_lists dfn_cache
;
837 struct dfn_generators codegen
;
838 GLvertexformat vtxfmt
;
842 struct r200_context
{
843 GLcontext
*glCtx
; /* Mesa context */
845 /* Driver and hardware state management
847 struct r200_hw_state hw
;
848 struct r200_state state
;
850 /* Texture object bookkeeping
853 driTexHeap
* texture_heaps
[ R200_NR_TEX_HEAPS
];
854 driTextureObject swapped
;
856 float initialMaxAnisotropy
;
858 /* Rasterization and vertex state:
863 GLuint tnl_index
; /* index of bits for last tnl_install_attrs */
867 struct r200_ioctl ioctl
;
869 struct r200_store store
;
870 /* A full state emit as of the first state emit in the main store, in case
871 * the context is lost.
873 struct r200_store backup_store
;
884 drm_radeon_irq_wait_t iw
;
886 /* Clientdata textures;
888 GLuint prefer_gart_client_texturing
;
890 /* Drawable, cliprect and scissor information
892 GLuint numClipRects
; /* Cliprects for the draw buffer */
893 drm_clip_rect_t
*pClipRects
;
894 unsigned int lastStamp
;
895 GLboolean lost_context
;
896 GLboolean save_on_next_emit
;
897 r200ScreenPtr r200Screen
; /* Screen private DRI data */
898 drm_radeon_sarea_t
*sarea
; /* Private SAREA data */
902 GLmatrix TexGenMatrix
[R200_MAX_TEXTURE_UNITS
];
903 GLboolean recheck_texgen
[R200_MAX_TEXTURE_UNITS
];
904 GLboolean TexGenNeedNormals
[R200_MAX_TEXTURE_UNITS
];
905 GLuint TexMatEnabled
;
906 GLuint TexMatCompSel
;
907 GLuint TexGenEnabled
;
908 GLuint TexGenCompSel
;
917 int64_t swap_missed_ust
;
920 GLuint swap_missed_count
;
925 struct r200_tcl_info tcl
;
929 struct r200_swtcl_info swtcl
;
933 struct r200_vbinfo vb
;
935 /* Mirrors of some DRI state
937 struct r200_dri_mirror dri
;
939 /* Configuration cache
941 driOptionCache optionCache
;
943 GLboolean using_hyperz
;
944 GLboolean texmicrotile
;
947 #define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx))
950 static __inline GLuint
r200PackColor( GLuint cpp
,
951 GLubyte r
, GLubyte g
,
952 GLubyte b
, GLubyte a
)
956 return PACK_COLOR_565( r
, g
, b
);
958 return PACK_COLOR_8888( a
, r
, g
, b
);
965 extern void r200DestroyContext( __DRIcontextPrivate
*driContextPriv
);
966 extern GLboolean
r200CreateContext( const __GLcontextModes
*glVisual
,
967 __DRIcontextPrivate
*driContextPriv
,
968 void *sharedContextPrivate
);
969 extern void r200SwapBuffers( __DRIdrawablePrivate
*dPriv
);
970 extern GLboolean
r200MakeCurrent( __DRIcontextPrivate
*driContextPriv
,
971 __DRIdrawablePrivate
*driDrawPriv
,
972 __DRIdrawablePrivate
*driReadPriv
);
973 extern GLboolean
r200UnbindContext( __DRIcontextPrivate
*driContextPriv
);
975 /* ================================================================
981 extern int R200_DEBUG
;
986 #define DEBUG_TEXTURE 0x001
987 #define DEBUG_STATE 0x002
988 #define DEBUG_IOCTL 0x004
989 #define DEBUG_PRIMS 0x008
990 #define DEBUG_VERTS 0x010
991 #define DEBUG_FALLBACKS 0x020
992 #define DEBUG_VFMT 0x040
993 #define DEBUG_CODEGEN 0x080
994 #define DEBUG_VERBOSE 0x100
995 #define DEBUG_DRI 0x200
996 #define DEBUG_DMA 0x400
997 #define DEBUG_SANITY 0x800
998 #define DEBUG_SYNC 0x1000
999 #define DEBUG_PIXEL 0x2000
1000 #define DEBUG_MEMORY 0x4000
1002 #endif /* __R200_CONTEXT_H__ */