| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "gl/GrGLInterface.h" | 9 #include "gl/GrGLInterface.h" |
| 10 #include "gl/GrGLExtensions.h" | 10 #include "gl/GrGLExtensions.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 fCallbackData = 0; | 26 fCallbackData = 0; |
| 27 #endif | 27 #endif |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool GrGLInterface::validate() const { | 30 bool GrGLInterface::validate() const { |
| 31 | 31 |
| 32 if (kNone_GrGLStandard == fStandard) { | 32 if (kNone_GrGLStandard == fStandard) { |
| 33 return false; | 33 return false; |
| 34 } | 34 } |
| 35 | 35 |
| 36 GrGLExtensions extensions; | 36 // This const hackery is necessary because the factories in Chromium do not
yet initialize |
| 37 if (!extensions.init(this)) { | 37 // fExtensions. |
| 38 return false; | 38 if (!fExtensions.isInitialized()) { |
| 39 GrGLExtensions* extensions = const_cast<GrGLExtensions*>(&fExtensions); |
| 40 if (!extensions->init(fStandard, fGetString, fGetStringi, fGetIntegerv))
{ |
| 41 return false; |
| 42 } |
| 39 } | 43 } |
| 40 | 44 |
| 41 // functions that are always required | 45 // functions that are always required |
| 42 if (NULL == fActiveTexture || | 46 if (NULL == fActiveTexture || |
| 43 NULL == fAttachShader || | 47 NULL == fAttachShader || |
| 44 NULL == fBindAttribLocation || | 48 NULL == fBindAttribLocation || |
| 45 NULL == fBindBuffer || | 49 NULL == fBindBuffer || |
| 46 NULL == fBindTexture || | 50 NULL == fBindTexture || |
| 47 NULL == fBlendFunc || | 51 NULL == fBlendFunc || |
| 48 NULL == fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension | 52 NULL == fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 GrGLVersion glVer = GrGLGetVersion(this); | 141 GrGLVersion glVer = GrGLGetVersion(this); |
| 138 | 142 |
| 139 bool isCoreProfile = false; | 143 bool isCoreProfile = false; |
| 140 if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,2)) { | 144 if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,2)) { |
| 141 GrGLint profileMask; | 145 GrGLint profileMask; |
| 142 GR_GL_GetIntegerv(this, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); | 146 GR_GL_GetIntegerv(this, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); |
| 143 isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); | 147 isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); |
| 144 } | 148 } |
| 145 | 149 |
| 146 // Now check that baseline ES/Desktop fns not covered above are present | 150 // Now check that baseline ES/Desktop fns not covered above are present |
| 147 // and that we have fn pointers for any advertised extensions that we will | 151 // and that we have fn pointers for any advertised fExtensions that we will |
| 148 // try to use. | 152 // try to use. |
| 149 | 153 |
| 150 // these functions are part of ES2, we assume they are available | 154 // these functions are part of ES2, we assume they are available |
| 151 // On the desktop we assume they are available if the extension | 155 // On the desktop we assume they are available if the extension |
| 152 // is present or GL version is high enough. | 156 // is present or GL version is high enough. |
| 153 if (kGLES_GrGLStandard == fStandard) { | 157 if (kGLES_GrGLStandard == fStandard) { |
| 154 if (NULL == fStencilFuncSeparate || | 158 if (NULL == fStencilFuncSeparate || |
| 155 NULL == fStencilMaskSeparate || | 159 NULL == fStencilMaskSeparate || |
| 156 NULL == fStencilOpSeparate) { | 160 NULL == fStencilOpSeparate) { |
| 157 return false; | 161 return false; |
| 158 } | 162 } |
| 159 } else if (kGL_GrGLStandard == fStandard) { | 163 } else if (kGL_GrGLStandard == fStandard) { |
| 160 | 164 |
| 161 if (glVer >= GR_GL_VER(2,0)) { | 165 if (glVer >= GR_GL_VER(2,0)) { |
| 162 if (NULL == fStencilFuncSeparate || | 166 if (NULL == fStencilFuncSeparate || |
| 163 NULL == fStencilMaskSeparate || | 167 NULL == fStencilMaskSeparate || |
| 164 NULL == fStencilOpSeparate) { | 168 NULL == fStencilOpSeparate) { |
| 165 return false; | 169 return false; |
| 166 } | 170 } |
| 167 } | 171 } |
| 168 if (glVer >= GR_GL_VER(3,0) && NULL == fBindFragDataLocation) { | 172 if (glVer >= GR_GL_VER(3,0) && NULL == fBindFragDataLocation) { |
| 169 return false; | 173 return false; |
| 170 } | 174 } |
| 171 if (glVer >= GR_GL_VER(2,0) || extensions.has("GL_ARB_draw_buffers")) { | 175 if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) { |
| 172 if (NULL == fDrawBuffers) { | 176 if (NULL == fDrawBuffers) { |
| 173 return false; | 177 return false; |
| 174 } | 178 } |
| 175 } | 179 } |
| 176 | 180 |
| 177 if (glVer >= GR_GL_VER(1,5) || extensions.has("GL_ARB_occlusion_query"))
{ | 181 if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")
) { |
| 178 if (NULL == fGenQueries || | 182 if (NULL == fGenQueries || |
| 179 NULL == fDeleteQueries || | 183 NULL == fDeleteQueries || |
| 180 NULL == fBeginQuery || | 184 NULL == fBeginQuery || |
| 181 NULL == fEndQuery || | 185 NULL == fEndQuery || |
| 182 NULL == fGetQueryiv || | 186 NULL == fGetQueryiv || |
| 183 NULL == fGetQueryObjectiv || | 187 NULL == fGetQueryObjectiv || |
| 184 NULL == fGetQueryObjectuiv) { | 188 NULL == fGetQueryObjectuiv) { |
| 185 return false; | 189 return false; |
| 186 } | 190 } |
| 187 } | 191 } |
| 188 if (glVer >= GR_GL_VER(3,3) || | 192 if (glVer >= GR_GL_VER(3,3) || |
| 189 extensions.has("GL_ARB_timer_query") || | 193 fExtensions.has("GL_ARB_timer_query") || |
| 190 extensions.has("GL_EXT_timer_query")) { | 194 fExtensions.has("GL_EXT_timer_query")) { |
| 191 if (NULL == fGetQueryObjecti64v || | 195 if (NULL == fGetQueryObjecti64v || |
| 192 NULL == fGetQueryObjectui64v) { | 196 NULL == fGetQueryObjectui64v) { |
| 193 return false; | 197 return false; |
| 194 } | 198 } |
| 195 } | 199 } |
| 196 if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { | 200 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) { |
| 197 if (NULL == fQueryCounter) { | 201 if (NULL == fQueryCounter) { |
| 198 return false; | 202 return false; |
| 199 } | 203 } |
| 200 } | 204 } |
| 201 if (!isCoreProfile) { | 205 if (!isCoreProfile) { |
| 202 if (NULL == fClientActiveTexture || | 206 if (NULL == fClientActiveTexture || |
| 203 NULL == fDisableClientState || | 207 NULL == fDisableClientState || |
| 204 NULL == fEnableClientState || | 208 NULL == fEnableClientState || |
| 205 NULL == fLoadIdentity || | 209 NULL == fLoadIdentity || |
| 206 NULL == fLoadMatrixf || | 210 NULL == fLoadMatrixf || |
| 207 NULL == fMatrixMode || | 211 NULL == fMatrixMode || |
| 208 NULL == fTexGenf || | 212 NULL == fTexGenf || |
| 209 NULL == fTexGenfv || | 213 NULL == fTexGenfv || |
| 210 NULL == fTexGeni || | 214 NULL == fTexGeni || |
| 211 NULL == fVertexPointer) { | 215 NULL == fVertexPointer) { |
| 212 return false; | 216 return false; |
| 213 } | 217 } |
| 214 } | 218 } |
| 215 if (false && extensions.has("GL_NV_path_rendering")) { | 219 if (false && fExtensions.has("GL_NV_path_rendering")) { |
| 216 if (NULL == fPathCommands || | 220 if (NULL == fPathCommands || |
| 217 NULL == fPathCoords || | 221 NULL == fPathCoords || |
| 218 NULL == fPathSubCommands || | 222 NULL == fPathSubCommands || |
| 219 NULL == fPathSubCoords || | 223 NULL == fPathSubCoords || |
| 220 NULL == fPathString || | 224 NULL == fPathString || |
| 221 NULL == fPathGlyphs || | 225 NULL == fPathGlyphs || |
| 222 NULL == fPathGlyphRange || | 226 NULL == fPathGlyphRange || |
| 223 NULL == fWeightPaths || | 227 NULL == fWeightPaths || |
| 224 NULL == fCopyPath || | 228 NULL == fCopyPath || |
| 225 NULL == fInterpolatePaths || | 229 NULL == fInterpolatePaths || |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 NULL == fGetPathLength || | 267 NULL == fGetPathLength || |
| 264 NULL == fPointAlongPath) { | 268 NULL == fPointAlongPath) { |
| 265 return false; | 269 return false; |
| 266 } | 270 } |
| 267 } | 271 } |
| 268 } | 272 } |
| 269 | 273 |
| 270 // optional function on desktop before 1.3 | 274 // optional function on desktop before 1.3 |
| 271 if (kGL_GrGLStandard != fStandard || | 275 if (kGL_GrGLStandard != fStandard || |
| 272 (glVer >= GR_GL_VER(1,3)) || | 276 (glVer >= GR_GL_VER(1,3)) || |
| 273 extensions.has("GL_ARB_texture_compression")) { | 277 fExtensions.has("GL_ARB_texture_compression")) { |
| 274 if (NULL == fCompressedTexImage2D) { | 278 if (NULL == fCompressedTexImage2D) { |
| 275 return false; | 279 return false; |
| 276 } | 280 } |
| 277 } | 281 } |
| 278 | 282 |
| 279 // part of desktop GL, but not ES | 283 // part of desktop GL, but not ES |
| 280 if (kGL_GrGLStandard == fStandard && | 284 if (kGL_GrGLStandard == fStandard && |
| 281 (NULL == fGetTexLevelParameteriv || | 285 (NULL == fGetTexLevelParameteriv || |
| 282 NULL == fDrawBuffer || | 286 NULL == fDrawBuffer || |
| 283 NULL == fReadBuffer)) { | 287 NULL == fReadBuffer)) { |
| 284 return false; | 288 return false; |
| 285 } | 289 } |
| 286 | 290 |
| 287 // GL_EXT_texture_storage is part of desktop 4.2 | 291 // GL_EXT_texture_storage is part of desktop 4.2 |
| 288 // There is a desktop ARB extension and an ES+desktop EXT extension | 292 // There is a desktop ARB extension and an ES+desktop EXT extension |
| 289 if (kGL_GrGLStandard == fStandard) { | 293 if (kGL_GrGLStandard == fStandard) { |
| 290 if (glVer >= GR_GL_VER(4,2) || | 294 if (glVer >= GR_GL_VER(4,2) || |
| 291 extensions.has("GL_ARB_texture_storage") || | 295 fExtensions.has("GL_ARB_texture_storage") || |
| 292 extensions.has("GL_EXT_texture_storage")) { | 296 fExtensions.has("GL_EXT_texture_storage")) { |
| 293 if (NULL == fTexStorage2D) { | 297 if (NULL == fTexStorage2D) { |
| 294 return false; | 298 return false; |
| 295 } | 299 } |
| 296 } | 300 } |
| 297 } else if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_EXT_texture_storage
")) { | 301 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storag
e")) { |
| 298 if (NULL == fTexStorage2D) { | 302 if (NULL == fTexStorage2D) { |
| 299 return false; | 303 return false; |
| 300 } | 304 } |
| 301 } | 305 } |
| 302 | 306 |
| 303 if (extensions.has("GL_EXT_discard_framebuffer")) { | 307 if (fExtensions.has("GL_EXT_discard_framebuffer")) { |
| 304 // FIXME: Remove this once Chromium is updated to provide this function | 308 // FIXME: Remove this once Chromium is updated to provide this function |
| 305 #if 0 | 309 #if 0 |
| 306 if (NULL == fDiscardFramebuffer) { | 310 if (NULL == fDiscardFramebuffer) { |
| 307 return false; | 311 return false; |
| 308 } | 312 } |
| 309 #endif | 313 #endif |
| 310 } | 314 } |
| 311 | 315 |
| 312 // FBO MSAA | 316 // FBO MSAA |
| 313 if (kGL_GrGLStandard == fStandard) { | 317 if (kGL_GrGLStandard == fStandard) { |
| 314 // GL 3.0 and the ARB extension have multisample + blit | 318 // GL 3.0 and the ARB extension have multisample + blit |
| 315 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object
")) { | 319 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_objec
t")) { |
| 316 if (NULL == fRenderbufferStorageMultisample || | 320 if (NULL == fRenderbufferStorageMultisample || |
| 317 NULL == fBlitFramebuffer) { | 321 NULL == fBlitFramebuffer) { |
| 318 return false; | 322 return false; |
| 319 } | 323 } |
| 320 } else { | 324 } else { |
| 321 if (extensions.has("GL_EXT_framebuffer_blit") && | 325 if (fExtensions.has("GL_EXT_framebuffer_blit") && |
| 322 NULL == fBlitFramebuffer) { | 326 NULL == fBlitFramebuffer) { |
| 323 return false; | 327 return false; |
| 324 } | 328 } |
| 325 if (extensions.has("GL_EXT_framebuffer_multisample") && | 329 if (fExtensions.has("GL_EXT_framebuffer_multisample") && |
| 326 NULL == fRenderbufferStorageMultisample) { | 330 NULL == fRenderbufferStorageMultisample) { |
| 327 return false; | 331 return false; |
| 328 } | 332 } |
| 329 } | 333 } |
| 330 } else { | 334 } else { |
| 331 #if GR_GL_IGNORE_ES3_MSAA | 335 #if GR_GL_IGNORE_ES3_MSAA |
| 332 if (extensions.has("GL_CHROMIUM_framebuffer_multisample")) { | 336 if (fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) { |
| 333 if (NULL == fRenderbufferStorageMultisample || | 337 if (NULL == fRenderbufferStorageMultisample || |
| 334 NULL == fBlitFramebuffer) { | 338 NULL == fBlitFramebuffer) { |
| 335 return false; | 339 return false; |
| 336 } | 340 } |
| 337 } else if (extensions.has("GL_APPLE_framebuffer_multisample")) { | 341 } else if (fExtensions.has("GL_APPLE_framebuffer_multisample")) { |
| 338 if (NULL == fRenderbufferStorageMultisample || | 342 if (NULL == fRenderbufferStorageMultisample || |
| 339 NULL == fResolveMultisampleFramebuffer) { | 343 NULL == fResolveMultisampleFramebuffer) { |
| 340 return false; | 344 return false; |
| 341 } | 345 } |
| 342 } else if (extensions.has("GL_IMG_multisampled_render_to_texture") || | 346 } else if (fExtensions.has("GL_IMG_multisampled_render_to_texture") || |
| 343 extensions.has("GL_EXT_multisampled_render_to_texture")) { | 347 fExtensions.has("GL_EXT_multisampled_render_to_texture")) { |
| 344 if (NULL == fRenderbufferStorageMultisample || | 348 if (NULL == fRenderbufferStorageMultisample || |
| 345 NULL == fFramebufferTexture2DMultisample) { | 349 NULL == fFramebufferTexture2DMultisample) { |
| 346 return false; | 350 return false; |
| 347 } | 351 } |
| 348 } | 352 } |
| 349 #else | 353 #else |
| 350 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_CHROMIUM_framebuffer_m
ultisample")) { | 354 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_
multisample")) { |
| 351 if (NULL == fRenderbufferStorageMultisample || | 355 if (NULL == fRenderbufferStorageMultisample || |
| 352 NULL == fBlitFramebuffer) { | 356 NULL == fBlitFramebuffer) { |
| 353 return false; | 357 return false; |
| 354 } | 358 } |
| 355 } | 359 } |
| 356 if (extensions.has("GL_APPLE_framebuffer_multisample")) { | 360 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) { |
| 357 if (NULL == fRenderbufferStorageMultisampleES2APPLE || | 361 if (NULL == fRenderbufferStorageMultisampleES2APPLE || |
| 358 NULL == fResolveMultisampleFramebuffer) { | 362 NULL == fResolveMultisampleFramebuffer) { |
| 359 return false; | 363 return false; |
| 360 } | 364 } |
| 361 } | 365 } |
| 362 if (extensions.has("GL_IMG_multisampled_render_to_texture") || | 366 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") || |
| 363 extensions.has("GL_EXT_multisampled_render_to_texture")) { | 367 fExtensions.has("GL_EXT_multisampled_render_to_texture")) { |
| 364 if (NULL == fRenderbufferStorageMultisampleES2EXT || | 368 if (NULL == fRenderbufferStorageMultisampleES2EXT || |
| 365 NULL == fFramebufferTexture2DMultisample) { | 369 NULL == fFramebufferTexture2DMultisample) { |
| 366 return false; | 370 return false; |
| 367 } | 371 } |
| 368 } | 372 } |
| 369 #endif | 373 #endif |
| 370 } | 374 } |
| 371 | 375 |
| 372 // On ES buffer mapping is an extension. On Desktop | 376 // On ES buffer mapping is an extension. On Desktop |
| 373 // buffer mapping was part of original VBO extension | 377 // buffer mapping was part of original VBO extension |
| 374 // which we require. | 378 // which we require. |
| 375 if (kGL_GrGLStandard == fStandard || extensions.has("GL_OES_mapbuffer")) { | 379 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) { |
| 376 if (NULL == fMapBuffer || | 380 if (NULL == fMapBuffer || |
| 377 NULL == fUnmapBuffer) { | 381 NULL == fUnmapBuffer) { |
| 378 return false; | 382 return false; |
| 379 } | 383 } |
| 380 } | 384 } |
| 381 | 385 |
| 382 // Dual source blending | 386 // Dual source blending |
| 383 if (kGL_GrGLStandard == fStandard && | 387 if (kGL_GrGLStandard == fStandard && |
| 384 (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_blend_func_extended")
)) { | 388 (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"
))) { |
| 385 if (NULL == fBindFragDataLocationIndexed) { | 389 if (NULL == fBindFragDataLocationIndexed) { |
| 386 return false; | 390 return false; |
| 387 } | 391 } |
| 388 } | 392 } |
| 389 | 393 |
| 390 // glGetStringi was added in version 3.0 of both desktop and ES. | 394 // glGetStringi was added in version 3.0 of both desktop and ES. |
| 391 if (glVer >= GR_GL_VER(3, 0)) { | 395 if (glVer >= GR_GL_VER(3, 0)) { |
| 392 if (NULL == fGetStringi) { | 396 if (NULL == fGetStringi) { |
| 393 return false; | 397 return false; |
| 394 } | 398 } |
| 395 } | 399 } |
| 396 | 400 |
| 397 if (kGL_GrGLStandard == fStandard) { | 401 if (kGL_GrGLStandard == fStandard) { |
| 398 if (glVer >= GR_GL_VER(3, 0) || extensions.has("GL_ARB_vertex_array_obje
ct")) { | 402 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_obj
ect")) { |
| 399 if (NULL == fBindVertexArray || | 403 if (NULL == fBindVertexArray || |
| 400 NULL == fDeleteVertexArrays || | 404 NULL == fDeleteVertexArrays || |
| 401 NULL == fGenVertexArrays) { | 405 NULL == fGenVertexArrays) { |
| 402 return false; | 406 return false; |
| 403 } | 407 } |
| 404 } | 408 } |
| 405 } else { | 409 } else { |
| 406 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_OES_vertex_array_objec
t")) { | 410 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_obje
ct")) { |
| 407 if (NULL == fBindVertexArray || | 411 if (NULL == fBindVertexArray || |
| 408 NULL == fDeleteVertexArrays || | 412 NULL == fDeleteVertexArrays || |
| 409 NULL == fGenVertexArrays) { | 413 NULL == fGenVertexArrays) { |
| 410 return false; | 414 return false; |
| 411 } | 415 } |
| 412 } | 416 } |
| 413 } | 417 } |
| 414 | 418 |
| 415 return true; | 419 return true; |
| 416 } | 420 } |
| OLD | NEW |