~ubuntu-branches/ubuntu/oneiric/nux/oneiric

« back to all changes in this revision

Viewing changes to tools/unity_support_test.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-06-22 17:16:16 UTC
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: james.westby@ubuntu.com-20110622171616-49405ntrtnxfcpjj
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
// are based on what's done in Compiz (core/plugins/opengl/src/screen.cpp).
18
18
//
19
19
// $ gcc -std=c99 unity_support_test.c -o unity_support_test `pkg-config
20
 
// > --cflags --libs gl x11 libpci`
 
20
// > --cflags --libs gl x11 libpci xcomposite xdamage`
21
21
 
22
22
#include <pci/pci.h>
23
23
#include <X11/Xlib.h>
24
24
#include <X11/Xutil.h>
 
25
#include <X11/extensions/Xcomposite.h>
 
26
#include <X11/extensions/Xdamage.h>
25
27
#include <GL/gl.h>
26
28
#define GLX_GLXEXT_PROTOTYPES
27
29
#include <GL/glx.h>
79
81
  { 0x10de, 0x01d8 }   // nVidia: GeForce Go 7400
80
82
};
81
83
 
 
84
typedef struct _TestResults {
 
85
  char *vendor, *renderer, *version;
 
86
  int result, major, minor;
 
87
  int indirect;
 
88
  int compiz;
 
89
  unsigned int flags;
 
90
  char         *error;
 
91
} TestResults;
 
92
 
82
93
// Checks whether an extension is supported by the GLX/OpenGL implementation
83
94
// given the extension name and the list of supported extensions.
84
95
static int is_extension_supported (const char* extensions,
100
111
// Gets the OpenGL version number given the string.
101
112
static void get_opengl_version (const char *version, int* major, int* minor) {
102
113
  int tmp = 0, i;
 
114
 
 
115
  if (!version)
 
116
  {
 
117
    *major = 0;
 
118
    *minor = 0;
 
119
    return;
 
120
  }
 
121
 
103
122
  for (i = 0; isdigit (version[i]); i++)
104
123
    tmp = tmp * 10 + (version[i] - 48);
105
124
  if (version[i++] == '.') {
176
195
  }
177
196
}
178
197
 
179
 
int main (int argc, char* argv[]) {
180
 
  int indirect = 0, print = 0, compiz = 0;
181
 
  char* error = NULL;
182
 
  unsigned int flags = 0;
183
 
  char* display_name = NULL;
184
 
  int screen;
185
 
  Window root;
186
 
  XVisualInfo *vinfos;
187
 
  Display* display;
188
 
  GLXContext context;
189
 
  char *vendor, *renderer, *version;
190
 
  int result, major, minor;
191
 
 
192
 
  if (getenv ("UNITY_FORCE_START")) {
193
 
    fprintf (stdout, "Warning: UNITY_FORCE_START enabled, no check for unity or compiz support.\n");
194
 
    return 0;
195
 
  }
196
 
 
197
 
 
198
 
  // Basic command-line parsing.
199
 
  for (int i = 1; i < argc; i++) {
200
 
    if (((strncmp (argv[i], "-d", 2) == 0) ||
201
 
         (strncmp (argv[i], "--display", 9) == 0)) &&
202
 
        (i + 1 < argc)) {
203
 
      display_name = argv[i + 1];
204
 
      i++;
205
 
    } else if ((strncmp (argv[i], "-i", 2) == 0) ||
206
 
               (strncmp (argv[i], "--indirect", 10) == 0)) {
207
 
      indirect = 1;
208
 
    } else if ((strncmp (argv[i], "-p", 2) == 0) ||
209
 
               (strncmp (argv[i], "--print", 7) == 0)) {
210
 
      print = 1;
211
 
    } else if ((strncmp (argv[i], "-c", 2) == 0) ||
212
 
               (strncmp (argv[i], "--compiz", 8) == 0)) {
213
 
      compiz = 1;
214
 
    } else if ((strncmp (argv[i], "-h", 2) == 0) ||
215
 
               (strncmp (argv[i], "--help", 6) == 0)) {
216
 
      print_help ();
217
 
      return 2;
218
 
    } else {
219
 
      fprintf (stderr, "Error: unknown command-line option `%s'\n\n", argv[i]);
220
 
      print_help ();
221
 
      return 2;
222
 
    }
223
 
  }
224
 
 
225
 
  // Open a X11 connection and get the root window.
226
 
  display = XOpenDisplay (display_name);
227
 
  if (display == NULL) {
228
 
    error = "unable to open display";
229
 
    result = 1;
230
 
    goto abort;
231
 
  }
232
 
  screen = DefaultScreen (display);
233
 
  root = XRootWindow (display, screen);
234
 
 
 
198
static int check_root_visual (Display     *display,
 
199
                              unsigned int screen,
 
200
                              Window      root,
 
201
                              GLXContext  *context,
 
202
                              XVisualInfo **vinfos,
 
203
                              TestResults  *results)
 
204
{
235
205
  // Retrieve root window visual.
236
206
  XWindowAttributes attr;
237
207
  XVisualInfo vinfo_template;
238
208
  int nr_vinfos;
239
209
  if (XGetWindowAttributes (display, root, &attr) == 0) {
240
 
    error = "unable to get root window attributes";
241
 
    result = 1;
242
 
    goto abort;
 
210
    results->error = strdup ("unable to get root window attributes");
 
211
    results->result = 1;
 
212
    return 0;
243
213
  }
244
214
  vinfo_template.visualid = XVisualIDFromVisual (attr.visual);
245
 
  vinfos = XGetVisualInfo (display, VisualIDMask, &vinfo_template, &nr_vinfos);
 
215
  *vinfos = XGetVisualInfo (display, VisualIDMask, &vinfo_template, &nr_vinfos);
246
216
  if (nr_vinfos == 0) {
247
 
    error = "unable to get visual informations for default visual";
248
 
    result = 1;
249
 
    goto abort;
250
 
  }
251
 
 
 
217
    results->error = strdup ("unable to get visual informations for default visual");
 
218
    results->result = 1;
 
219
    return 0;
 
220
  }
 
221
 
 
222
  return 1;
 
223
}
 
224
 
 
225
static int check_xcomposite (Display     *display,
 
226
                              unsigned int screen,
 
227
                              Window      root,
 
228
                              GLXContext  *context,
 
229
                              XVisualInfo **vinfos,
 
230
                              TestResults  *results)
 
231
{
 
232
// Check for XComposite
 
233
  int composite_major, composite_minor;
 
234
  unsigned int composite_tmp;
 
235
 
 
236
  if (!XQueryExtension (display, COMPOSITE_NAME, &composite_tmp, &composite_tmp, &composite_tmp))
 
237
  {
 
238
    results->error = strdup ("no composite extension");
 
239
    results->result = 1;
 
240
    return 0;
 
241
  }
 
242
 
 
243
  XCompositeQueryVersion (display, &composite_major, &composite_minor);
 
244
 
 
245
  if (composite_major == 0 && composite_minor < 2)
 
246
  {
 
247
    results->error = strdup ("old composite extension");
 
248
    results->result = 1;
 
249
    return 0;
 
250
  }
 
251
 
 
252
  return 1;
 
253
}
 
254
 
 
255
static int check_damage_extension (Display     *display,
 
256
                                    unsigned int screen,
 
257
                                    Window      root,
 
258
                                    GLXContext  *context,
 
259
                                    XVisualInfo **vinfos,
 
260
                                    TestResults  *results)
 
261
{
 
262
  int damage_tmp;
 
263
 
 
264
  if (!XDamageQueryExtension (display, &damage_tmp, &damage_tmp))
 
265
  {
 
266
    results->error = strdup ("no damage extension");
 
267
    results->result = 1;
 
268
    return 0;
 
269
  }
 
270
 
 
271
  return 1;
 
272
}
 
273
 
 
274
static int check_fixes_extension (Display     *display,
 
275
                                   unsigned int screen,
 
276
                                   Window      root,
 
277
                                   GLXContext  *context,
 
278
                                   XVisualInfo **vinfos,
 
279
                                   TestResults  *results)
 
280
{
 
281
  int fixes_tmp;
 
282
 
 
283
  if (!XFixesQueryExtension (display, &fixes_tmp, &fixes_tmp))
 
284
  {
 
285
    results->error = strdup ("no fixes extension");
 
286
    results->result = 1;
 
287
    return 0;
 
288
  }
 
289
 
 
290
  return 1;
 
291
}
 
292
 
 
293
static int check_glx_config (Display     *display,
 
294
                              unsigned int screen,
 
295
                              Window      root,
 
296
                              GLXContext  *context,
 
297
                              XVisualInfo **vinfos,
 
298
                              TestResults  *results)
 
299
{
252
300
  // Check root window visual capabilities.
253
301
  int value;
254
 
  glXGetConfig (display, vinfos, GLX_USE_GL, &value);
255
 
  if (value == 0) {
256
 
    error = "OpenGL rendering is not supported by the root visual";
257
 
    result = 1;
258
 
    goto abort;
259
 
  }
260
 
  glXGetConfig (display, vinfos, GLX_DOUBLEBUFFER, &value);
261
 
  if (value == 0) {
262
 
    error = "color buffers of the root visual are not double-buffered";
263
 
    result = 1;
264
 
    goto abort;
265
 
  }
266
 
 
 
302
  glXGetConfig (display, *vinfos, GLX_USE_GL, &value);
 
303
  if (value == 0) {
 
304
    results->error = strdup ("OpenGL rendering is not supported by the root visual");
 
305
    results->result = 1;
 
306
    return 0;
 
307
  }
 
308
 
 
309
  return 1;
 
310
}
 
311
 
 
312
static int check_colorbuffers (Display     *display,
 
313
                                unsigned int screen,
 
314
                                Window      root,
 
315
                                GLXContext  *context,
 
316
                                XVisualInfo **vinfos,
 
317
                                TestResults  *results)
 
318
{
 
319
  int value;
 
320
  glXGetConfig (display,*vinfos, GLX_DOUBLEBUFFER, &value);
 
321
  if (value == 0) {
 
322
    results->error = strdup ("color buffers of the root visual are not double-buffered");
 
323
    results->result = 1;
 
324
    return 0;
 
325
  }
 
326
 
 
327
  return 1;
 
328
}
 
329
 
 
330
static int check_context (Display     *display,
 
331
                           unsigned int screen,
 
332
                           Window      root,
 
333
                           GLXContext  *context,
 
334
                           XVisualInfo **vinfos,
 
335
                           TestResults  *results)
 
336
{
267
337
  // Create and map the OpenGL context to the root window and get the strings.
268
 
  context = glXCreateContext (display, vinfos, NULL, !indirect);
269
 
  if (context == NULL) {
270
 
    error = "unable to create the OpenGL context";
271
 
    result = 1;
272
 
    goto abort;
273
 
  }
274
 
  glXMakeCurrent (display, root, context);
275
 
  vendor = (char*) glGetString (GL_VENDOR);
276
 
  renderer = (char*) glGetString (GL_RENDERER);
277
 
  version = (char*) glGetString (GL_VERSION);
278
 
 
279
 
  // Fill flags with the supported GLX extensions.
280
 
  const char* glx_extensions = glXQueryExtensionsString (display, screen);
281
 
  const struct { const char* name; const unsigned int flag; } glx_extension[] = {
282
 
    { "GLX_SGIX_fbconfig", FLAG_GLX_SGIX_FBCONFIG },
283
 
    { "GLX_EXT_texture_from_pixmap", FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP },
284
 
    { NULL, 0 }
285
 
  };
286
 
  for (int i = 0; glx_extension[i].name != NULL; i++)
287
 
    if (is_extension_supported (glx_extensions, glx_extension[i].name) == 1)
288
 
      flags |= glx_extension[i].flag;
289
 
  if (flags & FLAG_GLX_SGIX_FBCONFIG) {
290
 
    if (glXGetProcAddressARB ("glXQueryDrawable") == NULL ||
291
 
        glXGetProcAddressARB ("glXGetFBConfigs") == NULL ||
292
 
        glXGetProcAddressARB ("glXGetFBConfigAttrib") == NULL ||
293
 
        glXGetProcAddressARB ("glXCreatePixmap") == NULL ||
294
 
        glXGetProcAddressARB ("glXDestroyPixmap") == NULL) {
295
 
      flags &= ~FLAG_GLX_SGIX_FBCONFIG;
296
 
    }
297
 
  }
298
 
  if (flags & FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP) {
299
 
    if (glXGetProcAddressARB ("glXBindTexImageEXT") == NULL ||
300
 
        glXGetProcAddressARB ("glXReleaseTexImageEXT") == NULL) {
301
 
      flags &= ~FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP;
302
 
    }
303
 
  }
304
 
 
 
338
  *context = glXCreateContext (display, *vinfos, NULL, !results->indirect);
 
339
  if (*context == NULL) {
 
340
    results->error = strdup ("unable to create the OpenGL context");
 
341
    results->result = 1;
 
342
    return 0;
 
343
  }
 
344
  glXMakeCurrent (display, root, *context);
 
345
  results->vendor = (char*) glGetString (GL_VENDOR);
 
346
  results->renderer = (char*) glGetString (GL_RENDERER);
 
347
  results->version = (char*) glGetString (GL_VERSION);
 
348
 
 
349
  return 1;
 
350
}
 
351
 
 
352
static int check_extensions (Display     *display,
 
353
                             unsigned int screen,
 
354
                             Window      root,
 
355
                             GLXContext  *context,
 
356
                             XVisualInfo **vinfos,
 
357
                             TestResults  *results)
 
358
{
305
359
  // Fill flags with the supported OpenGL extensions.
306
360
  const char* gl_extensions = glGetString (GL_EXTENSIONS);
307
361
  if (gl_extensions == NULL) {
308
 
    error = "invalid OpenGL extensions string";
309
 
    result = 1;
310
 
    goto abort;
 
362
    results->error = strdup ("invalid OpenGL extensions string");
 
363
    results->result = 1;
 
364
    return 0;
311
365
  }
312
366
  const struct { const char* name; const unsigned int flag; } gl_extension[] = {
313
367
    { "GL_ARB_texture_non_power_of_two", FLAG_GL_ARB_NON_POWER_OF_TWO },
323
377
  };
324
378
  for (int i = 0; gl_extension[i].name != NULL; i++)
325
379
    if (is_extension_supported (gl_extensions, gl_extension[i].name) == 1)
326
 
      flags |= gl_extension[i].flag;
327
 
 
 
380
      results->flags |= gl_extension[i].flag;
 
381
 
 
382
  // Fill results->flags with the supported GLX extensions.
 
383
  const char* glx_extensions = glXQueryExtensionsString (display, screen);
 
384
  const struct { const char* name; const unsigned int flag; } glx_extension[] = {
 
385
    { "GLX_SGIX_fbconfig", FLAG_GLX_SGIX_FBCONFIG },
 
386
    { "GLX_EXT_texture_from_pixmap", FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP },
 
387
    { NULL, 0 }
 
388
  };
 
389
  for (int i = 0; glx_extension[i].name != NULL; i++)
 
390
    if (is_extension_supported (glx_extensions, glx_extension[i].name) == 1)
 
391
      results->flags |= glx_extension[i].flag;
 
392
  if (results->flags & FLAG_GLX_SGIX_FBCONFIG) {
 
393
    if (glXGetProcAddressARB ("glXQueryDrawable") == NULL ||
 
394
        glXGetProcAddressARB ("glXGetFBConfigs") == NULL ||
 
395
        glXGetProcAddressARB ("glXGetFBConfigAttrib") == NULL ||
 
396
        glXGetProcAddressARB ("glXCreatePixmap") == NULL ||
 
397
        glXGetProcAddressARB ("glXDestroyPixmap") == NULL) {
 
398
      results->flags &= ~FLAG_GLX_SGIX_FBCONFIG;
 
399
    }
 
400
  }
 
401
  if (results->flags & FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP) {
 
402
    if (glXGetProcAddressARB ("glXBindTexImageEXT") == NULL ||
 
403
        glXGetProcAddressARB ("glXReleaseTexImageEXT") == NULL) {
 
404
      results->flags &= ~FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP;
 
405
    }
 
406
  }
 
407
 
 
408
  return 1;
 
409
}
 
410
 
 
411
static int check_blacklist (Display     *display,
 
412
                            unsigned int screen,
 
413
                            Window      root,
 
414
                            GLXContext  *context,
 
415
                            XVisualInfo **vinfos,
 
416
                            TestResults  *results)
 
417
{
328
418
  // Check for software rendering.
329
 
  if (renderer != NULL &&
330
 
      (strncmp (renderer, "Software Rasterizer", 19) == 0 ||
331
 
       strncmp (renderer, "Mesa X11", 8) == 0)) {
332
 
    flags |= FLAG_SOFTWARE_RENDERING;
 
419
  if (results->renderer != NULL &&
 
420
      (strncmp (results->renderer, "Software Rasterizer", 19) == 0 ||
 
421
       strncmp (results->renderer, "Mesa X11", 8) == 0)) {
 
422
    results->flags |= FLAG_SOFTWARE_RENDERING;
333
423
  }
334
424
 
335
425
  // jaytaoko: Balcklist the Geforce FX cards
336
 
  if (renderer != NULL) {
337
 
    char* str = strstr (renderer, "GeForce FX");
 
426
  if (results->renderer != NULL) {
 
427
    char* str = strstr (results->renderer, "GeForce FX");
338
428
    if (str != NULL) {
339
 
      flags |= FLAG_BLACKLISTED;
 
429
      results->flags |= FLAG_BLACKLISTED;
340
430
    }
341
431
  }
342
432
 
356
446
    for (int i = 0; i < gpu_blacklist_size; i++) {
357
447
      if (dev->vendor_id == gpu_blacklist[i].vendor &&
358
448
          dev->device_id == gpu_blacklist[i].device) {
359
 
        flags |= FLAG_BLACKLISTED;
 
449
        results->flags |= FLAG_BLACKLISTED;
360
450
      }
361
451
    }
362
452
    dev = dev->next;
363
453
  }
364
454
  pci_cleanup (access);
365
455
 
366
 
  if (compiz == 0) {
367
 
    // Unity compatibility checks.
368
 
    get_opengl_version (version, &major, &minor);
369
 
    if ((major >= 2 || (major == 1 && minor >= 4)) &&
370
 
        (flags & FLAG_GLX_SGIX_FBCONFIG) &&
371
 
        (flags & FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP) &&
372
 
        (flags & MASK_GL_NON_POWER_OF_TWO) &&
373
 
        (flags & FLAG_GL_ARB_VERTEX_PROGRAM) &&
374
 
        (flags & FLAG_GL_ARB_FRAGMENT_PROGRAM) &&
375
 
        (flags & FLAG_GL_ARB_VERTEX_BUFFER_OBJECT) &&
376
 
        (flags & MASK_GL_FRAMEBUFFER_OBJECT) &&
377
 
        (~flags & FLAG_SOFTWARE_RENDERING) &&
378
 
        (~flags & FLAG_BLACKLISTED)) {
379
 
      result = 0;
380
 
    } else {
381
 
      result = 1;
382
 
    }
383
 
  } else {
384
 
    // Compiz compatibility checks.
385
 
    if ((flags & FLAG_GLX_SGIX_FBCONFIG) &&
386
 
        (flags & FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP) &&
387
 
        (flags & MASK_GL_NON_POWER_OF_TWO) &&
388
 
        (~flags & FLAG_SOFTWARE_RENDERING) &&
389
 
        (~flags & FLAG_BLACKLISTED)) {
390
 
      result = 0;
391
 
    } else {
392
 
      result = 1;
393
 
    }
394
 
  }
395
 
 
396
 
abort:
 
456
  return 1;
 
457
}
 
458
 
 
459
int (*tests[]) (Display     *display,
 
460
                      unsigned int screen,
 
461
                      Window      root,
 
462
                      GLXContext  *context,
 
463
                      XVisualInfo **vinfos,
 
464
                      TestResults  *results) = {
 
465
  check_root_visual,
 
466
  check_xcomposite,
 
467
  check_damage_extension,
 
468
  check_fixes_extension,
 
469
  check_glx_config,
 
470
  check_colorbuffers,
 
471
  check_context,
 
472
  check_extensions,
 
473
  check_blacklist
 
474
};
 
475
 
 
476
const unsigned int c_num_tests = 9;
 
477
 
 
478
int main (int argc, char* argv[]) {
 
479
  char         *display_name = NULL;
 
480
  int          screen;
 
481
  unsigned int print = 0;
 
482
  Window       root;
 
483
  XVisualInfo  *vinfos = NULL;
 
484
  Display      *display = NULL;
 
485
  GLXContext   context = NULL;
 
486
  TestResults  results;
 
487
 
 
488
  results.indirect = 0;
 
489
  results.compiz = 0;
 
490
  results.flags = 0;
 
491
  results.error = NULL;
 
492
  results.flags = 0;
 
493
 
 
494
  if (getenv ("UNITY_FORCE_START")) {
 
495
    fprintf (stdout, "Warning: UNITY_FORCE_START enabled, no check for unity or compiz support.\n");
 
496
    return 0;
 
497
  }
 
498
 
 
499
  // Basic command-line parsing.
 
500
  for (int i = 1; i < argc; i++) {
 
501
    if (((strncmp (argv[i], "-d", 2) == 0) ||
 
502
         (strncmp (argv[i], "--display", 9) == 0)) &&
 
503
        (i + 1 < argc)) {
 
504
      display_name = argv[i + 1];
 
505
      i++;
 
506
    } else if ((strncmp (argv[i], "-i", 2) == 0) ||
 
507
               (strncmp (argv[i], "--indirect", 10) == 0)) {
 
508
      results.indirect = 1;
 
509
    } else if ((strncmp (argv[i], "-p", 2) == 0) ||
 
510
               (strncmp (argv[i], "--print", 7) == 0)) {
 
511
      print = 1;
 
512
    } else if ((strncmp (argv[i], "-c", 2) == 0) ||
 
513
               (strncmp (argv[i], "--compiz", 8) == 0)) {
 
514
      results.compiz = 1;
 
515
    } else if ((strncmp (argv[i], "-h", 2) == 0) ||
 
516
               (strncmp (argv[i], "--help", 6) == 0)) {
 
517
      print_help ();
 
518
      return 2;
 
519
    } else {
 
520
      fprintf (stderr, "Error: unknown command-line option `%s'\n\n", argv[i]);
 
521
      print_help ();
 
522
      return 2;
 
523
    }
 
524
  }
 
525
 
 
526
  // Open a X11 connection and get the root window.
 
527
  display = XOpenDisplay (display_name);
 
528
  if (display == NULL) {
 
529
    results.error = strdup ("unable to open display");
 
530
    results.result = 1;
 
531
  }
 
532
  else
 
533
  {
 
534
    screen = DefaultScreen (display);
 
535
    root = XRootWindow (display, screen);
 
536
 
 
537
    // Do the tests, if one of them fails break out of the loop
 
538
 
 
539
    for (unsigned int i = 0; i < c_num_tests; i++)
 
540
      if (!(*tests[i]) (display, screen, root, &context, &vinfos, &results))
 
541
        break;
 
542
 
 
543
    if (results.compiz == 0) {
 
544
      // Unity compatibility checks.
 
545
      get_opengl_version (results.version, &results.major, &results.minor);
 
546
      if ((results.major >= 2 || (results.major == 1 && results.minor >= 4)) &&
 
547
          (results.flags & FLAG_GLX_SGIX_FBCONFIG) &&
 
548
          (results.flags & FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP) &&
 
549
          (results.flags & MASK_GL_NON_POWER_OF_TWO) &&
 
550
          (results.flags & FLAG_GL_ARB_VERTEX_PROGRAM) &&
 
551
          (results.flags & FLAG_GL_ARB_FRAGMENT_PROGRAM) &&
 
552
          (results.flags & FLAG_GL_ARB_VERTEX_BUFFER_OBJECT) &&
 
553
          (results.flags & MASK_GL_FRAMEBUFFER_OBJECT) &&
 
554
          (~results.flags & FLAG_SOFTWARE_RENDERING) &&
 
555
          (~results.flags & FLAG_BLACKLISTED)) {
 
556
        results.result = 0;
 
557
      } else {
 
558
        results.result = 1;
 
559
      }
 
560
    } else {
 
561
      // Compiz compatibility checks.
 
562
      if ((results.flags & FLAG_GLX_SGIX_FBCONFIG) &&
 
563
          (results.flags & FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP) &&
 
564
          (results.flags & MASK_GL_NON_POWER_OF_TWO) &&
 
565
          (~results.flags & FLAG_SOFTWARE_RENDERING) &&
 
566
          (~results.flags & FLAG_BLACKLISTED)) {
 
567
        results.result = 0;
 
568
      } else {
 
569
        results.result = 1;
 
570
      }
 
571
    }
 
572
  }
397
573
 
398
574
  if (print == 1) {
399
 
    print_report (vendor, renderer, version, major, minor, flags, compiz,
400
 
                  result, error);
 
575
    print_report (results.vendor,  results.renderer,
 
576
                  results.version, results.major,
 
577
                  results.minor,   results.flags,
 
578
                  results.compiz,  results.result, results.error);
401
579
  }
402
580
 
403
581
  if (vinfos != NULL)
406
584
    glXDestroyContext (display, context);
407
585
  if (display != NULL)
408
586
    XCloseDisplay (display);
 
587
  if (results.error != NULL)
 
588
    free (results.error);
409
589
 
410
 
  return result;
 
590
  return results.result;
411
591
}