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>
51 #include <GL/internal/dri_interface.h>
52 #include "main/mtypes.h"
53 #include "xmlconfig.h"
59 extern const __DRIcoreExtension driCoreExtension
;
60 extern const __DRIdri2Extension driDRI2Extension
;
61 extern const __DRI2configQueryExtension dri2ConfigQueryExtension
;
64 * Driver callback functions.
66 * Each DRI driver must have one of these structures with all the pointers set
67 * to appropriate functions within the driver.
69 * When glXCreateContext() is called, for example, it'll call a helper function
70 * dri_util.c which in turn will jump through the \a CreateContext pointer in
73 struct __DriverAPIRec
{
74 const __DRIconfig
**(*InitScreen
) (__DRIscreen
* priv
);
76 void (*DestroyScreen
)(__DRIscreen
*driScrnPriv
);
78 GLboolean (*CreateContext
)(gl_api api
,
79 const struct gl_config
*glVis
,
80 __DRIcontext
*driContextPriv
,
81 void *sharedContextPrivate
);
83 void (*DestroyContext
)(__DRIcontext
*driContextPriv
);
85 GLboolean (*CreateBuffer
)(__DRIscreen
*driScrnPriv
,
86 __DRIdrawable
*driDrawPriv
,
87 const struct gl_config
*glVis
,
88 GLboolean pixmapBuffer
);
90 void (*DestroyBuffer
)(__DRIdrawable
*driDrawPriv
);
92 void (*SwapBuffers
)(__DRIdrawable
*driDrawPriv
);
94 GLboolean (*MakeCurrent
)(__DRIcontext
*driContextPriv
,
95 __DRIdrawable
*driDrawPriv
,
96 __DRIdrawable
*driReadPriv
);
98 GLboolean (*UnbindContext
)(__DRIcontext
*driContextPriv
);
100 __DRIbuffer
*(*AllocateBuffer
) (__DRIscreen
*screenPrivate
,
101 unsigned int attachment
,
103 int width
, int height
);
105 void (*ReleaseBuffer
) (__DRIscreen
*screenPrivate
, __DRIbuffer
*buffer
);
108 extern const struct __DriverAPIRec driDriverAPI
;
112 * Per-drawable private DRI driver information.
114 struct __DRIdrawableRec
{
116 * Driver's private drawable information.
118 * This structure is opaque.
123 * Private data from the loader. We just hold on to it and pass
124 * it back when calling into loader provided functions.
129 * Reference count for number of context's currently bound to this
132 * Once it reaches zero, the drawable can be destroyed.
134 * \note This behavior will change with GLX 1.3.
139 * Last value of the stamp.
141 * If this differs from the value stored at __DRIdrawable::dri2.stamp,
142 * then the drawable information has been modified by the X server, and the
143 * drawable information (below) should be retrieved from the X server.
145 unsigned int lastStamp
;
150 * Pointer to context to which this drawable is currently bound.
152 __DRIcontext
*driContextPriv
;
155 * Pointer to screen on which this drawable was created.
157 __DRIscreen
*driScreenPriv
;
160 * Drawable timestamp. Increased when the loader calls invalidate.
168 * Per-context private driver information.
170 struct __DRIcontextRec
{
172 * Device driver's private context data. This structure is opaque.
177 * Pointer to drawable currently bound to this context for drawing.
179 __DRIdrawable
*driDrawablePriv
;
182 * Pointer to drawable currently bound to this context for reading.
184 __DRIdrawable
*driReadablePriv
;
187 * Pointer to screen on which this context was created.
189 __DRIscreen
*driScreenPriv
;
192 * The loaders's private context data. This structure is opaque.
203 * Per-screen private driver information.
205 struct __DRIscreenRec
{
207 * Current screen's number
212 * File descriptor returned when the kernel device driver is opened.
215 * - authenticate client to kernel
216 * - map the frame buffer, SAREA, etc.
217 * - close the kernel device driver
222 * DRM (kernel module) version information.
224 __DRIversion drm_version
;
227 * Device-dependent private information (not stored in the SAREA).
229 * This pointer is never touched by the DRI layer.
235 const __DRIextension
**extensions
;
237 const __DRIswrastLoaderExtension
*swrast_loader
;
240 /* Flag to indicate that this is a DRI2 screen. Many of the above
241 * fields will not be valid or initializaed in that case. */
242 __DRIdri2LoaderExtension
*loader
;
243 __DRIimageLookupExtension
*image
;
244 __DRIuseInvalidateExtension
*useInvalidate
;
247 driOptionCache optionInfo
;
248 driOptionCache optionCache
;
250 unsigned int api_mask
;
254 dri2InvalidateDrawable(__DRIdrawable
*drawable
);
257 driUpdateFramebufferSize(struct gl_context
*ctx
, const __DRIdrawable
*dPriv
);
259 #endif /* _DRI_UTIL_H_ */