| 1 |
{ |
| 2 |
Copyright 2001-2023 Michalis Kamburelis. |
| 3 |
|
| 4 |
This file is part of "Castle Game Engine". |
| 5 |
|
| 6 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 7 |
included in this distribution, for details about the copyright. |
| 8 |
|
| 9 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 |
|
| 13 |
---------------------------------------------------------------------------- |
| 14 |
} |
| 15 |
|
| 16 |
{ Checking OpenGL version, vendors and such (GLVersion). |
| 17 |
These should be initialized by calling GLInformationInitialize, |
| 18 |
which is done automatically when opening OpenGL context using |
| 19 |
TCastleWindow or TCastleControl. |
| 20 |
} |
| 21 |
unit CastleGLVersion; |
| 22 |
|
| 23 |
{$I castleconf.inc} |
| 24 |
|
| 25 |
{$ifdef CASTLE_STRICT_CLI} |
| 26 |
{$error When CASTLE_STRICT_CLI is defined, you cannot link to this unit.} |
| 27 |
{$endif} |
| 28 |
|
| 29 |
interface |
| 30 |
|
| 31 |
type |
| 32 |
{ OpenGL(ES) library version information. |
| 33 |
Determined looking at information from glGetString(GL_VERSION), |
| 34 |
glGetString(GL_VENDOR) and such. |
| 35 |
|
| 36 |
User code should never create instances of this class. |
| 37 |
Only use the singleton @link(GLVersion), already initialized for you. |
| 38 |
|
| 39 |
Internally, this should be always created by GLInformationInitialize. } |
| 40 |
TGenericGLVersion = class |
| 41 |
strict private |
| 42 |
FVersionString: String; |
| 43 |
public |
| 44 |
constructor Create(const AVersionString: string); |
| 45 |
public |
| 46 |
{ Major and minor version numbers of OpenGL(ES) implementation. |
| 47 |
@groupBegin } |
| 48 |
Major: Integer; |
| 49 |
Minor: Integer; |
| 50 |
{ @groupEnd } |
| 51 |
|
| 52 |
{ Release version number of OpenGL(ES) implementation. |
| 53 |
Optional, some OpenGL(ES) implementations may not have "release" number |
| 54 |
(check ReleaseExists first). |
| 55 |
@groupBegin } |
| 56 |
ReleaseExists: boolean; |
| 57 |
Release: Integer; |
| 58 |
{ @groupEnd } |
| 59 |
|
| 60 |
{ Vendor-specific version that was at the end of VersionString (after the |
| 61 |
major_number.minor_number.release_number). It never has any whitespace |
| 62 |
at the beginning (we trim it when initializing). } |
| 63 |
VendorVersion: string; |
| 64 |
|
| 65 |
function AtLeast(AMajor, AMinor: Integer): boolean; |
| 66 |
|
| 67 |
{ Version as a string. |
| 68 |
This is full unprocessed and untrimmed value, as returned by glGetString(GL_VERSION). } |
| 69 |
property VersionString: String read FVersionString; |
| 70 |
end; |
| 71 |
|
| 72 |
{ Recognized OpenGL(ES) vendor names. |
| 73 |
|
| 74 |
Note that we don't try to recognize all vendors, only the most popular ones |
| 75 |
and the ones whose detection is necessary to workaround/optimize |
| 76 |
some OpenGL(ES) code. For unrecognized vendors, we just set gvOther. } |
| 77 |
TGLVendorType = ( |
| 78 |
{ Some vendor not covered by other enums. } |
| 79 |
gvOther, |
| 80 |
{ ATI GPU with ATI drivers. } |
| 81 |
gvATI, |
| 82 |
{ NVidia GPU with NVidia drivers. } |
| 83 |
gvNvidia, |
| 84 |
{ Intel GPU with Intel drivers. } |
| 85 |
gvIntel, |
| 86 |
{ Imagination Technologies (PowerVR) GPU, found on mobile devices. } |
| 87 |
gvImaginationTechnologies, |
| 88 |
{ Qualcomm Adreno, found on mobile devices. } |
| 89 |
gvQualcomm, |
| 90 |
{ Arm, makers of Mali GPU, found on mobile devices. } |
| 91 |
gvArm |
| 92 |
); |
| 93 |
|
| 94 |
TGLVersion = class(TGenericGLVersion) |
| 95 |
private |
| 96 |
FVendor: string; |
| 97 |
FVendorType: TGLVendorType; |
| 98 |
FRenderer: string; |
| 99 |
FFglrx: boolean; |
| 100 |
FMesa: boolean; |
| 101 |
FVendorMajor: Integer; |
| 102 |
FVendorMinor: Integer; |
| 103 |
FVendorRelease: Integer; |
| 104 |
FBuggyGenerateCubeMap: boolean; |
| 105 |
FBuggyFBOCubeMap: boolean; |
| 106 |
FBuggyVBO: boolean; |
| 107 |
FBuggyFBOMultiSampling: boolean; |
| 108 |
FBuggySwapNonStandardViewport: boolean; |
| 109 |
FBuggyDepth32: boolean; |
| 110 |
FBuggyGLSLFrontFacing: boolean; |
| 111 |
FBuggyGLSLReadVarying: boolean; |
| 112 |
FBuggyTextureSizeAbove2048: Boolean; |
| 113 |
FBuggyGLSLBumpMappingNumSteps: Boolean; |
| 114 |
function AppleRendererOlderThan(const VersionNumber: Cardinal): Boolean; |
| 115 |
public |
| 116 |
constructor Create(const AVersionString, AVendor, ARenderer: string); |
| 117 |
|
| 118 |
{ Vendor that created the OpenGL implemenetation. |
| 119 |
This is just glGetString(GL_VENDOR). } |
| 120 |
property Vendor: string read FVendor; |
| 121 |
|
| 122 |
{ Vendor type, derived from @link(Vendor) string. } |
| 123 |
property VendorType: TGLVendorType read FVendorType; |
| 124 |
|
| 125 |
{ Renderer (GPU model, or software method used for rendering) of the OpenGL. |
| 126 |
This is just glGetString(GL_RENDERER). } |
| 127 |
property Renderer: string read FRenderer; |
| 128 |
|
| 129 |
{ Are we using Mesa (http://mesa3d.org/). |
| 130 |
Note that this is detected using VendorVersion, not Vendor. } |
| 131 |
property Mesa: boolean read FMesa; |
| 132 |
|
| 133 |
{ Vendor-specific drivers version. |
| 134 |
Right now this is detected for Mesa and Intel. |
| 135 |
@groupBegin } |
| 136 |
property VendorMajor: Integer read FVendorMajor; |
| 137 |
property VendorMinor: Integer read FVendorMinor; |
| 138 |
property VendorRelease: Integer read FVendorRelease; |
| 139 |
{ @groupEnd } |
| 140 |
|
| 141 |
{ ATI GPU with ATI drivers on Linux. } |
| 142 |
property Fglrx: boolean read FFglrx; |
| 143 |
|
| 144 |
{ Buggy generation of cube maps on FBO (Intel(Windows) bug). |
| 145 |
|
| 146 |
Symptoms: Parts of the cube map texture are uninitialized (left magenta). |
| 147 |
Reproducible with castle-model-viewer on |
| 148 |
demo_models/cube_environment_mapping/cubemap_generated_in_dynamic_world.x3dv . |
| 149 |
Using separate FBO for each cube map face doesn't help (actually, |
| 150 |
makes it worse, there's more magenta), |
| 151 |
so it's not about being unable to do RenderToTexture.SetTexture multiple times. |
| 152 |
|
| 153 |
Observed, and this workaround is needed, at least on: |
| 154 |
@unorderedList( |
| 155 |
@item Version string: 2.1.0 - Build 8.15.10.2104 |
| 156 |
@item Vendor: Intel |
| 157 |
@item Renderer: Intel(R) HD Graphics |
| 158 |
) |
| 159 |
} |
| 160 |
property BuggyFBOCubeMap: boolean read FBuggyFBOCubeMap; |
| 161 |
|
| 162 |
{ Buggy generation of cube maps at all (Intel(Windows) bug). |
| 163 |
|
| 164 |
Symptoms: Parts of the cube map texture are uninitialized (left magenta). |
| 165 |
Reproducible with castle-model-viewer on |
| 166 |
demo_models/cube_environment_mapping/cubemap_generated_in_dynamic_world.x3dv . |
| 167 |
This is worse than BuggyFBOCubeMap, magenta is always seen at positiveX part |
| 168 |
of the cube map. |
| 169 |
|
| 170 |
Observed, and this workaround is needed, at least on: |
| 171 |
@unorderedList( |
| 172 |
@item Version string: 3.3.0 - Build 8.15.10.2778 |
| 173 |
@item Vendor: Intel |
| 174 |
@item Renderer: Intel(R) HD Graphics 4000 |
| 175 |
) |
| 176 |
} |
| 177 |
property BuggyGenerateCubeMap: boolean read FBuggyGenerateCubeMap; |
| 178 |
|
| 179 |
{ Buggy VBO (Intel(Windows) bug). } |
| 180 |
property BuggyVBO: boolean read FBuggyVBO; |
| 181 |
|
| 182 |
{ Buggy (looks like wireframe) FBO rendering to |
| 183 |
the multi-sampling texture (ATI(Windows) and Intel(Windows) bug). |
| 184 |
This makes our screen effects broken on multi-sampled contexts. } |
| 185 |
property BuggyFBOMultiSampling: boolean read FBuggyFBOMultiSampling; |
| 186 |
|
| 187 |
{ Buggy swap buffers when glViewport does not contain |
| 188 |
whole window (ATI(Linux) bug). } |
| 189 |
property BuggySwapNonStandardViewport: boolean |
| 190 |
read FBuggySwapNonStandardViewport; |
| 191 |
|
| 192 |
{ Buggy 32-bit depth buffer, 24-bit depth buffer works Ok |
| 193 |
(Mesa on ATI (Linux) bug). } |
| 194 |
property BuggyDepth32: boolean read FBuggyDepth32; |
| 195 |
|
| 196 |
{ Buggy gl_FrontFacing in GLSL. Observed on Mesa 10.x with OpenGL 3.x |
| 197 |
(see implemenetation for details where it's observed / not observed). |
| 198 |
|
| 199 |
Note that avoiding gl_FrontFacing (that seems to always has inverted value?) |
| 200 |
is only a part of the workaround for these GPUs. |
| 201 |
The other is to not render back faces, since it seems |
| 202 |
that normals are *always* oriented to point to the light |
| 203 |
(so, if you don't look at gl_FrontFacing, you are lit from *both* sides). |
| 204 |
So enable backface culling, or just be prepared that backfaces may be |
| 205 |
incorrectly light. } |
| 206 |
property BuggyGLSLFrontFacing: boolean read FBuggyGLSLFrontFacing; |
| 207 |
|
| 208 |
{ Do not read varying values in vertex shader, treat them as write-only. } |
| 209 |
property BuggyGLSLReadVarying: boolean read FBuggyGLSLReadVarying; |
| 210 |
|
| 211 |
{ MaxTextureSize above 2048 shall not be trusted. } |
| 212 |
property BuggyTextureSizeAbove2048: Boolean read FBuggyTextureSizeAbove2048; |
| 213 |
|
| 214 |
{ Buggy num_steps value in bmSteepParallax and bmSteepParallaxShadowing |
| 215 |
BumpMapping modes on Adreno mobile GPU's (random crashes, sometimes |
| 216 |
variable in shader has wrong value. Observed on: |
| 217 |
- Xiaomi Mi 10 Lite (M2002J9G), Snapdragon 765G, Adreno 620: |
| 218 |
- Motorola Moto G8 (XT2045-2), Snapdragon 665, Adreno 610 |
| 219 |
- Motorola Moto G7 Plus (XT2081-2), Snapdragon 460, Adreno 610 |
| 220 |
- Xiaomi Redmi Note 8, Snapdragon 665, Adreno 610 |
| 221 |
- Xiaomi Redmi Note 7A Snapdragon 439, Adreno 505 |
| 222 |
More info in comment TGLVersion.Create(). |
| 223 |
|
| 224 |
It can be tested by https://github.com/and3md/castle-adreno-tests } |
| 225 |
property BuggyGLSLBumpMappingNumSteps: Boolean read FBuggyGLSLBumpMappingNumSteps; |
| 226 |
end; |
| 227 |
|
| 228 |
var |
| 229 |
{ OpenGL(ES) version information. |
| 230 |
|
| 231 |
Internally automatically initialized when at least one OpenGL(ES) context is open, |
| 232 |
may be @nil otherwise. |
| 233 |
User code should never set this variable. } |
| 234 |
GLVersion: TGLVersion; |
| 235 |
|
| 236 |
function VendorTypeToStr(const VendorType: TGLVendorType): string; |
| 237 |
|
| 238 |
implementation |
| 239 |
|
| 240 |
uses SysUtils, CastleStringUtils, CastleUtils, CastleLog; |
| 241 |
|
| 242 |
{ Skip whitespace. Moves I to next index after whitespace. } |
| 243 |
procedure ParseWhiteSpaces(const S: string; var I: Integer); |
| 244 |
begin |
| 245 |
while SCharIs(S, I, WhiteSpaces) do Inc(I); |
| 246 |
end; |
| 247 |
|
| 248 |
{ Parse next non-white-space part of string, assuming we stand on it's start. |
| 249 |
Returns empty string if none (string ended). |
| 250 |
Moves I to next index after this part. } |
| 251 |
function ParseString(const S: string; var I: Integer): string; |
| 252 |
var |
| 253 |
Start: Integer; |
| 254 |
begin |
| 255 |
if (I <= Length(S)) and not CharInSet(S[I], WhiteSpaces) then |
| 256 |
begin |
| 257 |
Start := I; |
| 258 |
repeat Inc(I) until not ((I <= Length(S)) and not CharInSet(S[I], WhiteSpaces)); |
| 259 |
Result := CopyPos(S, Start, I - 1); |
| 260 |
end else |
| 261 |
Result := ''; |
| 262 |
end; |
| 263 |
|
| 264 |
{ Parse next number in the string. |
| 265 |
Moves I to next character. |
| 266 |
Sets out Number on success, returns false on failure (no number, |
| 267 |
or invalid int format). } |
| 268 |
function ParseNumber(const S: string; var I: Integer; out Number: Integer): boolean; |
| 269 |
const |
| 270 |
Digits = ['0'..'9']; |
| 271 |
var |
| 272 |
Start: Integer; |
| 273 |
begin |
| 274 |
if not SCharIs(S, I, Digits) then |
| 275 |
Exit(false); |
| 276 |
Start := I; |
| 277 |
while SCharIs(S, I, Digits) do Inc(I); |
| 278 |
Result := TryStrToInt(CopyPos(S, Start, I - 1), Number); |
| 279 |
end; |
| 280 |
|
| 281 |
{ TGenericGLVersion ---------------------------------------------------------- } |
| 282 |
|
| 283 |
constructor TGenericGLVersion.Create(const AVersionString: string); |
| 284 |
var |
| 285 |
I: Integer; |
| 286 |
begin |
| 287 |
inherited Create; |
| 288 |
|
| 289 |
FVersionString := AVersionString; |
| 290 |
|
| 291 |
try |
| 292 |
I := 1; |
| 293 |
|
| 294 |
{ Note: we allow some whitespace that is not allowed by OpenGL/GLU |
| 295 |
spec. That's because we try hard to work correctly even with |
| 296 |
broken GL_VERSION / GLU_VERSION strings. } |
| 297 |
|
| 298 |
ParseWhiteSpaces(VersionString, I); |
| 299 |
|
| 300 |
{$ifdef OpenGLES} |
| 301 |
if ParseString(VersionString, I) <> 'OpenGL' then |
| 302 |
WritelnWarning('OpenGL', 'OpenGL ES version string 1st component must be "OpenGL"'); |
| 303 |
ParseWhiteSpaces(VersionString, I); |
| 304 |
|
| 305 |
if not IsPrefix('ES', ParseString(VersionString, I)) then |
| 306 |
WritelnWarning('OpenGL', 'OpenGL ES version string 2nd component must start with "ES"'); |
| 307 |
ParseWhiteSpaces(VersionString, I); |
| 308 |
{$endif} |
| 309 |
|
| 310 |
if not ParseNumber(VersionString, I, Major) then Exit; |
| 311 |
ParseWhiteSpaces(VersionString, I); |
| 312 |
|
| 313 |
{ Dot } |
| 314 |
if not SCharIs(VersionString, I, '.') then |
| 315 |
Exit; // The dot "." separator major and minor version number not found |
| 316 |
Inc(I); |
| 317 |
ParseWhiteSpaces(VersionString, I); |
| 318 |
|
| 319 |
if not ParseNumber(VersionString, I, Minor) then Exit; |
| 320 |
|
| 321 |
{ Release number } |
| 322 |
ReleaseExists := SCharIs(VersionString, I, '.'); |
| 323 |
if ReleaseExists then |
| 324 |
begin |
| 325 |
Inc(I); |
| 326 |
if not ParseNumber(VersionString, I, Release) then Exit; |
| 327 |
end; |
| 328 |
ParseWhiteSpaces(VersionString, I); |
| 329 |
|
| 330 |
VendorVersion := SEnding(VersionString, I); |
| 331 |
except |
| 332 |
{ In case of any error here: silence it. |
| 333 |
We want our program to work even with broken GL_VERSION or GLU_VERSION |
| 334 |
strings. |
| 335 |
|
| 336 |
Class constructor always starts with Major and Minor initialized |
| 337 |
to 0, ReleaseExists initialized to false, and VendorVersion to ''. |
| 338 |
If we have here an exception, only part of them may be initialized. } |
| 339 |
end; |
| 340 |
end; |
| 341 |
|
| 342 |
function TGenericGLVersion.AtLeast(AMajor, AMinor: Integer): boolean; |
| 343 |
begin |
| 344 |
Result := (AMajor < Major) or |
| 345 |
( (AMajor = Major) and (AMinor <= Minor) ); |
| 346 |
end; |
| 347 |
|
| 348 |
{ TGLVersion ----------------------------------------------------------------- } |
| 349 |
|
| 350 |
constructor TGLVersion.Create(const AVersionString, AVendor, ARenderer: String); |
| 351 |
|
| 352 |
{ Parse VendorMajor / VendorMinor / VendorRelease, starting from S[I]. } |
| 353 |
procedure ParseVendorVersionSuffix(const S: string; var I: Integer); |
| 354 |
begin |
| 355 |
ParseWhiteSpaces(S, I); |
| 356 |
|
| 357 |
if not ParseNumber(S, I, FVendorMajor) then Exit; |
| 358 |
ParseWhiteSpaces(S, I); |
| 359 |
|
| 360 |
{ Dot } |
| 361 |
if not SCharIs(S, I, '.') then |
| 362 |
Exit; //The dot "." separator between Vendor major and minor version number not found |
| 363 |
Inc(I); |
| 364 |
ParseWhiteSpaces(S, I); |
| 365 |
|
| 366 |
if not ParseNumber(S, I, FVendorMinor) then Exit; |
| 367 |
ParseWhiteSpaces(S, I); |
| 368 |
|
| 369 |
{ Vendor release number } |
| 370 |
if SCharIs(S, I, '.') then |
| 371 |
begin |
| 372 |
Inc(I); |
| 373 |
ParseWhiteSpaces(S, I); |
| 374 |
if not ParseNumber(S, I, FVendorRelease) then Exit; |
| 375 |
end else |
| 376 |
begin |
| 377 |
{ Some older Mesa versions (like 5.1) and newer (7.2) really |
| 378 |
don't have release number inside a version string. |
| 379 |
Seems like they don't have |
| 380 |
release number at all, and assuming "0" seems sensible following |
| 381 |
version names on WWW. So the missing dot "." |
| 382 |
separator between Vendor minor and release version number should |
| 383 |
be ignored. } |
| 384 |
FVendorRelease := 0; |
| 385 |
end; |
| 386 |
end; |
| 387 |
|
| 388 |
{ Extract information from VendorVersion String. } |
| 389 |
procedure ParseVendorVersion; |
| 390 |
const |
| 391 |
SCompatibilityProfile = '(Compatibility Profile)'; |
| 392 |
var |
| 393 |
MaybeMesa, S: string; |
| 394 |
I, MaybeMesaStart: Integer; |
| 395 |
begin |
| 396 |
try |
| 397 |
{ Handle the case like this: GL_VERSION = '1.4 (2.1 Mesa 7.0.4)' |
| 398 |
(Debian testing (lenny) on 2008-12-31). |
| 399 |
In such case "Mesa" is within parenthesis, |
| 400 |
preceeded by another version number that we ignore, |
| 401 |
followed by Mesa version number. } |
| 402 |
if SCharIs(VendorVersion, 1, '(') and |
| 403 |
(VendorVersion[Length(VendorVersion)] = ')') then |
| 404 |
begin |
| 405 |
S := Copy(VendorVersion, 2, Length(VendorVersion) - 2); |
| 406 |
I := 1; |
| 407 |
|
| 408 |
{ omit preceeding version number } |
| 409 |
ParseString(S, I); |
| 410 |
|
| 411 |
{ omit whitespace } |
| 412 |
ParseWhiteSpaces(S, I); |
| 413 |
|
| 414 |
{ read "Mesa" (possibly) string } |
| 415 |
MaybeMesa := ParseString(S, I); |
| 416 |
FMesa := SameText(MaybeMesa, 'Mesa'); |
| 417 |
if Mesa then |
| 418 |
ParseVendorVersionSuffix(S, I); |
| 419 |
end else |
| 420 |
begin |
| 421 |
{ Try to handle normal vendor version. |
| 422 |
This should work on various GPUs (at least for Mesa, Intel and NVidia). } |
| 423 |
|
| 424 |
// calculate MaybeMesaStart, to omit SCompatibilityProfile at the beginning |
| 425 |
if IsPrefix(SCompatibilityProfile, VendorVersion, true) then |
| 426 |
begin |
| 427 |
MaybeMesaStart := Length(SCompatibilityProfile) + 1; |
| 428 |
ParseWhiteSpaces(VendorVersion, MaybeMesaStart); |
| 429 |
end else |
| 430 |
MaybeMesaStart := 1; |
| 431 |
|
| 432 |
// calculate MaybeMesa and FMesa |
| 433 |
I := MaybeMesaStart; |
| 434 |
MaybeMesa := ParseString(VendorVersion, I); |
| 435 |
FMesa := SameText(MaybeMesa, 'Mesa'); |
| 436 |
|
| 437 |
while SCharIs(VendorVersion, I, AllChars - ['0'..'9']) and |
| 438 |
(I < Length(VendorVersion)) do |
| 439 |
Inc(I); |
| 440 |
ParseVendorVersionSuffix(VendorVersion, I); |
| 441 |
end; |
| 442 |
except |
| 443 |
{ Just like in TGenericGLVersion: in case of trouble (GL_VERSION |
| 444 |
string that we don't recognize) just ignore the problem. |
| 445 |
We don't strictly need the VendorXxx information. } |
| 446 |
end; |
| 447 |
end; |
| 448 |
|
| 449 |
{ Compare arguments with VendorMajor / VendorMinor / VendorRelease numbers. } |
| 450 |
function VendorVersionAtLeast(const VerMaj, VerMin, VerRel: Integer): boolean; |
| 451 |
begin |
| 452 |
Result := |
| 453 |
(VendorMajor > VerMaj) or |
| 454 |
( (VendorMajor = VerMaj) and ( |
| 455 |
|
| 456 |
(VendorMinor > VerMin) or |
| 457 |
( (VendorMinor = VerMin) and ( |
| 458 |
|
| 459 |
VendorRelease >= VerRel |
| 460 |
)))); |
| 461 |
end; |
| 462 |
|
| 463 |
begin |
| 464 |
inherited Create(AVersionString); |
| 465 |
|
| 466 |
if AVersionString = '' then |
| 467 |
raise Exception.Create('Cannot initialize TGLVersion before OpenGL context is open'); |
| 468 |
|
| 469 |
ParseVendorVersion; |
| 470 |
|
| 471 |
FVendor := AVendor; |
| 472 |
FRenderer := ARenderer; |
| 473 |
|
| 474 |
{ calculate FVendorType } |
| 475 |
if IsPrefix('NVIDIA', Vendor) then // Actually seen possible values here: 'NVIDIA Corporation'. |
| 476 |
FVendorType := gvNvidia |
| 477 |
else |
| 478 |
{ Although "ATI Technologies Inc." is usually found, |
| 479 |
according to http://delphi3d.net/hardware/listreports.php |
| 480 |
also just "ATI" is possible. } |
| 481 |
if (Vendor = 'ATI Technologies Inc.') or (Vendor = 'ATI') then |
| 482 |
FVendorType := gvATI |
| 483 |
else |
| 484 |
if IsPrefix('Intel', Vendor) then |
| 485 |
FVendorType := gvIntel |
| 486 |
else |
| 487 |
if (Vendor = 'Imagination Technologies') then |
| 488 |
FVendorType := gvImaginationTechnologies |
| 489 |
else |
| 490 |
if (Vendor = 'Qualcomm') then |
| 491 |
FVendorType := gvQualcomm |
| 492 |
else |
| 493 |
if SameText(Vendor, 'Arm') then |
| 494 |
FVendorType := gvArm |
| 495 |
else |
| 496 |
FVendorType := gvOther; |
| 497 |
|
| 498 |
FFglrx := {$ifdef LINUX} VendorType = gvATI {$else} false {$endif}; |
| 499 |
|
| 500 |
FBuggyFBOCubeMap := |
| 501 |
{$ifdef MSWINDOWS} |
| 502 |
( (VendorType = gvIntel) and |
| 503 |
not VendorVersionAtLeast(9, 0, 0) |
| 504 |
) |
| 505 |
{$else} false |
| 506 |
{$endif}; |
| 507 |
|
| 508 |
FBuggyGenerateCubeMap := |
| 509 |
{$ifdef MSWINDOWS} |
| 510 |
( (VendorType = gvIntel) and |
| 511 |
SameText(Renderer, 'Intel(R) HD Graphics 4000') and |
| 512 |
not VendorVersionAtLeast(9, 0, 0) |
| 513 |
) |
| 514 |
{$else} false |
| 515 |
{$endif}; |
| 516 |
|
| 517 |
FBuggyVBO := {$ifdef MSWINDOWS} |
| 518 |
{ See demo_models/x3d/background_test_mobile_intel_gpu_bugs.x3d } |
| 519 |
(Vendor = 'Intel') and |
| 520 |
(Renderer = 'Intel Cantiga') and |
| 521 |
(not AtLeast(1, 6)) |
| 522 |
{$else} |
| 523 |
false |
| 524 |
{$endif}; |
| 525 |
|
| 526 |
{ Reported on Radeon 6600, 6850 - looks like wireframe |
| 527 |
Also on Intel cards - querying multisampled depth buffer returns bad data. } |
| 528 |
FBuggyFBOMultiSampling := |
| 529 |
{$ifdef MSWINDOWS} ((VendorType = gvATI) and |
| 530 |
(IsPrefix('AMD Radeon HD 6', Renderer) or IsPrefix('AMD Radeon HD6', Renderer))) |
| 531 |
or ((VendorType = gvIntel) and (not VendorVersionAtLeast(9, 18, 10))) |
| 532 |
{$else} false {$endif}; |
| 533 |
|
| 534 |
{ Observed on fglrx (ATI proprietary OpenGL driver under Linux, |
| 535 |
aka the worst OpenGL driver in the world), at least on this version: |
| 536 |
|
| 537 |
Version string: 3.3.11627 Compatibility Profile Context |
| 538 |
Vendor: ATI Technologies Inc. |
| 539 |
Renderer: ATI Mobility Radeon HD 4300 Series |
| 540 |
|
| 541 |
This corresponds to Ubuntu 12.04.1 package fglrx 2:8.960-0ubuntu1.1. |
| 542 |
The bug is *not* present on Windows installed on the same hardware |
| 543 |
(or any other GPU, Linux or Windows). |
| 544 |
Easily reproducible by fps_game: the ExtraViewport by default leaves |
| 545 |
glViewport at non-full-screen state at the end of EventDraw, |
| 546 |
causing following SwapBuffers in DoDraw to fail, leaving part |
| 547 |
of the screen not updated (black) without this workaround. } |
| 548 |
FBuggySwapNonStandardViewport := Fglrx; |
| 549 |
|
| 550 |
{ Observed on Mac Book Pro GPU under Linux, with Debian testing on 2013-01-08: |
| 551 |
|
| 552 |
Version string: 2.1 Mesa 8.0.5 |
| 553 |
Version parsed: major: 2, minor: 1, release exists: FALSE, release: 0, vendor-specific version: "Mesa 8.0.5" |
| 554 |
Vendor: VMware, Inc. |
| 555 |
Renderer: Gallium 0.4 on llvmpipe (LLVM 0x209) |
| 556 |
} |
| 557 |
FBuggyDepth32 := Mesa and (VendorMajor = 8) and (VendorMinor = 0) and |
| 558 |
(Vendor = 'VMware, Inc.') and IsPrefix('Gallium 0.4 on llvmpipe', Renderer); |
| 559 |
|
| 560 |
{ Observed on (system "river" owned by Michalis, Debian): |
| 561 |
|
| 562 |
Version string: 3.0 Mesa 10.2.2 |
| 563 |
Vendor: nouveau |
| 564 |
Renderer: Gallium 0.4 on NVC3 |
| 565 |
|
| 566 |
Not observed on (system "chantal" owned by Michalis, Debian): |
| 567 |
|
| 568 |
Version string: 2.1 Mesa 10.2.1 |
| 569 |
Vendor: X.Org R300 Project |
| 570 |
Renderer: Gallium 0.4 on ATI RV530 |
| 571 |
|
| 572 |
Observed on (system "czarny" owned by Michalis, Ubuntu): |
| 573 |
|
| 574 |
Version string: 3.0 Mesa 10.1.3 |
| 575 |
Vendor: X.Org |
| 576 |
Renderer: Gallium 0.4 on AMD RV710 |
| 577 |
} |
| 578 |
FBuggyGLSLFrontFacing := Mesa and (VendorMajor = 10) and (Major = 3); |
| 579 |
|
| 580 |
{ observed on Android on |
| 581 |
|
| 582 |
Version string: OpenGL ES 2.0 build 1.9.RC2@2130229 |
| 583 |
Version parsed: major: 2, minor: 0, release exists: False, release: 0, vendor-specific information: "build 1.9.RC2@2130229" |
| 584 |
Vendor-specific version parsed: major: 1, minor: 9, release: 0 |
| 585 |
Vendor: Imagination Technologies |
| 586 |
Renderer: PowerVR SGX 540 |
| 587 |
} |
| 588 |
FBuggyGLSLReadVarying := |
| 589 |
{$ifdef ANDROID} |
| 590 |
(VendorType = gvImaginationTechnologies) and |
| 591 |
(Major = 2) |
| 592 |
{$else} false |
| 593 |
{$endif}; |
| 594 |
|
| 595 |
{ On old iPhones, OpenGLES reports it can handle 4096 texture size, |
| 596 |
but actually it can crash on them. |
| 597 |
Testcase: Unholy on iOS with Wedding (ice texture). |
| 598 |
Tested: it works OK on 'Apple A12 GPU' and 'Apple A13 GPU', and crashes on 'Apple A10 GPU'. |
| 599 |
For safety, assume it crashes too on 'Apple A11 GPU' (not tested). } |
| 600 |
FBuggyTextureSizeAbove2048 := |
| 601 |
{$ifdef CASTLE_IOS} |
| 602 |
AppleRendererOlderThan(12) |
| 603 |
{$else} |
| 604 |
false |
| 605 |
{$endif}; |
| 606 |
|
| 607 |
{ BuggyGLSLBumpMappingNumSteps - affected devices: |
| 608 |
|
| 609 |
Xiaomi Mi 10 Lite (M2002J9G), Snapdragon 765G, Adreno 620: |
| 610 |
Version string: OpenGL ES 3.2 [email protected] (GIT@1fbdf4e, Ia04d082869, 1585724642) (Date:04/01/20) |
| 611 |
Version parsed: major: 3, minor: 2, release exists: False, release: 0, vendor-specific information: "[email protected] (GIT@1fbdf4e, Ia04d082869, 1585724642) (Date:04/01/20)" |
| 612 |
Vendor-specific version parsed: major: 1, minor: 0, release: 0 |
| 613 |
Vendor: Qualcomm |
| 614 |
Vendor type: Unknown |
| 615 |
Renderer: Adreno (TM) 620 |
| 616 |
|
| 617 |
Redmi Note 8, Snapdragon 665, Adreno 610 |
| 618 |
Version string: OpenGL ES 3.2 [email protected] (GIT@6c0fbe4, I4f6179b11f) (Date:03/05/20) |
| 619 |
Version parsed: major: 3, minor: 2, release exists: False, release: 0, vendor-specific information: "[email protected] (GIT@6c0fbe4, I4f6179b11f) (Date:03/05/20)" |
| 620 |
Vendor-specific version parsed: major: 6, minor: 0, release: 0 |
| 621 |
Vendor: Qualcomm |
| 622 |
Vendor type: Qualcomm |
| 623 |
Renderer: Adreno (TM) 610 |
| 624 |
|
| 625 |
Motorola Moto G8 (XT2045-2), Snapdragon 665, Adreno 610 |
| 626 |
Version: |
| 627 |
Version string: OpenGL ES 3.2 [email protected] (GIT@d4cfdf3, Ic907de5ed0, 1601055299) (Date:09/25/20) |
| 628 |
Version parsed: major: 3, minor: 2, release exists: False, release: 0, vendor-specific information: "[email protected] (GIT@d4cfdf3, Ic907de5ed0, 1601055299) (Date:09/25/20)" |
| 629 |
Vendor-specific version parsed: major: 4, minor: 0, release: 0 |
| 630 |
Vendor: Qualcomm |
| 631 |
Vendor type: Qualcomm |
| 632 |
Renderer: Adreno (TM) 610 |
| 633 |
|
| 634 |
Motorola Moto G7 Plus (XT2081-2), Snapdragon 460, Adreno 610 |
| 635 |
Version: |
| 636 |
Version string: OpenGL ES 3.2 [email protected] (GIT@39a1dfd, Ic628754133, 1593471350) (Date:06/29/20) |
| 637 |
Version parsed: major: 3, minor: 2, release exists: False, release: 0, vendor-specific information: "[email protected] (GIT@39a1dfd, Ic628754133, 1593471350) (Date:06/29/20)" |
| 638 |
Vendor-specific version parsed: major: 39, minor: 0, release: 0 |
| 639 |
Vendor: Qualcomm |
| 640 |
Vendor type: Qualcomm |
| 641 |
Renderer: Adreno (TM) 610 |
| 642 |
|
| 643 |
Redmi Note 7A Snapdragon 439, Adreno 505 |
| 644 |
Version: |
| 645 |
Version string: OpenGL ES 3.2 [email protected] (GIT@c692a3f, Ie3bb699d95, 1601378470) (Date:09/29/20) |
| 646 |
Version parsed: major: 3, minor: 2, release exists: False, release: 0, vendor-specific information: "[email protected] (GIT@c692a3f, Ie3bb699d95, 1601378470) (Date:09/29/20)" |
| 647 |
Vendor-specific version parsed: major: 692, minor: 0, release: 0 |
| 648 |
Vendor: Qualcomm |
| 649 |
Vendor type: Qualcomm |
| 650 |
Renderer: Adreno (TM) 505 } |
| 651 |
FBuggyGLSLBumpMappingNumSteps := |
| 652 |
{$ifdef ANDROID} |
| 653 |
(VendorType = gvQualcomm) |
| 654 |
{$else} false |
| 655 |
{$endif}; |
| 656 |
end; |
| 657 |
|
| 658 |
function TGLVersion.AppleRendererOlderThan(const VersionNumber: Cardinal): Boolean; |
| 659 |
var |
| 660 |
I: Integer; |
| 661 |
begin |
| 662 |
for I := 0 to VersionNumber - 1 do |
| 663 |
if Renderer = 'Apple A' + IntToStr(I) + ' GPU' then |
| 664 |
Exit(true); |
| 665 |
Result := false; |
| 666 |
end; |
| 667 |
|
| 668 |
const |
| 669 |
VendorTypeNames: array [TGLVendorType] of String = ( |
| 670 |
'Other', |
| 671 |
'ATI', |
| 672 |
'Nvidia', |
| 673 |
'Intel', |
| 674 |
'Imagination Technologies', |
| 675 |
'Qualcomm', |
| 676 |
'Arm' |
| 677 |
); |
| 678 |
|
| 679 |
function VendorTypeToStr(const VendorType: TGLVendorType): string; |
| 680 |
begin |
| 681 |
Result := VendorTypeNames[VendorType]; |
| 682 |
end; |
| 683 |
|
| 684 |
end. |