glfwinfo.c
Go to the documentation of this file.
1 //========================================================================
2 // Context creation and information tool
3 // Copyright (c) Camilla Löwy <elmindreda@glfw.org>
4 //
5 // This software is provided 'as-is', without any express or implied
6 // warranty. In no event will the authors be held liable for any damages
7 // arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it
11 // freely, subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented; you must not
14 // claim that you wrote the original software. If you use this software
15 // in a product, an acknowledgment in the product documentation would
16 // be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such, and must not
19 // be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source
22 // distribution.
23 //
24 //========================================================================
25 
26 #define VK_NO_PROTOTYPES
27 #include <vulkan/vulkan.h>
28 #include <glad/glad.h>
29 #include <GLFW/glfw3.h>
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 
35 #include "getopt.h"
36 
37 #ifdef _MSC_VER
38 #define strcasecmp(x, y) _stricmp(x, y)
39 #endif
40 
41 #define API_NAME_OPENGL "gl"
42 #define API_NAME_OPENGL_ES "es"
43 
44 #define API_NAME_NATIVE "native"
45 #define API_NAME_EGL "egl"
46 #define API_NAME_OSMESA "osmesa"
47 
48 #define PROFILE_NAME_CORE "core"
49 #define PROFILE_NAME_COMPAT "compat"
50 
51 #define STRATEGY_NAME_NONE "none"
52 #define STRATEGY_NAME_LOSE "lose"
53 
54 #define BEHAVIOR_NAME_NONE "none"
55 #define BEHAVIOR_NAME_FLUSH "flush"
56 
57 static void usage(void)
58 {
59  printf("Usage: glfwinfo [OPTION]...\n");
60  printf("Options:\n");
61  printf(" -a, --client-api=API the client API to use ("
62  API_NAME_OPENGL " or "
63  API_NAME_OPENGL_ES ")\n");
64  printf(" -b, --behavior=BEHAVIOR the release behavior to use ("
65  BEHAVIOR_NAME_NONE " or "
66  BEHAVIOR_NAME_FLUSH ")\n");
67  printf(" -c, --context-api=API the context creation API to use ("
68  API_NAME_NATIVE " or "
69  API_NAME_EGL " or "
70  API_NAME_OSMESA ")\n");
71  printf(" -d, --debug request a debug context\n");
72  printf(" -f, --forward require a forward-compatible context\n");
73  printf(" -h, --help show this help\n");
74  printf(" -l, --list-extensions list all Vulkan and client API extensions\n");
75  printf(" --list-layers list all Vulkan layers\n");
76  printf(" -m, --major=MAJOR the major number of the required "
77  "client API version\n");
78  printf(" -n, --minor=MINOR the minor number of the required "
79  "client API version\n");
80  printf(" -p, --profile=PROFILE the OpenGL profile to use ("
81  PROFILE_NAME_CORE " or "
82  PROFILE_NAME_COMPAT ")\n");
83  printf(" -s, --robustness=STRATEGY the robustness strategy to use ("
84  STRATEGY_NAME_NONE " or "
85  STRATEGY_NAME_LOSE ")\n");
86  printf(" -v, --version print version information\n");
87  printf(" --red-bits=N the number of red bits to request\n");
88  printf(" --green-bits=N the number of green bits to request\n");
89  printf(" --blue-bits=N the number of blue bits to request\n");
90  printf(" --alpha-bits=N the number of alpha bits to request\n");
91  printf(" --depth-bits=N the number of depth bits to request\n");
92  printf(" --stencil-bits=N the number of stencil bits to request\n");
93  printf(" --accum-red-bits=N the number of red bits to request\n");
94  printf(" --accum-green-bits=N the number of green bits to request\n");
95  printf(" --accum-blue-bits=N the number of blue bits to request\n");
96  printf(" --accum-alpha-bits=N the number of alpha bits to request\n");
97  printf(" --aux-buffers=N the number of aux buffers to request\n");
98  printf(" --samples=N the number of MSAA samples to request\n");
99  printf(" --stereo request stereo rendering\n");
100  printf(" --srgb request an sRGB capable framebuffer\n");
101  printf(" --singlebuffer request single-buffering\n");
102  printf(" --no-error request a context that does not emit errors\n");
103 }
104 
105 static void error_callback(int error, const char* description)
106 {
107  fprintf(stderr, "Error: %s\n", description);
108 }
109 
111 {
112  if (type == VK_PHYSICAL_DEVICE_TYPE_OTHER)
113  return "other";
115  return "integrated GPU";
116  else if (type == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
117  return "discrete GPU";
118  else if (type == VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU)
119  return "virtual GPU";
120  else if (type == VK_PHYSICAL_DEVICE_TYPE_CPU)
121  return "CPU";
122 
123  return "unknown";
124 }
125 
126 static const char* get_api_name(int api)
127 {
128  if (api == GLFW_OPENGL_API)
129  return "OpenGL";
130  else if (api == GLFW_OPENGL_ES_API)
131  return "OpenGL ES";
132 
133  return "Unknown API";
134 }
135 
136 static const char* get_profile_name_gl(GLint mask)
137 {
139  return PROFILE_NAME_COMPAT;
140  if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
141  return PROFILE_NAME_CORE;
142 
143  return "unknown";
144 }
145 
146 static const char* get_profile_name_glfw(int profile)
147 {
148  if (profile == GLFW_OPENGL_COMPAT_PROFILE)
149  return PROFILE_NAME_COMPAT;
150  if (profile == GLFW_OPENGL_CORE_PROFILE)
151  return PROFILE_NAME_CORE;
152 
153  return "unknown";
154 }
155 
156 static const char* get_strategy_name_gl(GLint strategy)
157 {
158  if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
159  return STRATEGY_NAME_LOSE;
160  if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
161  return STRATEGY_NAME_NONE;
162 
163  return "unknown";
164 }
165 
166 static const char* get_strategy_name_glfw(int strategy)
167 {
168  if (strategy == GLFW_LOSE_CONTEXT_ON_RESET)
169  return STRATEGY_NAME_LOSE;
170  if (strategy == GLFW_NO_RESET_NOTIFICATION)
171  return STRATEGY_NAME_NONE;
172 
173  return "unknown";
174 }
175 
176 static void list_context_extensions(int client, int major, int minor)
177 {
178  int i;
179  GLint count;
180  const GLubyte* extensions;
181 
182  printf("%s context extensions:\n", get_api_name(client));
183 
184  if (client == GLFW_OPENGL_API && major > 2)
185  {
187 
188  for (i = 0; i < count; i++)
189  printf(" %s\n", (const char*) glGetStringi(GL_EXTENSIONS, i));
190  }
191  else
192  {
193  extensions = glGetString(GL_EXTENSIONS);
194  while (*extensions != '\0')
195  {
196  putchar(' ');
197 
198  while (*extensions != '\0' && *extensions != ' ')
199  {
200  putchar(*extensions);
201  extensions++;
202  }
203 
204  while (*extensions == ' ')
205  extensions++;
206 
207  putchar('\n');
208  }
209  }
210 }
211 
213 {
214  uint32_t i, ep_count = 0;
218  glfwGetInstanceProcAddress(NULL, "vkEnumerateInstanceExtensionProperties");
219 
220  printf("Vulkan instance extensions:\n");
221 
223  return;
224 
225  ep = calloc(ep_count, sizeof(VkExtensionProperties));
226 
228  {
229  free(ep);
230  return;
231  }
232 
233  for (i = 0; i < ep_count; i++)
234  printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion);
235 
236  free(ep);
237 }
238 
240 {
241  uint32_t i, lp_count = 0;
242  VkLayerProperties* lp;
245  glfwGetInstanceProcAddress(NULL, "vkEnumerateInstanceLayerProperties");
246 
247  printf("Vulkan instance layers:\n");
248 
250  return;
251 
252  lp = calloc(lp_count, sizeof(VkLayerProperties));
253 
254  if (vkEnumerateInstanceLayerProperties(&lp_count, lp) != VK_SUCCESS)
255  {
256  free(lp);
257  return;
258  }
259 
260  for (i = 0; i < lp_count; i++)
261  {
262  printf(" %s (v%u) \"%s\"\n",
263  lp[i].layerName,
264  lp[i].specVersion >> 22,
265  lp[i].description);
266  }
267 
268  free(lp);
269 }
270 
272 {
273  uint32_t i, ep_count;
277  glfwGetInstanceProcAddress(instance, "vkEnumerateDeviceExtensionProperties");
278 
279  printf("Vulkan device extensions:\n");
280 
281  if (vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, NULL) != VK_SUCCESS)
282  return;
283 
284  ep = calloc(ep_count, sizeof(VkExtensionProperties));
285 
286  if (vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, ep) != VK_SUCCESS)
287  {
288  free(ep);
289  return;
290  }
291 
292  for (i = 0; i < ep_count; i++)
293  printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion);
294 
295  free(ep);
296 }
297 
299 {
300  uint32_t i, lp_count;
301  VkLayerProperties* lp;
304  glfwGetInstanceProcAddress(instance, "vkEnumerateDeviceLayerProperties");
305 
306  printf("Vulkan device layers:\n");
307 
308  if (vkEnumerateDeviceLayerProperties(device, &lp_count, NULL) != VK_SUCCESS)
309  return;
310 
311  lp = calloc(lp_count, sizeof(VkLayerProperties));
312 
313  if (vkEnumerateDeviceLayerProperties(device, &lp_count, lp) != VK_SUCCESS)
314  {
315  free(lp);
316  return;
317  }
318 
319  for (i = 0; i < lp_count; i++)
320  {
321  printf(" %s (v%u) \"%s\"\n",
322  lp[i].layerName,
323  lp[i].specVersion >> 22,
324  lp[i].description);
325  }
326 
327  free(lp);
328 }
329 
330 static int valid_version(void)
331 {
332  int major, minor, revision;
333  glfwGetVersion(&major, &minor, &revision);
334 
335  if (major != GLFW_VERSION_MAJOR)
336  {
337  printf("*** ERROR: GLFW major version mismatch! ***\n");
338  return GLFW_FALSE;
339  }
340 
341  if (minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION)
342  printf("*** WARNING: GLFW version mismatch! ***\n");
343 
344  return GLFW_TRUE;
345 }
346 
347 static void print_version(void)
348 {
349  int major, minor, revision;
350  glfwGetVersion(&major, &minor, &revision);
351 
352  printf("GLFW header version: %u.%u.%u\n",
356  printf("GLFW library version: %u.%u.%u\n", major, minor, revision);
357  printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
358 }
359 
360 int main(int argc, char** argv)
361 {
362  int ch, client, major, minor, revision, profile;
363  GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits;
364  int list_extensions = GLFW_FALSE, list_layers = GLFW_FALSE;
365  GLenum error;
367 
368  enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG, FORWARD, HELP, EXTENSIONS, LAYERS,
369  MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION,
370  REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
371  ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
372  AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY };
373  const struct option options[] =
374  {
375  { "behavior", 1, NULL, BEHAVIOR },
376  { "client-api", 1, NULL, CLIENT },
377  { "context-api", 1, NULL, CONTEXT },
378  { "debug", 0, NULL, DEBUG },
379  { "forward", 0, NULL, FORWARD },
380  { "help", 0, NULL, HELP },
381  { "list-extensions", 0, NULL, EXTENSIONS },
382  { "list-layers", 0, NULL, LAYERS },
383  { "major", 1, NULL, MAJOR },
384  { "minor", 1, NULL, MINOR },
385  { "profile", 1, NULL, PROFILE },
386  { "robustness", 1, NULL, ROBUSTNESS },
387  { "version", 0, NULL, VERSION },
388  { "red-bits", 1, NULL, REDBITS },
389  { "green-bits", 1, NULL, GREENBITS },
390  { "blue-bits", 1, NULL, BLUEBITS },
391  { "alpha-bits", 1, NULL, ALPHABITS },
392  { "depth-bits", 1, NULL, DEPTHBITS },
393  { "stencil-bits", 1, NULL, STENCILBITS },
394  { "accum-red-bits", 1, NULL, ACCUMREDBITS },
395  { "accum-green-bits", 1, NULL, ACCUMGREENBITS },
396  { "accum-blue-bits", 1, NULL, ACCUMBLUEBITS },
397  { "accum-alpha-bits", 1, NULL, ACCUMALPHABITS },
398  { "aux-buffers", 1, NULL, AUXBUFFERS },
399  { "samples", 1, NULL, SAMPLES },
400  { "stereo", 0, NULL, STEREO },
401  { "srgb", 0, NULL, SRGB },
402  { "singlebuffer", 0, NULL, SINGLEBUFFER },
403  { "no-error", 0, NULL, NOERROR_SRSLY },
404  { NULL, 0, NULL, 0 }
405  };
406 
407  // Initialize GLFW and create window
408 
409  if (!valid_version())
410  exit(EXIT_FAILURE);
411 
413 
415 
416  if (!glfwInit())
417  exit(EXIT_FAILURE);
418 
419  while ((ch = getopt_long(argc, argv, "a:b:c:dfhlm:n:p:s:v", options, NULL)) != -1)
420  {
421  switch (ch)
422  {
423  case 'a':
424  case CLIENT:
425  if (strcasecmp(optarg, API_NAME_OPENGL) == 0)
427  else if (strcasecmp(optarg, API_NAME_OPENGL_ES) == 0)
429  else
430  {
431  usage();
432  exit(EXIT_FAILURE);
433  }
434  break;
435  case 'b':
436  case BEHAVIOR:
437  if (strcasecmp(optarg, BEHAVIOR_NAME_NONE) == 0)
438  {
441  }
442  else if (strcasecmp(optarg, BEHAVIOR_NAME_FLUSH) == 0)
443  {
446  }
447  else
448  {
449  usage();
450  exit(EXIT_FAILURE);
451  }
452  break;
453  case 'c':
454  case CONTEXT:
455  if (strcasecmp(optarg, API_NAME_NATIVE) == 0)
457  else if (strcasecmp(optarg, API_NAME_EGL) == 0)
459  else if (strcasecmp(optarg, API_NAME_OSMESA) == 0)
461  else
462  {
463  usage();
464  exit(EXIT_FAILURE);
465  }
466  break;
467  case 'd':
468  case DEBUG:
470  break;
471  case 'f':
472  case FORWARD:
474  break;
475  case 'h':
476  case HELP:
477  usage();
478  exit(EXIT_SUCCESS);
479  case 'l':
480  case EXTENSIONS:
481  list_extensions = GLFW_TRUE;
482  break;
483  case LAYERS:
484  list_layers = GLFW_TRUE;
485  break;
486  case 'm':
487  case MAJOR:
489  break;
490  case 'n':
491  case MINOR:
493  break;
494  case 'p':
495  case PROFILE:
496  if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0)
497  {
500  }
501  else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0)
502  {
505  }
506  else
507  {
508  usage();
509  exit(EXIT_FAILURE);
510  }
511  break;
512  case 's':
513  case ROBUSTNESS:
514  if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0)
515  {
518  }
519  else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0)
520  {
523  }
524  else
525  {
526  usage();
527  exit(EXIT_FAILURE);
528  }
529  break;
530  case 'v':
531  case VERSION:
532  print_version();
533  exit(EXIT_SUCCESS);
534  case REDBITS:
535  if (strcmp(optarg, "-") == 0)
537  else
539  break;
540  case GREENBITS:
541  if (strcmp(optarg, "-") == 0)
543  else
545  break;
546  case BLUEBITS:
547  if (strcmp(optarg, "-") == 0)
549  else
551  break;
552  case ALPHABITS:
553  if (strcmp(optarg, "-") == 0)
555  else
557  break;
558  case DEPTHBITS:
559  if (strcmp(optarg, "-") == 0)
561  else
563  break;
564  case STENCILBITS:
565  if (strcmp(optarg, "-") == 0)
567  else
569  break;
570  case ACCUMREDBITS:
571  if (strcmp(optarg, "-") == 0)
573  else
575  break;
576  case ACCUMGREENBITS:
577  if (strcmp(optarg, "-") == 0)
579  else
581  break;
582  case ACCUMBLUEBITS:
583  if (strcmp(optarg, "-") == 0)
585  else
587  break;
588  case ACCUMALPHABITS:
589  if (strcmp(optarg, "-") == 0)
591  else
593  break;
594  case AUXBUFFERS:
595  if (strcmp(optarg, "-") == 0)
597  else
599  break;
600  case SAMPLES:
601  if (strcmp(optarg, "-") == 0)
603  else
605  break;
606  case STEREO:
608  break;
609  case SRGB:
611  break;
612  case SINGLEBUFFER:
614  break;
615  case NOERROR_SRSLY:
617  break;
618  default:
619  usage();
620  exit(EXIT_FAILURE);
621  }
622  }
623 
624  print_version();
625 
627 
628  window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
629  if (!window)
630  {
631  glfwTerminate();
632  exit(EXIT_FAILURE);
633  }
634 
635  glfwMakeContextCurrent(window);
637 
638  error = glGetError();
639  if (error != GL_NO_ERROR)
640  printf("*** OpenGL error after make current: 0x%08x ***\n", error);
641 
642  // Report client API version
643 
644  client = glfwGetWindowAttrib(window, GLFW_CLIENT_API);
647  revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION);
648  profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE);
649 
650  printf("%s context version string: \"%s\"\n",
651  get_api_name(client),
653 
654  printf("%s context version parsed by GLFW: %u.%u.%u\n",
655  get_api_name(client),
656  major, minor, revision);
657 
658  // Report client API context properties
659 
660  if (client == GLFW_OPENGL_API)
661  {
662  if (major >= 3)
663  {
664  GLint flags;
665 
667  printf("%s context flags (0x%08x):", get_api_name(client), flags);
668 
670  printf(" forward-compatible");
671  if (flags & 2/*GL_CONTEXT_FLAG_DEBUG_BIT*/)
672  printf(" debug");
674  printf(" robustness");
675  if (flags & 8/*GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR*/)
676  printf(" no-error");
677  putchar('\n');
678 
679  printf("%s context flags parsed by GLFW:", get_api_name(client));
680 
682  printf(" forward-compatible");
684  printf(" debug");
686  printf(" robustness");
688  printf(" no-error");
689  putchar('\n');
690  }
691 
692  if (major >= 4 || (major == 3 && minor >= 2))
693  {
694  GLint mask;
696 
697  printf("%s profile mask (0x%08x): %s\n",
698  get_api_name(client),
699  mask,
700  get_profile_name_gl(mask));
701 
702  printf("%s profile mask parsed by GLFW: %s\n",
703  get_api_name(client),
704  get_profile_name_glfw(profile));
705  }
706 
708  {
709  const int robustness = glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS);
710  GLint strategy;
712 
713  printf("%s robustness strategy (0x%08x): %s\n",
714  get_api_name(client),
715  strategy,
716  get_strategy_name_gl(strategy));
717 
718  printf("%s robustness strategy parsed by GLFW: %s\n",
719  get_api_name(client),
720  get_strategy_name_glfw(robustness));
721  }
722  }
723 
724  printf("%s context renderer string: \"%s\"\n",
725  get_api_name(client),
727  printf("%s context vendor string: \"%s\"\n",
728  get_api_name(client),
730 
731  if (major >= 2)
732  {
733  printf("%s context shading language version: \"%s\"\n",
734  get_api_name(client),
736  }
737 
738  printf("%s framebuffer:\n", get_api_name(client));
739 
740  if (client == GLFW_OPENGL_API && profile == GLFW_OPENGL_CORE_PROFILE)
741  {
743  GL_BACK_LEFT,
745  &redbits);
747  GL_BACK_LEFT,
749  &greenbits);
751  GL_BACK_LEFT,
753  &bluebits);
755  GL_BACK_LEFT,
757  &alphabits);
759  GL_DEPTH,
761  &depthbits);
763  GL_STENCIL,
765  &stencilbits);
766  }
767  else
768  {
769  glGetIntegerv(GL_RED_BITS, &redbits);
770  glGetIntegerv(GL_GREEN_BITS, &greenbits);
771  glGetIntegerv(GL_BLUE_BITS, &bluebits);
772  glGetIntegerv(GL_ALPHA_BITS, &alphabits);
773  glGetIntegerv(GL_DEPTH_BITS, &depthbits);
774  glGetIntegerv(GL_STENCIL_BITS, &stencilbits);
775  }
776 
777  printf(" red: %u green: %u blue: %u alpha: %u depth: %u stencil: %u\n",
778  redbits, greenbits, bluebits, alphabits, depthbits, stencilbits);
779 
780  if (client == GLFW_OPENGL_ES_API ||
782  major > 1 || minor >= 3)
783  {
784  GLint samples, samplebuffers;
785  glGetIntegerv(GL_SAMPLES, &samples);
786  glGetIntegerv(GL_SAMPLE_BUFFERS, &samplebuffers);
787 
788  printf(" samples: %u sample buffers: %u\n", samples, samplebuffers);
789  }
790 
791  if (client == GLFW_OPENGL_API && profile != GLFW_OPENGL_CORE_PROFILE)
792  {
793  GLint accumredbits, accumgreenbits, accumbluebits, accumalphabits;
794  GLint auxbuffers;
795 
796  glGetIntegerv(GL_ACCUM_RED_BITS, &accumredbits);
797  glGetIntegerv(GL_ACCUM_GREEN_BITS, &accumgreenbits);
798  glGetIntegerv(GL_ACCUM_BLUE_BITS, &accumbluebits);
799  glGetIntegerv(GL_ACCUM_ALPHA_BITS, &accumalphabits);
800  glGetIntegerv(GL_AUX_BUFFERS, &auxbuffers);
801 
802  printf(" accum red: %u accum green: %u accum blue: %u accum alpha: %u aux buffers: %u\n",
803  accumredbits, accumgreenbits, accumbluebits, accumalphabits, auxbuffers);
804  }
805 
806  if (list_extensions)
807  list_context_extensions(client, major, minor);
808 
809  printf("Vulkan loader: %s\n",
810  glfwVulkanSupported() ? "available" : "missing");
811 
812  if (glfwVulkanSupported())
813  {
814  uint32_t i, re_count, pd_count;
815  const char** re;
816  VkApplicationInfo ai = {0};
817  VkInstanceCreateInfo ici = {0};
818  VkInstance instance;
819  VkPhysicalDevice* pd;
821  glfwGetInstanceProcAddress(NULL, "vkCreateInstance");
825 
826  re = glfwGetRequiredInstanceExtensions(&re_count);
827 
828  printf("Vulkan required instance extensions:");
829  if (re)
830  {
831  for (i = 0; i < re_count; i++)
832  printf(" %s", re[i]);
833  putchar('\n');
834  }
835  else
836  printf(" missing\n");
837 
838  if (list_extensions)
840 
841  if (list_layers)
843 
845  ai.pApplicationName = "glfwinfo";
847  ai.pEngineName = "GLFW";
850 
852  ici.pApplicationInfo = &ai;
853  ici.enabledExtensionCount = re_count;
854  ici.ppEnabledExtensionNames = re;
855 
856  if (vkCreateInstance(&ici, NULL, &instance) != VK_SUCCESS)
857  {
858  glfwTerminate();
859  exit(EXIT_FAILURE);
860  }
861 
862  vkDestroyInstance = (PFN_vkDestroyInstance)
863  glfwGetInstanceProcAddress(instance, "vkDestroyInstance");
864  vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices)
865  glfwGetInstanceProcAddress(instance, "vkEnumeratePhysicalDevices");
866  vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties)
867  glfwGetInstanceProcAddress(instance, "vkGetPhysicalDeviceProperties");
868 
869  if (vkEnumeratePhysicalDevices(instance, &pd_count, NULL) != VK_SUCCESS)
870  {
871  vkDestroyInstance(instance, NULL);
872  glfwTerminate();
873  exit(EXIT_FAILURE);
874  }
875 
876  pd = calloc(pd_count, sizeof(VkPhysicalDevice));
877 
878  if (vkEnumeratePhysicalDevices(instance, &pd_count, pd) != VK_SUCCESS)
879  {
880  free(pd);
881  vkDestroyInstance(instance, NULL);
882  glfwTerminate();
883  exit(EXIT_FAILURE);
884  }
885 
886  for (i = 0; i < pd_count; i++)
887  {
889 
890  vkGetPhysicalDeviceProperties(pd[i], &pdp);
891 
892  printf("Vulkan %s device: \"%s\"\n",
894  pdp.deviceName);
895 
896  if (list_extensions)
897  list_vulkan_device_extensions(instance, pd[i]);
898 
899  if (list_layers)
900  list_vulkan_device_layers(instance, pd[i]);
901  }
902 
903  free(pd);
904  vkDestroyInstance(instance, NULL);
905  }
906 
907  glfwTerminate();
908  exit(EXIT_SUCCESS);
909 }
910 
#define GLFW_CONTEXT_RELEASE_BEHAVIOR
Context flush-on-release hint and attribute.
Definition: glfw3.h:963
#define GL_CONTEXT_PROFILE_MASK
static void error_callback(int error, const char *description)
Definition: glfwinfo.c:105
#define GLFW_OPENGL_ES_API
Definition: glfw3.h:991
static const char * get_strategy_name_glfw(int strategy)
Definition: glfwinfo.c:166
#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
VkResult(VKAPI_PTR * PFN_vkCreateInstance)(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance)
Definition: vulkan_core.h:2704
#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance)
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
static void usage(void)
Definition: glfwinfo.c:57
#define VK_API_VERSION_1_0
Definition: vulkan_core.h:40
uint32_t applicationVersion
Definition: vulkan_core.h:1602
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
VkPhysicalDeviceType deviceType
Definition: vulkan_core.h:1857
GLFWAPI int glfwGetWindowAttrib(GLFWwindow *window, int attrib)
Returns an attribute of the specified window.
Definition: window.c:804
GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char *procname)
Definition: src/vulkan.c:243
The header of the GLFW 3 API.
#define GLFW_CONTEXT_ROBUSTNESS
Context robustness hint and attribute.
Definition: glfw3.h:939
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
Definition: context.c:741
#define BEHAVIOR_NAME_NONE
Definition: glfwinfo.c:54
#define GLFW_OPENGL_COMPAT_PROFILE
Definition: glfw3.h:999
void *(* GLADloadproc)(const char *name)
#define GL_RENDERER
static GLFWwindow * window
Definition: joysticks.c:55
#define GLFW_OPENGL_FORWARD_COMPAT
OpenGL forward-compatibility hint and attribute.
Definition: glfw3.h:945
#define glGetIntegerv
GLFWAPI int glfwVulkanSupported(void)
Returns whether the Vulkan loader and an ICD have been found.
Definition: src/vulkan.c:219
static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice device)
Definition: glfwinfo.c:298
#define GLFW_ACCUM_GREEN_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:868
#define GL_DEPTH
GLint GLuint mask
#define GLFW_CONTEXT_VERSION_MAJOR
Context client API major version hint and attribute.
Definition: glfw3.h:921
#define GL_AUX_BUFFERS
static const char * get_profile_name_gl(GLint mask)
Definition: glfwinfo.c:136
#define API_NAME_EGL
Definition: glfwinfo.c:45
#define GLFW_COCOA_MENUBAR
macOS specific init hint.
Definition: glfw3.h:1077
static const char * get_device_type_name(VkPhysicalDeviceType type)
Definition: glfwinfo.c:110
#define GL_STENCIL_BITS
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
Definition: init.c:309
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties)
GLAPI int GLAD_GL_ARB_multisample
#define API_NAME_NATIVE
Definition: glfwinfo.c:44
#define GLFW_FALSE
Zero.
Definition: glfw3.h:287
void(VKAPI_PTR * PFN_vkDestroyInstance)(VkInstance instance, const VkAllocationCallbacks *pAllocator)
Definition: vulkan_core.h:2705
#define GL_ACCUM_BLUE_BITS
#define GLFW_LOSE_CONTEXT_ON_RESET
Definition: glfw3.h:995
#define API_NAME_OPENGL
Definition: glfwinfo.c:41
#define GLFW_OPENGL_API
Definition: glfw3.h:990
#define GLFW_EGL_CONTEXT_API
Definition: glfw3.h:1015
#define GL_NO_ERROR
#define GLFW_OPENGL_PROFILE
OpenGL profile hint and attribute.
Definition: glfw3.h:957
#define glGetFramebufferAttachmentParameteriv
#define GLFW_RELEASE_BEHAVIOR_NONE
Definition: glfw3.h:1012
VkResult(VKAPI_PTR * PFN_vkEnumerateInstanceLayerProperties)(uint32_t *pPropertyCount, VkLayerProperties *pProperties)
Definition: vulkan_core.h:2719
VkResult(VKAPI_PTR * PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
Definition: vulkan_core.h:2718
#define BEHAVIOR_NAME_FLUSH
Definition: glfwinfo.c:55
#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB
#define GL_VENDOR
#define API_NAME_OPENGL_ES
Definition: glfwinfo.c:42
#define GLFW_CONTEXT_CREATION_API
Context creation API hint and attribute.
Definition: glfw3.h:975
#define GLFW_DONT_CARE
Definition: glfw3.h:1080
#define GL_SAMPLE_BUFFERS
khronos_uint8_t GLubyte
#define GLFW_OPENGL_DEBUG_CONTEXT
OpenGL debug context hint and attribute.
Definition: glfw3.h:951
#define GL_ACCUM_ALPHA_BITS
const char *const * ppEnabledExtensionNames
Definition: vulkan_core.h:1616
#define glGetStringi
#define GL_ACCUM_GREEN_BITS
static const std::string VERSION
Definition: constants.h:44
static void list_context_extensions(int client, int major, int minor)
Definition: glfwinfo.c:176
uint32_t enabledExtensionCount
Definition: vulkan_core.h:1615
static const char * get_profile_name_glfw(int profile)
Definition: glfwinfo.c:146
#define GL_BACK_LEFT
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
Definition: init.c:198
#define GL_SHADING_LANGUAGE_VERSION
#define GLFW_RED_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:833
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]
Definition: vulkan_core.h:1858
Definition: getopt.h:41
static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice device)
Definition: glfwinfo.c:271
#define GLFW_ALPHA_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:848
#define STRATEGY_NAME_NONE
Definition: glfwinfo.c:51
#define GL_CONTEXT_FLAGS
#define GL_LOSE_CONTEXT_ON_RESET_ARB
#define GLFW_NATIVE_CONTEXT_API
Definition: glfw3.h:1014
#define GLFW_CONTEXT_NO_ERROR
Context error suppression hint and attribute.
Definition: glfw3.h:969
#define GLFW_STENCIL_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:858
VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices)
int GLint
#define API_NAME_OSMESA
Definition: glfwinfo.c:46
static void print_version(void)
Definition: glfwinfo.c:347
#define PROFILE_NAME_COMPAT
Definition: glfwinfo.c:49
void * VkInstance
Definition: internal.h:118
unsigned int uint32_t
Definition: stdint.h:80
GLFWAPI const char * glfwGetVersionString(void)
Returns a string describing the compile-time configuration.
Definition: init.c:280
#define GL_ALPHA_BITS
#define GL_CONTEXT_CORE_PROFILE_BIT
void * VkPhysicalDevice
Definition: internal.h:119
#define GLFW_ACCUM_ALPHA_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:878
GLFWAPI void glfwGetVersion(int *major, int *minor, int *rev)
Retrieves the version of the GLFW library.
Definition: init.c:270
const VkApplicationInfo * pApplicationInfo
Definition: vulkan_core.h:1612
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
Definition: context.c:611
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkLayerProperties *pProperties)
#define PROFILE_NAME_CORE
Definition: glfwinfo.c:48
#define GL_NO_RESET_NOTIFICATION_ARB
GLbitfield flags
VkResult(VKAPI_PTR * PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices)
Definition: vulkan_core.h:2706
const char * pEngineName
Definition: vulkan_core.h:1603
static void list_vulkan_instance_extensions(void)
Definition: glfwinfo.c:212
#define GLFW_OSMESA_CONTEXT_API
Definition: glfw3.h:1016
#define glGetError
#define GLFW_AUX_BUFFERS
Framebuffer auxiliary buffer hint.
Definition: glfw3.h:883
#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
#define GLFW_ACCUM_RED_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:863
#define GLFW_GREEN_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:838
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, VkLayerProperties *pProperties)
void(VKAPI_PTR * PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties)
Definition: vulkan_core.h:2710
GLAPI int gladLoadGLLoader(GLADloadproc)
Definition: glad/glad.c:1697
#define GLFW_RELEASE_BEHAVIOR_FLUSH
Definition: glfw3.h:1011
static const textual_icon exit
Definition: model-views.h:254
VkPhysicalDeviceType
Definition: vulkan_core.h:752
#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT
static void list_vulkan_instance_layers(void)
Definition: glfwinfo.c:239
#define GL_GREEN_BITS
#define STRATEGY_NAME_LOSE
Definition: glfwinfo.c:52
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
Definition: getopt.c:158
#define GLFW_STEREO
OpenGL stereoscopic rendering hint.
Definition: glfw3.h:888
const char * pApplicationName
Definition: vulkan_core.h:1601
#define GL_DEPTH_BITS
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
Definition: window.c:151
#define GLFW_TRUE
One.
Definition: glfw3.h:279
#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
#define GL_BLUE_BITS
#define GLFW_DOUBLEBUFFER
Framebuffer double buffering hint.
Definition: glfw3.h:908
#define GLFW_SRGB_CAPABLE
Framebuffer sRGB hint.
Definition: glfw3.h:898
int main(int argc, char **argv)
Definition: glfwinfo.c:360
static const char * get_strategy_name_gl(GLint strategy)
Definition: glfwinfo.c:156
VkResult(VKAPI_PTR * PFN_vkEnumerateInstanceExtensionProperties)(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
Definition: vulkan_core.h:2717
#define GLFW_VERSION_REVISION
The revision number of the GLFW library.
Definition: glfw3.h:269
#define GL_EXTENSIONS
#define GL_STENCIL
#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT
#define GLFW_CONTEXT_REVISION
Context client API revision number hint and attribute.
Definition: glfw3.h:933
GLenum type
#define GLFW_OPENGL_CORE_PROFILE
Definition: glfw3.h:998
GLsizei samples
GLint GLsizei count
#define GLFW_VERSION_MINOR
The minor version number of the GLFW library.
Definition: glfw3.h:262
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
Definition: init.c:243
#define glGetString
VkResult(VKAPI_PTR * PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkLayerProperties *pProperties)
Definition: vulkan_core.h:2720
#define GL_ACCUM_RED_BITS
#define GLFW_VISIBLE
Window visibility window hint and attribute.
Definition: glfw3.h:780
#define GL_SAMPLES
#define GLFW_SAMPLES
Framebuffer MSAA samples hint.
Definition: glfw3.h:893
#define GL_RESET_NOTIFICATION_STRATEGY_ARB
GLAPI int GLAD_GL_ARB_robustness
VkStructureType sType
Definition: vulkan_core.h:1609
#define GLFW_VERSION_MAJOR
The major version number of the GLFW library.
Definition: glfw3.h:255
#define GLFW_ACCUM_BLUE_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:873
#define GLFW_BLUE_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:843
#define NULL
Definition: tinycthread.c:47
VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator)
unsigned int GLenum
int i
GLFWAPI const char ** glfwGetRequiredInstanceExtensions(uint32_t *count)
Returns the Vulkan instance extensions required by GLFW.
Definition: src/vulkan.c:225
char * optarg
Definition: getopt.c:36
static int valid_version(void)
Definition: glfwinfo.c:330
#define GL_VERSION
#define GLFW_CONTEXT_VERSION_MINOR
Context client API minor version hint and attribute.
Definition: glfw3.h:927
#define GL_NUM_EXTENSIONS
#define GL_RED_BITS
#define GLFW_NO_RESET_NOTIFICATION
Definition: glfw3.h:994
static const char * get_api_name(int api)
Definition: glfwinfo.c:126
auto device
Definition: pyrs_net.cpp:17
struct GLFWwindow GLFWwindow
uint32_t engineVersion
Definition: vulkan_core.h:1604
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
Definition: window.c:291
#define GL_FRAMEBUFFER
#define GLFW_CLIENT_API
Context client API hint and attribute.
Definition: glfw3.h:915
VkStructureType sType
Definition: vulkan_core.h:1599
#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
#define GLFW_DEPTH_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:853
GLFWAPI void glfwInitHint(int hint, int value)
Sets the specified init hint to the desired value.
Definition: init.c:251


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:16