2 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
4 The Weather Channel (TM) funded Tungsten Graphics to develop the
5 initial release of the Radeon 8500 driver under the XFree86 license.
6 This notice must be preserved.
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
16 The above copyright notice and this permission notice (including the
17 next paragraph) shall be included in all copies or substantial
18 portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
32 * Keith Whitwell <keith@tungstengraphics.com>
35 #include "main/glheader.h"
36 #include "main/mtypes.h"
37 #include "main/colormac.h"
38 #include "main/imports.h"
39 #include "main/macros.h"
41 #include "swrast_setup/swrast_setup.h"
42 #include "math/m_translate.h"
44 #include "tnl/t_context.h"
46 #include "r200_context.h"
47 #include "r200_ioctl.h"
48 #include "r200_state.h"
49 #include "r200_swtcl.h"
50 #include "r200_maos.h"
53 #if defined(USE_X86_ASM)
54 #define COPY_DWORDS( dst, src, nr ) \
57 __asm__ __volatile__( "rep ; movsl" \
58 : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
64 #define COPY_DWORDS( dst, src, nr ) \
67 for ( j = 0 ; j < nr ; j++ ) \
68 dst[j] = ((int *)src)[j]; \
73 static void r200_emit_vecfog(GLcontext
*ctx
, struct radeon_aos
*aos
,
74 GLvoid
*data
, int stride
, int count
)
76 radeonContextPtr rmesa
= RADEON_CONTEXT(ctx
);
82 radeonAllocDmaRegion(rmesa
, &aos
->bo
, &aos
->offset
, size
* 4, 32);
86 radeonAllocDmaRegion(rmesa
, &aos
->bo
, &aos
->offset
, size
* 4, 32);
90 aos
->components
= size
;
93 radeon_bo_map(aos
->bo
, 1);
94 out
= (uint32_t*)((char*)aos
->bo
->ptr
+ aos
->offset
);
95 for (i
= 0; i
< count
; i
++) {
96 out
[0] = r200ComputeFogBlendFactor( ctx
, *(GLfloat
*)data
);
100 radeon_bo_unmap(aos
->bo
);
103 /* Emit any changed arrays to new GART memory, re-emit a packet to
106 void r200EmitArrays( GLcontext
*ctx
, GLubyte
*vimap_rev
)
108 r200ContextPtr rmesa
= R200_CONTEXT( ctx
);
109 struct vertex_buffer
*VB
= &TNL_CONTEXT( ctx
)->vb
;
111 GLuint vfmt0
= 0, vfmt1
= 0;
112 GLuint count
= VB
->Count
;
115 // fprintf(stderr,"emit arrays\n");
116 for ( i
= 0; i
< 15; i
++ ) {
117 GLubyte attrib
= vimap_rev
[i
];
121 emitsize
= (VB
->AttribPtr
[attrib
]->size
);
124 vfmt0
|= R200_VTX_W0
;
127 vfmt0
|= R200_VTX_Z0
;
135 assert(attrib
== VERT_ATTRIB_WEIGHT
);
136 emitsize
= (VB
->AttribPtr
[attrib
]->size
);
137 vfmt0
|= emitsize
<< R200_VTX_WEIGHT_COUNT_SHIFT
;
140 assert(attrib
== VERT_ATTRIB_NORMAL
);
142 vfmt0
|= R200_VTX_N0
;
145 /* special handling to fix up fog. Will get us into trouble with vbos...*/
146 assert(attrib
== VERT_ATTRIB_FOG
);
147 if (!rmesa
->radeon
.tcl
.aos
[i
].bo
) {
148 if (ctx
->VertexProgram
._Enabled
)
149 rcommon_emit_vector( ctx
,
150 &(rmesa
->radeon
.tcl
.aos
[nr
]),
151 (char *)VB
->AttribPtr
[attrib
]->data
,
153 VB
->AttribPtr
[attrib
]->stride
,
156 r200_emit_vecfog( ctx
,
157 &(rmesa
->radeon
.tcl
.aos
[nr
]),
158 (char *)VB
->AttribPtr
[attrib
]->data
,
159 VB
->AttribPtr
[attrib
]->stride
,
162 vfmt0
|= R200_VTX_DISCRETE_FOG
;
169 if (VB
->AttribPtr
[attrib
]->size
== 4 &&
170 (VB
->AttribPtr
[attrib
]->stride
!= 0 ||
171 VB
->AttribPtr
[attrib
]->data
[0][3] != 1.0)) emitsize
= 4;
174 vfmt0
|= R200_VTX_FP_RGBA
<< (R200_VTX_COLOR_0_SHIFT
+ (i
- 4) * 2);
176 vfmt0
|= R200_VTX_FP_RGB
<< (R200_VTX_COLOR_0_SHIFT
+ (i
- 4) * 2);
185 emitsize
= VB
->AttribPtr
[attrib
]->size
;
186 vfmt1
|= emitsize
<< (R200_VTX_TEX0_COMP_CNT_SHIFT
+ (i
- 8) * 3);
189 emitsize
= VB
->AttribPtr
[attrib
]->size
>= 2 ? VB
->AttribPtr
[attrib
]->size
: 2;
192 vfmt0
|= R200_VTX_XY1
;
195 vfmt0
|= R200_VTX_Z1
;
198 vfmt0
|= R200_VTX_W1
;
204 if (!rmesa
->radeon
.tcl
.aos
[nr
].bo
) {
205 rcommon_emit_vector( ctx
,
206 &(rmesa
->radeon
.tcl
.aos
[nr
]),
207 (char *)VB
->AttribPtr
[attrib
]->data
,
209 VB
->AttribPtr
[attrib
]->stride
,
218 if (vfmt0
!= rmesa
->hw
.vtx
.cmd
[VTX_VTXFMT_0
] ||
219 vfmt1
!= rmesa
->hw
.vtx
.cmd
[VTX_VTXFMT_1
]) {
220 R200_STATECHANGE( rmesa
, vtx
);
221 rmesa
->hw
.vtx
.cmd
[VTX_VTXFMT_0
] = vfmt0
;
222 rmesa
->hw
.vtx
.cmd
[VTX_VTXFMT_1
] = vfmt1
;
225 rmesa
->radeon
.tcl
.aos_count
= nr
;