epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 10 | #include "GrTypes.h" |
bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 11 | #include "GrGLInterface.h" |
| 12 | #include "GrGLDefines.h" |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 13 | |
| 14 | #include <stdio.h> |
| 15 | |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 16 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 17 | namespace { |
| 18 | void GrGLDefaultInterfaceCallback(const GrGLInterface*) {} |
| 19 | } |
| 20 | #endif |
| 21 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 22 | GrGLVersion GrGLGetVersionFromString(const char* versionString) { |
bsalomon@google.com | edfe1aa | 2011-09-29 14:40:26 +0000 | [diff] [blame^] | 23 | if (NULL == versionString) { |
| 24 | GrAssert(!"NULL GL version string."); |
| 25 | return 0; |
| 26 | } |
| 27 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 28 | int major, minor; |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 29 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 30 | int n = sscanf(versionString, "%d.%d", &major, &minor); |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 31 | if (2 == n) { |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 32 | return GR_GL_VER(major, minor); |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 33 | } |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 34 | |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 35 | char profile[2]; |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 36 | n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1, |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 37 | &major, &minor); |
| 38 | if (4 == n) { |
| 39 | return GR_GL_VER(major, minor); |
| 40 | } |
| 41 | |
| 42 | n = sscanf(versionString, "OpenGL ES %d.%d", &major, &minor); |
| 43 | if (2 == n) { |
| 44 | return GR_GL_VER(major, minor); |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 45 | } |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 46 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 47 | return 0; |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 48 | } |
| 49 | |
bsalomon@google.com | edfe1aa | 2011-09-29 14:40:26 +0000 | [diff] [blame^] | 50 | GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString) { |
| 51 | if (NULL == versionString) { |
| 52 | GrAssert(!"NULL GLSL version string."); |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | int major, minor; |
| 57 | |
| 58 | int n = sscanf(versionString, "%d.%d", &major, &minor); |
| 59 | if (2 == n) { |
| 60 | return GR_GLSL_VER(major, minor); |
| 61 | } |
| 62 | |
| 63 | n = sscanf(versionString, "OpenGL ES GLSL ES %d.%d", &major, &minor); |
| 64 | if (2 == n) { |
| 65 | return GR_GLSL_VER(major, minor); |
| 66 | } |
| 67 | return 0; |
| 68 | } |
| 69 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 70 | bool GrGLHasExtensionFromString(const char* ext, const char* extensionString) { |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 71 | int extLength = strlen(ext); |
| 72 | |
| 73 | while (true) { |
| 74 | int n = strcspn(extensionString, " "); |
| 75 | if (n == extLength && 0 == strncmp(ext, extensionString, n)) { |
| 76 | return true; |
| 77 | } |
| 78 | if (0 == extensionString[n]) { |
| 79 | return false; |
| 80 | } |
| 81 | extensionString += n+1; |
| 82 | } |
| 83 | |
| 84 | return false; |
| 85 | } |
| 86 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 87 | bool GrGLHasExtension(const GrGLInterface* gl, const char* ext) { |
bsalomon@google.com | dca4aab | 2011-09-06 19:05:24 +0000 | [diff] [blame] | 88 | const GrGLubyte* glstr; |
| 89 | GR_GL_CALL_RET(gl, glstr, GetString(GR_GL_EXTENSIONS)); |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 90 | return GrGLHasExtensionFromString(ext, (const char*) glstr); |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 91 | } |
| 92 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 93 | GrGLVersion GrGLGetVersion(const GrGLInterface* gl) { |
bsalomon@google.com | dca4aab | 2011-09-06 19:05:24 +0000 | [diff] [blame] | 94 | const GrGLubyte* v; |
| 95 | GR_GL_CALL_RET(gl, v, GetString(GR_GL_VERSION)); |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 96 | return GrGLGetVersionFromString((const char*) v); |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 97 | } |
| 98 | |
bsalomon@google.com | edfe1aa | 2011-09-29 14:40:26 +0000 | [diff] [blame^] | 99 | GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface* gl) { |
| 100 | const GrGLubyte* v; |
| 101 | GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); |
| 102 | return GrGLGetGLSLVersionFromString((const char*) v); |
| 103 | } |
| 104 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 105 | GrGLInterface::GrGLInterface() { |
| 106 | fBindingsExported = (GrGLBinding)0; |
| 107 | fNPOTRenderTargetSupport = kProbe_GrGLCapability; |
| 108 | fMinRenderTargetHeight = kProbe_GrGLCapability; |
| 109 | fMinRenderTargetWidth = kProbe_GrGLCapability; |
| 110 | |
| 111 | fActiveTexture = NULL; |
| 112 | fAttachShader = NULL; |
| 113 | fBindAttribLocation = NULL; |
| 114 | fBindBuffer = NULL; |
bsalomon@google.com | bc5cf51 | 2011-09-21 16:21:07 +0000 | [diff] [blame] | 115 | fBindFragDataLocation = NULL; |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 116 | fBindTexture = NULL; |
| 117 | fBlendColor = NULL; |
| 118 | fBlendFunc = NULL; |
| 119 | fBufferData = NULL; |
| 120 | fBufferSubData = NULL; |
| 121 | fClear = NULL; |
| 122 | fClearColor = NULL; |
| 123 | fClearStencil = NULL; |
| 124 | fClientActiveTexture = NULL; |
| 125 | fColor4ub = NULL; |
| 126 | fColorMask = NULL; |
| 127 | fColorPointer = NULL; |
| 128 | fCompileShader = NULL; |
| 129 | fCompressedTexImage2D = NULL; |
| 130 | fCreateProgram = NULL; |
| 131 | fCreateShader = NULL; |
| 132 | fCullFace = NULL; |
| 133 | fDeleteBuffers = NULL; |
| 134 | fDeleteProgram = NULL; |
| 135 | fDeleteShader = NULL; |
| 136 | fDeleteTextures = NULL; |
| 137 | fDepthMask = NULL; |
| 138 | fDisable = NULL; |
| 139 | fDisableClientState = NULL; |
| 140 | fDisableVertexAttribArray = NULL; |
| 141 | fDrawArrays = NULL; |
| 142 | fDrawBuffer = NULL; |
| 143 | fDrawBuffers = NULL; |
| 144 | fDrawElements = NULL; |
| 145 | fEnable = NULL; |
| 146 | fEnableClientState = NULL; |
| 147 | fEnableVertexAttribArray = NULL; |
| 148 | fFrontFace = NULL; |
| 149 | fGenBuffers = NULL; |
| 150 | fGenTextures = NULL; |
| 151 | fGetBufferParameteriv = NULL; |
| 152 | fGetError = NULL; |
| 153 | fGetIntegerv = NULL; |
| 154 | fGetProgramInfoLog = NULL; |
| 155 | fGetProgramiv = NULL; |
| 156 | fGetShaderInfoLog = NULL; |
| 157 | fGetShaderiv = NULL; |
| 158 | fGetString = NULL; |
| 159 | fGetTexLevelParameteriv = NULL; |
| 160 | fGetUniformLocation = NULL; |
| 161 | fLineWidth = NULL; |
| 162 | fLinkProgram = NULL; |
| 163 | fLoadMatrixf = NULL; |
| 164 | fMatrixMode = NULL; |
| 165 | fPixelStorei = NULL; |
| 166 | fPointSize = NULL; |
| 167 | fReadBuffer = NULL; |
| 168 | fReadPixels = NULL; |
| 169 | fScissor = NULL; |
| 170 | fShadeModel = NULL; |
| 171 | fShaderSource = NULL; |
| 172 | fStencilFunc = NULL; |
| 173 | fStencilFuncSeparate = NULL; |
| 174 | fStencilMask = NULL; |
| 175 | fStencilMaskSeparate = NULL; |
| 176 | fStencilOp = NULL; |
| 177 | fStencilOpSeparate = NULL; |
| 178 | fTexCoordPointer = NULL; |
| 179 | fTexEnvi = NULL; |
| 180 | fTexImage2D = NULL; |
| 181 | fTexParameteri = NULL; |
| 182 | fTexSubImage2D = NULL; |
| 183 | fUniform1f = NULL; |
| 184 | fUniform1i = NULL; |
| 185 | fUniform1fv = NULL; |
| 186 | fUniform1iv = NULL; |
| 187 | fUniform2f = NULL; |
| 188 | fUniform2i = NULL; |
| 189 | fUniform2fv = NULL; |
| 190 | fUniform2iv = NULL; |
| 191 | fUniform3f = NULL; |
| 192 | fUniform3i = NULL; |
| 193 | fUniform3fv = NULL; |
| 194 | fUniform3iv = NULL; |
| 195 | fUniform4f = NULL; |
| 196 | fUniform4i = NULL; |
| 197 | fUniform4fv = NULL; |
| 198 | fUniform4iv = NULL; |
| 199 | fUniformMatrix2fv = NULL; |
| 200 | fUniformMatrix3fv = NULL; |
| 201 | fUniformMatrix4fv = NULL; |
| 202 | fUseProgram = NULL; |
| 203 | fVertexAttrib4fv = NULL; |
| 204 | fVertexAttribPointer = NULL; |
| 205 | fVertexPointer = NULL; |
| 206 | fViewport = NULL; |
| 207 | fBindFramebuffer = NULL; |
| 208 | fBindRenderbuffer = NULL; |
| 209 | fCheckFramebufferStatus = NULL; |
| 210 | fDeleteFramebuffers = NULL; |
| 211 | fDeleteRenderbuffers = NULL; |
| 212 | fFramebufferRenderbuffer = NULL; |
| 213 | fFramebufferTexture2D = NULL; |
| 214 | fGenFramebuffers = NULL; |
| 215 | fGenRenderbuffers = NULL; |
| 216 | fGetFramebufferAttachmentParameteriv = NULL; |
| 217 | fGetRenderbufferParameteriv = NULL; |
| 218 | fRenderbufferStorage = NULL; |
| 219 | fRenderbufferStorageMultisample = NULL; |
| 220 | fBlitFramebuffer = NULL; |
| 221 | fResolveMultisampleFramebuffer = NULL; |
| 222 | fMapBuffer = NULL; |
| 223 | fUnmapBuffer = NULL; |
| 224 | fBindFragDataLocationIndexed = NULL; |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 225 | |
| 226 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 227 | fCallback = GrGLDefaultInterfaceCallback; |
| 228 | fCallbackData = 0; |
| 229 | #endif |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 233 | bool GrGLInterface::validateShaderFunctions() const { |
| 234 | // required for GrGpuGLShaders |
| 235 | if (NULL == fAttachShader || |
| 236 | NULL == fBindAttribLocation || |
| 237 | NULL == fCompileShader || |
| 238 | NULL == fCreateProgram || |
| 239 | NULL == fCreateShader || |
| 240 | NULL == fDeleteProgram || |
| 241 | NULL == fDeleteShader || |
| 242 | NULL == fDisableVertexAttribArray || |
| 243 | NULL == fEnableVertexAttribArray || |
| 244 | NULL == fGetProgramInfoLog || |
| 245 | NULL == fGetProgramiv || |
| 246 | NULL == fGetShaderInfoLog || |
| 247 | NULL == fGetShaderiv || |
| 248 | NULL == fGetUniformLocation || |
| 249 | NULL == fLinkProgram || |
| 250 | NULL == fShaderSource || |
| 251 | NULL == fUniform1f || |
| 252 | NULL == fUniform1i || |
| 253 | NULL == fUniform1fv || |
| 254 | NULL == fUniform1iv || |
| 255 | NULL == fUniform2f || |
| 256 | NULL == fUniform2i || |
| 257 | NULL == fUniform2fv || |
| 258 | NULL == fUniform2iv || |
| 259 | NULL == fUniform3f || |
| 260 | NULL == fUniform3i || |
| 261 | NULL == fUniform3fv || |
| 262 | NULL == fUniform3iv || |
| 263 | NULL == fUniform4f || |
| 264 | NULL == fUniform4i || |
| 265 | NULL == fUniform4fv || |
| 266 | NULL == fUniform4iv || |
| 267 | NULL == fUniformMatrix2fv || |
| 268 | NULL == fUniformMatrix3fv || |
| 269 | NULL == fUniformMatrix4fv || |
| 270 | NULL == fUseProgram || |
| 271 | NULL == fVertexAttrib4fv || |
| 272 | NULL == fVertexAttribPointer) { |
| 273 | return false; |
| 274 | } |
| 275 | return true; |
| 276 | } |
| 277 | |
| 278 | bool GrGLInterface::validateFixedFunctions() const { |
| 279 | if (NULL == fClientActiveTexture || |
| 280 | NULL == fColor4ub || |
| 281 | NULL == fColorPointer || |
| 282 | NULL == fDisableClientState || |
| 283 | NULL == fEnableClientState || |
| 284 | NULL == fLoadMatrixf || |
| 285 | NULL == fMatrixMode || |
| 286 | NULL == fPointSize || |
| 287 | NULL == fShadeModel || |
| 288 | NULL == fTexCoordPointer || |
bsalomon@google.com | 4b9b6a2 | 2011-05-04 15:01:16 +0000 | [diff] [blame] | 289 | NULL == fTexEnvi || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 290 | NULL == fVertexPointer) { |
| 291 | return false; |
| 292 | } |
| 293 | return true; |
| 294 | } |
| 295 | |
| 296 | bool GrGLInterface::validate(GrEngine engine) const { |
| 297 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 298 | bool isDesktop = this->supportsDesktop(); |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 299 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 300 | bool isES = this->supportsES(); |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 301 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 302 | if (isDesktop == isES) { |
| 303 | // must have one, don't support both in same interface |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 304 | return false; |
| 305 | } |
| 306 | |
| 307 | // functions that are always required |
| 308 | if (NULL == fActiveTexture || |
| 309 | NULL == fBindBuffer || |
| 310 | NULL == fBindTexture || |
| 311 | NULL == fBlendFunc || |
| 312 | NULL == fBufferData || |
| 313 | NULL == fBufferSubData || |
| 314 | NULL == fClear || |
| 315 | NULL == fClearColor || |
| 316 | NULL == fClearStencil || |
| 317 | NULL == fColorMask || |
| 318 | NULL == fCullFace || |
| 319 | NULL == fDeleteBuffers || |
| 320 | NULL == fDeleteTextures || |
| 321 | NULL == fDepthMask || |
| 322 | NULL == fDisable || |
| 323 | NULL == fDrawArrays || |
| 324 | NULL == fDrawElements || |
| 325 | NULL == fEnable || |
| 326 | NULL == fFrontFace || |
| 327 | NULL == fGenBuffers || |
| 328 | NULL == fGenTextures || |
| 329 | NULL == fGetBufferParameteriv || |
| 330 | NULL == fGetError || |
| 331 | NULL == fGetIntegerv || |
| 332 | NULL == fGetString || |
| 333 | NULL == fPixelStorei || |
| 334 | NULL == fReadPixels || |
| 335 | NULL == fScissor || |
| 336 | NULL == fStencilFunc || |
| 337 | NULL == fStencilMask || |
| 338 | NULL == fStencilOp || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 339 | NULL == fTexImage2D || |
| 340 | NULL == fTexParameteri || |
| 341 | NULL == fTexSubImage2D || |
| 342 | NULL == fViewport || |
| 343 | NULL == fBindFramebuffer || |
| 344 | NULL == fBindRenderbuffer || |
| 345 | NULL == fCheckFramebufferStatus || |
| 346 | NULL == fDeleteFramebuffers || |
| 347 | NULL == fDeleteRenderbuffers || |
| 348 | NULL == fFramebufferRenderbuffer || |
| 349 | NULL == fFramebufferTexture2D || |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 350 | NULL == fGetFramebufferAttachmentParameteriv || |
| 351 | NULL == fGetRenderbufferParameteriv || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 352 | NULL == fGenFramebuffers || |
| 353 | NULL == fGenRenderbuffers || |
| 354 | NULL == fRenderbufferStorage) { |
| 355 | return false; |
| 356 | } |
| 357 | |
| 358 | switch (engine) { |
| 359 | case kOpenGL_Shaders_GrEngine: |
| 360 | if (kES1_GrGLBinding == fBindingsExported) { |
| 361 | return false; |
| 362 | } |
| 363 | if (!this->validateShaderFunctions()) { |
| 364 | return false; |
| 365 | } |
| 366 | break; |
| 367 | case kOpenGL_Fixed_GrEngine: |
| 368 | if (kES1_GrGLBinding == fBindingsExported) { |
| 369 | return false; |
| 370 | } |
| 371 | if (!this->validateFixedFunctions()) { |
| 372 | return false; |
| 373 | } |
| 374 | break; |
| 375 | default: |
| 376 | return false; |
| 377 | } |
| 378 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 379 | const char* ext; |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 380 | GrGLVersion glVer = GrGLGetVersion(this); |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 381 | ext = (const char*)fGetString(GR_GL_EXTENSIONS); |
| 382 | |
| 383 | // Now check that baseline ES/Desktop fns not covered above are present |
| 384 | // and that we have fn pointers for any advertised extensions that we will |
| 385 | // try to use. |
| 386 | |
| 387 | // these functions are part of ES2, we assume they are available |
| 388 | // On the desktop we assume they are available if the extension |
| 389 | // is present or GL version is high enough. |
| 390 | if ((kES2_GrGLBinding & fBindingsExported)) { |
| 391 | if (NULL == fBlendColor || |
| 392 | NULL == fStencilFuncSeparate || |
| 393 | NULL == fStencilMaskSeparate || |
| 394 | NULL == fStencilOpSeparate) { |
| 395 | return false; |
| 396 | } |
| 397 | } else if (kDesktop_GrGLBinding == fBindingsExported) { |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 398 | if (glVer >= GR_GL_VER(2,0)) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 399 | if (NULL == fStencilFuncSeparate || |
| 400 | NULL == fStencilMaskSeparate || |
| 401 | NULL == fStencilOpSeparate) { |
| 402 | return false; |
| 403 | } |
| 404 | } |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 405 | if (glVer >= GR_GL_VER(3,0) && NULL == fBindFragDataLocation) { |
bsalomon@google.com | bc5cf51 | 2011-09-21 16:21:07 +0000 | [diff] [blame] | 406 | return false; |
| 407 | } |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 408 | if (glVer >= GR_GL_VER(2,0) || |
| 409 | GrGLHasExtensionFromString("GL_ARB_draw_buffers", ext)) { |
bsalomon@google.com | d32c5f5 | 2011-08-02 19:29:03 +0000 | [diff] [blame] | 410 | if (NULL == fDrawBuffers) { |
| 411 | return false; |
| 412 | } |
| 413 | } |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 414 | if (glVer >= GR_GL_VER(1,4) || |
| 415 | GrGLHasExtensionFromString("GL_EXT_blend_color", ext)) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 416 | if (NULL == fBlendColor) { |
| 417 | return false; |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | // optional function on desktop before 1.3 |
| 423 | if (kDesktop_GrGLBinding != fBindingsExported || |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 424 | (glVer >= GR_GL_VER(1,3) || |
| 425 | GrGLHasExtensionFromString("GL_ARB_texture_compression", ext))) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 426 | if (NULL == fCompressedTexImage2D) { |
| 427 | return false; |
| 428 | } |
| 429 | } |
| 430 | |
bsalomon@google.com | d32c5f5 | 2011-08-02 19:29:03 +0000 | [diff] [blame] | 431 | // part of desktop GL, but not ES |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 432 | if (kDesktop_GrGLBinding == fBindingsExported && |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 433 | (NULL == fLineWidth || |
bsalomon@google.com | d32c5f5 | 2011-08-02 19:29:03 +0000 | [diff] [blame] | 434 | NULL == fGetTexLevelParameteriv || |
bsalomon@google.com | c49d66b | 2011-08-03 14:22:30 +0000 | [diff] [blame] | 435 | NULL == fDrawBuffer || |
| 436 | NULL == fReadBuffer)) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 437 | return false; |
| 438 | } |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 439 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 440 | // FBO MSAA |
| 441 | if (kDesktop_GrGLBinding == fBindingsExported) { |
| 442 | // GL 3.0 and the ARB extension have multisample + blit |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 443 | if (glVer >= GR_GL_VER(3,0) || GrGLHasExtensionFromString("GL_ARB_framebuffer_object", ext)) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 444 | if (NULL == fRenderbufferStorageMultisample || |
| 445 | NULL == fBlitFramebuffer) { |
| 446 | return false; |
| 447 | } |
| 448 | } else { |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 449 | if (GrGLHasExtensionFromString("GL_EXT_framebuffer_blit", ext) && |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 450 | NULL == fBlitFramebuffer) { |
| 451 | return false; |
| 452 | } |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 453 | if (GrGLHasExtensionFromString("GL_EXT_framebuffer_multisample", ext) && |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 454 | NULL == fRenderbufferStorageMultisample) { |
| 455 | return false; |
| 456 | } |
| 457 | } |
| 458 | } else { |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 459 | if (GrGLHasExtensionFromString("GL_CHROMIUM_framebuffer_multisample", ext)) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 460 | if (NULL == fRenderbufferStorageMultisample || |
| 461 | NULL == fBlitFramebuffer) { |
| 462 | return false; |
| 463 | } |
| 464 | } |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 465 | if (GrGLHasExtensionFromString("GL_APPLE_framebuffer_multisample", ext)) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 466 | if (NULL == fRenderbufferStorageMultisample || |
| 467 | NULL == fResolveMultisampleFramebuffer) { |
| 468 | return false; |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | // On ES buffer mapping is an extension. On Desktop |
| 474 | // buffer mapping was part of original VBO extension |
| 475 | // which we require. |
| 476 | if (kDesktop_GrGLBinding == fBindingsExported || |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 477 | GrGLHasExtensionFromString("GL_OES_mapbuffer", ext)) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 478 | if (NULL == fMapBuffer || |
| 479 | NULL == fUnmapBuffer) { |
| 480 | return false; |
| 481 | } |
| 482 | } |
| 483 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 484 | // Dual source blending |
| 485 | if (kDesktop_GrGLBinding == fBindingsExported && |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 486 | (glVer >= GR_GL_VER(3,3) || |
| 487 | GrGLHasExtensionFromString("GL_ARB_blend_func_extended", ext))) { |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 488 | if (NULL == fBindFragDataLocationIndexed) { |
| 489 | return false; |
| 490 | } |
| 491 | } |
| 492 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 493 | return true; |
| 494 | } |
| 495 | |