1 /* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_ioctl.h,v 1.1 2002/10/30 12:51:52 alanh 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_IOCTL_H__
37 #define __R200_IOCTL_H__
39 #ifdef GLX_DIRECT_RENDERING
41 #include "simple_list.h"
42 #include "radeon_dri.h"
43 #include "r200_lock.h"
47 #include "radeon_drm.h"
49 extern void r200EmitState( r200ContextPtr rmesa
);
50 extern void r200EmitVertexAOS( r200ContextPtr rmesa
,
54 extern void r200EmitVbufPrim( r200ContextPtr rmesa
,
58 extern void r200FlushElts( r200ContextPtr rmesa
);
60 extern GLushort
*r200AllocEltsOpenEnded( r200ContextPtr rmesa
,
64 extern void r200EmitAOS( r200ContextPtr rmesa
,
65 struct r200_dma_region
**regions
,
69 extern void r200EmitBlit( r200ContextPtr rmesa
,
75 GLint srcx
, GLint srcy
,
76 GLint dstx
, GLint dsty
,
79 extern void r200EmitWait( r200ContextPtr rmesa
, GLuint flags
);
81 extern void r200FlushCmdBuf( r200ContextPtr rmesa
, const char * );
82 extern int r200FlushCmdBufLocked( r200ContextPtr rmesa
, const char * caller
);
84 extern void r200RefillCurrentDmaRegion( r200ContextPtr rmesa
);
86 extern void r200AllocDmaRegion( r200ContextPtr rmesa
,
87 struct r200_dma_region
*region
,
91 extern void r200AllocDmaRegionVerts( r200ContextPtr rmesa
,
92 struct r200_dma_region
*region
,
97 extern void r200ReleaseDmaRegion( r200ContextPtr rmesa
,
98 struct r200_dma_region
*region
,
101 extern void r200CopyBuffer( const __DRIdrawablePrivate
*drawable
);
102 extern void r200PageFlip( const __DRIdrawablePrivate
*drawable
);
103 extern void r200Flush( GLcontext
*ctx
);
104 extern void r200Finish( GLcontext
*ctx
);
105 extern void r200WaitForIdleLocked( r200ContextPtr rmesa
);
106 extern void r200WaitForVBlank( r200ContextPtr rmesa
);
107 extern void r200InitIoctlFuncs( struct dd_function_table
*functions
);
109 extern void *r200AllocateMemoryMESA( __DRInativeDisplay
*dpy
, int scrn
, GLsizei size
, GLfloat readfreq
,
110 GLfloat writefreq
, GLfloat priority
);
111 extern void r200FreeMemoryMESA( __DRInativeDisplay
*dpy
, int scrn
, GLvoid
*pointer
);
112 extern GLuint
r200GetMemoryOffsetMESA( __DRInativeDisplay
*dpy
, int scrn
, const GLvoid
*pointer
);
114 extern GLboolean
r200IsGartMemory( r200ContextPtr rmesa
, const GLvoid
*pointer
,
117 extern GLuint
r200GartOffsetFromVirtual( r200ContextPtr rmesa
,
118 const GLvoid
*pointer
);
120 void r200SetUpAtomList( r200ContextPtr rmesa
);
122 /* ================================================================
126 /* Close off the last primitive, if it exists.
128 #define R200_NEWPRIM( rmesa ) \
130 if ( rmesa->dma.flush ) \
131 rmesa->dma.flush( rmesa ); \
134 /* Can accomodate several state changes and primitive changes without
135 * actually firing the buffer.
137 #define R200_STATECHANGE( rmesa, ATOM ) \
139 R200_NEWPRIM( rmesa ); \
140 rmesa->hw.ATOM.dirty = GL_TRUE; \
141 rmesa->hw.is_dirty = GL_TRUE; \
144 #define R200_DB_STATE( ATOM ) \
145 memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
146 rmesa->hw.ATOM.cmd_size * 4)
148 static __inline
int R200_DB_STATECHANGE(
149 r200ContextPtr rmesa
,
150 struct r200_state_atom
*atom
)
152 if (memcmp(atom
->cmd
, atom
->lastcmd
, atom
->cmd_size
*4)) {
154 R200_NEWPRIM( rmesa
);
155 atom
->dirty
= GL_TRUE
;
156 rmesa
->hw
.is_dirty
= GL_TRUE
;
158 atom
->cmd
= atom
->lastcmd
;
167 /* Fire the buffered vertices no matter what.
169 #define R200_FIREVERTICES( rmesa ) \
171 if ( rmesa->store.cmd_used || rmesa->dma.flush ) { \
172 r200Flush( rmesa->glCtx ); \
176 /* Command lengths. Note that any time you ensure ELTS_BUFSZ or VBUF_BUFSZ
177 * are available, you will also be adding an rmesa->state.max_state_size because
178 * r200EmitState is called from within r200EmitVbufPrim and r200FlushElts.
180 #define AOS_BUFSZ(nr) ((3 + ((nr / 2) * 3) + ((nr & 1) * 2)) * sizeof(int))
181 #define VERT_AOS_BUFSZ (5 * sizeof(int))
182 #define ELTS_BUFSZ(nr) (12 + nr * 2)
183 #define VBUF_BUFSZ (3 * 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 r200EnsureCmdBufSpace( r200ContextPtr rmesa
, int bytes
)
196 if (rmesa
->store
.cmd_used
+ bytes
> R200_CMD_BUF_SZ
)
197 r200FlushCmdBuf( rmesa
, __FUNCTION__
);
198 assert( bytes
<= R200_CMD_BUF_SZ
);
201 /* Alloc space in the command buffer
203 static __inline
char *r200AllocCmdBuf( r200ContextPtr rmesa
,
204 int bytes
, const char *where
)
208 if (rmesa
->store
.cmd_used
+ bytes
> R200_CMD_BUF_SZ
)
209 r200FlushCmdBuf( rmesa
, where
);
211 head
= rmesa
->store
.cmd_buf
+ rmesa
->store
.cmd_used
;
212 rmesa
->store
.cmd_used
+= bytes
;
213 assert( rmesa
->store
.cmd_used
<= R200_CMD_BUF_SZ
);
221 #endif /* __R200_IOCTL_H__ */