eglinfo: Note when an EGLConfig is streams-compatible
[mesa-demos.git] / src / egl / opengl / eglinfo.c
blobca22df24080ef5aaa2c7458f96970c98b30a6e10
1 /*
2 * eglinfo - like glxinfo but for EGL
4 * Brian Paul
5 * 11 March 2005
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
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>
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" };
44 /**
45 * Print table of all available configurations.
47 static void
48 PrintConfigs(EGLDisplay d)
50 EGLConfig configs[MAX_CONFIGS];
51 EGLint numConfigs, i;
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 ",
102 id, size, level,
103 red, green, blue, alpha,
104 depth, stencil,
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' : ' ',
113 surfString);
118 static void
119 PrintExtensions(EGLDisplay d)
121 const char *extensions, *p, *end, *next;
122 int column;
124 puts(d == EGL_NO_DISPLAY ? "EGL client extensions string:" :
125 "EGL extensions string:");
127 extensions = eglQueryString(d, EGL_EXTENSIONS);
128 if (!extensions)
129 return;
131 column = 0;
132 end = extensions + strlen(extensions);
134 for (p = extensions; p < end; p = next + 1) {
135 next = strchr(p, ' ');
136 if (next == NULL)
137 next = end;
139 if (column > 0 && column + next - p + 1 > 70) {
140 printf("\n");
141 column = 0;
143 if (column == 0)
144 printf(" ");
145 else
146 printf(" ");
147 column += next - p + 1;
149 printf("%.*s", (int) (next - p), p);
151 p = next + 1;
154 if (column > 0)
155 printf("\n");
159 main(int argc, char *argv[])
161 int maj, min;
162 EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
164 if (!eglInitialize(d, &maj, &min)) {
165 printf("eglinfo: eglInitialize failed\n");
166 exit(1);
169 printf("EGL API version: %d.%d\n", maj, min);
170 printf("EGL vendor string: %s\n", eglQueryString(d, EGL_VENDOR));
171 printf("EGL version string: %s\n", eglQueryString(d, EGL_VERSION));
172 #ifdef EGL_VERSION_1_2
173 printf("EGL client APIs: %s\n", eglQueryString(d, EGL_CLIENT_APIS));
174 #endif
176 PrintExtensions(d);
177 PrintExtensions(EGL_NO_DISPLAY);
179 PrintConfigs(d);
181 eglTerminate(d);
183 return 0;