summaryrefslogtreecommitdiff
path: root/src/egl/docs/EGL_MESA_screen_surface
blob: 6beb4ce88e278eab8ce1f5ab906d705a9ee82755 (plain)
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
Name

    MESA_screen_surface

Name Strings

    EGL_MESA_screen_surface

Contact

    Brian Paul

    To discuss, join the dri-egl@lists.freedesktop.org list.

Status

    Preliminary - totally subject to change.

Version

    11 (27 January 2006)

Number

    TBD

Dependencies

    EGL 1.0 or later.

Overview

    EGL 1.1 supports three types of drawing surfaces:
      * Window surfaces
      * Pixmap surfaces
      * Pbuffer surfaces
    This extension defines a fourth type of drawing surface:
      * Screen surface

    A screen surface is a surface for which the (front) color buffer can
    be directly displayed (i.e. scanned out) on a monitor (such as a flat
    panel or CRT).  In particular the color buffer memory will be allocated
    at a location in VRAM (and in a suitable format) which can be displayed
    by the graphics hardware.

    Note that the width and height of the screen surface need not exactly
    match the monitor's current resolution.  For example, while the monitor
    may be configured to to show 1024x768 pixels, the associated screen
    surface may be larger, such as 1200x1000.  The "screen origin" attribute
    will specify which region of the screen surface which is visible on the
    monitor.  The screen surface can be scrolled by changing this origin.

    This extension also defines functions for controlling the monitor's
    display mode (width, height, refresh rate, etc), and specifing which
    screen surface is to be displayed on a monitor.

    The new EGLModeMESA type and related functions are very similar to the
    EGLConfig type and related functions.  The user may get a list of
    supported modes for a screen and specify the mode to be used when
    displaying a screen surface.


Issues

    1. Should EGL_INTERLACE be a supported mode attribute?

       Arguments against:

           No, this should be provided by another extension which would
           also provide the mechanisms needed to play back interlaced video
           material correctly on hardware that supports it.
           This extension should prefer non-interlaced modes. [M. Danzer]

       Arguments for:

           An interlaced display can be of use without considering video
           material.  Being able to query whether a screen is operating in
           interlaced mode can be used by applications to control their
           drawing.  For example: avoid drawing 1-pixel-wide horizontal lines
           if screen is interlaced. [B. Paul]

       Resolution: Defer for future extension?


    2. Should EGL_REFRESH_RATE be a supported mode attribute?

       Arguments for:

           Yes, it's been shown that applications and/or users need to select
           modes by this.  [M. Danzer]

           Many examples have been given in which it's desirable to let the
           user choose from a variety of refresh rates without having to
           restart/reconfigure.  [B. Paul]

       Arguments against:

           TBD.

       Resolution: Yes.


    3. Exactly how should the list of modes returned by eglChooseConfigMESA
       be sorted?

       Current method is described in the text below.  Subject to change.

       Alternately, leave the sorting order undefined so that each
       implementation can return the modes in order of "most desirable"
       to "least desirable" which may depend on the display technology
       (CRT vs LCD, etc) or other factors.


    4. How should screen blanking be supported?  Note that a screen can be
       disabled or turned off by calling eglShowSurface(dpy, scrn,
       EGL_NO_SURFACE, EGL_NO_MODE_MESA).  But what about power-save mode?

       I would defer this to other extensions that depend on this one.
       I can imagine people wanting different semantics not just in
       relation to the power management API being exposed (DPMS or whatever)
       but also relating to what events can trigger EGL_CONTEXT_LOST.  Also
       I'm not sure whether power management commands are properly operations
       on the Display or on a screen surface. [A. Jackson]


    5. Should the EGL_PHYSICAL_SIZE_EGL query be kept?  The size information
       isn't always reliable (consider video projectors) but can still be
       used to determine the pixel aspect ratio.

       Resolution: Omit.  The EGL 1.2 specification includes queries for
       the display resolution and pixel aspect ratio.


    6. Should detailed mode timing information be exposed by this API?

       Probably not.  Instead, offer that information in a layered extension.


    7. How should the notion of a screen's "native" mode be expressed?
       For example, LCD panels have a native resolution and refresh rate
       that looks best but other sub-optimal resolutions may be supported.

       The mode attribute EGL_OPTIMAL_MESA will be set for modes which
       best match the screen.  [M. Danzer]


    8. Should eglQueryModeStringMESA() be included?  This function returns
       a human-readable string which corresponds to an EGLMode.

       Arguments for:

           A mode name such as "HDTV-720P" might mean more to users than
           "1280x720@60Hz" if the later were generated via code.

       Arguments against:

           There's no standard syntax for the strings.  May cause more
           trouble than it's worth.

       Postpone for future extension. [A. Jackson]

       Latest discussion leaning toward omitting this function.


    9. Should we use "Get" or "Query" for functions which return state?
       The EGL 1.x specification doesn't seem to be totally consistent
       in this regard, but "Query" is used more often.

       Use "Get" for mode-related queries (as for EGLConfigs) but "Query"
       for everything else.


    10. What should be the default size for screen surfaces?

        For Pbuffer surfaces the default width and height are zero.
        We'll do the same for screen surfaces.  Since there's no function
        to resize surfaces it's useless to have a 0x0 screen, but this isn't
        a situation that'll normally be encountered.


    11. Should there be a function for resizing a screen surface?

        Suppose one wants to change the screen's size in the EGL application.
        Also suppose there's a hardware restriction such that only one screen
        surface can exist at a time (either for lack of memory or because of
        memory layout restrictions).

        The basic idea is that the currently displayed screen surface must
        be deallocated before a new one can be created.  Perhaps a resize
        function would work better?


    12. How should sub-pixel LCD color information be made available?
        What about the display's gamma value?

        Perhaps expose as additional read-only mode attributes.

        Perhaps postpone for a layered extension.


    13. What happens if the user attempts to delete a screen surface that
        is currently being shown?

        Spec currently says that's illegal and that an error (TBD) will be
        generated.


    14. What if the physical screen size can't be determined?  Should
        a query of EGL_PHYSICAL_SIZE_MESA return [0,0]?

        Obsolete: EGL_PHYSICAL_SIZE_MESA not used.


    15. Suppose the device's number of RAMDACs is different from the
        number of output ports.  For example, a graphics card with
        two RAMDACs but three ports (VGA, DVI, TV).

        Address this in a follow-on extension. [Matthias Hopf]


    16. How should we deal with on-the-fly device changes?  For example,
        the monitor being unplugged and replaced by another with different
        characteristics?

        A HAL event could be received via DBUS in the application [J. Smirl,
        A. Jackson].

        Should there be an EGL mechanism for detecting this?  Maybe an
        EGL_SCREEN_LOST error (similar to EGL_CONTEXT_LOST) can be recorded
        when there's a screen change.  At least then the application can
        poll to detect this situation.

        Maybe leave that to a future extension.

        See also the EGL_SCREEN_COUNT_MESA query.


    17. What if pixel-accurate panning is not supported (see
        eglScreenPositionMESA)? [M. Danzer]

        Is this a common problem?  Can we ignore it for now?


    18. Should eglShowSurfaceMESA be renamed to eglShowScreenSurfaceMESA?

        Probably.



New Procedures and Functions

    EGLBoolean eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                 const EGLint *attrib_list,
                                 EGLModeMESA *modes, EGLint modes_size,
                                 EGLint *num_modes)

    EGLBoolean eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen,
                               EGLModeMESA *modes, EGLint modes_size,
                               EGLint *num_modes)

    EGLBoolean eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode,
                                    EGLint attrib, EGLint *value)


    EGLBoolean eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens,
                                 EGLint screens_size, EGLint *num_screens)

    EGLSurface eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config,
                                          const EGLint *attrib_list)

    EGLBoolean eglShowSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                  EGLSurface surface, EGLModeMESA mode)

    EGLBoolean eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                     EGLint x, EGLint y)


    EGLBoolean eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                  EGLint attrib, EGLint *value);

    EGLBoolean eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                         EGLSurface *surface)

    EGLBoolean eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                      EGLModeMESA *mode)

    const char *eglQueryModeStringMESA(EGLDisplay dpy, EGLMode mode);


New Types

    EGLModeMESA
    EGLScreenMESA

New Tokens

    New error codes:

    EGL_BAD_SCREEN_MESA        
    EGL_BAD_MODE_MESA          

    Screen-related tokens:

    EGL_SCREEN_COUNT_MESA      
    EGL_SCREEN_POSITION_MESA   
    EGL_SCREEN_BIT_MESA        
    EGL_SCREEN_POSITION_GRANULARITY_MESA

    Mode-related tokens:

    EGL_MODE_ID_MESA           
    EGL_REFRESH_RATE_MESA      
    EGL_INTERLACED_MESA
    EGL_OPTIMAL_MESA
    EGL_NO_MODE_MESA


Additions to Chapter X of the EGL 1.1 Specification

    [XXX this all has to be rewritten to fit into the EGL specification
    and match the conventions of an EGL extension.  For now, just list
    all the functions with brief descriptions.]


    EGLBoolean eglChooseModeMESA(EGLDisplay dpy, const EGLScreenMESA screen,
                                 EGLint *attrib_list, EGLModeMESA *modes,
                                 EGLint modes_size, EGLint *num_modes)

    Like eglChooseConfig, returns a list of EGLModes which match the given
    attribute list.  This does not set the screen's current display mode.
    The attribute list is a list of token/value pairs terminated with
    EGL_NONE.  Supported attributes include:

        Name                   Description
        ---------------------  ---------------------------------------------
        EGL_WIDTH              Mode width (resolution)
        EGL_HEIGHT             Mode height (resolution)
        EGL_REFRESH_RATE_MESA  The mode's refresh rate, multiplied by 1000
        EGL_INTERLACED_MESA    1 indicates an interlaced mode, 0 otherwise
        EGL_OPTIMAL_MESA       Set if the most is especially optimal for the
                               screen (ex. for particular LCD resolutions)

    Any other token will generate the error EGL_BAD_ATTRIBUTE.

    The list of modes returned by eglChooseModeMESA will be sorted
    according to the following criteria.  See the discussion of table 3.3
    in the EGL specification for more information.

                                            Selection   Sort   Sort
        Attribute            Default        Criteria    Order  Priority
        -------------------- -------------- ----------- ------ --------
        EGL_OPTIMAL_MESA     EGL_DONT_CARE  Exact       1,0      1
        EGL_INTERLACED_MESA  EGL_DONT_CARE  Exact       0,1      2
        EGL_REFRESH_RATE     EGL_DONT_CARE  AtLeast     Larger   3
        EGL_WIDTH            EGL_DONT_CARE  AtLeast     Larger   4
        EGL_HEIGHT           EGL_DONT_CARE  AtLeast     Larger   5
        EGL_MODE_ID_MESA     EGL_DONT_CARE  Exact       Smaller  6


    EGLBoolean eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen,
                               EGLModeMESA *modes, EGLint modes_size,
                               EGLint *num_modes)

    Like eglGetConfigs, returns a list of all modes supported by the
    given screen.  The returned modes will be sorted in the same manner
    as for eglChooseModeMESA().



    EGLBoolean eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode,
                                    EGLint attrib, EGLint *value)

    Used to query mode attributes.  The following attributes are supported:

        Name                   Return value description
        ---------------------  ----------------------------------------------
        EGL_OPTIMAL_MESA       1 indicates an optimal mode, 0 otherwise
        EGL_INTERLACED_MESA    1 indicates an interlaced mode, 0 otherwise
        EGL_REFRESH_RATE_MESA  The mode's refresh rate, multiplied by 1000
        EGL_WIDTH              Mode width (resolution)
        EGL_HEIGHT             Mode height (resolution)
        EGL_MODE_ID_MESA       A unique small integer identifier for the mode

    Any other token will generate the error EGL_BAD_ATTRIBUTE.



    EGLBoolean eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens,
                                 EGLint screens_size, EGLint *num_screens)

    This function returns an array of all available screen handles.
    <screens_size> is the maximum number of screens to return in the
    <screens> array.  <num_screens> will return the number of screen handles
    placed in the array, even if <screens> is NULL.

    The number of screens and the availability of each may change over
    time (hot-plugging).  Screen handles will not be reused.  When a
    screen handle becomes invalid, function calls which reference an
    invalid handle will generate EGL_BAD_SCREEN_MESA.

    The first screen handle returned will be considered to be the primary
    one.



    EGLSurface eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config,
                                          const EGLint *attrib_list)

    Create a surface that can be displayed on a screen.  <attrib_list> is
    an array of token/value pairs terminated with EGL_NONE.  Valid tokens
    include:

        Name              Description
        ----------------  --------------------------------
        EGL_WIDTH         desired surface width in pixels
        EGL_HEIGHT        desired surface height in pixels

    Any other token will generate the error EGL_BAD_ATTRIBUTE.
    The default width and height are zero.

    

    EGLBoolean eglShowSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                  EGLSurface surface, EGLModeMESA mode)

    This function causes a screen to show the given surface (or more
    precisely, the surface's front color buffer) with the given mode.

    If the surface is in any way incompatible with the mode, the error
    EGL_BAD_MATCH will be generated, EGL_FALSE will be returned, and the
    previous screen state will remain in effect.  This might occur when
    the bandwidth of the video-out subsystem is exceeded, or if the mode
    specifies a width or height that's greater than the width or height
    of the surface.

    To disable a screen, the values EGL_NO_SURFACE and EGL_NO_MODE_MESA
    be passed as the <surface> and <mode> parameters.

    The values of EGL_SCREEN_POSITION_MESA are clamped to the new valid
    range computed from the screen size and surface size.  If the new
    surface is EGL_NO_SURFACE, EGL_SCREEN_POSITION_MESA is set to [0, 0].


    Attempting to delete a screen surface which is currently being
    displayed will result in the error EGL_BAD_ACCESS being generated.



    EGLBoolean eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                     EGLint x, EGLint y)

    Specifies the origin of the screen's view into the surface, if the
    surface is larger than the screen.  Valid values for x and y are
    [0, surfaceWidth - screenWidth] and [0, surfaceHeight - screenHeight],
    respectively.

    The x and y values are also constrained to be integer multiples of the
    EGL_SCREEN_POSITION_GRANULARITY_MESA values.




    EGLBoolean eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                  EGLint attrib, EGLint *value);

    Used to query screen attributes.  <attrib> may be one of the following:

        Name                      Return value description
        ------------------------  ---------------------------------------------
        EGL_SCREEN_POSITION_MESA  x, y position of the screen's origin with
                                  respect to the surface.  If no surface is
                                  attached to the screen, [0, 0] is returned.
        EGL_SCREEN_POSITION_GRANULARITY_MESA
                                  Returns the granularity, in pixels, for
                                  which the screen position is constrained.

    Any other token will generate the error EGL_BAD_ATTRIBUTE.




    EGLBoolean eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                         EGLSurface *surface)

    Returns the surface currently displayed on the given screen.  <surface>
    may be EGL_NO_SURFACE if the screen isn't currently showing any surface.




    EGLBoolean eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen,
                                      EGLModeMESA *mode)

    Returns the given screen's current display mode.  The mode may be
    EGL_NO_MODE_MESA if the screen is currently disabled.



    const char *eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode);

    Returns a human-readable string for the given mode.  The string is a
    zero-terminated C string which the user should not attempt to free.
    There is no standard syntax for mode strings.  Applications should
    not directly rely on mode strings.



Version History

    1. 15 March 2005 - BrianP
        Initial version

    2. 16 March 2005 - BrianP
        Removed EGL_DEPTH_MESA
        Added EGL_PHYSICAL_WIDTH_MESA, EGL_PHYSICAL_HEIGHT_MESA queries
        Added EGL_OPTIMAL_MESA for width/height/refresh rate selection
        Added possible eglQueryModeStringMESA() function
        More details of the new functions explained.

    3. 18 March 2005 - BrianP
        Added screen_number to eglChooseModeMESA().
        Fix off by one mistake in value range for ORIGIN attributes
        Added Issues section

    4. 21 March 2005 - BrianP
        Removed eglScreenAttribsMESA().
        Added eglScreenPositionMESA() to set screen origin.
        Replaced EGL_SCREEN_X/Y_OFFSET_MESA with EGL_SCREEN_POSITION_MESA.
        Replaced EGL_PHYSICAL_WIDTH/HEIGHT_MESA with EGL_PHYSICAL_SIZE_MESA.
        Use EGL_OPTIMAL_MESA as a new mode attribute. (Michel Danzer)
        Added a few more issues.

    5. 6 April 2005 - BrianP
        More language for eglGetModeStringMESA().
        Added issues 10, 11, 12, 13, 14.
        Updated issue 3 discussion about mode sorting.

    6. 22 April 2005 - BrianP
        Fixed "LDC" typo.
        Added issues 15, 16.
        Changed dependency on EGL 1.1 to EGL 1.0
        s/EGL_NUM_SCREENS_MESA/EGL_SCREEN_COUNT_MESA/
        Added eglQueryDisplayMESA() to New Functions section.
        Clarified language for the EGL_SCREEN_COUNT_MESA query.

    7. 29 April 2005 - BrianP
        Added EGLScreenMESA type and eglGetScreensMESA() function. [J. Smirl].
        Replaced EGLint screen_number parameters with EGLScreenMESA screen.
        Added issue 17 (pixel-accurate panning)

    8. 2 May 2005 - BrianP
        Removed eglQueryDisplayMESA.
        Fixed a few more EGLint -> EGLScreenMESA changes.

    9. 20 May 2005 - BrianP
        Fixed a few typos.
        Updated some open issues text.

    10. 10 August 2005 - BrianP
        Added EGL_SCREEN_POSITION_GRANULARITY_MESA.

    11. 27 January 2006 - BrianP
        EGL_PHYSICAL_SIZE_MESA removed since EGL 1.2 has a similar feature.