Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

eglinfo.c 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. #define EGL_EGLEXT_PROTOTYPES
  27. #include <EGL/egl.h>
  28. #include <EGL/eglext.h>
  29. #include <assert.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #define MAX_CONFIGS 1000
  34. #define MAX_MODES 1000
  35. #define MAX_SCREENS 10
  36. /**
  37. * Print table of all available configurations.
  38. */
  39. static void
  40. PrintConfigs(EGLDisplay d)
  41. {
  42. EGLConfig configs[MAX_CONFIGS];
  43. EGLint numConfigs, i;
  44. eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
  45. printf("Configurations:\n");
  46. printf(" bf lv d st colorbuffer dp st ms vis supported\n");
  47. printf(" id sz l b ro r g b a th cl ns b id surfaces \n");
  48. printf("--------------------------------------------------------\n");
  49. for (i = 0; i < numConfigs; i++) {
  50. EGLint id, size, level;
  51. EGLint red, green, blue, alpha;
  52. EGLint depth, stencil;
  53. EGLint surfaces;
  54. EGLint doubleBuf = 1, stereo = 0;
  55. EGLint vid;
  56. EGLint samples, sampleBuffers;
  57. char surfString[100] = "";
  58. eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id);
  59. eglGetConfigAttrib(d, configs[i], EGL_BUFFER_SIZE, &size);
  60. eglGetConfigAttrib(d, configs[i], EGL_LEVEL, &level);
  61. eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red);
  62. eglGetConfigAttrib(d, configs[i], EGL_GREEN_SIZE, &green);
  63. eglGetConfigAttrib(d, configs[i], EGL_BLUE_SIZE, &blue);
  64. eglGetConfigAttrib(d, configs[i], EGL_ALPHA_SIZE, &alpha);
  65. eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth);
  66. eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil);
  67. eglGetConfigAttrib(d, configs[i], EGL_NATIVE_VISUAL_ID, &vid);
  68. eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces);
  69. eglGetConfigAttrib(d, configs[i], EGL_SAMPLES, &samples);
  70. eglGetConfigAttrib(d, configs[i], EGL_SAMPLE_BUFFERS, &sampleBuffers);
  71. if (surfaces & EGL_WINDOW_BIT)
  72. strcat(surfString, "win,");
  73. if (surfaces & EGL_PBUFFER_BIT)
  74. strcat(surfString, "pb,");
  75. if (surfaces & EGL_PIXMAP_BIT)
  76. strcat(surfString, "pix,");
  77. #ifdef EGL_MESA_screen_surface
  78. if (surfaces & EGL_SCREEN_BIT_MESA)
  79. strcat(surfString, "scrn,");
  80. #endif
  81. if (strlen(surfString) > 0)
  82. surfString[strlen(surfString) - 1] = 0;
  83. printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %2d%2d 0x%02x %-12s\n",
  84. id, size, level,
  85. doubleBuf ? 'y' : '.',
  86. stereo ? 'y' : '.',
  87. red, green, blue, alpha,
  88. depth, stencil,
  89. samples, sampleBuffers, vid, surfString);
  90. }
  91. }
  92. /**
  93. * Print table of all available configurations.
  94. */
  95. static void
  96. PrintModes(EGLDisplay d)
  97. {
  98. #ifdef EGL_MESA_screen_surface
  99. const char *extensions = eglQueryString(d, EGL_EXTENSIONS);
  100. if (strstr(extensions, "EGL_MESA_screen_surface")) {
  101. EGLScreenMESA screens[MAX_SCREENS];
  102. EGLint numScreens = 1, scrn;
  103. EGLModeMESA modes[MAX_MODES];
  104. eglGetScreensMESA(d, screens, MAX_SCREENS, &numScreens);
  105. printf("Number of Screens: %d\n\n", numScreens);
  106. for (scrn = 0; scrn < numScreens; scrn++) {
  107. EGLint numModes, i;
  108. eglGetModesMESA(d, screens[scrn], modes, MAX_MODES, &numModes);
  109. printf("Screen %d Modes:\n", scrn);
  110. printf(" id width height refresh name\n");
  111. printf("-----------------------------------------\n");
  112. for (i = 0; i < numModes; i++) {
  113. EGLint id, w, h, r;
  114. const char *str;
  115. eglGetModeAttribMESA(d, modes[i], EGL_MODE_ID_MESA, &id);
  116. eglGetModeAttribMESA(d, modes[i], EGL_WIDTH, &w);
  117. eglGetModeAttribMESA(d, modes[i], EGL_HEIGHT, &h);
  118. eglGetModeAttribMESA(d, modes[i], EGL_REFRESH_RATE_MESA, &r);
  119. str = eglQueryModeStringMESA(d, modes[i]);
  120. printf("0x%02x %5d %5d %.3f %s\n", id, w, h, r / 1000.0, str);
  121. }
  122. }
  123. }
  124. #endif
  125. }
  126. int
  127. main(int argc, char *argv[])
  128. {
  129. int maj, min;
  130. EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  131. if (!eglInitialize(d, &maj, &min)) {
  132. printf("eglinfo: eglInitialize failed\n");
  133. exit(1);
  134. }
  135. printf("EGL API version: %d.%d\n", maj, min);
  136. printf("EGL vendor string: %s\n", eglQueryString(d, EGL_VENDOR));
  137. printf("EGL version string: %s\n", eglQueryString(d, EGL_VERSION));
  138. #ifdef EGL_VERSION_1_2
  139. printf("EGL client APIs: %s\n", eglQueryString(d, EGL_CLIENT_APIS));
  140. #endif
  141. printf("EGL extensions string:\n");
  142. printf(" %s\n", eglQueryString(d, EGL_EXTENSIONS));
  143. PrintConfigs(d);
  144. PrintModes(d);
  145. eglTerminate(d);
  146. return 0;
  147. }