Fix building evolution-data-server with cmake-3.20.1
[linux_from_scratch_patches.git] / mesa / mesa-19.2.0-add_xdemos-1.patch
bloba840b7181802086894480d69dba40bc1e1cd41b1
1 Submitted By: DJ Lucas <dj_AT_linuxfromscratch_DOT_org>
2 based on previous patches submitted
3 by Armin K and Fernando de Oliveira
4 Date: 2019-05-30
5 Initial Package Version: 19.0.4
6 Upstream Status: Not applicable.
7 Origin: Self.
8 Description: This patch adds two OpenGL demos, glxinfo and
9 glxgears and respective man pages.
11 diff -Naurp mesa-19.0.4-orig/src/glx/meson.build mesa-19.0.4/src/glx/meson.build
12 --- mesa-19.0.4-orig/src/glx/meson.build 2019-05-29 21:31:33.029435281 -0500
13 +++ mesa-19.0.4/src/glx/meson.build 2019-05-29 21:31:47.991434946 -0500
14 @@ -166,6 +166,8 @@ libgl = shared_library(
15 install : true,
18 +subdir('xdemos')
20 if with_tests
21 subdir('tests')
22 endif
23 diff -Naurp mesa-19.0.4-orig/src/glx/xdemos/glinfo_common.c mesa-19.0.4/src/glx/xdemos/glinfo_common.c
24 --- mesa-19.0.4-orig/src/glx/xdemos/glinfo_common.c 1969-12-31 18:00:00.000000000 -0600
25 +++ mesa-19.0.4/src/glx/xdemos/glinfo_common.c 2019-05-29 21:31:47.992434946 -0500
26 @@ -0,0 +1,800 @@
27 +/*
28 + * Copyright (C) 1999-2014 Brian Paul All Rights Reserved.
29 + *
30 + * Permission is hereby granted, free of charge, to any person obtaining a
31 + * copy of this software and associated documentation files (the "Software"),
32 + * to deal in the Software without restriction, including without limitation
33 + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
34 + * and/or sell copies of the Software, and to permit persons to whom the
35 + * Software is furnished to do so, subject to the following conditions:
36 + *
37 + * The above copyright notice and this permission notice shall be included
38 + * in all copies or substantial portions of the Software.
39 + *
40 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
41 + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
43 + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
44 + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
45 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 + */
48 +#include <assert.h>
49 +#include <ctype.h>
50 +#include <stdio.h>
51 +#include <stdlib.h>
52 +#include <string.h>
53 +#include "glinfo_common.h"
55 +#ifdef _WIN32
56 +#define snprintf _snprintf
57 +#endif
60 +/**
61 + * Return the GL enum name for a numeric value.
62 + * We really only care about the compressed texture formats for now.
63 + */
64 +static const char *
65 +enum_name(GLenum val)
67 + static const struct {
68 + const char *name;
69 + GLenum val;
70 + } enums [] = {
71 + { "GL_COMPRESSED_ALPHA", 0x84E9 },
72 + { "GL_COMPRESSED_LUMINANCE", 0x84EA },
73 + { "GL_COMPRESSED_LUMINANCE_ALPHA", 0x84EB },
74 + { "GL_COMPRESSED_INTENSITY", 0x84EC },
75 + { "GL_COMPRESSED_RGB", 0x84ED },
76 + { "GL_COMPRESSED_RGBA", 0x84EE },
77 + { "GL_COMPRESSED_TEXTURE_FORMATS", 0x86A3 },
78 + { "GL_COMPRESSED_RGB", 0x84ED },
79 + { "GL_COMPRESSED_RGBA", 0x84EE },
80 + { "GL_COMPRESSED_TEXTURE_FORMATS", 0x86A3 },
81 + { "GL_COMPRESSED_ALPHA", 0x84E9 },
82 + { "GL_COMPRESSED_LUMINANCE", 0x84EA },
83 + { "GL_COMPRESSED_LUMINANCE_ALPHA", 0x84EB },
84 + { "GL_COMPRESSED_INTENSITY", 0x84EC },
85 + { "GL_COMPRESSED_SRGB", 0x8C48 },
86 + { "GL_COMPRESSED_SRGB_ALPHA", 0x8C49 },
87 + { "GL_COMPRESSED_SLUMINANCE", 0x8C4A },
88 + { "GL_COMPRESSED_SLUMINANCE_ALPHA", 0x8C4B },
89 + { "GL_COMPRESSED_RED", 0x8225 },
90 + { "GL_COMPRESSED_RG", 0x8226 },
91 + { "GL_COMPRESSED_RED_RGTC1", 0x8DBB },
92 + { "GL_COMPRESSED_SIGNED_RED_RGTC1", 0x8DBC },
93 + { "GL_COMPRESSED_RG_RGTC2", 0x8DBD },
94 + { "GL_COMPRESSED_SIGNED_RG_RGTC2", 0x8DBE },
95 + { "GL_COMPRESSED_RGB8_ETC2", 0x9274 },
96 + { "GL_COMPRESSED_SRGB8_ETC2", 0x9275 },
97 + { "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", 0x9276 },
98 + { "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", 0x9277 },
99 + { "GL_COMPRESSED_RGBA8_ETC2_EAC", 0x9278 },
100 + { "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", 0x9279 },
101 + { "GL_COMPRESSED_R11_EAC", 0x9270 },
102 + { "GL_COMPRESSED_SIGNED_R11_EAC", 0x9271 },
103 + { "GL_COMPRESSED_RG11_EAC", 0x9272 },
104 + { "GL_COMPRESSED_SIGNED_RG11_EAC", 0x9273 },
105 + { "GL_COMPRESSED_ALPHA_ARB", 0x84E9 },
106 + { "GL_COMPRESSED_LUMINANCE_ARB", 0x84EA },
107 + { "GL_COMPRESSED_LUMINANCE_ALPHA_ARB", 0x84EB },
108 + { "GL_COMPRESSED_INTENSITY_ARB", 0x84EC },
109 + { "GL_COMPRESSED_RGB_ARB", 0x84ED },
110 + { "GL_COMPRESSED_RGBA_ARB", 0x84EE },
111 + { "GL_COMPRESSED_TEXTURE_FORMATS_ARB", 0x86A3 },
112 + { "GL_COMPRESSED_RGBA_BPTC_UNORM_ARB", 0x8E8C },
113 + { "GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB", 0x8E8D },
114 + { "GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB", 0x8E8E },
115 + { "GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB", 0x8E8F },
116 + { "GL_COMPRESSED_RGBA_ASTC_4x4_KHR", 0x93B0 },
117 + { "GL_COMPRESSED_RGBA_ASTC_5x4_KHR", 0x93B1 },
118 + { "GL_COMPRESSED_RGBA_ASTC_5x5_KHR", 0x93B2 },
119 + { "GL_COMPRESSED_RGBA_ASTC_6x5_KHR", 0x93B3 },
120 + { "GL_COMPRESSED_RGBA_ASTC_6x6_KHR", 0x93B4 },
121 + { "GL_COMPRESSED_RGBA_ASTC_8x5_KHR", 0x93B5 },
122 + { "GL_COMPRESSED_RGBA_ASTC_8x6_KHR", 0x93B6 },
123 + { "GL_COMPRESSED_RGBA_ASTC_8x8_KHR", 0x93B7 },
124 + { "GL_COMPRESSED_RGBA_ASTC_10x5_KHR", 0x93B8 },
125 + { "GL_COMPRESSED_RGBA_ASTC_10x6_KHR", 0x93B9 },
126 + { "GL_COMPRESSED_RGBA_ASTC_10x8_KHR", 0x93BA },
127 + { "GL_COMPRESSED_RGBA_ASTC_10x10_KHR", 0x93BB },
128 + { "GL_COMPRESSED_RGBA_ASTC_12x10_KHR", 0x93BC },
129 + { "GL_COMPRESSED_RGBA_ASTC_12x12_KHR", 0x93BD },
130 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR", 0x93D0 },
131 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR", 0x93D1 },
132 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR", 0x93D2 },
133 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR", 0x93D3 },
134 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR", 0x93D4 },
135 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR", 0x93D5 },
136 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR", 0x93D6 },
137 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR", 0x93D7 },
138 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR", 0x93D8 },
139 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR", 0x93D9 },
140 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR", 0x93DA },
141 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR", 0x93DB },
142 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR", 0x93DC },
143 + { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR", 0x93DD },
144 + { "GL_COMPRESSED_RGB_FXT1_3DFX", 0x86B0 },
145 + { "GL_COMPRESSED_RGBA_FXT1_3DFX", 0x86B1 },
146 + { "GL_COMPRESSED_LUMINANCE_LATC1_EXT", 0x8C70 },
147 + { "GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT", 0x8C71 },
148 + { "GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT", 0x8C72 },
149 + { "GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT", 0x8C73 },
150 + { "GL_COMPRESSED_RED_RGTC1_EXT", 0x8DBB },
151 + { "GL_COMPRESSED_SIGNED_RED_RGTC1_EXT", 0x8DBC },
152 + { "GL_COMPRESSED_RED_GREEN_RGTC2_EXT", 0x8DBD },
153 + { "GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT", 0x8DBE },
154 + { "GL_COMPRESSED_RGB_S3TC_DXT1_EXT", 0x83F0 },
155 + { "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT", 0x83F1 },
156 + { "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT", 0x83F2 },
157 + { "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT", 0x83F3 },
158 + { "GL_COMPRESSED_SRGB_EXT", 0x8C48 },
159 + { "GL_COMPRESSED_SRGB_ALPHA_EXT", 0x8C49 },
160 + { "GL_COMPRESSED_SLUMINANCE_EXT", 0x8C4A },
161 + { "GL_COMPRESSED_SLUMINANCE_ALPHA_EXT", 0x8C4B },
162 + { "GL_COMPRESSED_SRGB_S3TC_DXT1_EXT", 0x8C4C },
163 + { "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT", 0x8C4D },
164 + { "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT", 0x8C4E },
165 + { "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT", 0x8C4F },
166 + { "GL_PALETTE4_RGB8_OES", 0x8B90 },
167 + { "GL_PALETTE4_RGBA8_OES", 0x8B91 },
168 + { "GL_PALETTE4_R5_G6_B5_OES", 0x8B92 },
169 + { "GL_PALETTE4_RGBA4_OES", 0x8B93 },
170 + { "GL_PALETTE4_RGB5_A1_OES", 0x8B94 },
171 + { "GL_PALETTE8_RGB8_OES", 0x8B95 },
172 + { "GL_PALETTE8_RGBA8_OES", 0x8B96 },
173 + { "GL_PALETTE8_R5_G6_B5_OES", 0x8B97 },
174 + { "GL_PALETTE8_RGBA4_OES", 0x8B98 },
175 + { "GL_PALETTE8_RGB5_A1_OES", 0x8B99 }
176 + };
177 + const int n = sizeof(enums) / sizeof(enums[0]);
178 + static char buffer[100];
179 + int i;
180 + for (i = 0; i < n; i++) {
181 + if (enums[i].val == val) {
182 + return enums[i].name;
185 + /* enum val not found, just print hexadecimal value into static buffer */
186 + snprintf(buffer, sizeof(buffer), "0x%x", val);
187 + return buffer;
192 + * qsort callback for string comparison.
193 + */
194 +static int
195 +compare_string_ptr(const void *p1, const void *p2)
197 + return strcmp(* (char * const *) p1, * (char * const *) p2);
201 + * Print a list of extensions, with word-wrapping.
202 + */
203 +void
204 +print_extension_list(const char *ext, GLboolean singleLine)
206 + char **extensions;
207 + int num_extensions;
208 + const char *indentString = " ";
209 + const int indent = 4;
210 + const int max = 79;
211 + int width, i, j, k;
213 + if (!ext || !ext[0])
214 + return;
216 + /* count the number of extensions, ignoring successive spaces */
217 + num_extensions = 0;
218 + j = 1;
219 + do {
220 + if ((ext[j] == ' ' || ext[j] == 0) && ext[j - 1] != ' ') {
221 + ++num_extensions;
223 + } while(ext[j++]);
225 + /* copy individual extensions to an array */
226 + extensions = malloc(num_extensions * sizeof *extensions);
227 + if (!extensions) {
228 + fprintf(stderr, "Error: malloc() failed\n");
229 + exit(1);
231 + i = j = k = 0;
232 + while (1) {
233 + if (ext[j] == ' ' || ext[j] == 0) {
234 + /* found end of an extension name */
235 + const int len = j - i;
237 + if (len) {
238 + assert(k < num_extensions);
240 + extensions[k] = malloc(len + 1);
241 + if (!extensions[k]) {
242 + fprintf(stderr, "Error: malloc() failed\n");
243 + exit(1);
246 + memcpy(extensions[k], ext + i, len);
247 + extensions[k][len] = 0;
249 + ++k;
250 + };
252 + i += len + 1;
254 + if (ext[j] == 0) {
255 + break;
258 + j++;
260 + assert(k == num_extensions);
262 + /* sort extensions alphabetically */
263 + qsort(extensions, num_extensions, sizeof extensions[0], compare_string_ptr);
265 + /* print the extensions */
266 + width = indent;
267 + printf("%s", indentString);
268 + for (k = 0; k < num_extensions; ++k) {
269 + const int len = strlen(extensions[k]);
270 + if ((!singleLine) && (width + len > max)) {
271 + /* start a new line */
272 + printf("\n");
273 + width = indent;
274 + printf("%s", indentString);
276 + /* print the extension name */
277 + printf("%s", extensions[k]);
279 + /* either we're all done, or we'll continue with next extension */
280 + width += len + 1;
282 + if (singleLine) {
283 + printf("\n");
284 + width = indent;
285 + printf("%s", indentString);
287 + else if (k < (num_extensions -1)) {
288 + printf(", ");
289 + width += 2;
292 + printf("\n");
294 + for (k = 0; k < num_extensions; ++k) {
295 + free(extensions[k]);
297 + free(extensions);
303 +/**
304 + * Get list of OpenGL extensions using core profile's glGetStringi().
305 + */
306 +char *
307 +build_core_profile_extension_list(const struct ext_functions *extfuncs)
309 + GLint i, n, totalLen;
310 + char *buffer;
312 + glGetIntegerv(GL_NUM_EXTENSIONS, &n);
314 + /* compute totalLen */
315 + totalLen = 0;
316 + for (i = 0; i < n; i++) {
317 + const char *ext = (const char *) extfuncs->GetStringi(GL_EXTENSIONS, i);
318 + if (ext)
319 + totalLen += strlen(ext) + 1; /* plus a space */
322 + if (!totalLen)
323 + return NULL;
325 + buffer = malloc(totalLen + 1);
326 + if (buffer) {
327 + int pos = 0;
328 + for (i = 0; i < n; i++) {
329 + const char *ext = (const char *) extfuncs->GetStringi(GL_EXTENSIONS, i);
330 + strcpy(buffer + pos, ext);
331 + pos += strlen(ext);
332 + buffer[pos++] = ' ';
334 + buffer[pos] = '\0';
336 + return buffer;
340 +/** Is extension 'ext' supported? */
341 +GLboolean
342 +extension_supported(const char *ext, const char *extensionsList)
344 + while (1) {
345 + const char *p = strstr(extensionsList, ext);
346 + if (p) {
347 + /* check that next char is a space or end of string */
348 + int extLen = strlen(ext);
349 + if (p[extLen] == 0 || p[extLen] == ' ') {
350 + return 1;
352 + else {
353 + /* We found a superset string, keep looking */
354 + extensionsList += extLen;
357 + else {
358 + break;
361 + return 0;
365 +/**
366 + * Is verNum >= verString?
367 + * \param verString such as "2.1", "3.0", etc.
368 + * \param verNum such as 20, 21, 30, 31, 32, etc.
369 + */
370 +static GLboolean
371 +version_supported(const char *verString, int verNum)
373 + int v;
375 + if (!verString ||
376 + !isdigit(verString[0]) ||
377 + verString[1] != '.' ||
378 + !isdigit(verString[2])) {
379 + return GL_FALSE;
382 + v = (verString[0] - '0') * 10 + (verString[2] - '0');
384 + return verNum >= v;
388 +struct token_name
390 + GLenum token;
391 + const char *name;
395 +static void
396 +print_shader_limit_list(const struct token_name *lim)
398 + GLint max[1];
399 + unsigned i;
401 + for (i = 0; lim[i].token; i++) {
402 + glGetIntegerv(lim[i].token, max);
403 + if (glGetError() == GL_NO_ERROR) {
404 + printf(" %s = %d\n", lim[i].name, max[0]);
410 +/**
411 + * Print interesting limits for vertex/fragment shaders.
412 + */
413 +static void
414 +print_shader_limits(GLenum target)
416 + static const struct token_name vertex_limits[] = {
417 + { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" },
418 + { GL_MAX_VARYING_FLOATS_ARB, "GL_MAX_VARYING_FLOATS_ARB" },
419 + { GL_MAX_VERTEX_ATTRIBS_ARB, "GL_MAX_VERTEX_ATTRIBS_ARB" },
420 + { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
421 + { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" },
422 + { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" },
423 + { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" },
424 + { GL_MAX_VERTEX_OUTPUT_COMPONENTS , "GL_MAX_VERTEX_OUTPUT_COMPONENTS " },
425 + { (GLenum) 0, NULL }
426 + };
427 + static const struct token_name fragment_limits[] = {
428 + { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" },
429 + { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" },
430 + { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
431 + { GL_MAX_FRAGMENT_INPUT_COMPONENTS , "GL_MAX_FRAGMENT_INPUT_COMPONENTS " },
432 + { (GLenum) 0, NULL }
433 + };
434 + static const struct token_name geometry_limits[] = {
435 + { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS, "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS" },
436 + { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS" },
437 + { GL_MAX_GEOMETRY_OUTPUT_VERTICES , "GL_MAX_GEOMETRY_OUTPUT_VERTICES " },
438 + { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS, "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS" },
439 + { GL_MAX_GEOMETRY_INPUT_COMPONENTS , "GL_MAX_GEOMETRY_INPUT_COMPONENTS " },
440 + { GL_MAX_GEOMETRY_OUTPUT_COMPONENTS, "GL_MAX_GEOMETRY_OUTPUT_COMPONENTS" },
441 + { (GLenum) 0, NULL }
442 + };
444 + switch (target) {
445 + case GL_VERTEX_SHADER:
446 + printf(" GL_VERTEX_SHADER_ARB:\n");
447 + print_shader_limit_list(vertex_limits);
448 + break;
450 + case GL_FRAGMENT_SHADER:
451 + printf(" GL_FRAGMENT_SHADER_ARB:\n");
452 + print_shader_limit_list(fragment_limits);
453 + break;
455 + case GL_GEOMETRY_SHADER:
456 + printf(" GL_GEOMETRY_SHADER:\n");
457 + print_shader_limit_list(geometry_limits);
458 + break;
463 +/**
464 + * Print interesting limits for vertex/fragment programs.
465 + */
466 +static void
467 +print_program_limits(GLenum target,
468 + const struct ext_functions *extfuncs)
470 +#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
471 + struct token_name {
472 + GLenum token;
473 + const char *name;
474 + };
475 + static const struct token_name common_limits[] = {
476 + { GL_MAX_PROGRAM_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" },
477 + { GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" },
478 + { GL_MAX_PROGRAM_TEMPORARIES_ARB, "GL_MAX_PROGRAM_TEMPORARIES_ARB" },
479 + { GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" },
480 + { GL_MAX_PROGRAM_PARAMETERS_ARB, "GL_MAX_PROGRAM_PARAMETERS_ARB" },
481 + { GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" },
482 + { GL_MAX_PROGRAM_ATTRIBS_ARB, "GL_MAX_PROGRAM_ATTRIBS_ARB" },
483 + { GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" },
484 + { GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" },
485 + { GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" },
486 + { GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" },
487 + { GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" },
488 + { (GLenum) 0, NULL }
489 + };
490 + static const struct token_name fragment_limits[] = {
491 + { GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" },
492 + { GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" },
493 + { GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" },
494 + { GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" },
495 + { GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" },
496 + { GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" },
497 + { (GLenum) 0, NULL }
498 + };
500 + GLint max[1];
501 + int i;
503 + if (target == GL_VERTEX_PROGRAM_ARB) {
504 + printf(" GL_VERTEX_PROGRAM_ARB:\n");
506 + else if (target == GL_FRAGMENT_PROGRAM_ARB) {
507 + printf(" GL_FRAGMENT_PROGRAM_ARB:\n");
509 + else {
510 + return; /* something's wrong */
513 + for (i = 0; common_limits[i].token; i++) {
514 + extfuncs->GetProgramivARB(target, common_limits[i].token, max);
515 + if (glGetError() == GL_NO_ERROR) {
516 + printf(" %s = %d\n", common_limits[i].name, max[0]);
519 + if (target == GL_FRAGMENT_PROGRAM_ARB) {
520 + for (i = 0; fragment_limits[i].token; i++) {
521 + extfuncs->GetProgramivARB(target, fragment_limits[i].token, max);
522 + if (glGetError() == GL_NO_ERROR) {
523 + printf(" %s = %d\n", fragment_limits[i].name, max[0]);
527 +#endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */
531 +/**
532 + * Print interesting OpenGL implementation limits.
533 + * \param version 20, 21, 30, 31, 32, etc.
534 + */
535 +void
536 +print_limits(const char *extensions, const char *oglstring, int version,
537 + const struct ext_functions *extfuncs)
539 + struct token_name {
540 + GLuint count;
541 + GLenum token;
542 + const char *name;
543 + const char *extension; /* NULL or GL extension name or version string */
544 + };
545 + static const struct token_name limits[] = {
546 + { 1, GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH", NULL },
547 + { 1, GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", NULL },
548 + { 1, GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES", NULL },
549 + { 1, GL_MAX_COLOR_MATRIX_STACK_DEPTH, "GL_MAX_COLOR_MATRIX_STACK_DEPTH", "GL_ARB_imaging" },
550 + { 1, GL_MAX_ELEMENTS_VERTICES, "GL_MAX_ELEMENTS_VERTICES", NULL },
551 + { 1, GL_MAX_ELEMENTS_INDICES, "GL_MAX_ELEMENTS_INDICES", NULL },
552 + { 1, GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER", NULL },
553 + { 1, GL_MAX_LIGHTS, "GL_MAX_LIGHTS", NULL },
554 + { 1, GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING", NULL },
555 + { 1, GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH", NULL },
556 + { 1, GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH", NULL },
557 + { 1, GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE", NULL },
558 + { 1, GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH", NULL },
559 + { 1, GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH", NULL },
560 + { 1, GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE", NULL },
561 + { 1, GL_MAX_3D_TEXTURE_SIZE, "GL_MAX_3D_TEXTURE_SIZE", NULL },
562 +#if defined(GL_EXT_texture_array)
563 + { 1, GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, "GL_MAX_ARRAY_TEXTURE_LAYERS", "GL_EXT_texture_array" },
564 +#endif
565 + { 2, GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS", NULL },
566 + { 2, GL_ALIASED_LINE_WIDTH_RANGE, "GL_ALIASED_LINE_WIDTH_RANGE", NULL },
567 + { 2, GL_SMOOTH_LINE_WIDTH_RANGE, "GL_SMOOTH_LINE_WIDTH_RANGE", NULL },
568 + { 2, GL_ALIASED_POINT_SIZE_RANGE, "GL_ALIASED_POINT_SIZE_RANGE", NULL },
569 + { 2, GL_SMOOTH_POINT_SIZE_RANGE, "GL_SMOOTH_POINT_SIZE_RANGE", NULL },
570 +#if defined(GL_ARB_texture_cube_map)
571 + { 1, GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", "GL_ARB_texture_cube_map" },
572 +#endif
573 +#if defined(GL_NV_texture_rectangle)
574 + { 1, GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV", "GL_NV_texture_rectangle" },
575 +#endif
576 +#if defined(GL_ARB_multitexture)
577 + { 1, GL_MAX_TEXTURE_UNITS_ARB, "GL_MAX_TEXTURE_UNITS_ARB", "GL_ARB_multitexture" },
578 +#endif
579 +#if defined(GL_EXT_texture_lod_bias)
580 + { 1, GL_MAX_TEXTURE_LOD_BIAS_EXT, "GL_MAX_TEXTURE_LOD_BIAS_EXT", "GL_EXT_texture_lod_bias" },
581 +#endif
582 +#if defined(GL_EXT_texture_filter_anisotropic)
583 + { 1, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", "GL_EXT_texture_filter_anisotropic" },
584 +#endif
585 +#if defined(GL_ARB_draw_buffers)
586 + { 1, GL_MAX_DRAW_BUFFERS_ARB, "GL_MAX_DRAW_BUFFERS_ARB", "GL_ARB_draw_buffers" },
587 +#endif
588 +#if defined(GL_ARB_blend_func_extended)
589 + { 1, GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, "GL_MAX_DUAL_SOURCE_DRAW_BUFFERS", "GL_ARB_blend_func_extended" },
590 +#endif
591 +#if defined (GL_ARB_framebuffer_object)
592 + { 1, GL_MAX_RENDERBUFFER_SIZE, "GL_MAX_RENDERBUFFER_SIZE", "GL_ARB_framebuffer_object" },
593 + { 1, GL_MAX_COLOR_ATTACHMENTS, "GL_MAX_COLOR_ATTACHMENTS", "GL_ARB_framebuffer_object" },
594 + { 1, GL_MAX_SAMPLES, "GL_MAX_SAMPLES", "GL_ARB_framebuffer_object" },
595 +#endif
596 +#if defined (GL_EXT_transform_feedback)
597 + { 1, GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, "GL_MAX_TRANSFORM_FEEDBACK_BUFFERS", "GL_EXT_transform_feedback" },
598 + { 1, GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT, "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS", "GL_EXT_transform_feedback" },
599 + { 1, GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT, "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", "GL_EXT_transform_feedback", },
600 + { 1, GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT, "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS", "GL_EXT_transform_feedback" },
601 +#endif
602 +#if defined (GL_ARB_texture_buffer_object)
603 + { 1, GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, "GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT", "GL_ARB_texture_buffer_object" },
604 + { 1, GL_MAX_TEXTURE_BUFFER_SIZE, "GL_MAX_TEXTURE_BUFFER_SIZE", "GL_ARB_texture_buffer_object" },
605 +#endif
606 +#if defined (GL_ARB_texture_multisample)
607 + { 1, GL_MAX_COLOR_TEXTURE_SAMPLES, "GL_MAX_COLOR_TEXTURE_SAMPLES", "GL_ARB_texture_multisample" },
608 + { 1, GL_MAX_DEPTH_TEXTURE_SAMPLES, "GL_MAX_DEPTH_TEXTURE_SAMPLES", "GL_ARB_texture_multisample" },
609 + { 1, GL_MAX_INTEGER_SAMPLES, "GL_MAX_INTEGER_SAMPLES", "GL_ARB_texture_multisample" },
610 +#endif
611 +#if defined (GL_ARB_uniform_buffer_object)
612 + { 1, GL_MAX_VERTEX_UNIFORM_BLOCKS, "GL_MAX_VERTEX_UNIFORM_BLOCKS", "GL_ARB_uniform_buffer_object" },
613 + { 1, GL_MAX_FRAGMENT_UNIFORM_BLOCKS, "GL_MAX_FRAGMENT_UNIFORM_BLOCKS", "GL_ARB_uniform_buffer_object" },
614 + { 1, GL_MAX_GEOMETRY_UNIFORM_BLOCKS, "GL_MAX_GEOMETRY_UNIFORM_BLOCKS" , "GL_ARB_uniform_buffer_object" },
615 + { 1, GL_MAX_COMBINED_UNIFORM_BLOCKS, "GL_MAX_COMBINED_UNIFORM_BLOCKS", "GL_ARB_uniform_buffer_object" },
616 + { 1, GL_MAX_UNIFORM_BUFFER_BINDINGS, "GL_MAX_UNIFORM_BUFFER_BINDINGS", "GL_ARB_uniform_buffer_object" },
617 + { 1, GL_MAX_UNIFORM_BLOCK_SIZE, "GL_MAX_UNIFORM_BLOCK_SIZE", "GL_ARB_uniform_buffer_object" },
618 + { 1, GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, "GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS", "GL_ARB_uniform_buffer_object" },
619 + { 1, GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, "GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS", "GL_ARB_uniform_buffer_object" },
620 + { 1, GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS, "GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS", "GL_ARB_uniform_buffer_object" },
621 + { 1, GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, "GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT", "GL_ARB_uniform_buffer_object" },
622 +#endif
623 +#if defined (GL_ARB_vertex_attrib_binding)
624 + { 1, GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET", "GL_ARB_vertex_attrib_binding" },
625 + { 1, GL_MAX_VERTEX_ATTRIB_BINDINGS, "GL_MAX_VERTEX_ATTRIB_BINDINGS", "GL_ARB_vertex_attrib_binding" },
626 +#endif
627 +#if defined(GL_VERSION_4_4)
628 + { 1, GL_MAX_VERTEX_ATTRIB_STRIDE, "GL_MAX_VERTEX_ATTRIB_STRIDE", "4.4" },
629 +#endif
630 + { 0, (GLenum) 0, NULL, NULL }
631 + };
632 + GLint i, max[2];
634 + printf("%s limits:\n", oglstring);
635 + for (i = 0; limits[i].count; i++) {
636 + if (!limits[i].extension ||
637 + version_supported(limits[i].extension, version) ||
638 + extension_supported(limits[i].extension, extensions)) {
639 + glGetIntegerv(limits[i].token, max);
640 + if (glGetError() == GL_NO_ERROR) {
641 + if (limits[i].count == 1)
642 + printf(" %s = %d\n", limits[i].name, max[0]);
643 + else /* XXX fix if we ever query something with more than 2 values */
644 + printf(" %s = %d, %d\n", limits[i].name, max[0], max[1]);
649 + /* these don't fit into the above mechanism, unfortunately */
650 + if (extension_supported("GL_ARB_imaging", extensions)) {
651 + extfuncs->GetConvolutionParameteriv(GL_CONVOLUTION_2D,
652 + GL_MAX_CONVOLUTION_WIDTH, max);
653 + extfuncs->GetConvolutionParameteriv(GL_CONVOLUTION_2D,
654 + GL_MAX_CONVOLUTION_HEIGHT, max+1);
655 + printf(" GL_MAX_CONVOLUTION_WIDTH/HEIGHT = %d, %d\n", max[0], max[1]);
658 + if (extension_supported("GL_ARB_texture_compression", extensions)) {
659 + GLint i, n;
660 + GLint *formats;
661 + glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &n);
662 + printf(" GL_NUM_COMPRESSED_TEXTURE_FORMATS = %d\n", n);
663 + formats = (GLint *) malloc(n * sizeof(GLint));
664 + glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
665 + for (i = 0; i < n; i++) {
666 + printf(" %s\n", enum_name(formats[i]));
668 + free(formats);
670 +#if defined(GL_ARB_vertex_program)
671 + if (extension_supported("GL_ARB_vertex_program", extensions)) {
672 + print_program_limits(GL_VERTEX_PROGRAM_ARB, extfuncs);
674 +#endif
675 +#if defined(GL_ARB_fragment_program)
676 + if (extension_supported("GL_ARB_fragment_program", extensions)) {
677 + print_program_limits(GL_FRAGMENT_PROGRAM_ARB, extfuncs);
679 +#endif
680 + if (extension_supported("GL_ARB_vertex_shader", extensions)) {
681 + print_shader_limits(GL_VERTEX_SHADER_ARB);
683 + if (extension_supported("GL_ARB_fragment_shader", extensions)) {
684 + print_shader_limits(GL_FRAGMENT_SHADER_ARB);
686 + if (version >= 32) {
687 + print_shader_limits(GL_GEOMETRY_SHADER);
693 +/**
694 + * Return string representation for bits in a bitmask.
695 + */
696 +const char *
697 +bitmask_to_string(const struct bit_info bits[], int numBits, int mask)
699 + static char buffer[256], *p;
700 + int i;
702 + strcpy(buffer, "(none)");
703 + p = buffer;
704 + for (i = 0; i < numBits; i++) {
705 + if (mask & bits[i].bit) {
706 + if (p > buffer)
707 + *p++ = ',';
708 + strcpy(p, bits[i].name);
709 + p += strlen(bits[i].name);
713 + return buffer;
716 +/**
717 + * Return string representation for the bitmask returned by
718 + * GL_CONTEXT_PROFILE_MASK (OpenGL 3.2 or later).
719 + */
720 +const char *
721 +profile_mask_string(int mask)
723 + const static struct bit_info bits[] = {
724 +#ifdef GL_CONTEXT_CORE_PROFILE_BIT
725 + { GL_CONTEXT_CORE_PROFILE_BIT, "core profile"},
726 +#endif
727 +#ifdef GL_CONTEXT_COMPATIBILITY_PROFILE_BIT
728 + { GL_CONTEXT_COMPATIBILITY_PROFILE_BIT, "compatibility profile" }
729 +#endif
730 + };
732 + return bitmask_to_string(bits, ELEMENTS(bits), mask);
736 +/**
737 + * Return string representation for the bitmask returned by
738 + * GL_CONTEXT_FLAGS (OpenGL 3.0 or later).
739 + */
740 +const char *
741 +context_flags_string(int mask)
743 + const static struct bit_info bits[] = {
744 +#ifdef GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT
745 + { GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT, "forward-compatible" },
746 +#endif
747 +#ifdef GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB
748 + { GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB, "robust-access" },
749 +#endif
750 + };
752 + return bitmask_to_string(bits, ELEMENTS(bits), mask);
756 +static void
757 +usage(void)
759 +#ifdef _WIN32
760 + printf("Usage: wglinfo [-v] [-t] [-h] [-b] [-l] [-s]\n");
761 +#else
762 + printf("Usage: glxinfo [-v] [-t] [-h] [-b] [-l] [-s] [-i] [-display <dname>]\n");
763 + printf("\t-display <dname>: Print GLX visuals on specified server.\n");
764 + printf("\t-i: Force an indirect rendering context.\n");
765 +#endif
766 + printf("\t-B: brief output, print only the basics.\n");
767 + printf("\t-v: Print visuals info in verbose form.\n");
768 + printf("\t-t: Print verbose table.\n");
769 + printf("\t-h: This information.\n");
770 + printf("\t-b: Find the 'best' visual and print its number.\n");
771 + printf("\t-l: Print interesting OpenGL limits.\n");
772 + printf("\t-s: Print a single extension per line.\n");
775 +void
776 +parse_args(int argc, char *argv[], struct options *options)
778 + int i;
780 + options->mode = Normal;
781 + options->findBest = GL_FALSE;
782 + options->limits = GL_FALSE;
783 + options->singleLine = GL_FALSE;
784 + options->displayName = NULL;
785 + options->allowDirect = GL_TRUE;
787 + for (i = 1; i < argc; i++) {
788 +#ifndef _WIN32
789 + if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
790 + options->displayName = argv[i + 1];
791 + i++;
793 + else if (strcmp(argv[i], "-i") == 0) {
794 + options->allowDirect = GL_FALSE;
796 + else
797 +#endif
798 + if (strcmp(argv[i], "-t") == 0) {
799 + options->mode = Wide;
801 + else if (strcmp(argv[i], "-v") == 0) {
802 + options->mode = Verbose;
804 + else if (strcmp(argv[i], "-B") == 0) {
805 + options->mode = Brief;
807 + else if (strcmp(argv[i], "-b") == 0) {
808 + options->findBest = GL_TRUE;
810 + else if (strcmp(argv[i], "-l") == 0) {
811 + options->limits = GL_TRUE;
813 + else if (strcmp(argv[i], "-h") == 0) {
814 + usage();
815 + exit(0);
817 + else if(strcmp(argv[i], "-s") == 0) {
818 + options->singleLine = GL_TRUE;
820 + else {
821 + printf("Unknown option `%s'\n", argv[i]);
822 + usage();
823 + exit(0);
827 diff -Naurp mesa-19.0.4-orig/src/glx/xdemos/glinfo_common.h mesa-19.0.4/src/glx/xdemos/glinfo_common.h
828 --- mesa-19.0.4-orig/src/glx/xdemos/glinfo_common.h 1969-12-31 18:00:00.000000000 -0600
829 +++ mesa-19.0.4/src/glx/xdemos/glinfo_common.h 2019-05-29 21:31:47.992434946 -0500
830 @@ -0,0 +1,142 @@
832 + * Copyright (C) 1999-2014 Brian Paul All Rights Reserved.
833 + *
834 + * Permission is hereby granted, free of charge, to any person obtaining a
835 + * copy of this software and associated documentation files (the "Software"),
836 + * to deal in the Software without restriction, including without limitation
837 + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
838 + * and/or sell copies of the Software, and to permit persons to whom the
839 + * Software is furnished to do so, subject to the following conditions:
840 + *
841 + * The above copyright notice and this permission notice shall be included
842 + * in all copies or substantial portions of the Software.
843 + *
844 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
845 + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
846 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
847 + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
848 + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
849 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
850 + */
853 +/**
854 + * Common code shared by glxinfo and wglinfo.
855 + */
857 +#ifndef GLINFO_COMMON_H
858 +#define GLINFO_COMMON_H
861 +#ifdef _WIN32
862 +/* GL/glext.h is not commonly available on Windows. */
863 +#include <GL/glew.h>
864 +#else
865 +#include <GL/gl.h>
866 +#include <GL/glext.h>
867 +#endif
869 +typedef void (APIENTRY * GETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
870 +typedef const GLubyte *(APIENTRY * GETSTRINGIPROC) (GLenum name, GLuint index);
871 +typedef void (APIENTRY * GETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
874 +/**
875 + * Ext functions needed in common code but must be provided by
876 + * glxinfo or wglinfo.
877 + */
878 +struct ext_functions
880 + GETPROGRAMIVARBPROC GetProgramivARB;
881 + GETSTRINGIPROC GetStringi;
882 + GETCONVOLUTIONPARAMETERIVPROC GetConvolutionParameteriv;
886 +#define ELEMENTS(array) (sizeof(array) / sizeof(array[0]))
889 +struct bit_info
891 + int bit;
892 + const char *name;
896 +typedef enum
898 + Normal,
899 + Wide,
900 + Verbose,
901 + Brief
902 +} InfoMode;
905 +struct options
907 + InfoMode mode;
908 + GLboolean findBest;
909 + GLboolean limits;
910 + GLboolean singleLine;
911 + /* GLX only */
912 + char *displayName;
913 + GLboolean allowDirect;
917 +/** list of known OpenGL versions */
918 +static const struct { int major, minor; } gl_versions[] = {
919 + {4, 5},
920 + {4, 4},
921 + {4, 3},
922 + {4, 2},
923 + {4, 1},
924 + {4, 0},
926 + {3, 3},
927 + {3, 2},
928 + {3, 1},
929 + {3, 0},
931 + {2, 1},
932 + {2, 0},
934 + {1, 5},
935 + {1, 4},
936 + {1, 3},
937 + {1, 2},
938 + {1, 1},
939 + {1, 0},
941 + {0, 0} /* end of list */
945 +void
946 +print_extension_list(const char *ext, GLboolean singleLine);
948 +char *
949 +build_core_profile_extension_list(const struct ext_functions *extfuncs);
951 +GLboolean
952 +extension_supported(const char *ext, const char *extensionsList);
954 +void
955 +print_limits(const char *extensions, const char *oglstring, int version,
956 + const struct ext_functions *extfuncs);
958 +const char *
959 +bitmask_to_string(const struct bit_info bits[], int numBits, int mask);
961 +const char *
962 +profile_mask_string(int mask);
964 +const char *
965 +context_flags_string(int mask);
968 +void
969 +parse_args(int argc, char *argv[], struct options *options);
972 +#endif /* GLINFO_COMMON_H */
973 diff -Naurp mesa-19.0.4-orig/src/glx/xdemos/glxgears.1 mesa-19.0.4/src/glx/xdemos/glxgears.1
974 --- mesa-19.0.4-orig/src/glx/xdemos/glxgears.1 1969-12-31 18:00:00.000000000 -0600
975 +++ mesa-19.0.4/src/glx/xdemos/glxgears.1 2019-05-29 21:31:47.992434946 -0500
976 @@ -0,0 +1,37 @@
977 +.TH glxgears 1 "2006-11-29"
978 +.SH NAME
979 +glxgears \- ``gears'' demo for GLX
980 +.SH SYNOPSIS
981 +.B glxgears
982 +.RI [ options ]
983 +.SH DESCRIPTION
984 +The \fIglxgears\fP program is a port of the ``gears'' demo to GLX. It displays
985 +a set of rotating gears and prints out the frame rate at regular intervals. It
986 +has become quite popular as basic benchmarking tool.
987 +.SH OPTIONS
988 +.TP 8
989 +.B \-display \fIdisplay\fP
990 +Specify which X display to run on.
991 +.TP 8
992 +.B \-stereo
993 +Use a stereo enabled GLX visual.
994 +.TP 8
995 +.B \-samples \fIN\fP
996 +Run in multisample mode with at least N samples.
997 +.TP 8
998 +.B \-fullscreen
999 +Run in fullscreen mode.
1000 +.TP 8
1001 +.B \-info
1002 +Display OpenGL renderer information.
1003 +.TP 8
1004 +.B \-geometry \fIWxH+X+Y\fP
1005 +Window geometry.
1006 +.SH AUTHOR
1007 +glxgears was written by Brian Paul <brian.paul@tungstengraphics.com>.
1008 +.PP
1009 +This manual page was written by Thierry Reding <thierry@gilfi.de>, for the
1010 +Debian project and updated by Fernando de Oliveira <famobr at yahoo dot
1011 +com dot br>, for the Linux From Scratch (LFS) project (but may be used by
1012 +others).
1014 diff -Naurp mesa-19.0.4-orig/src/glx/xdemos/glxgears.c mesa-19.0.4/src/glx/xdemos/glxgears.c
1015 --- mesa-19.0.4-orig/src/glx/xdemos/glxgears.c 1969-12-31 18:00:00.000000000 -0600
1016 +++ mesa-19.0.4/src/glx/xdemos/glxgears.c 2019-05-29 21:31:47.992434946 -0500
1017 @@ -0,0 +1,809 @@
1019 + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
1020 + *
1021 + * Permission is hereby granted, free of charge, to any person obtaining a
1022 + * copy of this software and associated documentation files (the "Software"),
1023 + * to deal in the Software without restriction, including without limitation
1024 + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1025 + * and/or sell copies of the Software, and to permit persons to whom the
1026 + * Software is furnished to do so, subject to the following conditions:
1027 + *
1028 + * The above copyright notice and this permission notice shall be included
1029 + * in all copies or substantial portions of the Software.
1030 + *
1031 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1032 + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1033 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1034 + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
1035 + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1036 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1037 + */
1040 + * This is a port of the infamous "gears" demo to straight GLX (i.e. no GLUT)
1041 + * Port by Brian Paul 23 March 2001
1043 + * See usage() below for command line options.
1044 + */
1047 +#include <math.h>
1048 +#include <stdlib.h>
1049 +#include <stdio.h>
1050 +#include <string.h>
1051 +#include <X11/Xlib.h>
1052 +#include <X11/keysym.h>
1053 +#include <GL/gl.h>
1054 +#include <GL/glx.h>
1055 +#include <GL/glxext.h>
1057 +#ifndef GLX_MESA_swap_control
1058 +#define GLX_MESA_swap_control 1
1059 +typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void);
1060 +#endif
1063 +#define BENCHMARK
1065 +#ifdef BENCHMARK
1067 +/* XXX this probably isn't very portable */
1069 +#include <sys/time.h>
1070 +#include <unistd.h>
1072 +/* return current time (in seconds) */
1073 +static double
1074 +current_time(void)
1076 + struct timeval tv;
1077 +#ifdef __VMS
1078 + (void) gettimeofday(&tv, NULL );
1079 +#else
1080 + struct timezone tz;
1081 + (void) gettimeofday(&tv, &tz);
1082 +#endif
1083 + return (double) tv.tv_sec + tv.tv_usec / 1000000.0;
1086 +#else /*BENCHMARK*/
1088 +/* dummy */
1089 +static double
1090 +current_time(void)
1092 + /* update this function for other platforms! */
1093 + static double t = 0.0;
1094 + static int warn = 1;
1095 + if (warn) {
1096 + fprintf(stderr, "Warning: current_time() not implemented!!\n");
1097 + warn = 0;
1099 + return t += 1.0;
1102 +#endif /*BENCHMARK*/
1106 +#ifndef M_PI
1107 +#define M_PI 3.14159265
1108 +#endif
1111 +/** Event handler results: */
1112 +#define NOP 0
1113 +#define EXIT 1
1114 +#define DRAW 2
1116 +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
1117 +static GLint gear1, gear2, gear3;
1118 +static GLfloat angle = 0.0;
1120 +static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */
1121 +static GLboolean stereo = GL_FALSE; /* Enable stereo. */
1122 +static GLint samples = 0; /* Choose visual with at least N samples. */
1123 +static GLboolean animate = GL_TRUE; /* Animation */
1124 +static GLfloat eyesep = 5.0; /* Eye separation. */
1125 +static GLfloat fix_point = 40.0; /* Fixation point distance. */
1126 +static GLfloat left, right, asp; /* Stereo frustum params. */
1131 + * Draw a gear wheel. You'll probably want to call this function when
1132 + * building a display list since we do a lot of trig here.
1133 + *
1134 + * Input: inner_radius - radius of hole at center
1135 + * outer_radius - radius at center of teeth
1136 + * width - width of gear
1137 + * teeth - number of teeth
1138 + * tooth_depth - depth of tooth
1139 + */
1140 +static void
1141 +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
1142 + GLint teeth, GLfloat tooth_depth)
1144 + GLint i;
1145 + GLfloat r0, r1, r2;
1146 + GLfloat angle, da;
1147 + GLfloat u, v, len;
1149 + r0 = inner_radius;
1150 + r1 = outer_radius - tooth_depth / 2.0;
1151 + r2 = outer_radius + tooth_depth / 2.0;
1153 + da = 2.0 * M_PI / teeth / 4.0;
1155 + glShadeModel(GL_FLAT);
1157 + glNormal3f(0.0, 0.0, 1.0);
1159 + /* draw front face */
1160 + glBegin(GL_QUAD_STRIP);
1161 + for (i = 0; i <= teeth; i++) {
1162 + angle = i * 2.0 * M_PI / teeth;
1163 + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
1164 + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
1165 + if (i < teeth) {
1166 + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
1167 + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1168 + width * 0.5);
1171 + glEnd();
1173 + /* draw front sides of teeth */
1174 + glBegin(GL_QUADS);
1175 + da = 2.0 * M_PI / teeth / 4.0;
1176 + for (i = 0; i < teeth; i++) {
1177 + angle = i * 2.0 * M_PI / teeth;
1179 + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
1180 + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
1181 + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
1182 + width * 0.5);
1183 + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1184 + width * 0.5);
1186 + glEnd();
1188 + glNormal3f(0.0, 0.0, -1.0);
1190 + /* draw back face */
1191 + glBegin(GL_QUAD_STRIP);
1192 + for (i = 0; i <= teeth; i++) {
1193 + angle = i * 2.0 * M_PI / teeth;
1194 + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
1195 + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
1196 + if (i < teeth) {
1197 + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1198 + -width * 0.5);
1199 + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
1202 + glEnd();
1204 + /* draw back sides of teeth */
1205 + glBegin(GL_QUADS);
1206 + da = 2.0 * M_PI / teeth / 4.0;
1207 + for (i = 0; i < teeth; i++) {
1208 + angle = i * 2.0 * M_PI / teeth;
1210 + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1211 + -width * 0.5);
1212 + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
1213 + -width * 0.5);
1214 + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
1215 + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
1217 + glEnd();
1219 + /* draw outward faces of teeth */
1220 + glBegin(GL_QUAD_STRIP);
1221 + for (i = 0; i < teeth; i++) {
1222 + angle = i * 2.0 * M_PI / teeth;
1224 + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
1225 + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
1226 + u = r2 * cos(angle + da) - r1 * cos(angle);
1227 + v = r2 * sin(angle + da) - r1 * sin(angle);
1228 + len = sqrt(u * u + v * v);
1229 + u /= len;
1230 + v /= len;
1231 + glNormal3f(v, -u, 0.0);
1232 + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
1233 + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
1234 + glNormal3f(cos(angle), sin(angle), 0.0);
1235 + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
1236 + width * 0.5);
1237 + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
1238 + -width * 0.5);
1239 + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
1240 + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
1241 + glNormal3f(v, -u, 0.0);
1242 + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1243 + width * 0.5);
1244 + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1245 + -width * 0.5);
1246 + glNormal3f(cos(angle), sin(angle), 0.0);
1249 + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
1250 + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
1252 + glEnd();
1254 + glShadeModel(GL_SMOOTH);
1256 + /* draw inside radius cylinder */
1257 + glBegin(GL_QUAD_STRIP);
1258 + for (i = 0; i <= teeth; i++) {
1259 + angle = i * 2.0 * M_PI / teeth;
1260 + glNormal3f(-cos(angle), -sin(angle), 0.0);
1261 + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
1262 + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
1264 + glEnd();
1268 +static void
1269 +draw(void)
1271 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1273 + glPushMatrix();
1274 + glRotatef(view_rotx, 1.0, 0.0, 0.0);
1275 + glRotatef(view_roty, 0.0, 1.0, 0.0);
1276 + glRotatef(view_rotz, 0.0, 0.0, 1.0);
1278 + glPushMatrix();
1279 + glTranslatef(-3.0, -2.0, 0.0);
1280 + glRotatef(angle, 0.0, 0.0, 1.0);
1281 + glCallList(gear1);
1282 + glPopMatrix();
1284 + glPushMatrix();
1285 + glTranslatef(3.1, -2.0, 0.0);
1286 + glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
1287 + glCallList(gear2);
1288 + glPopMatrix();
1290 + glPushMatrix();
1291 + glTranslatef(-3.1, 4.2, 0.0);
1292 + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
1293 + glCallList(gear3);
1294 + glPopMatrix();
1296 + glPopMatrix();
1300 +static void
1301 +draw_gears(void)
1303 + if (stereo) {
1304 + /* First left eye. */
1305 + glDrawBuffer(GL_BACK_LEFT);
1307 + glMatrixMode(GL_PROJECTION);
1308 + glLoadIdentity();
1309 + glFrustum(left, right, -asp, asp, 5.0, 60.0);
1311 + glMatrixMode(GL_MODELVIEW);
1313 + glPushMatrix();
1314 + glTranslated(+0.5 * eyesep, 0.0, 0.0);
1315 + draw();
1316 + glPopMatrix();
1318 + /* Then right eye. */
1319 + glDrawBuffer(GL_BACK_RIGHT);
1321 + glMatrixMode(GL_PROJECTION);
1322 + glLoadIdentity();
1323 + glFrustum(-right, -left, -asp, asp, 5.0, 60.0);
1325 + glMatrixMode(GL_MODELVIEW);
1327 + glPushMatrix();
1328 + glTranslated(-0.5 * eyesep, 0.0, 0.0);
1329 + draw();
1330 + glPopMatrix();
1332 + else {
1333 + draw();
1338 +/** Draw single frame, do SwapBuffers, compute FPS */
1339 +static void
1340 +draw_frame(Display *dpy, Window win)
1342 + static int frames = 0;
1343 + static double tRot0 = -1.0, tRate0 = -1.0;
1344 + double dt, t = current_time();
1346 + if (tRot0 < 0.0)
1347 + tRot0 = t;
1348 + dt = t - tRot0;
1349 + tRot0 = t;
1351 + if (animate) {
1352 + /* advance rotation for next frame */
1353 + angle += 70.0 * dt; /* 70 degrees per second */
1354 + if (angle > 3600.0)
1355 + angle -= 3600.0;
1358 + draw_gears();
1359 + glXSwapBuffers(dpy, win);
1361 + frames++;
1363 + if (tRate0 < 0.0)
1364 + tRate0 = t;
1365 + if (t - tRate0 >= 5.0) {
1366 + GLfloat seconds = t - tRate0;
1367 + GLfloat fps = frames / seconds;
1368 + printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
1369 + fps);
1370 + fflush(stdout);
1371 + tRate0 = t;
1372 + frames = 0;
1377 +/* new window size or exposure */
1378 +static void
1379 +reshape(int width, int height)
1381 + glViewport(0, 0, (GLint) width, (GLint) height);
1383 + if (stereo) {
1384 + GLfloat w;
1386 + asp = (GLfloat) height / (GLfloat) width;
1387 + w = fix_point * (1.0 / 5.0);
1389 + left = -5.0 * ((w - 0.5 * eyesep) / fix_point);
1390 + right = 5.0 * ((w + 0.5 * eyesep) / fix_point);
1392 + else {
1393 + GLfloat h = (GLfloat) height / (GLfloat) width;
1395 + glMatrixMode(GL_PROJECTION);
1396 + glLoadIdentity();
1397 + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
1400 + glMatrixMode(GL_MODELVIEW);
1401 + glLoadIdentity();
1402 + glTranslatef(0.0, 0.0, -40.0);
1407 +static void
1408 +init(void)
1410 + static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
1411 + static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
1412 + static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
1413 + static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
1415 + glLightfv(GL_LIGHT0, GL_POSITION, pos);
1416 + glEnable(GL_CULL_FACE);
1417 + glEnable(GL_LIGHTING);
1418 + glEnable(GL_LIGHT0);
1419 + glEnable(GL_DEPTH_TEST);
1421 + /* make the gears */
1422 + gear1 = glGenLists(1);
1423 + glNewList(gear1, GL_COMPILE);
1424 + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
1425 + gear(1.0, 4.0, 1.0, 20, 0.7);
1426 + glEndList();
1428 + gear2 = glGenLists(1);
1429 + glNewList(gear2, GL_COMPILE);
1430 + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
1431 + gear(0.5, 2.0, 2.0, 10, 0.7);
1432 + glEndList();
1434 + gear3 = glGenLists(1);
1435 + glNewList(gear3, GL_COMPILE);
1436 + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
1437 + gear(1.3, 2.0, 0.5, 10, 0.7);
1438 + glEndList();
1440 + glEnable(GL_NORMALIZE);
1444 +/**
1445 + * Remove window border/decorations.
1446 + */
1447 +static void
1448 +no_border( Display *dpy, Window w)
1450 + static const unsigned MWM_HINTS_DECORATIONS = (1 << 1);
1451 + static const int PROP_MOTIF_WM_HINTS_ELEMENTS = 5;
1453 + typedef struct
1455 + unsigned long flags;
1456 + unsigned long functions;
1457 + unsigned long decorations;
1458 + long inputMode;
1459 + unsigned long status;
1460 + } PropMotifWmHints;
1462 + PropMotifWmHints motif_hints;
1463 + Atom prop, proptype;
1464 + unsigned long flags = 0;
1466 + /* setup the property */
1467 + motif_hints.flags = MWM_HINTS_DECORATIONS;
1468 + motif_hints.decorations = flags;
1470 + /* get the atom for the property */
1471 + prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True );
1472 + if (!prop) {
1473 + /* something went wrong! */
1474 + return;
1477 + /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */
1478 + proptype = prop;
1480 + XChangeProperty( dpy, w, /* display, window */
1481 + prop, proptype, /* property, type */
1482 + 32, /* format: 32-bit datums */
1483 + PropModeReplace, /* mode */
1484 + (unsigned char *) &motif_hints, /* data */
1485 + PROP_MOTIF_WM_HINTS_ELEMENTS /* nelements */
1486 + );
1491 + * Create an RGB, double-buffered window.
1492 + * Return the window and context handles.
1493 + */
1494 +static void
1495 +make_window( Display *dpy, const char *name,
1496 + int x, int y, int width, int height,
1497 + Window *winRet, GLXContext *ctxRet, VisualID *visRet)
1499 + int attribs[64];
1500 + int i = 0;
1502 + int scrnum;
1503 + XSetWindowAttributes attr;
1504 + unsigned long mask;
1505 + Window root;
1506 + Window win;
1507 + GLXContext ctx;
1508 + XVisualInfo *visinfo;
1510 + /* Singleton attributes. */
1511 + attribs[i++] = GLX_RGBA;
1512 + attribs[i++] = GLX_DOUBLEBUFFER;
1513 + if (stereo)
1514 + attribs[i++] = GLX_STEREO;
1516 + /* Key/value attributes. */
1517 + attribs[i++] = GLX_RED_SIZE;
1518 + attribs[i++] = 1;
1519 + attribs[i++] = GLX_GREEN_SIZE;
1520 + attribs[i++] = 1;
1521 + attribs[i++] = GLX_BLUE_SIZE;
1522 + attribs[i++] = 1;
1523 + attribs[i++] = GLX_DEPTH_SIZE;
1524 + attribs[i++] = 1;
1525 + if (samples > 0) {
1526 + attribs[i++] = GLX_SAMPLE_BUFFERS;
1527 + attribs[i++] = 1;
1528 + attribs[i++] = GLX_SAMPLES;
1529 + attribs[i++] = samples;
1532 + attribs[i++] = None;
1534 + scrnum = DefaultScreen( dpy );
1535 + root = RootWindow( dpy, scrnum );
1537 + visinfo = glXChooseVisual(dpy, scrnum, attribs);
1538 + if (!visinfo) {
1539 + printf("Error: couldn't get an RGB, Double-buffered");
1540 + if (stereo)
1541 + printf(", Stereo");
1542 + if (samples > 0)
1543 + printf(", Multisample");
1544 + printf(" visual\n");
1545 + exit(1);
1548 + /* window attributes */
1549 + attr.background_pixel = 0;
1550 + attr.border_pixel = 0;
1551 + attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
1552 + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
1553 + /* XXX this is a bad way to get a borderless window! */
1554 + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
1556 + win = XCreateWindow( dpy, root, x, y, width, height,
1557 + 0, visinfo->depth, InputOutput,
1558 + visinfo->visual, mask, &attr );
1560 + if (fullscreen)
1561 + no_border(dpy, win);
1563 + /* set hints and properties */
1565 + XSizeHints sizehints;
1566 + sizehints.x = x;
1567 + sizehints.y = y;
1568 + sizehints.width = width;
1569 + sizehints.height = height;
1570 + sizehints.flags = USSize | USPosition;
1571 + XSetNormalHints(dpy, win, &sizehints);
1572 + XSetStandardProperties(dpy, win, name, name,
1573 + None, (char **)NULL, 0, &sizehints);
1576 + ctx = glXCreateContext( dpy, visinfo, NULL, True );
1577 + if (!ctx) {
1578 + printf("Error: glXCreateContext failed\n");
1579 + exit(1);
1582 + *winRet = win;
1583 + *ctxRet = ctx;
1584 + *visRet = visinfo->visualid;
1586 + XFree(visinfo);
1590 +/**
1591 + * Determine whether or not a GLX extension is supported.
1592 + */
1593 +static int
1594 +is_glx_extension_supported(Display *dpy, const char *query)
1596 + const int scrnum = DefaultScreen(dpy);
1597 + const char *glx_extensions = NULL;
1598 + const size_t len = strlen(query);
1599 + const char *ptr;
1601 + if (glx_extensions == NULL) {
1602 + glx_extensions = glXQueryExtensionsString(dpy, scrnum);
1605 + ptr = strstr(glx_extensions, query);
1606 + return ((ptr != NULL) && ((ptr[len] == ' ') || (ptr[len] == '\0')));
1610 +/**
1611 + * Attempt to determine whether or not the display is synched to vblank.
1612 + */
1613 +static void
1614 +query_vsync(Display *dpy, GLXDrawable drawable)
1616 + int interval = 0;
1618 +#if defined(GLX_EXT_swap_control)
1619 + if (is_glx_extension_supported(dpy, "GLX_EXT_swap_control")) {
1620 + unsigned int tmp = -1;
1621 + glXQueryDrawable(dpy, drawable, GLX_SWAP_INTERVAL_EXT, &tmp);
1622 + interval = tmp;
1623 + } else
1624 +#endif
1625 + if (is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) {
1626 + PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA =
1627 + (PFNGLXGETSWAPINTERVALMESAPROC)
1628 + glXGetProcAddressARB((const GLubyte *) "glXGetSwapIntervalMESA");
1630 + interval = (*pglXGetSwapIntervalMESA)();
1631 + } else if (is_glx_extension_supported(dpy, "GLX_SGI_swap_control")) {
1632 + /* The default swap interval with this extension is 1. Assume that it
1633 + * is set to the default.
1635 + * Many Mesa-based drivers default to 0, but all of these drivers also
1636 + * export GLX_MESA_swap_control. In that case, this branch will never
1637 + * be taken, and the correct result should be reported.
1638 + */
1639 + interval = 1;
1643 + if (interval > 0) {
1644 + printf("Running synchronized to the vertical refresh. The framerate should be\n");
1645 + if (interval == 1) {
1646 + printf("approximately the same as the monitor refresh rate.\n");
1647 + } else if (interval > 1) {
1648 + printf("approximately 1/%d the monitor refresh rate.\n",
1649 + interval);
1654 +/**
1655 + * Handle one X event.
1656 + * \return NOP, EXIT or DRAW
1657 + */
1658 +static int
1659 +handle_event(Display *dpy, Window win, XEvent *event)
1661 + (void) dpy;
1662 + (void) win;
1664 + switch (event->type) {
1665 + case Expose:
1666 + return DRAW;
1667 + case ConfigureNotify:
1668 + reshape(event->xconfigure.width, event->xconfigure.height);
1669 + break;
1670 + case KeyPress:
1672 + char buffer[10];
1673 + int code;
1674 + code = XLookupKeysym(&event->xkey, 0);
1675 + if (code == XK_Left) {
1676 + view_roty += 5.0;
1678 + else if (code == XK_Right) {
1679 + view_roty -= 5.0;
1681 + else if (code == XK_Up) {
1682 + view_rotx += 5.0;
1684 + else if (code == XK_Down) {
1685 + view_rotx -= 5.0;
1687 + else {
1688 + XLookupString(&event->xkey, buffer, sizeof(buffer),
1689 + NULL, NULL);
1690 + if (buffer[0] == 27) {
1691 + /* escape */
1692 + return EXIT;
1694 + else if (buffer[0] == 'a' || buffer[0] == 'A') {
1695 + animate = !animate;
1698 + return DRAW;
1701 + return NOP;
1705 +static void
1706 +event_loop(Display *dpy, Window win)
1708 + while (1) {
1709 + int op;
1710 + while (!animate || XPending(dpy) > 0) {
1711 + XEvent event;
1712 + XNextEvent(dpy, &event);
1713 + op = handle_event(dpy, win, &event);
1714 + if (op == EXIT)
1715 + return;
1716 + else if (op == DRAW)
1717 + break;
1720 + draw_frame(dpy, win);
1725 +static void
1726 +usage(void)
1728 + printf("Usage:\n");
1729 + printf(" -display <displayname> set the display to run on\n");
1730 + printf(" -stereo run in stereo mode\n");
1731 + printf(" -samples N run in multisample mode with at least N samples\n");
1732 + printf(" -fullscreen run in fullscreen mode\n");
1733 + printf(" -info display OpenGL renderer info\n");
1734 + printf(" -geometry WxH+X+Y window geometry\n");
1738 +int
1739 +main(int argc, char *argv[])
1741 + unsigned int winWidth = 300, winHeight = 300;
1742 + int x = 0, y = 0;
1743 + Display *dpy;
1744 + Window win;
1745 + GLXContext ctx;
1746 + char *dpyName = NULL;
1747 + GLboolean printInfo = GL_FALSE;
1748 + VisualID visId;
1749 + int i;
1751 + for (i = 1; i < argc; i++) {
1752 + if (strcmp(argv[i], "-display") == 0) {
1753 + dpyName = argv[i+1];
1754 + i++;
1756 + else if (strcmp(argv[i], "-info") == 0) {
1757 + printInfo = GL_TRUE;
1759 + else if (strcmp(argv[i], "-stereo") == 0) {
1760 + stereo = GL_TRUE;
1762 + else if (i < argc-1 && strcmp(argv[i], "-samples") == 0) {
1763 + samples = strtod(argv[i+1], NULL );
1764 + ++i;
1766 + else if (strcmp(argv[i], "-fullscreen") == 0) {
1767 + fullscreen = GL_TRUE;
1769 + else if (i < argc-1 && strcmp(argv[i], "-geometry") == 0) {
1770 + XParseGeometry(argv[i+1], &x, &y, &winWidth, &winHeight);
1771 + i++;
1773 + else {
1774 + usage();
1775 + return -1;
1779 + dpy = XOpenDisplay(dpyName);
1780 + if (!dpy) {
1781 + printf("Error: couldn't open display %s\n",
1782 + dpyName ? dpyName : getenv("DISPLAY"));
1783 + return -1;
1786 + if (fullscreen) {
1787 + int scrnum = DefaultScreen(dpy);
1789 + x = 0; y = 0;
1790 + winWidth = DisplayWidth(dpy, scrnum);
1791 + winHeight = DisplayHeight(dpy, scrnum);
1794 + make_window(dpy, "glxgears", x, y, winWidth, winHeight, &win, &ctx, &visId);
1795 + XMapWindow(dpy, win);
1796 + glXMakeCurrent(dpy, win, ctx);
1797 + query_vsync(dpy, win);
1799 + if (printInfo) {
1800 + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
1801 + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
1802 + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
1803 + printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
1804 + printf("VisualID %d, 0x%x\n", (int) visId, (int) visId);
1807 + init();
1809 + /* Set initial projection/viewing transformation.
1810 + * We can't be sure we'll get a ConfigureNotify event when the window
1811 + * first appears.
1812 + */
1813 + reshape(winWidth, winHeight);
1815 + event_loop(dpy, win);
1817 + glDeleteLists(gear1, 1);
1818 + glDeleteLists(gear2, 1);
1819 + glDeleteLists(gear3, 1);
1820 + glXMakeCurrent(dpy, None, NULL);
1821 + glXDestroyContext(dpy, ctx);
1822 + XDestroyWindow(dpy, win);
1823 + XCloseDisplay(dpy);
1825 + return 0;
1827 diff -Naurp mesa-19.0.4-orig/src/glx/xdemos/glxinfo.1 mesa-19.0.4/src/glx/xdemos/glxinfo.1
1828 --- mesa-19.0.4-orig/src/glx/xdemos/glxinfo.1 1969-12-31 18:00:00.000000000 -0600
1829 +++ mesa-19.0.4/src/glx/xdemos/glxinfo.1 2019-05-29 21:31:47.992434946 -0500
1830 @@ -0,0 +1,46 @@
1831 +.TH glxinfo 1 "2006-11-29"
1832 +.SH NAME
1833 +glxinfo \- show information about the GLX implementation
1834 +.SH SYNOPSIS
1835 +.B glxinfo
1836 +.RI [ options ]
1837 +.SH DESCRIPTION
1838 +The \fIglxinfo\fP program shows information about the OpenGL and GLX
1839 +implementations running on a given X display.
1840 +.PP
1841 +The information includes details about the server- and client-side GLX
1842 +implementation, the OpenGL and GLU implementations as well as a list
1843 +of available GLX visuals.
1844 +.SH OPTIONS
1845 +.TP 8
1846 +.B \-v
1847 +Print visuals info in verbose form.
1848 +.TP 8
1849 +.B \-t
1850 +Print verbose table.
1851 +.TP 8
1852 +.B \-display \fIdisplay\fP
1853 +Specify the X display to interrogate.
1854 +.TP 8
1855 +.B \-h
1856 +Print usage information.
1857 +.TP 8
1858 +.B \-i
1859 +Force an indirect rendering context.
1860 +.TP 8
1861 +.B \-b
1862 +Find the "best" visual and print its number.
1863 +.TP 8
1864 +.B \-l
1865 +Print interesting OpenGL limits.
1866 +.TP 8
1867 +.B \-s
1868 +Print a single extension per line.
1869 +.SH AUTHOR
1870 +glxinfo was written by Brian Paul <brian.paul@tungstengraphics.com>.
1871 +.PP
1872 +This manual page was written by Thierry Reding <thierry@gilfi.de>, for the
1873 +Debian project and updated by Fernando de Oliveira <famobr at yahoo dot
1874 +com dot br>, for the Linux From Scratch (LFS) project (but may be used by
1875 +others).
1877 diff -Naurp mesa-19.0.4-orig/src/glx/xdemos/glxinfo.c mesa-19.0.4/src/glx/xdemos/glxinfo.c
1878 --- mesa-19.0.4-orig/src/glx/xdemos/glxinfo.c 1969-12-31 18:00:00.000000000 -0600
1879 +++ mesa-19.0.4/src/glx/xdemos/glxinfo.c 2019-05-29 21:31:47.992434946 -0500
1880 @@ -0,0 +1,1281 @@
1882 + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
1883 + *
1884 + * Permission is hereby granted, free of charge, to any person obtaining a
1885 + * copy of this software and associated documentation files (the "Software"),
1886 + * to deal in the Software without restriction, including without limitation
1887 + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1888 + * and/or sell copies of the Software, and to permit persons to whom the
1889 + * Software is furnished to do so, subject to the following conditions:
1890 + *
1891 + * The above copyright notice and this permission notice shall be included
1892 + * in all copies or substantial portions of the Software.
1893 + *
1894 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1895 + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1896 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1897 + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
1898 + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1899 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1900 + */
1904 + * This program is a work-alike of the IRIX glxinfo program.
1905 + * Command line options:
1906 + * -t print wide table
1907 + * -v print verbose information
1908 + * -display DisplayName specify the X display to interogate
1909 + * -B brief, print only the basics
1910 + * -b only print ID of "best" visual on screen 0
1911 + * -i use indirect rendering connection only
1912 + * -l print interesting OpenGL limits (added 5 Sep 2002)
1914 + * Brian Paul 26 January 2000
1915 + */
1917 +#define GLX_GLXEXT_PROTOTYPES
1918 +#define GL_GLEXT_PROTOTYPES
1920 +#include <assert.h>
1921 +#include <X11/Xlib.h>
1922 +#include <X11/Xutil.h>
1923 +#include <GL/gl.h>
1924 +#include <GL/glx.h>
1925 +#include <stdio.h>
1926 +#include <string.h>
1927 +#include <stdlib.h>
1928 +#include "glinfo_common.h"
1931 +#ifndef GLX_NONE_EXT
1932 +#define GLX_NONE_EXT 0x8000
1933 +#endif
1935 +#ifndef GLX_TRANSPARENT_RGB
1936 +#define GLX_TRANSPARENT_RGB 0x8008
1937 +#endif
1939 +#ifndef GLX_RGBA_BIT
1940 +#define GLX_RGBA_BIT 0x00000001
1941 +#endif
1943 +#ifndef GLX_COLOR_INDEX_BIT
1944 +#define GLX_COLOR_INDEX_BIT 0x00000002
1945 +#endif
1948 +struct visual_attribs
1950 + /* X visual attribs */
1951 + int id; /* May be visual ID or FBConfig ID */
1952 + int vis_id; /* Visual ID. Only set for FBConfigs */
1953 + int klass;
1954 + int depth;
1955 + int redMask, greenMask, blueMask;
1956 + int colormapSize;
1957 + int bitsPerRGB;
1959 + /* GL visual attribs */
1960 + int supportsGL;
1961 + int drawableType;
1962 + int transparentType;
1963 + int transparentRedValue;
1964 + int transparentGreenValue;
1965 + int transparentBlueValue;
1966 + int transparentAlphaValue;
1967 + int transparentIndexValue;
1968 + int bufferSize;
1969 + int level;
1970 + int render_type;
1971 + int doubleBuffer;
1972 + int stereo;
1973 + int auxBuffers;
1974 + int redSize, greenSize, blueSize, alphaSize;
1975 + int depthSize;
1976 + int stencilSize;
1977 + int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize;
1978 + int numSamples, numMultisample;
1979 + int visualCaveat;
1980 + int floatComponents;
1981 + int packedfloatComponents;
1982 + int srgb;
1986 +/**
1987 + * Version of the context that was created
1989 + * 20, 21, 30, 31, 32, etc.
1990 + */
1991 +static int version;
1993 +/**
1994 + * GL Error checking/warning.
1995 + */
1996 +static void
1997 +CheckError(int line)
1999 + int n;
2000 + n = glGetError();
2001 + if (n)
2002 + printf("Warning: GL error 0x%x at line %d\n", n, line);
2006 +static void
2007 +print_display_info(Display *dpy)
2009 + printf("name of display: %s\n", DisplayString(dpy));
2013 +/**
2014 + * Choose a simple FB Config.
2015 + */
2016 +static GLXFBConfig *
2017 +choose_fb_config(Display *dpy, int scrnum)
2019 + int fbAttribSingle[] = {
2020 + GLX_RENDER_TYPE, GLX_RGBA_BIT,
2021 + GLX_RED_SIZE, 1,
2022 + GLX_GREEN_SIZE, 1,
2023 + GLX_BLUE_SIZE, 1,
2024 + GLX_DOUBLEBUFFER, False,
2025 + None };
2026 + int fbAttribDouble[] = {
2027 + GLX_RENDER_TYPE, GLX_RGBA_BIT,
2028 + GLX_RED_SIZE, 1,
2029 + GLX_GREEN_SIZE, 1,
2030 + GLX_BLUE_SIZE, 1,
2031 + GLX_DOUBLEBUFFER, True,
2032 + None };
2033 + GLXFBConfig *configs;
2034 + int nConfigs;
2036 + configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs);
2037 + if (!configs)
2038 + configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs);
2040 + return configs;
2044 +static Bool CreateContextErrorFlag;
2046 +static int
2047 +create_context_error_handler(Display *dpy, XErrorEvent *error)
2049 + (void) dpy;
2050 + (void) error->error_code;
2051 + CreateContextErrorFlag = True;
2052 + return 0;
2056 +/**
2057 + * Try to create a GLX context of the given version with flags/options.
2058 + * Note: A version number is required in order to get a core profile
2059 + * (at least w/ NVIDIA).
2060 + */
2061 +static GLXContext
2062 +create_context_flags(Display *dpy, GLXFBConfig fbconfig, int major, int minor,
2063 + int contextFlags, int profileMask, Bool direct)
2065 +#ifdef GLX_ARB_create_context
2066 + static PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB_func = 0;
2067 + static Bool firstCall = True;
2068 + int (*old_handler)(Display *, XErrorEvent *);
2069 + GLXContext context;
2070 + int attribs[20];
2071 + int n = 0;
2073 + if (firstCall) {
2074 + /* See if we have GLX_ARB_create_context_profile and get pointer to
2075 + * glXCreateContextAttribsARB() function.
2076 + */
2077 + const char *glxExt = glXQueryExtensionsString(dpy, 0);
2078 + if (extension_supported("GLX_ARB_create_context_profile", glxExt)) {
2079 + glXCreateContextAttribsARB_func = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
2080 + glXGetProcAddress((const GLubyte *) "glXCreateContextAttribsARB");
2082 + firstCall = False;
2085 + if (!glXCreateContextAttribsARB_func)
2086 + return 0;
2088 + /* setup attribute array */
2089 + if (major) {
2090 + attribs[n++] = GLX_CONTEXT_MAJOR_VERSION_ARB;
2091 + attribs[n++] = major;
2092 + attribs[n++] = GLX_CONTEXT_MINOR_VERSION_ARB;
2093 + attribs[n++] = minor;
2095 + if (contextFlags) {
2096 + attribs[n++] = GLX_CONTEXT_FLAGS_ARB;
2097 + attribs[n++] = contextFlags;
2099 +#ifdef GLX_ARB_create_context_profile
2100 + if (profileMask) {
2101 + attribs[n++] = GLX_CONTEXT_PROFILE_MASK_ARB;
2102 + attribs[n++] = profileMask;
2104 +#endif
2105 + attribs[n++] = 0;
2107 + /* install X error handler */
2108 + old_handler = XSetErrorHandler(create_context_error_handler);
2109 + CreateContextErrorFlag = False;
2111 + /* try creating context */
2112 + context = glXCreateContextAttribsARB_func(dpy,
2113 + fbconfig,
2114 + 0, /* share_context */
2115 + direct,
2116 + attribs);
2118 + /* restore error handler */
2119 + XSetErrorHandler(old_handler);
2121 + if (CreateContextErrorFlag)
2122 + context = 0;
2124 + if (context && direct) {
2125 + if (!glXIsDirect(dpy, context)) {
2126 + glXDestroyContext(dpy, context);
2127 + return 0;
2131 + return context;
2132 +#else
2133 + return 0;
2134 +#endif
2138 +/**
2139 + * Try to create a GLX context of the newest version.
2140 + */
2141 +static GLXContext
2142 +create_context_with_config(Display *dpy, GLXFBConfig config,
2143 + Bool coreProfile, Bool es2Profile, Bool direct)
2145 + GLXContext ctx = 0;
2147 + if (coreProfile) {
2148 + /* Try to create a core profile, starting with the newest version of
2149 + * GL that we're aware of. If we don't specify the version
2150 + */
2151 + int i;
2152 + for (i = 0; gl_versions[i].major > 0; i++) {
2153 + /* don't bother below GL 3.0 */
2154 + if (gl_versions[i].major == 3 &&
2155 + gl_versions[i].minor == 0)
2156 + return 0;
2157 + ctx = create_context_flags(dpy, config,
2158 + gl_versions[i].major,
2159 + gl_versions[i].minor,
2160 + 0x0,
2161 + GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
2162 + direct);
2163 + if (ctx)
2164 + return ctx;
2166 + /* couldn't get core profile context */
2167 + return 0;
2170 + if (es2Profile) {
2171 +#ifdef GLX_CONTEXT_ES2_PROFILE_BIT_EXT
2172 + if (extension_supported("GLX_EXT_create_context_es2_profile",
2173 + glXQueryExtensionsString(dpy, 0))) {
2174 + ctx = create_context_flags(dpy, config, 2, 0, 0x0,
2175 + GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
2176 + direct);
2177 + return ctx;
2179 +#endif
2180 + return 0;
2183 + /* GLX should return a context of the latest GL version that supports
2184 + * the full profile.
2185 + */
2186 + ctx = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, direct);
2188 + /* make sure the context is direct, if direct was requested */
2189 + if (ctx && direct) {
2190 + if (!glXIsDirect(dpy, ctx)) {
2191 + glXDestroyContext(dpy, ctx);
2192 + return 0;
2196 + return ctx;
2200 +static XVisualInfo *
2201 +choose_xvisinfo(Display *dpy, int scrnum)
2203 + int attribSingle[] = {
2204 + GLX_RGBA,
2205 + GLX_RED_SIZE, 1,
2206 + GLX_GREEN_SIZE, 1,
2207 + GLX_BLUE_SIZE, 1,
2208 + None };
2209 + int attribDouble[] = {
2210 + GLX_RGBA,
2211 + GLX_RED_SIZE, 1,
2212 + GLX_GREEN_SIZE, 1,
2213 + GLX_BLUE_SIZE, 1,
2214 + GLX_DOUBLEBUFFER,
2215 + None };
2216 + XVisualInfo *visinfo;
2218 + visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
2219 + if (!visinfo)
2220 + visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
2222 + return visinfo;
2226 +static void
2227 +query_renderer(void)
2229 +#ifdef GLX_MESA_query_renderer
2230 + PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger;
2231 + PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC queryString;
2232 + unsigned int v[3];
2234 + queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
2235 + glXGetProcAddressARB((const GLubyte *)
2236 + "glXQueryCurrentRendererIntegerMESA");
2237 + queryString = (PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC)
2238 + glXGetProcAddressARB((const GLubyte *)
2239 + "glXQueryCurrentRendererStringMESA");
2241 + printf("Extended renderer info (GLX_MESA_query_renderer):\n");
2242 + queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
2243 + printf(" Vendor: %s (0x%x)\n",
2244 + queryString(GLX_RENDERER_VENDOR_ID_MESA), *v);
2245 + queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
2246 + printf(" Device: %s (0x%x)\n",
2247 + queryString(GLX_RENDERER_DEVICE_ID_MESA), *v);
2248 + queryInteger(GLX_RENDERER_VERSION_MESA, v);
2249 + printf(" Version: %d.%d.%d\n", v[0], v[1], v[2]);
2250 + queryInteger(GLX_RENDERER_ACCELERATED_MESA, v);
2251 + printf(" Accelerated: %s\n", *v ? "yes" : "no");
2252 + queryInteger(GLX_RENDERER_VIDEO_MEMORY_MESA, v);
2253 + printf(" Video memory: %dMB\n", *v);
2254 + queryInteger(GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA, v);
2255 + printf(" Unified memory: %s\n", *v ? "yes" : "no");
2256 + queryInteger(GLX_RENDERER_PREFERRED_PROFILE_MESA, v);
2257 + printf(" Preferred profile: %s (0x%x)\n",
2258 + *v == GLX_CONTEXT_CORE_PROFILE_BIT_ARB ? "core" :
2259 + *v == GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB ? "compat" :
2260 + "unknown", *v);
2261 + queryInteger(GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA, v);
2262 + printf(" Max core profile version: %d.%d\n", v[0], v[1]);
2263 + queryInteger(GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA, v);
2264 + printf(" Max compat profile version: %d.%d\n", v[0], v[1]);
2265 + queryInteger(GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA, v);
2266 + printf(" Max GLES1 profile version: %d.%d\n", v[0], v[1]);
2267 + queryInteger(GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA, v);
2268 + printf(" Max GLES[23] profile version: %d.%d\n", v[0], v[1]);
2269 +#endif
2273 +static Bool
2274 +print_screen_info(Display *dpy, int scrnum,
2275 + const struct options *opts,
2276 + Bool coreProfile, Bool es2Profile, Bool limits,
2277 + Bool coreWorked)
2279 + Window win;
2280 + XSetWindowAttributes attr;
2281 + unsigned long mask;
2282 + Window root;
2283 + GLXContext ctx = NULL;
2284 + XVisualInfo *visinfo;
2285 + int width = 100, height = 100;
2286 + GLXFBConfig *fbconfigs;
2287 + const char *oglstring = coreProfile ? "OpenGL core profile" :
2288 + es2Profile ? "OpenGL ES profile" : "OpenGL";
2290 + root = RootWindow(dpy, scrnum);
2292 + /*
2293 + * Choose FBConfig or XVisualInfo and create a context.
2294 + */
2295 + fbconfigs = choose_fb_config(dpy, scrnum);
2296 + if (fbconfigs) {
2297 + ctx = create_context_with_config(dpy, fbconfigs[0],
2298 + coreProfile, es2Profile,
2299 + opts->allowDirect);
2300 + if (!ctx && opts->allowDirect && !coreProfile) {
2301 + /* try indirect */
2302 + ctx = create_context_with_config(dpy, fbconfigs[0],
2303 + coreProfile, es2Profile, False);
2306 + visinfo = glXGetVisualFromFBConfig(dpy, fbconfigs[0]);
2307 + XFree(fbconfigs);
2309 + else if (!coreProfile && !es2Profile) {
2310 + visinfo = choose_xvisinfo(dpy, scrnum);
2311 + if (visinfo)
2312 + ctx = glXCreateContext(dpy, visinfo, NULL, opts->allowDirect);
2313 + } else
2314 + visinfo = NULL;
2316 + if (!visinfo && !coreProfile && !es2Profile) {
2317 + fprintf(stderr, "Error: couldn't find RGB GLX visual or fbconfig\n");
2318 + return False;
2321 + if (!ctx) {
2322 + if (!coreProfile && !es2Profile)
2323 + fprintf(stderr, "Error: glXCreateContext failed\n");
2324 + XFree(visinfo);
2325 + return False;
2328 + /*
2329 + * Create a window so that we can just bind the context.
2330 + */
2331 + attr.background_pixel = 0;
2332 + attr.border_pixel = 0;
2333 + attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
2334 + attr.event_mask = StructureNotifyMask | ExposureMask;
2335 + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
2336 + win = XCreateWindow(dpy, root, 0, 0, width, height,
2337 + 0, visinfo->depth, InputOutput,
2338 + visinfo->visual, mask, &attr);
2340 + if (glXMakeCurrent(dpy, win, ctx)) {
2341 + const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR);
2342 + const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION);
2343 + const char *serverExtensions = glXQueryServerString(dpy, scrnum, GLX_EXTENSIONS);
2344 + const char *clientVendor = glXGetClientString(dpy, GLX_VENDOR);
2345 + const char *clientVersion = glXGetClientString(dpy, GLX_VERSION);
2346 + const char *clientExtensions = glXGetClientString(dpy, GLX_EXTENSIONS);
2347 + const char *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
2348 + const char *glVendor = (const char *) glGetString(GL_VENDOR);
2349 + const char *glRenderer = (const char *) glGetString(GL_RENDERER);
2350 + const char *glVersion = (const char *) glGetString(GL_VERSION);
2351 + char *glExtensions = NULL;
2352 + int glxVersionMajor = 0;
2353 + int glxVersionMinor = 0;
2354 + char *displayName = NULL;
2355 + char *colon = NULL, *period = NULL;
2356 + struct ext_functions extfuncs;
2358 + CheckError(__LINE__);
2360 + /* Get some ext functions */
2361 + extfuncs.GetProgramivARB = (GETPROGRAMIVARBPROC)
2362 + glXGetProcAddressARB((GLubyte *) "glGetProgramivARB");
2363 + extfuncs.GetStringi = (GETSTRINGIPROC)
2364 + glXGetProcAddressARB((GLubyte *) "glGetStringi");
2365 + extfuncs.GetConvolutionParameteriv = (GETCONVOLUTIONPARAMETERIVPROC)
2366 + glXGetProcAddressARB((GLubyte *) "glGetConvolutionParameteriv");
2368 + if (!glXQueryVersion(dpy, & glxVersionMajor, & glxVersionMinor)) {
2369 + fprintf(stderr, "Error: glXQueryVersion failed\n");
2370 + exit(1);
2373 + /* Get list of GL extensions */
2374 + if (coreProfile && extfuncs.GetStringi)
2375 + glExtensions = build_core_profile_extension_list(&extfuncs);
2376 + if (!glExtensions) {
2377 + coreProfile = False;
2378 + glExtensions = (char *) glGetString(GL_EXTENSIONS);
2381 + CheckError(__LINE__);
2383 + if (!coreWorked) {
2384 + /* Strip the screen number from the display name, if present. */
2385 + if (!(displayName = (char *) malloc(strlen(DisplayString(dpy)) + 1))) {
2386 + fprintf(stderr, "Error: malloc() failed\n");
2387 + exit(1);
2389 + strcpy(displayName, DisplayString(dpy));
2390 + colon = strrchr(displayName, ':');
2391 + if (colon) {
2392 + period = strchr(colon, '.');
2393 + if (period)
2394 + *period = '\0';
2397 + printf("display: %s screen: %d\n", displayName, scrnum);
2398 + free(displayName);
2399 + printf("direct rendering: ");
2400 + if (glXIsDirect(dpy, ctx)) {
2401 + printf("Yes\n");
2403 + else {
2404 + if (!opts->allowDirect) {
2405 + printf("No (-i specified)\n");
2407 + else if (getenv("LIBGL_ALWAYS_INDIRECT")) {
2408 + printf("No (LIBGL_ALWAYS_INDIRECT set)\n");
2410 + else {
2411 + printf("No (If you want to find out why, try setting "
2412 + "LIBGL_DEBUG=verbose)\n");
2415 + if (opts->mode != Brief) {
2416 + printf("server glx vendor string: %s\n", serverVendor);
2417 + printf("server glx version string: %s\n", serverVersion);
2418 + printf("server glx extensions:\n");
2419 + print_extension_list(serverExtensions, opts->singleLine);
2420 + printf("client glx vendor string: %s\n", clientVendor);
2421 + printf("client glx version string: %s\n", clientVersion);
2422 + printf("client glx extensions:\n");
2423 + print_extension_list(clientExtensions, opts->singleLine);
2424 + printf("GLX version: %u.%u\n", glxVersionMajor, glxVersionMinor);
2425 + printf("GLX extensions:\n");
2426 + print_extension_list(glxExtensions, opts->singleLine);
2428 + if (strstr(glxExtensions, "GLX_MESA_query_renderer"))
2429 + query_renderer();
2430 + printf("OpenGL vendor string: %s\n", glVendor);
2431 + printf("OpenGL renderer string: %s\n", glRenderer);
2432 + } else
2433 + printf("\n");
2435 + printf("%s version string: %s\n", oglstring, glVersion);
2437 + version = (glVersion[0] - '0') * 10 + (glVersion[2] - '0');
2439 + CheckError(__LINE__);
2441 +#ifdef GL_VERSION_2_0
2442 + if (version >= 20) {
2443 + char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
2444 + printf("%s shading language version string: %s\n", oglstring, v);
2446 +#endif
2447 + CheckError(__LINE__);
2448 +#ifdef GL_VERSION_3_0
2449 + if (version >= 30 && !es2Profile) {
2450 + GLint flags;
2451 + glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
2452 + printf("%s context flags: %s\n", oglstring, context_flags_string(flags));
2454 +#endif
2455 + CheckError(__LINE__);
2456 +#ifdef GL_VERSION_3_2
2457 + if (version >= 32 && !es2Profile) {
2458 + GLint mask;
2459 + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
2460 + printf("%s profile mask: %s\n", oglstring, profile_mask_string(mask));
2462 +#endif
2464 + CheckError(__LINE__);
2466 + if (opts->mode != Brief) {
2467 + printf("%s extensions:\n", oglstring);
2468 + print_extension_list(glExtensions, opts->singleLine);
2471 + if (limits) {
2472 + print_limits(glExtensions, oglstring, version, &extfuncs);
2475 + if (coreProfile)
2476 + free(glExtensions);
2478 + else {
2479 + fprintf(stderr, "Error: glXMakeCurrent failed\n");
2482 + glXDestroyContext(dpy, ctx);
2483 + XFree(visinfo);
2484 + XDestroyWindow(dpy, win);
2485 + XSync(dpy, 1);
2486 + return True;
2490 +static const char *
2491 +visual_class_name(int cls)
2493 + switch (cls) {
2494 + case StaticColor:
2495 + return "StaticColor";
2496 + case PseudoColor:
2497 + return "PseudoColor";
2498 + case StaticGray:
2499 + return "StaticGray";
2500 + case GrayScale:
2501 + return "GrayScale";
2502 + case TrueColor:
2503 + return "TrueColor";
2504 + case DirectColor:
2505 + return "DirectColor";
2506 + default:
2507 + return "";
2511 +static const char *
2512 +visual_drawable_type(int type)
2514 + const static struct bit_info bits[] = {
2515 + { GLX_WINDOW_BIT, "window" },
2516 + { GLX_PIXMAP_BIT, "pixmap" },
2517 + { GLX_PBUFFER_BIT, "pbuffer" }
2518 + };
2520 + return bitmask_to_string(bits, ELEMENTS(bits), type);
2523 +static const char *
2524 +visual_class_abbrev(int cls)
2526 + switch (cls) {
2527 + case StaticColor:
2528 + return "sc";
2529 + case PseudoColor:
2530 + return "pc";
2531 + case StaticGray:
2532 + return "sg";
2533 + case GrayScale:
2534 + return "gs";
2535 + case TrueColor:
2536 + return "tc";
2537 + case DirectColor:
2538 + return "dc";
2539 + default:
2540 + return "";
2544 +static const char *
2545 +visual_render_type_name(int type)
2547 + switch (type) {
2548 + case GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT:
2549 + return "ufloat";
2550 + case GLX_RGBA_FLOAT_BIT_ARB:
2551 + return "float";
2552 + case GLX_RGBA_BIT:
2553 + return "rgba";
2554 + case GLX_COLOR_INDEX_BIT:
2555 + return "ci";
2556 + case GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT:
2557 + return "rgba|ci";
2558 + default:
2559 + return "";
2563 +static const char *
2564 +caveat_string(int caveat)
2566 + switch (caveat) {
2567 +#ifdef GLX_EXT_visual_rating
2568 + case GLX_SLOW_VISUAL_EXT:
2569 + return "Slow";
2570 + case GLX_NON_CONFORMANT_VISUAL_EXT:
2571 + return "Ncon";
2572 + case GLX_NONE_EXT:
2573 + /* fall-through */
2574 +#endif
2575 + case 0:
2576 + /* fall-through */
2577 + default:
2578 + return "None";
2583 +static Bool
2584 +get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
2585 + struct visual_attribs *attribs)
2587 + const char *ext = glXQueryExtensionsString(dpy, vInfo->screen);
2588 + int rgba;
2590 + memset(attribs, 0, sizeof(struct visual_attribs));
2592 + attribs->id = vInfo->visualid;
2593 +#if defined(__cplusplus) || defined(c_plusplus)
2594 + attribs->klass = vInfo->c_class;
2595 +#else
2596 + attribs->klass = vInfo->class;
2597 +#endif
2598 + attribs->depth = vInfo->depth;
2599 + attribs->redMask = vInfo->red_mask;
2600 + attribs->greenMask = vInfo->green_mask;
2601 + attribs->blueMask = vInfo->blue_mask;
2602 + attribs->colormapSize = vInfo->colormap_size;
2603 + attribs->bitsPerRGB = vInfo->bits_per_rgb;
2605 + if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0 ||
2606 + !attribs->supportsGL)
2607 + return False;
2608 + glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize);
2609 + glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level);
2610 + glXGetConfig(dpy, vInfo, GLX_RGBA, &rgba);
2611 + if (rgba)
2612 + attribs->render_type = GLX_RGBA_BIT;
2613 + else
2614 + attribs->render_type = GLX_COLOR_INDEX_BIT;
2616 + glXGetConfig(dpy, vInfo, GLX_DRAWABLE_TYPE, &attribs->drawableType);
2617 + glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
2618 + glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo);
2619 + glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers);
2620 + glXGetConfig(dpy, vInfo, GLX_RED_SIZE, &attribs->redSize);
2621 + glXGetConfig(dpy, vInfo, GLX_GREEN_SIZE, &attribs->greenSize);
2622 + glXGetConfig(dpy, vInfo, GLX_BLUE_SIZE, &attribs->blueSize);
2623 + glXGetConfig(dpy, vInfo, GLX_ALPHA_SIZE, &attribs->alphaSize);
2624 + glXGetConfig(dpy, vInfo, GLX_DEPTH_SIZE, &attribs->depthSize);
2625 + glXGetConfig(dpy, vInfo, GLX_STENCIL_SIZE, &attribs->stencilSize);
2626 + glXGetConfig(dpy, vInfo, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
2627 + glXGetConfig(dpy, vInfo, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
2628 + glXGetConfig(dpy, vInfo, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
2629 + glXGetConfig(dpy, vInfo, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
2631 + /* get transparent pixel stuff */
2632 + glXGetConfig(dpy, vInfo,GLX_TRANSPARENT_TYPE, &attribs->transparentType);
2633 + if (attribs->transparentType == GLX_TRANSPARENT_RGB) {
2634 + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue);
2635 + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue);
2636 + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue);
2637 + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue);
2639 + else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) {
2640 + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue);
2643 + /* multisample attribs */
2644 +#ifdef GLX_ARB_multisample
2645 + if (ext && strstr(ext, "GLX_ARB_multisample")) {
2646 + glXGetConfig(dpy, vInfo, GLX_SAMPLE_BUFFERS_ARB, &attribs->numMultisample);
2647 + glXGetConfig(dpy, vInfo, GLX_SAMPLES_ARB, &attribs->numSamples);
2649 +#endif
2650 + else {
2651 + attribs->numSamples = 0;
2652 + attribs->numMultisample = 0;
2655 +#if defined(GLX_EXT_visual_rating)
2656 + if (ext && strstr(ext, "GLX_EXT_visual_rating")) {
2657 + glXGetConfig(dpy, vInfo, GLX_VISUAL_CAVEAT_EXT, &attribs->visualCaveat);
2659 + else {
2660 + attribs->visualCaveat = GLX_NONE_EXT;
2662 +#else
2663 + attribs->visualCaveat = 0;
2664 +#endif
2666 +#if defined(GLX_EXT_framebuffer_sRGB)
2667 + if (ext && strstr(ext, "GLX_EXT_framebuffer_sRGB")) {
2668 + glXGetConfig(dpy, vInfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, &attribs->srgb);
2670 +#endif
2672 + return True;
2675 +#ifdef GLX_VERSION_1_3
2677 +static int
2678 +glx_token_to_visual_class(int visual_type)
2680 + switch (visual_type) {
2681 + case GLX_TRUE_COLOR:
2682 + return TrueColor;
2683 + case GLX_DIRECT_COLOR:
2684 + return DirectColor;
2685 + case GLX_PSEUDO_COLOR:
2686 + return PseudoColor;
2687 + case GLX_STATIC_COLOR:
2688 + return StaticColor;
2689 + case GLX_GRAY_SCALE:
2690 + return GrayScale;
2691 + case GLX_STATIC_GRAY:
2692 + return StaticGray;
2693 + case GLX_NONE:
2694 + default:
2695 + return None;
2699 +static Bool
2700 +get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig,
2701 + struct visual_attribs *attribs)
2703 + const char *ext = glXQueryExtensionsString(dpy, 0);
2704 + int visual_type;
2705 + XVisualInfo *vInfo;
2707 + memset(attribs, 0, sizeof(struct visual_attribs));
2709 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &attribs->id);
2711 + vInfo = glXGetVisualFromFBConfig(dpy, fbconfig);
2713 + if (vInfo != NULL) {
2714 + attribs->vis_id = vInfo->visualid;
2715 + attribs->depth = vInfo->depth;
2716 + attribs->redMask = vInfo->red_mask;
2717 + attribs->greenMask = vInfo->green_mask;
2718 + attribs->blueMask = vInfo->blue_mask;
2719 + attribs->colormapSize = vInfo->colormap_size;
2720 + attribs->bitsPerRGB = vInfo->bits_per_rgb;
2723 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type);
2724 + attribs->klass = glx_token_to_visual_class(visual_type);
2726 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_DRAWABLE_TYPE, &attribs->drawableType);
2727 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize);
2728 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level);
2729 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type);
2730 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
2731 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo);
2732 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers);
2734 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_RED_SIZE, &attribs->redSize);
2735 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_GREEN_SIZE, &attribs->greenSize);
2736 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_BLUE_SIZE, &attribs->blueSize);
2737 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ALPHA_SIZE, &attribs->alphaSize);
2738 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_DEPTH_SIZE, &attribs->depthSize);
2739 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_STENCIL_SIZE, &attribs->stencilSize);
2741 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
2742 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
2743 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
2744 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
2746 + /* get transparent pixel stuff */
2747 + glXGetFBConfigAttrib(dpy, fbconfig,GLX_TRANSPARENT_TYPE, &attribs->transparentType);
2748 + if (attribs->transparentType == GLX_TRANSPARENT_RGB) {
2749 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue);
2750 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue);
2751 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue);
2752 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue);
2754 + else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) {
2755 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue);
2758 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLE_BUFFERS, &attribs->numMultisample);
2759 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples);
2760 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat);
2762 +#if defined(GLX_NV_float_buffer)
2763 + if (ext && strstr(ext, "GLX_NV_float_buffer")) {
2764 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_FLOAT_COMPONENTS_NV, &attribs->floatComponents);
2766 +#endif
2767 +#if defined(GLX_ARB_fbconfig_float)
2768 + if (ext && strstr(ext, "GLX_ARB_fbconfig_float")) {
2769 + if (attribs->render_type & GLX_RGBA_FLOAT_BIT_ARB) {
2770 + attribs->floatComponents = True;
2773 +#endif
2774 +#if defined(GLX_EXT_fbconfig_packed_float)
2775 + if (ext && strstr(ext, "GLX_EXT_fbconfig_packed_float")) {
2776 + if (attribs->render_type & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) {
2777 + attribs->packedfloatComponents = True;
2780 +#endif
2782 +#if defined(GLX_EXT_framebuffer_sRGB)
2783 + if (ext && strstr(ext, "GLX_EXT_framebuffer_sRGB")) {
2784 + glXGetFBConfigAttrib(dpy, fbconfig, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, &attribs->srgb);
2786 +#endif
2787 + return True;
2790 +#endif
2794 +static void
2795 +print_visual_attribs_verbose(const struct visual_attribs *attribs,
2796 + int fbconfigs)
2798 + if (fbconfigs) {
2799 + printf("FBConfig ID: %x Visual ID=%x depth=%d class=%s, type=%s\n",
2800 + attribs->id, attribs->vis_id, attribs->depth,
2801 + visual_class_name(attribs->klass),
2802 + visual_drawable_type(attribs->drawableType));
2804 + else {
2805 + printf("Visual ID: %x depth=%d class=%s, type=%s\n",
2806 + attribs->id, attribs->depth, visual_class_name(attribs->klass),
2807 + visual_drawable_type(attribs->drawableType));
2809 + printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
2810 + attribs->bufferSize, attribs->level,
2811 + visual_render_type_name(attribs->render_type),
2812 + attribs->doubleBuffer, attribs->stereo);
2813 + printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d float=%c sRGB=%c\n",
2814 + attribs->redSize, attribs->greenSize,
2815 + attribs->blueSize, attribs->alphaSize,
2816 + attribs->packedfloatComponents ? 'P' : attribs->floatComponents ? 'Y' : 'N',
2817 + attribs->srgb ? 'Y' : 'N');
2818 + printf(" auxBuffers=%d depthSize=%d stencilSize=%d\n",
2819 + attribs->auxBuffers, attribs->depthSize, attribs->stencilSize);
2820 + printf(" accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
2821 + attribs->accumRedSize, attribs->accumGreenSize,
2822 + attribs->accumBlueSize, attribs->accumAlphaSize);
2823 + printf(" multiSample=%d multiSampleBuffers=%d\n",
2824 + attribs->numSamples, attribs->numMultisample);
2825 +#ifdef GLX_EXT_visual_rating
2826 + if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0)
2827 + printf(" visualCaveat=None\n");
2828 + else if (attribs->visualCaveat == GLX_SLOW_VISUAL_EXT)
2829 + printf(" visualCaveat=Slow\n");
2830 + else if (attribs->visualCaveat == GLX_NON_CONFORMANT_VISUAL_EXT)
2831 + printf(" visualCaveat=Nonconformant\n");
2832 +#endif
2833 + if (attribs->transparentType == GLX_NONE) {
2834 + printf(" Opaque.\n");
2836 + else if (attribs->transparentType == GLX_TRANSPARENT_RGB) {
2837 + printf(" Transparent RGB: Red=%d Green=%d Blue=%d Alpha=%d\n",attribs->transparentRedValue,attribs->transparentGreenValue,attribs->transparentBlueValue,attribs->transparentAlphaValue);
2839 + else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) {
2840 + printf(" Transparent index=%d\n",attribs->transparentIndexValue);
2845 +static void
2846 +print_visual_attribs_short_header(void)
2848 + printf(" visual x bf lv rg d st colorbuffer sr ax dp st accumbuffer ms cav\n");
2849 + printf(" id dep cl sp sz l ci b ro r g b a F gb bf th cl r g b a ns b eat\n");
2850 + printf("----------------------------------------------------------------------------\n");
2854 +static void
2855 +print_visual_attribs_short(const struct visual_attribs *attribs)
2857 + const char *caveat = caveat_string(attribs->visualCaveat);
2859 + printf("0x%03x %2d %2s %2d %3d %2d %c%c %c %c %2d %2d %2d %2d %c %c %2d %2d %2d",
2860 + attribs->id,
2861 + attribs->depth,
2862 + visual_class_abbrev(attribs->klass),
2863 + attribs->transparentType != GLX_NONE,
2864 + attribs->bufferSize,
2865 + attribs->level,
2866 + (attribs->render_type & GLX_RGBA_BIT) ? 'r' : ' ',
2867 + (attribs->render_type & GLX_COLOR_INDEX_BIT) ? 'c' : ' ',
2868 + attribs->doubleBuffer ? 'y' : '.',
2869 + attribs->stereo ? 'y' : '.',
2870 + attribs->redSize, attribs->greenSize,
2871 + attribs->blueSize, attribs->alphaSize,
2872 + attribs->packedfloatComponents ? 'u' : attribs->floatComponents ? 'f' : '.',
2873 + attribs->srgb ? 's' : '.',
2874 + attribs->auxBuffers,
2875 + attribs->depthSize,
2876 + attribs->stencilSize
2877 + );
2879 + printf(" %2d %2d %2d %2d %2d %1d %s\n",
2880 + attribs->accumRedSize, attribs->accumGreenSize,
2881 + attribs->accumBlueSize, attribs->accumAlphaSize,
2882 + attribs->numSamples, attribs->numMultisample,
2883 + caveat
2884 + );
2888 +static void
2889 +print_visual_attribs_long_header(void)
2891 + printf("Vis Vis Visual Trans buff lev render DB ste r g b a s aux dep ste accum buffer MS MS \n");
2892 + printf(" ID Depth Type parent size el type reo sz sz sz sz flt rgb buf th ncl r g b a num bufs caveats\n");
2893 + printf("--------------------------------------------------------------------------------------------------------------------\n");
2897 +static void
2898 +print_visual_attribs_long(const struct visual_attribs *attribs)
2900 + const char *caveat = caveat_string(attribs->visualCaveat);
2902 + printf("0x%3x %2d %-11s %2d %3d %2d %4s %3d %3d %3d %3d %3d %3d",
2903 + attribs->id,
2904 + attribs->depth,
2905 + visual_class_name(attribs->klass),
2906 + attribs->transparentType != GLX_NONE,
2907 + attribs->bufferSize,
2908 + attribs->level,
2909 + visual_render_type_name(attribs->render_type),
2910 + attribs->doubleBuffer,
2911 + attribs->stereo,
2912 + attribs->redSize, attribs->greenSize,
2913 + attribs->blueSize, attribs->alphaSize
2914 + );
2916 + printf(" %c %c %3d %4d %2d %3d %3d %3d %3d %2d %2d %6s\n",
2917 + attribs->floatComponents ? 'f' : '.',
2918 + attribs->srgb ? 's' : '.',
2919 + attribs->auxBuffers,
2920 + attribs->depthSize,
2921 + attribs->stencilSize,
2922 + attribs->accumRedSize, attribs->accumGreenSize,
2923 + attribs->accumBlueSize, attribs->accumAlphaSize,
2924 + attribs->numSamples, attribs->numMultisample,
2925 + caveat
2926 + );
2930 +static void
2931 +print_visual_info(Display *dpy, int scrnum, InfoMode mode)
2933 + XVisualInfo theTemplate;
2934 + XVisualInfo *visuals;
2935 + int numVisuals, numGlxVisuals;
2936 + long mask;
2937 + int i;
2938 + struct visual_attribs attribs;
2940 + /* get list of all visuals on this screen */
2941 + theTemplate.screen = scrnum;
2942 + mask = VisualScreenMask;
2943 + visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals);
2945 + numGlxVisuals = 0;
2946 + for (i = 0; i < numVisuals; i++) {
2947 + if (get_visual_attribs(dpy, &visuals[i], &attribs))
2948 + numGlxVisuals++;
2951 + if (numGlxVisuals == 0)
2952 + return;
2954 + printf("%d GLX Visuals\n", numGlxVisuals);
2956 + if (mode == Normal)
2957 + print_visual_attribs_short_header();
2958 + else if (mode == Wide)
2959 + print_visual_attribs_long_header();
2961 + for (i = 0; i < numVisuals; i++) {
2962 + if (!get_visual_attribs(dpy, &visuals[i], &attribs))
2963 + continue;
2965 + if (mode == Verbose)
2966 + print_visual_attribs_verbose(&attribs, False);
2967 + else if (mode == Normal)
2968 + print_visual_attribs_short(&attribs);
2969 + else if (mode == Wide)
2970 + print_visual_attribs_long(&attribs);
2972 + printf("\n");
2974 + XFree(visuals);
2977 +#ifdef GLX_VERSION_1_3
2979 +static void
2980 +print_fbconfig_info(Display *dpy, int scrnum, InfoMode mode)
2982 + int numFBConfigs = 0;
2983 + struct visual_attribs attribs;
2984 + GLXFBConfig *fbconfigs;
2985 + int i;
2987 + /* get list of all fbconfigs on this screen */
2988 + fbconfigs = glXGetFBConfigs(dpy, scrnum, &numFBConfigs);
2990 + if (numFBConfigs == 0) {
2991 + XFree(fbconfigs);
2992 + return;
2995 + printf("%d GLXFBConfigs:\n", numFBConfigs);
2996 + if (mode == Normal)
2997 + print_visual_attribs_short_header();
2998 + else if (mode == Wide)
2999 + print_visual_attribs_long_header();
3001 + for (i = 0; i < numFBConfigs; i++) {
3002 + get_fbconfig_attribs(dpy, fbconfigs[i], &attribs);
3004 + if (mode == Verbose)
3005 + print_visual_attribs_verbose(&attribs, True);
3006 + else if (mode == Normal)
3007 + print_visual_attribs_short(&attribs);
3008 + else if (mode == Wide)
3009 + print_visual_attribs_long(&attribs);
3011 + printf("\n");
3013 + XFree(fbconfigs);
3016 +#endif
3019 + * Stand-alone Mesa doesn't really implement the GLX protocol so it
3020 + * doesn't really know the GLX attributes associated with an X visual.
3021 + * The first time a visual is presented to Mesa's pseudo-GLX it
3022 + * attaches ancilliary buffers to it (like depth and stencil).
3023 + * But that usually only works if glXChooseVisual is used.
3024 + * This function calls glXChooseVisual() to sort of "prime the pump"
3025 + * for Mesa's GLX so that the visuals that get reported actually
3026 + * reflect what applications will see.
3027 + * This has no effect when using true GLX.
3028 + */
3029 +static void
3030 +mesa_hack(Display *dpy, int scrnum)
3032 + static int attribs[] = {
3033 + GLX_RGBA,
3034 + GLX_RED_SIZE, 1,
3035 + GLX_GREEN_SIZE, 1,
3036 + GLX_BLUE_SIZE, 1,
3037 + GLX_DEPTH_SIZE, 1,
3038 + GLX_STENCIL_SIZE, 1,
3039 + GLX_ACCUM_RED_SIZE, 1,
3040 + GLX_ACCUM_GREEN_SIZE, 1,
3041 + GLX_ACCUM_BLUE_SIZE, 1,
3042 + GLX_ACCUM_ALPHA_SIZE, 1,
3043 + GLX_DOUBLEBUFFER,
3044 + None
3045 + };
3046 + XVisualInfo *visinfo;
3048 + visinfo = glXChooseVisual(dpy, scrnum, attribs);
3049 + if (visinfo)
3050 + XFree(visinfo);
3055 + * Examine all visuals to find the so-called best one.
3056 + * We prefer deepest RGBA buffer with depth, stencil and accum
3057 + * that has no caveats.
3058 + */
3059 +static int
3060 +find_best_visual(Display *dpy, int scrnum)
3062 + XVisualInfo theTemplate;
3063 + XVisualInfo *visuals;
3064 + int numVisuals;
3065 + long mask;
3066 + int i;
3067 + struct visual_attribs bestVis;
3069 + /* get list of all visuals on this screen */
3070 + theTemplate.screen = scrnum;
3071 + mask = VisualScreenMask;
3072 + visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals);
3074 + /* init bestVis with first visual info */
3075 + get_visual_attribs(dpy, &visuals[0], &bestVis);
3077 + /* try to find a "better" visual */
3078 + for (i = 1; i < numVisuals; i++) {
3079 + struct visual_attribs vis;
3081 + get_visual_attribs(dpy, &visuals[i], &vis);
3083 + /* always skip visuals with caveats */
3084 + if (vis.visualCaveat != GLX_NONE_EXT)
3085 + continue;
3087 + /* see if this vis is better than bestVis */
3088 + if ((!bestVis.supportsGL && vis.supportsGL) ||
3089 + (bestVis.visualCaveat != GLX_NONE_EXT) ||
3090 + (!(bestVis.render_type & GLX_RGBA_BIT) && (vis.render_type & GLX_RGBA_BIT)) ||
3091 + (!bestVis.doubleBuffer && vis.doubleBuffer) ||
3092 + (bestVis.redSize < vis.redSize) ||
3093 + (bestVis.greenSize < vis.greenSize) ||
3094 + (bestVis.blueSize < vis.blueSize) ||
3095 + (bestVis.alphaSize < vis.alphaSize) ||
3096 + (bestVis.depthSize < vis.depthSize) ||
3097 + (bestVis.stencilSize < vis.stencilSize) ||
3098 + (bestVis.accumRedSize < vis.accumRedSize)) {
3099 + /* found a better visual */
3100 + bestVis = vis;
3104 + XFree(visuals);
3106 + return bestVis.id;
3110 +int
3111 +main(int argc, char *argv[])
3113 + Display *dpy;
3114 + int numScreens, scrnum;
3115 + struct options opts;
3116 + Bool coreWorked;
3118 + parse_args(argc, argv, &opts);
3120 + dpy = XOpenDisplay(opts.displayName);
3121 + if (!dpy) {
3122 + fprintf(stderr, "Error: unable to open display %s\n",
3123 + XDisplayName(opts.displayName));
3124 + return -1;
3127 + if (opts.findBest) {
3128 + int b;
3129 + mesa_hack(dpy, 0);
3130 + b = find_best_visual(dpy, 0);
3131 + printf("%d\n", b);
3133 + else {
3134 + numScreens = ScreenCount(dpy);
3135 + print_display_info(dpy);
3136 + for (scrnum = 0; scrnum < numScreens; scrnum++) {
3137 + mesa_hack(dpy, scrnum);
3138 + coreWorked = print_screen_info(dpy, scrnum, &opts,
3139 + True, False, opts.limits, False);
3140 + print_screen_info(dpy, scrnum, &opts, False, False,
3141 + opts.limits, coreWorked);
3142 + print_screen_info(dpy, scrnum, &opts, False, True, False, True);
3144 + printf("\n");
3146 + if (opts.mode != Brief) {
3147 + print_visual_info(dpy, scrnum, opts.mode);
3148 +#ifdef GLX_VERSION_1_3
3149 + print_fbconfig_info(dpy, scrnum, opts.mode);
3150 +#endif
3153 + if (scrnum + 1 < numScreens)
3154 + printf("\n\n");
3158 + XCloseDisplay(dpy);
3160 + return 0;
3162 diff -Naurp mesa-19.0.4-orig/src/glx/xdemos/meson.build mesa-19.0.4/src/glx/xdemos/meson.build
3163 --- mesa-19.0.4-orig/src/glx/xdemos/meson.build 1969-12-31 18:00:00.000000000 -0600
3164 +++ mesa-19.0.4/src/glx/xdemos/meson.build 2019-05-29 21:32:18.261434237 -0500
3165 @@ -0,0 +1,33 @@
3166 +inc_xdemos = include_directories('.')
3168 +glxinfo_files = files(
3169 + 'glxinfo.c',
3170 + 'glinfo_common.c',
3173 +x11_dep = dependency('x11', required: true)
3174 +link_xorg = ['-L' + x11_dep.get_pkgconfig_variable('libdir'), '-lX11']
3176 +executable('glxinfo', glxinfo_files,
3177 + install : true,
3178 + c_args : c_vis_args,
3179 + link_args : [ld_args_bsymbolic, ld_args_gc_sections, '-lm', link_xorg],
3180 + link_with : libgl,
3181 + include_directories : [ inc_src, inc_include, inc_mesa, inc_glx],
3182 + dependencies : [x11_dep]
3185 +executable('glxgears', 'glxgears.c',
3186 + install : true,
3187 + c_args : c_vis_args,
3188 + link_args : [ld_args_bsymbolic, ld_args_gc_sections, '-lm', link_xorg],
3189 + link_with : libgl,
3190 + include_directories : [inc_src, inc_include, inc_mesa, inc_glx],
3191 + dependencies : [x11_dep]
3194 +man_dir = get_option('prefix') + '/share/man/man1'
3195 +install_data(['glxinfo.1', 'glxgears.1'],
3196 + install_dir : man_dir