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 | |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 15 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 16 | namespace { |
| 17 | void GrGLDefaultInterfaceCallback(const GrGLInterface*) {} |
| 18 | } |
| 19 | #endif |
| 20 | |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 21 | const GrGLInterface* GrGLInterfaceAddTestDebugMarker(const GrGLInterface* interface, |
| 22 | GrGLInsertEventMarkerProc insertEventMarkerFn, |
| 23 | GrGLPushGroupMarkerProc pushGroupMarkerFn, |
| 24 | GrGLPopGroupMarkerProc popGroupMarkerFn) { |
| 25 | GrGLInterface* newInterface = GrGLInterface::NewClone(interface); |
| 26 | |
| 27 | if (!newInterface->fExtensions.has("GL_EXT_debug_marker")) { |
| 28 | newInterface->fExtensions.add("GL_EXT_debug_marker"); |
| 29 | } |
| 30 | |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 31 | newInterface->fFunctions.fInsertEventMarker = insertEventMarkerFn; |
| 32 | newInterface->fFunctions.fPushGroupMarker = pushGroupMarkerFn; |
| 33 | newInterface->fFunctions.fPopGroupMarker = popGroupMarkerFn; |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 34 | |
| 35 | return newInterface; |
| 36 | } |
| 37 | |
commit-bot@chromium.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 38 | const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) { |
| 39 | GrGLInterface* newInterface = GrGLInterface::NewClone(interface); |
| 40 | |
| 41 | newInterface->fExtensions.remove("GL_NV_path_rendering"); |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 42 | newInterface->fFunctions.fPathCommands = NULL; |
| 43 | newInterface->fFunctions.fPathCoords = NULL; |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 44 | newInterface->fFunctions.fPathParameteri = NULL; |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 45 | newInterface->fFunctions.fPathParameterf = NULL; |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 46 | newInterface->fFunctions.fGenPaths = NULL; |
| 47 | newInterface->fFunctions.fDeletePaths = NULL; |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 48 | newInterface->fFunctions.fPathStencilFunc = NULL; |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 49 | newInterface->fFunctions.fStencilFillPath = NULL; |
| 50 | newInterface->fFunctions.fStencilStrokePath = NULL; |
| 51 | newInterface->fFunctions.fStencilFillPathInstanced = NULL; |
| 52 | newInterface->fFunctions.fStencilStrokePathInstanced = NULL; |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 53 | newInterface->fFunctions.fPathTexGen = NULL; |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 54 | newInterface->fFunctions.fCoverFillPath = NULL; |
| 55 | newInterface->fFunctions.fCoverStrokePath = NULL; |
| 56 | newInterface->fFunctions.fCoverFillPathInstanced = NULL; |
| 57 | newInterface->fFunctions.fCoverStrokePathInstanced = NULL; |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 58 | newInterface->fFunctions.fProgramPathFragmentInputGen = NULL; |
commit-bot@chromium.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 59 | return newInterface; |
| 60 | } |
| 61 | |
commit-bot@chromium.org | f535561 | 2014-02-28 20:28:50 +0000 | [diff] [blame] | 62 | GrGLInterface::GrGLInterface() { |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 63 | fStandard = kNone_GrGLStandard; |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 64 | |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 65 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 66 | fCallback = GrGLDefaultInterfaceCallback; |
| 67 | fCallbackData = 0; |
| 68 | #endif |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 69 | } |
| 70 | |
commit-bot@chromium.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 71 | GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) { |
| 72 | SkASSERT(NULL != interface); |
| 73 | |
| 74 | GrGLInterface* clone = SkNEW(GrGLInterface); |
| 75 | clone->fStandard = interface->fStandard; |
| 76 | clone->fExtensions = interface->fExtensions; |
| 77 | clone->fFunctions = interface->fFunctions; |
| 78 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 79 | clone->fCallback = interface->fCallback; |
| 80 | clone->fCallbackData = interface->fCallbackData; |
| 81 | #endif |
| 82 | return clone; |
| 83 | } |
| 84 | |
commit-bot@chromium.org | e83b9b7 | 2014-05-01 19:21:41 +0000 | [diff] [blame] | 85 | #ifdef SK_DEBUG |
| 86 | static int kIsDebug = 1; |
| 87 | #else |
| 88 | static int kIsDebug = 0; |
| 89 | #endif |
| 90 | |
| 91 | #define RETURN_FALSE_INTERFACE \ |
| 92 | if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \ |
| 93 | return false; |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 94 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 95 | bool GrGLInterface::validate() const { |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 96 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 97 | if (kNone_GrGLStandard == fStandard) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 98 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 99 | } |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 100 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 101 | if (!fExtensions.isInitialized()) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 102 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 103 | } |
bsalomon@google.com | 1dcf506 | 2011-11-14 19:29:53 +0000 | [diff] [blame] | 104 | |
| 105 | // functions that are always required |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 106 | if (NULL == fFunctions.fActiveTexture || |
| 107 | NULL == fFunctions.fAttachShader || |
| 108 | NULL == fFunctions.fBindAttribLocation || |
| 109 | NULL == fFunctions.fBindBuffer || |
| 110 | NULL == fFunctions.fBindTexture || |
| 111 | NULL == fFunctions.fBlendFunc || |
| 112 | NULL == fFunctions.fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension |
| 113 | NULL == fFunctions.fBufferData || |
| 114 | NULL == fFunctions.fBufferSubData || |
| 115 | NULL == fFunctions.fClear || |
| 116 | NULL == fFunctions.fClearColor || |
| 117 | NULL == fFunctions.fClearStencil || |
| 118 | NULL == fFunctions.fColorMask || |
| 119 | NULL == fFunctions.fCompileShader || |
| 120 | NULL == fFunctions.fCopyTexSubImage2D || |
| 121 | NULL == fFunctions.fCreateProgram || |
| 122 | NULL == fFunctions.fCreateShader || |
| 123 | NULL == fFunctions.fCullFace || |
| 124 | NULL == fFunctions.fDeleteBuffers || |
| 125 | NULL == fFunctions.fDeleteProgram || |
| 126 | NULL == fFunctions.fDeleteShader || |
| 127 | NULL == fFunctions.fDeleteTextures || |
| 128 | NULL == fFunctions.fDepthMask || |
| 129 | NULL == fFunctions.fDisable || |
| 130 | NULL == fFunctions.fDisableVertexAttribArray || |
| 131 | NULL == fFunctions.fDrawArrays || |
| 132 | NULL == fFunctions.fDrawElements || |
| 133 | NULL == fFunctions.fEnable || |
| 134 | NULL == fFunctions.fEnableVertexAttribArray || |
| 135 | NULL == fFunctions.fFrontFace || |
| 136 | NULL == fFunctions.fGenBuffers || |
| 137 | NULL == fFunctions.fGenTextures || |
| 138 | NULL == fFunctions.fGetBufferParameteriv || |
| 139 | NULL == fFunctions.fGenerateMipmap || |
| 140 | NULL == fFunctions.fGetError || |
| 141 | NULL == fFunctions.fGetIntegerv || |
| 142 | NULL == fFunctions.fGetProgramInfoLog || |
| 143 | NULL == fFunctions.fGetProgramiv || |
| 144 | NULL == fFunctions.fGetShaderInfoLog || |
| 145 | NULL == fFunctions.fGetShaderiv || |
| 146 | NULL == fFunctions.fGetString || |
| 147 | NULL == fFunctions.fGetUniformLocation || |
| 148 | NULL == fFunctions.fLinkProgram || |
| 149 | NULL == fFunctions.fLineWidth || |
| 150 | NULL == fFunctions.fPixelStorei || |
| 151 | NULL == fFunctions.fReadPixels || |
| 152 | NULL == fFunctions.fScissor || |
| 153 | NULL == fFunctions.fShaderSource || |
| 154 | NULL == fFunctions.fStencilFunc || |
| 155 | NULL == fFunctions.fStencilMask || |
| 156 | NULL == fFunctions.fStencilOp || |
| 157 | NULL == fFunctions.fTexImage2D || |
| 158 | NULL == fFunctions.fTexParameteri || |
| 159 | NULL == fFunctions.fTexParameteriv || |
| 160 | NULL == fFunctions.fTexSubImage2D || |
| 161 | NULL == fFunctions.fUniform1f || |
| 162 | NULL == fFunctions.fUniform1i || |
| 163 | NULL == fFunctions.fUniform1fv || |
| 164 | NULL == fFunctions.fUniform1iv || |
| 165 | NULL == fFunctions.fUniform2f || |
| 166 | NULL == fFunctions.fUniform2i || |
| 167 | NULL == fFunctions.fUniform2fv || |
| 168 | NULL == fFunctions.fUniform2iv || |
| 169 | NULL == fFunctions.fUniform3f || |
| 170 | NULL == fFunctions.fUniform3i || |
| 171 | NULL == fFunctions.fUniform3fv || |
| 172 | NULL == fFunctions.fUniform3iv || |
| 173 | NULL == fFunctions.fUniform4f || |
| 174 | NULL == fFunctions.fUniform4i || |
| 175 | NULL == fFunctions.fUniform4fv || |
| 176 | NULL == fFunctions.fUniform4iv || |
| 177 | NULL == fFunctions.fUniformMatrix2fv || |
| 178 | NULL == fFunctions.fUniformMatrix3fv || |
| 179 | NULL == fFunctions.fUniformMatrix4fv || |
| 180 | NULL == fFunctions.fUseProgram || |
| 181 | NULL == fFunctions.fVertexAttrib4fv || |
| 182 | NULL == fFunctions.fVertexAttribPointer || |
| 183 | NULL == fFunctions.fViewport || |
| 184 | NULL == fFunctions.fBindFramebuffer || |
| 185 | NULL == fFunctions.fBindRenderbuffer || |
| 186 | NULL == fFunctions.fCheckFramebufferStatus || |
| 187 | NULL == fFunctions.fDeleteFramebuffers || |
| 188 | NULL == fFunctions.fDeleteRenderbuffers || |
| 189 | NULL == fFunctions.fFinish || |
| 190 | NULL == fFunctions.fFlush || |
| 191 | NULL == fFunctions.fFramebufferRenderbuffer || |
| 192 | NULL == fFunctions.fFramebufferTexture2D || |
| 193 | NULL == fFunctions.fGetFramebufferAttachmentParameteriv || |
| 194 | NULL == fFunctions.fGetRenderbufferParameteriv || |
| 195 | NULL == fFunctions.fGenFramebuffers || |
| 196 | NULL == fFunctions.fGenRenderbuffers || |
| 197 | NULL == fFunctions.fRenderbufferStorage) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 198 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 199 | } |
| 200 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 201 | GrGLVersion glVer = GrGLGetVersion(this); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 202 | if (GR_GL_INVALID_VER == glVer) { |
| 203 | RETURN_FALSE_INTERFACE |
| 204 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 205 | |
| 206 | // Now check that baseline ES/Desktop fns not covered above are present |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 207 | // and that we have fn pointers for any advertised fExtensions that we will |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 208 | // try to use. |
| 209 | |
| 210 | // these functions are part of ES2, we assume they are available |
| 211 | // On the desktop we assume they are available if the extension |
| 212 | // is present or GL version is high enough. |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 213 | if (kGLES_GrGLStandard == fStandard) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 214 | if (NULL == fFunctions.fStencilFuncSeparate || |
| 215 | NULL == fFunctions.fStencilMaskSeparate || |
| 216 | NULL == fFunctions.fStencilOpSeparate) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 217 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 218 | } |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 219 | } else if (kGL_GrGLStandard == fStandard) { |
robertphillips@google.com | e788430 | 2012-04-18 14:39:58 +0000 | [diff] [blame] | 220 | |
bsalomon@google.com | c82b889 | 2011-09-22 14:10:33 +0000 | [diff] [blame] | 221 | if (glVer >= GR_GL_VER(2,0)) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 222 | if (NULL == fFunctions.fStencilFuncSeparate || |
| 223 | NULL == fFunctions.fStencilMaskSeparate || |
| 224 | NULL == fFunctions.fStencilOpSeparate) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 225 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 226 | } |
| 227 | } |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 228 | if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 229 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bc5cf51 | 2011-09-21 16:21:07 +0000 | [diff] [blame] | 230 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 231 | if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 232 | if (NULL == fFunctions.fDrawBuffers) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 233 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | d32c5f5 | 2011-08-02 19:29:03 +0000 | [diff] [blame] | 234 | } |
| 235 | } |
robertphillips@google.com | e788430 | 2012-04-18 14:39:58 +0000 | [diff] [blame] | 236 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 237 | if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 238 | if (NULL == fFunctions.fGenQueries || |
| 239 | NULL == fFunctions.fDeleteQueries || |
| 240 | NULL == fFunctions.fBeginQuery || |
| 241 | NULL == fFunctions.fEndQuery || |
| 242 | NULL == fFunctions.fGetQueryiv || |
| 243 | NULL == fFunctions.fGetQueryObjectiv || |
| 244 | NULL == fFunctions.fGetQueryObjectuiv) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 245 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 246 | } |
| 247 | } |
| 248 | if (glVer >= GR_GL_VER(3,3) || |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 249 | fExtensions.has("GL_ARB_timer_query") || |
| 250 | fExtensions.has("GL_EXT_timer_query")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 251 | if (NULL == fFunctions.fGetQueryObjecti64v || |
| 252 | NULL == fFunctions.fGetQueryObjectui64v) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 253 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 254 | } |
| 255 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 256 | if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 257 | if (NULL == fFunctions.fQueryCounter) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 258 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 259 | } |
| 260 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | // optional function on desktop before 1.3 |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 264 | if (kGL_GrGLStandard != fStandard || |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 265 | (glVer >= GR_GL_VER(1,3)) || |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 266 | fExtensions.has("GL_ARB_texture_compression")) { |
krajcevski | e1f5a23 | 2014-06-11 16:08:50 -0700 | [diff] [blame] | 267 | if (NULL == fFunctions.fCompressedTexImage2D |
| 268 | #if 0 |
| 269 | || NULL == fFunctions.fCompressedTexSubImage2D |
| 270 | #endif |
| 271 | ) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 272 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 273 | } |
| 274 | } |
| 275 | |
bsalomon@google.com | d32c5f5 | 2011-08-02 19:29:03 +0000 | [diff] [blame] | 276 | // part of desktop GL, but not ES |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 277 | if (kGL_GrGLStandard == fStandard && |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 278 | (NULL == fFunctions.fGetTexLevelParameteriv || |
| 279 | NULL == fFunctions.fDrawBuffer || |
| 280 | NULL == fFunctions.fReadBuffer)) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 281 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 282 | } |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 283 | |
bsalomon@google.com | 280e99f | 2012-01-05 16:17:38 +0000 | [diff] [blame] | 284 | // GL_EXT_texture_storage is part of desktop 4.2 |
| 285 | // There is a desktop ARB extension and an ES+desktop EXT extension |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 286 | if (kGL_GrGLStandard == fStandard) { |
bsalomon@google.com | baa9ea1 | 2012-01-06 19:05:43 +0000 | [diff] [blame] | 287 | if (glVer >= GR_GL_VER(4,2) || |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 288 | fExtensions.has("GL_ARB_texture_storage") || |
| 289 | fExtensions.has("GL_EXT_texture_storage")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 290 | if (NULL == fFunctions.fTexStorage2D) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 291 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | baa9ea1 | 2012-01-06 19:05:43 +0000 | [diff] [blame] | 292 | } |
| 293 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 294 | } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 295 | if (NULL == fFunctions.fTexStorage2D) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 296 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | baa9ea1 | 2012-01-06 19:05:43 +0000 | [diff] [blame] | 297 | } |
bsalomon@google.com | 280e99f | 2012-01-05 16:17:38 +0000 | [diff] [blame] | 298 | } |
| 299 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 300 | if (fExtensions.has("GL_EXT_discard_framebuffer")) { |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 301 | // FIXME: Remove this once Chromium is updated to provide this function |
| 302 | #if 0 |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 303 | if (NULL == fFunctions.fDiscardFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 304 | RETURN_FALSE_INTERFACE |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 305 | } |
| 306 | #endif |
| 307 | } |
| 308 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 309 | // FBO MSAA |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 310 | if (kGL_GrGLStandard == fStandard) { |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 311 | // GL 3.0 and the ARB extension have multisample + blit |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 312 | if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 313 | if (NULL == fFunctions.fRenderbufferStorageMultisample || |
| 314 | NULL == fFunctions.fBlitFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 315 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 316 | } |
| 317 | } else { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 318 | if (fExtensions.has("GL_EXT_framebuffer_blit") && |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 319 | NULL == fFunctions.fBlitFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 320 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 321 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 322 | if (fExtensions.has("GL_EXT_framebuffer_multisample") && |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 323 | NULL == fFunctions.fRenderbufferStorageMultisample) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 324 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | } else { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 328 | if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 329 | if (NULL == fFunctions.fRenderbufferStorageMultisample || |
| 330 | NULL == fFunctions.fBlitFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 331 | RETURN_FALSE_INTERFACE |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 332 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 333 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 334 | if (fExtensions.has("GL_APPLE_framebuffer_multisample")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 335 | if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE || |
| 336 | NULL == fFunctions.fResolveMultisampleFramebuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 337 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 338 | } |
| 339 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 340 | if (fExtensions.has("GL_IMG_multisampled_render_to_texture") || |
| 341 | fExtensions.has("GL_EXT_multisampled_render_to_texture")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 342 | if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT || |
| 343 | NULL == fFunctions.fFramebufferTexture2DMultisample) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 344 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | f3a60c0 | 2013-03-19 19:06:09 +0000 | [diff] [blame] | 345 | } |
| 346 | } |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | // On ES buffer mapping is an extension. On Desktop |
| 350 | // buffer mapping was part of original VBO extension |
| 351 | // which we require. |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 352 | if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 353 | if (NULL == fFunctions.fMapBuffer || |
| 354 | NULL == fFunctions.fUnmapBuffer) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 355 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 356 | } |
| 357 | } |
| 358 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 359 | // Dual source blending |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 360 | if (kGL_GrGLStandard == fStandard && |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 361 | (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 362 | if (NULL == fFunctions.fBindFragDataLocationIndexed) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 363 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 364 | } |
| 365 | } |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 366 | |
commit-bot@chromium.org | 726e621 | 2013-08-23 20:55:46 +0000 | [diff] [blame] | 367 | // glGetStringi was added in version 3.0 of both desktop and ES. |
| 368 | if (glVer >= GR_GL_VER(3, 0)) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 369 | if (NULL == fFunctions.fGetStringi) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 370 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 371 | } |
| 372 | } |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 373 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 374 | if (kGL_GrGLStandard == fStandard) { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 375 | if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 376 | if (NULL == fFunctions.fBindVertexArray || |
| 377 | NULL == fFunctions.fDeleteVertexArrays || |
| 378 | NULL == fFunctions.fGenVertexArrays) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 379 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | ecd8484 | 2013-03-01 15:36:02 +0000 | [diff] [blame] | 380 | } |
| 381 | } |
| 382 | } else { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 383 | if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) { |
commit-bot@chromium.org | c72425a | 2014-01-21 16:09:18 +0000 | [diff] [blame] | 384 | if (NULL == fFunctions.fBindVertexArray || |
| 385 | NULL == fFunctions.fDeleteVertexArrays || |
| 386 | NULL == fFunctions.fGenVertexArrays) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 387 | RETURN_FALSE_INTERFACE |
bsalomon@google.com | ecd8484 | 2013-03-01 15:36:02 +0000 | [diff] [blame] | 388 | } |
| 389 | } |
bsalomon@google.com | ecd8484 | 2013-03-01 15:36:02 +0000 | [diff] [blame] | 390 | } |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 391 | |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 392 | if (fExtensions.has("GL_EXT_debug_marker")) { |
| 393 | if (NULL == fFunctions.fInsertEventMarker || |
| 394 | NULL == fFunctions.fPushGroupMarker || |
| 395 | NULL == fFunctions.fPopGroupMarker) { |
commit-bot@chromium.org | adadf7c | 2014-03-24 19:43:02 +0000 | [diff] [blame] | 396 | RETURN_FALSE_INTERFACE |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 397 | } |
| 398 | } |
bsalomon@google.com | a34bb60 | 2014-04-01 13:07:29 +0000 | [diff] [blame] | 399 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 400 | if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) || |
| 401 | fExtensions.has("GL_ARB_invalidate_subdata")) { |
bsalomon@google.com | a34bb60 | 2014-04-01 13:07:29 +0000 | [diff] [blame] | 402 | if (NULL == fFunctions.fInvalidateBufferData || |
| 403 | NULL == fFunctions.fInvalidateBufferSubData || |
| 404 | NULL == fFunctions.fInvalidateFramebuffer || |
| 405 | NULL == fFunctions.fInvalidateSubFramebuffer || |
| 406 | NULL == fFunctions.fInvalidateTexImage || |
| 407 | NULL == fFunctions.fInvalidateTexSubImage) { |
| 408 | RETURN_FALSE_INTERFACE; |
| 409 | } |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 410 | } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) { |
bsalomon@google.com | a34bb60 | 2014-04-01 13:07:29 +0000 | [diff] [blame] | 411 | // ES 3.0 adds the framebuffer functions but not the others. |
| 412 | if (NULL == fFunctions.fInvalidateFramebuffer || |
| 413 | NULL == fFunctions.fInvalidateSubFramebuffer) { |
| 414 | RETURN_FALSE_INTERFACE; |
| 415 | } |
| 416 | } |
commit-bot@chromium.org | beb8b3a | 2014-04-15 15:37:51 +0000 | [diff] [blame] | 417 | |
| 418 | if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) { |
| 419 | if (NULL == fFunctions.fMapBufferSubData || |
| 420 | NULL == fFunctions.fMapTexSubImage2D || |
| 421 | NULL == fFunctions.fUnmapBufferSubData || |
| 422 | NULL == fFunctions.fUnmapTexSubImage2D) { |
| 423 | RETURN_FALSE_INTERFACE; |
| 424 | } |
| 425 | } |
bsalomon@google.com | a34bb60 | 2014-04-01 13:07:29 +0000 | [diff] [blame] | 426 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 427 | // These functions are added to the 3.0 version of both GLES and GL. |
| 428 | if (glVer >= GR_GL_VER(3,0) || |
| 429 | (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) || |
| 430 | (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) { |
| 431 | if (NULL == fFunctions.fMapBufferRange || |
| 432 | NULL == fFunctions.fFlushMappedBufferRange) { |
| 433 | RETURN_FALSE_INTERFACE; |
| 434 | } |
| 435 | } |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 436 | |
| 437 | if ((kGL_GrGLStandard == fStandard && fExtensions.has("GL_EXT_direct_state_access")) || |
| 438 | (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_NV_path_rendering"))) { |
| 439 | if (NULL == fFunctions.fMatrixLoadf || |
| 440 | NULL == fFunctions.fMatrixLoadIdentity) { |
| 441 | RETURN_FALSE_INTERFACE |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | if ((kGL_GrGLStandard == fStandard && |
| 446 | (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) || |
| 447 | (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) { |
| 448 | if (NULL == fFunctions.fGetProgramResourceLocation) { |
| 449 | RETURN_FALSE_INTERFACE |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | if (fExtensions.has("GL_NV_path_rendering")) { |
| 454 | if (NULL == fFunctions.fPathCommands || |
| 455 | NULL == fFunctions.fPathCoords || |
| 456 | NULL == fFunctions.fPathParameteri || |
| 457 | NULL == fFunctions.fPathParameterf || |
| 458 | NULL == fFunctions.fGenPaths || |
| 459 | NULL == fFunctions.fDeletePaths || |
| 460 | NULL == fFunctions.fPathStencilFunc || |
| 461 | NULL == fFunctions.fStencilFillPath || |
| 462 | NULL == fFunctions.fStencilStrokePath || |
| 463 | NULL == fFunctions.fStencilFillPathInstanced || |
| 464 | NULL == fFunctions.fStencilStrokePathInstanced || |
| 465 | NULL == fFunctions.fCoverFillPath || |
| 466 | NULL == fFunctions.fCoverStrokePath || |
| 467 | NULL == fFunctions.fCoverFillPathInstanced || |
| 468 | NULL == fFunctions.fCoverStrokePathInstanced) { |
| 469 | RETURN_FALSE_INTERFACE |
| 470 | } |
| 471 | // Currently ProgramPathFragmentInputGen is not used on |
| 472 | // OpenGL, rather PathTexGen is. |
| 473 | if ((kGL_GrGLStandard == fStandard && NULL == fFunctions.fPathTexGen) || |
| 474 | (kGLES_GrGLStandard == fStandard && NULL == fFunctions.fProgramPathFragmentInputGen)) { |
| 475 | RETURN_FALSE_INTERFACE |
| 476 | } |
| 477 | } |
| 478 | |
bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame] | 479 | return true; |
| 480 | } |