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