2 * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
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:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
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.
28 * DRI utility functions definitions.
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
35 * Basically, these utility functions take care of some of the dirty details of
36 * screen initialization, context creation, context binding, DRM setup, etc.
38 * These functions are compiled into each DRI driver so libGL.so knows nothing
43 * \author Kevin E. Martin <kevin@precisioninsight.com>
44 * \author Brian Paul <brian@precisioninsight.com>
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.
57 #include <GL/internal/dri_interface.h>
58 #include "main/mtypes.h"
59 #include "util/xmlconfig.h"
65 extern const __DRIcoreExtension driCoreExtension
;
66 extern const __DRIswrastExtension driSWRastExtension
;
67 extern const __DRIdri2Extension driDRI2Extension
;
68 extern const __DRI2configQueryExtension dri2ConfigQueryExtension
;
69 extern const __DRIcopySubBufferExtension driCopySubBufferExtension
;
71 * Driver callback functions.
73 * Each DRI driver must have one of these structures with all the pointers set
74 * to appropriate functions within the driver.
76 * When glXCreateContext() is called, for example, it'll call a helper function
77 * dri_util.c which in turn will jump through the \a CreateContext pointer in
80 struct __DriverAPIRec
{
81 const __DRIconfig
**(*InitScreen
) (__DRIscreen
* priv
);
83 void (*DestroyScreen
)(__DRIscreen
*driScrnPriv
);
85 GLboolean (*CreateContext
)(gl_api api
,
86 const struct gl_config
*glVis
,
87 __DRIcontext
*driContextPriv
,
88 unsigned major_version
,
89 unsigned minor_version
,
93 void *sharedContextPrivate
);
95 void (*DestroyContext
)(__DRIcontext
*driContextPriv
);
97 GLboolean (*CreateBuffer
)(__DRIscreen
*driScrnPriv
,
98 __DRIdrawable
*driDrawPriv
,
99 const struct gl_config
*glVis
,
100 GLboolean pixmapBuffer
);
102 void (*DestroyBuffer
)(__DRIdrawable
*driDrawPriv
);
104 void (*SwapBuffers
)(__DRIdrawable
*driDrawPriv
);
106 GLboolean (*MakeCurrent
)(__DRIcontext
*driContextPriv
,
107 __DRIdrawable
*driDrawPriv
,
108 __DRIdrawable
*driReadPriv
);
110 GLboolean (*UnbindContext
)(__DRIcontext
*driContextPriv
);
112 __DRIbuffer
*(*AllocateBuffer
) (__DRIscreen
*screenPrivate
,
113 unsigned int attachment
,
115 int width
, int height
);
117 void (*ReleaseBuffer
) (__DRIscreen
*screenPrivate
, __DRIbuffer
*buffer
);
119 void (*CopySubBuffer
)(__DRIdrawable
*driDrawPriv
, int x
, int y
,
123 extern const struct __DriverAPIRec driDriverAPI
;
124 extern const struct __DriverAPIRec
*globalDriverAPI
;
127 * Per-screen private driver information.
129 struct __DRIscreenRec
{
131 * Driver-specific entrypoints provided by the driver's
132 * __DRIDriverVtableExtensionRec.
134 const struct __DriverAPIRec
*driver
;
137 * Current screen's number
142 * File descriptor returned when the kernel device driver is opened.
145 * - authenticate client to kernel
146 * - map the frame buffer, SAREA, etc.
147 * - close the kernel device driver
152 * Device-dependent private information (not stored in the SAREA).
154 * This pointer is never touched by the DRI layer.
160 int max_gl_core_version
;
161 int max_gl_compat_version
;
162 int max_gl_es1_version
;
163 int max_gl_es2_version
;
165 const __DRIextension
**extensions
;
167 const __DRIswrastLoaderExtension
*swrast_loader
;
170 /* Flag to indicate that this is a DRI2 screen. Many of the above
171 * fields will not be valid or initializaed in that case. */
172 const __DRIdri2LoaderExtension
*loader
;
173 const __DRIimageLookupExtension
*image
;
174 const __DRIuseInvalidateExtension
*useInvalidate
;
175 const __DRIbackgroundCallableExtension
*backgroundCallable
;
179 const __DRIimageLoaderExtension
*loader
;
182 driOptionCache optionInfo
;
183 driOptionCache optionCache
;
185 unsigned int api_mask
;
189 * Per-context private driver information.
191 struct __DRIcontextRec
{
193 * Device driver's private context data. This structure is opaque.
198 * The loaders's private context data. This structure is opaque.
203 * Pointer to drawable currently bound to this context for drawing.
205 __DRIdrawable
*driDrawablePriv
;
208 * Pointer to drawable currently bound to this context for reading.
210 __DRIdrawable
*driReadablePriv
;
213 * Pointer to screen on which this context was created.
215 __DRIscreen
*driScreenPriv
;
224 * Per-drawable private DRI driver information.
226 struct __DRIdrawableRec
{
228 * Driver's private drawable information.
230 * This structure is opaque.
235 * Private data from the loader. We just hold on to it and pass
236 * it back when calling into loader provided functions.
241 * Pointer to context to which this drawable is currently bound.
243 __DRIcontext
*driContextPriv
;
246 * Pointer to screen on which this drawable was created.
248 __DRIscreen
*driScreenPriv
;
251 * Reference count for number of context's currently bound to this
254 * Once it reaches zero, the drawable can be destroyed.
256 * \note This behavior will change with GLX 1.3.
261 * Last value of the stamp.
263 * If this differs from the value stored at __DRIdrawable::dri2.stamp,
264 * then the drawable information has been modified by the X server, and the
265 * drawable information (below) should be retrieved from the X server.
267 unsigned int lastStamp
;
272 * Drawable timestamp. Increased when the loader calls invalidate.
280 driGLFormatToImageFormat(mesa_format format
);
283 driImageFormatToGLFormat(uint32_t image_format
);
286 dri2InvalidateDrawable(__DRIdrawable
*drawable
);
289 driUpdateFramebufferSize(struct gl_context
*ctx
, const __DRIdrawable
*dPriv
);
292 driContextSetFlags(struct gl_context
*ctx
, uint32_t flags
);
294 extern const __DRIimageDriverExtension driImageDriverExtension
;
296 extern const __DRInoErrorExtension dri2NoErrorExtension
;
298 #endif /* _DRI_UTIL_H_ */