blob: 72c2b46d416f40b9d85a09a37da36f634bd500d6 [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.orgd8ed8512014-01-24 20:49:44 +000032const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) {
33 GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
34
35 newInterface->fExtensions.remove("GL_NV_path_rendering");
kkinnunen2ca29c02015-12-09 22:58:34 -080036 newInterface->fExtensions.remove("GL_CHROMIUM_path_rendering");
37 newInterface->fFunctions.fMatrixLoadf = nullptr;
38 newInterface->fFunctions.fMatrixLoadIdentity = nullptr;
halcanary96fcdcc2015-08-27 07:41:13 -070039 newInterface->fFunctions.fPathCommands = nullptr;
40 newInterface->fFunctions.fPathParameteri = nullptr;
41 newInterface->fFunctions.fPathParameterf = nullptr;
42 newInterface->fFunctions.fGenPaths = nullptr;
43 newInterface->fFunctions.fDeletePaths = nullptr;
44 newInterface->fFunctions.fIsPath = nullptr;
45 newInterface->fFunctions.fPathStencilFunc = nullptr;
46 newInterface->fFunctions.fStencilFillPath = nullptr;
47 newInterface->fFunctions.fStencilStrokePath = nullptr;
48 newInterface->fFunctions.fStencilFillPathInstanced = nullptr;
49 newInterface->fFunctions.fStencilStrokePathInstanced = nullptr;
50 newInterface->fFunctions.fCoverFillPath = nullptr;
51 newInterface->fFunctions.fCoverStrokePath = nullptr;
52 newInterface->fFunctions.fCoverFillPathInstanced = nullptr;
53 newInterface->fFunctions.fCoverStrokePathInstanced = nullptr;
54 newInterface->fFunctions.fStencilThenCoverFillPath = nullptr;
55 newInterface->fFunctions.fStencilThenCoverStrokePath = nullptr;
56 newInterface->fFunctions.fStencilThenCoverFillPathInstanced = nullptr;
57 newInterface->fFunctions.fStencilThenCoverStrokePathInstanced = nullptr;
58 newInterface->fFunctions.fProgramPathFragmentInputGen = nullptr;
59 newInterface->fFunctions.fBindFragmentInputLocation = nullptr;
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000060 return newInterface;
61}
62
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000063GrGLInterface::GrGLInterface() {
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000064 fStandard = kNone_GrGLStandard;
bsalomon@google.com0b77d682011-08-19 13:28:54 +000065}
66
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000067GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
bsalomon49f085d2014-09-05 13:34:00 -070068 SkASSERT(interface);
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000069
halcanary385fe4d2015-08-26 13:07:48 -070070 GrGLInterface* clone = new GrGLInterface;
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000071 clone->fStandard = interface->fStandard;
72 clone->fExtensions = interface->fExtensions;
73 clone->fFunctions = interface->fFunctions;
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000074 return clone;
75}
76
commit-bot@chromium.orge83b9b72014-05-01 19:21:41 +000077#ifdef SK_DEBUG
78 static int kIsDebug = 1;
79#else
80 static int kIsDebug = 0;
81#endif
82
83#define RETURN_FALSE_INTERFACE \
84 if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
85 return false;
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000086
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000087bool GrGLInterface::validate() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000088
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000089 if (kNone_GrGLStandard == fStandard) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000090 RETURN_FALSE_INTERFACE
bsalomon@google.com1dcf5062011-11-14 19:29:53 +000091 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +000092
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +000093 if (!fExtensions.isInitialized()) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000094 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +000095 }
bsalomon@google.com1dcf5062011-11-14 19:29:53 +000096
97 // functions that are always required
halcanary96fcdcc2015-08-27 07:41:13 -070098 if (nullptr == fFunctions.fActiveTexture ||
99 nullptr == fFunctions.fAttachShader ||
100 nullptr == fFunctions.fBindAttribLocation ||
101 nullptr == fFunctions.fBindBuffer ||
102 nullptr == fFunctions.fBindTexture ||
103 nullptr == fFunctions.fBlendColor || // -> GL >= 1.4 or extension, ES >= 2.0
104 nullptr == fFunctions.fBlendEquation || // -> GL >= 1.4 or extension, ES >= 2.0
105 nullptr == fFunctions.fBlendFunc ||
106 nullptr == fFunctions.fBufferData ||
107 nullptr == fFunctions.fBufferSubData ||
108 nullptr == fFunctions.fClear ||
109 nullptr == fFunctions.fClearColor ||
110 nullptr == fFunctions.fClearStencil ||
111 nullptr == fFunctions.fColorMask ||
112 nullptr == fFunctions.fCompileShader ||
113 nullptr == fFunctions.fCopyTexSubImage2D ||
114 nullptr == fFunctions.fCreateProgram ||
115 nullptr == fFunctions.fCreateShader ||
116 nullptr == fFunctions.fCullFace ||
117 nullptr == fFunctions.fDeleteBuffers ||
118 nullptr == fFunctions.fDeleteProgram ||
119 nullptr == fFunctions.fDeleteShader ||
120 nullptr == fFunctions.fDeleteTextures ||
121 nullptr == fFunctions.fDepthMask ||
122 nullptr == fFunctions.fDisable ||
123 nullptr == fFunctions.fDisableVertexAttribArray ||
124 nullptr == fFunctions.fDrawArrays ||
125 nullptr == fFunctions.fDrawElements ||
126 nullptr == fFunctions.fEnable ||
127 nullptr == fFunctions.fEnableVertexAttribArray ||
128 nullptr == fFunctions.fFrontFace ||
129 nullptr == fFunctions.fGenBuffers ||
130 nullptr == fFunctions.fGenTextures ||
131 nullptr == fFunctions.fGetBufferParameteriv ||
132 nullptr == fFunctions.fGenerateMipmap ||
133 nullptr == fFunctions.fGetError ||
134 nullptr == fFunctions.fGetIntegerv ||
135 nullptr == fFunctions.fGetProgramInfoLog ||
136 nullptr == fFunctions.fGetProgramiv ||
137 nullptr == fFunctions.fGetShaderInfoLog ||
138 nullptr == fFunctions.fGetShaderiv ||
139 nullptr == fFunctions.fGetString ||
140 nullptr == fFunctions.fGetUniformLocation ||
bsalomon6dc6f5f2015-06-18 09:12:16 -0700141#if 0 // Not included in Chrome yet
halcanary96fcdcc2015-08-27 07:41:13 -0700142 nullptr == fFunctions.fIsTexture ||
bsalomon6dc6f5f2015-06-18 09:12:16 -0700143#endif
halcanary96fcdcc2015-08-27 07:41:13 -0700144 nullptr == fFunctions.fLinkProgram ||
145 nullptr == fFunctions.fLineWidth ||
146 nullptr == fFunctions.fPixelStorei ||
147 nullptr == fFunctions.fReadPixels ||
148 nullptr == fFunctions.fScissor ||
149 nullptr == fFunctions.fShaderSource ||
150 nullptr == fFunctions.fStencilFunc ||
151 nullptr == fFunctions.fStencilMask ||
152 nullptr == fFunctions.fStencilOp ||
153 nullptr == fFunctions.fTexImage2D ||
154 nullptr == fFunctions.fTexParameteri ||
155 nullptr == fFunctions.fTexParameteriv ||
156 nullptr == fFunctions.fTexSubImage2D ||
157 nullptr == fFunctions.fUniform1f ||
158 nullptr == fFunctions.fUniform1i ||
159 nullptr == fFunctions.fUniform1fv ||
160 nullptr == fFunctions.fUniform1iv ||
161 nullptr == fFunctions.fUniform2f ||
162 nullptr == fFunctions.fUniform2i ||
163 nullptr == fFunctions.fUniform2fv ||
164 nullptr == fFunctions.fUniform2iv ||
165 nullptr == fFunctions.fUniform3f ||
166 nullptr == fFunctions.fUniform3i ||
167 nullptr == fFunctions.fUniform3fv ||
168 nullptr == fFunctions.fUniform3iv ||
169 nullptr == fFunctions.fUniform4f ||
170 nullptr == fFunctions.fUniform4i ||
171 nullptr == fFunctions.fUniform4fv ||
172 nullptr == fFunctions.fUniform4iv ||
173 nullptr == fFunctions.fUniformMatrix2fv ||
174 nullptr == fFunctions.fUniformMatrix3fv ||
175 nullptr == fFunctions.fUniformMatrix4fv ||
176 nullptr == fFunctions.fUseProgram ||
177 nullptr == fFunctions.fVertexAttrib1f ||
178 nullptr == fFunctions.fVertexAttrib2fv ||
179 nullptr == fFunctions.fVertexAttrib3fv ||
180 nullptr == fFunctions.fVertexAttrib4fv ||
181 nullptr == fFunctions.fVertexAttribPointer ||
182 nullptr == fFunctions.fViewport ||
183 nullptr == fFunctions.fBindFramebuffer ||
184 nullptr == fFunctions.fBindRenderbuffer ||
185 nullptr == fFunctions.fCheckFramebufferStatus ||
186 nullptr == fFunctions.fDeleteFramebuffers ||
187 nullptr == fFunctions.fDeleteRenderbuffers ||
188 nullptr == fFunctions.fFinish ||
189 nullptr == fFunctions.fFlush ||
190 nullptr == fFunctions.fFramebufferRenderbuffer ||
191 nullptr == fFunctions.fFramebufferTexture2D ||
192 nullptr == fFunctions.fGetFramebufferAttachmentParameteriv ||
193 nullptr == fFunctions.fGetRenderbufferParameteriv ||
194 nullptr == fFunctions.fGenFramebuffers ||
195 nullptr == fFunctions.fGenRenderbuffers ||
196 nullptr == fFunctions.fRenderbufferStorage) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000197 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000198 }
199
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000200 GrGLVersion glVer = GrGLGetVersion(this);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000201 if (GR_GL_INVALID_VER == glVer) {
202 RETURN_FALSE_INTERFACE
203 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000204
205 // Now check that baseline ES/Desktop fns not covered above are present
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000206 // and that we have fn pointers for any advertised fExtensions that we will
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000207 // try to use.
208
209 // these functions are part of ES2, we assume they are available
210 // On the desktop we assume they are available if the extension
211 // is present or GL version is high enough.
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000212 if (kGLES_GrGLStandard == fStandard) {
halcanary96fcdcc2015-08-27 07:41:13 -0700213 if (nullptr == fFunctions.fStencilFuncSeparate ||
214 nullptr == fFunctions.fStencilMaskSeparate ||
215 nullptr == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000216 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000217 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000218 } else if (kGL_GrGLStandard == fStandard) {
robertphillips@google.come7884302012-04-18 14:39:58 +0000219
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000220 if (glVer >= GR_GL_VER(2,0)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700221 if (nullptr == fFunctions.fStencilFuncSeparate ||
222 nullptr == fFunctions.fStencilMaskSeparate ||
223 nullptr == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000224 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000225 }
226 }
halcanary96fcdcc2015-08-27 07:41:13 -0700227 if (glVer >= GR_GL_VER(3,0) && nullptr == fFunctions.fBindFragDataLocation) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000228 RETURN_FALSE_INTERFACE
bsalomon@google.combc5cf512011-09-21 16:21:07 +0000229 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000230 if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700231 if (nullptr == fFunctions.fDrawBuffers) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000232 RETURN_FALSE_INTERFACE
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000233 }
234 }
robertphillips@google.come7884302012-04-18 14:39:58 +0000235
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000236 if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700237 if (nullptr == fFunctions.fGenQueries ||
238 nullptr == fFunctions.fDeleteQueries ||
239 nullptr == fFunctions.fBeginQuery ||
240 nullptr == fFunctions.fEndQuery ||
241 nullptr == fFunctions.fGetQueryiv ||
242 nullptr == fFunctions.fGetQueryObjectiv ||
243 nullptr == fFunctions.fGetQueryObjectuiv) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000244 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000245 }
246 }
247 if (glVer >= GR_GL_VER(3,3) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000248 fExtensions.has("GL_ARB_timer_query") ||
249 fExtensions.has("GL_EXT_timer_query")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700250 if (nullptr == fFunctions.fGetQueryObjecti64v ||
251 nullptr == fFunctions.fGetQueryObjectui64v) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000252 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000253 }
254 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000255 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700256 if (nullptr == fFunctions.fQueryCounter) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000257 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000258 }
259 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000260 }
261
262 // optional function on desktop before 1.3
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000263 if (kGL_GrGLStandard != fStandard ||
bsalomon@google.com1744f972013-02-26 21:46:32 +0000264 (glVer >= GR_GL_VER(1,3)) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000265 fExtensions.has("GL_ARB_texture_compression")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700266 if (nullptr == fFunctions.fCompressedTexImage2D
bsalomonc9aec1e2015-04-24 11:08:25 -0700267#if 0
halcanary96fcdcc2015-08-27 07:41:13 -0700268 || nullptr == fFunctions.fCompressedTexSubImage2D
bsalomonc9aec1e2015-04-24 11:08:25 -0700269#endif
krajcevskie1f5a232014-06-11 16:08:50 -0700270 ) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000271 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000272 }
273 }
274
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000275 // part of desktop GL, but not ES
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000276 if (kGL_GrGLStandard == fStandard &&
halcanary96fcdcc2015-08-27 07:41:13 -0700277 (nullptr == fFunctions.fGetTexLevelParameteriv ||
278 nullptr == fFunctions.fDrawBuffer ||
279 nullptr == fFunctions.fReadBuffer)) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000280 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000281 }
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000282
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000283 // GL_EXT_texture_storage is part of desktop 4.2
284 // There is a desktop ARB extension and an ES+desktop EXT extension
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000285 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000286 if (glVer >= GR_GL_VER(4,2) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000287 fExtensions.has("GL_ARB_texture_storage") ||
288 fExtensions.has("GL_EXT_texture_storage")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700289 if (nullptr == fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000290 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000291 }
292 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000293 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
kkinnunenf655e932016-03-03 07:39:48 -0800294 if (nullptr == fFunctions.fTexStorage2D) {
295 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000296 }
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000297 }
298
cdaltonfd4167d2015-04-21 11:45:56 -0700299 // glTextureBarrier is part of desktop 4.5. There are also ARB and NV extensions.
300 if (kGL_GrGLStandard == fStandard) {
301 if (glVer >= GR_GL_VER(4,5) ||
302 fExtensions.has("GL_ARB_texture_barrier") ||
303 fExtensions.has("GL_NV_texture_barrier")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700304 if (nullptr == fFunctions.fTextureBarrier) {
cdaltonfd4167d2015-04-21 11:45:56 -0700305 RETURN_FALSE_INTERFACE
306 }
307 }
308 } else if (fExtensions.has("GL_NV_texture_barrier")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700309 if (nullptr == fFunctions.fTextureBarrier) {
cdaltonfd4167d2015-04-21 11:45:56 -0700310 RETURN_FALSE_INTERFACE
311 }
312 }
313
cdaltonbae6f6c2015-04-22 10:39:03 -0700314 if (fExtensions.has("GL_KHR_blend_equation_advanced") ||
315 fExtensions.has("GL_NV_blend_equation_advanced")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700316 if (nullptr == fFunctions.fBlendBarrier) {
cdaltonbae6f6c2015-04-22 10:39:03 -0700317 RETURN_FALSE_INTERFACE
318 }
319 }
320
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000321 if (fExtensions.has("GL_EXT_discard_framebuffer")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700322 if (nullptr == fFunctions.fDiscardFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000323 RETURN_FALSE_INTERFACE
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000324 }
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000325 }
326
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000327 // FBO MSAA
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000328 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000329 // GL 3.0 and the ARB extension have multisample + blit
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000330 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700331 if (nullptr == fFunctions.fRenderbufferStorageMultisample ||
332 nullptr == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000333 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000334 }
335 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000336 if (fExtensions.has("GL_EXT_framebuffer_blit") &&
halcanary96fcdcc2015-08-27 07:41:13 -0700337 nullptr == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000338 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000339 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000340 if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
halcanary96fcdcc2015-08-27 07:41:13 -0700341 nullptr == fFunctions.fRenderbufferStorageMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000342 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000343 }
344 }
345 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000346 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700347 if (nullptr == fFunctions.fRenderbufferStorageMultisample ||
348 nullptr == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000349 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000350 }
Brian Salomonc5eceb02016-10-18 10:21:43 -0400351 } else {
352 if (fExtensions.has("GL_ANGLE_framebuffer_multisample") &&
353 nullptr == fFunctions.fRenderbufferStorageMultisample) {
354 RETURN_FALSE_INTERFACE
355 }
356 if (fExtensions.has("GL_ANGLE_framebuffer_blit") &&
357 nullptr == fFunctions.fBlitFramebuffer) {
358 RETURN_FALSE_INTERFACE
359 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000360 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000361 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700362 if (nullptr == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
363 nullptr == fFunctions.fResolveMultisampleFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000364 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000365 }
366 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000367 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
368 fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700369 if (nullptr == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
370 nullptr == fFunctions.fFramebufferTexture2DMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000371 RETURN_FALSE_INTERFACE
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000372 }
373 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000374 }
375
376 // On ES buffer mapping is an extension. On Desktop
377 // buffer mapping was part of original VBO extension
378 // which we require.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000379 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700380 if (nullptr == fFunctions.fMapBuffer ||
381 nullptr == fFunctions.fUnmapBuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000382 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000383 }
384 }
385
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000386 // Dual source blending
kkinnunend94708e2015-07-30 22:47:04 -0700387 if (kGL_GrGLStandard == fStandard) {
388 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700389 if (nullptr == fFunctions.fBindFragDataLocationIndexed) {
kkinnunend94708e2015-07-30 22:47:04 -0700390 RETURN_FALSE_INTERFACE
391 }
392 }
393 } else {
394 if (glVer >= GR_GL_VER(3,0) && fExtensions.has("GL_EXT_blend_func_extended")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700395 if (nullptr == fFunctions.fBindFragDataLocation ||
396 nullptr == fFunctions.fBindFragDataLocationIndexed) {
kkinnunend94708e2015-07-30 22:47:04 -0700397 RETURN_FALSE_INTERFACE
398 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000399 }
400 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000401
kkinnunend94708e2015-07-30 22:47:04 -0700402
commit-bot@chromium.org726e6212013-08-23 20:55:46 +0000403 // glGetStringi was added in version 3.0 of both desktop and ES.
404 if (glVer >= GR_GL_VER(3, 0)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700405 if (nullptr == fFunctions.fGetStringi) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000406 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000407 }
408 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000409
cdalton793dc262016-02-08 10:11:47 -0800410 // glVertexAttribIPointer was added in version 3.0 of both desktop and ES.
411 if (glVer >= GR_GL_VER(3, 0)) {
412 if (NULL == fFunctions.fVertexAttribIPointer) {
413 RETURN_FALSE_INTERFACE
414 }
415 }
416
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000417 if (kGL_GrGLStandard == fStandard) {
cdaltonc04ce672016-03-11 14:07:38 -0800418 if (glVer >= GR_GL_VER(3,1)) {
419 if (nullptr == fFunctions.fTexBuffer) {
420 RETURN_FALSE_INTERFACE;
421 }
422 }
cdaltonf8a6ce82016-04-11 13:02:05 -0700423 if (glVer >= GR_GL_VER(4,3)) {
424 if (nullptr == fFunctions.fTexBufferRange) {
425 RETURN_FALSE_INTERFACE;
426 }
427 }
cdaltonc04ce672016-03-11 14:07:38 -0800428 } else {
429 if (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_OES_texture_buffer") ||
430 fExtensions.has("GL_EXT_texture_buffer")) {
cdaltonf8a6ce82016-04-11 13:02:05 -0700431 if (nullptr == fFunctions.fTexBuffer ||
432 nullptr == fFunctions.fTexBufferRange) {
cdaltonc04ce672016-03-11 14:07:38 -0800433 RETURN_FALSE_INTERFACE;
434 }
435 }
436 }
437
438 if (kGL_GrGLStandard == fStandard) {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000439 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700440 if (nullptr == fFunctions.fBindVertexArray ||
441 nullptr == fFunctions.fDeleteVertexArrays ||
442 nullptr == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000443 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000444 }
445 }
446 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000447 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700448 if (nullptr == fFunctions.fBindVertexArray ||
449 nullptr == fFunctions.fDeleteVertexArrays ||
450 nullptr == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000451 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000452 }
453 }
bsalomon@google.comecd84842013-03-01 15:36:02 +0000454 }
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000455
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000456 if (fExtensions.has("GL_EXT_debug_marker")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700457 if (nullptr == fFunctions.fInsertEventMarker ||
458 nullptr == fFunctions.fPushGroupMarker ||
459 nullptr == fFunctions.fPopGroupMarker) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000460 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000461 }
462 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000463
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000464 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
465 fExtensions.has("GL_ARB_invalidate_subdata")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700466 if (nullptr == fFunctions.fInvalidateBufferData ||
467 nullptr == fFunctions.fInvalidateBufferSubData ||
468 nullptr == fFunctions.fInvalidateFramebuffer ||
469 nullptr == fFunctions.fInvalidateSubFramebuffer ||
470 nullptr == fFunctions.fInvalidateTexImage ||
471 nullptr == fFunctions.fInvalidateTexSubImage) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000472 RETURN_FALSE_INTERFACE;
473 }
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000474 } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000475 // ES 3.0 adds the framebuffer functions but not the others.
halcanary96fcdcc2015-08-27 07:41:13 -0700476 if (nullptr == fFunctions.fInvalidateFramebuffer ||
477 nullptr == fFunctions.fInvalidateSubFramebuffer) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000478 RETURN_FALSE_INTERFACE;
479 }
480 }
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000481
482 if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700483 if (nullptr == fFunctions.fMapBufferSubData ||
484 nullptr == fFunctions.fMapTexSubImage2D ||
485 nullptr == fFunctions.fUnmapBufferSubData ||
486 nullptr == fFunctions.fUnmapTexSubImage2D) {
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000487 RETURN_FALSE_INTERFACE;
488 }
489 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000490
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000491 // These functions are added to the 3.0 version of both GLES and GL.
492 if (glVer >= GR_GL_VER(3,0) ||
493 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
494 (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
kkinnunenf655e932016-03-03 07:39:48 -0800495 if (nullptr == fFunctions.fMapBufferRange ||
496 nullptr == fFunctions.fFlushMappedBufferRange) {
497 RETURN_FALSE_INTERFACE;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000498 }
499 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700500
kkinnunen32b9a3b2014-07-02 22:56:35 -0700501 if ((kGL_GrGLStandard == fStandard &&
cdaltoneb79eea2016-02-26 10:39:34 -0800502 (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_ARB_texture_multisample"))) ||
503 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
504 if (NULL == fFunctions.fGetMultisamplefv) {
505 RETURN_FALSE_INTERFACE
506 }
507 }
508
509 if ((kGL_GrGLStandard == fStandard &&
kkinnunen32b9a3b2014-07-02 22:56:35 -0700510 (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) ||
511 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
halcanary96fcdcc2015-08-27 07:41:13 -0700512 if (nullptr == fFunctions.fGetProgramResourceLocation) {
kkinnunen32b9a3b2014-07-02 22:56:35 -0700513 RETURN_FALSE_INTERFACE
514 }
515 }
516
bsalomonee64d6e2014-12-03 10:46:08 -0800517 if (kGLES_GrGLStandard == fStandard || glVer >= GR_GL_VER(4,1) ||
518 fExtensions.has("GL_ARB_ES2_compatibility")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700519 if (nullptr == fFunctions.fGetShaderPrecisionFormat) {
bsalomonee64d6e2014-12-03 10:46:08 -0800520 RETURN_FALSE_INTERFACE
521 }
bsalomonee64d6e2014-12-03 10:46:08 -0800522 }
523
kkinnunen6bb6d402015-07-14 10:59:23 -0700524 if (fExtensions.has("GL_NV_path_rendering") || fExtensions.has("GL_CHROMIUM_path_rendering")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700525 if (nullptr == fFunctions.fMatrixLoadf ||
526 nullptr == fFunctions.fMatrixLoadIdentity ||
527 nullptr == fFunctions.fPathCommands ||
528 nullptr == fFunctions.fPathParameteri ||
529 nullptr == fFunctions.fPathParameterf ||
530 nullptr == fFunctions.fGenPaths ||
531 nullptr == fFunctions.fDeletePaths ||
532 nullptr == fFunctions.fIsPath ||
533 nullptr == fFunctions.fPathStencilFunc ||
534 nullptr == fFunctions.fStencilFillPath ||
535 nullptr == fFunctions.fStencilStrokePath ||
536 nullptr == fFunctions.fStencilFillPathInstanced ||
537 nullptr == fFunctions.fStencilStrokePathInstanced ||
538 nullptr == fFunctions.fCoverFillPath ||
539 nullptr == fFunctions.fCoverStrokePath ||
540 nullptr == fFunctions.fCoverFillPathInstanced ||
541 nullptr == fFunctions.fCoverStrokePathInstanced
kkinnunencfe62e32015-07-01 02:58:50 -0700542#if 0
543 // List of functions that Skia uses, but which have been added since the initial release
544 // of NV_path_rendering driver. We do not want to fail interface validation due to
545 // missing features, we will just not use the extension.
546 // Update this list -> update GrGLCaps::hasPathRenderingSupport too.
halcanary96fcdcc2015-08-27 07:41:13 -0700547 || nullptr == fFunctions.fStencilThenCoverFillPath ||
548 nullptr == fFunctions.fStencilThenCoverStrokePath ||
549 nullptr == fFunctions.fStencilThenCoverFillPathInstanced ||
550 nullptr == fFunctions.fStencilThenCoverStrokePathInstanced ||
551 nullptr == fFunctions.fProgramPathFragmentInputGen
kkinnunencfe62e32015-07-01 02:58:50 -0700552#endif
553 ) {
kkinnunen32b9a3b2014-07-02 22:56:35 -0700554 RETURN_FALSE_INTERFACE
555 }
kkinnunen6bb6d402015-07-14 10:59:23 -0700556 if (fExtensions.has("GL_CHROMIUM_path_rendering")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700557 if (nullptr == fFunctions.fBindFragmentInputLocation) {
kkinnunen6bb6d402015-07-14 10:59:23 -0700558 RETURN_FALSE_INTERFACE
559 }
560 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700561 }
562
cdalton0edea2c2015-05-21 08:27:44 -0700563 if (fExtensions.has("GL_EXT_raster_multisample")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700564 if (nullptr == fFunctions.fRasterSamples) {
cdalton0edea2c2015-05-21 08:27:44 -0700565 RETURN_FALSE_INTERFACE
566 }
567 }
568
kkinnunenea409432015-12-10 01:21:59 -0800569 if (fExtensions.has("GL_NV_framebuffer_mixed_samples") ||
570 fExtensions.has("GL_CHROMIUM_framebuffer_mixed_samples")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700571 if (nullptr == fFunctions.fCoverageModulation) {
vbuzinov08b4d292015-04-01 06:29:49 -0700572 RETURN_FALSE_INTERFACE
573 }
574 }
575
hendrikwb3f16362015-10-19 06:13:55 -0700576 if (kGL_GrGLStandard == fStandard) {
577 if (glVer >= GR_GL_VER(3,1) ||
578 fExtensions.has("GL_EXT_draw_instanced") || fExtensions.has("GL_ARB_draw_instanced")) {
579 if (nullptr == fFunctions.fDrawArraysInstanced ||
580 nullptr == fFunctions.fDrawElementsInstanced) {
581 RETURN_FALSE_INTERFACE
582 }
halcanary9d524f22016-03-29 09:03:52 -0700583 }
hendrikwb3f16362015-10-19 06:13:55 -0700584 } else if (kGLES_GrGLStandard == fStandard) {
kkinnunenf655e932016-03-03 07:39:48 -0800585 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_draw_instanced")) {
586 if (nullptr == fFunctions.fDrawArraysInstanced ||
587 nullptr == fFunctions.fDrawElementsInstanced) {
588 RETURN_FALSE_INTERFACE
hendrikwb3f16362015-10-19 06:13:55 -0700589 }
halcanary9d524f22016-03-29 09:03:52 -0700590 }
cdalton626e1ff2015-06-12 13:56:46 -0700591 }
592
hendrikwb3f16362015-10-19 06:13:55 -0700593 if (kGL_GrGLStandard == fStandard) {
594 if (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_ARB_instanced_arrays")) {
595 if (nullptr == fFunctions.fVertexAttribDivisor) {
596 RETURN_FALSE_INTERFACE
597 }
halcanary9d524f22016-03-29 09:03:52 -0700598 }
hendrikwb3f16362015-10-19 06:13:55 -0700599 } else if (kGLES_GrGLStandard == fStandard) {
kkinnunenf655e932016-03-03 07:39:48 -0800600 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_instanced_arrays")) {
601 if (nullptr == fFunctions.fVertexAttribDivisor) {
602 RETURN_FALSE_INTERFACE
hendrikwb3f16362015-10-19 06:13:55 -0700603 }
halcanary9d524f22016-03-29 09:03:52 -0700604 }
cdalton626e1ff2015-06-12 13:56:46 -0700605 }
606
csmartdalton5cebf8c2016-06-03 08:28:47 -0700607 if ((kGL_GrGLStandard == fStandard &&
608 (glVer >= GR_GL_VER(4,0) || fExtensions.has("GL_ARB_draw_indirect"))) ||
cdalton06604b92016-02-05 10:09:51 -0800609 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
610 if (NULL == fFunctions.fDrawArraysIndirect ||
611 NULL == fFunctions.fDrawElementsIndirect) {
612 RETURN_FALSE_INTERFACE
613 }
614 }
615
csmartdalton5cebf8c2016-06-03 08:28:47 -0700616 if ((kGL_GrGLStandard == fStandard &&
617 (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_multi_draw_indirect"))) ||
cdalton06604b92016-02-05 10:09:51 -0800618 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_multi_draw_indirect"))) {
619 if (NULL == fFunctions.fMultiDrawArraysIndirect ||
620 NULL == fFunctions.fMultiDrawElementsIndirect) {
621 RETURN_FALSE_INTERFACE
622 }
623 }
624
cdalton626e1ff2015-06-12 13:56:46 -0700625 if (fExtensions.has("GL_NV_bindless_texture")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700626 if (nullptr == fFunctions.fGetTextureHandle ||
627 nullptr == fFunctions.fGetTextureSamplerHandle ||
628 nullptr == fFunctions.fMakeTextureHandleResident ||
629 nullptr == fFunctions.fMakeTextureHandleNonResident ||
630 nullptr == fFunctions.fGetImageHandle ||
631 nullptr == fFunctions.fMakeImageHandleResident ||
632 nullptr == fFunctions.fMakeImageHandleNonResident ||
633 nullptr == fFunctions.fIsTextureHandleResident ||
634 nullptr == fFunctions.fIsImageHandleResident ||
635 nullptr == fFunctions.fUniformHandleui64 ||
636 nullptr == fFunctions.fUniformHandleui64v ||
637 nullptr == fFunctions.fProgramUniformHandleui64 ||
638 nullptr == fFunctions.fProgramUniformHandleui64v) {
cdalton626e1ff2015-06-12 13:56:46 -0700639 RETURN_FALSE_INTERFACE
640 }
641 }
642
643 if (kGL_GrGLStandard == fStandard && fExtensions.has("GL_EXT_direct_state_access")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700644 if (nullptr == fFunctions.fTextureParameteri ||
645 nullptr == fFunctions.fTextureParameteriv ||
646 nullptr == fFunctions.fTextureParameterf ||
647 nullptr == fFunctions.fTextureParameterfv ||
648 nullptr == fFunctions.fTextureImage1D ||
649 nullptr == fFunctions.fTextureImage2D ||
650 nullptr == fFunctions.fTextureSubImage1D ||
651 nullptr == fFunctions.fTextureSubImage2D ||
652 nullptr == fFunctions.fCopyTextureImage1D ||
653 nullptr == fFunctions.fCopyTextureImage2D ||
654 nullptr == fFunctions.fCopyTextureSubImage1D ||
655 nullptr == fFunctions.fCopyTextureSubImage2D ||
656 nullptr == fFunctions.fGetTextureImage ||
657 nullptr == fFunctions.fGetTextureParameterfv ||
658 nullptr == fFunctions.fGetTextureParameteriv ||
659 nullptr == fFunctions.fGetTextureLevelParameterfv ||
660 nullptr == fFunctions.fGetTextureLevelParameteriv) {
cdalton626e1ff2015-06-12 13:56:46 -0700661 RETURN_FALSE_INTERFACE
662 }
663 if (glVer >= GR_GL_VER(1,2)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700664 if (nullptr == fFunctions.fTextureImage3D ||
665 nullptr == fFunctions.fTextureSubImage3D ||
666 nullptr == fFunctions.fCopyTextureSubImage3D ||
667 nullptr == fFunctions.fCompressedTextureImage3D ||
668 nullptr == fFunctions.fCompressedTextureImage2D ||
669 nullptr == fFunctions.fCompressedTextureImage1D ||
670 nullptr == fFunctions.fCompressedTextureSubImage3D ||
671 nullptr == fFunctions.fCompressedTextureSubImage2D ||
672 nullptr == fFunctions.fCompressedTextureSubImage1D ||
673 nullptr == fFunctions.fGetCompressedTextureImage) {
cdalton626e1ff2015-06-12 13:56:46 -0700674 RETURN_FALSE_INTERFACE
675 }
676 }
677 if (glVer >= GR_GL_VER(1,5)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700678 if (nullptr == fFunctions.fNamedBufferData ||
679 nullptr == fFunctions.fNamedBufferSubData ||
680 nullptr == fFunctions.fMapNamedBuffer ||
681 nullptr == fFunctions.fUnmapNamedBuffer ||
682 nullptr == fFunctions.fGetNamedBufferParameteriv ||
683 nullptr == fFunctions.fGetNamedBufferPointerv ||
684 nullptr == fFunctions.fGetNamedBufferSubData) {
cdalton626e1ff2015-06-12 13:56:46 -0700685 RETURN_FALSE_INTERFACE
686 }
687 }
688 if (glVer >= GR_GL_VER(2,0)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700689 if (nullptr == fFunctions.fProgramUniform1f ||
690 nullptr == fFunctions.fProgramUniform2f ||
691 nullptr == fFunctions.fProgramUniform3f ||
692 nullptr == fFunctions.fProgramUniform4f ||
693 nullptr == fFunctions.fProgramUniform1i ||
694 nullptr == fFunctions.fProgramUniform2i ||
695 nullptr == fFunctions.fProgramUniform3i ||
696 nullptr == fFunctions.fProgramUniform4i ||
697 nullptr == fFunctions.fProgramUniform1fv ||
698 nullptr == fFunctions.fProgramUniform2fv ||
699 nullptr == fFunctions.fProgramUniform3fv ||
700 nullptr == fFunctions.fProgramUniform4fv ||
701 nullptr == fFunctions.fProgramUniform1iv ||
702 nullptr == fFunctions.fProgramUniform2iv ||
703 nullptr == fFunctions.fProgramUniform3iv ||
704 nullptr == fFunctions.fProgramUniform4iv ||
705 nullptr == fFunctions.fProgramUniformMatrix2fv ||
706 nullptr == fFunctions.fProgramUniformMatrix3fv ||
707 nullptr == fFunctions.fProgramUniformMatrix4fv) {
cdalton626e1ff2015-06-12 13:56:46 -0700708 RETURN_FALSE_INTERFACE
709 }
710 }
711 if (glVer >= GR_GL_VER(2,1)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700712 if (nullptr == fFunctions.fProgramUniformMatrix2x3fv ||
713 nullptr == fFunctions.fProgramUniformMatrix3x2fv ||
714 nullptr == fFunctions.fProgramUniformMatrix2x4fv ||
715 nullptr == fFunctions.fProgramUniformMatrix4x2fv ||
716 nullptr == fFunctions.fProgramUniformMatrix3x4fv ||
717 nullptr == fFunctions.fProgramUniformMatrix4x3fv) {
cdalton626e1ff2015-06-12 13:56:46 -0700718 RETURN_FALSE_INTERFACE
719 }
720 }
721 if (glVer >= GR_GL_VER(3,0)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700722 if (nullptr == fFunctions.fNamedRenderbufferStorage ||
723 nullptr == fFunctions.fGetNamedRenderbufferParameteriv ||
724 nullptr == fFunctions.fNamedRenderbufferStorageMultisample ||
725 nullptr == fFunctions.fCheckNamedFramebufferStatus ||
726 nullptr == fFunctions.fNamedFramebufferTexture1D ||
727 nullptr == fFunctions.fNamedFramebufferTexture2D ||
728 nullptr == fFunctions.fNamedFramebufferTexture3D ||
729 nullptr == fFunctions.fNamedFramebufferRenderbuffer ||
730 nullptr == fFunctions.fGetNamedFramebufferAttachmentParameteriv ||
731 nullptr == fFunctions.fGenerateTextureMipmap ||
732 nullptr == fFunctions.fFramebufferDrawBuffer ||
733 nullptr == fFunctions.fFramebufferDrawBuffers ||
734 nullptr == fFunctions.fFramebufferReadBuffer ||
735 nullptr == fFunctions.fGetFramebufferParameteriv ||
736 nullptr == fFunctions.fNamedCopyBufferSubData ||
737 nullptr == fFunctions.fVertexArrayVertexOffset ||
738 nullptr == fFunctions.fVertexArrayColorOffset ||
739 nullptr == fFunctions.fVertexArrayEdgeFlagOffset ||
740 nullptr == fFunctions.fVertexArrayIndexOffset ||
741 nullptr == fFunctions.fVertexArrayNormalOffset ||
742 nullptr == fFunctions.fVertexArrayTexCoordOffset ||
743 nullptr == fFunctions.fVertexArrayMultiTexCoordOffset ||
744 nullptr == fFunctions.fVertexArrayFogCoordOffset ||
745 nullptr == fFunctions.fVertexArraySecondaryColorOffset ||
746 nullptr == fFunctions.fVertexArrayVertexAttribOffset ||
747 nullptr == fFunctions.fVertexArrayVertexAttribIOffset ||
748 nullptr == fFunctions.fEnableVertexArray ||
749 nullptr == fFunctions.fDisableVertexArray ||
750 nullptr == fFunctions.fEnableVertexArrayAttrib ||
751 nullptr == fFunctions.fDisableVertexArrayAttrib ||
752 nullptr == fFunctions.fGetVertexArrayIntegerv ||
753 nullptr == fFunctions.fGetVertexArrayPointerv ||
754 nullptr == fFunctions.fGetVertexArrayIntegeri_v ||
755 nullptr == fFunctions.fGetVertexArrayPointeri_v ||
756 nullptr == fFunctions.fMapNamedBufferRange ||
757 nullptr == fFunctions.fFlushMappedNamedBufferRange) {
cdalton626e1ff2015-06-12 13:56:46 -0700758 RETURN_FALSE_INTERFACE
759 }
760 }
cdaltonc04ce672016-03-11 14:07:38 -0800761 if (glVer >= GR_GL_VER(3,1)) {
762 if (nullptr == fFunctions.fTextureBuffer) {
763 RETURN_FALSE_INTERFACE;
764 }
765 }
cdalton626e1ff2015-06-12 13:56:46 -0700766 }
767
768 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
769 fExtensions.has("GL_KHR_debug")) {
halcanary96fcdcc2015-08-27 07:41:13 -0700770 if (nullptr == fFunctions.fDebugMessageControl ||
771 nullptr == fFunctions.fDebugMessageInsert ||
772 nullptr == fFunctions.fDebugMessageCallback ||
773 nullptr == fFunctions.fGetDebugMessageLog ||
774 nullptr == fFunctions.fPushDebugGroup ||
775 nullptr == fFunctions.fPopDebugGroup ||
776 nullptr == fFunctions.fObjectLabel) {
cdalton626e1ff2015-06-12 13:56:46 -0700777 RETURN_FALSE_INTERFACE
778 }
779 }
780
csmartdalton9bc11872016-08-09 12:42:47 -0700781 if (fExtensions.has("GL_EXT_window_rectangles")) {
782 if (nullptr == fFunctions.fWindowRectangles) {
783 RETURN_FALSE_INTERFACE
784 }
785 }
786
ethannicholas28ef4452016-03-25 09:26:03 -0700787 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,0)) ||
788 fExtensions.has("GL_ARB_sample_shading")) {
789 if (nullptr == fFunctions.fMinSampleShading) {
790 RETURN_FALSE_INTERFACE
791 }
bsalomon23c4f1a2016-07-19 06:21:55 -0700792 } else if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_OES_sample_shading")) {
ethannicholas28ef4452016-03-25 09:26:03 -0700793 if (nullptr == fFunctions.fMinSampleShading) {
794 RETURN_FALSE_INTERFACE
795 }
796 }
797
jvanverth84741b32016-09-30 08:39:02 -0700798 if (kGL_GrGLStandard == fStandard) {
799 if (glVer >= GR_GL_VER(3, 2) || fExtensions.has("GL_ARB_sync")) {
800 if (nullptr == fFunctions.fFenceSync ||
801 nullptr == fFunctions.fClientWaitSync ||
802 nullptr == fFunctions.fDeleteSync) {
803 RETURN_FALSE_INTERFACE
804 }
805 }
806 } else if (kGLES_GrGLStandard == fStandard) {
807 if (glVer >= GR_GL_VER(3, 0)) {
808 if (nullptr == fFunctions.fFenceSync ||
809 nullptr == fFunctions.fClientWaitSync ||
810 nullptr == fFunctions.fDeleteSync) {
811 RETURN_FALSE_INTERFACE
812 }
813 }
814 }
815
bsalomonb1a32ad2015-11-16 06:48:44 -0800816 if (fExtensions.has("EGL_KHR_image") || fExtensions.has("EGL_KHR_image_base")) {
bsalomon7ea33f52015-11-22 14:51:00 -0800817 if (nullptr == fFunctions.fEGLCreateImage ||
818 nullptr == fFunctions.fEGLDestroyImage) {
bsalomonb1a32ad2015-11-16 06:48:44 -0800819 RETURN_FALSE_INTERFACE
820 }
821 }
822
bsalomonfc9527a2016-08-29 09:18:39 -0700823 if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(2,0)) {
824 if (nullptr == fFunctions.fDrawRangeElements) {
825 RETURN_FALSE_INTERFACE;
826 }
827 } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
828 if (nullptr == fFunctions.fDrawRangeElements) {
829 RETURN_FALSE_INTERFACE;
830 }
831 }
832
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000833 return true;
834}