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! */
54 typedef struct r200_context r200ContextRec
;
55 typedef struct r200_context
*r200ContextPtr
;
57 /* This union is used to avoid warnings/miscompilation
58 with float to uint32_t casts due to strict-aliasing */
59 typedef union { GLfloat f
; uint32_t ui32
; } float_ui32_type
;
61 #include "r200_lock.h"
62 #include "radeon_screen.h"
65 /* Flags for software fallback cases */
66 /* See correponding strings in r200_swtcl.c */
67 #define R200_FALLBACK_TEXTURE 0x01
68 #define R200_FALLBACK_DRAW_BUFFER 0x02
69 #define R200_FALLBACK_STENCIL 0x04
70 #define R200_FALLBACK_RENDER_MODE 0x08
71 #define R200_FALLBACK_DISABLE 0x10
72 #define R200_FALLBACK_BORDER_MODE 0x20
74 /* The blit width for texture uploads
76 #define BLIT_WIDTH_BYTES 1024
78 /* Use the templated vertex format:
81 #define TAG(x) r200##x
82 #include "tnl_dd/t_dd_vertex.h"
85 typedef void (*r200_tri_func
)( r200ContextPtr
,
90 typedef void (*r200_line_func
)( r200ContextPtr
,
94 typedef void (*r200_point_func
)( r200ContextPtr
,
98 struct r200_vertex_program
{
99 struct vertex_program mesa_program
; /* Must be first */
101 VERTEX_SHADER_INSTRUCTION instr
[R200_VSF_MAX_INST
+ 2];
103 int inputs
[VERT_ATTRIB_MAX
];
107 struct r200_colorbuffer_state
{
110 GLint drawOffset
, drawPitch
;
116 struct r200_depthbuffer_state
{
122 struct r200_pixel_state
{
123 GLint readOffset
, readPitch
;
127 struct r200_scissor_state
{
128 drm_clip_rect_t rect
;
131 GLuint numClipRects
; /* Cliprects active */
132 GLuint numAllocedClipRects
; /* Cliprects available */
133 drm_clip_rect_t
*pClipRects
;
136 struct r200_stencilbuffer_state
{
138 GLuint clear
; /* rb3d_stencilrefmask value */
141 struct r200_stipple_state
{
155 typedef struct r200_tex_obj r200TexObj
, *r200TexObjPtr
;
157 /* Texture object in locally shared texture space.
159 struct r200_tex_obj
{
160 driTextureObject base
;
162 GLuint bufAddr
; /* Offset to start of locally
163 shared texture block */
165 GLuint dirty_state
; /* Flags (1 per texunit) for
166 whether or not this texobj
167 has dirty hardware state
168 (pp_*) that needs to be
172 drm_radeon_tex_image_t image
[6][RADEON_MAX_TEXTURE_LEVELS
];
173 /* Six, for the cube faces */
175 GLuint pp_txfilter
; /* hardware register values */
177 GLuint pp_txformat_x
;
178 GLuint pp_txoffset
; /* Image location in texmem.
179 All cube faces follow. */
180 GLuint pp_txsize
; /* npot only */
181 GLuint pp_txpitch
; /* npot only */
182 GLuint pp_border_color
;
183 GLuint pp_cubic_faces
; /* cube face 1,2,3,4 log2 sizes */
185 GLboolean border_fallback
;
187 GLuint tile_bits
; /* hw texture tile bits used on this texture */
191 struct r200_texture_env_state
{
192 r200TexObjPtr texobj
;
197 #define R200_MAX_TEXTURE_UNITS 6
199 struct r200_texture_state
{
200 struct r200_texture_env_state unit
[R200_MAX_TEXTURE_UNITS
];
204 struct r200_state_atom
{
205 struct r200_state_atom
*next
, *prev
;
206 const char *name
; /* for debug */
207 int cmd_size
; /* size in bytes */
209 int *cmd
; /* one or more cmd's */
210 int *lastcmd
; /* one or more cmd's */
212 GLboolean (*check
)( GLcontext
*, int ); /* is this state active? */
217 /* Trying to keep these relatively short as the variables are becoming
218 * extravagently long. Drop the driver name prefix off the front of
219 * everything - I think we know which driver we're in by now, and keep the
220 * prefix to 3 letters unless absolutely impossible.
224 #define CTX_PP_MISC 1
225 #define CTX_PP_FOG_COLOR 2
226 #define CTX_RE_SOLID_COLOR 3
227 #define CTX_RB3D_BLENDCNTL 4
228 #define CTX_RB3D_DEPTHOFFSET 5
229 #define CTX_RB3D_DEPTHPITCH 6
230 #define CTX_RB3D_ZSTENCILCNTL 7
232 #define CTX_PP_CNTL 9
233 #define CTX_RB3D_CNTL 10
234 #define CTX_RB3D_COLOROFFSET 11
235 #define CTX_CMD_2 12 /* why */
236 #define CTX_RB3D_COLORPITCH 13 /* why */
237 #define CTX_STATE_SIZE_OLDDRM 14
239 #define CTX_RB3D_BLENDCOLOR 15
240 #define CTX_RB3D_ABLENDCNTL 16
241 #define CTX_RB3D_CBLENDCNTL 17
242 #define CTX_STATE_SIZE_NEWDRM 18
245 #define SET_SE_CNTL 1
246 #define SET_RE_CNTL 2 /* replace se_coord_fmt */
247 #define SET_STATE_SIZE 3
250 #define VTE_SE_VTE_CNTL 1
251 #define VTE_STATE_SIZE 2
254 #define LIN_RE_LINE_PATTERN 1
255 #define LIN_RE_LINE_STATE 2
257 #define LIN_SE_LINE_WIDTH 4
258 #define LIN_STATE_SIZE 5
261 #define MSK_RB3D_STENCILREFMASK 1
262 #define MSK_RB3D_ROPCNTL 2
263 #define MSK_RB3D_PLANEMASK 3
264 #define MSK_STATE_SIZE 4
267 #define VPT_SE_VPORT_XSCALE 1
268 #define VPT_SE_VPORT_XOFFSET 2
269 #define VPT_SE_VPORT_YSCALE 3
270 #define VPT_SE_VPORT_YOFFSET 4
271 #define VPT_SE_VPORT_ZSCALE 5
272 #define VPT_SE_VPORT_ZOFFSET 6
273 #define VPT_STATE_SIZE 7
276 #define ZBS_SE_ZBIAS_FACTOR 1
277 #define ZBS_SE_ZBIAS_CONSTANT 2
278 #define ZBS_STATE_SIZE 3
281 #define MSC_RE_MISC 1
282 #define MSC_STATE_SIZE 2
286 #define TAM_STATE_SIZE 2
289 #define TEX_PP_TXFILTER 1 /*2c00*/
290 #define TEX_PP_TXFORMAT 2 /*2c04*/
291 #define TEX_PP_TXFORMAT_X 3 /*2c08*/
292 #define TEX_PP_TXSIZE 4 /*2c0c*/
293 #define TEX_PP_TXPITCH 5 /*2c10*/
294 #define TEX_PP_BORDER_COLOR 6 /*2c14*/
295 #define TEX_CMD_1_OLDDRM 7
296 #define TEX_PP_TXOFFSET_OLDDRM 8 /*2d00 */
297 #define TEX_STATE_SIZE_OLDDRM 9
298 #define TEX_PP_CUBIC_FACES 7
299 #define TEX_PP_TXMULTI_CTL 8
300 #define TEX_CMD_1_NEWDRM 9
301 #define TEX_PP_TXOFFSET_NEWDRM 10
302 #define TEX_STATE_SIZE_NEWDRM 11
304 #define CUBE_CMD_0 0 /* 1 register follows */ /* this command unnecessary */
305 #define CUBE_PP_CUBIC_FACES 1 /* 0x2c18 */ /* with new enough drm */
306 #define CUBE_CMD_1 2 /* 5 registers follow */
307 #define CUBE_PP_CUBIC_OFFSET_F1 3 /* 0x2d04 */
308 #define CUBE_PP_CUBIC_OFFSET_F2 4 /* 0x2d08 */
309 #define CUBE_PP_CUBIC_OFFSET_F3 5 /* 0x2d0c */
310 #define CUBE_PP_CUBIC_OFFSET_F4 6 /* 0x2d10 */
311 #define CUBE_PP_CUBIC_OFFSET_F5 7 /* 0x2d14 */
312 #define CUBE_STATE_SIZE 8
315 #define PIX_PP_TXCBLEND 1
316 #define PIX_PP_TXCBLEND2 2
317 #define PIX_PP_TXABLEND 3
318 #define PIX_PP_TXABLEND2 4
319 #define PIX_STATE_SIZE 5
322 #define TF_TFACTOR_0 1
323 #define TF_TFACTOR_1 2
324 #define TF_TFACTOR_2 3
325 #define TF_TFACTOR_3 4
326 #define TF_TFACTOR_4 5
327 #define TF_TFACTOR_5 6
328 #define TF_STATE_SIZE 7
331 #define ATF_TFACTOR_0 1
332 #define ATF_TFACTOR_1 2
333 #define ATF_TFACTOR_2 3
334 #define ATF_TFACTOR_3 4
335 #define ATF_TFACTOR_4 5
336 #define ATF_TFACTOR_5 6
337 #define ATF_TFACTOR_6 7
338 #define ATF_TFACTOR_7 8
339 #define ATF_STATE_SIZE 9
341 /* ATI_FRAGMENT_SHADER */
343 #define AFS_IC0 1 /* 2f00 */
344 #define AFS_IC1 2 /* 2f04 */
345 #define AFS_IA0 3 /* 2f08 */
346 #define AFS_IA1 4 /* 2f0c */
347 #define AFS_STATE_SIZE 33
352 #define PVS_STATE_SIZE 3
354 /* those are quite big... */
356 #define VPI_OPDST_0 1
360 #define VPI_OPDST_63 253
361 #define VPI_SRC0_63 254
362 #define VPI_SRC1_63 255
363 #define VPI_SRC2_63 256
364 #define VPI_STATE_SIZE 257
367 #define VPP_PARAM0_0 1
368 #define VPP_PARAM1_0 2
369 #define VPP_PARAM2_0 3
370 #define VPP_PARAM3_0 4
371 #define VPP_PARAM0_95 381
372 #define VPP_PARAM1_95 382
373 #define VPP_PARAM2_95 383
374 #define VPP_PARAM3_95 384
375 #define VPP_STATE_SIZE 385
378 #define TCL_LIGHT_MODEL_CTL_0 1
379 #define TCL_LIGHT_MODEL_CTL_1 2
380 #define TCL_PER_LIGHT_CTL_0 3
381 #define TCL_PER_LIGHT_CTL_1 4
382 #define TCL_PER_LIGHT_CTL_2 5
383 #define TCL_PER_LIGHT_CTL_3 6
385 #define TCL_UCP_VERT_BLEND_CTL 8
386 #define TCL_STATE_SIZE 9
389 #define MSL_MATRIX_SELECT_0 1
390 #define MSL_MATRIX_SELECT_1 2
391 #define MSL_MATRIX_SELECT_2 3
392 #define MSL_MATRIX_SELECT_3 4
393 #define MSL_MATRIX_SELECT_4 5
394 #define MSL_STATE_SIZE 6
397 #define TCG_TEX_PROC_CTL_2 1
398 #define TCG_TEX_PROC_CTL_3 2
399 #define TCG_TEX_PROC_CTL_0 3
400 #define TCG_TEX_PROC_CTL_1 4
401 #define TCG_TEX_CYL_WRAP_CTL 5
402 #define TCG_STATE_SIZE 6
405 #define MTL_EMMISSIVE_RED 1
406 #define MTL_EMMISSIVE_GREEN 2
407 #define MTL_EMMISSIVE_BLUE 3
408 #define MTL_EMMISSIVE_ALPHA 4
409 #define MTL_AMBIENT_RED 5
410 #define MTL_AMBIENT_GREEN 6
411 #define MTL_AMBIENT_BLUE 7
412 #define MTL_AMBIENT_ALPHA 8
413 #define MTL_DIFFUSE_RED 9
414 #define MTL_DIFFUSE_GREEN 10
415 #define MTL_DIFFUSE_BLUE 11
416 #define MTL_DIFFUSE_ALPHA 12
417 #define MTL_SPECULAR_RED 13
418 #define MTL_SPECULAR_GREEN 14
419 #define MTL_SPECULAR_BLUE 15
420 #define MTL_SPECULAR_ALPHA 16
422 #define MTL_SHININESS 18
423 #define MTL_STATE_SIZE 19
426 #define VAP_SE_VAP_CNTL 1
427 #define VAP_STATE_SIZE 2
429 /* Replaces a lot of packet info from radeon
432 #define VTX_VTXFMT_0 1
433 #define VTX_VTXFMT_1 2
434 #define VTX_TCL_OUTPUT_VTXFMT_0 3
435 #define VTX_TCL_OUTPUT_VTXFMT_1 4
437 #define VTX_TCL_OUTPUT_COMPSEL 6
439 #define VTX_STATE_CNTL 8
440 #define VTX_STATE_SIZE 9
442 /* SPR - point sprite state
445 #define SPR_POINT_SPRITE_CNTL 1
446 #define SPR_STATE_SIZE 2
448 #define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\
452 * Given the \c R200_SE_VTX_FMT_1 for the current vertex state, determine
453 * how many components are in texture coordinate \c n.
455 #define VTX_TEXn_COUNT(v,n) (((v) >> (3 * n)) & 0x07)
459 #define MAT_STATE_SIZE 17
462 #define GRD_VERT_GUARD_CLIP_ADJ 1
463 #define GRD_VERT_GUARD_DISCARD_ADJ 2
464 #define GRD_HORZ_GUARD_CLIP_ADJ 3
465 #define GRD_HORZ_GUARD_DISCARD_ADJ 4
466 #define GRD_STATE_SIZE 5
468 /* position changes frequently when lighting in modelpos - separate
469 * out to new state item?
472 #define LIT_AMBIENT_RED 1
473 #define LIT_AMBIENT_GREEN 2
474 #define LIT_AMBIENT_BLUE 3
475 #define LIT_AMBIENT_ALPHA 4
476 #define LIT_DIFFUSE_RED 5
477 #define LIT_DIFFUSE_GREEN 6
478 #define LIT_DIFFUSE_BLUE 7
479 #define LIT_DIFFUSE_ALPHA 8
480 #define LIT_SPECULAR_RED 9
481 #define LIT_SPECULAR_GREEN 10
482 #define LIT_SPECULAR_BLUE 11
483 #define LIT_SPECULAR_ALPHA 12
484 #define LIT_POSITION_X 13
485 #define LIT_POSITION_Y 14
486 #define LIT_POSITION_Z 15
487 #define LIT_POSITION_W 16
488 #define LIT_DIRECTION_X 17
489 #define LIT_DIRECTION_Y 18
490 #define LIT_DIRECTION_Z 19
491 #define LIT_DIRECTION_W 20
492 #define LIT_ATTEN_QUADRATIC 21
493 #define LIT_ATTEN_LINEAR 22
494 #define LIT_ATTEN_CONST 23
495 #define LIT_ATTEN_XXX 24
497 #define LIT_SPOT_DCD 26
498 #define LIT_SPOT_DCM 27
499 #define LIT_SPOT_EXPONENT 28
500 #define LIT_SPOT_CUTOFF 29
501 #define LIT_SPECULAR_THRESH 30
502 #define LIT_RANGE_CUTOFF 31 /* ? */
503 #define LIT_ATTEN_CONST_INV 32
504 #define LIT_STATE_SIZE 33
513 #define FOG_STATE_SIZE 5
522 #define UCP_STATE_SIZE 5
524 /* GLT - Global ambient
531 #define GLT_STATE_SIZE 5
539 #define EYE_RESCALE_FACTOR 4
540 #define EYE_STATE_SIZE 5
542 /* CST - constant state
545 #define CST_PP_CNTL_X 1
547 #define CST_RB3D_DEPTHXY_OFFSET 3
549 #define CST_RE_AUX_SCISSOR_CNTL 5
551 #define CST_RE_SCISSOR_TL_0 7
552 #define CST_RE_SCISSOR_BR_0 8
554 #define CST_SE_VAP_CNTL_STATUS 10
556 #define CST_RE_POINTSIZE 12
558 #define CST_SE_TCL_INPUT_VTX_0 14
559 #define CST_SE_TCL_INPUT_VTX_1 15
560 #define CST_SE_TCL_INPUT_VTX_2 16
561 #define CST_SE_TCL_INPUT_VTX_3 17
562 #define CST_STATE_SIZE 18
565 #define PRF_PP_TRI_PERF 1
566 #define PRF_PP_PERF_CNTL 2
567 #define PRF_STATE_SIZE 3
570 struct r200_hw_state
{
571 /* Head of the linked list of state atoms. */
572 struct r200_state_atom atomlist
;
574 /* Hardware state, stored as cmdbuf commands:
575 * -- Need to doublebuffer for
576 * - reviving state after loss of context
577 * - eliding noop statechange loops? (except line stipple count)
579 struct r200_state_atom ctx
;
580 struct r200_state_atom set
;
581 struct r200_state_atom vte
;
582 struct r200_state_atom lin
;
583 struct r200_state_atom msk
;
584 struct r200_state_atom vpt
;
585 struct r200_state_atom vap
;
586 struct r200_state_atom vtx
;
587 struct r200_state_atom tcl
;
588 struct r200_state_atom msl
;
589 struct r200_state_atom tcg
;
590 struct r200_state_atom msc
;
591 struct r200_state_atom cst
;
592 struct r200_state_atom tam
;
593 struct r200_state_atom tf
;
594 struct r200_state_atom tex
[6];
595 struct r200_state_atom cube
[6];
596 struct r200_state_atom zbs
;
597 struct r200_state_atom mtl
[2];
598 struct r200_state_atom mat
[9];
599 struct r200_state_atom lit
[8]; /* includes vec, scl commands */
600 struct r200_state_atom ucp
[6];
601 struct r200_state_atom pix
[6]; /* pixshader stages */
602 struct r200_state_atom eye
; /* eye pos */
603 struct r200_state_atom grd
; /* guard band clipping */
604 struct r200_state_atom fog
;
605 struct r200_state_atom glt
;
606 struct r200_state_atom prf
;
607 struct r200_state_atom afs
[2];
608 struct r200_state_atom pvs
;
609 struct r200_state_atom vpi
[2];
610 struct r200_state_atom vpp
[2];
611 struct r200_state_atom atf
;
612 struct r200_state_atom spr
;
614 int max_state_size
; /* Number of bytes necessary for a full state emit. */
615 GLboolean is_dirty
, all_dirty
;
619 /* Derived state for internal purposes:
621 struct r200_colorbuffer_state color
;
622 struct r200_depthbuffer_state depth
;
624 struct r200_pixel_state pixel
;
626 struct r200_scissor_state scissor
;
627 struct r200_stencilbuffer_state stencil
;
628 struct r200_stipple_state stipple
;
629 struct r200_texture_state texture
;
633 /* Need refcounting on dma buffers:
635 struct r200_dma_buffer
{
636 int refcount
; /* the number of retained regions in buf */
640 #define GET_START(rvb) (rmesa->r200Screen->gart_buffer_offset + \
641 (rvb)->address - rmesa->dma.buf0_address + \
644 /* A retained region, eg vertices for indexed vertices.
646 struct r200_dma_region
{
647 struct r200_dma_buffer
*buf
;
648 char *address
; /* == buf->address */
649 int start
, end
, ptr
; /* offsets from start of buf */
657 /* Active dma region. Allocations for vertices and retained
658 * regions come from here. Also used for emitting random vertices,
659 * these may be flushed by calling flush_current();
661 struct r200_dma_region current
;
663 void (*flush
)( r200ContextPtr
);
665 char *buf0_address
; /* start of buf[0], for index calcs */
666 GLuint nr_released_bufs
; /* flush after so many buffers released */
669 struct r200_dri_mirror
{
670 __DRIcontextPrivate
*context
; /* DRI context */
671 __DRIscreenPrivate
*screen
; /* DRI screen */
672 __DRIdrawablePrivate
*drawable
; /* DRI drawable bound to this ctx */
674 drm_context_t hwContext
;
675 drm_hw_lock_t
*hwLock
;
681 #define R200_CMD_BUF_SZ (16*1024)
686 char cmd_buf
[R200_CMD_BUF_SZ
];
694 struct r200_tcl_info
{
695 GLuint vertex_format
;
699 /* FIXME: what's the maximum number of components? */
700 struct r200_dma_region
*aos_components
[11];
701 GLuint nr_aos_components
;
705 struct r200_dma_region indexed_verts
;
706 struct r200_dma_region obj
;
707 struct r200_dma_region rgba
;
708 struct r200_dma_region spec
;
709 struct r200_dma_region fog
;
710 struct r200_dma_region tex
[R200_MAX_TEXTURE_UNITS
];
711 struct r200_dma_region norm
;
717 struct r200_swtcl_info
{
721 * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is
722 * installed in the Mesa state vector.
727 * Attributes instructing the Mesa TCL pipeline where / how to put vertex
728 * data in the hardware buffer.
730 struct tnl_attr_map vertex_attrs
[VERT_ATTRIB_MAX
];
733 * Number of elements of \c ::vertex_attrs that are actually used.
735 GLuint vertex_attr_count
;
738 * Cached pointer to the buffer where Mesa will store vertex data.
742 /* Fallback rasterization functions
744 r200_point_func draw_point
;
745 r200_line_func draw_line
;
746 r200_tri_func draw_tri
;
749 GLenum render_primitive
;
753 * Offset of the 4UB color data within a hardware (swtcl) vertex.
758 * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
763 * Should Mesa project vertex data or will the hardware do it?
767 struct r200_dma_region indexed_verts
;
772 GLuint vertex_offset
;
778 #define R200_MAX_PRIMS 64
781 /* Want to keep a cache of these around. Each is parameterized by
782 * only a single value which has only a small range. Only expect a
783 * few, so just rescan the list each time?
786 struct dynfn
*next
, *prev
;
792 struct dynfn Vertex2f
;
793 struct dynfn Vertex2fv
;
794 struct dynfn Vertex3f
;
795 struct dynfn Vertex3fv
;
796 struct dynfn Color4ub
;
797 struct dynfn Color4ubv
;
798 struct dynfn Color3ub
;
799 struct dynfn Color3ubv
;
800 struct dynfn Color4f
;
801 struct dynfn Color4fv
;
802 struct dynfn Color3f
;
803 struct dynfn Color3fv
;
804 struct dynfn SecondaryColor3ubEXT
;
805 struct dynfn SecondaryColor3ubvEXT
;
806 struct dynfn SecondaryColor3fEXT
;
807 struct dynfn SecondaryColor3fvEXT
;
808 struct dynfn Normal3f
;
809 struct dynfn Normal3fv
;
810 struct dynfn TexCoord3f
;
811 struct dynfn TexCoord3fv
;
812 struct dynfn TexCoord2f
;
813 struct dynfn TexCoord2fv
;
814 struct dynfn TexCoord1f
;
815 struct dynfn TexCoord1fv
;
816 struct dynfn MultiTexCoord3fARB
;
817 struct dynfn MultiTexCoord3fvARB
;
818 struct dynfn MultiTexCoord2fARB
;
819 struct dynfn MultiTexCoord2fvARB
;
820 struct dynfn MultiTexCoord1fARB
;
821 struct dynfn MultiTexCoord1fvARB
;
822 struct dynfn FogCoordfEXT
;
823 struct dynfn FogCoordfvEXT
;
826 struct dfn_generators
{
827 struct dynfn
*(*Vertex2f
)( GLcontext
*, const int * );
828 struct dynfn
*(*Vertex2fv
)( GLcontext
*, const int * );
829 struct dynfn
*(*Vertex3f
)( GLcontext
*, const int * );
830 struct dynfn
*(*Vertex3fv
)( GLcontext
*, const int * );
831 struct dynfn
*(*Color4ub
)( GLcontext
*, const int * );
832 struct dynfn
*(*Color4ubv
)( GLcontext
*, const int * );
833 struct dynfn
*(*Color3ub
)( GLcontext
*, const int * );
834 struct dynfn
*(*Color3ubv
)( GLcontext
*, const int * );
835 struct dynfn
*(*Color4f
)( GLcontext
*, const int * );
836 struct dynfn
*(*Color4fv
)( GLcontext
*, const int * );
837 struct dynfn
*(*Color3f
)( GLcontext
*, const int * );
838 struct dynfn
*(*Color3fv
)( GLcontext
*, const int * );
839 struct dynfn
*(*SecondaryColor3ubEXT
)( GLcontext
*, const int * );
840 struct dynfn
*(*SecondaryColor3ubvEXT
)( GLcontext
*, const int * );
841 struct dynfn
*(*SecondaryColor3fEXT
)( GLcontext
*, const int * );
842 struct dynfn
*(*SecondaryColor3fvEXT
)( GLcontext
*, const int * );
843 struct dynfn
*(*Normal3f
)( GLcontext
*, const int * );
844 struct dynfn
*(*Normal3fv
)( GLcontext
*, const int * );
845 struct dynfn
*(*TexCoord3f
)( GLcontext
*, const int * );
846 struct dynfn
*(*TexCoord3fv
)( GLcontext
*, const int * );
847 struct dynfn
*(*TexCoord2f
)( GLcontext
*, const int * );
848 struct dynfn
*(*TexCoord2fv
)( GLcontext
*, const int * );
849 struct dynfn
*(*TexCoord1f
)( GLcontext
*, const int * );
850 struct dynfn
*(*TexCoord1fv
)( GLcontext
*, const int * );
851 struct dynfn
*(*MultiTexCoord3fARB
)( GLcontext
*, const int * );
852 struct dynfn
*(*MultiTexCoord3fvARB
)( GLcontext
*, const int * );
853 struct dynfn
*(*MultiTexCoord2fARB
)( GLcontext
*, const int * );
854 struct dynfn
*(*MultiTexCoord2fvARB
)( GLcontext
*, const int * );
855 struct dynfn
*(*MultiTexCoord1fARB
)( GLcontext
*, const int * );
856 struct dynfn
*(*MultiTexCoord1fvARB
)( GLcontext
*, const int * );
857 struct dynfn
*(*FogCoordfEXT
)( GLcontext
*, const int * );
858 struct dynfn
*(*FogCoordfvEXT
)( GLcontext
*, const int * );
869 /* A maximum total of 29 elements per vertex: 3 floats for position, 3
870 * floats for normal, 4 floats for color, 4 bytes for secondary color,
871 * 3 floats for each texture unit (18 floats total).
873 * we maybe need add. 4 to prevent segfault if someone specifies
874 * GL_TEXTURE6/GL_TEXTURE7 (esp. for the codegen-path) (FIXME: )
876 * The position data is never actually stored here, so 3 elements could be
877 * trimmed out of the buffer.
880 #define R200_MAX_VERTEX_SIZE ((3*6)+11)
883 GLint counter
, initial_counter
;
885 void (*notify
)( void );
888 union { float f
; int i
; r200_color_t color
; } vertex
[R200_MAX_VERTEX_SIZE
];
891 GLfloat
*floatcolorptr
;
893 r200_color_t
*colorptr
;
894 GLfloat
*floatspecptr
;
895 r200_color_t
*specptr
;
896 GLfloat
*texcoordptr
[8]; /* 6 (TMU) + 2 for r200_vtxfmt_c.c when GL_TEXTURE6/7 */
899 GLenum
*prim
; /* &ctx->Driver.CurrentExecPrimitive */
901 GLboolean enabled
; /* *_NO_VTXFMT / *_NO_TCL env vars */
906 GLuint vtxfmt_0
, vtxfmt_1
;
908 GLuint installed_vertex_format
;
909 GLuint installed_color_3f_sz
;
911 struct r200_prim primlist
[R200_MAX_PRIMS
];
914 struct dfn_lists dfn_cache
;
915 struct dfn_generators codegen
;
916 GLvertexformat vtxfmt
;
920 struct r200_context
{
921 GLcontext
*glCtx
; /* Mesa context */
923 /* Driver and hardware state management
925 struct r200_hw_state hw
;
926 struct r200_state state
;
927 struct r200_vertex_program
*curr_vp_hw
;
929 /* Texture object bookkeeping
932 driTexHeap
* texture_heaps
[ RADEON_NR_TEX_HEAPS
];
933 driTextureObject swapped
;
935 float initialMaxAnisotropy
;
937 /* Rasterization and vertex state:
942 DECLARE_RENDERINPUTS(tnl_index_bitset
); /* index of bits for last tnl_install_attrs */
946 struct r200_ioctl ioctl
;
948 struct r200_store store
;
949 /* A full state emit as of the first state emit in the main store, in case
950 * the context is lost.
952 struct r200_store backup_store
;
963 drm_radeon_irq_wait_t iw
;
965 /* Clientdata textures;
967 GLuint prefer_gart_client_texturing
;
969 /* Drawable, cliprect and scissor information
971 GLuint numClipRects
; /* Cliprects for the draw buffer */
972 drm_clip_rect_t
*pClipRects
;
973 unsigned int lastStamp
;
974 GLboolean lost_context
;
975 GLboolean save_on_next_emit
;
976 radeonScreenPtr r200Screen
; /* Screen private DRI data */
977 drm_radeon_sarea_t
*sarea
; /* Private SAREA data */
981 GLmatrix TexGenMatrix
[R200_MAX_TEXTURE_UNITS
];
982 GLboolean recheck_texgen
[R200_MAX_TEXTURE_UNITS
];
983 GLboolean TexGenNeedNormals
[R200_MAX_TEXTURE_UNITS
];
984 GLuint TexMatEnabled
;
985 GLuint TexMatCompSel
;
986 GLuint TexGenEnabled
;
987 GLuint TexGenCompSel
;
996 int64_t swap_missed_ust
;
999 GLuint swap_missed_count
;
1004 struct r200_tcl_info tcl
;
1008 struct r200_swtcl_info swtcl
;
1012 struct r200_vbinfo vb
;
1014 /* Mirrors of some DRI state
1016 struct r200_dri_mirror dri
;
1018 /* Configuration cache
1020 driOptionCache optionCache
;
1022 GLboolean using_hyperz
;
1023 GLboolean texmicrotile
;
1025 struct ati_fragment_shader
*afs_loaded
;
1028 #define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx))
1031 static __inline GLuint
r200PackColor( GLuint cpp
,
1032 GLubyte r
, GLubyte g
,
1033 GLubyte b
, GLubyte a
)
1037 return PACK_COLOR_565( r
, g
, b
);
1039 return PACK_COLOR_8888( a
, r
, g
, b
);
1046 extern void r200DestroyContext( __DRIcontextPrivate
*driContextPriv
);
1047 extern GLboolean
r200CreateContext( const __GLcontextModes
*glVisual
,
1048 __DRIcontextPrivate
*driContextPriv
,
1049 void *sharedContextPrivate
);
1050 extern void r200SwapBuffers( __DRIdrawablePrivate
*dPriv
);
1051 extern void r200CopySubBuffer( __DRIdrawablePrivate
* dPriv
,
1052 int x
, int y
, int w
, int h
);
1053 extern GLboolean
r200MakeCurrent( __DRIcontextPrivate
*driContextPriv
,
1054 __DRIdrawablePrivate
*driDrawPriv
,
1055 __DRIdrawablePrivate
*driReadPriv
);
1056 extern GLboolean
r200UnbindContext( __DRIcontextPrivate
*driContextPriv
);
1058 /* ================================================================
1064 extern int R200_DEBUG
;
1066 #define R200_DEBUG 0
1069 #define DEBUG_TEXTURE 0x001
1070 #define DEBUG_STATE 0x002
1071 #define DEBUG_IOCTL 0x004
1072 #define DEBUG_PRIMS 0x008
1073 #define DEBUG_VERTS 0x010
1074 #define DEBUG_FALLBACKS 0x020
1075 #define DEBUG_VFMT 0x040
1076 #define DEBUG_CODEGEN 0x080
1077 #define DEBUG_VERBOSE 0x100
1078 #define DEBUG_DRI 0x200
1079 #define DEBUG_DMA 0x400
1080 #define DEBUG_SANITY 0x800
1081 #define DEBUG_SYNC 0x1000
1082 #define DEBUG_PIXEL 0x2000
1083 #define DEBUG_MEMORY 0x4000
1085 #endif /* __R200_CONTEXT_H__ */