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 #ifndef __R200_IOCTL_H__
36 #define __R200_IOCTL_H__
38 #include "simple_list.h"
39 #include "radeon_dri.h"
40 #include "radeon_lock.h"
44 #include "r200_context.h"
45 #include "radeon_drm.h"
47 extern void r200EmitState(r200ContextPtr rmesa
);
48 extern void r200EmitVertexAOS(r200ContextPtr rmesa
,
49 GLuint vertex_size
, GLuint offset
);
51 extern void r200EmitVbufPrim(r200ContextPtr rmesa
,
52 GLuint primitive
, GLuint vertex_nr
);
54 extern void r200FlushElts(r200ContextPtr rmesa
);
56 extern GLushort
*r200AllocEltsOpenEnded(r200ContextPtr rmesa
,
57 GLuint primitive
, GLuint min_nr
);
59 extern void r200EmitAOS(r200ContextPtr rmesa
,
60 struct r200_dma_region
**regions
,
61 GLuint n
, GLuint offset
);
63 extern void r200EmitBlit(r200ContextPtr rmesa
,
69 GLint srcx
, GLint srcy
,
70 GLint dstx
, GLint dsty
, GLuint w
, GLuint h
);
72 extern void r200EmitWait(r200ContextPtr rmesa
, GLuint flags
);
74 extern void r200FlushCmdBuf(r200ContextPtr rmesa
, const char *);
75 extern int r200FlushCmdBufLocked(r200ContextPtr rmesa
, const char *caller
);
76 extern void r200Flush(GLcontext
* ctx
);
78 extern void r200RefillCurrentDmaRegion(r200ContextPtr rmesa
);
80 extern void r200AllocDmaRegion(r200ContextPtr rmesa
,
81 struct r200_dma_region
*region
,
82 int bytes
, int alignment
);
84 extern void r200AllocDmaRegionVerts(r200ContextPtr rmesa
,
85 struct r200_dma_region
*region
,
86 int numverts
, int vertsize
, int alignment
);
88 extern void r200ReleaseDmaRegion(r200ContextPtr rmesa
,
89 struct r200_dma_region
*region
,
92 extern void r200WaitForVBlank(r200ContextPtr rmesa
);
93 extern void r200InitIoctlFuncs(struct dd_function_table
*functions
);
95 extern void *r200AllocateMemoryMESA(__DRInativeDisplay
* dpy
, int scrn
,
96 GLsizei size
, GLfloat readfreq
,
97 GLfloat writefreq
, GLfloat priority
);
98 extern void r200FreeMemoryMESA(__DRInativeDisplay
* dpy
, int scrn
,
100 extern GLuint
r200GetMemoryOffsetMESA(__DRInativeDisplay
* dpy
, int scrn
,
101 const GLvoid
* pointer
);
103 extern GLboolean
r200IsGartMemory(r200ContextPtr rmesa
, const GLvoid
* pointer
,
106 extern GLuint
r200GartOffsetFromVirtual(r200ContextPtr rmesa
,
107 const GLvoid
* pointer
);
109 void r200SaveHwState(r200ContextPtr radeon
);
110 void r200SetUpAtomList(r200ContextPtr rmesa
);
112 /* ================================================================
116 /* Close off the last primitive, if it exists.
118 #define R200_NEWPRIM( rmesa ) \
120 if ( rmesa->dma.flush ) \
121 rmesa->dma.flush( rmesa ); \
124 /* Can accomodate several state changes and primitive changes without
125 * actually firing the buffer.
127 #define R200_STATECHANGE( rmesa, ATOM ) \
129 R200_NEWPRIM( rmesa ); \
130 rmesa->hw.ATOM.dirty = GL_TRUE; \
131 rmesa->hw.is_dirty = GL_TRUE; \
134 #define R200_DB_STATE( ATOM ) \
135 memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
136 rmesa->hw.ATOM.cmd_size * 4)
138 static __inline
int R200_DB_STATECHANGE(r200ContextPtr rmesa
,
139 struct r200_state_atom
*atom
)
141 if (memcmp(atom
->cmd
, atom
->lastcmd
, atom
->cmd_size
* 4)) {
144 atom
->dirty
= GL_TRUE
;
145 rmesa
->hw
.is_dirty
= GL_TRUE
;
147 atom
->cmd
= atom
->lastcmd
;
154 /* Fire the buffered vertices no matter what.
156 #define R200_FIREVERTICES( r200 ) \
158 if ( (r200)->store.cmd_used || (r200)->dma.flush ) { \
159 radeonFlush( (r200)->radeon.glCtx ); \
163 /* Command lengths. Note that any time you ensure ELTS_BUFSZ or VBUF_BUFSZ
164 * are available, you will also be adding an rmesa->state.max_state_size because
165 * r200EmitState is called from within r200EmitVbufPrim and r200FlushElts.
167 #define AOS_BUFSZ(nr) ((3 + ((nr / 2) * 3) + ((nr & 1) * 2)) * sizeof(int))
168 #define VERT_AOS_BUFSZ (5 * sizeof(int))
169 #define ELTS_BUFSZ(nr) (12 + nr * 2)
170 #define VBUF_BUFSZ (3 * sizeof(int))
172 /* Ensure that a minimum amount of space is available in the command buffer.
173 * This is used to ensure atomicity of state updates with the rendering requests
176 * An alternative would be to implement a "soft lock" such that when the buffer
177 * wraps at an inopportune time, we grab the lock, flush the current buffer,
178 * and hang on to the lock until the critical section is finished and we flush
179 * the buffer again and unlock.
181 static __inline
void r200EnsureCmdBufSpace(r200ContextPtr rmesa
, int bytes
)
183 if (rmesa
->store
.cmd_used
+ bytes
> R200_CMD_BUF_SZ
)
184 r200FlushCmdBuf(rmesa
, __FUNCTION__
);
185 assert(bytes
<= R200_CMD_BUF_SZ
);
188 /* Alloc space in the command buffer
190 static __inline
char *r200AllocCmdBuf(r200ContextPtr rmesa
,
191 int bytes
, const char *where
)
195 if (rmesa
->store
.cmd_used
+ bytes
> R200_CMD_BUF_SZ
)
196 r200FlushCmdBuf(rmesa
, where
);
198 head
= rmesa
->store
.cmd_buf
+ rmesa
->store
.cmd_used
;
199 rmesa
->store
.cmd_used
+= bytes
;
200 assert(rmesa
->store
.cmd_used
<= R200_CMD_BUF_SZ
);
204 #endif /* __R200_IOCTL_H__ */