Disabling some fallbacks as they cause misc programs not to start and adding some...
[mesa.git] / src / mesa / drivers / dri / r300 / r200_ioctl.h
1 /*
2 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
3
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.
7
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:
15
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.
19
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.
27
28 **************************************************************************/
29
30 /*
31 * Authors:
32 * Keith Whitwell <keith@tungstengraphics.com>
33 */
34
35 #ifndef __R200_IOCTL_H__
36 #define __R200_IOCTL_H__
37
38 #include "simple_list.h"
39 #include "radeon_dri.h"
40 #include "radeon_lock.h"
41
42 #include "xf86drm.h"
43 #include "drm.h"
44 #include "r200_context.h"
45 #include "radeon_drm.h"
46
47 extern void r200EmitState(r200ContextPtr rmesa);
48 extern void r200EmitVertexAOS(r200ContextPtr rmesa,
49 GLuint vertex_size, GLuint offset);
50
51 extern void r200EmitVbufPrim(r200ContextPtr rmesa,
52 GLuint primitive, GLuint vertex_nr);
53
54 extern void r200FlushElts(r200ContextPtr rmesa);
55
56 extern GLushort *r200AllocEltsOpenEnded(r200ContextPtr rmesa,
57 GLuint primitive, GLuint min_nr);
58
59 extern void r200EmitAOS(r200ContextPtr rmesa,
60 struct r200_dma_region **regions,
61 GLuint n, GLuint offset);
62
63 extern void r200EmitBlit(r200ContextPtr rmesa,
64 GLuint color_fmt,
65 GLuint src_pitch,
66 GLuint src_offset,
67 GLuint dst_pitch,
68 GLuint dst_offset,
69 GLint srcx, GLint srcy,
70 GLint dstx, GLint dsty, GLuint w, GLuint h);
71
72 extern void r200EmitWait(r200ContextPtr rmesa, GLuint flags);
73
74 extern void r200FlushCmdBuf(r200ContextPtr rmesa, const char *);
75 extern int r200FlushCmdBufLocked(r200ContextPtr rmesa, const char *caller);
76 extern void r200Flush(GLcontext * ctx);
77
78 extern void r200RefillCurrentDmaRegion(r200ContextPtr rmesa);
79
80 extern void r200AllocDmaRegion(r200ContextPtr rmesa,
81 struct r200_dma_region *region,
82 int bytes, int alignment);
83
84 extern void r200AllocDmaRegionVerts(r200ContextPtr rmesa,
85 struct r200_dma_region *region,
86 int numverts, int vertsize, int alignment);
87
88 extern void r200ReleaseDmaRegion(r200ContextPtr rmesa,
89 struct r200_dma_region *region,
90 const char *caller);
91
92 extern void r200WaitForVBlank(r200ContextPtr rmesa);
93 extern void r200InitIoctlFuncs(struct dd_function_table *functions);
94
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,
99 GLvoid * pointer);
100 extern GLuint r200GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
101 const GLvoid * pointer);
102
103 extern GLboolean r200IsGartMemory(r200ContextPtr rmesa, const GLvoid * pointer,
104 GLint size);
105
106 extern GLuint r200GartOffsetFromVirtual(r200ContextPtr rmesa,
107 const GLvoid * pointer);
108
109 void r200SaveHwState(r200ContextPtr radeon);
110 void r200SetUpAtomList(r200ContextPtr rmesa);
111
112 /* ================================================================
113 * Helper macros:
114 */
115
116 /* Close off the last primitive, if it exists.
117 */
118 #define R200_NEWPRIM( rmesa ) \
119 do { \
120 if ( rmesa->dma.flush ) \
121 rmesa->dma.flush( rmesa ); \
122 } while (0)
123
124 /* Can accomodate several state changes and primitive changes without
125 * actually firing the buffer.
126 */
127 #define R200_STATECHANGE( rmesa, ATOM ) \
128 do { \
129 R200_NEWPRIM( rmesa ); \
130 rmesa->hw.ATOM.dirty = GL_TRUE; \
131 rmesa->hw.is_dirty = GL_TRUE; \
132 } while (0)
133
134 #define R200_DB_STATE( ATOM ) \
135 memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
136 rmesa->hw.ATOM.cmd_size * 4)
137
138 static __inline int R200_DB_STATECHANGE(r200ContextPtr rmesa,
139 struct r200_state_atom *atom)
140 {
141 if (memcmp(atom->cmd, atom->lastcmd, atom->cmd_size * 4)) {
142 int *tmp;
143 R200_NEWPRIM(rmesa);
144 atom->dirty = GL_TRUE;
145 rmesa->hw.is_dirty = GL_TRUE;
146 tmp = atom->cmd;
147 atom->cmd = atom->lastcmd;
148 atom->lastcmd = tmp;
149 return 1;
150 } else
151 return 0;
152 }
153
154 /* Fire the buffered vertices no matter what.
155 */
156 #define R200_FIREVERTICES( r200 ) \
157 do { \
158 if ( (r200)->store.cmd_used || (r200)->dma.flush ) { \
159 radeonFlush( (r200)->radeon.glCtx ); \
160 } \
161 } while (0)
162
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.
166 */
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))
171
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
174 * that rely on them.
175 *
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.
180 */
181 static __inline void r200EnsureCmdBufSpace(r200ContextPtr rmesa, int bytes)
182 {
183 if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
184 r200FlushCmdBuf(rmesa, __FUNCTION__);
185 assert(bytes <= R200_CMD_BUF_SZ);
186 }
187
188 /* Alloc space in the command buffer
189 */
190 static __inline char *r200AllocCmdBuf(r200ContextPtr rmesa,
191 int bytes, const char *where)
192 {
193 char *head;
194
195 if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
196 r200FlushCmdBuf(rmesa, where);
197
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);
201 return head;
202 }
203
204 #endif /* __R200_IOCTL_H__ */