blob: 8ce8af70983d6555baacca5aa355192181cacf2f [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
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000015const GrGLInterface* GrGLInterfaceAddTestDebugMarker(const GrGLInterface* interface,
16 GrGLInsertEventMarkerProc insertEventMarkerFn,
17 GrGLPushGroupMarkerProc pushGroupMarkerFn,
18 GrGLPopGroupMarkerProc popGroupMarkerFn) {
19 GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
20
21 if (!newInterface->fExtensions.has("GL_EXT_debug_marker")) {
22 newInterface->fExtensions.add("GL_EXT_debug_marker");
23 }
24
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000025 newInterface->fFunctions.fInsertEventMarker = insertEventMarkerFn;
26 newInterface->fFunctions.fPushGroupMarker = pushGroupMarkerFn;
27 newInterface->fFunctions.fPopGroupMarker = popGroupMarkerFn;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000028
29 return newInterface;
30}
31
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000032GrGLInterface::GrGLInterface() {
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000033 fStandard = kNone_GrGLStandard;
bsalomon@google.com0b77d682011-08-19 13:28:54 +000034}
35
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000036GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
bsalomon49f085d2014-09-05 13:34:00 -070037 SkASSERT(interface);
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000038
halcanary385fe4d2015-08-26 13:07:48 -070039 GrGLInterface* clone = new GrGLInterface;
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000040 clone->fStandard = interface->fStandard;
41 clone->fExtensions = interface->fExtensions;
42 clone->fFunctions = interface->fFunctions;
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000043 return clone;
44}
45
commit-bot@chromium.orge83b9b72014-05-01 19:21:41 +000046#ifdef SK_DEBUG
47 static int kIsDebug = 1;
48#else
49 static int kIsDebug = 0;
50#endif
51
52#define RETURN_FALSE_INTERFACE \
53 if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
54 return false;
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000055
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000056bool GrGLInterface::validate() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000057
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000058 if (kNone_GrGLStandard == fStandard) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000059 RETURN_FALSE_INTERFACE
bsalomon@google.com1dcf5062011-11-14 19:29:53 +000060 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +000061
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +000062 if (!fExtensions.isInitialized()) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000063 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +000064 }
bsalomon@google.com1dcf5062011-11-14 19:29:53 +000065
66 // functions that are always required
Mike Klein76343302017-06-22 13:15:13 -070067 if (!fFunctions.fActiveTexture ||
68 !fFunctions.fAttachShader ||
69 !fFunctions.fBindAttribLocation ||
70 !fFunctions.fBindBuffer ||
71 !fFunctions.fBindTexture ||
72 !fFunctions.fBlendColor || // -> GL >= 1.4 or extension, ES >= 2.0
73 !fFunctions.fBlendEquation || // -> GL >= 1.4 or extension, ES >= 2.0
74 !fFunctions.fBlendFunc ||
75 !fFunctions.fBufferData ||
76 !fFunctions.fBufferSubData ||
77 !fFunctions.fClear ||
78 !fFunctions.fClearColor ||
79 !fFunctions.fClearStencil ||
80 !fFunctions.fColorMask ||
81 !fFunctions.fCompileShader ||
82 !fFunctions.fCompressedTexImage2D ||
83 !fFunctions.fCompressedTexSubImage2D ||
84 !fFunctions.fCopyTexSubImage2D ||
85 !fFunctions.fCreateProgram ||
86 !fFunctions.fCreateShader ||
87 !fFunctions.fCullFace ||
88 !fFunctions.fDeleteBuffers ||
89 !fFunctions.fDeleteProgram ||
90 !fFunctions.fDeleteShader ||
91 !fFunctions.fDeleteTextures ||
92 !fFunctions.fDepthMask ||
93 !fFunctions.fDisable ||
94 !fFunctions.fDisableVertexAttribArray ||
95 !fFunctions.fDrawArrays ||
96 !fFunctions.fDrawElements ||
97 !fFunctions.fEnable ||
98 !fFunctions.fEnableVertexAttribArray ||
99 !fFunctions.fFrontFace ||
100 !fFunctions.fGenBuffers ||
101 !fFunctions.fGenTextures ||
102 !fFunctions.fGetBufferParameteriv ||
103 !fFunctions.fGenerateMipmap ||
104 !fFunctions.fGetError ||
105 !fFunctions.fGetIntegerv ||
106 !fFunctions.fGetProgramInfoLog ||
107 !fFunctions.fGetProgramiv ||
108 !fFunctions.fGetShaderInfoLog ||
109 !fFunctions.fGetShaderiv ||
110 !fFunctions.fGetString ||
111 !fFunctions.fGetUniformLocation ||
112 !fFunctions.fIsTexture ||
113 !fFunctions.fLinkProgram ||
114 !fFunctions.fLineWidth ||
115 !fFunctions.fPixelStorei ||
116 !fFunctions.fReadPixels ||
117 !fFunctions.fScissor ||
118 !fFunctions.fShaderSource ||
119 !fFunctions.fStencilFunc ||
120 !fFunctions.fStencilFuncSeparate ||
121 !fFunctions.fStencilMask ||
122 !fFunctions.fStencilMaskSeparate ||
123 !fFunctions.fStencilOp ||
124 !fFunctions.fStencilOpSeparate ||
125 !fFunctions.fTexImage2D ||
126 !fFunctions.fTexParameteri ||
127 !fFunctions.fTexParameteriv ||
128 !fFunctions.fTexSubImage2D ||
129 !fFunctions.fUniform1f ||
130 !fFunctions.fUniform1i ||
131 !fFunctions.fUniform1fv ||
132 !fFunctions.fUniform1iv ||
133 !fFunctions.fUniform2f ||
134 !fFunctions.fUniform2i ||
135 !fFunctions.fUniform2fv ||
136 !fFunctions.fUniform2iv ||
137 !fFunctions.fUniform3f ||
138 !fFunctions.fUniform3i ||
139 !fFunctions.fUniform3fv ||
140 !fFunctions.fUniform3iv ||
141 !fFunctions.fUniform4f ||
142 !fFunctions.fUniform4i ||
143 !fFunctions.fUniform4fv ||
144 !fFunctions.fUniform4iv ||
145 !fFunctions.fUniformMatrix2fv ||
146 !fFunctions.fUniformMatrix3fv ||
147 !fFunctions.fUniformMatrix4fv ||
148 !fFunctions.fUseProgram ||
149 !fFunctions.fVertexAttrib1f ||
150 !fFunctions.fVertexAttrib2fv ||
151 !fFunctions.fVertexAttrib3fv ||
152 !fFunctions.fVertexAttrib4fv ||
153 !fFunctions.fVertexAttribPointer ||
154 !fFunctions.fViewport ||
155 !fFunctions.fBindFramebuffer ||
156 !fFunctions.fBindRenderbuffer ||
157 !fFunctions.fCheckFramebufferStatus ||
158 !fFunctions.fDeleteFramebuffers ||
159 !fFunctions.fDeleteRenderbuffers ||
160 !fFunctions.fFinish ||
161 !fFunctions.fFlush ||
162 !fFunctions.fFramebufferRenderbuffer ||
163 !fFunctions.fFramebufferTexture2D ||
164 !fFunctions.fGetFramebufferAttachmentParameteriv ||
165 !fFunctions.fGetRenderbufferParameteriv ||
166 !fFunctions.fGenFramebuffers ||
167 !fFunctions.fGenRenderbuffers ||
168 !fFunctions.fRenderbufferStorage) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000169 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000170 }
171
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000172 GrGLVersion glVer = GrGLGetVersion(this);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000173 if (GR_GL_INVALID_VER == glVer) {
174 RETURN_FALSE_INTERFACE
175 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000176
177 // Now check that baseline ES/Desktop fns not covered above are present
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000178 // and that we have fn pointers for any advertised fExtensions that we will
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000179 // try to use.
180
181 // these functions are part of ES2, we assume they are available
182 // On the desktop we assume they are available if the extension
183 // is present or GL version is high enough.
Brian Salomonf0861672017-05-08 11:10:10 -0400184 if (kGL_GrGLStandard == fStandard) {
Mike Klein76343302017-06-22 13:15:13 -0700185 if (glVer >= GR_GL_VER(3,0) && !fFunctions.fBindFragDataLocation) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000186 RETURN_FALSE_INTERFACE
bsalomon@google.combc5cf512011-09-21 16:21:07 +0000187 }
robertphillips@google.come7884302012-04-18 14:39:58 +0000188
bsalomon@google.com373a6632011-10-19 20:43:20 +0000189 if (glVer >= GR_GL_VER(3,3) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000190 fExtensions.has("GL_ARB_timer_query") ||
191 fExtensions.has("GL_EXT_timer_query")) {
Mike Klein76343302017-06-22 13:15:13 -0700192 if (!fFunctions.fGetQueryObjecti64v ||
193 !fFunctions.fGetQueryObjectui64v) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000194 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000195 }
196 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000197 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
Mike Klein76343302017-06-22 13:15:13 -0700198 if (!fFunctions.fQueryCounter) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000199 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000200 }
201 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000202 }
203
Brian Salomon15b25092017-05-08 11:10:53 -0400204 // part of desktop GL, but not ES
205 if (kGL_GrGLStandard == fStandard &&
Mike Klein76343302017-06-22 13:15:13 -0700206 (!fFunctions.fDrawBuffer ||
207 !fFunctions.fPolygonMode)) {
Brian Salomon15b25092017-05-08 11:10:53 -0400208 RETURN_FALSE_INTERFACE
209 }
210
211 // ES 3.0 (or ES 2.0 extended) has glDrawBuffers but not glDrawBuffer
212 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,0)) {
Mike Klein76343302017-06-22 13:15:13 -0700213 if (!fFunctions.fDrawBuffers) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000214 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000215 }
216 }
217
Brian Salomon15b25092017-05-08 11:10:53 -0400218 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,0)) {
Mike Klein76343302017-06-22 13:15:13 -0700219 if (!fFunctions.fReadBuffer) {
Brian Salomon15b25092017-05-08 11:10:53 -0400220 RETURN_FALSE_INTERFACE
221 }
222 }
223
224 // glGetTexLevelParameteriv was added to ES in 3.1.
225 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,1)) {
Mike Klein76343302017-06-22 13:15:13 -0700226 if (!fFunctions.fGetTexLevelParameteriv) {
Brian Salomon15b25092017-05-08 11:10:53 -0400227 RETURN_FALSE_INTERFACE
228 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000229 }
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000230
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000231 // GL_EXT_texture_storage is part of desktop 4.2
232 // There is a desktop ARB extension and an ES+desktop EXT extension
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000233 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000234 if (glVer >= GR_GL_VER(4,2) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000235 fExtensions.has("GL_ARB_texture_storage") ||
236 fExtensions.has("GL_EXT_texture_storage")) {
Mike Klein76343302017-06-22 13:15:13 -0700237 if (!fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000238 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000239 }
240 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000241 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
Mike Klein76343302017-06-22 13:15:13 -0700242 if (!fFunctions.fTexStorage2D) {
kkinnunenf655e932016-03-03 07:39:48 -0800243 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000244 }
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000245 }
246
cdaltonfd4167d2015-04-21 11:45:56 -0700247 // glTextureBarrier is part of desktop 4.5. There are also ARB and NV extensions.
248 if (kGL_GrGLStandard == fStandard) {
249 if (glVer >= GR_GL_VER(4,5) ||
250 fExtensions.has("GL_ARB_texture_barrier") ||
251 fExtensions.has("GL_NV_texture_barrier")) {
Mike Klein76343302017-06-22 13:15:13 -0700252 if (!fFunctions.fTextureBarrier) {
cdaltonfd4167d2015-04-21 11:45:56 -0700253 RETURN_FALSE_INTERFACE
254 }
255 }
256 } else if (fExtensions.has("GL_NV_texture_barrier")) {
Mike Klein76343302017-06-22 13:15:13 -0700257 if (!fFunctions.fTextureBarrier) {
cdaltonfd4167d2015-04-21 11:45:56 -0700258 RETURN_FALSE_INTERFACE
259 }
260 }
261
cdaltonbae6f6c2015-04-22 10:39:03 -0700262 if (fExtensions.has("GL_KHR_blend_equation_advanced") ||
263 fExtensions.has("GL_NV_blend_equation_advanced")) {
Mike Klein76343302017-06-22 13:15:13 -0700264 if (!fFunctions.fBlendBarrier) {
cdaltonbae6f6c2015-04-22 10:39:03 -0700265 RETURN_FALSE_INTERFACE
266 }
267 }
268
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000269 if (fExtensions.has("GL_EXT_discard_framebuffer")) {
Mike Klein76343302017-06-22 13:15:13 -0700270 if (!fFunctions.fDiscardFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000271 RETURN_FALSE_INTERFACE
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000272 }
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000273 }
274
Brian Salomon15b25092017-05-08 11:10:53 -0400275 // Required since OpenGL 1.5 and ES 3.0 or with GL_EXT_occlusion_query_boolean
276 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,0) ||
277 fExtensions.has("GL_EXT_occlusion_query_boolean")) {
278#if 0 // Not yet added to chrome's bindings.
Mike Klein76343302017-06-22 13:15:13 -0700279 if (!fFunctions.fGenQueries ||
280 !fFunctions.fDeleteQueries ||
281 !fFunctions.fBeginQuery ||
282 !fFunctions.fEndQuery ||
283 !fFunctions.fGetQueryiv ||
284 !fFunctions.fGetQueryObjectuiv) {
Brian Salomon15b25092017-05-08 11:10:53 -0400285 RETURN_FALSE_INTERFACE
286 }
287#endif
288 }
289 // glGetQueryObjectiv doesn't exist in ES.
Mike Klein76343302017-06-22 13:15:13 -0700290 if (kGL_GrGLStandard == fStandard && !fFunctions.fGetQueryObjectiv) {
Brian Salomon15b25092017-05-08 11:10:53 -0400291 RETURN_FALSE_INTERFACE
292 }
293
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000294 // FBO MSAA
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000295 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000296 // GL 3.0 and the ARB extension have multisample + blit
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000297 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
Mike Klein76343302017-06-22 13:15:13 -0700298 if (!fFunctions.fRenderbufferStorageMultisample ||
299 !fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000300 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000301 }
302 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000303 if (fExtensions.has("GL_EXT_framebuffer_blit") &&
Mike Klein76343302017-06-22 13:15:13 -0700304 !fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000305 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000306 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000307 if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
Mike Klein76343302017-06-22 13:15:13 -0700308 !fFunctions.fRenderbufferStorageMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000309 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000310 }
311 }
312 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000313 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
Mike Klein76343302017-06-22 13:15:13 -0700314 if (!fFunctions.fRenderbufferStorageMultisample ||
315 !fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000316 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000317 }
Brian Salomonc5eceb02016-10-18 10:21:43 -0400318 } else {
319 if (fExtensions.has("GL_ANGLE_framebuffer_multisample") &&
Mike Klein76343302017-06-22 13:15:13 -0700320 !fFunctions.fRenderbufferStorageMultisample) {
Brian Salomonc5eceb02016-10-18 10:21:43 -0400321 RETURN_FALSE_INTERFACE
322 }
323 if (fExtensions.has("GL_ANGLE_framebuffer_blit") &&
Mike Klein76343302017-06-22 13:15:13 -0700324 !fFunctions.fBlitFramebuffer) {
Brian Salomonc5eceb02016-10-18 10:21:43 -0400325 RETURN_FALSE_INTERFACE
326 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000327 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000328 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
Mike Klein76343302017-06-22 13:15:13 -0700329 if (!fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
330 !fFunctions.fResolveMultisampleFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000331 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000332 }
333 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000334 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
335 fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
Mike Klein76343302017-06-22 13:15:13 -0700336 if (!fFunctions.fRenderbufferStorageMultisampleES2EXT ||
337 !fFunctions.fFramebufferTexture2DMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000338 RETURN_FALSE_INTERFACE
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000339 }
340 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000341 }
342
343 // On ES buffer mapping is an extension. On Desktop
344 // buffer mapping was part of original VBO extension
345 // which we require.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000346 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
Mike Klein76343302017-06-22 13:15:13 -0700347 if (!fFunctions.fMapBuffer ||
348 !fFunctions.fUnmapBuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000349 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000350 }
351 }
352
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000353 // Dual source blending
kkinnunend94708e2015-07-30 22:47:04 -0700354 if (kGL_GrGLStandard == fStandard) {
355 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended")) {
Mike Klein76343302017-06-22 13:15:13 -0700356 if (!fFunctions.fBindFragDataLocationIndexed) {
kkinnunend94708e2015-07-30 22:47:04 -0700357 RETURN_FALSE_INTERFACE
358 }
359 }
360 } else {
361 if (glVer >= GR_GL_VER(3,0) && fExtensions.has("GL_EXT_blend_func_extended")) {
Mike Klein76343302017-06-22 13:15:13 -0700362 if (!fFunctions.fBindFragDataLocation ||
363 !fFunctions.fBindFragDataLocationIndexed) {
kkinnunend94708e2015-07-30 22:47:04 -0700364 RETURN_FALSE_INTERFACE
365 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000366 }
367 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000368
kkinnunend94708e2015-07-30 22:47:04 -0700369
commit-bot@chromium.org726e6212013-08-23 20:55:46 +0000370 // glGetStringi was added in version 3.0 of both desktop and ES.
371 if (glVer >= GR_GL_VER(3, 0)) {
Mike Klein76343302017-06-22 13:15:13 -0700372 if (!fFunctions.fGetStringi) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000373 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000374 }
375 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000376
cdalton793dc262016-02-08 10:11:47 -0800377 // glVertexAttribIPointer was added in version 3.0 of both desktop and ES.
378 if (glVer >= GR_GL_VER(3, 0)) {
Mike Klein76343302017-06-22 13:15:13 -0700379 if (!fFunctions.fVertexAttribIPointer) {
cdalton793dc262016-02-08 10:11:47 -0800380 RETURN_FALSE_INTERFACE
381 }
382 }
383
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000384 if (kGL_GrGLStandard == fStandard) {
cdaltonc04ce672016-03-11 14:07:38 -0800385 if (glVer >= GR_GL_VER(3,1)) {
Mike Klein76343302017-06-22 13:15:13 -0700386 if (!fFunctions.fTexBuffer) {
cdaltonc04ce672016-03-11 14:07:38 -0800387 RETURN_FALSE_INTERFACE;
388 }
389 }
cdaltonf8a6ce82016-04-11 13:02:05 -0700390 if (glVer >= GR_GL_VER(4,3)) {
Mike Klein76343302017-06-22 13:15:13 -0700391 if (!fFunctions.fTexBufferRange) {
cdaltonf8a6ce82016-04-11 13:02:05 -0700392 RETURN_FALSE_INTERFACE;
393 }
394 }
cdaltonc04ce672016-03-11 14:07:38 -0800395 } else {
396 if (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_OES_texture_buffer") ||
397 fExtensions.has("GL_EXT_texture_buffer")) {
Mike Klein76343302017-06-22 13:15:13 -0700398 if (!fFunctions.fTexBuffer ||
399 !fFunctions.fTexBufferRange) {
cdaltonc04ce672016-03-11 14:07:38 -0800400 RETURN_FALSE_INTERFACE;
401 }
402 }
403 }
404
405 if (kGL_GrGLStandard == fStandard) {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000406 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
Mike Klein76343302017-06-22 13:15:13 -0700407 if (!fFunctions.fBindVertexArray ||
408 !fFunctions.fDeleteVertexArrays ||
409 !fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000410 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000411 }
412 }
413 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000414 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
Mike Klein76343302017-06-22 13:15:13 -0700415 if (!fFunctions.fBindVertexArray ||
416 !fFunctions.fDeleteVertexArrays ||
417 !fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000418 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000419 }
420 }
bsalomon@google.comecd84842013-03-01 15:36:02 +0000421 }
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000422
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000423 if (fExtensions.has("GL_EXT_debug_marker")) {
Mike Klein76343302017-06-22 13:15:13 -0700424 if (!fFunctions.fInsertEventMarker ||
425 !fFunctions.fPushGroupMarker ||
426 !fFunctions.fPopGroupMarker) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000427 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000428 }
429 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000430
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000431 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
432 fExtensions.has("GL_ARB_invalidate_subdata")) {
Mike Klein76343302017-06-22 13:15:13 -0700433 if (!fFunctions.fInvalidateBufferData ||
434 !fFunctions.fInvalidateBufferSubData ||
435 !fFunctions.fInvalidateFramebuffer ||
436 !fFunctions.fInvalidateSubFramebuffer ||
437 !fFunctions.fInvalidateTexImage ||
438 !fFunctions.fInvalidateTexSubImage) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000439 RETURN_FALSE_INTERFACE;
440 }
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000441 } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000442 // ES 3.0 adds the framebuffer functions but not the others.
Mike Klein76343302017-06-22 13:15:13 -0700443 if (!fFunctions.fInvalidateFramebuffer ||
444 !fFunctions.fInvalidateSubFramebuffer) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000445 RETURN_FALSE_INTERFACE;
446 }
447 }
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000448
449 if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
Mike Klein76343302017-06-22 13:15:13 -0700450 if (!fFunctions.fMapBufferSubData ||
451 !fFunctions.fMapTexSubImage2D ||
452 !fFunctions.fUnmapBufferSubData ||
453 !fFunctions.fUnmapTexSubImage2D) {
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000454 RETURN_FALSE_INTERFACE;
455 }
456 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000457
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000458 // These functions are added to the 3.0 version of both GLES and GL.
459 if (glVer >= GR_GL_VER(3,0) ||
460 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
461 (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
Mike Klein76343302017-06-22 13:15:13 -0700462 if (!fFunctions.fMapBufferRange ||
463 !fFunctions.fFlushMappedBufferRange) {
kkinnunenf655e932016-03-03 07:39:48 -0800464 RETURN_FALSE_INTERFACE;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000465 }
466 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700467
kkinnunen32b9a3b2014-07-02 22:56:35 -0700468 if ((kGL_GrGLStandard == fStandard &&
cdaltoneb79eea2016-02-26 10:39:34 -0800469 (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_ARB_texture_multisample"))) ||
470 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
Mike Klein76343302017-06-22 13:15:13 -0700471 if (!fFunctions.fGetMultisamplefv) {
cdaltoneb79eea2016-02-26 10:39:34 -0800472 RETURN_FALSE_INTERFACE
473 }
474 }
475
476 if ((kGL_GrGLStandard == fStandard &&
kkinnunen32b9a3b2014-07-02 22:56:35 -0700477 (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) ||
478 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
Mike Klein76343302017-06-22 13:15:13 -0700479 if (!fFunctions.fGetProgramResourceLocation) {
kkinnunen32b9a3b2014-07-02 22:56:35 -0700480 RETURN_FALSE_INTERFACE
481 }
482 }
483
bsalomonee64d6e2014-12-03 10:46:08 -0800484 if (kGLES_GrGLStandard == fStandard || glVer >= GR_GL_VER(4,1) ||
485 fExtensions.has("GL_ARB_ES2_compatibility")) {
Mike Klein76343302017-06-22 13:15:13 -0700486 if (!fFunctions.fGetShaderPrecisionFormat) {
bsalomonee64d6e2014-12-03 10:46:08 -0800487 RETURN_FALSE_INTERFACE
488 }
bsalomonee64d6e2014-12-03 10:46:08 -0800489 }
490
kkinnunen6bb6d402015-07-14 10:59:23 -0700491 if (fExtensions.has("GL_NV_path_rendering") || fExtensions.has("GL_CHROMIUM_path_rendering")) {
Mike Klein76343302017-06-22 13:15:13 -0700492 if (!fFunctions.fMatrixLoadf ||
493 !fFunctions.fMatrixLoadIdentity ||
494 !fFunctions.fPathCommands ||
495 !fFunctions.fPathParameteri ||
496 !fFunctions.fPathParameterf ||
497 !fFunctions.fGenPaths ||
498 !fFunctions.fDeletePaths ||
499 !fFunctions.fIsPath ||
500 !fFunctions.fPathStencilFunc ||
501 !fFunctions.fStencilFillPath ||
502 !fFunctions.fStencilStrokePath ||
503 !fFunctions.fStencilFillPathInstanced ||
504 !fFunctions.fStencilStrokePathInstanced ||
505 !fFunctions.fCoverFillPath ||
506 !fFunctions.fCoverStrokePath ||
507 !fFunctions.fCoverFillPathInstanced ||
508 !fFunctions.fCoverStrokePathInstanced
kkinnunencfe62e32015-07-01 02:58:50 -0700509#if 0
510 // List of functions that Skia uses, but which have been added since the initial release
511 // of NV_path_rendering driver. We do not want to fail interface validation due to
512 // missing features, we will just not use the extension.
513 // Update this list -> update GrGLCaps::hasPathRenderingSupport too.
Mike Klein76343302017-06-22 13:15:13 -0700514 || !fFunctions.fStencilThenCoverFillPath ||
515 !fFunctions.fStencilThenCoverStrokePath ||
516 !fFunctions.fStencilThenCoverFillPathInstanced ||
517 !fFunctions.fStencilThenCoverStrokePathInstanced ||
518 !fFunctions.fProgramPathFragmentInputGen
kkinnunencfe62e32015-07-01 02:58:50 -0700519#endif
520 ) {
kkinnunen32b9a3b2014-07-02 22:56:35 -0700521 RETURN_FALSE_INTERFACE
522 }
kkinnunen6bb6d402015-07-14 10:59:23 -0700523 if (fExtensions.has("GL_CHROMIUM_path_rendering")) {
Mike Klein76343302017-06-22 13:15:13 -0700524 if (!fFunctions.fBindFragmentInputLocation) {
kkinnunen6bb6d402015-07-14 10:59:23 -0700525 RETURN_FALSE_INTERFACE
526 }
527 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700528 }
529
cdalton0edea2c2015-05-21 08:27:44 -0700530 if (fExtensions.has("GL_EXT_raster_multisample")) {
Mike Klein76343302017-06-22 13:15:13 -0700531 if (!fFunctions.fRasterSamples) {
cdalton0edea2c2015-05-21 08:27:44 -0700532 RETURN_FALSE_INTERFACE
533 }
534 }
535
kkinnunenea409432015-12-10 01:21:59 -0800536 if (fExtensions.has("GL_NV_framebuffer_mixed_samples") ||
537 fExtensions.has("GL_CHROMIUM_framebuffer_mixed_samples")) {
Mike Klein76343302017-06-22 13:15:13 -0700538 if (!fFunctions.fCoverageModulation) {
vbuzinov08b4d292015-04-01 06:29:49 -0700539 RETURN_FALSE_INTERFACE
540 }
541 }
542
hendrikwb3f16362015-10-19 06:13:55 -0700543 if (kGL_GrGLStandard == fStandard) {
544 if (glVer >= GR_GL_VER(3,1) ||
545 fExtensions.has("GL_EXT_draw_instanced") || fExtensions.has("GL_ARB_draw_instanced")) {
Mike Klein76343302017-06-22 13:15:13 -0700546 if (!fFunctions.fDrawArraysInstanced ||
547 !fFunctions.fDrawElementsInstanced) {
hendrikwb3f16362015-10-19 06:13:55 -0700548 RETURN_FALSE_INTERFACE
549 }
halcanary9d524f22016-03-29 09:03:52 -0700550 }
hendrikwb3f16362015-10-19 06:13:55 -0700551 } else if (kGLES_GrGLStandard == fStandard) {
kkinnunenf655e932016-03-03 07:39:48 -0800552 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_draw_instanced")) {
Mike Klein76343302017-06-22 13:15:13 -0700553 if (!fFunctions.fDrawArraysInstanced ||
554 !fFunctions.fDrawElementsInstanced) {
kkinnunenf655e932016-03-03 07:39:48 -0800555 RETURN_FALSE_INTERFACE
hendrikwb3f16362015-10-19 06:13:55 -0700556 }
halcanary9d524f22016-03-29 09:03:52 -0700557 }
cdalton626e1ff2015-06-12 13:56:46 -0700558 }
559
hendrikwb3f16362015-10-19 06:13:55 -0700560 if (kGL_GrGLStandard == fStandard) {
561 if (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_ARB_instanced_arrays")) {
Mike Klein76343302017-06-22 13:15:13 -0700562 if (!fFunctions.fVertexAttribDivisor) {
hendrikwb3f16362015-10-19 06:13:55 -0700563 RETURN_FALSE_INTERFACE
564 }
halcanary9d524f22016-03-29 09:03:52 -0700565 }
hendrikwb3f16362015-10-19 06:13:55 -0700566 } else if (kGLES_GrGLStandard == fStandard) {
kkinnunenf655e932016-03-03 07:39:48 -0800567 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_instanced_arrays")) {
Mike Klein76343302017-06-22 13:15:13 -0700568 if (!fFunctions.fVertexAttribDivisor) {
kkinnunenf655e932016-03-03 07:39:48 -0800569 RETURN_FALSE_INTERFACE
hendrikwb3f16362015-10-19 06:13:55 -0700570 }
halcanary9d524f22016-03-29 09:03:52 -0700571 }
cdalton626e1ff2015-06-12 13:56:46 -0700572 }
573
csmartdalton5cebf8c2016-06-03 08:28:47 -0700574 if ((kGL_GrGLStandard == fStandard &&
575 (glVer >= GR_GL_VER(4,0) || fExtensions.has("GL_ARB_draw_indirect"))) ||
cdalton06604b92016-02-05 10:09:51 -0800576 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
Mike Klein76343302017-06-22 13:15:13 -0700577 if (!fFunctions.fDrawArraysIndirect ||
578 !fFunctions.fDrawElementsIndirect) {
cdalton06604b92016-02-05 10:09:51 -0800579 RETURN_FALSE_INTERFACE
580 }
581 }
582
csmartdalton5cebf8c2016-06-03 08:28:47 -0700583 if ((kGL_GrGLStandard == fStandard &&
584 (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_multi_draw_indirect"))) ||
cdalton06604b92016-02-05 10:09:51 -0800585 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_multi_draw_indirect"))) {
Mike Klein76343302017-06-22 13:15:13 -0700586 if (!fFunctions.fMultiDrawArraysIndirect ||
587 !fFunctions.fMultiDrawElementsIndirect) {
cdalton06604b92016-02-05 10:09:51 -0800588 RETURN_FALSE_INTERFACE
589 }
590 }
591
cdalton626e1ff2015-06-12 13:56:46 -0700592 if (fExtensions.has("GL_NV_bindless_texture")) {
Mike Klein76343302017-06-22 13:15:13 -0700593 if (!fFunctions.fGetTextureHandle ||
594 !fFunctions.fGetTextureSamplerHandle ||
595 !fFunctions.fMakeTextureHandleResident ||
596 !fFunctions.fMakeTextureHandleNonResident ||
597 !fFunctions.fGetImageHandle ||
598 !fFunctions.fMakeImageHandleResident ||
599 !fFunctions.fMakeImageHandleNonResident ||
600 !fFunctions.fIsTextureHandleResident ||
601 !fFunctions.fIsImageHandleResident ||
602 !fFunctions.fUniformHandleui64 ||
603 !fFunctions.fUniformHandleui64v ||
604 !fFunctions.fProgramUniformHandleui64 ||
605 !fFunctions.fProgramUniformHandleui64v) {
cdalton626e1ff2015-06-12 13:56:46 -0700606 RETURN_FALSE_INTERFACE
607 }
608 }
609
610 if (kGL_GrGLStandard == fStandard && fExtensions.has("GL_EXT_direct_state_access")) {
Mike Klein76343302017-06-22 13:15:13 -0700611 if (!fFunctions.fTextureParameteri ||
612 !fFunctions.fTextureParameteriv ||
613 !fFunctions.fTextureParameterf ||
614 !fFunctions.fTextureParameterfv ||
615 !fFunctions.fTextureImage1D ||
616 !fFunctions.fTextureImage2D ||
617 !fFunctions.fTextureSubImage1D ||
618 !fFunctions.fTextureSubImage2D ||
619 !fFunctions.fCopyTextureImage1D ||
620 !fFunctions.fCopyTextureImage2D ||
621 !fFunctions.fCopyTextureSubImage1D ||
622 !fFunctions.fCopyTextureSubImage2D ||
623 !fFunctions.fGetNamedBufferParameteriv ||
624 !fFunctions.fGetNamedBufferPointerv ||
625 !fFunctions.fGetNamedBufferSubData ||
626 !fFunctions.fGetTextureImage ||
627 !fFunctions.fGetTextureParameterfv ||
628 !fFunctions.fGetTextureParameteriv ||
629 !fFunctions.fGetTextureLevelParameterfv ||
630 !fFunctions.fGetTextureLevelParameteriv ||
631 !fFunctions.fMapNamedBuffer ||
632 !fFunctions.fNamedBufferData ||
633 !fFunctions.fNamedBufferSubData ||
634 !fFunctions.fProgramUniform1f ||
635 !fFunctions.fProgramUniform2f ||
636 !fFunctions.fProgramUniform3f ||
637 !fFunctions.fProgramUniform4f ||
638 !fFunctions.fProgramUniform1i ||
639 !fFunctions.fProgramUniform2i ||
640 !fFunctions.fProgramUniform3i ||
641 !fFunctions.fProgramUniform4i ||
642 !fFunctions.fProgramUniform1fv ||
643 !fFunctions.fProgramUniform2fv ||
644 !fFunctions.fProgramUniform3fv ||
645 !fFunctions.fProgramUniform4fv ||
646 !fFunctions.fProgramUniform1iv ||
647 !fFunctions.fProgramUniform2iv ||
648 !fFunctions.fProgramUniform3iv ||
649 !fFunctions.fProgramUniform4iv ||
650 !fFunctions.fProgramUniformMatrix2fv ||
651 !fFunctions.fProgramUniformMatrix3fv ||
652 !fFunctions.fProgramUniformMatrix4fv ||
653 !fFunctions.fUnmapNamedBuffer) {
cdalton626e1ff2015-06-12 13:56:46 -0700654 RETURN_FALSE_INTERFACE
655 }
656 if (glVer >= GR_GL_VER(1,2)) {
Mike Klein76343302017-06-22 13:15:13 -0700657 if (!fFunctions.fTextureImage3D ||
658 !fFunctions.fTextureSubImage3D ||
659 !fFunctions.fCopyTextureSubImage3D ||
660 !fFunctions.fCompressedTextureImage3D ||
661 !fFunctions.fCompressedTextureImage2D ||
662 !fFunctions.fCompressedTextureImage1D ||
663 !fFunctions.fCompressedTextureSubImage3D ||
664 !fFunctions.fCompressedTextureSubImage2D ||
665 !fFunctions.fCompressedTextureSubImage1D ||
666 !fFunctions.fGetCompressedTextureImage) {
cdalton626e1ff2015-06-12 13:56:46 -0700667 RETURN_FALSE_INTERFACE
668 }
669 }
cdalton626e1ff2015-06-12 13:56:46 -0700670 if (glVer >= GR_GL_VER(2,1)) {
Mike Klein76343302017-06-22 13:15:13 -0700671 if (!fFunctions.fProgramUniformMatrix2x3fv ||
672 !fFunctions.fProgramUniformMatrix3x2fv ||
673 !fFunctions.fProgramUniformMatrix2x4fv ||
674 !fFunctions.fProgramUniformMatrix4x2fv ||
675 !fFunctions.fProgramUniformMatrix3x4fv ||
676 !fFunctions.fProgramUniformMatrix4x3fv) {
cdalton626e1ff2015-06-12 13:56:46 -0700677 RETURN_FALSE_INTERFACE
678 }
679 }
680 if (glVer >= GR_GL_VER(3,0)) {
Mike Klein76343302017-06-22 13:15:13 -0700681 if (!fFunctions.fNamedRenderbufferStorage ||
682 !fFunctions.fGetNamedRenderbufferParameteriv ||
683 !fFunctions.fNamedRenderbufferStorageMultisample ||
684 !fFunctions.fCheckNamedFramebufferStatus ||
685 !fFunctions.fNamedFramebufferTexture1D ||
686 !fFunctions.fNamedFramebufferTexture2D ||
687 !fFunctions.fNamedFramebufferTexture3D ||
688 !fFunctions.fNamedFramebufferRenderbuffer ||
689 !fFunctions.fGetNamedFramebufferAttachmentParameteriv ||
690 !fFunctions.fGenerateTextureMipmap ||
691 !fFunctions.fFramebufferDrawBuffer ||
692 !fFunctions.fFramebufferDrawBuffers ||
693 !fFunctions.fFramebufferReadBuffer ||
694 !fFunctions.fGetFramebufferParameteriv ||
695 !fFunctions.fNamedCopyBufferSubData ||
696 !fFunctions.fVertexArrayVertexOffset ||
697 !fFunctions.fVertexArrayColorOffset ||
698 !fFunctions.fVertexArrayEdgeFlagOffset ||
699 !fFunctions.fVertexArrayIndexOffset ||
700 !fFunctions.fVertexArrayNormalOffset ||
701 !fFunctions.fVertexArrayTexCoordOffset ||
702 !fFunctions.fVertexArrayMultiTexCoordOffset ||
703 !fFunctions.fVertexArrayFogCoordOffset ||
704 !fFunctions.fVertexArraySecondaryColorOffset ||
705 !fFunctions.fVertexArrayVertexAttribOffset ||
706 !fFunctions.fVertexArrayVertexAttribIOffset ||
707 !fFunctions.fEnableVertexArray ||
708 !fFunctions.fDisableVertexArray ||
709 !fFunctions.fEnableVertexArrayAttrib ||
710 !fFunctions.fDisableVertexArrayAttrib ||
711 !fFunctions.fGetVertexArrayIntegerv ||
712 !fFunctions.fGetVertexArrayPointerv ||
713 !fFunctions.fGetVertexArrayIntegeri_v ||
714 !fFunctions.fGetVertexArrayPointeri_v ||
715 !fFunctions.fMapNamedBufferRange ||
716 !fFunctions.fFlushMappedNamedBufferRange) {
cdalton626e1ff2015-06-12 13:56:46 -0700717 RETURN_FALSE_INTERFACE
718 }
719 }
cdaltonc04ce672016-03-11 14:07:38 -0800720 if (glVer >= GR_GL_VER(3,1)) {
Mike Klein76343302017-06-22 13:15:13 -0700721 if (!fFunctions.fTextureBuffer) {
cdaltonc04ce672016-03-11 14:07:38 -0800722 RETURN_FALSE_INTERFACE;
723 }
724 }
cdalton626e1ff2015-06-12 13:56:46 -0700725 }
726
727 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
728 fExtensions.has("GL_KHR_debug")) {
Mike Klein76343302017-06-22 13:15:13 -0700729 if (!fFunctions.fDebugMessageControl ||
730 !fFunctions.fDebugMessageInsert ||
731 !fFunctions.fDebugMessageCallback ||
732 !fFunctions.fGetDebugMessageLog ||
733 !fFunctions.fPushDebugGroup ||
734 !fFunctions.fPopDebugGroup ||
735 !fFunctions.fObjectLabel) {
cdalton626e1ff2015-06-12 13:56:46 -0700736 RETURN_FALSE_INTERFACE
737 }
738 }
739
csmartdalton9bc11872016-08-09 12:42:47 -0700740 if (fExtensions.has("GL_EXT_window_rectangles")) {
Mike Klein76343302017-06-22 13:15:13 -0700741 if (!fFunctions.fWindowRectangles) {
csmartdalton9bc11872016-08-09 12:42:47 -0700742 RETURN_FALSE_INTERFACE
743 }
744 }
745
ethannicholas28ef4452016-03-25 09:26:03 -0700746 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,0)) ||
747 fExtensions.has("GL_ARB_sample_shading")) {
Mike Klein76343302017-06-22 13:15:13 -0700748 if (!fFunctions.fMinSampleShading) {
ethannicholas28ef4452016-03-25 09:26:03 -0700749 RETURN_FALSE_INTERFACE
750 }
bsalomon23c4f1a2016-07-19 06:21:55 -0700751 } else if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_OES_sample_shading")) {
Mike Klein76343302017-06-22 13:15:13 -0700752 if (!fFunctions.fMinSampleShading) {
ethannicholas28ef4452016-03-25 09:26:03 -0700753 RETURN_FALSE_INTERFACE
754 }
755 }
756
jvanverth84741b32016-09-30 08:39:02 -0700757 if (kGL_GrGLStandard == fStandard) {
758 if (glVer >= GR_GL_VER(3, 2) || fExtensions.has("GL_ARB_sync")) {
Mike Klein76343302017-06-22 13:15:13 -0700759 if (!fFunctions.fFenceSync ||
Greg Daniel6bd729d2017-07-31 09:38:23 -0400760 !fFunctions.fIsSync ||
Mike Klein76343302017-06-22 13:15:13 -0700761 !fFunctions.fClientWaitSync ||
762 !fFunctions.fWaitSync ||
763 !fFunctions.fDeleteSync) {
jvanverth84741b32016-09-30 08:39:02 -0700764 RETURN_FALSE_INTERFACE
765 }
766 }
767 } else if (kGLES_GrGLStandard == fStandard) {
Brian Osman93a23462017-06-21 15:13:39 -0400768 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_APPLE_sync")) {
Mike Klein76343302017-06-22 13:15:13 -0700769 if (!fFunctions.fFenceSync ||
Greg Daniel6bd729d2017-07-31 09:38:23 -0400770 !fFunctions.fIsSync ||
Mike Klein76343302017-06-22 13:15:13 -0700771 !fFunctions.fClientWaitSync ||
772 !fFunctions.fWaitSync ||
773 !fFunctions.fDeleteSync) {
jvanverth84741b32016-09-30 08:39:02 -0700774 RETURN_FALSE_INTERFACE
775 }
776 }
777 }
778
bsalomonb1a32ad2015-11-16 06:48:44 -0800779 if (fExtensions.has("EGL_KHR_image") || fExtensions.has("EGL_KHR_image_base")) {
Mike Klein76343302017-06-22 13:15:13 -0700780 if (!fFunctions.fEGLCreateImage ||
781 !fFunctions.fEGLDestroyImage) {
bsalomonb1a32ad2015-11-16 06:48:44 -0800782 RETURN_FALSE_INTERFACE
783 }
784 }
785
Brian Salomon15b25092017-05-08 11:10:53 -0400786 // glDrawRangeElements was added to ES in 3.0.
787 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,0)) {
Mike Klein76343302017-06-22 13:15:13 -0700788 if (!fFunctions.fDrawRangeElements) {
bsalomonfc9527a2016-08-29 09:18:39 -0700789 RETURN_FALSE_INTERFACE;
790 }
791 }
792
Brian Salomon0b63ceb2016-11-15 12:36:29 -0500793 if (kGL_GrGLStandard == fStandard) {
794 if (glVer >= GR_GL_VER(4,2) || fExtensions.has("GL_ARB_shader_image_load_store")) {
Mike Klein76343302017-06-22 13:15:13 -0700795 if (!fFunctions.fBindImageTexture ||
796 !fFunctions.fMemoryBarrier) {
Brian Salomon0b63ceb2016-11-15 12:36:29 -0500797 RETURN_FALSE_INTERFACE;
798 }
799 }
800 if (glVer >= GR_GL_VER(4,5) || fExtensions.has("GL_ARB_ES3_1_compatibility")) {
Mike Klein76343302017-06-22 13:15:13 -0700801 if (!fFunctions.fMemoryBarrierByRegion) {
Brian Salomon0b63ceb2016-11-15 12:36:29 -0500802 RETURN_FALSE_INTERFACE;
803 }
804 }
805 } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1)) {
Mike Klein76343302017-06-22 13:15:13 -0700806 if (!fFunctions.fBindImageTexture ||
807 !fFunctions.fMemoryBarrier ||
808 !fFunctions.fMemoryBarrierByRegion) {
Brian Salomon0b63ceb2016-11-15 12:36:29 -0500809 RETURN_FALSE_INTERFACE;
810 }
811 }
812
Greg Daniel81e7bf82017-07-19 14:47:42 -0400813 // getInternalformativ was added in GL 4.2, ES 3.0, and with extension ARB_internalformat_query
814 if ((kGL_GrGLStandard == fStandard &&
815 (glVer >= GR_GL_VER(4,2) || fExtensions.has("GL_ARB_internalformat_query"))) ||
816 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0))) {
Mike Klein76343302017-06-22 13:15:13 -0700817 if (!fFunctions.fGetInternalformativ) {
Greg Daniel6bd729d2017-07-31 09:38:23 -0400818 RETURN_FALSE_INTERFACE;
Greg Daniel81e7bf82017-07-19 14:47:42 -0400819 }
820 }
821
Ethan Nicholasd1b2eec2017-11-01 15:45:43 -0400822 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,1)) ||
823 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0))) {
824 if (!fFunctions.fGetProgramBinary ||
825 !fFunctions.fProgramBinary ||
826 !fFunctions.fProgramParameteri) {
827 RETURN_FALSE_INTERFACE;
828 }
829 }
830
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000831 return true;
832}