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"
49 #include "r200_vertprog.h"
51 #define ENABLE_HW_3D_TEXTURE 1 /* XXX this is temporary! */
53 #ifndef R200_EMIT_VAP_PVS_CNTL
54 #error This driver requires a newer libdrm to compile
58 typedef struct r200_context r200ContextRec
;
59 typedef struct r200_context
*r200ContextPtr
;
61 /* This union is used to avoid warnings/miscompilation
62 with float to uint32_t casts due to strict-aliasing */
63 typedef union { GLfloat f
; uint32_t ui32
; } float_ui32_type
;
65 #include "r200_lock.h"
66 #include "radeon_screen.h"
69 /* Flags for software fallback cases */
70 /* See correponding strings in r200_swtcl.c */
71 #define R200_FALLBACK_TEXTURE 0x01
72 #define R200_FALLBACK_DRAW_BUFFER 0x02
73 #define R200_FALLBACK_STENCIL 0x04
74 #define R200_FALLBACK_RENDER_MODE 0x08
75 #define R200_FALLBACK_DISABLE 0x10
76 #define R200_FALLBACK_BORDER_MODE 0x20
78 /* The blit width for texture uploads
80 #define BLIT_WIDTH_BYTES 1024
82 /* Use the templated vertex format:
85 #define TAG(x) r200##x
86 #include "tnl_dd/t_dd_vertex.h"
89 typedef void (*r200_tri_func
)( r200ContextPtr
,
94 typedef void (*r200_line_func
)( r200ContextPtr
,
98 typedef void (*r200_point_func
)( r200ContextPtr
,
102 struct r200_vertex_program
{
103 struct gl_vertex_program mesa_program
; /* Must be first */
105 VERTEX_SHADER_INSTRUCTION instr
[R200_VSF_MAX_INST
+ 3];
107 int inputs
[VERT_ATTRIB_MAX
];
111 struct r200_colorbuffer_state
{
114 GLint drawOffset
, drawPitch
;
120 struct r200_depthbuffer_state
{
126 struct r200_pixel_state
{
127 GLint readOffset
, readPitch
;
131 struct r200_scissor_state
{
132 drm_clip_rect_t rect
;
135 GLuint numClipRects
; /* Cliprects active */
136 GLuint numAllocedClipRects
; /* Cliprects available */
137 drm_clip_rect_t
*pClipRects
;
140 struct r200_stencilbuffer_state
{
142 GLuint clear
; /* rb3d_stencilrefmask value */
145 struct r200_stipple_state
{
159 typedef struct r200_tex_obj r200TexObj
, *r200TexObjPtr
;
161 /* Texture object in locally shared texture space.
163 struct r200_tex_obj
{
164 driTextureObject base
;
166 GLuint bufAddr
; /* Offset to start of locally
167 shared texture block */
169 GLuint dirty_state
; /* Flags (1 per texunit) for
170 whether or not this texobj
171 has dirty hardware state
172 (pp_*) that needs to be
176 drm_radeon_tex_image_t image
[6][RADEON_MAX_TEXTURE_LEVELS
];
177 /* Six, for the cube faces */
179 GLuint pp_txfilter
; /* hardware register values */
181 GLuint pp_txformat_x
;
182 GLuint pp_txoffset
; /* Image location in texmem.
183 All cube faces follow. */
184 GLuint pp_txsize
; /* npot only */
185 GLuint pp_txpitch
; /* npot only */
186 GLuint pp_border_color
;
187 GLuint pp_cubic_faces
; /* cube face 1,2,3,4 log2 sizes */
189 GLboolean border_fallback
;
191 GLuint tile_bits
; /* hw texture tile bits used on this texture */
195 struct r200_texture_env_state
{
196 r200TexObjPtr texobj
;
201 #define R200_MAX_TEXTURE_UNITS 6
203 struct r200_texture_state
{
204 struct r200_texture_env_state unit
[R200_MAX_TEXTURE_UNITS
];
208 struct r200_state_atom
{
209 struct r200_state_atom
*next
, *prev
;
210 const char *name
; /* for debug */
211 int cmd_size
; /* size in bytes */
213 int *cmd
; /* one or more cmd's */
214 int *lastcmd
; /* one or more cmd's */
216 GLboolean (*check
)( GLcontext
*, int ); /* is this state active? */
221 /* Trying to keep these relatively short as the variables are becoming
222 * extravagently long. Drop the driver name prefix off the front of
223 * everything - I think we know which driver we're in by now, and keep the
224 * prefix to 3 letters unless absolutely impossible.
228 #define CTX_PP_MISC 1
229 #define CTX_PP_FOG_COLOR 2
230 #define CTX_RE_SOLID_COLOR 3
231 #define CTX_RB3D_BLENDCNTL 4
232 #define CTX_RB3D_DEPTHOFFSET 5
233 #define CTX_RB3D_DEPTHPITCH 6
234 #define CTX_RB3D_ZSTENCILCNTL 7
236 #define CTX_PP_CNTL 9
237 #define CTX_RB3D_CNTL 10
238 #define CTX_RB3D_COLOROFFSET 11
239 #define CTX_CMD_2 12 /* why */
240 #define CTX_RB3D_COLORPITCH 13 /* why */
241 #define CTX_STATE_SIZE_OLDDRM 14
243 #define CTX_RB3D_BLENDCOLOR 15
244 #define CTX_RB3D_ABLENDCNTL 16
245 #define CTX_RB3D_CBLENDCNTL 17
246 #define CTX_STATE_SIZE_NEWDRM 18
249 #define SET_SE_CNTL 1
250 #define SET_RE_CNTL 2 /* replace se_coord_fmt */
251 #define SET_STATE_SIZE 3
254 #define VTE_SE_VTE_CNTL 1
255 #define VTE_STATE_SIZE 2
258 #define LIN_RE_LINE_PATTERN 1
259 #define LIN_RE_LINE_STATE 2
261 #define LIN_SE_LINE_WIDTH 4
262 #define LIN_STATE_SIZE 5
265 #define MSK_RB3D_STENCILREFMASK 1
266 #define MSK_RB3D_ROPCNTL 2
267 #define MSK_RB3D_PLANEMASK 3
268 #define MSK_STATE_SIZE 4
271 #define VPT_SE_VPORT_XSCALE 1
272 #define VPT_SE_VPORT_XOFFSET 2
273 #define VPT_SE_VPORT_YSCALE 3
274 #define VPT_SE_VPORT_YOFFSET 4
275 #define VPT_SE_VPORT_ZSCALE 5
276 #define VPT_SE_VPORT_ZOFFSET 6
277 #define VPT_STATE_SIZE 7
280 #define ZBS_SE_ZBIAS_FACTOR 1
281 #define ZBS_SE_ZBIAS_CONSTANT 2
282 #define ZBS_STATE_SIZE 3
285 #define MSC_RE_MISC 1
286 #define MSC_STATE_SIZE 2
290 #define TAM_STATE_SIZE 2
293 #define TEX_PP_TXFILTER 1 /*2c00*/
294 #define TEX_PP_TXFORMAT 2 /*2c04*/
295 #define TEX_PP_TXFORMAT_X 3 /*2c08*/
296 #define TEX_PP_TXSIZE 4 /*2c0c*/
297 #define TEX_PP_TXPITCH 5 /*2c10*/
298 #define TEX_PP_BORDER_COLOR 6 /*2c14*/
299 #define TEX_CMD_1_OLDDRM 7
300 #define TEX_PP_TXOFFSET_OLDDRM 8 /*2d00 */
301 #define TEX_STATE_SIZE_OLDDRM 9
302 #define TEX_PP_CUBIC_FACES 7
303 #define TEX_PP_TXMULTI_CTL 8
304 #define TEX_CMD_1_NEWDRM 9
305 #define TEX_PP_TXOFFSET_NEWDRM 10
306 #define TEX_STATE_SIZE_NEWDRM 11
308 #define CUBE_CMD_0 0 /* 1 register follows */ /* this command unnecessary */
309 #define CUBE_PP_CUBIC_FACES 1 /* 0x2c18 */ /* with new enough drm */
310 #define CUBE_CMD_1 2 /* 5 registers follow */
311 #define CUBE_PP_CUBIC_OFFSET_F1 3 /* 0x2d04 */
312 #define CUBE_PP_CUBIC_OFFSET_F2 4 /* 0x2d08 */
313 #define CUBE_PP_CUBIC_OFFSET_F3 5 /* 0x2d0c */
314 #define CUBE_PP_CUBIC_OFFSET_F4 6 /* 0x2d10 */
315 #define CUBE_PP_CUBIC_OFFSET_F5 7 /* 0x2d14 */
316 #define CUBE_STATE_SIZE 8
319 #define PIX_PP_TXCBLEND 1
320 #define PIX_PP_TXCBLEND2 2
321 #define PIX_PP_TXABLEND 3
322 #define PIX_PP_TXABLEND2 4
323 #define PIX_STATE_SIZE 5
326 #define TF_TFACTOR_0 1
327 #define TF_TFACTOR_1 2
328 #define TF_TFACTOR_2 3
329 #define TF_TFACTOR_3 4
330 #define TF_TFACTOR_4 5
331 #define TF_TFACTOR_5 6
332 #define TF_STATE_SIZE 7
335 #define ATF_TFACTOR_0 1
336 #define ATF_TFACTOR_1 2
337 #define ATF_TFACTOR_2 3
338 #define ATF_TFACTOR_3 4
339 #define ATF_TFACTOR_4 5
340 #define ATF_TFACTOR_5 6
341 #define ATF_TFACTOR_6 7
342 #define ATF_TFACTOR_7 8
343 #define ATF_STATE_SIZE 9
345 /* ATI_FRAGMENT_SHADER */
347 #define AFS_IC0 1 /* 2f00 */
348 #define AFS_IC1 2 /* 2f04 */
349 #define AFS_IA0 3 /* 2f08 */
350 #define AFS_IA1 4 /* 2f0c */
351 #define AFS_STATE_SIZE 33
356 #define PVS_STATE_SIZE 3
358 /* those are quite big... */
360 #define VPI_OPDST_0 1
364 #define VPI_OPDST_63 253
365 #define VPI_SRC0_63 254
366 #define VPI_SRC1_63 255
367 #define VPI_SRC2_63 256
368 #define VPI_STATE_SIZE 257
371 #define VPP_PARAM0_0 1
372 #define VPP_PARAM1_0 2
373 #define VPP_PARAM2_0 3
374 #define VPP_PARAM3_0 4
375 #define VPP_PARAM0_95 381
376 #define VPP_PARAM1_95 382
377 #define VPP_PARAM2_95 383
378 #define VPP_PARAM3_95 384
379 #define VPP_STATE_SIZE 385
382 #define TCL_LIGHT_MODEL_CTL_0 1
383 #define TCL_LIGHT_MODEL_CTL_1 2
384 #define TCL_PER_LIGHT_CTL_0 3
385 #define TCL_PER_LIGHT_CTL_1 4
386 #define TCL_PER_LIGHT_CTL_2 5
387 #define TCL_PER_LIGHT_CTL_3 6
389 #define TCL_UCP_VERT_BLEND_CTL 8
390 #define TCL_STATE_SIZE 9
393 #define MSL_MATRIX_SELECT_0 1
394 #define MSL_MATRIX_SELECT_1 2
395 #define MSL_MATRIX_SELECT_2 3
396 #define MSL_MATRIX_SELECT_3 4
397 #define MSL_MATRIX_SELECT_4 5
398 #define MSL_STATE_SIZE 6
401 #define TCG_TEX_PROC_CTL_2 1
402 #define TCG_TEX_PROC_CTL_3 2
403 #define TCG_TEX_PROC_CTL_0 3
404 #define TCG_TEX_PROC_CTL_1 4
405 #define TCG_TEX_CYL_WRAP_CTL 5
406 #define TCG_STATE_SIZE 6
409 #define MTL_EMMISSIVE_RED 1
410 #define MTL_EMMISSIVE_GREEN 2
411 #define MTL_EMMISSIVE_BLUE 3
412 #define MTL_EMMISSIVE_ALPHA 4
413 #define MTL_AMBIENT_RED 5
414 #define MTL_AMBIENT_GREEN 6
415 #define MTL_AMBIENT_BLUE 7
416 #define MTL_AMBIENT_ALPHA 8
417 #define MTL_DIFFUSE_RED 9
418 #define MTL_DIFFUSE_GREEN 10
419 #define MTL_DIFFUSE_BLUE 11
420 #define MTL_DIFFUSE_ALPHA 12
421 #define MTL_SPECULAR_RED 13
422 #define MTL_SPECULAR_GREEN 14
423 #define MTL_SPECULAR_BLUE 15
424 #define MTL_SPECULAR_ALPHA 16
426 #define MTL_SHININESS 18
427 #define MTL_STATE_SIZE 19
430 #define VAP_SE_VAP_CNTL 1
431 #define VAP_STATE_SIZE 2
433 /* Replaces a lot of packet info from radeon
436 #define VTX_VTXFMT_0 1
437 #define VTX_VTXFMT_1 2
438 #define VTX_TCL_OUTPUT_VTXFMT_0 3
439 #define VTX_TCL_OUTPUT_VTXFMT_1 4
441 #define VTX_TCL_OUTPUT_COMPSEL 6
443 #define VTX_STATE_CNTL 8
444 #define VTX_STATE_SIZE 9
446 /* SPR - point sprite state
449 #define SPR_POINT_SPRITE_CNTL 1
450 #define SPR_STATE_SIZE 2
452 #define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\
456 * Given the \c R200_SE_VTX_FMT_1 for the current vertex state, determine
457 * how many components are in texture coordinate \c n.
459 #define VTX_TEXn_COUNT(v,n) (((v) >> (3 * n)) & 0x07)
463 #define MAT_STATE_SIZE 17
466 #define GRD_VERT_GUARD_CLIP_ADJ 1
467 #define GRD_VERT_GUARD_DISCARD_ADJ 2
468 #define GRD_HORZ_GUARD_CLIP_ADJ 3
469 #define GRD_HORZ_GUARD_DISCARD_ADJ 4
470 #define GRD_STATE_SIZE 5
472 /* position changes frequently when lighting in modelpos - separate
473 * out to new state item?
476 #define LIT_AMBIENT_RED 1
477 #define LIT_AMBIENT_GREEN 2
478 #define LIT_AMBIENT_BLUE 3
479 #define LIT_AMBIENT_ALPHA 4
480 #define LIT_DIFFUSE_RED 5
481 #define LIT_DIFFUSE_GREEN 6
482 #define LIT_DIFFUSE_BLUE 7
483 #define LIT_DIFFUSE_ALPHA 8
484 #define LIT_SPECULAR_RED 9
485 #define LIT_SPECULAR_GREEN 10
486 #define LIT_SPECULAR_BLUE 11
487 #define LIT_SPECULAR_ALPHA 12
488 #define LIT_POSITION_X 13
489 #define LIT_POSITION_Y 14
490 #define LIT_POSITION_Z 15
491 #define LIT_POSITION_W 16
492 #define LIT_DIRECTION_X 17
493 #define LIT_DIRECTION_Y 18
494 #define LIT_DIRECTION_Z 19
495 #define LIT_DIRECTION_W 20
496 #define LIT_ATTEN_QUADRATIC 21
497 #define LIT_ATTEN_LINEAR 22
498 #define LIT_ATTEN_CONST 23
499 #define LIT_ATTEN_XXX 24
501 #define LIT_SPOT_DCD 26
502 #define LIT_SPOT_DCM 27
503 #define LIT_SPOT_EXPONENT 28
504 #define LIT_SPOT_CUTOFF 29
505 #define LIT_SPECULAR_THRESH 30
506 #define LIT_RANGE_CUTOFF 31 /* ? */
507 #define LIT_ATTEN_CONST_INV 32
508 #define LIT_STATE_SIZE 33
517 #define FOG_STATE_SIZE 5
526 #define UCP_STATE_SIZE 5
528 /* GLT - Global ambient
535 #define GLT_STATE_SIZE 5
543 #define EYE_RESCALE_FACTOR 4
544 #define EYE_STATE_SIZE 5
546 /* CST - constant state
549 #define CST_PP_CNTL_X 1
551 #define CST_RB3D_DEPTHXY_OFFSET 3
553 #define CST_RE_AUX_SCISSOR_CNTL 5
555 #define CST_RE_SCISSOR_TL_0 7
556 #define CST_RE_SCISSOR_BR_0 8
558 #define CST_SE_VAP_CNTL_STATUS 10
560 #define CST_RE_POINTSIZE 12
562 #define CST_SE_TCL_INPUT_VTX_0 14
563 #define CST_SE_TCL_INPUT_VTX_1 15
564 #define CST_SE_TCL_INPUT_VTX_2 16
565 #define CST_SE_TCL_INPUT_VTX_3 17
566 #define CST_STATE_SIZE 18
569 #define PRF_PP_TRI_PERF 1
570 #define PRF_PP_PERF_CNTL 2
571 #define PRF_STATE_SIZE 3
574 struct r200_hw_state
{
575 /* Head of the linked list of state atoms. */
576 struct r200_state_atom atomlist
;
578 /* Hardware state, stored as cmdbuf commands:
579 * -- Need to doublebuffer for
580 * - reviving state after loss of context
581 * - eliding noop statechange loops? (except line stipple count)
583 struct r200_state_atom ctx
;
584 struct r200_state_atom set
;
585 struct r200_state_atom vte
;
586 struct r200_state_atom lin
;
587 struct r200_state_atom msk
;
588 struct r200_state_atom vpt
;
589 struct r200_state_atom vap
;
590 struct r200_state_atom vtx
;
591 struct r200_state_atom tcl
;
592 struct r200_state_atom msl
;
593 struct r200_state_atom tcg
;
594 struct r200_state_atom msc
;
595 struct r200_state_atom cst
;
596 struct r200_state_atom tam
;
597 struct r200_state_atom tf
;
598 struct r200_state_atom tex
[6];
599 struct r200_state_atom cube
[6];
600 struct r200_state_atom zbs
;
601 struct r200_state_atom mtl
[2];
602 struct r200_state_atom mat
[9];
603 struct r200_state_atom lit
[8]; /* includes vec, scl commands */
604 struct r200_state_atom ucp
[6];
605 struct r200_state_atom pix
[6]; /* pixshader stages */
606 struct r200_state_atom eye
; /* eye pos */
607 struct r200_state_atom grd
; /* guard band clipping */
608 struct r200_state_atom fog
;
609 struct r200_state_atom glt
;
610 struct r200_state_atom prf
;
611 struct r200_state_atom afs
[2];
612 struct r200_state_atom pvs
;
613 struct r200_state_atom vpi
[2];
614 struct r200_state_atom vpp
[2];
615 struct r200_state_atom atf
;
616 struct r200_state_atom spr
;
618 int max_state_size
; /* Number of bytes necessary for a full state emit. */
619 GLboolean is_dirty
, all_dirty
;
623 /* Derived state for internal purposes:
625 struct r200_colorbuffer_state color
;
626 struct r200_depthbuffer_state depth
;
628 struct r200_pixel_state pixel
;
630 struct r200_scissor_state scissor
;
631 struct r200_stencilbuffer_state stencil
;
632 struct r200_stipple_state stipple
;
633 struct r200_texture_state texture
;
637 /* Need refcounting on dma buffers:
639 struct r200_dma_buffer
{
640 int refcount
; /* the number of retained regions in buf */
644 #define GET_START(rvb) (rmesa->r200Screen->gart_buffer_offset + \
645 (rvb)->address - rmesa->dma.buf0_address + \
648 /* A retained region, eg vertices for indexed vertices.
650 struct r200_dma_region
{
651 struct r200_dma_buffer
*buf
;
652 char *address
; /* == buf->address */
653 int start
, end
, ptr
; /* offsets from start of buf */
661 /* Active dma region. Allocations for vertices and retained
662 * regions come from here. Also used for emitting random vertices,
663 * these may be flushed by calling flush_current();
665 struct r200_dma_region current
;
667 void (*flush
)( r200ContextPtr
);
669 char *buf0_address
; /* start of buf[0], for index calcs */
670 GLuint nr_released_bufs
; /* flush after so many buffers released */
673 struct r200_dri_mirror
{
674 __DRIcontextPrivate
*context
; /* DRI context */
675 __DRIscreenPrivate
*screen
; /* DRI screen */
676 __DRIdrawablePrivate
*drawable
; /* DRI drawable bound to this ctx */
678 drm_context_t hwContext
;
679 drm_hw_lock_t
*hwLock
;
685 #define R200_CMD_BUF_SZ (16*1024)
690 char cmd_buf
[R200_CMD_BUF_SZ
];
698 struct r200_tcl_info
{
699 GLuint vertex_format
;
703 /* FIXME: what's the maximum number of components? */
704 struct r200_dma_region
*aos_components
[11];
705 GLuint nr_aos_components
;
709 struct r200_dma_region indexed_verts
;
710 struct r200_dma_region obj
;
711 struct r200_dma_region rgba
;
712 struct r200_dma_region spec
;
713 struct r200_dma_region fog
;
714 struct r200_dma_region tex
[R200_MAX_TEXTURE_UNITS
];
715 struct r200_dma_region norm
;
721 struct r200_swtcl_info
{
725 * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is
726 * installed in the Mesa state vector.
731 * Attributes instructing the Mesa TCL pipeline where / how to put vertex
732 * data in the hardware buffer.
734 struct tnl_attr_map vertex_attrs
[VERT_ATTRIB_MAX
];
737 * Number of elements of \c ::vertex_attrs that are actually used.
739 GLuint vertex_attr_count
;
742 * Cached pointer to the buffer where Mesa will store vertex data.
746 /* Fallback rasterization functions
748 r200_point_func draw_point
;
749 r200_line_func draw_line
;
750 r200_tri_func draw_tri
;
753 GLenum render_primitive
;
757 * Offset of the 4UB color data within a hardware (swtcl) vertex.
762 * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
767 * Should Mesa project vertex data or will the hardware do it?
771 struct r200_dma_region indexed_verts
;
776 GLuint vertex_offset
;
782 #define R200_MAX_PRIMS 64
785 /* Want to keep a cache of these around. Each is parameterized by
786 * only a single value which has only a small range. Only expect a
787 * few, so just rescan the list each time?
790 struct dynfn
*next
, *prev
;
796 struct dynfn Vertex2f
;
797 struct dynfn Vertex2fv
;
798 struct dynfn Vertex3f
;
799 struct dynfn Vertex3fv
;
800 struct dynfn Color4ub
;
801 struct dynfn Color4ubv
;
802 struct dynfn Color3ub
;
803 struct dynfn Color3ubv
;
804 struct dynfn Color4f
;
805 struct dynfn Color4fv
;
806 struct dynfn Color3f
;
807 struct dynfn Color3fv
;
808 struct dynfn SecondaryColor3ubEXT
;
809 struct dynfn SecondaryColor3ubvEXT
;
810 struct dynfn SecondaryColor3fEXT
;
811 struct dynfn SecondaryColor3fvEXT
;
812 struct dynfn Normal3f
;
813 struct dynfn Normal3fv
;
814 struct dynfn TexCoord3f
;
815 struct dynfn TexCoord3fv
;
816 struct dynfn TexCoord2f
;
817 struct dynfn TexCoord2fv
;
818 struct dynfn TexCoord1f
;
819 struct dynfn TexCoord1fv
;
820 struct dynfn MultiTexCoord3fARB
;
821 struct dynfn MultiTexCoord3fvARB
;
822 struct dynfn MultiTexCoord2fARB
;
823 struct dynfn MultiTexCoord2fvARB
;
824 struct dynfn MultiTexCoord1fARB
;
825 struct dynfn MultiTexCoord1fvARB
;
826 struct dynfn FogCoordfEXT
;
827 struct dynfn FogCoordfvEXT
;
830 struct dfn_generators
{
831 struct dynfn
*(*Vertex2f
)( GLcontext
*, const int * );
832 struct dynfn
*(*Vertex2fv
)( GLcontext
*, const int * );
833 struct dynfn
*(*Vertex3f
)( GLcontext
*, const int * );
834 struct dynfn
*(*Vertex3fv
)( GLcontext
*, const int * );
835 struct dynfn
*(*Color4ub
)( GLcontext
*, const int * );
836 struct dynfn
*(*Color4ubv
)( GLcontext
*, const int * );
837 struct dynfn
*(*Color3ub
)( GLcontext
*, const int * );
838 struct dynfn
*(*Color3ubv
)( GLcontext
*, const int * );
839 struct dynfn
*(*Color4f
)( GLcontext
*, const int * );
840 struct dynfn
*(*Color4fv
)( GLcontext
*, const int * );
841 struct dynfn
*(*Color3f
)( GLcontext
*, const int * );
842 struct dynfn
*(*Color3fv
)( GLcontext
*, const int * );
843 struct dynfn
*(*SecondaryColor3ubEXT
)( GLcontext
*, const int * );
844 struct dynfn
*(*SecondaryColor3ubvEXT
)( GLcontext
*, const int * );
845 struct dynfn
*(*SecondaryColor3fEXT
)( GLcontext
*, const int * );
846 struct dynfn
*(*SecondaryColor3fvEXT
)( GLcontext
*, const int * );
847 struct dynfn
*(*Normal3f
)( GLcontext
*, const int * );
848 struct dynfn
*(*Normal3fv
)( GLcontext
*, const int * );
849 struct dynfn
*(*TexCoord3f
)( GLcontext
*, const int * );
850 struct dynfn
*(*TexCoord3fv
)( GLcontext
*, const int * );
851 struct dynfn
*(*TexCoord2f
)( GLcontext
*, const int * );
852 struct dynfn
*(*TexCoord2fv
)( GLcontext
*, const int * );
853 struct dynfn
*(*TexCoord1f
)( GLcontext
*, const int * );
854 struct dynfn
*(*TexCoord1fv
)( GLcontext
*, const int * );
855 struct dynfn
*(*MultiTexCoord3fARB
)( GLcontext
*, const int * );
856 struct dynfn
*(*MultiTexCoord3fvARB
)( GLcontext
*, const int * );
857 struct dynfn
*(*MultiTexCoord2fARB
)( GLcontext
*, const int * );
858 struct dynfn
*(*MultiTexCoord2fvARB
)( GLcontext
*, const int * );
859 struct dynfn
*(*MultiTexCoord1fARB
)( GLcontext
*, const int * );
860 struct dynfn
*(*MultiTexCoord1fvARB
)( GLcontext
*, const int * );
861 struct dynfn
*(*FogCoordfEXT
)( GLcontext
*, const int * );
862 struct dynfn
*(*FogCoordfvEXT
)( GLcontext
*, const int * );
873 /* A maximum total of 29 elements per vertex: 3 floats for position, 3
874 * floats for normal, 4 floats for color, 4 bytes for secondary color,
875 * 3 floats for each texture unit (18 floats total).
877 * we maybe need add. 4 to prevent segfault if someone specifies
878 * GL_TEXTURE6/GL_TEXTURE7 (esp. for the codegen-path) (FIXME: )
880 * The position data is never actually stored here, so 3 elements could be
881 * trimmed out of the buffer.
884 #define R200_MAX_VERTEX_SIZE ((3*6)+11)
887 GLint counter
, initial_counter
;
889 void (*notify
)( void );
892 union { float f
; int i
; r200_color_t color
; } vertex
[R200_MAX_VERTEX_SIZE
];
895 GLfloat
*floatcolorptr
;
897 r200_color_t
*colorptr
;
898 GLfloat
*floatspecptr
;
899 r200_color_t
*specptr
;
900 GLfloat
*texcoordptr
[8]; /* 6 (TMU) + 2 for r200_vtxfmt_c.c when GL_TEXTURE6/7 */
903 GLenum
*prim
; /* &ctx->Driver.CurrentExecPrimitive */
905 GLboolean enabled
; /* *_NO_VTXFMT / *_NO_TCL env vars */
910 GLuint vtxfmt_0
, vtxfmt_1
;
912 GLuint installed_vertex_format
;
913 GLuint installed_color_3f_sz
;
915 struct r200_prim primlist
[R200_MAX_PRIMS
];
918 struct dfn_lists dfn_cache
;
919 struct dfn_generators codegen
;
920 GLvertexformat vtxfmt
;
924 struct r200_context
{
925 GLcontext
*glCtx
; /* Mesa context */
927 /* Driver and hardware state management
929 struct r200_hw_state hw
;
930 struct r200_state state
;
931 struct r200_vertex_program
*curr_vp_hw
;
933 /* Texture object bookkeeping
936 driTexHeap
* texture_heaps
[ RADEON_NR_TEX_HEAPS
];
937 driTextureObject swapped
;
939 float initialMaxAnisotropy
;
941 /* Rasterization and vertex state:
946 DECLARE_RENDERINPUTS(tnl_index_bitset
); /* index of bits for last tnl_install_attrs */
950 struct r200_ioctl ioctl
;
952 struct r200_store store
;
953 /* A full state emit as of the first state emit in the main store, in case
954 * the context is lost.
956 struct r200_store backup_store
;
967 drm_radeon_irq_wait_t iw
;
969 /* Clientdata textures;
971 GLuint prefer_gart_client_texturing
;
973 /* Drawable, cliprect and scissor information
975 GLuint numClipRects
; /* Cliprects for the draw buffer */
976 drm_clip_rect_t
*pClipRects
;
977 unsigned int lastStamp
;
978 GLboolean lost_context
;
979 GLboolean save_on_next_emit
;
980 radeonScreenPtr r200Screen
; /* Screen private DRI data */
981 drm_radeon_sarea_t
*sarea
; /* Private SAREA data */
985 GLmatrix TexGenMatrix
[R200_MAX_TEXTURE_UNITS
];
986 GLboolean recheck_texgen
[R200_MAX_TEXTURE_UNITS
];
987 GLboolean TexGenNeedNormals
[R200_MAX_TEXTURE_UNITS
];
988 GLuint TexMatEnabled
;
989 GLuint TexMatCompSel
;
990 GLuint TexGenEnabled
;
991 GLuint TexGenCompSel
;
1000 int64_t swap_missed_ust
;
1003 GLuint swap_missed_count
;
1008 struct r200_tcl_info tcl
;
1012 struct r200_swtcl_info swtcl
;
1016 struct r200_vbinfo vb
;
1018 /* Mirrors of some DRI state
1020 struct r200_dri_mirror dri
;
1022 /* Configuration cache
1024 driOptionCache optionCache
;
1026 GLboolean using_hyperz
;
1027 GLboolean texmicrotile
;
1029 struct ati_fragment_shader
*afs_loaded
;
1032 #define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx))
1035 static __inline GLuint
r200PackColor( GLuint cpp
,
1036 GLubyte r
, GLubyte g
,
1037 GLubyte b
, GLubyte a
)
1041 return PACK_COLOR_565( r
, g
, b
);
1043 return PACK_COLOR_8888( a
, r
, g
, b
);
1050 extern void r200DestroyContext( __DRIcontextPrivate
*driContextPriv
);
1051 extern GLboolean
r200CreateContext( const __GLcontextModes
*glVisual
,
1052 __DRIcontextPrivate
*driContextPriv
,
1053 void *sharedContextPrivate
);
1054 extern void r200SwapBuffers( __DRIdrawablePrivate
*dPriv
);
1055 extern void r200CopySubBuffer( __DRIdrawablePrivate
* dPriv
,
1056 int x
, int y
, int w
, int h
);
1057 extern GLboolean
r200MakeCurrent( __DRIcontextPrivate
*driContextPriv
,
1058 __DRIdrawablePrivate
*driDrawPriv
,
1059 __DRIdrawablePrivate
*driReadPriv
);
1060 extern GLboolean
r200UnbindContext( __DRIcontextPrivate
*driContextPriv
);
1062 /* ================================================================
1068 extern int R200_DEBUG
;
1070 #define R200_DEBUG 0
1073 #define DEBUG_TEXTURE 0x001
1074 #define DEBUG_STATE 0x002
1075 #define DEBUG_IOCTL 0x004
1076 #define DEBUG_PRIMS 0x008
1077 #define DEBUG_VERTS 0x010
1078 #define DEBUG_FALLBACKS 0x020
1079 #define DEBUG_VFMT 0x040
1080 #define DEBUG_CODEGEN 0x080
1081 #define DEBUG_VERBOSE 0x100
1082 #define DEBUG_DRI 0x200
1083 #define DEBUG_DMA 0x400
1084 #define DEBUG_SANITY 0x800
1085 #define DEBUG_SYNC 0x1000
1086 #define DEBUG_PIXEL 0x2000
1087 #define DEBUG_MEMORY 0x4000
1089 #endif /* __R200_CONTEXT_H__ */