1 /* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h,v 1.6 2002/12/16 16:18:58 dawes Exp $ */
2 /**************************************************************************
4 Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
5 VA Linux Systems Inc., Fremont, California.
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 * Kevin E. Martin <martin@valinux.com>
34 * Gareth Hughes <gareth@valinux.com>
37 #ifndef __RADEON_IOCTL_H__
38 #define __RADEON_IOCTL_H__
40 #ifdef GLX_DIRECT_RENDERING
42 #include "simple_list.h"
43 #include "radeon_lock.h"
46 extern void radeonEmitState( radeonContextPtr rmesa
);
47 extern void radeonEmitVertexAOS( radeonContextPtr rmesa
,
51 extern void radeonEmitVbufPrim( radeonContextPtr rmesa
,
56 extern void radeonFlushElts( radeonContextPtr rmesa
);
58 extern GLushort
*radeonAllocEltsOpenEnded( radeonContextPtr rmesa
,
63 extern void radeonEmitAOS( radeonContextPtr rmesa
,
64 struct radeon_dma_region
**regions
,
68 extern void radeonEmitBlit( radeonContextPtr rmesa
,
74 GLint srcx
, GLint srcy
,
75 GLint dstx
, GLint dsty
,
78 extern void radeonEmitWait( radeonContextPtr rmesa
, GLuint flags
);
80 extern void radeonFlushCmdBuf( radeonContextPtr rmesa
, const char * );
81 extern void radeonRefillCurrentDmaRegion( radeonContextPtr rmesa
);
83 extern void radeonAllocDmaRegion( radeonContextPtr rmesa
,
84 struct radeon_dma_region
*region
,
88 extern void radeonAllocDmaRegionVerts( radeonContextPtr rmesa
,
89 struct radeon_dma_region
*region
,
94 extern void radeonReleaseDmaRegion( radeonContextPtr rmesa
,
95 struct radeon_dma_region
*region
,
98 extern void radeonCopyBuffer( const __DRIdrawablePrivate
*drawable
);
99 extern void radeonPageFlip( const __DRIdrawablePrivate
*drawable
);
100 extern void radeonFlush( GLcontext
*ctx
);
101 extern void radeonFinish( GLcontext
*ctx
);
102 extern void radeonWaitForIdleLocked( radeonContextPtr rmesa
);
103 extern void radeonWaitForVBlank( radeonContextPtr rmesa
);
104 extern void radeonInitIoctlFuncs( GLcontext
*ctx
);
105 extern void radeonGetAllParams( radeonContextPtr rmesa
);
106 extern void radeonSetUpAtomList( radeonContextPtr rmesa
);
110 extern void radeonCompatEmitPrimitive( radeonContextPtr rmesa
,
111 GLuint vertex_format
,
115 /* ================================================================
119 /* Close off the last primitive, if it exists.
121 #define RADEON_NEWPRIM( rmesa ) \
123 if ( rmesa->dma.flush ) \
124 rmesa->dma.flush( rmesa ); \
127 /* Can accomodate several state changes and primitive changes without
128 * actually firing the buffer.
130 #define RADEON_STATECHANGE( rmesa, ATOM ) \
132 RADEON_NEWPRIM( rmesa ); \
133 rmesa->hw.ATOM.dirty = GL_TRUE; \
134 rmesa->hw.is_dirty = GL_TRUE; \
137 #define RADEON_DB_STATE( ATOM ) \
138 memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
139 rmesa->hw.ATOM.cmd_size * 4)
141 static __inline
int RADEON_DB_STATECHANGE(
142 radeonContextPtr rmesa
,
143 struct radeon_state_atom
*atom
)
145 if (memcmp(atom
->cmd
, atom
->lastcmd
, atom
->cmd_size
*4)) {
147 RADEON_NEWPRIM( rmesa
);
148 atom
->dirty
= GL_TRUE
;
149 rmesa
->hw
.is_dirty
= GL_TRUE
;
151 atom
->cmd
= atom
->lastcmd
;
160 /* Fire the buffered vertices no matter what.
162 #define RADEON_FIREVERTICES( rmesa ) \
164 if ( rmesa->store.cmd_used || rmesa->dma.flush ) { \
165 radeonFlush( rmesa->glCtx ); \
169 /* Command lengths. Note that any time you ensure ELTS_BUFSZ or VBUF_BUFSZ
170 * are available, you will also be adding an rmesa->state.max_state_size because
171 * r200EmitState is called from within r200EmitVbufPrim and r200FlushElts.
173 #if RADEON_OLD_PACKETS
174 #define AOS_BUFSZ(nr) ((3 + ((nr / 2) * 3) + ((nr & 1) * 2)) * sizeof(int))
175 #define VERT_AOS_BUFSZ (0)
176 #define ELTS_BUFSZ(nr) (24 + nr * 2)
177 #define VBUF_BUFSZ (6 * sizeof(int))
179 #define AOS_BUFSZ(nr) ((3 + ((nr / 2) * 3) + ((nr & 1) * 2)) * sizeof(int))
180 #define VERT_AOS_BUFSZ (5 * sizeof(int))
181 #define ELTS_BUFSZ(nr) (16 + nr * 2)
182 #define VBUF_BUFSZ (4 * sizeof(int))
185 /* Ensure that a minimum amount of space is available in the command buffer.
186 * This is used to ensure atomicity of state updates with the rendering requests
189 * An alternative would be to implement a "soft lock" such that when the buffer
190 * wraps at an inopportune time, we grab the lock, flush the current buffer,
191 * and hang on to the lock until the critical section is finished and we flush
192 * the buffer again and unlock.
194 static __inline
void radeonEnsureCmdBufSpace( radeonContextPtr rmesa
,
197 if (rmesa
->store
.cmd_used
+ bytes
> RADEON_CMD_BUF_SZ
)
198 radeonFlushCmdBuf( rmesa
, __FUNCTION__
);
199 assert( bytes
<= RADEON_CMD_BUF_SZ
);
202 /* Alloc space in the command buffer
204 static __inline
char *radeonAllocCmdBuf( radeonContextPtr rmesa
,
205 int bytes
, const char *where
)
207 if (rmesa
->store
.cmd_used
+ bytes
> RADEON_CMD_BUF_SZ
)
208 radeonFlushCmdBuf( rmesa
, __FUNCTION__
);
210 assert(rmesa
->dri
.drmMinor
>= 3);
213 char *head
= rmesa
->store
.cmd_buf
+ rmesa
->store
.cmd_used
;
214 rmesa
->store
.cmd_used
+= bytes
;
223 #endif /* __RADEON_IOCTL_H__ */