This file is indexed.

/usr/src/castle-game-engine-4.1.1/opengl/castleglversion.pas is in castle-game-engine-src 4.1.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
{
  Copyright 2001-2013 Michalis Kamburelis.

  This file is part of "Castle Game Engine".

  "Castle Game Engine" is free software; see the file COPYING.txt,
  included in this distribution, for details about the copyright.

  "Castle Game Engine" is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  ----------------------------------------------------------------------------
}

{ Checking OpenGL version, vendors and such (GLVersion, GLUVersion).

  You must manually initialize GLVersion and such (this unit doesn't even
  use GL bindings). For my engine, this will happen automatically
  at LoadAllExtensions call. Which is done during TCastleWindowBase.Open,
  or TCastleControlCustom on GL context initialization.
}
unit CastleGLVersion;

interface

type
  { OpenGL libraries (core OpenGL or GLU) version information.

    As obtained from glGetString(GL_VERSION)
    or gluGetString(GLU_VERSION), also by glGetString(GL_VENDOR).

    This is usually created by CastleGLUtils.LoadAllExtensions. }
  TGenericGLVersion = class
  public
    constructor Create(const VersionString: string);
  public
    { Required (every OpenGL implemenetation has them)
      major and minor numbers.
      @groupBegin }
    Major: Integer;
    Minor: Integer;
    { @groupEnd }

    { Release is the optional release number (check ReleaseExists first).
      @groupBegin }
    ReleaseExists: boolean;
    Release: Integer;
    { @groupEnd }

    { VendorVersion is whatever vendor-specific information was placed
      inside VersionString, after the
      major_number.minor_number.release_number. It never has any whitespace
      at the beginning (we trim it when initializing). }
    VendorVersion: string;

    function AtLeast(AMajor, AMinor: Integer): boolean;
  end;

  TGLVersion = class(TGenericGLVersion)
  private
    FVendor: string;
    FRenderer: string;
    FVendorATI: boolean;
    FFglrx: boolean;
    FVendorNVidia: boolean;
    FVendorIntel: boolean;
    FMesa: boolean;
    FMesaMajor: Integer;
    FMesaMinor: Integer;
    FMesaRelease: Integer;
    FBuggyPointSetAttrib: boolean;
    FBuggyDrawOddWidth: boolean;
    FBuggyGenerateMipmap: boolean;
    FBuggyGenerateCubeMap: boolean;
    FBuggyFBOCubeMap: boolean;
    FBuggyLightModelTwoSide: boolean;
    FBuggyLightModelTwoSideMessage: string;
    FBuggyVBO: boolean;
    FBuggyShaderShadowMap: boolean;
    FBuggyGLSLConstStruct: boolean;
    FBuggyFBOMultiSampling: boolean;
    FBuggySwapNonStandardViewport: boolean;
    FBuggyDepth32: boolean;
  public
    constructor Create(const VersionString, AVendor, ARenderer: string);

    { Vendor that created the OpenGL implemenetation.
      This is just glGetString(GL_VENDOR). }
    property Vendor: string read FVendor;

    { Renderer (GPU model, or software method used for rendering) of the OpenGL.
      This is just glGetString(GL_RENDERER). }
    property Renderer: string read FRenderer;

    { Are we using Mesa (http://mesa3d.org/).
      Detected using VendorSpecific information
      (extracted by base TGenericGLVersion), this allows us to also detect
      Mesa version.
      @groupBegin }
    property Mesa: boolean read FMesa;
    property MesaMajor: Integer read FMesaMajor;
    property MesaMinor: Integer read FMesaMinor;
    property MesaRelease: Integer read FMesaRelease;
    { @groupEnd }

    { ATI GPU with ATI drivers. }
    property VendorATI: boolean read FVendorATI;

    { ATI GPU with ATI drivers on Linux. }
    property Fglrx: boolean read FFglrx;

    { NVidia GPU with NVidia drivers. }
    property VendorNVidia: boolean read FVendorNVidia;

    { Intel GPU with Intel drivers. }
    property VendorIntel: boolean read FVendorIntel;

    { Buggy GL_POINT_BIT flag for glPushAttrib (Mesa DRI Intel bug).

      Observed on Ubuntu 8.10 on computer "domek".
      It seems a bug in upstream Mesa 7.2, as it's reproducible with
      version from http://mesa3d.org/.
      Seemingly reproducible only with "DRI Intel"
      (not reproducible on "chantal" with upstream Mesa 7.2).

      Reported to Ubuntu as
      https://bugs.launchpad.net/ubuntu/+source/mesa/+bug/312830,
      let them report upstream if needed.
      Not observed with Mesa 7.6 in Ubuntu 10.4. }
    property BuggyPointSetAttrib: boolean read FBuggyPointSetAttrib;

    { Buggy drawing of images with odd width (fglrx (ATI on Linux) bug).

      I observe this under Debian testing after upgrading fglrx
      from 8-12-4 to 9-2-2. I know the bug wasn't present in 8-12-4
      (and some other < 8-12-4 that I previously used), and it is in 9-2-2.

      I also see this on Mac OS X with the same GPU (driver GL_VERSION:
      2.0 ATI-1.4.56, GL_RENDERER: ATI Radeon X1600 OpenGL Engine).
      Although it's less common on Mac OS X, but can be seen with
      demo_models/x3d/rendered_texture.x3dv:
      open it, then make some operation that saves screen,
      e.g. open dialog by Ctrl+O.

      Precisely, the problem is for images with size like 819 x 614.
      Drawing them by glDrawPixels (including the case when you put
      this in display list) requires glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
      (as our TRGBImage is not aligned). And on GPUs with
      BuggyDrawOddWidth, such glDrawPixels will simply draw a random
      mess of colors on the screen, like some memory garbage.
      (Note that the image is actually correct, even capturing it
      by glReadPixels works Ok; only drawing of it fails.)

      As far as I tested, this doesn't seem related to
      actual GL_UNPACK_ALIGNMENT (glPixelStorei(GL_UNPACK_ALIGNMENT, 4)
      may also produce the bug, e.g. when used with ImageDrawPart
      trying to draw subimage with odd width). }
    property BuggyDrawOddWidth: boolean read FBuggyDrawOddWidth;

    { Buggy glGenerateMipmapEXT (Mesa and Intel(Windows) bug).

      This was observed with software (no direct) rendering with
      7.0.2 (segfaults) and 7.2.? (makes X crashing; sweet).
      With Mesa 7.5.1 (but tested only with radeon and radeonhd,
      so possibly it's not really related to Mesa version! Reports welcome)
      no problems. }
    property BuggyGenerateMipmap: boolean read FBuggyGenerateMipmap;

    { Buggy generation of cube maps on FBO (Intel(Windows) bug).

      Symptoms: Parts of the cube map texture are uninitialized (left magenta).
      Reproducible with view3dscene on
      demo_models/cube_environment_mapping/cubemap_generated_in_dynamic_world.x3dv .
      Using separate FBO for each cube map face doesn't help (actually,
      makes it worse, there's more magenta),
      so it's not about being unable to do RenderToTexture.SetTexture multiple times.

      Observed, and this workaround is needed, at least on:
      @unorderedList(
        @item Version string: 2.1.0 - Build 8.15.10.2104
        @item Vendor: Intel
        @item Renderer: Intel(R) HD Graphics
      )
    }
    property BuggyFBOCubeMap: boolean read FBuggyFBOCubeMap;

    { Buggy generation of cube maps at all (Intel(Windows) bug).

      Symptoms: Parts of the cube map texture are uninitialized (left magenta).
      Reproducible with view3dscene on
      demo_models/cube_environment_mapping/cubemap_generated_in_dynamic_world.x3dv .
      This is worse then BuggyFBOCubeMap, magenta is always seen at positiveX part
      of the cube map.

      Observed, and this workaround is needed, at least on:
      @unorderedList(
        @item Version string: 3.3.0 - Build 8.15.10.2778
        @item Vendor: Intel
        @item Renderer: Intel(R) HD Graphics 4000
      )
    }
    property BuggyGenerateCubeMap: boolean read FBuggyGenerateCubeMap;

    { Buggy GL_LIGHT_MODEL_TWO_SIDE = GL_TRUE behavior (ATI(Linux) bug).
      See [https://sourceforge.net/apps/phpbb/vrmlengine/viewtopic.php?f=3&t=14] }
    property BuggyLightModelTwoSide: boolean read FBuggyLightModelTwoSide;
    property BuggyLightModelTwoSideMessage: string read FBuggyLightModelTwoSideMessage;

    { Buggy VBO (Intel(Windows) bug). }
    property BuggyVBO: boolean read FBuggyVBO;

    { Buggy shadow2DProj in some situations (ATI(Linux) bug). }
    property BuggyShaderShadowMap: boolean read FBuggyShaderShadowMap;

    { Buggy GLSL @code("const in gl_Xxx") (NVidia bug).
      Segfaults at glCompileShader[ARB] on GLSL declarations like
      @code("const in gl_MaterialParameters material").
      Affects some NVidia drivers on Linux (like version 295.49
      in Debian testing on 2012-06-02). }
    property BuggyGLSLConstStruct: boolean read FBuggyGLSLConstStruct;

    { Buggy (looks like wireframe) FBO rendering to
      the multi-sampling texture (ATI(Windows) and Intel(Windows) bug).
      This makes our screen effects broken on multi-sampled contexts. }
    property BuggyFBOMultiSampling: boolean read FBuggyFBOMultiSampling;

    { Buggy swap buffers when glViewport does not contain
      whole window (ATI(Linux) bug). }
    property BuggySwapNonStandardViewport: boolean
      read FBuggySwapNonStandardViewport;

    { Buggy 32-bit depth buffer, 24-bit depth buffer works Ok
      (Mesa on ATI (Linux) bug). }
    property BuggyDepth32: boolean read FBuggyDepth32;
  end;

var
  { Core OpenGL version information.
    This is usually created by CastleGLUtils.LoadAllExtensions. }
  GLVersion: TGLVersion;

  { GLU version information.
    This is usually created by CastleGLUtils.LoadAllExtensions. }
  GLUVersion: TGenericGLVersion;

implementation

uses SysUtils, CastleStringUtils, CastleUtils;

{ TGenericGLVersion ---------------------------------------------------------- }

type
  EInvalidGLVersionString = class(Exception);

procedure ParseWhiteSpaces(const S: string; var I: Integer);
begin
  while SCharIs(S, I, WhiteSpaces) do Inc(I);
end;

constructor TGenericGLVersion.Create(const VersionString: string);
const
  Digits = ['0'..'9'];
var
  NumberBegin, I: Integer;
begin
  inherited Create;

  try
    I := 1;

    { Note: we allow some whitespace that is not allowed by OpenGL/GLU
      spec. That's because we try hard to work correctly even with
      broken GL_VERSION / GLU_VERSION strings. }

    { Whitespace }
    ParseWhiteSpaces(VersionString, I);

    { Major number }
    if not SCharIs(VersionString, I, Digits) then
      raise EInvalidGLVersionString.Create('Major version number not found');
    NumberBegin := I;
    while SCharIs(VersionString, I, Digits) do Inc(I);
    Major := StrToInt(CopyPos(VersionString, NumberBegin, I - 1));

    { Whitespace }
    ParseWhiteSpaces(VersionString, I);

    { Dot }
    if not SCharIs(VersionString, I, '.') then
      raise EInvalidGLVersionString.Create(
        'The dot "." separator major and minor version number not found');
    Inc(I);

    { Whitespace }
    ParseWhiteSpaces(VersionString, I);

    { Minor number }
    if not SCharIs(VersionString, I, Digits) then
      raise EInvalidGLVersionString.Create('Minor version number not found');
    NumberBegin := I;
    while SCharIs(VersionString, I, Digits) do Inc(I);
    Minor := StrToInt(CopyPos(VersionString, NumberBegin, I - 1));

    ReleaseExists := SCharIs(VersionString, I, '.');

    if ReleaseExists then
    begin
      { Dot }
      Inc(I);

      { Release number }
      if not SCharIs(VersionString, I, Digits) then
      raise EInvalidGLVersionString.Create(
        'Release version number not found, ' +
        'although there was a dot after minor number');
      NumberBegin := I;
      while SCharIs(VersionString, I, Digits) do Inc(I);
      Release := StrToInt(CopyPos(VersionString, NumberBegin, I - 1));
    end;

    { Whitespace }
    ParseWhiteSpaces(VersionString, I);

    VendorVersion := SEnding(VersionString, I);
  except
    { In case of any error here: silence it.
      So actually EInvalidGLVersionString is not useful.
      We want our program to work even with broken GL_VERSION or GLU_VERSION
      strings.

      Class constructor always starts with Major and Minor initialized
      to 0, ReleaseExists initialized to false, and VendorVersion to ''.
      If we have here an exception, only part of them may be initialized. }
  end;
end;

function TGenericGLVersion.AtLeast(AMajor, AMinor: Integer): boolean;
begin
  Result := (AMajor < Major) or
    ( (AMajor = Major) and (AMinor <= Minor) );
end;

{ TGLVersion ----------------------------------------------------------------- }

constructor TGLVersion.Create(const VersionString, AVendor, ARenderer: string);

  { Parse Mesa version, starting from S[I] (where I should
    be the index in S right after the word "Mesa"). }
  procedure ParseMesaVersion(const S: string; var I: Integer);
  const
    Digits = ['0'..'9'];
  var
    NumberBegin: Integer;
  begin
    { Whitespace }
    ParseWhiteSpaces(S, I);

    { Mesa major number }
    if not SCharIs(S, I, Digits) then
      raise EInvalidGLVersionString.Create('Mesa major version number not found');
    NumberBegin := I;
    while SCharIs(S, I, Digits) do Inc(I);
    FMesaMajor := StrToInt(CopyPos(S, NumberBegin, I - 1));

    { Whitespace }
    ParseWhiteSpaces(S, I);

    { Dot }
    if not SCharIs(S, I, '.') then
      raise EInvalidGLVersionString.Create(
        'The dot "." separator between Mesa major and minor version number not found');
    Inc(I);

    { Whitespace }
    ParseWhiteSpaces(S, I);

    { Mesa minor number }
    if not SCharIs(S, I, Digits) then
      raise EInvalidGLVersionString.Create('Mesa minor version number not found');
    NumberBegin := I;
    while SCharIs(S, I, Digits) do Inc(I);
    FMesaMinor := StrToInt(CopyPos(S, NumberBegin, I - 1));

    { Whitespace }
    ParseWhiteSpaces(S, I);

    { Dot }
    if SCharIs(S, I, '.') then
    begin
      Inc(I);

      { Whitespace }
      ParseWhiteSpaces(S, I);

      { Mesa release number }
      if not SCharIs(S, I, Digits) then
        raise EInvalidGLVersionString.Create('Mesa release version number not found');
      NumberBegin := I;
      while SCharIs(S, I, Digits) do Inc(I);
      FMesaRelease := StrToInt(CopyPos(S, NumberBegin, I - 1));
    end else
    begin
      { Some older Mesa versions (like 5.1) and newer (7.2) really
        don't have release number inside a version string.
        Seems like they don't have
        release number at all, and assuming "0" seems sensible following
        version names on WWW. So the missing dot "."
        separator between Mesa minor and release version number should
        be ignored. }
      FMesaRelease := 0;
    end;
  end;

  function MesaVersionAtLeast(VerMaj, VerMin, VerRel: Integer): boolean;
  begin
    Result :=
        (MesaMajor > VerMaj) or
      ( (MesaMajor = VerMaj) and (

        (MesaMinor > VerMin) or
      ( (MesaMinor = VerMin) and (

         MesaRelease >= VerRel
      ))));
  end;

var
  VendorName, S: string;
  MesaStartIndex, I: Integer;
begin
  inherited Create(VersionString);

  try
    I := 1;
    while SCharIs(VendorVersion, I, AllChars - WhiteSpaces) do Inc(I);

    VendorName := CopyPos(VendorVersion, 1, I - 1);
    FMesa := SameText(VendorName, 'Mesa');
    if Mesa then
      ParseMesaVersion(VendorVersion, I) else
    begin
      { I'm seeing also things like GL_VERSION = 1.4 (2.1 Mesa 7.0.4)
        (Debian testing (lenny) on 2008-12-31).
        So "Mesa" may be within parenthesis, preceeded by another version
        number. }
      if SCharIs(VendorVersion, 1, '(') and
         (VendorVersion[Length(VendorVersion)] = ')') then
      begin
        S := Copy(VendorVersion, 2, Length(VendorVersion) - 2);
        I := 1;

        { omit preceeding version number }
        while SCharIs(S, I, AllChars - WhiteSpaces) do Inc(I);

        { omit whitespace }
        ParseWhiteSpaces(S, I);

        { read "Mesa" (hopefully) string }
        MesaStartIndex := I;
        while SCharIs(S, I, AllChars - WhiteSpaces) do Inc(I);

        VendorName := CopyPos(S, MesaStartIndex, I - 1);
        FMesa := SameText(VendorName, 'Mesa');
        if Mesa then
          ParseMesaVersion(S, I);
      end;
    end;

  except
    { Just like in TGenericGLVersion: in case of trouble (broken GL_VERSION
      string) ignore the problem. }
  end;

  FVendor := AVendor;
  FRenderer := ARenderer;

  { Actually seen possible values here: 'NVIDIA Corporation'. }
  FVendorNVidia := IsPrefix('NVIDIA', Vendor);

  { Although "ATI Technologies Inc." is usually found,
    according to http://delphi3d.net/hardware/listreports.php
    also just "ATI" is possible. }
  FVendorATI := (Vendor = 'ATI Technologies Inc.') or (Vendor = 'ATI');
  FFglrx := {$ifdef LINUX} VendorATI {$else} false {$endif};

  FVendorIntel := IsPrefix('Intel', Vendor);

  FBuggyPointSetAttrib := Mesa and IsPrefix('Mesa DRI Intel', Renderer)
    and (not MesaVersionAtLeast(7, 6, 0));

  { Initially, I wanted to set this when fglrx version 9.x is detected.

    This can be detected by looking at the last number in GL_VERSION,
    it's an internal fglrx version number (9.x is an "official" Catalyst
    version). Looking at http://www2.ati.com/drivers/linux/catalyst_91_linux.pdf
    (linked from http://wiki.cchtml.com/index.php/Catalyst_9.1)
    the 9.1 release corresponds to internal number 8.573,
    which I think is encoded directly in Release number we have here.

    Later: I'll just do this do every ATI, since Mac OS X GPU has the same
    problem on rendered_texture.x3dv test. }
  FBuggyDrawOddWidth := VendorATI;

  FBuggyGenerateMipmap := (Mesa and (not MesaVersionAtLeast(7, 5, 0)))
                          {$ifdef WINDOWS} or VendorIntel {$endif};

  FBuggyFBOCubeMap := {$ifdef WINDOWS} VendorIntel {$else} false {$endif};

  FBuggyGenerateCubeMap := {$ifdef WINDOWS} (VendorIntel and SameText(Renderer, 'Intel(R) HD Graphics 4000')) {$else} false {$endif};
  { On which fglrx versions does this occur?

    - On Catalyst 8.12 (fglrx 8.561) all seems to work fine
      (tested on MacBook Pro "chantal").

    - Catalyst 9.1 (fglrx 8.573) - not known.
      Below we only *assume* the bug started from 9.1.

    - On Catalyst 9.10 and 10.3 the bug does occur.
      Tested on Radeon HD 4300 (on HP ProBook "czarny"), Ubuntu x86_64.

    - Bug confirmed also on Ubuntu 10.04 (fglrx 8.723).
      Tested on Radeon HD 4300 (on HP ProBook "czarny"), Ubuntu x86_64.

    - Bug disappeared on Ubuntu 10.10 (fglrx 8.780). Seems fixed there.
      (fglrx bugzilla was wiped, so we don't have any official
      confirmation about this from AMD.) }

  FBuggyLightModelTwoSide := Fglrx and ReleaseExists and
    (Release >= 8573) and (Release < 8780);
  if BuggyLightModelTwoSide then
    FBuggyLightModelTwoSideMessage := 'Detected fglrx (ATI proprietary Linux drivers) version >= 9.x. ' + 'Setting GL_LIGHT_MODEL_TWO_SIDE to GL_TRUE may cause nasty bugs on some shaders (see http://sourceforge.net/apps/phpbb/vrmlengine/viewtopic.php?f=3&t=14), so disabling two-sided lighting.' else
    FBuggyLightModelTwoSideMessage := '';

  FBuggyVBO := {$ifdef WINDOWS}
    { See demo_models/x3d/background_test_mobile_intel_gpu_bugs.x3d }
    (Vendor = 'Intel') and
    (Renderer = 'Intel Cantiga') and
    (not AtLeast(1, 6))
    {$else}
    false
    {$endif};

  FBuggyShaderShadowMap :=
    { This happens on fglrx, the worst OpenGL driver in the world.
      card: ATI Mobility Radeon HD 4300,
      confirmed on
        Ubuntu 10.10/x86_64 (czarny)
        Ubuntu 10.10/i386   (czarny)
        Ubuntu 11.4/x86_64  (czarny)
        Ubuntu 11.4/i386    (czarny) (fglrx OpenGL version 3.3.10665)
      not occurs on
        Ubuntu 9.10/i386    (czarny)
      Looks like fglrx bug since at least Ubuntu 10.10 (assuming always
      since Ubuntu 10.04, which is fglrx >= 8.723). }
    Fglrx and ReleaseExists and (Release >= 8723);

  FBuggyGLSLConstStruct := {$ifdef LINUX} VendorNvidia {$else} false {$endif};

   { Reported on Radeon 6600, 6850 - looks like wireframe
     Also on Intel cards - querying multisampled depth buffer returns bad data. }
  FBuggyFBOMultiSampling :=
    {$ifdef WINDOWS} (VendorATI and
      (IsPrefix('AMD Radeon HD 6', Renderer) or IsPrefix('AMD Radeon HD6', Renderer)))
    or VendorIntel
    {$else} false {$endif};

  { Observed on fglrx (ATI proprietary OpenGL driver under Linux,
    aka the worst OpenGL driver in the world), at least on this version:

    Version string: 3.3.11627 Compatibility Profile Context
    Vendor: ATI Technologies Inc.
    Renderer: ATI Mobility Radeon HD 4300 Series

    This corresponds to Ubuntu 12.04.1 package fglrx 2:8.960-0ubuntu1.1.
    The bug is *not* present on Windows installed on the same hardware
    (or any other GPU, Linux or Windows).
    Easily reproducible by fps_game: the ExtraViewport by default leaves
    glViewport at non-full-screen state at the end of EventDraw,
    causing following SwapBuffers in DoDraw to fail, leaving part
    of the screen not updated (black) without this workaround. }
  FBuggySwapNonStandardViewport := Fglrx;

  { Observed on Mac Book Pro GPU under Linux, with Debian testing on 2013-01-08:

      Version string: 2.1 Mesa 8.0.5
      Version parsed: major: 2, minor: 1, release exists: FALSE, release: 0, vendor-specific version: "Mesa 8.0.5"
      Vendor: VMware, Inc.
      Renderer: Gallium 0.4 on llvmpipe (LLVM 0x209)
  }
  FBuggyDepth32 := Mesa and (MesaMajor = 8) and (MesaMinor = 0) and
    (Vendor = 'VMware, Inc.') and IsPrefix('Gallium 0.4 on llvmpipe', Renderer);
end;

finalization
  FreeAndNil(GLVersion);
  FreeAndNil(GLUVersion);
end.