blob: 823b73efa38a4725ee7765a8c420919b5347a577 [file] [log] [blame]
twiz@google.com59a190b2011-03-14 21:23:01 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
twiz@google.com59a190b2011-03-14 21:23:01 +00006 */
7
8
tomhudson@google.com6bf38b52012-02-14 15:11:59 +00009#include "gl/GrGLInterface.h"
bsalomon@google.com1744f972013-02-26 21:46:32 +000010#include "gl/GrGLExtensions.h"
11#include "gl/GrGLUtil.h"
twiz@google.com59a190b2011-03-14 21:23:01 +000012
13#include <stdio.h>
14
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +000015#if GR_GL_PER_GL_FUNC_CALLBACK
16namespace {
17void GrGLDefaultInterfaceCallback(const GrGLInterface*) {}
18}
19#endif
20
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000021const GrGLInterface* GrGLInterfaceAddTestDebugMarker(const GrGLInterface* interface,
22 GrGLInsertEventMarkerProc insertEventMarkerFn,
23 GrGLPushGroupMarkerProc pushGroupMarkerFn,
24 GrGLPopGroupMarkerProc popGroupMarkerFn) {
25 GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
26
27 if (!newInterface->fExtensions.has("GL_EXT_debug_marker")) {
28 newInterface->fExtensions.add("GL_EXT_debug_marker");
29 }
30
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000031 newInterface->fFunctions.fInsertEventMarker = insertEventMarkerFn;
32 newInterface->fFunctions.fPushGroupMarker = pushGroupMarkerFn;
33 newInterface->fFunctions.fPopGroupMarker = popGroupMarkerFn;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000034
35 return newInterface;
36}
37
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000038const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) {
39 GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
40
41 newInterface->fExtensions.remove("GL_NV_path_rendering");
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000042 newInterface->fFunctions.fPathCommands = NULL;
43 newInterface->fFunctions.fPathCoords = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000044 newInterface->fFunctions.fPathParameteri = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000045 newInterface->fFunctions.fPathParameterf = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000046 newInterface->fFunctions.fGenPaths = NULL;
47 newInterface->fFunctions.fDeletePaths = NULL;
cdalton8dd90cb2014-07-17 09:28:36 -070048 newInterface->fFunctions.fIsPath = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000049 newInterface->fFunctions.fPathStencilFunc = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000050 newInterface->fFunctions.fStencilFillPath = NULL;
51 newInterface->fFunctions.fStencilStrokePath = NULL;
52 newInterface->fFunctions.fStencilFillPathInstanced = NULL;
53 newInterface->fFunctions.fStencilStrokePathInstanced = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000054 newInterface->fFunctions.fPathTexGen = NULL;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +000055 newInterface->fFunctions.fCoverFillPath = NULL;
56 newInterface->fFunctions.fCoverStrokePath = NULL;
57 newInterface->fFunctions.fCoverFillPathInstanced = NULL;
58 newInterface->fFunctions.fCoverStrokePathInstanced = NULL;
kkinnunen32b9a3b2014-07-02 22:56:35 -070059 newInterface->fFunctions.fProgramPathFragmentInputGen = NULL;
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
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +000066#if GR_GL_PER_GL_FUNC_CALLBACK
67 fCallback = GrGLDefaultInterfaceCallback;
68 fCallbackData = 0;
69#endif
bsalomon@google.com0b77d682011-08-19 13:28:54 +000070}
71
commit-bot@chromium.orgd8ed8512014-01-24 20:49:44 +000072GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
73 SkASSERT(NULL != interface);
74
75 GrGLInterface* clone = SkNEW(GrGLInterface);
76 clone->fStandard = interface->fStandard;
77 clone->fExtensions = interface->fExtensions;
78 clone->fFunctions = interface->fFunctions;
79#if GR_GL_PER_GL_FUNC_CALLBACK
80 clone->fCallback = interface->fCallback;
81 clone->fCallbackData = interface->fCallbackData;
82#endif
83 return clone;
84}
85
commit-bot@chromium.orge83b9b72014-05-01 19:21:41 +000086#ifdef SK_DEBUG
87 static int kIsDebug = 1;
88#else
89 static int kIsDebug = 0;
90#endif
91
92#define RETURN_FALSE_INTERFACE \
93 if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
94 return false;
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000095
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000096bool GrGLInterface::validate() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000097
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +000098 if (kNone_GrGLStandard == fStandard) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +000099 RETURN_FALSE_INTERFACE
bsalomon@google.com1dcf5062011-11-14 19:29:53 +0000100 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000101
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000102 if (!fExtensions.isInitialized()) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000103 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000104 }
bsalomon@google.com1dcf5062011-11-14 19:29:53 +0000105
106 // functions that are always required
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000107 if (NULL == fFunctions.fActiveTexture ||
108 NULL == fFunctions.fAttachShader ||
109 NULL == fFunctions.fBindAttribLocation ||
110 NULL == fFunctions.fBindBuffer ||
111 NULL == fFunctions.fBindTexture ||
112 NULL == fFunctions.fBlendFunc ||
113 NULL == fFunctions.fBlendColor || // -> GL >= 1.4, ES >= 2.0 or extension
114 NULL == fFunctions.fBufferData ||
115 NULL == fFunctions.fBufferSubData ||
116 NULL == fFunctions.fClear ||
117 NULL == fFunctions.fClearColor ||
118 NULL == fFunctions.fClearStencil ||
119 NULL == fFunctions.fColorMask ||
120 NULL == fFunctions.fCompileShader ||
121 NULL == fFunctions.fCopyTexSubImage2D ||
122 NULL == fFunctions.fCreateProgram ||
123 NULL == fFunctions.fCreateShader ||
124 NULL == fFunctions.fCullFace ||
125 NULL == fFunctions.fDeleteBuffers ||
126 NULL == fFunctions.fDeleteProgram ||
127 NULL == fFunctions.fDeleteShader ||
128 NULL == fFunctions.fDeleteTextures ||
129 NULL == fFunctions.fDepthMask ||
130 NULL == fFunctions.fDisable ||
131 NULL == fFunctions.fDisableVertexAttribArray ||
132 NULL == fFunctions.fDrawArrays ||
133 NULL == fFunctions.fDrawElements ||
134 NULL == fFunctions.fEnable ||
135 NULL == fFunctions.fEnableVertexAttribArray ||
136 NULL == fFunctions.fFrontFace ||
137 NULL == fFunctions.fGenBuffers ||
138 NULL == fFunctions.fGenTextures ||
139 NULL == fFunctions.fGetBufferParameteriv ||
140 NULL == fFunctions.fGenerateMipmap ||
141 NULL == fFunctions.fGetError ||
142 NULL == fFunctions.fGetIntegerv ||
143 NULL == fFunctions.fGetProgramInfoLog ||
144 NULL == fFunctions.fGetProgramiv ||
145 NULL == fFunctions.fGetShaderInfoLog ||
146 NULL == fFunctions.fGetShaderiv ||
147 NULL == fFunctions.fGetString ||
148 NULL == fFunctions.fGetUniformLocation ||
149 NULL == fFunctions.fLinkProgram ||
150 NULL == fFunctions.fLineWidth ||
151 NULL == fFunctions.fPixelStorei ||
152 NULL == fFunctions.fReadPixels ||
153 NULL == fFunctions.fScissor ||
154 NULL == fFunctions.fShaderSource ||
155 NULL == fFunctions.fStencilFunc ||
156 NULL == fFunctions.fStencilMask ||
157 NULL == fFunctions.fStencilOp ||
158 NULL == fFunctions.fTexImage2D ||
159 NULL == fFunctions.fTexParameteri ||
160 NULL == fFunctions.fTexParameteriv ||
161 NULL == fFunctions.fTexSubImage2D ||
162 NULL == fFunctions.fUniform1f ||
163 NULL == fFunctions.fUniform1i ||
164 NULL == fFunctions.fUniform1fv ||
165 NULL == fFunctions.fUniform1iv ||
166 NULL == fFunctions.fUniform2f ||
167 NULL == fFunctions.fUniform2i ||
168 NULL == fFunctions.fUniform2fv ||
169 NULL == fFunctions.fUniform2iv ||
170 NULL == fFunctions.fUniform3f ||
171 NULL == fFunctions.fUniform3i ||
172 NULL == fFunctions.fUniform3fv ||
173 NULL == fFunctions.fUniform3iv ||
174 NULL == fFunctions.fUniform4f ||
175 NULL == fFunctions.fUniform4i ||
176 NULL == fFunctions.fUniform4fv ||
177 NULL == fFunctions.fUniform4iv ||
178 NULL == fFunctions.fUniformMatrix2fv ||
179 NULL == fFunctions.fUniformMatrix3fv ||
180 NULL == fFunctions.fUniformMatrix4fv ||
181 NULL == fFunctions.fUseProgram ||
182 NULL == fFunctions.fVertexAttrib4fv ||
183 NULL == fFunctions.fVertexAttribPointer ||
184 NULL == fFunctions.fViewport ||
185 NULL == fFunctions.fBindFramebuffer ||
186 NULL == fFunctions.fBindRenderbuffer ||
187 NULL == fFunctions.fCheckFramebufferStatus ||
188 NULL == fFunctions.fDeleteFramebuffers ||
189 NULL == fFunctions.fDeleteRenderbuffers ||
190 NULL == fFunctions.fFinish ||
191 NULL == fFunctions.fFlush ||
192 NULL == fFunctions.fFramebufferRenderbuffer ||
193 NULL == fFunctions.fFramebufferTexture2D ||
194 NULL == fFunctions.fGetFramebufferAttachmentParameteriv ||
195 NULL == fFunctions.fGetRenderbufferParameteriv ||
196 NULL == fFunctions.fGenFramebuffers ||
197 NULL == fFunctions.fGenRenderbuffers ||
198 NULL == fFunctions.fRenderbufferStorage) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000199 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000200 }
201
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000202 GrGLVersion glVer = GrGLGetVersion(this);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000203 if (GR_GL_INVALID_VER == glVer) {
204 RETURN_FALSE_INTERFACE
205 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000206
207 // Now check that baseline ES/Desktop fns not covered above are present
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000208 // and that we have fn pointers for any advertised fExtensions that we will
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000209 // try to use.
210
211 // these functions are part of ES2, we assume they are available
212 // On the desktop we assume they are available if the extension
213 // is present or GL version is high enough.
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000214 if (kGLES_GrGLStandard == fStandard) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000215 if (NULL == fFunctions.fStencilFuncSeparate ||
216 NULL == fFunctions.fStencilMaskSeparate ||
217 NULL == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000218 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000219 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000220 } else if (kGL_GrGLStandard == fStandard) {
robertphillips@google.come7884302012-04-18 14:39:58 +0000221
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000222 if (glVer >= GR_GL_VER(2,0)) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000223 if (NULL == fFunctions.fStencilFuncSeparate ||
224 NULL == fFunctions.fStencilMaskSeparate ||
225 NULL == fFunctions.fStencilOpSeparate) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000226 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000227 }
228 }
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000229 if (glVer >= GR_GL_VER(3,0) && NULL == fFunctions.fBindFragDataLocation) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000230 RETURN_FALSE_INTERFACE
bsalomon@google.combc5cf512011-09-21 16:21:07 +0000231 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000232 if (glVer >= GR_GL_VER(2,0) || fExtensions.has("GL_ARB_draw_buffers")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000233 if (NULL == fFunctions.fDrawBuffers) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000234 RETURN_FALSE_INTERFACE
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000235 }
236 }
robertphillips@google.come7884302012-04-18 14:39:58 +0000237
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000238 if (glVer >= GR_GL_VER(1,5) || fExtensions.has("GL_ARB_occlusion_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000239 if (NULL == fFunctions.fGenQueries ||
240 NULL == fFunctions.fDeleteQueries ||
241 NULL == fFunctions.fBeginQuery ||
242 NULL == fFunctions.fEndQuery ||
243 NULL == fFunctions.fGetQueryiv ||
244 NULL == fFunctions.fGetQueryObjectiv ||
245 NULL == fFunctions.fGetQueryObjectuiv) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000246 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000247 }
248 }
249 if (glVer >= GR_GL_VER(3,3) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000250 fExtensions.has("GL_ARB_timer_query") ||
251 fExtensions.has("GL_EXT_timer_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000252 if (NULL == fFunctions.fGetQueryObjecti64v ||
253 NULL == fFunctions.fGetQueryObjectui64v) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000254 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000255 }
256 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000257 if (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_timer_query")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000258 if (NULL == fFunctions.fQueryCounter) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000259 RETURN_FALSE_INTERFACE
bsalomon@google.com373a6632011-10-19 20:43:20 +0000260 }
261 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000262 }
263
264 // optional function on desktop before 1.3
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000265 if (kGL_GrGLStandard != fStandard ||
bsalomon@google.com1744f972013-02-26 21:46:32 +0000266 (glVer >= GR_GL_VER(1,3)) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000267 fExtensions.has("GL_ARB_texture_compression")) {
krajcevskie1f5a232014-06-11 16:08:50 -0700268 if (NULL == fFunctions.fCompressedTexImage2D
269#if 0
270 || NULL == fFunctions.fCompressedTexSubImage2D
271#endif
272 ) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000273 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000274 }
275 }
276
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000277 // part of desktop GL, but not ES
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000278 if (kGL_GrGLStandard == fStandard &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000279 (NULL == fFunctions.fGetTexLevelParameteriv ||
280 NULL == fFunctions.fDrawBuffer ||
281 NULL == fFunctions.fReadBuffer)) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000282 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000283 }
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000284
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000285 // GL_EXT_texture_storage is part of desktop 4.2
286 // There is a desktop ARB extension and an ES+desktop EXT extension
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000287 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000288 if (glVer >= GR_GL_VER(4,2) ||
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000289 fExtensions.has("GL_ARB_texture_storage") ||
290 fExtensions.has("GL_EXT_texture_storage")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000291 if (NULL == fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000292 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000293 }
294 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000295 } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000296 if (NULL == fFunctions.fTexStorage2D) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000297 RETURN_FALSE_INTERFACE
bsalomon@google.combaa9ea12012-01-06 19:05:43 +0000298 }
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000299 }
300
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000301 if (fExtensions.has("GL_EXT_discard_framebuffer")) {
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000302// FIXME: Remove this once Chromium is updated to provide this function
303#if 0
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000304 if (NULL == fFunctions.fDiscardFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000305 RETURN_FALSE_INTERFACE
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000306 }
307#endif
308 }
309
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000310 // FBO MSAA
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000311 if (kGL_GrGLStandard == fStandard) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000312 // GL 3.0 and the ARB extension have multisample + blit
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000313 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_ARB_framebuffer_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000314 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
315 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000316 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000317 }
318 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000319 if (fExtensions.has("GL_EXT_framebuffer_blit") &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000320 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000321 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000322 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000323 if (fExtensions.has("GL_EXT_framebuffer_multisample") &&
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000324 NULL == fFunctions.fRenderbufferStorageMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000325 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000326 }
327 }
328 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000329 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_CHROMIUM_framebuffer_multisample")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000330 if (NULL == fFunctions.fRenderbufferStorageMultisample ||
331 NULL == fFunctions.fBlitFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000332 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000333 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000334 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000335 if (fExtensions.has("GL_APPLE_framebuffer_multisample")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000336 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2APPLE ||
337 NULL == fFunctions.fResolveMultisampleFramebuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000338 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000339 }
340 }
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000341 if (fExtensions.has("GL_IMG_multisampled_render_to_texture") ||
342 fExtensions.has("GL_EXT_multisampled_render_to_texture")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000343 if (NULL == fFunctions.fRenderbufferStorageMultisampleES2EXT ||
344 NULL == fFunctions.fFramebufferTexture2DMultisample) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000345 RETURN_FALSE_INTERFACE
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000346 }
347 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000348 }
349
350 // On ES buffer mapping is an extension. On Desktop
351 // buffer mapping was part of original VBO extension
352 // which we require.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000353 if (kGL_GrGLStandard == fStandard || fExtensions.has("GL_OES_mapbuffer")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000354 if (NULL == fFunctions.fMapBuffer ||
355 NULL == fFunctions.fUnmapBuffer) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000356 RETURN_FALSE_INTERFACE
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000357 }
358 }
359
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000360 // Dual source blending
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000361 if (kGL_GrGLStandard == fStandard &&
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000362 (glVer >= GR_GL_VER(3,3) || fExtensions.has("GL_ARB_blend_func_extended"))) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000363 if (NULL == fFunctions.fBindFragDataLocationIndexed) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000364 RETURN_FALSE_INTERFACE
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000365 }
366 }
skia.committer@gmail.com12eea2b2013-02-27 07:10:10 +0000367
commit-bot@chromium.org726e6212013-08-23 20:55:46 +0000368 // glGetStringi was added in version 3.0 of both desktop and ES.
369 if (glVer >= GR_GL_VER(3, 0)) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000370 if (NULL == fFunctions.fGetStringi) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000371 RETURN_FALSE_INTERFACE
bsalomon@google.com1744f972013-02-26 21:46:32 +0000372 }
373 }
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000374
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000375 if (kGL_GrGLStandard == fStandard) {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000376 if (glVer >= GR_GL_VER(3, 0) || fExtensions.has("GL_ARB_vertex_array_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000377 if (NULL == fFunctions.fBindVertexArray ||
378 NULL == fFunctions.fDeleteVertexArrays ||
379 NULL == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000380 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000381 }
382 }
383 } else {
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000384 if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_OES_vertex_array_object")) {
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000385 if (NULL == fFunctions.fBindVertexArray ||
386 NULL == fFunctions.fDeleteVertexArrays ||
387 NULL == fFunctions.fGenVertexArrays) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000388 RETURN_FALSE_INTERFACE
bsalomon@google.comecd84842013-03-01 15:36:02 +0000389 }
390 }
bsalomon@google.comecd84842013-03-01 15:36:02 +0000391 }
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000392
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000393 if (fExtensions.has("GL_EXT_debug_marker")) {
394 if (NULL == fFunctions.fInsertEventMarker ||
395 NULL == fFunctions.fPushGroupMarker ||
396 NULL == fFunctions.fPopGroupMarker) {
commit-bot@chromium.orgadadf7c2014-03-24 19:43:02 +0000397 RETURN_FALSE_INTERFACE
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000398 }
399 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000400
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000401 if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
402 fExtensions.has("GL_ARB_invalidate_subdata")) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000403 if (NULL == fFunctions.fInvalidateBufferData ||
404 NULL == fFunctions.fInvalidateBufferSubData ||
405 NULL == fFunctions.fInvalidateFramebuffer ||
406 NULL == fFunctions.fInvalidateSubFramebuffer ||
407 NULL == fFunctions.fInvalidateTexImage ||
408 NULL == fFunctions.fInvalidateTexSubImage) {
409 RETURN_FALSE_INTERFACE;
410 }
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000411 } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000412 // ES 3.0 adds the framebuffer functions but not the others.
413 if (NULL == fFunctions.fInvalidateFramebuffer ||
414 NULL == fFunctions.fInvalidateSubFramebuffer) {
415 RETURN_FALSE_INTERFACE;
416 }
417 }
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000418
419 if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
420 if (NULL == fFunctions.fMapBufferSubData ||
421 NULL == fFunctions.fMapTexSubImage2D ||
422 NULL == fFunctions.fUnmapBufferSubData ||
423 NULL == fFunctions.fUnmapTexSubImage2D) {
424 RETURN_FALSE_INTERFACE;
425 }
426 }
bsalomon@google.coma34bb602014-04-01 13:07:29 +0000427
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000428 // These functions are added to the 3.0 version of both GLES and GL.
429 if (glVer >= GR_GL_VER(3,0) ||
430 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
431 (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
432 if (NULL == fFunctions.fMapBufferRange ||
433 NULL == fFunctions.fFlushMappedBufferRange) {
434 RETURN_FALSE_INTERFACE;
435 }
436 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700437
438 if ((kGL_GrGLStandard == fStandard && fExtensions.has("GL_EXT_direct_state_access")) ||
439 (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_NV_path_rendering"))) {
440 if (NULL == fFunctions.fMatrixLoadf ||
441 NULL == fFunctions.fMatrixLoadIdentity) {
442 RETURN_FALSE_INTERFACE
443 }
444 }
445
446 if ((kGL_GrGLStandard == fStandard &&
447 (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) ||
448 (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
449 if (NULL == fFunctions.fGetProgramResourceLocation) {
450 RETURN_FALSE_INTERFACE
451 }
452 }
453
454 if (fExtensions.has("GL_NV_path_rendering")) {
455 if (NULL == fFunctions.fPathCommands ||
456 NULL == fFunctions.fPathCoords ||
457 NULL == fFunctions.fPathParameteri ||
458 NULL == fFunctions.fPathParameterf ||
459 NULL == fFunctions.fGenPaths ||
460 NULL == fFunctions.fDeletePaths ||
cdalton8dd90cb2014-07-17 09:28:36 -0700461 NULL == fFunctions.fIsPath ||
kkinnunen32b9a3b2014-07-02 22:56:35 -0700462 NULL == fFunctions.fPathStencilFunc ||
463 NULL == fFunctions.fStencilFillPath ||
464 NULL == fFunctions.fStencilStrokePath ||
465 NULL == fFunctions.fStencilFillPathInstanced ||
466 NULL == fFunctions.fStencilStrokePathInstanced ||
467 NULL == fFunctions.fCoverFillPath ||
468 NULL == fFunctions.fCoverStrokePath ||
469 NULL == fFunctions.fCoverFillPathInstanced ||
470 NULL == fFunctions.fCoverStrokePathInstanced) {
471 RETURN_FALSE_INTERFACE
472 }
473 // Currently ProgramPathFragmentInputGen is not used on
474 // OpenGL, rather PathTexGen is.
475 if ((kGL_GrGLStandard == fStandard && NULL == fFunctions.fPathTexGen) ||
476 (kGLES_GrGLStandard == fStandard && NULL == fFunctions.fProgramPathFragmentInputGen)) {
477 RETURN_FALSE_INTERFACE
478 }
479 }
480
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000481 return true;
482}