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