blob: 10b7b16dd9a72256b0a452dfa98b207caf0c74c8 [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.orgf5355612014-02-28 20:28:50 +000015GrGLInterface::GrGLInterface() {
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000016 fStandard = kNone_GrGLStandard;
bsalomon@google.com0b77d682011-08-19 13:28:54 +000017}
18
commit-bot@chromium.orge83b9b72014-05-01 19:21:41 +000019#ifdef SK_DEBUG
20 static int kIsDebug = 1;
21#else
22 static int kIsDebug = 0;
23#endif
24
25#define RETURN_FALSE_INTERFACE \
26 if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
27 return false;
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000028
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000029bool GrGLInterface::validate() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000030
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000031 if (kNone_GrGLStandard == fStandard) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000032 RETURN_FALSE_INTERFACE
bsalomon@google.com1dcf5062011-11-14 19:29:53 +000033 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +000034
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +000035 if (!fExtensions.isInitialized()) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000036 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +000037 }
bsalomon@google.com1dcf5062011-11-14 19:29:53 +000038
39 // functions that are always required
Mike Klein76343302017-06-22 13:15:13 -070040 if (!fFunctions.fActiveTexture ||
41 !fFunctions.fAttachShader ||
42 !fFunctions.fBindAttribLocation ||
43 !fFunctions.fBindBuffer ||
44 !fFunctions.fBindTexture ||
45 !fFunctions.fBlendColor || // -> GL >= 1.4 or extension, ES >= 2.0
46 !fFunctions.fBlendEquation || // -> GL >= 1.4 or extension, ES >= 2.0
47 !fFunctions.fBlendFunc ||
48 !fFunctions.fBufferData ||
49 !fFunctions.fBufferSubData ||
50 !fFunctions.fClear ||
51 !fFunctions.fClearColor ||
52 !fFunctions.fClearStencil ||
53 !fFunctions.fColorMask ||
54 !fFunctions.fCompileShader ||
55 !fFunctions.fCompressedTexImage2D ||
56 !fFunctions.fCompressedTexSubImage2D ||
57 !fFunctions.fCopyTexSubImage2D ||
58 !fFunctions.fCreateProgram ||
59 !fFunctions.fCreateShader ||
60 !fFunctions.fCullFace ||
61 !fFunctions.fDeleteBuffers ||
62 !fFunctions.fDeleteProgram ||
63 !fFunctions.fDeleteShader ||
64 !fFunctions.fDeleteTextures ||
65 !fFunctions.fDepthMask ||
66 !fFunctions.fDisable ||
67 !fFunctions.fDisableVertexAttribArray ||
68 !fFunctions.fDrawArrays ||
69 !fFunctions.fDrawElements ||
70 !fFunctions.fEnable ||
71 !fFunctions.fEnableVertexAttribArray ||
72 !fFunctions.fFrontFace ||
73 !fFunctions.fGenBuffers ||
74 !fFunctions.fGenTextures ||
75 !fFunctions.fGetBufferParameteriv ||
76 !fFunctions.fGenerateMipmap ||
77 !fFunctions.fGetError ||
78 !fFunctions.fGetIntegerv ||
79 !fFunctions.fGetProgramInfoLog ||
80 !fFunctions.fGetProgramiv ||
81 !fFunctions.fGetShaderInfoLog ||
82 !fFunctions.fGetShaderiv ||
83 !fFunctions.fGetString ||
84 !fFunctions.fGetUniformLocation ||
85 !fFunctions.fIsTexture ||
86 !fFunctions.fLinkProgram ||
87 !fFunctions.fLineWidth ||
88 !fFunctions.fPixelStorei ||
89 !fFunctions.fReadPixels ||
90 !fFunctions.fScissor ||
91 !fFunctions.fShaderSource ||
92 !fFunctions.fStencilFunc ||
93 !fFunctions.fStencilFuncSeparate ||
94 !fFunctions.fStencilMask ||
95 !fFunctions.fStencilMaskSeparate ||
96 !fFunctions.fStencilOp ||
97 !fFunctions.fStencilOpSeparate ||
98 !fFunctions.fTexImage2D ||
99 !fFunctions.fTexParameteri ||
100 !fFunctions.fTexParameteriv ||
101 !fFunctions.fTexSubImage2D ||
102 !fFunctions.fUniform1f ||
103 !fFunctions.fUniform1i ||
104 !fFunctions.fUniform1fv ||
105 !fFunctions.fUniform1iv ||
106 !fFunctions.fUniform2f ||
107 !fFunctions.fUniform2i ||
108 !fFunctions.fUniform2fv ||
109 !fFunctions.fUniform2iv ||
110 !fFunctions.fUniform3f ||
111 !fFunctions.fUniform3i ||
112 !fFunctions.fUniform3fv ||
113 !fFunctions.fUniform3iv ||
114 !fFunctions.fUniform4f ||
115 !fFunctions.fUniform4i ||
116 !fFunctions.fUniform4fv ||
117 !fFunctions.fUniform4iv ||
118 !fFunctions.fUniformMatrix2fv ||
119 !fFunctions.fUniformMatrix3fv ||
120 !fFunctions.fUniformMatrix4fv ||
121 !fFunctions.fUseProgram ||
122 !fFunctions.fVertexAttrib1f ||
123 !fFunctions.fVertexAttrib2fv ||
124 !fFunctions.fVertexAttrib3fv ||
125 !fFunctions.fVertexAttrib4fv ||
126 !fFunctions.fVertexAttribPointer ||
127 !fFunctions.fViewport ||
128 !fFunctions.fBindFramebuffer ||
129 !fFunctions.fBindRenderbuffer ||
130 !fFunctions.fCheckFramebufferStatus ||
131 !fFunctions.fDeleteFramebuffers ||
132 !fFunctions.fDeleteRenderbuffers ||
133 !fFunctions.fFinish ||
134 !fFunctions.fFlush ||
135 !fFunctions.fFramebufferRenderbuffer ||
136 !fFunctions.fFramebufferTexture2D ||
137 !fFunctions.fGetFramebufferAttachmentParameteriv ||
138 !fFunctions.fGetRenderbufferParameteriv ||
139 !fFunctions.fGenFramebuffers ||
140 !fFunctions.fGenRenderbuffers ||
141 !fFunctions.fRenderbufferStorage) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000142 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000143 }
144
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000145 GrGLVersion glVer = GrGLGetVersion(this);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000146 if (GR_GL_INVALID_VER == glVer) {
147 RETURN_FALSE_INTERFACE
148 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000149
150 // Now check that baseline ES/Desktop fns not covered above are present
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000151 // and that we have fn pointers for any advertised fExtensions that we will
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000152 // try to use.
153
154 // these functions are part of ES2, we assume they are available
155 // On the desktop we assume they are available if the extension
156 // is present or GL version is high enough.
Brian Salomonf0861672017-05-08 11:10:10 -0400157 if (kGL_GrGLStandard == fStandard) {
Mike Klein76343302017-06-22 13:15:13 -0700158 if (glVer >= GR_GL_VER(3,0) && !fFunctions.fBindFragDataLocation) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000159 RETURN_FALSE_INTERFACE
bsalomon@google.combc5cf512011-09-21 16:21:07 +0000160 }
robertphillips@google.come7884302012-04-18 14:39:58 +0000161
bsalomon@google.com373a6632011-10-19 20:43:20 +0000162 if (glVer >= GR_GL_VER(3,3) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000163 fExtensions.has("GL_ARB_timer_query") ||
164 fExtensions.has("GL_EXT_timer_query")) {
Mike Klein76343302017-06-22 13:15:13 -0700165 if (!fFunctions.fGetQueryObjecti64v ||
166 !fFunctions.fGetQueryObjectui64v) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000167 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000168 }
169 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000170 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
Mike Klein76343302017-06-22 13:15:13 -0700171 if (!fFunctions.fQueryCounter) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000172 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000173 }
174 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000175 }
176
Brian Salomon15b25092017-05-08 11:10:53 -0400177 // part of desktop GL, but not ES
178 if (kGL_GrGLStandard == fStandard &&
Mike Klein76343302017-06-22 13:15:13 -0700179 (!fFunctions.fDrawBuffer ||
180 !fFunctions.fPolygonMode)) {
Brian Salomon15b25092017-05-08 11:10:53 -0400181 RETURN_FALSE_INTERFACE
182 }
183
184 // ES 3.0 (or ES 2.0 extended) has glDrawBuffers but not glDrawBuffer
185 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,0)) {
Mike Klein76343302017-06-22 13:15:13 -0700186 if (!fFunctions.fDrawBuffers) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000187 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000188 }
189 }
190
Brian Salomon15b25092017-05-08 11:10:53 -0400191 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,0)) {
Mike Klein76343302017-06-22 13:15:13 -0700192 if (!fFunctions.fReadBuffer) {
Brian Salomon15b25092017-05-08 11:10:53 -0400193 RETURN_FALSE_INTERFACE
194 }
195 }
196
197 // glGetTexLevelParameteriv was added to ES in 3.1.
198 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,1)) {
Mike Klein76343302017-06-22 13:15:13 -0700199 if (!fFunctions.fGetTexLevelParameteriv) {
Brian Salomon15b25092017-05-08 11:10:53 -0400200 RETURN_FALSE_INTERFACE
201 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000202 }
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000203
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000204 // GL_EXT_texture_storage is part of desktop 4.2
205 // There is a desktop ARB extension and an ES+desktop EXT extension
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000206 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000207 if (glVer >= GR_GL_VER(4,2) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000208 fExtensions.has("GL_ARB_texture_storage") ||
209 fExtensions.has("GL_EXT_texture_storage")) {
Mike Klein76343302017-06-22 13:15:13 -0700210 if (!fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000211 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000212 }
213 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000214 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
Mike Klein76343302017-06-22 13:15:13 -0700215 if (!fFunctions.fTexStorage2D) {
kkinnunenf655e932016-03-03 07:39:48 -0800216 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000217 }
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000218 }
219
cdaltonfd4167d2015-04-21 11:45:56 -0700220 // glTextureBarrier is part of desktop 4.5. There are also ARB and NV extensions.
221 if (kGL_GrGLStandard == fStandard) {
222 if (glVer >= GR_GL_VER(4,5) ||
223 fExtensions.has("GL_ARB_texture_barrier") ||
224 fExtensions.has("GL_NV_texture_barrier")) {
Mike Klein76343302017-06-22 13:15:13 -0700225 if (!fFunctions.fTextureBarrier) {
cdaltonfd4167d2015-04-21 11:45:56 -0700226 RETURN_FALSE_INTERFACE
227 }
228 }
229 } else if (fExtensions.has("GL_NV_texture_barrier")) {
Mike Klein76343302017-06-22 13:15:13 -0700230 if (!fFunctions.fTextureBarrier) {
cdaltonfd4167d2015-04-21 11:45:56 -0700231 RETURN_FALSE_INTERFACE
232 }
233 }
234
cdaltonbae6f6c2015-04-22 10:39:03 -0700235 if (fExtensions.has("GL_KHR_blend_equation_advanced") ||
236 fExtensions.has("GL_NV_blend_equation_advanced")) {
Mike Klein76343302017-06-22 13:15:13 -0700237 if (!fFunctions.fBlendBarrier) {
cdaltonbae6f6c2015-04-22 10:39:03 -0700238 RETURN_FALSE_INTERFACE
239 }
240 }
241
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000242 if (fExtensions.has("GL_EXT_discard_framebuffer")) {
Mike Klein76343302017-06-22 13:15:13 -0700243 if (!fFunctions.fDiscardFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000244 RETURN_FALSE_INTERFACE
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000245 }
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000246 }
247
Brian Salomon15b25092017-05-08 11:10:53 -0400248 // Required since OpenGL 1.5 and ES 3.0 or with GL_EXT_occlusion_query_boolean
249 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,0) ||
250 fExtensions.has("GL_EXT_occlusion_query_boolean")) {
251#if 0 // Not yet added to chrome's bindings.
Mike Klein76343302017-06-22 13:15:13 -0700252 if (!fFunctions.fGenQueries ||
253 !fFunctions.fDeleteQueries ||
254 !fFunctions.fBeginQuery ||
255 !fFunctions.fEndQuery ||
256 !fFunctions.fGetQueryiv ||
257 !fFunctions.fGetQueryObjectuiv) {
Brian Salomon15b25092017-05-08 11:10:53 -0400258 RETURN_FALSE_INTERFACE
259 }
260#endif
261 }
262 // glGetQueryObjectiv doesn't exist in ES.
Mike Klein76343302017-06-22 13:15:13 -0700263 if (kGL_GrGLStandard == fStandard && !fFunctions.fGetQueryObjectiv) {
Brian Salomon15b25092017-05-08 11:10:53 -0400264 RETURN_FALSE_INTERFACE
265 }
266
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000267 // FBO MSAA
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000268 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000269 // GL 3.0 and the ARB extension have multisample + blit
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000270 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
Mike Klein76343302017-06-22 13:15:13 -0700271 if (!fFunctions.fRenderbufferStorageMultisample ||
272 !fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000273 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000274 }
275 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000276 if (fExtensions.has("GL_EXT_framebuffer_blit") &&
Mike Klein76343302017-06-22 13:15:13 -0700277 !fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000278 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000279 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000280 if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
Mike Klein76343302017-06-22 13:15:13 -0700281 !fFunctions.fRenderbufferStorageMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000282 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000283 }
284 }
285 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000286 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
Mike Klein76343302017-06-22 13:15:13 -0700287 if (!fFunctions.fRenderbufferStorageMultisample ||
288 !fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000289 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000290 }
Brian Salomonc5eceb02016-10-18 10:21:43 -0400291 } else {
292 if (fExtensions.has("GL_ANGLE_framebuffer_multisample") &&
Mike Klein76343302017-06-22 13:15:13 -0700293 !fFunctions.fRenderbufferStorageMultisample) {
Brian Salomonc5eceb02016-10-18 10:21:43 -0400294 RETURN_FALSE_INTERFACE
295 }
296 if (fExtensions.has("GL_ANGLE_framebuffer_blit") &&
Mike Klein76343302017-06-22 13:15:13 -0700297 !fFunctions.fBlitFramebuffer) {
Brian Salomonc5eceb02016-10-18 10:21:43 -0400298 RETURN_FALSE_INTERFACE
299 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000300 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000301 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
Mike Klein76343302017-06-22 13:15:13 -0700302 if (!fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
303 !fFunctions.fResolveMultisampleFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000304 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000305 }
306 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000307 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
308 fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
Mike Klein76343302017-06-22 13:15:13 -0700309 if (!fFunctions.fRenderbufferStorageMultisampleES2EXT ||
310 !fFunctions.fFramebufferTexture2DMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000311 RETURN_FALSE_INTERFACE
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000312 }
313 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000314 }
315
316 // On ES buffer mapping is an extension. On Desktop
317 // buffer mapping was part of original VBO extension
318 // which we require.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000319 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
Mike Klein76343302017-06-22 13:15:13 -0700320 if (!fFunctions.fMapBuffer ||
321 !fFunctions.fUnmapBuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000322 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000323 }
324 }
325
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000326 // Dual source blending
kkinnunend94708e2015-07-30 22:47:04 -0700327 if (kGL_GrGLStandard == fStandard) {
328 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended")) {
Mike Klein76343302017-06-22 13:15:13 -0700329 if (!fFunctions.fBindFragDataLocationIndexed) {
kkinnunend94708e2015-07-30 22:47:04 -0700330 RETURN_FALSE_INTERFACE
331 }
332 }
333 } else {
334 if (glVer >= GR_GL_VER(3,0) && fExtensions.has("GL_EXT_blend_func_extended")) {
Mike Klein76343302017-06-22 13:15:13 -0700335 if (!fFunctions.fBindFragDataLocation ||
336 !fFunctions.fBindFragDataLocationIndexed) {
kkinnunend94708e2015-07-30 22:47:04 -0700337 RETURN_FALSE_INTERFACE
338 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000339 }
340 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000341
kkinnunend94708e2015-07-30 22:47:04 -0700342
commit-bot@chromium.org726e6212013-08-23 20:55:46 +0000343 // glGetStringi was added in version 3.0 of both desktop and ES.
344 if (glVer >= GR_GL_VER(3, 0)) {
Mike Klein76343302017-06-22 13:15:13 -0700345 if (!fFunctions.fGetStringi) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000346 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000347 }
348 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000349
cdalton793dc262016-02-08 10:11:47 -0800350 // glVertexAttribIPointer was added in version 3.0 of both desktop and ES.
351 if (glVer >= GR_GL_VER(3, 0)) {
Mike Klein76343302017-06-22 13:15:13 -0700352 if (!fFunctions.fVertexAttribIPointer) {
cdalton793dc262016-02-08 10:11:47 -0800353 RETURN_FALSE_INTERFACE
354 }
355 }
356
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000357 if (kGL_GrGLStandard == fStandard) {
cdaltonc04ce672016-03-11 14:07:38 -0800358 if (glVer >= GR_GL_VER(3,1)) {
Mike Klein76343302017-06-22 13:15:13 -0700359 if (!fFunctions.fTexBuffer) {
cdaltonc04ce672016-03-11 14:07:38 -0800360 RETURN_FALSE_INTERFACE;
361 }
362 }
cdaltonf8a6ce82016-04-11 13:02:05 -0700363 if (glVer >= GR_GL_VER(4,3)) {
Mike Klein76343302017-06-22 13:15:13 -0700364 if (!fFunctions.fTexBufferRange) {
cdaltonf8a6ce82016-04-11 13:02:05 -0700365 RETURN_FALSE_INTERFACE;
366 }
367 }
cdaltonc04ce672016-03-11 14:07:38 -0800368 } else {
369 if (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_OES_texture_buffer") ||
370 fExtensions.has("GL_EXT_texture_buffer")) {
Mike Klein76343302017-06-22 13:15:13 -0700371 if (!fFunctions.fTexBuffer ||
372 !fFunctions.fTexBufferRange) {
cdaltonc04ce672016-03-11 14:07:38 -0800373 RETURN_FALSE_INTERFACE;
374 }
375 }
376 }
377
378 if (kGL_GrGLStandard == fStandard) {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000379 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
Mike Klein76343302017-06-22 13:15:13 -0700380 if (!fFunctions.fBindVertexArray ||
381 !fFunctions.fDeleteVertexArrays ||
382 !fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000383 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000384 }
385 }
386 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000387 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
Mike Klein76343302017-06-22 13:15:13 -0700388 if (!fFunctions.fBindVertexArray ||
389 !fFunctions.fDeleteVertexArrays ||
390 !fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000391 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000392 }
393 }
bsalomon@google.comecd84842013-03-01 15:36:02 +0000394 }
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000395
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000396 if (fExtensions.has("GL_EXT_debug_marker")) {
Mike Klein76343302017-06-22 13:15:13 -0700397 if (!fFunctions.fInsertEventMarker ||
398 !fFunctions.fPushGroupMarker ||
399 !fFunctions.fPopGroupMarker) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000400 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000401 }
402 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000403
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000404 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
405 fExtensions.has("GL_ARB_invalidate_subdata")) {
Mike Klein76343302017-06-22 13:15:13 -0700406 if (!fFunctions.fInvalidateBufferData ||
407 !fFunctions.fInvalidateBufferSubData ||
408 !fFunctions.fInvalidateFramebuffer ||
409 !fFunctions.fInvalidateSubFramebuffer ||
410 !fFunctions.fInvalidateTexImage ||
411 !fFunctions.fInvalidateTexSubImage) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000412 RETURN_FALSE_INTERFACE;
413 }
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000414 } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000415 // ES 3.0 adds the framebuffer functions but not the others.
Mike Klein76343302017-06-22 13:15:13 -0700416 if (!fFunctions.fInvalidateFramebuffer ||
417 !fFunctions.fInvalidateSubFramebuffer) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000418 RETURN_FALSE_INTERFACE;
419 }
420 }
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000421
422 if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
Mike Klein76343302017-06-22 13:15:13 -0700423 if (!fFunctions.fMapBufferSubData ||
424 !fFunctions.fMapTexSubImage2D ||
425 !fFunctions.fUnmapBufferSubData ||
426 !fFunctions.fUnmapTexSubImage2D) {
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000427 RETURN_FALSE_INTERFACE;
428 }
429 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000430
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000431 // These functions are added to the 3.0 version of both GLES and GL.
432 if (glVer >= GR_GL_VER(3,0) ||
433 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
434 (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
Mike Klein76343302017-06-22 13:15:13 -0700435 if (!fFunctions.fMapBufferRange ||
436 !fFunctions.fFlushMappedBufferRange) {
kkinnunenf655e932016-03-03 07:39:48 -0800437 RETURN_FALSE_INTERFACE;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000438 }
439 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700440
kkinnunen32b9a3b2014-07-02 22:56:35 -0700441 if ((kGL_GrGLStandard == fStandard &&
cdaltoneb79eea2016-02-26 10:39:34 -0800442 (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_ARB_texture_multisample"))) ||
443 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
Mike Klein76343302017-06-22 13:15:13 -0700444 if (!fFunctions.fGetMultisamplefv) {
cdaltoneb79eea2016-02-26 10:39:34 -0800445 RETURN_FALSE_INTERFACE
446 }
447 }
448
449 if ((kGL_GrGLStandard == fStandard &&
kkinnunen32b9a3b2014-07-02 22:56:35 -0700450 (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) ||
451 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
Mike Klein76343302017-06-22 13:15:13 -0700452 if (!fFunctions.fGetProgramResourceLocation) {
kkinnunen32b9a3b2014-07-02 22:56:35 -0700453 RETURN_FALSE_INTERFACE
454 }
455 }
456
bsalomonee64d6e2014-12-03 10:46:08 -0800457 if (kGLES_GrGLStandard == fStandard || glVer >= GR_GL_VER(4,1) ||
458 fExtensions.has("GL_ARB_ES2_compatibility")) {
Mike Klein76343302017-06-22 13:15:13 -0700459 if (!fFunctions.fGetShaderPrecisionFormat) {
bsalomonee64d6e2014-12-03 10:46:08 -0800460 RETURN_FALSE_INTERFACE
461 }
bsalomonee64d6e2014-12-03 10:46:08 -0800462 }
463
kkinnunen6bb6d402015-07-14 10:59:23 -0700464 if (fExtensions.has("GL_NV_path_rendering") || fExtensions.has("GL_CHROMIUM_path_rendering")) {
Mike Klein76343302017-06-22 13:15:13 -0700465 if (!fFunctions.fMatrixLoadf ||
466 !fFunctions.fMatrixLoadIdentity ||
467 !fFunctions.fPathCommands ||
468 !fFunctions.fPathParameteri ||
469 !fFunctions.fPathParameterf ||
470 !fFunctions.fGenPaths ||
471 !fFunctions.fDeletePaths ||
472 !fFunctions.fIsPath ||
473 !fFunctions.fPathStencilFunc ||
474 !fFunctions.fStencilFillPath ||
475 !fFunctions.fStencilStrokePath ||
476 !fFunctions.fStencilFillPathInstanced ||
477 !fFunctions.fStencilStrokePathInstanced ||
478 !fFunctions.fCoverFillPath ||
479 !fFunctions.fCoverStrokePath ||
480 !fFunctions.fCoverFillPathInstanced ||
481 !fFunctions.fCoverStrokePathInstanced
kkinnunencfe62e32015-07-01 02:58:50 -0700482#if 0
483 // List of functions that Skia uses, but which have been added since the initial release
484 // of NV_path_rendering driver. We do not want to fail interface validation due to
485 // missing features, we will just not use the extension.
486 // Update this list -> update GrGLCaps::hasPathRenderingSupport too.
Mike Klein76343302017-06-22 13:15:13 -0700487 || !fFunctions.fStencilThenCoverFillPath ||
488 !fFunctions.fStencilThenCoverStrokePath ||
489 !fFunctions.fStencilThenCoverFillPathInstanced ||
490 !fFunctions.fStencilThenCoverStrokePathInstanced ||
491 !fFunctions.fProgramPathFragmentInputGen
kkinnunencfe62e32015-07-01 02:58:50 -0700492#endif
493 ) {
kkinnunen32b9a3b2014-07-02 22:56:35 -0700494 RETURN_FALSE_INTERFACE
495 }
kkinnunen6bb6d402015-07-14 10:59:23 -0700496 if (fExtensions.has("GL_CHROMIUM_path_rendering")) {
Mike Klein76343302017-06-22 13:15:13 -0700497 if (!fFunctions.fBindFragmentInputLocation) {
kkinnunen6bb6d402015-07-14 10:59:23 -0700498 RETURN_FALSE_INTERFACE
499 }
500 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700501 }
502
cdalton0edea2c2015-05-21 08:27:44 -0700503 if (fExtensions.has("GL_EXT_raster_multisample")) {
Mike Klein76343302017-06-22 13:15:13 -0700504 if (!fFunctions.fRasterSamples) {
cdalton0edea2c2015-05-21 08:27:44 -0700505 RETURN_FALSE_INTERFACE
506 }
507 }
508
kkinnunenea409432015-12-10 01:21:59 -0800509 if (fExtensions.has("GL_NV_framebuffer_mixed_samples") ||
510 fExtensions.has("GL_CHROMIUM_framebuffer_mixed_samples")) {
Mike Klein76343302017-06-22 13:15:13 -0700511 if (!fFunctions.fCoverageModulation) {
vbuzinov08b4d292015-04-01 06:29:49 -0700512 RETURN_FALSE_INTERFACE
513 }
514 }
515
hendrikwb3f16362015-10-19 06:13:55 -0700516 if (kGL_GrGLStandard == fStandard) {
517 if (glVer >= GR_GL_VER(3,1) ||
518 fExtensions.has("GL_EXT_draw_instanced") || fExtensions.has("GL_ARB_draw_instanced")) {
Mike Klein76343302017-06-22 13:15:13 -0700519 if (!fFunctions.fDrawArraysInstanced ||
520 !fFunctions.fDrawElementsInstanced) {
hendrikwb3f16362015-10-19 06:13:55 -0700521 RETURN_FALSE_INTERFACE
522 }
halcanary9d524f22016-03-29 09:03:52 -0700523 }
hendrikwb3f16362015-10-19 06:13:55 -0700524 } else if (kGLES_GrGLStandard == fStandard) {
kkinnunenf655e932016-03-03 07:39:48 -0800525 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_draw_instanced")) {
Mike Klein76343302017-06-22 13:15:13 -0700526 if (!fFunctions.fDrawArraysInstanced ||
527 !fFunctions.fDrawElementsInstanced) {
kkinnunenf655e932016-03-03 07:39:48 -0800528 RETURN_FALSE_INTERFACE
hendrikwb3f16362015-10-19 06:13:55 -0700529 }
halcanary9d524f22016-03-29 09:03:52 -0700530 }
cdalton626e1ff2015-06-12 13:56:46 -0700531 }
532
hendrikwb3f16362015-10-19 06:13:55 -0700533 if (kGL_GrGLStandard == fStandard) {
534 if (glVer >= GR_GL_VER(3,2) || fExtensions.has("GL_ARB_instanced_arrays")) {
Mike Klein76343302017-06-22 13:15:13 -0700535 if (!fFunctions.fVertexAttribDivisor) {
hendrikwb3f16362015-10-19 06:13:55 -0700536 RETURN_FALSE_INTERFACE
537 }
halcanary9d524f22016-03-29 09:03:52 -0700538 }
hendrikwb3f16362015-10-19 06:13:55 -0700539 } else if (kGLES_GrGLStandard == fStandard) {
kkinnunenf655e932016-03-03 07:39:48 -0800540 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_instanced_arrays")) {
Mike Klein76343302017-06-22 13:15:13 -0700541 if (!fFunctions.fVertexAttribDivisor) {
kkinnunenf655e932016-03-03 07:39:48 -0800542 RETURN_FALSE_INTERFACE
hendrikwb3f16362015-10-19 06:13:55 -0700543 }
halcanary9d524f22016-03-29 09:03:52 -0700544 }
cdalton626e1ff2015-06-12 13:56:46 -0700545 }
546
csmartdalton5cebf8c2016-06-03 08:28:47 -0700547 if ((kGL_GrGLStandard == fStandard &&
548 (glVer >= GR_GL_VER(4,0) || fExtensions.has("GL_ARB_draw_indirect"))) ||
cdalton06604b92016-02-05 10:09:51 -0800549 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
Mike Klein76343302017-06-22 13:15:13 -0700550 if (!fFunctions.fDrawArraysIndirect ||
551 !fFunctions.fDrawElementsIndirect) {
cdalton06604b92016-02-05 10:09:51 -0800552 RETURN_FALSE_INTERFACE
553 }
554 }
555
csmartdalton5cebf8c2016-06-03 08:28:47 -0700556 if ((kGL_GrGLStandard == fStandard &&
557 (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_multi_draw_indirect"))) ||
cdalton06604b92016-02-05 10:09:51 -0800558 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_multi_draw_indirect"))) {
Mike Klein76343302017-06-22 13:15:13 -0700559 if (!fFunctions.fMultiDrawArraysIndirect ||
560 !fFunctions.fMultiDrawElementsIndirect) {
cdalton06604b92016-02-05 10:09:51 -0800561 RETURN_FALSE_INTERFACE
562 }
563 }
564
cdalton626e1ff2015-06-12 13:56:46 -0700565 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
566 fExtensions.has("GL_KHR_debug")) {
Mike Klein76343302017-06-22 13:15:13 -0700567 if (!fFunctions.fDebugMessageControl ||
568 !fFunctions.fDebugMessageInsert ||
569 !fFunctions.fDebugMessageCallback ||
570 !fFunctions.fGetDebugMessageLog ||
571 !fFunctions.fPushDebugGroup ||
572 !fFunctions.fPopDebugGroup ||
573 !fFunctions.fObjectLabel) {
cdalton626e1ff2015-06-12 13:56:46 -0700574 RETURN_FALSE_INTERFACE
575 }
576 }
577
csmartdalton9bc11872016-08-09 12:42:47 -0700578 if (fExtensions.has("GL_EXT_window_rectangles")) {
Mike Klein76343302017-06-22 13:15:13 -0700579 if (!fFunctions.fWindowRectangles) {
csmartdalton9bc11872016-08-09 12:42:47 -0700580 RETURN_FALSE_INTERFACE
581 }
582 }
583
ethannicholas28ef4452016-03-25 09:26:03 -0700584 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,0)) ||
585 fExtensions.has("GL_ARB_sample_shading")) {
Mike Klein76343302017-06-22 13:15:13 -0700586 if (!fFunctions.fMinSampleShading) {
ethannicholas28ef4452016-03-25 09:26:03 -0700587 RETURN_FALSE_INTERFACE
588 }
bsalomon23c4f1a2016-07-19 06:21:55 -0700589 } else if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_OES_sample_shading")) {
Mike Klein76343302017-06-22 13:15:13 -0700590 if (!fFunctions.fMinSampleShading) {
ethannicholas28ef4452016-03-25 09:26:03 -0700591 RETURN_FALSE_INTERFACE
592 }
593 }
594
jvanverth84741b32016-09-30 08:39:02 -0700595 if (kGL_GrGLStandard == fStandard) {
596 if (glVer >= GR_GL_VER(3, 2) || fExtensions.has("GL_ARB_sync")) {
Mike Klein76343302017-06-22 13:15:13 -0700597 if (!fFunctions.fFenceSync ||
Greg Daniel6bd729d2017-07-31 09:38:23 -0400598 !fFunctions.fIsSync ||
Mike Klein76343302017-06-22 13:15:13 -0700599 !fFunctions.fClientWaitSync ||
600 !fFunctions.fWaitSync ||
601 !fFunctions.fDeleteSync) {
jvanverth84741b32016-09-30 08:39:02 -0700602 RETURN_FALSE_INTERFACE
603 }
604 }
605 } else if (kGLES_GrGLStandard == fStandard) {
Brian Osman93a23462017-06-21 15:13:39 -0400606 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_APPLE_sync")) {
Mike Klein76343302017-06-22 13:15:13 -0700607 if (!fFunctions.fFenceSync ||
Greg Daniel6bd729d2017-07-31 09:38:23 -0400608 !fFunctions.fIsSync ||
Mike Klein76343302017-06-22 13:15:13 -0700609 !fFunctions.fClientWaitSync ||
610 !fFunctions.fWaitSync ||
611 !fFunctions.fDeleteSync) {
jvanverth84741b32016-09-30 08:39:02 -0700612 RETURN_FALSE_INTERFACE
613 }
614 }
615 }
616
bsalomonb1a32ad2015-11-16 06:48:44 -0800617 if (fExtensions.has("EGL_KHR_image") || fExtensions.has("EGL_KHR_image_base")) {
Mike Klein76343302017-06-22 13:15:13 -0700618 if (!fFunctions.fEGLCreateImage ||
619 !fFunctions.fEGLDestroyImage) {
bsalomonb1a32ad2015-11-16 06:48:44 -0800620 RETURN_FALSE_INTERFACE
621 }
622 }
623
Brian Salomon15b25092017-05-08 11:10:53 -0400624 // glDrawRangeElements was added to ES in 3.0.
625 if (kGL_GrGLStandard == fStandard || glVer >= GR_GL_VER(3,0)) {
Mike Klein76343302017-06-22 13:15:13 -0700626 if (!fFunctions.fDrawRangeElements) {
bsalomonfc9527a2016-08-29 09:18:39 -0700627 RETURN_FALSE_INTERFACE;
628 }
629 }
630
Greg Daniel81e7bf82017-07-19 14:47:42 -0400631 // getInternalformativ was added in GL 4.2, ES 3.0, and with extension ARB_internalformat_query
632 if ((kGL_GrGLStandard == fStandard &&
633 (glVer >= GR_GL_VER(4,2) || fExtensions.has("GL_ARB_internalformat_query"))) ||
634 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0))) {
Mike Klein76343302017-06-22 13:15:13 -0700635 if (!fFunctions.fGetInternalformativ) {
Greg Daniel6bd729d2017-07-31 09:38:23 -0400636 RETURN_FALSE_INTERFACE;
Greg Daniel81e7bf82017-07-19 14:47:42 -0400637 }
638 }
639
Ethan Nicholasd1b2eec2017-11-01 15:45:43 -0400640 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,1)) ||
641 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0))) {
642 if (!fFunctions.fGetProgramBinary ||
643 !fFunctions.fProgramBinary ||
644 !fFunctions.fProgramParameteri) {
645 RETURN_FALSE_INTERFACE;
646 }
647 }
648
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000649 return true;
650}