| 1 |
{%MainUnit castleglutils.pas} |
| 2 |
{ |
| 3 |
Copyright 2001-2023 Michalis Kamburelis. |
| 4 |
|
| 5 |
This file is part of "Castle Game Engine". |
| 6 |
|
| 7 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 8 |
included in this distribution, for details about the copyright. |
| 9 |
|
| 10 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
|
| 14 |
---------------------------------------------------------------------------- |
| 15 |
} |
| 16 |
|
| 17 |
{ Part of CastleGLUtils unit: GLInformationString. } |
| 18 |
|
| 19 |
{$ifdef read_interface} |
| 20 |
|
| 21 |
{ Multiline string describing attributes of current OpenGL(ES) |
| 22 |
library. This simply queries OpenGL(ES) using glGet* functions |
| 23 |
about many things. Does not change OpenGL(ES) state in any way. |
| 24 |
|
| 25 |
Note that the last line of returned string does not terminate |
| 26 |
with a newline character (so e.g. you may want to do |
| 27 |
Writeln(GLInformationString) instead of just Write(GLInformationString)). } |
| 28 |
function GLInformationString: String; |
| 29 |
|
| 30 |
{ One-line string summarizing current OpenGL(ES). } |
| 31 |
function GLInformationStringSummary: String; |
| 32 |
|
| 33 |
{$endif read_interface} |
| 34 |
|
| 35 |
{$ifdef read_implementation} |
| 36 |
|
| 37 |
function GLInformationString: string; |
| 38 |
const |
| 39 |
Section = '----------------------------------------'; |
| 40 |
|
| 41 |
function GetFloat2(const Param: TGLenum; const Available: Boolean): String; |
| 42 |
var |
| 43 |
V: packed array [0..1] of TGLFloat; |
| 44 |
begin |
| 45 |
if not Available then |
| 46 |
Exit('Not Available'); |
| 47 |
glGetFloatv(Param, @V); |
| 48 |
Result := Format('%f %f', [V[0], V[1]]); |
| 49 |
end; |
| 50 |
|
| 51 |
function VersionReport(Version: TGenericGLVersion): string; |
| 52 |
begin |
| 53 |
Result := Format( |
| 54 |
' Version parsed: major: %d, minor: %d, release exists: %s, ' + |
| 55 |
'release: %d, vendor-specific information: "%s"', [ |
| 56 |
Version.Major, |
| 57 |
Version.Minor, |
| 58 |
BoolToStr(Version.ReleaseExists, true), |
| 59 |
Version.Release, |
| 60 |
Version.VendorVersion |
| 61 |
]); |
| 62 |
end; |
| 63 |
|
| 64 |
function VendorReport(Version: TGLVersion): string; |
| 65 |
begin |
| 66 |
Result := |
| 67 |
Format( |
| 68 |
' Version in suffix, specific to vendor: major: %d, minor: %d, release: %d' + NL + |
| 69 |
NL + |
| 70 |
' Vendor string: %s' + NL + |
| 71 |
' Vendor type: %s' + NL + |
| 72 |
' Special vendors:' + NL + |
| 73 |
' Fglrx: %s' + NL + |
| 74 |
' Mesa: %s' + NL + |
| 75 |
NL + |
| 76 |
' Renderer: %s', [ |
| 77 |
Version.VendorMajor, |
| 78 |
Version.VendorMinor, |
| 79 |
Version.VendorRelease, |
| 80 |
Version.Vendor, |
| 81 |
VendorTypeToStr(Version.VendorType), |
| 82 |
BoolToStr(Version.Fglrx, true), |
| 83 |
BoolToStr(Version.Mesa, true), |
| 84 |
Version.Renderer |
| 85 |
]); |
| 86 |
end; |
| 87 |
|
| 88 |
function BugsReport(Version: TGLVersion): string; |
| 89 |
begin |
| 90 |
Result := |
| 91 |
Format( |
| 92 |
' Buggy VBO: %s' + NL + |
| 93 |
' Buggy FBO rendering to multi-sampling texture: %s' + NL + |
| 94 |
' Buggy FBO rendering to cube map texture: %s' + NL + |
| 95 |
' Buggy swap buffers with non-standard glViewport: %s' + NL + |
| 96 |
' Buggy 32-bit depth buffer: %s' + NL + |
| 97 |
' Buggy GLSL gl_FrontFacing: %s' + NL + |
| 98 |
' Buggy GLSL read varying: %s' + NL + |
| 99 |
' Buggy Texture Size Above 2048: %s' + NL + |
| 100 |
' Buggy Shader Bump Mapping num_steps: %s', [ |
| 101 |
BoolToStr(Version.BuggyVBO, true), |
| 102 |
BoolToStr(Version.BuggyFBOMultiSampling, true), |
| 103 |
BoolToStr(Version.BuggyFBOCubeMap, true), |
| 104 |
BoolToStr(Version.BuggySwapNonStandardViewport, true), |
| 105 |
BoolToStr(Version.BuggyDepth32, true), |
| 106 |
BoolToStr(Version.BuggyGLSLFrontFacing, true), |
| 107 |
BoolToStr(Version.BuggyGLSLReadVarying, true), |
| 108 |
BoolToStr(Version.BuggyTextureSizeAbove2048, true), |
| 109 |
BoolToStr(Version.BuggyGLSLBumpMappingNumSteps, true) |
| 110 |
]); |
| 111 |
end; |
| 112 |
|
| 113 |
function GetMaxTextureMaxAnisotropy: string; |
| 114 |
begin |
| 115 |
if GLFeatures.TextureFilterAnisotropic then |
| 116 |
Result := FloatToStrDot(GLFeatures.MaxTextureMaxAnisotropy) |
| 117 |
else |
| 118 |
Result := 'EXT_texture_filter_anisotropic not available'; |
| 119 |
end; |
| 120 |
|
| 121 |
function GetOcclusionQueryCounterBits: string; |
| 122 |
begin |
| 123 |
if GLFeatures.OcclusionQuery then |
| 124 |
Result := IntToStr(GLFeatures.OcclusionQueryCounterBits) |
| 125 |
else |
| 126 |
Result := 'Occlusion query not available'; |
| 127 |
end; |
| 128 |
|
| 129 |
function TextureCompressionsToString(const Compressions: TTextureCompressions): string; |
| 130 |
var |
| 131 |
C: TTextureCompression; |
| 132 |
begin |
| 133 |
Result := ''; |
| 134 |
for C := Low(C) to High(C) do |
| 135 |
if C in Compressions then |
| 136 |
begin |
| 137 |
if Result <> '' then Result := Result + ', '; |
| 138 |
Result := Result + TextureCompressionInfo[C].Name; |
| 139 |
end; |
| 140 |
Result := '[' + Result + ']'; |
| 141 |
end; |
| 142 |
|
| 143 |
function IntToStrUnknown(const I: Integer): string; |
| 144 |
begin |
| 145 |
Result := IntToStr(I); |
| 146 |
if I = 0 then |
| 147 |
Result := Result + ' (unknown)'; |
| 148 |
end; |
| 149 |
|
| 150 |
begin |
| 151 |
Result := |
| 152 |
{$ifdef OpenGLES} 'OpenGLES' {$else} 'OpenGL' {$endif} + |
| 153 |
' information (detected by ' + ApplicationName + '):' + NL + |
| 154 |
NL + |
| 155 |
|
| 156 |
Section + NL + |
| 157 |
'Basic information:' + NL + |
| 158 |
NL + |
| 159 |
' Context requested: ' + CapabilitiesStr[TGLFeatures.RequestCapabilities] + NL + |
| 160 |
NL + |
| 161 |
' Version string: ' + GLVersion.VersionString + NL + |
| 162 |
VersionReport(GLVersion) + NL + |
| 163 |
VendorReport(GLVersion) + NL + |
| 164 |
NL + |
| 165 |
|
| 166 |
Section + NL + |
| 167 |
'Confirmed versions:' + NL + |
| 168 |
'(checks both version string and actual functions availability in the library, to secure from buggy implementations)' + NL + |
| 169 |
NL + |
| 170 |
{$ifdef OpenGLES} |
| 171 |
' 2_0: ' + BoolToStr(GLFeatures.VersionES_2_0, true) + NL + |
| 172 |
' 3.0: ' + BoolToStr(GLFeatures.VersionES_3_0, true) + NL + |
| 173 |
' 3.1: ' + BoolToStr(GLFeatures.VersionES_3_1, true) + NL + |
| 174 |
' 3.2: ' + BoolToStr(GLFeatures.VersionES_3_2, true) + NL + |
| 175 |
NL + |
| 176 |
|
| 177 |
{$else} |
| 178 |
' 1.2: ' + BoolToStr(GLFeatures.Version_1_2, true) + NL + |
| 179 |
' 1.3: ' + BoolToStr(GLFeatures.Version_1_3, true) + NL + |
| 180 |
' 1.4: ' + BoolToStr(GLFeatures.Version_1_4, true) + NL + |
| 181 |
' 1.5: ' + BoolToStr(GLFeatures.Version_1_5, true) + NL + |
| 182 |
' 2.0: ' + BoolToStr(GLFeatures.Version_2_0, true) + NL + |
| 183 |
' 2.1: ' + BoolToStr(GLFeatures.Version_2_1, true) + NL + |
| 184 |
' 3.0: ' + BoolToStr(GLFeatures.Version_3_0, true) + NL + |
| 185 |
' 3.1: ' + BoolToStr(GLFeatures.Version_3_1, true) + NL + |
| 186 |
' 3.2: ' + BoolToStr(GLFeatures.Version_3_2, true) + NL + |
| 187 |
' 3.3: ' + BoolToStr(GLFeatures.Version_3_3, true) + NL + |
| 188 |
' 4.0: ' + BoolToStr(GLFeatures.Version_4_0, true) + NL + |
| 189 |
NL + |
| 190 |
{$endif} |
| 191 |
|
| 192 |
Section + NL + |
| 193 |
'Features:' + NL + |
| 194 |
NL + |
| 195 |
' Shaders (GLSL): ' + BoolToStr(GLFeatures.Shaders, true) + NL + |
| 196 |
' Multi-texturing: ' + BoolToStr(GLFeatures.UseMultiTexturing, true) + NL + |
| 197 |
' Framebuffer Object: ' + BoolToStr(GLFeatures.Framebuffer, true) + NL + |
| 198 |
' Multi-sampling for FBO buffers and textures: ' + BoolToStr(GLFeatures.FBOMultiSampling, true) + NL + |
| 199 |
' Vertex Buffer Object: ' + BoolToStr(GLFeatures.VertexBufferObject, true) + NL + |
| 200 |
' Vertex Array Object: ' + BoolToStr(GLFeatures.VertexArrayObject, true) + NL + |
| 201 |
' GenerateMipmap available (and reliable): ' + BoolToStr(HasGenerateMipmap, true) + NL + |
| 202 |
' Cube map textures: ' + BoolToStr(GLFeatures.TextureCubeMap, true) + NL + |
| 203 |
' Compressed textures supported: ' + TextureCompressionsToString(GLFeatures.TextureCompression) + NL + |
| 204 |
' 3D textures: ' + BoolToStr(GLFeatures.Texture3D, true) + NL + |
| 205 |
' Textures non-power-of-2: ' + BoolToStr(GLFeatures.TextureNonPowerOfTwo, true) + NL + |
| 206 |
' Blend constant parameter: ' + BoolToStr(GLFeatures.BlendConstant, true) + NL + |
| 207 |
' Float textures: ' + BoolToStr(GLFeatures.TextureFloat, true) + NL + |
| 208 |
' Depth textures: ' + BoolToStr(GLFeatures.TextureDepth, true) + NL + |
| 209 |
' Shadow samplers (necessary for shadow maps): ' + BoolToStr(GLFeatures.TextureDepthCompare, true) + NL + |
| 210 |
' Packed depth + stencil: ' + BoolToStr(GLFeatures.PackedDepthStencil, true) + NL + |
| 211 |
' Texture Modern Formats + Swizzle: ' + BoolToStr(GLFeatures.TextureModernFormatsAndSwizzle, true) + NL + |
| 212 |
' Shadow Volumes Possible (stencil buffer, two-sided stencil operations): ' + BoolToStr(GLFeatures.ShadowVolumesPossible, true) + NL + |
| 213 |
' Occlusion Query: ' + BoolToStr(GLFeatures.OcclusionQuery, true) + NL + |
| 214 |
' Texture Max Level: ' + BoolToStr(GLFeatures.TextureMaxLevel, true) + NL + |
| 215 |
NL + |
| 216 |
' Necessary to use deprecated fixed-function pipeline: ' + BoolToStr(GLFeatures.EnableFixedFunction, true) + NL + |
| 217 |
NL + |
| 218 |
' All extensions: ' + GLFeatures.AllExtensions + NL + |
| 219 |
NL + |
| 220 |
|
| 221 |
Section + NL + |
| 222 |
'Bugs:' + NL + |
| 223 |
NL + |
| 224 |
BugsReport(GLVersion) + NL + |
| 225 |
NL + |
| 226 |
|
| 227 |
Section + NL + |
| 228 |
'Current buffers bit depths:' + NL + |
| 229 |
NL + |
| 230 |
' Color buffer (red, green, blue, alpha): ' |
| 231 |
+ IntToStr(GLFeatures.RedBits) +' / ' |
| 232 |
+ IntToStr(GLFeatures.GreenBits) +' / ' |
| 233 |
+ IntToStr(GLFeatures.BlueBits) +' / ' |
| 234 |
+ IntToStr(GLFeatures.AlphaBits) + NL + |
| 235 |
' Depth: ' + IntToStr(GLFeatures.DepthBits) + NL + |
| 236 |
' Stencil: ' + IntToStr(GLFeatures.StencilBits) + NL + |
| 237 |
' Double buffer: ' + BoolToStr(GLFeatures.DoubleBuffer, true) + NL + |
| 238 |
' Multi-sampling (full-screen anti-aliasing) possible: ' + |
| 239 |
BoolToStr(GLFeatures.Multisample, true) + NL + |
| 240 |
' Current: ' + IntToStr(GLFeatures.CurrentMultiSampling) + ' samples per pixel' + NL + |
| 241 |
NL + |
| 242 |
|
| 243 |
Section + NL + |
| 244 |
'Limits:' + NL + |
| 245 |
NL + |
| 246 |
' Max clip planes: ' + IntToStr(GLFeatures.MaxClipPlanes) + NL + |
| 247 |
' Max lights (fixed-function limit): ' + IntToStr(GLFeatures.MaxLights) + NL + |
| 248 |
' Max texture size: ' + IntToStr(GLFeatures.MaxTextureSize) + NL + |
| 249 |
' Max viewport dims (width, height): ' +GLFeatures.MaxViewportDimensions.ToString + NL + |
| 250 |
' Max texture units (shader pipeline): ' + IntToStr(GLFeatures.MaxTextureUnitsShaders) + NL + |
| 251 |
' Max texture units (fixed-function): ' + IntToStr(GLFeatures.MaxTextureUnitsFixedFunction) + NL + |
| 252 |
' Max cube map texture size: ' + IntToStr(GLFeatures.MaxCubeMapTextureSize) + NL + |
| 253 |
' Max 3d texture size: ' + IntToStr(GLFeatures.MaxTexture3DSize) + NL + |
| 254 |
' Max texture max anisotropy: ' + GetMaxTextureMaxAnisotropy + NL + |
| 255 |
' Occlusion query counter bits: ' + GetOcclusionQueryCounterBits + NL + |
| 256 |
' Max renderbuffer size: ' + IntToStr(GLFeatures.MaxRenderbufferSize) + NL + |
| 257 |
' Max line width: ' + GLFeatures.LineWidth.ToString + NL + |
| 258 |
NL + |
| 259 |
|
| 260 |
Section + NL + |
| 261 |
'Memory (in Kb):' + NL + |
| 262 |
NL + |
| 263 |
' Total: ' + IntToStrUnknown(GLFeatures.Memory.Total) + NL + |
| 264 |
' Current: ' + IntToStrUnknown(GLFeatures.Memory.Current) + NL + |
| 265 |
' Current for VBO: ' + IntToStrUnknown(GLFeatures.Memory.CurrentVbo) + NL + |
| 266 |
' Current for Textures: ' + IntToStrUnknown(GLFeatures.Memory.CurrentTexture) + NL + |
| 267 |
' Current for Renderbuffers: ' + IntToStrUnknown(GLFeatures.Memory.CurrentRenderbuffer); |
| 268 |
|
| 269 |
CheckGLErrors('End of GLInformationString'); |
| 270 |
end; |
| 271 |
|
| 272 |
function GLInformationStringSummary: String; |
| 273 |
begin |
| 274 |
Result := Format('%s %d.%d (%s) (modern rendering: %s)', [ |
| 275 |
{$ifdef OpenGLES} 'OpenGLES' {$else} 'OpenGL' {$endif}, |
| 276 |
GLVersion.Major, |
| 277 |
GLVersion.Minor, |
| 278 |
VendorTypeToStr(GLVersion.VendorType), |
| 279 |
BoolToStr(not GLFeatures.EnableFixedFunction, true) |
| 280 |
]); |
| 281 |
end; |
| 282 |
|
| 283 |
{$endif read_implementation} |