mesa: GL_NV_blend_square is not optional
[mesa.git] / src / mesa / drivers / dri / common / dri_util.h
1 /*
2 * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 /**
27 * \file dri_util.h
28 * DRI utility functions definitions.
29 *
30 * This module acts as glue between GLX and the actual hardware driver. A DRI
31 * driver doesn't really \e have to use any of this - it's optional. But, some
32 * useful stuff is done here that otherwise would have to be duplicated in most
33 * drivers.
34 *
35 * Basically, these utility functions take care of some of the dirty details of
36 * screen initialization, context creation, context binding, DRM setup, etc.
37 *
38 * These functions are compiled into each DRI driver so libGL.so knows nothing
39 * about them.
40 *
41 * \sa dri_util.c.
42 *
43 * \author Kevin E. Martin <kevin@precisioninsight.com>
44 * \author Brian Paul <brian@precisioninsight.com>
45 */
46
47 /**
48 * The following structs are shared between DRISW and DRI2, the DRISW structs
49 * are essentially base classes of the DRI2 structs. DRISW needs to compile on
50 * platforms without DRM, so keep the structs opaque to DRM.
51 */
52
53 #ifndef _DRI_UTIL_H_
54 #define _DRI_UTIL_H_
55
56 #include <GL/gl.h>
57 #include <GL/internal/dri_interface.h>
58 #include "main/mtypes.h"
59 #include "xmlconfig.h"
60
61 /**
62 * Extensions.
63 */
64 extern const __DRIcoreExtension driCoreExtension;
65 extern const __DRIswrastExtension driSWRastExtension;
66 extern const __DRIdri2Extension driDRI2Extension;
67 extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
68
69 /**
70 * Driver callback functions.
71 *
72 * Each DRI driver must have one of these structures with all the pointers set
73 * to appropriate functions within the driver.
74 *
75 * When glXCreateContext() is called, for example, it'll call a helper function
76 * dri_util.c which in turn will jump through the \a CreateContext pointer in
77 * this structure.
78 */
79 struct __DriverAPIRec {
80 const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
81
82 void (*DestroyScreen)(__DRIscreen *driScrnPriv);
83
84 GLboolean (*CreateContext)(gl_api api,
85 const struct gl_config *glVis,
86 __DRIcontext *driContextPriv,
87 unsigned major_version,
88 unsigned minor_version,
89 uint32_t flags,
90 unsigned *error,
91 void *sharedContextPrivate);
92
93 void (*DestroyContext)(__DRIcontext *driContextPriv);
94
95 GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv,
96 __DRIdrawable *driDrawPriv,
97 const struct gl_config *glVis,
98 GLboolean pixmapBuffer);
99
100 void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
101
102 void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
103
104 GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
105 __DRIdrawable *driDrawPriv,
106 __DRIdrawable *driReadPriv);
107
108 GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
109
110 __DRIbuffer *(*AllocateBuffer) (__DRIscreen *screenPrivate,
111 unsigned int attachment,
112 unsigned int format,
113 int width, int height);
114
115 void (*ReleaseBuffer) (__DRIscreen *screenPrivate, __DRIbuffer *buffer);
116 };
117
118 extern const struct __DriverAPIRec driDriverAPI;
119
120
121 /**
122 * Per-screen private driver information.
123 */
124 struct __DRIscreenRec {
125 /**
126 * Current screen's number
127 */
128 int myNum;
129
130 /**
131 * File descriptor returned when the kernel device driver is opened.
132 *
133 * Used to:
134 * - authenticate client to kernel
135 * - map the frame buffer, SAREA, etc.
136 * - close the kernel device driver
137 */
138 int fd;
139
140 /**
141 * DRM (kernel module) version information.
142 */
143 __DRIversion drm_version;
144
145 /**
146 * Device-dependent private information (not stored in the SAREA).
147 *
148 * This pointer is never touched by the DRI layer.
149 */
150 void *driverPrivate;
151
152 void *loaderPrivate;
153
154 const __DRIextension **extensions;
155
156 const __DRIswrastLoaderExtension *swrast_loader;
157
158 struct {
159 /* Flag to indicate that this is a DRI2 screen. Many of the above
160 * fields will not be valid or initializaed in that case. */
161 __DRIdri2LoaderExtension *loader;
162 __DRIimageLookupExtension *image;
163 __DRIuseInvalidateExtension *useInvalidate;
164 } dri2;
165
166 driOptionCache optionInfo;
167 driOptionCache optionCache;
168
169 unsigned int api_mask;
170 };
171
172 /**
173 * Per-context private driver information.
174 */
175 struct __DRIcontextRec {
176 /**
177 * Device driver's private context data. This structure is opaque.
178 */
179 void *driverPrivate;
180
181 /**
182 * The loaders's private context data. This structure is opaque.
183 */
184 void *loaderPrivate;
185
186 /**
187 * Pointer to drawable currently bound to this context for drawing.
188 */
189 __DRIdrawable *driDrawablePriv;
190
191 /**
192 * Pointer to drawable currently bound to this context for reading.
193 */
194 __DRIdrawable *driReadablePriv;
195
196 /**
197 * Pointer to screen on which this context was created.
198 */
199 __DRIscreen *driScreenPriv;
200
201 struct {
202 int draw_stamp;
203 int read_stamp;
204 } dri2;
205 };
206
207 /**
208 * Per-drawable private DRI driver information.
209 */
210 struct __DRIdrawableRec {
211 /**
212 * Driver's private drawable information.
213 *
214 * This structure is opaque.
215 */
216 void *driverPrivate;
217
218 /**
219 * Private data from the loader. We just hold on to it and pass
220 * it back when calling into loader provided functions.
221 */
222 void *loaderPrivate;
223
224 /**
225 * Pointer to context to which this drawable is currently bound.
226 */
227 __DRIcontext *driContextPriv;
228
229 /**
230 * Pointer to screen on which this drawable was created.
231 */
232 __DRIscreen *driScreenPriv;
233
234 /**
235 * Reference count for number of context's currently bound to this
236 * drawable.
237 *
238 * Once it reaches zero, the drawable can be destroyed.
239 *
240 * \note This behavior will change with GLX 1.3.
241 */
242 int refcount;
243
244 /**
245 * Last value of the stamp.
246 *
247 * If this differs from the value stored at __DRIdrawable::dri2.stamp,
248 * then the drawable information has been modified by the X server, and the
249 * drawable information (below) should be retrieved from the X server.
250 */
251 unsigned int lastStamp;
252
253 int w, h;
254
255 /**
256 * Drawable timestamp. Increased when the loader calls invalidate.
257 */
258 struct {
259 unsigned int stamp;
260 } dri2;
261 };
262
263 extern void
264 dri2InvalidateDrawable(__DRIdrawable *drawable);
265
266 extern void
267 driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv);
268
269 #endif /* _DRI_UTIL_H_ */