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