twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | |
tomhudson@google.com | 6bf38b5 | 2012-02-14 15:11:59 +0000 | [diff] [blame] | 9 | #include "gl/GrGLInterface.h" |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 10 | #include "gl/GrGLExtensions.h" |
| 11 | #include "gl/GrGLUtil.h" |
twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 12 | |
| 13 | #include <stdio.h> |
| 14 | |
robertphillips@google.com | 15e9d3e | 2012-06-21 20:25:03 +0000 | [diff] [blame] | 15 | SK_DEFINE_INST_COUNT(GrGLInterface) |
| 16 | |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 17 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 18 | namespace { |
| 19 | void GrGLDefaultInterfaceCallback(const GrGLInterface*) {} |
| 20 | } |
| 21 | #endif |
| 22 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 23 | GrGLInterface::GrGLInterface() { |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 24 | fBindingsExported = kNone_GrGLBinding; |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 25 | |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 26 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 27 | fCallback = GrGLDefaultInterfaceCallback; |
| 28 | fCallbackData = 0; |
| 29 | #endif |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 30 | } |
| 31 | |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 32 | bool GrGLInterface::validate(GrGLBinding binding) const { |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 33 | |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 34 | // kNone must be 0 so that the check we're about to do can never succeed if |
| 35 | // binding == kNone. |
| 36 | GR_STATIC_ASSERT(kNone_GrGLBinding == 0); |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 37 | |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 38 | if (0 == (binding & fBindingsExported)) { |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 39 | return false; |
| 40 | } |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 41 | |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 42 | GrGLExtensions extensions; |
| 43 | if (!extensions.init(binding, this)) { |
| 44 | return false; |
| 45 | } |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 46 | |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame] | 47 | bool isCoreProfile = false; |
| 48 | if (kDesktop_GrGLBinding == binding) { |
| 49 | if (NULL == this->fGetIntegerv) { |
| 50 | return false; |
| 51 | } |
| 52 | GrGLint profileMask = 0; |
| 53 | fGetIntegerv(GR_GL_CONTEXT_PROFILE_MASK, &profileMask); |
| 54 | isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); |
| 55 | } |
| 56 | |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 57 | // functions that are always required |
| 58 | if (NULL == fActiveTexture || |
| 59 | NULL == fAttachShader || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 60 | NULL == fBindAttribLocation || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 61 | NULL == fBindBuffer || |
| 62 | NULL == fBindTexture || |
| 63 | NULL == fBlendFunc || |
robertphillips@google.com | e788430 | 2012-04-18 14:39:58 +0000 | [diff] [blame] | 64 | NULL == fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 65 | NULL == fBufferData || |
| 66 | NULL == fBufferSubData || |
| 67 | NULL == fClear || |
| 68 | NULL == fClearColor || |
| 69 | NULL == fClearStencil || |
| 70 | NULL == fColorMask || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 71 | NULL == fCompileShader || |
commit-bot@chromium.org | 98168bb | 2013-04-11 22:00:34 +0000 | [diff] [blame] | 72 | NULL == fCopyTexSubImage2D || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 73 | NULL == fCreateProgram || |
| 74 | NULL == fCreateShader || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 75 | NULL == fCullFace || |
| 76 | NULL == fDeleteBuffers || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 77 | NULL == fDeleteProgram || |
| 78 | NULL == fDeleteShader || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 79 | NULL == fDeleteTextures || |
| 80 | NULL == fDepthMask || |
| 81 | NULL == fDisable || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 82 | NULL == fDisableVertexAttribArray || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 83 | NULL == fDrawArrays || |
| 84 | NULL == fDrawElements || |
| 85 | NULL == fEnable || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 86 | NULL == fEnableVertexAttribArray || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 87 | NULL == fFrontFace || |
| 88 | NULL == fGenBuffers || |
| 89 | NULL == fGenTextures || |
| 90 | NULL == fGetBufferParameteriv || |
commit-bot@chromium.org | cffff79 | 2013-07-26 16:36:04 +0000 | [diff] [blame] | 91 | #ifndef SKIA_IGNORE_GPU_MIPMAPS |
| 92 | NULL == fGenerateMipmap || |
| 93 | #endif |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 94 | NULL == fGetError || |
| 95 | NULL == fGetIntegerv || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 96 | NULL == fGetProgramInfoLog || |
| 97 | NULL == fGetProgramiv || |
| 98 | NULL == fGetShaderInfoLog || |
| 99 | NULL == fGetShaderiv || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 100 | NULL == fGetString || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 101 | NULL == fGetUniformLocation || |
| 102 | NULL == fLinkProgram || |
commit-bot@chromium.org | 941df4f | 2013-08-20 20:54:08 +0000 | [diff] [blame] | 103 | NULL == fLineWidth || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 104 | NULL == fPixelStorei || |
| 105 | NULL == fReadPixels || |
| 106 | NULL == fScissor || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 107 | NULL == fShaderSource || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 108 | NULL == fStencilFunc || |
| 109 | NULL == fStencilMask || |
| 110 | NULL == fStencilOp || |
| 111 | NULL == fTexImage2D || |
| 112 | NULL == fTexParameteri || |
bsalomon@google.com | 4d063de | 2012-05-31 17:59:23 +0000 | [diff] [blame] | 113 | NULL == fTexParameteriv || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 114 | NULL == fTexSubImage2D || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 115 | NULL == fUniform1f || |
| 116 | NULL == fUniform1i || |
| 117 | NULL == fUniform1fv || |
| 118 | NULL == fUniform1iv || |
| 119 | NULL == fUniform2f || |
| 120 | NULL == fUniform2i || |
| 121 | NULL == fUniform2fv || |
| 122 | NULL == fUniform2iv || |
| 123 | NULL == fUniform3f || |
| 124 | NULL == fUniform3i || |
| 125 | NULL == fUniform3fv || |
| 126 | NULL == fUniform3iv || |
| 127 | NULL == fUniform4f || |
| 128 | NULL == fUniform4i || |
| 129 | NULL == fUniform4fv || |
| 130 | NULL == fUniform4iv || |
| 131 | NULL == fUniformMatrix2fv || |
| 132 | NULL == fUniformMatrix3fv || |
| 133 | NULL == fUniformMatrix4fv || |
| 134 | NULL == fUseProgram || |
| 135 | NULL == fVertexAttrib4fv || |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 136 | NULL == fVertexAttribPointer || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 137 | NULL == fViewport || |
| 138 | NULL == fBindFramebuffer || |
| 139 | NULL == fBindRenderbuffer || |
| 140 | NULL == fCheckFramebufferStatus || |
| 141 | NULL == fDeleteFramebuffers || |
| 142 | NULL == fDeleteRenderbuffers || |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 143 | NULL == fFinish || |
| 144 | NULL == fFlush || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 145 | NULL == fFramebufferRenderbuffer || |
| 146 | NULL == fFramebufferTexture2D || |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 147 | NULL == fGetFramebufferAttachmentParameteriv || |
| 148 | NULL == fGetRenderbufferParameteriv || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 149 | NULL == fGenFramebuffers || |
| 150 | NULL == fGenRenderbuffers || |
| 151 | NULL == fRenderbufferStorage) { |
| 152 | return false; |
| 153 | } |
| 154 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 155 | GrGLVersion glVer = GrGLGetVersion(this); |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 156 | |
| 157 | // Now check that baseline ES/Desktop fns not covered above are present |
| 158 | // and that we have fn pointers for any advertised extensions that we will |
| 159 | // try to use. |
| 160 | |
| 161 | // these functions are part of ES2, we assume they are available |
| 162 | // On the desktop we assume they are available if the extension |
| 163 | // is present or GL version is high enough. |
bsalomon@google.com | 791816a | 2013-08-15 18:54:39 +0000 | [diff] [blame] | 164 | if (kES_GrGLBinding == binding) { |
robertphillips@google.com | e788430 | 2012-04-18 14:39:58 +0000 | [diff] [blame] | 165 | if (NULL == fStencilFuncSeparate || |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 166 | NULL == fStencilMaskSeparate || |
| 167 | NULL == fStencilOpSeparate) { |
| 168 | return false; |
| 169 | } |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 170 | } else if (kDesktop_GrGLBinding == binding) { |
robertphillips@google.com | e788430 | 2012-04-18 14:39:58 +0000 | [diff] [blame] | 171 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 172 | if (glVer >= GR_GL_VER(2,0)) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 173 | if (NULL == fStencilFuncSeparate || |
| 174 | NULL == fStencilMaskSeparate || |
| 175 | NULL == fStencilOpSeparate) { |
| 176 | return false; |
| 177 | } |
| 178 | } |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 179 | if (glVer >= GR_GL_VER(3,0) && NULL == fBindFragDataLocation) { |
bsalomon@google.com | bc5cf51 | 2011-09-21 16:21:07 +0000 | [diff] [blame] | 180 | return false; |
| 181 | } |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 182 | if (glVer >= GR_GL_VER(2,0) || extensions.has("GL_ARB_draw_buffers")) { |
bsalomon@google.com | d32c5f5 | 2011-08-02 19:29:03 +0000 | [diff] [blame] | 183 | if (NULL == fDrawBuffers) { |
| 184 | return false; |
| 185 | } |
| 186 | } |
robertphillips@google.com | e788430 | 2012-04-18 14:39:58 +0000 | [diff] [blame] | 187 | |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 188 | if (glVer >= GR_GL_VER(1,5) || extensions.has("GL_ARB_occlusion_query")) { |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 189 | if (NULL == fGenQueries || |
| 190 | NULL == fDeleteQueries || |
| 191 | NULL == fBeginQuery || |
| 192 | NULL == fEndQuery || |
| 193 | NULL == fGetQueryiv || |
| 194 | NULL == fGetQueryObjectiv || |
| 195 | NULL == fGetQueryObjectuiv) { |
| 196 | return false; |
| 197 | } |
| 198 | } |
| 199 | if (glVer >= GR_GL_VER(3,3) || |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 200 | extensions.has("GL_ARB_timer_query") || |
| 201 | extensions.has("GL_EXT_timer_query")) { |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 202 | if (NULL == fGetQueryObjecti64v || |
| 203 | NULL == fGetQueryObjectui64v) { |
| 204 | return false; |
| 205 | } |
| 206 | } |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 207 | if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 208 | if (NULL == fQueryCounter) { |
| 209 | return false; |
| 210 | } |
| 211 | } |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame] | 212 | if (!isCoreProfile) { |
| 213 | if (NULL == fClientActiveTexture || |
| 214 | NULL == fDisableClientState || |
| 215 | NULL == fEnableClientState || |
| 216 | NULL == fLoadIdentity || |
| 217 | NULL == fLoadMatrixf || |
| 218 | NULL == fMatrixMode || |
| 219 | NULL == fTexGenf || |
| 220 | NULL == fTexGenfv || |
| 221 | NULL == fTexGeni || |
| 222 | NULL == fVertexPointer) { |
| 223 | return false; |
| 224 | } |
bsalomon@google.com | fe11cb6 | 2012-06-06 15:17:54 +0000 | [diff] [blame] | 225 | } |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 226 | if (false && extensions.has("GL_NV_path_rendering")) { |
bsalomon@google.com | fe11cb6 | 2012-06-06 15:17:54 +0000 | [diff] [blame] | 227 | if (NULL == fPathCommands || |
| 228 | NULL == fPathCoords || |
| 229 | NULL == fPathSubCommands || |
| 230 | NULL == fPathSubCoords || |
| 231 | NULL == fPathString || |
| 232 | NULL == fPathGlyphs || |
| 233 | NULL == fPathGlyphRange || |
| 234 | NULL == fWeightPaths || |
| 235 | NULL == fCopyPath || |
| 236 | NULL == fInterpolatePaths || |
| 237 | NULL == fTransformPath || |
| 238 | NULL == fPathParameteriv || |
| 239 | NULL == fPathParameteri || |
| 240 | NULL == fPathParameterfv || |
| 241 | NULL == fPathParameterf || |
| 242 | NULL == fPathDashArray || |
| 243 | NULL == fGenPaths || |
| 244 | NULL == fDeletePaths || |
| 245 | NULL == fIsPath || |
| 246 | NULL == fPathStencilFunc || |
| 247 | NULL == fPathStencilDepthOffset || |
| 248 | NULL == fStencilFillPath || |
| 249 | NULL == fStencilStrokePath || |
| 250 | NULL == fStencilFillPathInstanced || |
| 251 | NULL == fStencilStrokePathInstanced || |
| 252 | NULL == fPathCoverDepthFunc || |
| 253 | NULL == fPathColorGen || |
| 254 | NULL == fPathTexGen || |
| 255 | NULL == fPathFogGen || |
| 256 | NULL == fCoverFillPath || |
| 257 | NULL == fCoverStrokePath || |
| 258 | NULL == fCoverFillPathInstanced || |
| 259 | NULL == fCoverStrokePathInstanced || |
| 260 | NULL == fGetPathParameteriv || |
| 261 | NULL == fGetPathParameterfv || |
| 262 | NULL == fGetPathCommands || |
| 263 | NULL == fGetPathCoords || |
| 264 | NULL == fGetPathDashArray || |
| 265 | NULL == fGetPathMetrics || |
| 266 | NULL == fGetPathMetricRange || |
| 267 | NULL == fGetPathSpacing || |
| 268 | NULL == fGetPathColorGeniv || |
| 269 | NULL == fGetPathColorGenfv || |
| 270 | NULL == fGetPathTexGeniv || |
| 271 | NULL == fGetPathTexGenfv || |
| 272 | NULL == fIsPointInFillPath || |
| 273 | NULL == fIsPointInStrokePath || |
| 274 | NULL == fGetPathLength || |
| 275 | NULL == fPointAlongPath) { |
| 276 | return false; |
| 277 | } |
| 278 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | // optional function on desktop before 1.3 |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 282 | if (kDesktop_GrGLBinding != binding || |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 283 | (glVer >= GR_GL_VER(1,3)) || |
| 284 | extensions.has("GL_ARB_texture_compression")) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 285 | if (NULL == fCompressedTexImage2D) { |
| 286 | return false; |
| 287 | } |
| 288 | } |
| 289 | |
bsalomon@google.com | d32c5f5 | 2011-08-02 19:29:03 +0000 | [diff] [blame] | 290 | // part of desktop GL, but not ES |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 291 | if (kDesktop_GrGLBinding == binding && |
commit-bot@chromium.org | 941df4f | 2013-08-20 20:54:08 +0000 | [diff] [blame] | 292 | (NULL == fGetTexLevelParameteriv || |
bsalomon@google.com | c49d66b | 2011-08-03 14:22:30 +0000 | [diff] [blame] | 293 | NULL == fDrawBuffer || |
| 294 | NULL == fReadBuffer)) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 295 | return false; |
| 296 | } |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 297 | |
bsalomon@google.com | 280e99f | 2012-01-05 16:17:38 +0000 | [diff] [blame] | 298 | // GL_EXT_texture_storage is part of desktop 4.2 |
| 299 | // There is a desktop ARB extension and an ES+desktop EXT extension |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 300 | if (kDesktop_GrGLBinding == binding) { |
bsalomon@google.com | baa9ea1 | 2012-01-06 19:05:43 +0000 | [diff] [blame] | 301 | if (glVer >= GR_GL_VER(4,2) || |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 302 | extensions.has("GL_ARB_texture_storage") || |
| 303 | extensions.has("GL_EXT_texture_storage")) { |
bsalomon@google.com | baa9ea1 | 2012-01-06 19:05:43 +0000 | [diff] [blame] | 304 | if (NULL == fTexStorage2D) { |
| 305 | return false; |
| 306 | } |
| 307 | } |
commit-bot@chromium.org | 7a434a2 | 2013-08-21 14:01:56 +0000 | [diff] [blame] | 308 | } else if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_EXT_texture_storage")) { |
bsalomon@google.com | baa9ea1 | 2012-01-06 19:05:43 +0000 | [diff] [blame] | 309 | if (NULL == fTexStorage2D) { |
| 310 | return false; |
| 311 | } |
bsalomon@google.com | 280e99f | 2012-01-05 16:17:38 +0000 | [diff] [blame] | 312 | } |
| 313 | |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 314 | if (extensions.has("GL_EXT_discard_framebuffer")) { |
| 315 | // FIXME: Remove this once Chromium is updated to provide this function |
| 316 | #if 0 |
| 317 | if (NULL == fDiscardFramebuffer) { |
| 318 | return false; |
| 319 | } |
| 320 | #endif |
| 321 | } |
| 322 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 323 | // FBO MSAA |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 324 | if (kDesktop_GrGLBinding == binding) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 325 | // GL 3.0 and the ARB extension have multisample + blit |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 326 | if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 327 | if (NULL == fRenderbufferStorageMultisample || |
| 328 | NULL == fBlitFramebuffer) { |
| 329 | return false; |
| 330 | } |
| 331 | } else { |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 332 | if (extensions.has("GL_EXT_framebuffer_blit") && |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 333 | NULL == fBlitFramebuffer) { |
| 334 | return false; |
| 335 | } |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 336 | if (extensions.has("GL_EXT_framebuffer_multisample") && |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 337 | NULL == fRenderbufferStorageMultisample) { |
| 338 | return false; |
| 339 | } |
| 340 | } |
| 341 | } else { |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 342 | if (extensions.has("GL_CHROMIUM_framebuffer_multisample")) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 343 | if (NULL == fRenderbufferStorageMultisample || |
| 344 | NULL == fBlitFramebuffer) { |
| 345 | return false; |
| 346 | } |
| 347 | } |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 348 | if (extensions.has("GL_APPLE_framebuffer_multisample")) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 349 | if (NULL == fRenderbufferStorageMultisample || |
| 350 | NULL == fResolveMultisampleFramebuffer) { |
| 351 | return false; |
| 352 | } |
| 353 | } |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 354 | if (extensions.has("GL_IMG_multisampled_render_to_texture") || |
| 355 | extensions.has("GL_EXT_multisampled_render_to_texture")) { |
bsalomon@google.com | f3a60c0 | 2013-03-19 19:06:09 +0000 | [diff] [blame] | 356 | if (NULL == fRenderbufferStorageMultisample || |
| 357 | NULL == fFramebufferTexture2DMultisample) { |
| 358 | return false; |
| 359 | } |
| 360 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | // On ES buffer mapping is an extension. On Desktop |
| 364 | // buffer mapping was part of original VBO extension |
| 365 | // which we require. |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 366 | if (kDesktop_GrGLBinding == binding || extensions.has("GL_OES_mapbuffer")) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 367 | if (NULL == fMapBuffer || |
| 368 | NULL == fUnmapBuffer) { |
| 369 | return false; |
| 370 | } |
| 371 | } |
| 372 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 373 | // Dual source blending |
bsalomon@google.com | 89ec61e | 2012-02-10 20:05:18 +0000 | [diff] [blame] | 374 | if (kDesktop_GrGLBinding == binding && |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 375 | (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_blend_func_extended"))) { |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 376 | if (NULL == fBindFragDataLocationIndexed) { |
| 377 | return false; |
| 378 | } |
| 379 | } |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 380 | |
commit-bot@chromium.org | 726e621 | 2013-08-23 20:55:46 +0000 | [diff] [blame] | 381 | // glGetStringi was added in version 3.0 of both desktop and ES. |
| 382 | if (glVer >= GR_GL_VER(3, 0)) { |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 383 | if (NULL == fGetStringi) { |
| 384 | return false; |
| 385 | } |
| 386 | } |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 387 | |
bsalomon@google.com | ecd8484 | 2013-03-01 15:36:02 +0000 | [diff] [blame] | 388 | if (kDesktop_GrGLBinding == binding) { |
| 389 | if (glVer >= GR_GL_VER(3, 0) || extensions.has("GL_ARB_vertex_array_object")) { |
| 390 | if (NULL == fBindVertexArray || |
| 391 | NULL == fDeleteVertexArrays || |
| 392 | NULL == fGenVertexArrays) { |
| 393 | return false; |
| 394 | } |
| 395 | } |
| 396 | } else { |
commit-bot@chromium.org | 2276c01 | 2013-08-16 15:53:33 +0000 | [diff] [blame] | 397 | if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_OES_vertex_array_object")) { |
bsalomon@google.com | ecd8484 | 2013-03-01 15:36:02 +0000 | [diff] [blame] | 398 | if (NULL == fBindVertexArray || |
| 399 | NULL == fDeleteVertexArrays || |
| 400 | NULL == fGenVertexArrays) { |
| 401 | return false; |
| 402 | } |
| 403 | } |
bsalomon@google.com | ecd8484 | 2013-03-01 15:36:02 +0000 | [diff] [blame] | 404 | } |
| 405 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 406 | return true; |
| 407 | } |