1/* 2 * eglinfo - like glxinfo but for EGL 3 * 4 * Brian Paul 5 * 11 March 2005 6 * 7 * Copyright (C) 2005 Brian Paul All Rights Reserved. 8 * 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: 15 * 16 * The above copyright notice and this permission notice shall be included 17 * in all copies or substantial portions of the Software. 18 * 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. 25 */ 26 27#define EGL_EGLEXT_PROTOTYPES 28 29#include <EGL/egl.h> 30#include <EGL/eglext.h> 31#include <assert.h> 32#include <stdio.h> 33#include <stdlib.h> 34#include <string.h> 35 36#define MAX_CONFIGS 1000 37#define MAX_MODES 1000 38#define MAX_SCREENS 10 39 40/* These are X visual types, so if you're running eglinfo under 41 * something not X, they probably don't make sense. */ 42static const char *vnames[] = { "SG", "GS", "SC", "PC", "TC", "DC" }; 43 44/** 45 * Print table of all available configurations. 46 */ 47static void 48PrintConfigs(EGLDisplay d) 49{ 50 EGLConfig configs[MAX_CONFIGS]; 51 EGLint numConfigs, i; 52 53 eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs); 54 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 /* ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 59 * | | | | | | | | | | | | | | | | | | | 60 * | | | | | | | | | | | | | | | | | | EGL_SURFACE_TYPE 61 * | | | | | | | | | | | | | | EGL_RENDERABLE_TYPE 62 * | | | | | | | | | | | | | EGL_BIND_TO_TEXTURE_RGB/EGL_BIND_TO_TEXTURE_RGBA 63 * | | | | | | | | | | | | EGL_CONFIG_CAVEAT 64 * | | | | | | | | | | | EGL_NATIVE_VISUAL_ID/EGL_NATIVE_VISUAL_TYPE 65 * | | | | | | | | | | EGL_SAMPLE_BUFFERS 66 * | | | | | | | | | EGL_SAMPLES 67 * | | | | | | | | EGL_STENCIL_SIZE 68 * | | | | | | | EGL_DEPTH_SIZE 69 * | | | | | | EGL_ALPHA_SIZE 70 * | | | | | EGL_BLUE_SIZE 71 * | | | | EGL_GREEN_SIZE 72 * | | | EGL_RED_SIZE 73 * | | EGL_LEVEL 74 * | EGL_BUFFER_SIZE 75 * EGL_CONFIG_ID 76 */ 77 printf("---------------------------------------------------------------------\n"); 78 for (i = 0; i < numConfigs; i++) { 79 EGLint id, size, level; 80 EGLint red, green, blue, alpha; 81 EGLint depth, stencil; 82 EGLint renderable, surfaces; 83 EGLint vid, vtype, caveat, bindRgb, bindRgba; 84 EGLint samples, sampleBuffers; 85 char surfString[100] = ""; 86 87 eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id); 88 eglGetConfigAttrib(d, configs[i], EGL_BUFFER_SIZE, &size); 89 eglGetConfigAttrib(d, configs[i], EGL_LEVEL, &level); 90 91 eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red); 92 eglGetConfigAttrib(d, configs[i], EGL_GREEN_SIZE, &green); 93 eglGetConfigAttrib(d, configs[i], EGL_BLUE_SIZE, &blue); 94 eglGetConfigAttrib(d, configs[i], EGL_ALPHA_SIZE, &alpha); 95 eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth); 96 eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil); 97 eglGetConfigAttrib(d, configs[i], EGL_NATIVE_VISUAL_ID, &vid); 98 eglGetConfigAttrib(d, configs[i], EGL_NATIVE_VISUAL_TYPE, &vtype); 99 100 eglGetConfigAttrib(d, configs[i], EGL_CONFIG_CAVEAT, &caveat); 101 eglGetConfigAttrib(d, configs[i], EGL_BIND_TO_TEXTURE_RGB, &bindRgb); 102 eglGetConfigAttrib(d, configs[i], EGL_BIND_TO_TEXTURE_RGBA, &bindRgba); 103 eglGetConfigAttrib(d, configs[i], EGL_RENDERABLE_TYPE, &renderable); 104 eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces); 105 106 eglGetConfigAttrib(d, configs[i], EGL_SAMPLES, &samples); 107 eglGetConfigAttrib(d, configs[i], EGL_SAMPLE_BUFFERS, &sampleBuffers); 108 109 if (surfaces & EGL_WINDOW_BIT) 110 strcat(surfString, "win,"); 111 if (surfaces & EGL_PBUFFER_BIT) 112 strcat(surfString, "pb,"); 113 if (surfaces & EGL_PIXMAP_BIT) 114 strcat(surfString, "pix,"); 115 if (surfaces & EGL_STREAM_BIT_KHR) 116 strcat(surfString, "str,"); 117 if (strlen(surfString) > 0) 118 surfString[strlen(surfString) - 1] = 0; 119 120 printf("0x%02x %2d %2d %2d %2d %2d %2d %2d %2d %2d%2d 0x%02x%s ", 121 id, size, level, 122 red, green, blue, alpha, 123 depth, stencil, 124 samples, sampleBuffers, vid, vtype < 6 ? vnames[vtype] : "--"); 125 printf(" %c %c %c %c %c %c %s\n", 126 (caveat != EGL_NONE) ? 'y' : ' ', 127 (bindRgba) ? 'a' : (bindRgb) ? 'y' : ' ', 128 (renderable & EGL_OPENGL_BIT) ? 'y' : ' ', 129 (renderable & EGL_OPENGL_ES_BIT) ? 'y' : ' ', 130 (renderable & EGL_OPENGL_ES2_BIT) ? 'y' : ' ', 131 (renderable & EGL_OPENVG_BIT) ? 'y' : ' ', 132 surfString); 133 } 134} 135 136 137static const char * 138PrintExtensions(EGLDisplay d) 139{ 140 const char *extensions, *p, *end, *next; 141 int column; 142 143 puts(d == EGL_NO_DISPLAY ? "EGL client extensions string:" : 144 "EGL extensions string:"); 145 146 extensions = eglQueryString(d, EGL_EXTENSIONS); 147 if (!extensions) 148 return NULL; 149 150 column = 0; 151 end = extensions + strlen(extensions); 152 153 for (p = extensions; p < end; p = next + 1) { 154 next = strchr(p, ' '); 155 if (next == NULL) 156 next = end; 157 158 if (column > 0 && column + next - p + 1 > 70) { 159 printf("\n"); 160 column = 0; 161 } 162 if (column == 0) 163 printf(" "); 164 else 165 printf(" "); 166 column += next - p + 1; 167 168 printf("%.*s", (int) (next - p), p); 169 170 p = next + 1; 171 } 172 173 if (column > 0) 174 printf("\n"); 175 176 return extensions; 177} 178 179static int 180doOneDisplay(EGLDisplay d, const char *name) 181{ 182 int maj, min; 183 184 printf("%s:\n", name); 185 if (!eglInitialize(d, &maj, &min)) { 186 printf("eglinfo: eglInitialize failed\n\n"); 187 return 1; 188 } 189 190 printf("EGL API version: %d.%d\n", maj, min); 191 printf("EGL vendor string: %s\n", eglQueryString(d, EGL_VENDOR)); 192 printf("EGL version string: %s\n", eglQueryString(d, EGL_VERSION)); 193#ifdef EGL_VERSION_1_2 194 printf("EGL client APIs: %s\n", eglQueryString(d, EGL_CLIENT_APIS)); 195#endif 196 197 PrintExtensions(d); 198 199 PrintConfigs(d); 200 eglTerminate(d); 201 printf("\n"); 202 return 0; 203} 204 205int 206main(int argc, char *argv[]) 207{ 208 int ret = 0; 209 const char *clientext; 210 211 clientext = PrintExtensions(EGL_NO_DISPLAY); 212 printf("\n"); 213 214 if (strstr(clientext, "EGL_EXT_platform_base")) { 215 PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay = 216 (PFNEGLGETPLATFORMDISPLAYEXTPROC) 217 eglGetProcAddress("eglGetPlatformDisplayEXT"); 218 if (strstr(clientext, "EGL_KHR_platform_android")) 219 ret += doOneDisplay(getPlatformDisplay(EGL_PLATFORM_ANDROID_KHR, 220 EGL_DEFAULT_DISPLAY, 221 NULL), "Android platform"); 222 if (strstr(clientext, "EGL_MESA_platform_gbm") || 223 strstr(clientext, "EGL_KHR_platform_gbm")) 224 ret += doOneDisplay(getPlatformDisplay(EGL_PLATFORM_GBM_MESA, 225 EGL_DEFAULT_DISPLAY, 226 NULL), "GBM platform"); 227 if (strstr(clientext, "EGL_EXT_platform_wayland") || 228 strstr(clientext, "EGL_KHR_platform_wayland")) 229 ret += doOneDisplay(getPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, 230 EGL_DEFAULT_DISPLAY, 231 NULL), "Wayland platform"); 232 if (strstr(clientext, "EGL_EXT_platform_x11") || 233 strstr(clientext, "EGL_KHR_platform_x11")) 234 ret += doOneDisplay(getPlatformDisplay(EGL_PLATFORM_X11_EXT, 235 EGL_DEFAULT_DISPLAY, 236 NULL), "X11 platform"); 237 if (strstr(clientext, "EGL_EXT_platform_device")) 238 ret += doOneDisplay(getPlatformDisplay(EGL_PLATFORM_DEVICE_EXT, 239 EGL_DEFAULT_DISPLAY, 240 NULL), "Device platform"); 241 } 242 else { 243 ret = doOneDisplay(eglGetDisplay(EGL_DEFAULT_DISPLAY), "Default display"); 244 } 245 246 return ret; 247} 248