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 "xmlconfig.h"
64 extern const __DRIcoreExtension driCoreExtension
;
65 extern const __DRIswrastExtension driSWRastExtension
;
66 extern const __DRIdri2Extension driDRI2Extension
;
67 extern const __DRI2configQueryExtension dri2ConfigQueryExtension
;
70 * Driver callback functions.
72 * Each DRI driver must have one of these structures with all the pointers set
73 * to appropriate functions within the driver.
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
79 struct __DriverAPIRec
{
80 const __DRIconfig
**(*InitScreen
) (__DRIscreen
* priv
);
82 void (*DestroyScreen
)(__DRIscreen
*driScrnPriv
);
84 GLboolean (*CreateContext
)(gl_api api
,
85 const struct gl_config
*glVis
,
86 __DRIcontext
*driContextPriv
,
87 void *sharedContextPrivate
);
89 void (*DestroyContext
)(__DRIcontext
*driContextPriv
);
91 GLboolean (*CreateBuffer
)(__DRIscreen
*driScrnPriv
,
92 __DRIdrawable
*driDrawPriv
,
93 const struct gl_config
*glVis
,
94 GLboolean pixmapBuffer
);
96 void (*DestroyBuffer
)(__DRIdrawable
*driDrawPriv
);
98 void (*SwapBuffers
)(__DRIdrawable
*driDrawPriv
);
100 GLboolean (*MakeCurrent
)(__DRIcontext
*driContextPriv
,
101 __DRIdrawable
*driDrawPriv
,
102 __DRIdrawable
*driReadPriv
);
104 GLboolean (*UnbindContext
)(__DRIcontext
*driContextPriv
);
106 __DRIbuffer
*(*AllocateBuffer
) (__DRIscreen
*screenPrivate
,
107 unsigned int attachment
,
109 int width
, int height
);
111 void (*ReleaseBuffer
) (__DRIscreen
*screenPrivate
, __DRIbuffer
*buffer
);
114 extern const struct __DriverAPIRec driDriverAPI
;
118 * Per-screen private driver information.
120 struct __DRIscreenRec
{
122 * Current screen's number
127 * File descriptor returned when the kernel device driver is opened.
130 * - authenticate client to kernel
131 * - map the frame buffer, SAREA, etc.
132 * - close the kernel device driver
137 * DRM (kernel module) version information.
139 __DRIversion drm_version
;
142 * Device-dependent private information (not stored in the SAREA).
144 * This pointer is never touched by the DRI layer.
150 const __DRIextension
**extensions
;
152 const __DRIswrastLoaderExtension
*swrast_loader
;
155 /* Flag to indicate that this is a DRI2 screen. Many of the above
156 * fields will not be valid or initializaed in that case. */
157 __DRIdri2LoaderExtension
*loader
;
158 __DRIimageLookupExtension
*image
;
159 __DRIuseInvalidateExtension
*useInvalidate
;
162 driOptionCache optionInfo
;
163 driOptionCache optionCache
;
165 unsigned int api_mask
;
169 * Per-context private driver information.
171 struct __DRIcontextRec
{
173 * Device driver's private context data. This structure is opaque.
178 * The loaders's private context data. This structure is opaque.
183 * Pointer to drawable currently bound to this context for drawing.
185 __DRIdrawable
*driDrawablePriv
;
188 * Pointer to drawable currently bound to this context for reading.
190 __DRIdrawable
*driReadablePriv
;
193 * Pointer to screen on which this context was created.
195 __DRIscreen
*driScreenPriv
;
204 * Per-drawable private DRI driver information.
206 struct __DRIdrawableRec
{
208 * Driver's private drawable information.
210 * This structure is opaque.
215 * Private data from the loader. We just hold on to it and pass
216 * it back when calling into loader provided functions.
221 * Pointer to context to which this drawable is currently bound.
223 __DRIcontext
*driContextPriv
;
226 * Pointer to screen on which this drawable was created.
228 __DRIscreen
*driScreenPriv
;
231 * Reference count for number of context's currently bound to this
234 * Once it reaches zero, the drawable can be destroyed.
236 * \note This behavior will change with GLX 1.3.
241 * Last value of the stamp.
243 * If this differs from the value stored at __DRIdrawable::dri2.stamp,
244 * then the drawable information has been modified by the X server, and the
245 * drawable information (below) should be retrieved from the X server.
247 unsigned int lastStamp
;
252 * Drawable timestamp. Increased when the loader calls invalidate.
260 dri2InvalidateDrawable(__DRIdrawable
*drawable
);
263 driUpdateFramebufferSize(struct gl_context
*ctx
, const __DRIdrawable
*dPriv
);
265 #endif /* _DRI_UTIL_H_ */