blob: 8054fd5d1e5f0c14341f43a8ab6a2f1b813ba0ca [file] [log] [blame]
twiz@google.com59a190b2011-03-14 21:23:01 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * 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.com59a190b2011-03-14 21:23:01 +00006 */
7
8
tomhudson@google.com6bf38b52012-02-14 15:11:59 +00009#include "gl/GrGLInterface.h"
bsalomon@google.com1744f972013-02-26 21:46:32 +000010#include "gl/GrGLExtensions.h"
11#include "gl/GrGLUtil.h"
twiz@google.com59a190b2011-03-14 21:23:01 +000012
13#include <stdio.h>
14
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +000015#if GR_GL_PER_GL_FUNC_CALLBACK
16namespace {
17void GrGLDefaultInterfaceCallback(const GrGLInterface*) {}
18}
19#endif
20
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000021const 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.orgf5355612014-02-28 20:28:50 +000031 newInterface->fFunctions.fInsertEventMarker = insertEventMarkerFn;
32 newInterface->fFunctions.fPushGroupMarker = pushGroupMarkerFn;
33 newInterface->fFunctions.fPopGroupMarker = popGroupMarkerFn;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000034
35 return newInterface;
36}
37
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000038const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) {
39 GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
40
41 newInterface->fExtensions.remove("GL_NV_path_rendering");
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000042 newInterface->fFunctions.fPathCommands = NULL;
43 newInterface->fFunctions.fPathCoords = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000044 newInterface->fFunctions.fPathParameteri = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000045 newInterface->fFunctions.fPathParameterf = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000046 newInterface->fFunctions.fGenPaths = NULL;
47 newInterface->fFunctions.fDeletePaths = NULL;
cdalton8dd90cb2014-07-17 09:28:36 -070048 newInterface->fFunctions.fIsPath = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000049 newInterface->fFunctions.fPathStencilFunc = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000050 newInterface->fFunctions.fStencilFillPath = NULL;
51 newInterface->fFunctions.fStencilStrokePath = NULL;
52 newInterface->fFunctions.fStencilFillPathInstanced = NULL;
53 newInterface->fFunctions.fStencilStrokePathInstanced = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000054 newInterface->fFunctions.fPathTexGen = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000055 newInterface->fFunctions.fCoverFillPath = NULL;
56 newInterface->fFunctions.fCoverStrokePath = NULL;
57 newInterface->fFunctions.fCoverFillPathInstanced = NULL;
58 newInterface->fFunctions.fCoverStrokePathInstanced = NULL;
cdaltonc7103a12014-08-11 14:05:05 -070059 newInterface->fFunctions.fStencilThenCoverFillPath = NULL;
60 newInterface->fFunctions.fStencilThenCoverStrokePath = NULL;
61 newInterface->fFunctions.fStencilThenCoverFillPathInstanced = NULL;
62 newInterface->fFunctions.fStencilThenCoverStrokePathInstanced = NULL;
kkinnunen32b9a3b2014-07-02 22:56:35 -070063 newInterface->fFunctions.fProgramPathFragmentInputGen = NULL;
cdalton149b3ec2014-09-17 09:19:18 -070064 newInterface->fFunctions.fPathMemoryGlyphIndexArray = NULL;
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000065 return newInterface;
66}
67
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000068GrGLInterface::GrGLInterface() {
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000069 fStandard = kNone_GrGLStandard;
bsalomon@google.com0b77d682011-08-19 13:28:54 +000070
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +000071#if GR_GL_PER_GL_FUNC_CALLBACK
72 fCallback = GrGLDefaultInterfaceCallback;
73 fCallbackData = 0;
74#endif
bsalomon@google.com0b77d682011-08-19 13:28:54 +000075}
76
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000077GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
bsalomon49f085d2014-09-05 13:34:00 -070078 SkASSERT(interface);
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000079
80 GrGLInterface* clone = SkNEW(GrGLInterface);
81 clone->fStandard = interface->fStandard;
82 clone->fExtensions = interface->fExtensions;
83 clone->fFunctions = interface->fFunctions;
84#if GR_GL_PER_GL_FUNC_CALLBACK
85 clone->fCallback = interface->fCallback;
86 clone->fCallbackData = interface->fCallbackData;
87#endif
88 return clone;
89}
90
commit-bot@chromium.orge83b9b72014-05-01 19:21:41 +000091#ifdef SK_DEBUG
92 static int kIsDebug = 1;
93#else
94 static int kIsDebug = 0;
95#endif
96
97#define RETURN_FALSE_INTERFACE \
98 if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
99 return false;
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000100
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000101bool GrGLInterface::validate() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000102
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000103 if (kNone_GrGLStandard == fStandard) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000104 RETURN_FALSE_INTERFACE
bsalomon@google.com1dcf5062011-11-14 19:29:53 +0000105 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000106
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000107 if (!fExtensions.isInitialized()) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000108 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000109 }
bsalomon@google.com1dcf5062011-11-14 19:29:53 +0000110
111 // functions that are always required
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000112 if (NULL == fFunctions.fActiveTexture ||
113 NULL == fFunctions.fAttachShader ||
114 NULL == fFunctions.fBindAttribLocation ||
115 NULL == fFunctions.fBindBuffer ||
116 NULL == fFunctions.fBindTexture ||
117 NULL == fFunctions.fBlendFunc ||
118 NULL == fFunctions.fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension
119 NULL == fFunctions.fBufferData ||
120 NULL == fFunctions.fBufferSubData ||
121 NULL == fFunctions.fClear ||
122 NULL == fFunctions.fClearColor ||
123 NULL == fFunctions.fClearStencil ||
124 NULL == fFunctions.fColorMask ||
125 NULL == fFunctions.fCompileShader ||
126 NULL == fFunctions.fCopyTexSubImage2D ||
127 NULL == fFunctions.fCreateProgram ||
128 NULL == fFunctions.fCreateShader ||
129 NULL == fFunctions.fCullFace ||
130 NULL == fFunctions.fDeleteBuffers ||
131 NULL == fFunctions.fDeleteProgram ||
132 NULL == fFunctions.fDeleteShader ||
133 NULL == fFunctions.fDeleteTextures ||
134 NULL == fFunctions.fDepthMask ||
135 NULL == fFunctions.fDisable ||
136 NULL == fFunctions.fDisableVertexAttribArray ||
137 NULL == fFunctions.fDrawArrays ||
138 NULL == fFunctions.fDrawElements ||
139 NULL == fFunctions.fEnable ||
140 NULL == fFunctions.fEnableVertexAttribArray ||
141 NULL == fFunctions.fFrontFace ||
142 NULL == fFunctions.fGenBuffers ||
143 NULL == fFunctions.fGenTextures ||
144 NULL == fFunctions.fGetBufferParameteriv ||
145 NULL == fFunctions.fGenerateMipmap ||
146 NULL == fFunctions.fGetError ||
147 NULL == fFunctions.fGetIntegerv ||
148 NULL == fFunctions.fGetProgramInfoLog ||
149 NULL == fFunctions.fGetProgramiv ||
150 NULL == fFunctions.fGetShaderInfoLog ||
151 NULL == fFunctions.fGetShaderiv ||
152 NULL == fFunctions.fGetString ||
153 NULL == fFunctions.fGetUniformLocation ||
154 NULL == fFunctions.fLinkProgram ||
155 NULL == fFunctions.fLineWidth ||
156 NULL == fFunctions.fPixelStorei ||
157 NULL == fFunctions.fReadPixels ||
158 NULL == fFunctions.fScissor ||
159 NULL == fFunctions.fShaderSource ||
160 NULL == fFunctions.fStencilFunc ||
161 NULL == fFunctions.fStencilMask ||
162 NULL == fFunctions.fStencilOp ||
163 NULL == fFunctions.fTexImage2D ||
164 NULL == fFunctions.fTexParameteri ||
165 NULL == fFunctions.fTexParameteriv ||
166 NULL == fFunctions.fTexSubImage2D ||
167 NULL == fFunctions.fUniform1f ||
168 NULL == fFunctions.fUniform1i ||
169 NULL == fFunctions.fUniform1fv ||
170 NULL == fFunctions.fUniform1iv ||
171 NULL == fFunctions.fUniform2f ||
172 NULL == fFunctions.fUniform2i ||
173 NULL == fFunctions.fUniform2fv ||
174 NULL == fFunctions.fUniform2iv ||
175 NULL == fFunctions.fUniform3f ||
176 NULL == fFunctions.fUniform3i ||
177 NULL == fFunctions.fUniform3fv ||
178 NULL == fFunctions.fUniform3iv ||
179 NULL == fFunctions.fUniform4f ||
180 NULL == fFunctions.fUniform4i ||
181 NULL == fFunctions.fUniform4fv ||
182 NULL == fFunctions.fUniform4iv ||
183 NULL == fFunctions.fUniformMatrix2fv ||
184 NULL == fFunctions.fUniformMatrix3fv ||
185 NULL == fFunctions.fUniformMatrix4fv ||
186 NULL == fFunctions.fUseProgram ||
egdaniel27c15212014-10-24 15:00:50 -0700187#if 0
188 NULL == fFunctions.fVertexAttrib1f ||
189 NULL == fFunctions.fVertexAttrib2fv ||
190 NULL == fFunctions.fVertexAttrib3fv ||
191#endif
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000192 NULL == fFunctions.fVertexAttrib4fv ||
193 NULL == fFunctions.fVertexAttribPointer ||
194 NULL == fFunctions.fViewport ||
195 NULL == fFunctions.fBindFramebuffer ||
196 NULL == fFunctions.fBindRenderbuffer ||
197 NULL == fFunctions.fCheckFramebufferStatus ||
198 NULL == fFunctions.fDeleteFramebuffers ||
199 NULL == fFunctions.fDeleteRenderbuffers ||
200 NULL == fFunctions.fFinish ||
201 NULL == fFunctions.fFlush ||
202 NULL == fFunctions.fFramebufferRenderbuffer ||
203 NULL == fFunctions.fFramebufferTexture2D ||
204 NULL == fFunctions.fGetFramebufferAttachmentParameteriv ||
205 NULL == fFunctions.fGetRenderbufferParameteriv ||
206 NULL == fFunctions.fGenFramebuffers ||
207 NULL == fFunctions.fGenRenderbuffers ||
208 NULL == fFunctions.fRenderbufferStorage) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000209 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000210 }
211
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000212 GrGLVersion glVer = GrGLGetVersion(this);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000213 if (GR_GL_INVALID_VER == glVer) {
214 RETURN_FALSE_INTERFACE
215 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000216
217 // Now check that baseline ES/Desktop fns not covered above are present
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000218 // and that we have fn pointers for any advertised fExtensions that we will
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000219 // try to use.
220
221 // these functions are part of ES2, we assume they are available
222 // On the desktop we assume they are available if the extension
223 // is present or GL version is high enough.
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000224 if (kGLES_GrGLStandard == fStandard) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000225 if (NULL == fFunctions.fStencilFuncSeparate ||
226 NULL == fFunctions.fStencilMaskSeparate ||
227 NULL == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000228 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000229 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000230 } else if (kGL_GrGLStandard == fStandard) {
robertphillips@google.come7884302012-04-18 14:39:58 +0000231
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000232 if (glVer >= GR_GL_VER(2,0)) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000233 if (NULL == fFunctions.fStencilFuncSeparate ||
234 NULL == fFunctions.fStencilMaskSeparate ||
235 NULL == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000236 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000237 }
238 }
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000239 if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000240 RETURN_FALSE_INTERFACE
bsalomon@google.combc5cf512011-09-21 16:21:07 +0000241 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000242 if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000243 if (NULL == fFunctions.fDrawBuffers) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000244 RETURN_FALSE_INTERFACE
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000245 }
246 }
robertphillips@google.come7884302012-04-18 14:39:58 +0000247
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000248 if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000249 if (NULL == fFunctions.fGenQueries ||
250 NULL == fFunctions.fDeleteQueries ||
251 NULL == fFunctions.fBeginQuery ||
252 NULL == fFunctions.fEndQuery ||
253 NULL == fFunctions.fGetQueryiv ||
254 NULL == fFunctions.fGetQueryObjectiv ||
255 NULL == fFunctions.fGetQueryObjectuiv) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000256 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000257 }
258 }
259 if (glVer >= GR_GL_VER(3,3) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000260 fExtensions.has("GL_ARB_timer_query") ||
261 fExtensions.has("GL_EXT_timer_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000262 if (NULL == fFunctions.fGetQueryObjecti64v ||
263 NULL == fFunctions.fGetQueryObjectui64v) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000264 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000265 }
266 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000267 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000268 if (NULL == fFunctions.fQueryCounter) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000269 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000270 }
271 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000272 }
273
274 // optional function on desktop before 1.3
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000275 if (kGL_GrGLStandard != fStandard ||
bsalomon@google.com1744f972013-02-26 21:46:32 +0000276 (glVer >= GR_GL_VER(1,3)) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000277 fExtensions.has("GL_ARB_texture_compression")) {
krajcevskie1f5a232014-06-11 16:08:50 -0700278 if (NULL == fFunctions.fCompressedTexImage2D
279#if 0
280 || NULL == fFunctions.fCompressedTexSubImage2D
281#endif
282 ) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000283 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000284 }
285 }
286
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000287 // part of desktop GL, but not ES
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000288 if (kGL_GrGLStandard == fStandard &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000289 (NULL == fFunctions.fGetTexLevelParameteriv ||
290 NULL == fFunctions.fDrawBuffer ||
291 NULL == fFunctions.fReadBuffer)) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000292 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000293 }
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000294
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000295 // GL_EXT_texture_storage is part of desktop 4.2
296 // There is a desktop ARB extension and an ES+desktop EXT extension
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000297 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000298 if (glVer >= GR_GL_VER(4,2) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000299 fExtensions.has("GL_ARB_texture_storage") ||
300 fExtensions.has("GL_EXT_texture_storage")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000301 if (NULL == fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000302 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000303 }
304 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000305 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000306 if (NULL == fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000307 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000308 }
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000309 }
310
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000311 if (fExtensions.has("GL_EXT_discard_framebuffer")) {
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000312// FIXME: Remove this once Chromium is updated to provide this function
313#if 0
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000314 if (NULL == fFunctions.fDiscardFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000315 RETURN_FALSE_INTERFACE
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000316 }
317#endif
318 }
319
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000320 // FBO MSAA
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000321 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000322 // GL 3.0 and the ARB extension have multisample + blit
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000323 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000324 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
325 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000326 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000327 }
328 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000329 if (fExtensions.has("GL_EXT_framebuffer_blit") &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000330 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000331 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000332 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000333 if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000334 NULL == fFunctions.fRenderbufferStorageMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000335 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000336 }
337 }
338 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000339 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000340 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
341 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000342 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000343 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000344 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000345 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000346 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
347 NULL == fFunctions.fResolveMultisampleFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000348 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000349 }
350 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000351 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
352 fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000353 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
354 NULL == fFunctions.fFramebufferTexture2DMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000355 RETURN_FALSE_INTERFACE
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000356 }
357 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000358 }
359
360 // On ES buffer mapping is an extension. On Desktop
361 // buffer mapping was part of original VBO extension
362 // which we require.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000363 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000364 if (NULL == fFunctions.fMapBuffer ||
365 NULL == fFunctions.fUnmapBuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000366 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000367 }
368 }
369
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000370 // Dual source blending
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000371 if (kGL_GrGLStandard == fStandard &&
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000372 (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000373 if (NULL == fFunctions.fBindFragDataLocationIndexed) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000374 RETURN_FALSE_INTERFACE
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000375 }
376 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000377
commit-bot@chromium.org726e6212013-08-23 20:55:46 +0000378 // glGetStringi was added in version 3.0 of both desktop and ES.
379 if (glVer >= GR_GL_VER(3, 0)) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000380 if (NULL == fFunctions.fGetStringi) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000381 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000382 }
383 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000384
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000385 if (kGL_GrGLStandard == fStandard) {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000386 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000387 if (NULL == fFunctions.fBindVertexArray ||
388 NULL == fFunctions.fDeleteVertexArrays ||
389 NULL == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000390 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000391 }
392 }
393 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000394 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000395 if (NULL == fFunctions.fBindVertexArray ||
396 NULL == fFunctions.fDeleteVertexArrays ||
397 NULL == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000398 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000399 }
400 }
bsalomon@google.comecd84842013-03-01 15:36:02 +0000401 }
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000402
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000403 if (fExtensions.has("GL_EXT_debug_marker")) {
404 if (NULL == fFunctions.fInsertEventMarker ||
405 NULL == fFunctions.fPushGroupMarker ||
406 NULL == fFunctions.fPopGroupMarker) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000407 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000408 }
409 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000410
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000411 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
412 fExtensions.has("GL_ARB_invalidate_subdata")) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000413 if (NULL == fFunctions.fInvalidateBufferData ||
414 NULL == fFunctions.fInvalidateBufferSubData ||
415 NULL == fFunctions.fInvalidateFramebuffer ||
416 NULL == fFunctions.fInvalidateSubFramebuffer ||
417 NULL == fFunctions.fInvalidateTexImage ||
418 NULL == fFunctions.fInvalidateTexSubImage) {
419 RETURN_FALSE_INTERFACE;
420 }
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000421 } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000422 // ES 3.0 adds the framebuffer functions but not the others.
423 if (NULL == fFunctions.fInvalidateFramebuffer ||
424 NULL == fFunctions.fInvalidateSubFramebuffer) {
425 RETURN_FALSE_INTERFACE;
426 }
427 }
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000428
429 if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
430 if (NULL == fFunctions.fMapBufferSubData ||
431 NULL == fFunctions.fMapTexSubImage2D ||
432 NULL == fFunctions.fUnmapBufferSubData ||
433 NULL == fFunctions.fUnmapTexSubImage2D) {
434 RETURN_FALSE_INTERFACE;
435 }
436 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000437
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000438 // These functions are added to the 3.0 version of both GLES and GL.
439 if (glVer >= GR_GL_VER(3,0) ||
440 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
441 (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
442 if (NULL == fFunctions.fMapBufferRange ||
443 NULL == fFunctions.fFlushMappedBufferRange) {
444 RETURN_FALSE_INTERFACE;
445 }
446 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700447
448 if ((kGL_GrGLStandard == fStandard && fExtensions.has("GL_EXT_direct_state_access")) ||
449 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_NV_path_rendering"))) {
450 if (NULL == fFunctions.fMatrixLoadf ||
451 NULL == fFunctions.fMatrixLoadIdentity) {
452 RETURN_FALSE_INTERFACE
453 }
454 }
455
456 if ((kGL_GrGLStandard == fStandard &&
457 (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) ||
458 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
459 if (NULL == fFunctions.fGetProgramResourceLocation) {
460 RETURN_FALSE_INTERFACE
461 }
462 }
463
464 if (fExtensions.has("GL_NV_path_rendering")) {
465 if (NULL == fFunctions.fPathCommands ||
466 NULL == fFunctions.fPathCoords ||
467 NULL == fFunctions.fPathParameteri ||
468 NULL == fFunctions.fPathParameterf ||
469 NULL == fFunctions.fGenPaths ||
470 NULL == fFunctions.fDeletePaths ||
cdalton8dd90cb2014-07-17 09:28:36 -0700471 NULL == fFunctions.fIsPath ||
kkinnunen32b9a3b2014-07-02 22:56:35 -0700472 NULL == fFunctions.fPathStencilFunc ||
473 NULL == fFunctions.fStencilFillPath ||
474 NULL == fFunctions.fStencilStrokePath ||
475 NULL == fFunctions.fStencilFillPathInstanced ||
476 NULL == fFunctions.fStencilStrokePathInstanced ||
477 NULL == fFunctions.fCoverFillPath ||
478 NULL == fFunctions.fCoverStrokePath ||
479 NULL == fFunctions.fCoverFillPathInstanced ||
cdaltonc7103a12014-08-11 14:05:05 -0700480 NULL == fFunctions.fCoverStrokePathInstanced) {
kkinnunen32b9a3b2014-07-02 22:56:35 -0700481 RETURN_FALSE_INTERFACE
482 }
cdaltonc7103a12014-08-11 14:05:05 -0700483 if (kGL_GrGLStandard == fStandard) {
484 // Some methods only exist on desktop
485 if (NULL == fFunctions.fPathTexGen) {
486 RETURN_FALSE_INTERFACE
487 }
488 } else {
489 // All additions through v1.3 exist on GLES
490 if (NULL == fFunctions.fStencilThenCoverFillPath ||
491 NULL == fFunctions.fStencilThenCoverStrokePath ||
492 NULL == fFunctions.fStencilThenCoverFillPathInstanced ||
493 NULL == fFunctions.fStencilThenCoverStrokePathInstanced ||
cdalton149b3ec2014-09-17 09:19:18 -0700494 NULL == fFunctions.fProgramPathFragmentInputGen ||
495 NULL == fFunctions.fPathMemoryGlyphIndexArray) {
cdaltonc7103a12014-08-11 14:05:05 -0700496 RETURN_FALSE_INTERFACE
497 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700498 }
499 }
500
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000501 return true;
502}