blob: 8aaa02e86b2eff2028048dcc2712298791a17eb5 [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");
42
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000043 newInterface->fFunctions.fPathCommands = NULL;
44 newInterface->fFunctions.fPathCoords = NULL;
45 newInterface->fFunctions.fPathSubCommands = NULL;
46 newInterface->fFunctions.fPathSubCoords = NULL;
47 newInterface->fFunctions.fPathString = NULL;
48 newInterface->fFunctions.fPathGlyphs = NULL;
49 newInterface->fFunctions.fPathGlyphRange = NULL;
50 newInterface->fFunctions.fWeightPaths = NULL;
51 newInterface->fFunctions.fCopyPath = NULL;
52 newInterface->fFunctions.fInterpolatePaths = NULL;
53 newInterface->fFunctions.fTransformPath = NULL;
54 newInterface->fFunctions.fPathParameteriv = NULL;
55 newInterface->fFunctions.fPathParameteri = NULL;
56 newInterface->fFunctions.fPathParameterfv = NULL;
57 newInterface->fFunctions.fPathParameterf = NULL;
58 newInterface->fFunctions.fPathDashArray = NULL;
59 newInterface->fFunctions.fGenPaths = NULL;
60 newInterface->fFunctions.fDeletePaths = NULL;
61 newInterface->fFunctions.fIsPath = NULL;
62 newInterface->fFunctions.fPathStencilFunc = NULL;
63 newInterface->fFunctions.fPathStencilDepthOffset = NULL;
64 newInterface->fFunctions.fStencilFillPath = NULL;
65 newInterface->fFunctions.fStencilStrokePath = NULL;
66 newInterface->fFunctions.fStencilFillPathInstanced = NULL;
67 newInterface->fFunctions.fStencilStrokePathInstanced = NULL;
68 newInterface->fFunctions.fPathCoverDepthFunc = NULL;
69 newInterface->fFunctions.fPathColorGen = NULL;
70 newInterface->fFunctions.fPathTexGen = NULL;
71 newInterface->fFunctions.fPathFogGen = NULL;
72 newInterface->fFunctions.fCoverFillPath = NULL;
73 newInterface->fFunctions.fCoverStrokePath = NULL;
74 newInterface->fFunctions.fCoverFillPathInstanced = NULL;
75 newInterface->fFunctions.fCoverStrokePathInstanced = NULL;
76 newInterface->fFunctions.fGetPathParameteriv = NULL;
77 newInterface->fFunctions.fGetPathParameterfv = NULL;
78 newInterface->fFunctions.fGetPathCommands = NULL;
79 newInterface->fFunctions.fGetPathCoords = NULL;
80 newInterface->fFunctions.fGetPathDashArray = NULL;
81 newInterface->fFunctions.fGetPathMetrics = NULL;
82 newInterface->fFunctions.fGetPathMetricRange = NULL;
83 newInterface->fFunctions.fGetPathSpacing = NULL;
84 newInterface->fFunctions.fGetPathColorGeniv = NULL;
85 newInterface->fFunctions.fGetPathColorGenfv = NULL;
86 newInterface->fFunctions.fGetPathTexGeniv = NULL;
87 newInterface->fFunctions.fGetPathTexGenfv = NULL;
88 newInterface->fFunctions.fIsPointInFillPath = NULL;
89 newInterface->fFunctions.fIsPointInStrokePath = NULL;
90 newInterface->fFunctions.fGetPathLength = NULL;
91 newInterface->fFunctions.fPointAlongPath = NULL;
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000092
93 return newInterface;
94}
95
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000096GrGLInterface::GrGLInterface() {
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000097 fStandard = kNone_GrGLStandard;
bsalomon@google.com0b77d682011-08-19 13:28:54 +000098
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +000099#if GR_GL_PER_GL_FUNC_CALLBACK
100 fCallback = GrGLDefaultInterfaceCallback;
101 fCallbackData = 0;
102#endif
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000103}
104
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +0000105GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
106 SkASSERT(NULL != interface);
107
108 GrGLInterface* clone = SkNEW(GrGLInterface);
109 clone->fStandard = interface->fStandard;
110 clone->fExtensions = interface->fExtensions;
111 clone->fFunctions = interface->fFunctions;
112#if GR_GL_PER_GL_FUNC_CALLBACK
113 clone->fCallback = interface->fCallback;
114 clone->fCallbackData = interface->fCallbackData;
115#endif
116 return clone;
117}
118
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000119#define RETURN_FALSE_INTERFACE \
120 GrDebugCrash("GrGLInterface::validate() failed."); \
121 return false; \
122
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000123bool GrGLInterface::validate() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000124
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000125 if (kNone_GrGLStandard == fStandard) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000126 RETURN_FALSE_INTERFACE
bsalomon@google.com1dcf5062011-11-14 19:29:53 +0000127 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000128
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000129 if (!fExtensions.isInitialized()) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000130 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000131 }
bsalomon@google.com1dcf5062011-11-14 19:29:53 +0000132
133 // functions that are always required
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000134 if (NULL == fFunctions.fActiveTexture ||
135 NULL == fFunctions.fAttachShader ||
136 NULL == fFunctions.fBindAttribLocation ||
137 NULL == fFunctions.fBindBuffer ||
138 NULL == fFunctions.fBindTexture ||
139 NULL == fFunctions.fBlendFunc ||
140 NULL == fFunctions.fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension
141 NULL == fFunctions.fBufferData ||
142 NULL == fFunctions.fBufferSubData ||
143 NULL == fFunctions.fClear ||
144 NULL == fFunctions.fClearColor ||
145 NULL == fFunctions.fClearStencil ||
146 NULL == fFunctions.fColorMask ||
147 NULL == fFunctions.fCompileShader ||
148 NULL == fFunctions.fCopyTexSubImage2D ||
149 NULL == fFunctions.fCreateProgram ||
150 NULL == fFunctions.fCreateShader ||
151 NULL == fFunctions.fCullFace ||
152 NULL == fFunctions.fDeleteBuffers ||
153 NULL == fFunctions.fDeleteProgram ||
154 NULL == fFunctions.fDeleteShader ||
155 NULL == fFunctions.fDeleteTextures ||
156 NULL == fFunctions.fDepthMask ||
157 NULL == fFunctions.fDisable ||
158 NULL == fFunctions.fDisableVertexAttribArray ||
159 NULL == fFunctions.fDrawArrays ||
160 NULL == fFunctions.fDrawElements ||
161 NULL == fFunctions.fEnable ||
162 NULL == fFunctions.fEnableVertexAttribArray ||
163 NULL == fFunctions.fFrontFace ||
164 NULL == fFunctions.fGenBuffers ||
165 NULL == fFunctions.fGenTextures ||
166 NULL == fFunctions.fGetBufferParameteriv ||
167 NULL == fFunctions.fGenerateMipmap ||
168 NULL == fFunctions.fGetError ||
169 NULL == fFunctions.fGetIntegerv ||
170 NULL == fFunctions.fGetProgramInfoLog ||
171 NULL == fFunctions.fGetProgramiv ||
172 NULL == fFunctions.fGetShaderInfoLog ||
173 NULL == fFunctions.fGetShaderiv ||
174 NULL == fFunctions.fGetString ||
175 NULL == fFunctions.fGetUniformLocation ||
176 NULL == fFunctions.fLinkProgram ||
177 NULL == fFunctions.fLineWidth ||
178 NULL == fFunctions.fPixelStorei ||
179 NULL == fFunctions.fReadPixels ||
180 NULL == fFunctions.fScissor ||
181 NULL == fFunctions.fShaderSource ||
182 NULL == fFunctions.fStencilFunc ||
183 NULL == fFunctions.fStencilMask ||
184 NULL == fFunctions.fStencilOp ||
185 NULL == fFunctions.fTexImage2D ||
186 NULL == fFunctions.fTexParameteri ||
187 NULL == fFunctions.fTexParameteriv ||
188 NULL == fFunctions.fTexSubImage2D ||
189 NULL == fFunctions.fUniform1f ||
190 NULL == fFunctions.fUniform1i ||
191 NULL == fFunctions.fUniform1fv ||
192 NULL == fFunctions.fUniform1iv ||
193 NULL == fFunctions.fUniform2f ||
194 NULL == fFunctions.fUniform2i ||
195 NULL == fFunctions.fUniform2fv ||
196 NULL == fFunctions.fUniform2iv ||
197 NULL == fFunctions.fUniform3f ||
198 NULL == fFunctions.fUniform3i ||
199 NULL == fFunctions.fUniform3fv ||
200 NULL == fFunctions.fUniform3iv ||
201 NULL == fFunctions.fUniform4f ||
202 NULL == fFunctions.fUniform4i ||
203 NULL == fFunctions.fUniform4fv ||
204 NULL == fFunctions.fUniform4iv ||
205 NULL == fFunctions.fUniformMatrix2fv ||
206 NULL == fFunctions.fUniformMatrix3fv ||
207 NULL == fFunctions.fUniformMatrix4fv ||
208 NULL == fFunctions.fUseProgram ||
209 NULL == fFunctions.fVertexAttrib4fv ||
210 NULL == fFunctions.fVertexAttribPointer ||
211 NULL == fFunctions.fViewport ||
212 NULL == fFunctions.fBindFramebuffer ||
213 NULL == fFunctions.fBindRenderbuffer ||
214 NULL == fFunctions.fCheckFramebufferStatus ||
215 NULL == fFunctions.fDeleteFramebuffers ||
216 NULL == fFunctions.fDeleteRenderbuffers ||
217 NULL == fFunctions.fFinish ||
218 NULL == fFunctions.fFlush ||
219 NULL == fFunctions.fFramebufferRenderbuffer ||
220 NULL == fFunctions.fFramebufferTexture2D ||
221 NULL == fFunctions.fGetFramebufferAttachmentParameteriv ||
222 NULL == fFunctions.fGetRenderbufferParameteriv ||
223 NULL == fFunctions.fGenFramebuffers ||
224 NULL == fFunctions.fGenRenderbuffers ||
225 NULL == fFunctions.fRenderbufferStorage) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000226 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000227 }
228
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000229 GrGLVersion glVer = GrGLGetVersion(this);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000230
bsalomon@google.comf714d512013-08-30 18:25:21 +0000231 bool isCoreProfile = false;
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000232 if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,2)) {
bsalomon@google.comf714d512013-08-30 18:25:21 +0000233 GrGLint profileMask;
234 GR_GL_GetIntegerv(this, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
235 isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
236 }
237
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000238 // Now check that baseline ES/Desktop fns not covered above are present
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000239 // and that we have fn pointers for any advertised fExtensions that we will
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000240 // try to use.
241
242 // these functions are part of ES2, we assume they are available
243 // On the desktop we assume they are available if the extension
244 // is present or GL version is high enough.
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000245 if (kGLES_GrGLStandard == fStandard) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000246 if (NULL == fFunctions.fStencilFuncSeparate ||
247 NULL == fFunctions.fStencilMaskSeparate ||
248 NULL == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000249 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000250 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000251 } else if (kGL_GrGLStandard == fStandard) {
robertphillips@google.come7884302012-04-18 14:39:58 +0000252
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000253 if (glVer >= GR_GL_VER(2,0)) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000254 if (NULL == fFunctions.fStencilFuncSeparate ||
255 NULL == fFunctions.fStencilMaskSeparate ||
256 NULL == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000257 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000258 }
259 }
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000260 if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000261 RETURN_FALSE_INTERFACE
bsalomon@google.combc5cf512011-09-21 16:21:07 +0000262 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000263 if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000264 if (NULL == fFunctions.fDrawBuffers) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000265 RETURN_FALSE_INTERFACE
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000266 }
267 }
robertphillips@google.come7884302012-04-18 14:39:58 +0000268
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000269 if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000270 if (NULL == fFunctions.fGenQueries ||
271 NULL == fFunctions.fDeleteQueries ||
272 NULL == fFunctions.fBeginQuery ||
273 NULL == fFunctions.fEndQuery ||
274 NULL == fFunctions.fGetQueryiv ||
275 NULL == fFunctions.fGetQueryObjectiv ||
276 NULL == fFunctions.fGetQueryObjectuiv) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000277 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000278 }
279 }
280 if (glVer >= GR_GL_VER(3,3) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000281 fExtensions.has("GL_ARB_timer_query") ||
282 fExtensions.has("GL_EXT_timer_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000283 if (NULL == fFunctions.fGetQueryObjecti64v ||
284 NULL == fFunctions.fGetQueryObjectui64v) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000285 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000286 }
287 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000288 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000289 if (NULL == fFunctions.fQueryCounter) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000290 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000291 }
292 }
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000293 if (!isCoreProfile) {
commit-bot@chromium.org6ebfbf92014-02-24 12:05:02 +0000294 if (NULL == fFunctions.fLoadIdentity ||
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000295 NULL == fFunctions.fLoadMatrixf ||
commit-bot@chromium.org0a6fe712014-04-23 19:26:26 +0000296 NULL == fFunctions.fMatrixMode) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000297 RETURN_FALSE_INTERFACE
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000298 }
bsalomon@google.comfe11cb62012-06-06 15:17:54 +0000299 }
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +0000300 if (fExtensions.has("GL_NV_path_rendering")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000301 if (NULL == fFunctions.fPathCommands ||
302 NULL == fFunctions.fPathCoords ||
303 NULL == fFunctions.fPathSubCommands ||
304 NULL == fFunctions.fPathSubCoords ||
305 NULL == fFunctions.fPathString ||
306 NULL == fFunctions.fPathGlyphs ||
307 NULL == fFunctions.fPathGlyphRange ||
308 NULL == fFunctions.fWeightPaths ||
309 NULL == fFunctions.fCopyPath ||
310 NULL == fFunctions.fInterpolatePaths ||
311 NULL == fFunctions.fTransformPath ||
312 NULL == fFunctions.fPathParameteriv ||
313 NULL == fFunctions.fPathParameteri ||
314 NULL == fFunctions.fPathParameterfv ||
315 NULL == fFunctions.fPathParameterf ||
316 NULL == fFunctions.fPathDashArray ||
317 NULL == fFunctions.fGenPaths ||
318 NULL == fFunctions.fDeletePaths ||
319 NULL == fFunctions.fIsPath ||
320 NULL == fFunctions.fPathStencilFunc ||
321 NULL == fFunctions.fPathStencilDepthOffset ||
322 NULL == fFunctions.fStencilFillPath ||
323 NULL == fFunctions.fStencilStrokePath ||
324 NULL == fFunctions.fStencilFillPathInstanced ||
325 NULL == fFunctions.fStencilStrokePathInstanced ||
326 NULL == fFunctions.fPathCoverDepthFunc ||
327 NULL == fFunctions.fPathColorGen ||
328 NULL == fFunctions.fPathTexGen ||
329 NULL == fFunctions.fPathFogGen ||
330 NULL == fFunctions.fCoverFillPath ||
331 NULL == fFunctions.fCoverStrokePath ||
332 NULL == fFunctions.fCoverFillPathInstanced ||
333 NULL == fFunctions.fCoverStrokePathInstanced ||
334 NULL == fFunctions.fGetPathParameteriv ||
335 NULL == fFunctions.fGetPathParameterfv ||
336 NULL == fFunctions.fGetPathCommands ||
337 NULL == fFunctions.fGetPathCoords ||
338 NULL == fFunctions.fGetPathDashArray ||
339 NULL == fFunctions.fGetPathMetrics ||
340 NULL == fFunctions.fGetPathMetricRange ||
341 NULL == fFunctions.fGetPathSpacing ||
342 NULL == fFunctions.fGetPathColorGeniv ||
343 NULL == fFunctions.fGetPathColorGenfv ||
344 NULL == fFunctions.fGetPathTexGeniv ||
345 NULL == fFunctions.fGetPathTexGenfv ||
346 NULL == fFunctions.fIsPointInFillPath ||
347 NULL == fFunctions.fIsPointInStrokePath ||
348 NULL == fFunctions.fGetPathLength ||
349 NULL == fFunctions.fPointAlongPath) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000350 RETURN_FALSE_INTERFACE
bsalomon@google.comfe11cb62012-06-06 15:17:54 +0000351 }
352 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000353 }
354
355 // optional function on desktop before 1.3
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000356 if (kGL_GrGLStandard != fStandard ||
bsalomon@google.com1744f972013-02-26 21:46:32 +0000357 (glVer >= GR_GL_VER(1,3)) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000358 fExtensions.has("GL_ARB_texture_compression")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000359 if (NULL == fFunctions.fCompressedTexImage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000360 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000361 }
362 }
363
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000364 // part of desktop GL, but not ES
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000365 if (kGL_GrGLStandard == fStandard &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000366 (NULL == fFunctions.fGetTexLevelParameteriv ||
367 NULL == fFunctions.fDrawBuffer ||
368 NULL == fFunctions.fReadBuffer)) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000369 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000370 }
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000371
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000372 // GL_EXT_texture_storage is part of desktop 4.2
373 // There is a desktop ARB extension and an ES+desktop EXT extension
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000374 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000375 if (glVer >= GR_GL_VER(4,2) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000376 fExtensions.has("GL_ARB_texture_storage") ||
377 fExtensions.has("GL_EXT_texture_storage")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000378 if (NULL == fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000379 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000380 }
381 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000382 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000383 if (NULL == fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000384 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000385 }
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000386 }
387
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000388 if (fExtensions.has("GL_EXT_discard_framebuffer")) {
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000389// FIXME: Remove this once Chromium is updated to provide this function
390#if 0
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000391 if (NULL == fFunctions.fDiscardFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000392 RETURN_FALSE_INTERFACE
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000393 }
394#endif
395 }
396
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000397 // FBO MSAA
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000398 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000399 // GL 3.0 and the ARB extension have multisample + blit
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000400 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000401 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
402 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000403 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000404 }
405 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000406 if (fExtensions.has("GL_EXT_framebuffer_blit") &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000407 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000408 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000409 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000410 if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000411 NULL == fFunctions.fRenderbufferStorageMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000412 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000413 }
414 }
415 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000416 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000417 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
418 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000419 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000420 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000421 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000422 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000423 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
424 NULL == fFunctions.fResolveMultisampleFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000425 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000426 }
427 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000428 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
429 fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000430 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
431 NULL == fFunctions.fFramebufferTexture2DMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000432 RETURN_FALSE_INTERFACE
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000433 }
434 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000435 }
436
437 // On ES buffer mapping is an extension. On Desktop
438 // buffer mapping was part of original VBO extension
439 // which we require.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000440 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000441 if (NULL == fFunctions.fMapBuffer ||
442 NULL == fFunctions.fUnmapBuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000443 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000444 }
445 }
446
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000447 // Dual source blending
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000448 if (kGL_GrGLStandard == fStandard &&
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000449 (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000450 if (NULL == fFunctions.fBindFragDataLocationIndexed) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000451 RETURN_FALSE_INTERFACE
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000452 }
453 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000454
commit-bot@chromium.org726e6212013-08-23 20:55:46 +0000455 // glGetStringi was added in version 3.0 of both desktop and ES.
456 if (glVer >= GR_GL_VER(3, 0)) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000457 if (NULL == fFunctions.fGetStringi) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000458 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000459 }
460 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000461
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000462 if (kGL_GrGLStandard == fStandard) {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000463 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000464 if (NULL == fFunctions.fBindVertexArray ||
465 NULL == fFunctions.fDeleteVertexArrays ||
466 NULL == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000467 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000468 }
469 }
470 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000471 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000472 if (NULL == fFunctions.fBindVertexArray ||
473 NULL == fFunctions.fDeleteVertexArrays ||
474 NULL == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000475 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000476 }
477 }
bsalomon@google.comecd84842013-03-01 15:36:02 +0000478 }
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000479
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000480 if (fExtensions.has("GL_EXT_debug_marker")) {
481 if (NULL == fFunctions.fInsertEventMarker ||
482 NULL == fFunctions.fPushGroupMarker ||
483 NULL == fFunctions.fPopGroupMarker) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000484 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000485 }
486 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000487
488#if 0 // This can be enabled once Chromium is updated to set these functions pointers.
489 if ((kGL_GrGLStandard == fStandard) || fExtensions.has("GL_ARB_invalidate_subdata")) {
490 if (NULL == fFunctions.fInvalidateBufferData ||
491 NULL == fFunctions.fInvalidateBufferSubData ||
492 NULL == fFunctions.fInvalidateFramebuffer ||
493 NULL == fFunctions.fInvalidateSubFramebuffer ||
494 NULL == fFunctions.fInvalidateTexImage ||
495 NULL == fFunctions.fInvalidateTexSubImage) {
496 RETURN_FALSE_INTERFACE;
497 }
498 } else if (glVer >= GR_GL_VER(3,0)) {
499 // ES 3.0 adds the framebuffer functions but not the others.
500 if (NULL == fFunctions.fInvalidateFramebuffer ||
501 NULL == fFunctions.fInvalidateSubFramebuffer) {
502 RETURN_FALSE_INTERFACE;
503 }
504 }
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000505
506 if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
507 if (NULL == fFunctions.fMapBufferSubData ||
508 NULL == fFunctions.fMapTexSubImage2D ||
509 NULL == fFunctions.fUnmapBufferSubData ||
510 NULL == fFunctions.fUnmapTexSubImage2D) {
511 RETURN_FALSE_INTERFACE;
512 }
513 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000514#endif
515
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000516 return true;
517}