2 * eglinfo - like glxinfo but for EGL
7 * Copyright (C) 2005 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #define EGL_EGLEXT_PROTOTYPES
30 #include <EGL/eglext.h>
36 #define MAX_CONFIGS 1000
37 #define MAX_MODES 1000
38 #define MAX_SCREENS 10
40 /* These are X visual types, so if you're running eglinfo under
41 * something not X, they probably don't make sense. */
42 static const char *vnames
[] = { "SG", "GS", "SC", "PC", "TC", "DC" };
45 * Print table of all available configurations.
48 PrintConfigs(EGLDisplay d
)
50 EGLConfig configs
[MAX_CONFIGS
];
53 eglGetConfigs(d
, configs
, MAX_CONFIGS
, &numConfigs
);
55 printf("Configurations:\n");
56 printf(" bf lv colorbuffer dp st ms vis cav bi renderable supported\n");
57 printf(" id sz l r g b a th cl ns b id eat nd gl es es2 vg surfaces \n");
58 printf("---------------------------------------------------------------------\n");
59 for (i
= 0; i
< numConfigs
; i
++) {
60 EGLint id
, size
, level
;
61 EGLint red
, green
, blue
, alpha
;
62 EGLint depth
, stencil
;
63 EGLint renderable
, surfaces
;
64 EGLint vid
, vtype
, caveat
, bindRgb
, bindRgba
;
65 EGLint samples
, sampleBuffers
;
66 char surfString
[100] = "";
68 eglGetConfigAttrib(d
, configs
[i
], EGL_CONFIG_ID
, &id
);
69 eglGetConfigAttrib(d
, configs
[i
], EGL_BUFFER_SIZE
, &size
);
70 eglGetConfigAttrib(d
, configs
[i
], EGL_LEVEL
, &level
);
72 eglGetConfigAttrib(d
, configs
[i
], EGL_RED_SIZE
, &red
);
73 eglGetConfigAttrib(d
, configs
[i
], EGL_GREEN_SIZE
, &green
);
74 eglGetConfigAttrib(d
, configs
[i
], EGL_BLUE_SIZE
, &blue
);
75 eglGetConfigAttrib(d
, configs
[i
], EGL_ALPHA_SIZE
, &alpha
);
76 eglGetConfigAttrib(d
, configs
[i
], EGL_DEPTH_SIZE
, &depth
);
77 eglGetConfigAttrib(d
, configs
[i
], EGL_STENCIL_SIZE
, &stencil
);
78 eglGetConfigAttrib(d
, configs
[i
], EGL_NATIVE_VISUAL_ID
, &vid
);
79 eglGetConfigAttrib(d
, configs
[i
], EGL_NATIVE_VISUAL_TYPE
, &vtype
);
81 eglGetConfigAttrib(d
, configs
[i
], EGL_CONFIG_CAVEAT
, &caveat
);
82 eglGetConfigAttrib(d
, configs
[i
], EGL_BIND_TO_TEXTURE_RGB
, &bindRgb
);
83 eglGetConfigAttrib(d
, configs
[i
], EGL_BIND_TO_TEXTURE_RGBA
, &bindRgba
);
84 eglGetConfigAttrib(d
, configs
[i
], EGL_RENDERABLE_TYPE
, &renderable
);
85 eglGetConfigAttrib(d
, configs
[i
], EGL_SURFACE_TYPE
, &surfaces
);
87 eglGetConfigAttrib(d
, configs
[i
], EGL_SAMPLES
, &samples
);
88 eglGetConfigAttrib(d
, configs
[i
], EGL_SAMPLE_BUFFERS
, &sampleBuffers
);
90 if (surfaces
& EGL_WINDOW_BIT
)
91 strcat(surfString
, "win,");
92 if (surfaces
& EGL_PBUFFER_BIT
)
93 strcat(surfString
, "pb,");
94 if (surfaces
& EGL_PIXMAP_BIT
)
95 strcat(surfString
, "pix,");
96 if (surfaces
& EGL_STREAM_BIT_KHR
)
97 strcat(surfString
, "str,");
98 if (strlen(surfString
) > 0)
99 surfString
[strlen(surfString
) - 1] = 0;
101 printf("0x%02x %2d %2d %2d %2d %2d %2d %2d %2d %2d%2d 0x%02x%s ",
103 red
, green
, blue
, alpha
,
105 samples
, sampleBuffers
, vid
, vtype
< 6 ? vnames
[vtype
] : "--");
106 printf(" %c %c %c %c %c %c %s\n",
107 (caveat
!= EGL_NONE
) ? 'y' : ' ',
108 (bindRgba
) ? 'a' : (bindRgb
) ? 'y' : ' ',
109 (renderable
& EGL_OPENGL_BIT
) ? 'y' : ' ',
110 (renderable
& EGL_OPENGL_ES_BIT
) ? 'y' : ' ',
111 (renderable
& EGL_OPENGL_ES2_BIT
) ? 'y' : ' ',
112 (renderable
& EGL_OPENVG_BIT
) ? 'y' : ' ',
119 PrintExtensions(EGLDisplay d
)
121 const char *extensions
, *p
, *end
, *next
;
124 puts(d
== EGL_NO_DISPLAY
? "EGL client extensions string:" :
125 "EGL extensions string:");
127 extensions
= eglQueryString(d
, EGL_EXTENSIONS
);
132 end
= extensions
+ strlen(extensions
);
134 for (p
= extensions
; p
< end
; p
= next
+ 1) {
135 next
= strchr(p
, ' ');
139 if (column
> 0 && column
+ next
- p
+ 1 > 70) {
147 column
+= next
- p
+ 1;
149 printf("%.*s", (int) (next
- p
), p
);
161 doOneDisplay(EGLDisplay d
, const char *name
)
165 printf("%s:\n", name
);
166 if (!eglInitialize(d
, &maj
, &min
)) {
167 printf("eglinfo: eglInitialize failed\n\n");
171 printf("EGL API version: %d.%d\n", maj
, min
);
172 printf("EGL vendor string: %s\n", eglQueryString(d
, EGL_VENDOR
));
173 printf("EGL version string: %s\n", eglQueryString(d
, EGL_VERSION
));
174 #ifdef EGL_VERSION_1_2
175 printf("EGL client APIs: %s\n", eglQueryString(d
, EGL_CLIENT_APIS
));
186 main(int argc
, char *argv
[])
189 const char *clientext
;
191 clientext
= PrintExtensions(EGL_NO_DISPLAY
);
194 if (strstr(clientext
, "EGL_EXT_platform_base")) {
195 PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay
=
196 (PFNEGLGETPLATFORMDISPLAYEXTPROC
)
197 eglGetProcAddress("eglGetPlatformDisplayEXT");
198 if (strstr(clientext
, "EGL_KHR_platform_android"))
199 ret
+= doOneDisplay(getPlatformDisplay(EGL_PLATFORM_ANDROID_KHR
,
201 NULL
), "Android platform");
202 if (strstr(clientext
, "EGL_MESA_platform_gbm") ||
203 strstr(clientext
, "EGL_KHR_platform_gbm"))
204 ret
+= doOneDisplay(getPlatformDisplay(EGL_PLATFORM_GBM_MESA
,
206 NULL
), "GBM platform");
207 if (strstr(clientext
, "EGL_EXT_platform_wayland") ||
208 strstr(clientext
, "EGL_KHR_platform_wayland"))
209 ret
+= doOneDisplay(getPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT
,
211 NULL
), "Wayland platform");
212 if (strstr(clientext
, "EGL_EXT_platform_x11") ||
213 strstr(clientext
, "EGL_KHR_platform_x11"))
214 ret
+= doOneDisplay(getPlatformDisplay(EGL_PLATFORM_X11_EXT
,
216 NULL
), "X11 platform");
219 ret
= doOneDisplay(eglGetDisplay(EGL_DEFAULT_DISPLAY
), "Default display");