~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/gallium/include/state_tracker/st_api.h

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************
 
2
 * Copyright 2010 VMware, Inc.  All rights reserved.
 
3
 *
 
4
 * Permission is hereby granted, free of charge, to any person
 
5
 * obtaining a copy of this software and associated documentation
 
6
 * files (the "Software"), to deal in the Software without
 
7
 * restriction, including without limitation the rights to use, copy,
 
8
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 
9
 * of the Software, and to permit persons to whom the Software is
 
10
 * furnished to do so, subject to the following conditions:
 
11
 *
 
12
 * The above copyright notice and this permission notice shall be
 
13
 * included in all copies or substantial portions of the Software.
 
14
 *
 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
16
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
18
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 
19
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 
20
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
21
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
22
 * SOFTWARE.
 
23
 *
 
24
 **********************************************************/
 
25
 
 
26
 
 
27
#ifndef _ST_API_H_
 
28
#define _ST_API_H_
 
29
 
 
30
#include "pipe/p_compiler.h"
 
31
#include "pipe/p_format.h"
 
32
 
 
33
/**
 
34
 * \file API for communication between state trackers and state tracker
 
35
 * managers.
 
36
 *
 
37
 * While both are state tackers, we use the term state tracker for rendering
 
38
 * APIs such as OpenGL or OpenVG, and state tracker manager for window system
 
39
 * APIs such as EGL or GLX in this file.
 
40
 *
 
41
 * This file defines an API to be implemented by both state trackers and state
 
42
 * tracker managers.
 
43
 */
 
44
 
 
45
/**
 
46
 * The supported rendering API of a state tracker.
 
47
 */
 
48
enum st_api_type {
 
49
   ST_API_OPENGL,
 
50
   ST_API_OPENGL_ES1,
 
51
   ST_API_OPENGL_ES2,
 
52
   ST_API_OPENVG,
 
53
 
 
54
   ST_API_COUNT
 
55
};
 
56
 
 
57
/**
 
58
 * Used in st_context_iface->teximage.
 
59
 */
 
60
enum st_texture_type {
 
61
   ST_TEXTURE_1D,
 
62
   ST_TEXTURE_2D,
 
63
   ST_TEXTURE_3D,
 
64
   ST_TEXTURE_RECT
 
65
};
 
66
 
 
67
/**
 
68
 * Available attachments of framebuffer.
 
69
 */
 
70
enum st_attachment_type {
 
71
   ST_ATTACHMENT_FRONT_LEFT,
 
72
   ST_ATTACHMENT_BACK_LEFT,
 
73
   ST_ATTACHMENT_FRONT_RIGHT,
 
74
   ST_ATTACHMENT_BACK_RIGHT,
 
75
   ST_ATTACHMENT_DEPTH_STENCIL,
 
76
   ST_ATTACHMENT_ACCUM,
 
77
   ST_ATTACHMENT_SAMPLE,
 
78
 
 
79
   ST_ATTACHMENT_COUNT,
 
80
   ST_ATTACHMENT_INVALID = -1
 
81
};
 
82
 
 
83
/* for buffer_mask in st_visual */
 
84
#define ST_ATTACHMENT_FRONT_LEFT_MASK     (1 << ST_ATTACHMENT_FRONT_LEFT)
 
85
#define ST_ATTACHMENT_BACK_LEFT_MASK      (1 << ST_ATTACHMENT_BACK_LEFT)
 
86
#define ST_ATTACHMENT_FRONT_RIGHT_MASK    (1 << ST_ATTACHMENT_FRONT_RIGHT)
 
87
#define ST_ATTACHMENT_BACK_RIGHT_MASK     (1 << ST_ATTACHMENT_BACK_RIGHT)
 
88
#define ST_ATTACHMENT_DEPTH_STENCIL_MASK  (1 << ST_ATTACHMENT_DEPTH_STENCIL)
 
89
#define ST_ATTACHMENT_ACCUM_MASK          (1 << ST_ATTACHMENT_ACCUM)
 
90
#define ST_ATTACHMENT_SAMPLE_MASK         (1 << ST_ATTACHMENT_SAMPLE)
 
91
 
 
92
/**
 
93
 * Enumerations of state tracker context resources.
 
94
 */
 
95
enum st_context_resource_type {
 
96
   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_2D,
 
97
   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_3D,
 
98
   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_X,
 
99
   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_X,
 
100
   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_Y,
 
101
   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
 
102
   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_Z,
 
103
   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
 
104
   ST_CONTEXT_RESOURCE_OPENGL_RENDERBUFFER,
 
105
   ST_CONTEXT_RESOURCE_OPENVG_PARENT_IMAGE
 
106
};
 
107
 
 
108
/**
 
109
 * Value to st_manager->get_param function.
 
110
 */
 
111
enum st_manager_param {
 
112
   /**
 
113
    * The dri state tracker on old libGL's doesn't do the right thing
 
114
    * with regards to invalidating the framebuffers.
 
115
    *
 
116
    * For the mesa state tracker that means that it needs to invalidate
 
117
    * the framebuffer in glViewport itself.
 
118
    */
 
119
   ST_MANAGER_BROKEN_INVALIDATE
 
120
};
 
121
 
 
122
/**
 
123
 * The return type of st_api->get_proc_address.
 
124
 */
 
125
typedef void (*st_proc_t)(void);
 
126
 
 
127
struct pipe_context;
 
128
struct pipe_resource;
 
129
struct pipe_fence_handle;
 
130
 
 
131
/**
 
132
 * Used in st_context_iface->get_resource_for_egl_image.
 
133
 */
 
134
struct st_context_resource
 
135
{
 
136
   /* these fields are filled by the caller */
 
137
   enum st_context_resource_type type;
 
138
   void *resource;
 
139
 
 
140
   /* this is owned by the caller */
 
141
   struct pipe_resource *texture;
 
142
};
 
143
 
 
144
/**
 
145
 * Used in st_manager_iface->get_egl_image.
 
146
 */
 
147
struct st_egl_image
 
148
{
 
149
   /* this is owned by the caller */
 
150
   struct pipe_resource *texture;
 
151
 
 
152
   unsigned face;
 
153
   unsigned level;
 
154
   unsigned zslice;
 
155
};
 
156
 
 
157
/**
 
158
 * Represent the visual of a framebuffer.
 
159
 */
 
160
struct st_visual
 
161
{
 
162
   /**
 
163
    * Available buffers.  Tested with ST_FRAMEBUFFER_*_MASK.
 
164
    */
 
165
   unsigned buffer_mask;
 
166
 
 
167
   /**
 
168
    * Buffer formats.  The formats are always set even when the buffer is
 
169
    * not available.
 
170
    */
 
171
   enum pipe_format color_format;
 
172
   enum pipe_format depth_stencil_format;
 
173
   enum pipe_format accum_format;
 
174
   int samples;
 
175
 
 
176
   /**
 
177
    * Desired render buffer.
 
178
    */
 
179
   enum st_attachment_type render_buffer;
 
180
};
 
181
 
 
182
/**
 
183
 * Represent a windowing system drawable.
 
184
 *
 
185
 * The framebuffer is implemented by the state tracker manager and
 
186
 * used by the state trackers.
 
187
 *
 
188
 * Instead of the winsys pokeing into the API context to figure
 
189
 * out what buffers that might be needed in the future by the API
 
190
 * context, it calls into the framebuffer to get the textures.
 
191
 *
 
192
 * This structure along with the notify_invalid_framebuffer
 
193
 * allows framebuffers to be shared between different threads
 
194
 * but at the same make the API context free from thread
 
195
 * syncronisation primitves, with the exception of a small
 
196
 * atomic flag used for notification of framebuffer dirty status.
 
197
 *
 
198
 * The thread syncronisation is put inside the framebuffer
 
199
 * and only called once the framebuffer has become dirty.
 
200
 */
 
201
struct st_framebuffer_iface
 
202
{
 
203
   /**
 
204
    * Available for the state tracker manager to use.
 
205
    */
 
206
   void *st_manager_private;
 
207
 
 
208
   /**
 
209
    * The visual of a framebuffer.
 
210
    */
 
211
   const struct st_visual *visual;
 
212
 
 
213
   /**
 
214
    * Flush the front buffer.
 
215
    *
 
216
    * On some window systems, changes to the front buffers are not immediately
 
217
    * visible.  They need to be flushed.
 
218
    *
 
219
    * @att is one of the front buffer attachments.
 
220
    */
 
221
   boolean (*flush_front)(struct st_framebuffer_iface *stfbi,
 
222
                          enum st_attachment_type statt);
 
223
 
 
224
   /**
 
225
    * The state tracker asks for the textures it needs.
 
226
    *
 
227
    * It should try to only ask for attachments that it currently renders
 
228
    * to, thus allowing the winsys to delay the allocation of textures not
 
229
    * needed. For example front buffer attachments are not needed if you
 
230
    * only do back buffer rendering.
 
231
    *
 
232
    * The implementor of this function needs to also ensure
 
233
    * thread safty as this call might be done from multiple threads.
 
234
    *
 
235
    * The returned textures are owned by the caller.  They should be
 
236
    * unreferenced when no longer used.  If this function is called multiple
 
237
    * times with different sets of attachments, those buffers not included in
 
238
    * the last call might be destroyed.  This behavior might change in the
 
239
    * future.
 
240
    */
 
241
   boolean (*validate)(struct st_framebuffer_iface *stfbi,
 
242
                       const enum st_attachment_type *statts,
 
243
                       unsigned count,
 
244
                       struct pipe_resource **out);
 
245
};
 
246
 
 
247
/**
 
248
 * Represent a rendering context.
 
249
 *
 
250
 * This entity is created from st_api and used by the state tracker manager.
 
251
 */
 
252
struct st_context_iface
 
253
{
 
254
   /**
 
255
    * Available for the state tracker and the manager to use.
 
256
    */
 
257
   void *st_context_private;
 
258
   void *st_manager_private;
 
259
 
 
260
   /**
 
261
    * Destroy the context.
 
262
    */
 
263
   void (*destroy)(struct st_context_iface *stctxi);
 
264
 
 
265
   /**
 
266
    * Invalidate the current textures that was taken from a framebuffer.
 
267
    *
 
268
    * The state tracker manager calls this function to let the rendering
 
269
    * context know that it should update the textures it got from
 
270
    * st_framebuffer_iface::validate.  It should do so at the latest time possible.
 
271
    * Possible right before sending triangles to the pipe context.
 
272
    *
 
273
    * For certain platforms this function might be called from a thread other
 
274
    * than the thread that the context is currently bound in, and must
 
275
    * therefore be thread safe. But it is the state tracker manager's
 
276
    * responsibility to make sure that the framebuffer is bound to the context
 
277
    * and the API context is current for the duration of this call.
 
278
    *
 
279
    * Thus reducing the sync primitive needed to a single atomic flag.
 
280
    */
 
281
   void (*notify_invalid_framebuffer)(struct st_context_iface *stctxi,
 
282
                                      struct st_framebuffer_iface *stfbi);
 
283
 
 
284
   /**
 
285
    * Flush all drawing from context to the pipe also flushes the pipe.
 
286
    */
 
287
   void (*flush)(struct st_context_iface *stctxi, unsigned flags,
 
288
                 struct pipe_fence_handle **fence);
 
289
 
 
290
   /**
 
291
    * Replace the texture image of a texture object at the specified level.
 
292
    *
 
293
    * This function is optional.
 
294
    */
 
295
   boolean (*teximage)(struct st_context_iface *stctxi, enum st_texture_type target,
 
296
                       int level, enum pipe_format internal_format,
 
297
                       struct pipe_resource *tex, boolean mipmap);
 
298
 
 
299
   /**
 
300
    * Used to implement glXCopyContext.
 
301
    */
 
302
   void (*copy)(struct st_context_iface *stctxi,
 
303
                struct st_context_iface *stsrci, unsigned mask);
 
304
 
 
305
   /**
 
306
    * Look up and return the info of a resource for EGLImage.
 
307
    *
 
308
    * This function is optional.
 
309
    */
 
310
   boolean (*get_resource_for_egl_image)(struct st_context_iface *stctxi,
 
311
                                         struct st_context_resource *stres);
 
312
};
 
313
 
 
314
 
 
315
/**
 
316
 * Represent a state tracker manager.
 
317
 *
 
318
 * This interface is implemented by the state tracker manager.  It corresponds
 
319
 * to a "display" in the window system.
 
320
 */
 
321
struct st_manager
 
322
{
 
323
   struct pipe_screen *screen;
 
324
 
 
325
   /**
 
326
    * Look up and return the info of an EGLImage.
 
327
    *
 
328
    * This is used to implement for example EGLImageTargetTexture2DOES.
 
329
    * The GLeglImageOES agrument of that call is passed directly to this
 
330
    * function call and the information needed to access this is returned
 
331
    * in the given struct out.
 
332
    *
 
333
    * @smapi: manager owning the caller context
 
334
    * @stctx: caller context
 
335
    * @egl_image: EGLImage that caller recived
 
336
    * @out: return struct filled out with access information.
 
337
    *
 
338
    * This function is optional.
 
339
    */
 
340
   boolean (*get_egl_image)(struct st_manager *smapi,
 
341
                            struct st_context_iface *stctx,
 
342
                            void *egl_image,
 
343
                            struct st_egl_image *out);
 
344
 
 
345
   /**
 
346
    * Query an manager param.
 
347
    */
 
348
   int (*get_param)(struct st_manager *smapi,
 
349
                    enum st_manager_param param);
 
350
};
 
351
 
 
352
/**
 
353
 * Represent a rendering API such as OpenGL or OpenVG.
 
354
 *
 
355
 * Implemented by the state tracker and used by the state tracker manager.
 
356
 */
 
357
struct st_api
 
358
{
 
359
   /**
 
360
    * Destroy the API.
 
361
    */
 
362
   void (*destroy)(struct st_api *stapi);
 
363
 
 
364
   /**
 
365
    * Return an API entry point.
 
366
    *
 
367
    * For GL this is the same as _glapi_get_proc_address.
 
368
    */
 
369
   st_proc_t (*get_proc_address)(struct st_api *stapi, const char *procname);
 
370
 
 
371
   /**
 
372
    * Create a rendering context.
 
373
    */
 
374
   struct st_context_iface *(*create_context)(struct st_api *stapi,
 
375
                                              struct st_manager *smapi,
 
376
                                              const struct st_visual *visual,
 
377
                                              struct st_context_iface *stsharei);
 
378
 
 
379
   /**
 
380
    * Bind the context to the calling thread with draw and read as drawables.
 
381
    *
 
382
    * The framebuffers might have different visuals than the context does.
 
383
    */
 
384
   boolean (*make_current)(struct st_api *stapi,
 
385
                           struct st_context_iface *stctxi,
 
386
                           struct st_framebuffer_iface *stdrawi,
 
387
                           struct st_framebuffer_iface *streadi);
 
388
 
 
389
   /**
 
390
    * Get the currently bound context in the calling thread.
 
391
    */
 
392
   struct st_context_iface *(*get_current)(struct st_api *stapi);
 
393
};
 
394
 
 
395
/**
 
396
 * Return true if the visual has the specified buffers.
 
397
 */
 
398
static INLINE boolean
 
399
st_visual_have_buffers(const struct st_visual *visual, unsigned mask)
 
400
{
 
401
   return ((visual->buffer_mask & mask) == mask);
 
402
}
 
403
 
 
404
/* these symbols may need to be dynamically lookup up */
 
405
extern PUBLIC struct st_api * st_api_create_OpenGL(void);
 
406
extern PUBLIC struct st_api * st_api_create_OpenGL_ES1(void);
 
407
extern PUBLIC struct st_api * st_api_create_OpenGL_ES2(void);
 
408
extern PUBLIC struct st_api * st_api_create_OpenVG(void);
 
409
 
 
410
/**
 
411
 * The entry points of the state trackers.
 
412
 */
 
413
#define ST_CREATE_OPENGL_SYMBOL      "st_api_create_OpenGL"
 
414
#define ST_CREATE_OPENGL_ES1_SYMBOL  "st_api_create_OpenGL_ES1"
 
415
#define ST_CREATE_OPENGL_ES2_SYMBOL  "st_api_create_OpenGL_ES2"
 
416
#define ST_CREATE_OPENVG_SYMBOL      "st_api_create_OpenVG"
 
417
 
 
418
#endif /* _ST_API_H_ */