blob: 471b5a66cd55d28eac321c2b579f0c5030af0693 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
twiz@google.com59a190b2011-03-14 21:23:01 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
twiz@google.com59a190b2011-03-14 21:23:01 +00007 */
8
9
twiz@google.com59a190b2011-03-14 21:23:01 +000010#include "GrTypes.h"
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000011#include "GrGLInterface.h"
12#include "GrGLDefines.h"
twiz@google.com59a190b2011-03-14 21:23:01 +000013
14#include <stdio.h>
15
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +000016#if GR_GL_PER_GL_FUNC_CALLBACK
17namespace {
18void GrGLDefaultInterfaceCallback(const GrGLInterface*) {}
19}
20#endif
21
bsalomon@google.comc82b8892011-09-22 14:10:33 +000022GrGLVersion GrGLGetVersionFromString(const char* versionString) {
bsalomon@google.comedfe1aa2011-09-29 14:40:26 +000023 if (NULL == versionString) {
24 GrAssert(!"NULL GL version string.");
25 return 0;
26 }
27
bsalomon@google.comc82b8892011-09-22 14:10:33 +000028 int major, minor;
twiz@google.com0f31ca72011-03-18 17:38:11 +000029
bsalomon@google.comc82b8892011-09-22 14:10:33 +000030 int n = sscanf(versionString, "%d.%d", &major, &minor);
twiz@google.com0f31ca72011-03-18 17:38:11 +000031 if (2 == n) {
bsalomon@google.comc82b8892011-09-22 14:10:33 +000032 return GR_GL_VER(major, minor);
twiz@google.com59a190b2011-03-14 21:23:01 +000033 }
twiz@google.com0f31ca72011-03-18 17:38:11 +000034
twiz@google.com59a190b2011-03-14 21:23:01 +000035 char profile[2];
twiz@google.com0f31ca72011-03-18 17:38:11 +000036 n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1,
bsalomon@google.comc82b8892011-09-22 14:10:33 +000037 &major, &minor);
38 if (4 == n) {
39 return GR_GL_VER(major, minor);
40 }
41
42 n = sscanf(versionString, "OpenGL ES %d.%d", &major, &minor);
43 if (2 == n) {
44 return GR_GL_VER(major, minor);
twiz@google.com59a190b2011-03-14 21:23:01 +000045 }
twiz@google.com0f31ca72011-03-18 17:38:11 +000046
bsalomon@google.comc82b8892011-09-22 14:10:33 +000047 return 0;
twiz@google.com59a190b2011-03-14 21:23:01 +000048}
49
bsalomon@google.comedfe1aa2011-09-29 14:40:26 +000050GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString) {
51 if (NULL == versionString) {
52 GrAssert(!"NULL GLSL version string.");
53 return 0;
54 }
55
56 int major, minor;
57
58 int n = sscanf(versionString, "%d.%d", &major, &minor);
59 if (2 == n) {
60 return GR_GLSL_VER(major, minor);
61 }
62
63 n = sscanf(versionString, "OpenGL ES GLSL ES %d.%d", &major, &minor);
64 if (2 == n) {
65 return GR_GLSL_VER(major, minor);
66 }
67 return 0;
68}
69
bsalomon@google.comc82b8892011-09-22 14:10:33 +000070bool GrGLHasExtensionFromString(const char* ext, const char* extensionString) {
twiz@google.com59a190b2011-03-14 21:23:01 +000071 int extLength = strlen(ext);
72
73 while (true) {
74 int n = strcspn(extensionString, " ");
75 if (n == extLength && 0 == strncmp(ext, extensionString, n)) {
76 return true;
77 }
78 if (0 == extensionString[n]) {
79 return false;
80 }
81 extensionString += n+1;
82 }
83
84 return false;
85}
86
bsalomon@google.comc82b8892011-09-22 14:10:33 +000087bool GrGLHasExtension(const GrGLInterface* gl, const char* ext) {
bsalomon@google.comdca4aab2011-09-06 19:05:24 +000088 const GrGLubyte* glstr;
89 GR_GL_CALL_RET(gl, glstr, GetString(GR_GL_EXTENSIONS));
bsalomon@google.comc82b8892011-09-22 14:10:33 +000090 return GrGLHasExtensionFromString(ext, (const char*) glstr);
twiz@google.com59a190b2011-03-14 21:23:01 +000091}
92
bsalomon@google.comc82b8892011-09-22 14:10:33 +000093GrGLVersion GrGLGetVersion(const GrGLInterface* gl) {
bsalomon@google.comdca4aab2011-09-06 19:05:24 +000094 const GrGLubyte* v;
95 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VERSION));
bsalomon@google.comc82b8892011-09-22 14:10:33 +000096 return GrGLGetVersionFromString((const char*) v);
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +000097}
98
bsalomon@google.comedfe1aa2011-09-29 14:40:26 +000099GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface* gl) {
100 const GrGLubyte* v;
101 GR_GL_CALL_RET(gl, v, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
102 return GrGLGetGLSLVersionFromString((const char*) v);
103}
104
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000105GrGLInterface::GrGLInterface() {
106 fBindingsExported = (GrGLBinding)0;
107 fNPOTRenderTargetSupport = kProbe_GrGLCapability;
108 fMinRenderTargetHeight = kProbe_GrGLCapability;
109 fMinRenderTargetWidth = kProbe_GrGLCapability;
110
111 fActiveTexture = NULL;
112 fAttachShader = NULL;
bsalomon@google.comf97c1942011-10-19 21:35:26 +0000113 fBeginQuery = NULL;
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000114 fBindAttribLocation = NULL;
115 fBindBuffer = NULL;
bsalomon@google.combc5cf512011-09-21 16:21:07 +0000116 fBindFragDataLocation = NULL;
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000117 fBindTexture = NULL;
118 fBlendColor = NULL;
119 fBlendFunc = NULL;
120 fBufferData = NULL;
121 fBufferSubData = NULL;
122 fClear = NULL;
123 fClearColor = NULL;
124 fClearStencil = NULL;
125 fClientActiveTexture = NULL;
126 fColor4ub = NULL;
127 fColorMask = NULL;
128 fColorPointer = NULL;
129 fCompileShader = NULL;
130 fCompressedTexImage2D = NULL;
131 fCreateProgram = NULL;
132 fCreateShader = NULL;
133 fCullFace = NULL;
134 fDeleteBuffers = NULL;
135 fDeleteProgram = NULL;
bsalomon@google.comf97c1942011-10-19 21:35:26 +0000136 fDeleteQueries = NULL;
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000137 fDeleteShader = NULL;
138 fDeleteTextures = NULL;
139 fDepthMask = NULL;
140 fDisable = NULL;
141 fDisableClientState = NULL;
142 fDisableVertexAttribArray = NULL;
143 fDrawArrays = NULL;
144 fDrawBuffer = NULL;
145 fDrawBuffers = NULL;
146 fDrawElements = NULL;
bsalomon@google.comf97c1942011-10-19 21:35:26 +0000147 fEndQuery = NULL;
148 fFinish = NULL;
149 fFlush = NULL;
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000150 fEnable = NULL;
151 fEnableClientState = NULL;
152 fEnableVertexAttribArray = NULL;
153 fFrontFace = NULL;
154 fGenBuffers = NULL;
bsalomon@google.comf97c1942011-10-19 21:35:26 +0000155 fGenQueries = NULL;
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000156 fGenTextures = NULL;
157 fGetBufferParameteriv = NULL;
158 fGetError = NULL;
159 fGetIntegerv = NULL;
bsalomon@google.comf97c1942011-10-19 21:35:26 +0000160 fGetQueryiv = NULL;
161 fGetQueryObjecti64v = NULL;
162 fGetQueryObjectiv = NULL;
163 fGetQueryObjectui64v = NULL;
164 fGetQueryObjectuiv = NULL;
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000165 fGetProgramInfoLog = NULL;
166 fGetProgramiv = NULL;
167 fGetShaderInfoLog = NULL;
168 fGetShaderiv = NULL;
169 fGetString = NULL;
170 fGetTexLevelParameteriv = NULL;
171 fGetUniformLocation = NULL;
172 fLineWidth = NULL;
173 fLinkProgram = NULL;
174 fLoadMatrixf = NULL;
175 fMatrixMode = NULL;
176 fPixelStorei = NULL;
177 fPointSize = NULL;
bsalomon@google.comf97c1942011-10-19 21:35:26 +0000178 fQueryCounter = NULL;
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000179 fReadBuffer = NULL;
180 fReadPixels = NULL;
181 fScissor = NULL;
182 fShadeModel = NULL;
183 fShaderSource = NULL;
184 fStencilFunc = NULL;
185 fStencilFuncSeparate = NULL;
186 fStencilMask = NULL;
187 fStencilMaskSeparate = NULL;
188 fStencilOp = NULL;
189 fStencilOpSeparate = NULL;
190 fTexCoordPointer = NULL;
191 fTexEnvi = NULL;
192 fTexImage2D = NULL;
193 fTexParameteri = NULL;
194 fTexSubImage2D = NULL;
195 fUniform1f = NULL;
196 fUniform1i = NULL;
197 fUniform1fv = NULL;
198 fUniform1iv = NULL;
199 fUniform2f = NULL;
200 fUniform2i = NULL;
201 fUniform2fv = NULL;
202 fUniform2iv = NULL;
203 fUniform3f = NULL;
204 fUniform3i = NULL;
205 fUniform3fv = NULL;
206 fUniform3iv = NULL;
207 fUniform4f = NULL;
208 fUniform4i = NULL;
209 fUniform4fv = NULL;
210 fUniform4iv = NULL;
211 fUniformMatrix2fv = NULL;
212 fUniformMatrix3fv = NULL;
213 fUniformMatrix4fv = NULL;
214 fUseProgram = NULL;
215 fVertexAttrib4fv = NULL;
216 fVertexAttribPointer = NULL;
217 fVertexPointer = NULL;
218 fViewport = NULL;
219 fBindFramebuffer = NULL;
220 fBindRenderbuffer = NULL;
221 fCheckFramebufferStatus = NULL;
222 fDeleteFramebuffers = NULL;
223 fDeleteRenderbuffers = NULL;
224 fFramebufferRenderbuffer = NULL;
225 fFramebufferTexture2D = NULL;
226 fGenFramebuffers = NULL;
227 fGenRenderbuffers = NULL;
228 fGetFramebufferAttachmentParameteriv = NULL;
229 fGetRenderbufferParameteriv = NULL;
230 fRenderbufferStorage = NULL;
231 fRenderbufferStorageMultisample = NULL;
232 fBlitFramebuffer = NULL;
233 fResolveMultisampleFramebuffer = NULL;
234 fMapBuffer = NULL;
235 fUnmapBuffer = NULL;
236 fBindFragDataLocationIndexed = NULL;
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +0000237
238#if GR_GL_PER_GL_FUNC_CALLBACK
239 fCallback = GrGLDefaultInterfaceCallback;
240 fCallbackData = 0;
241#endif
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000242}
243
244
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000245bool GrGLInterface::validateShaderFunctions() const {
246 // required for GrGpuGLShaders
247 if (NULL == fAttachShader ||
248 NULL == fBindAttribLocation ||
249 NULL == fCompileShader ||
250 NULL == fCreateProgram ||
251 NULL == fCreateShader ||
252 NULL == fDeleteProgram ||
253 NULL == fDeleteShader ||
254 NULL == fDisableVertexAttribArray ||
255 NULL == fEnableVertexAttribArray ||
256 NULL == fGetProgramInfoLog ||
257 NULL == fGetProgramiv ||
258 NULL == fGetShaderInfoLog ||
259 NULL == fGetShaderiv ||
260 NULL == fGetUniformLocation ||
261 NULL == fLinkProgram ||
262 NULL == fShaderSource ||
263 NULL == fUniform1f ||
264 NULL == fUniform1i ||
265 NULL == fUniform1fv ||
266 NULL == fUniform1iv ||
267 NULL == fUniform2f ||
268 NULL == fUniform2i ||
269 NULL == fUniform2fv ||
270 NULL == fUniform2iv ||
271 NULL == fUniform3f ||
272 NULL == fUniform3i ||
273 NULL == fUniform3fv ||
274 NULL == fUniform3iv ||
275 NULL == fUniform4f ||
276 NULL == fUniform4i ||
277 NULL == fUniform4fv ||
278 NULL == fUniform4iv ||
279 NULL == fUniformMatrix2fv ||
280 NULL == fUniformMatrix3fv ||
281 NULL == fUniformMatrix4fv ||
282 NULL == fUseProgram ||
283 NULL == fVertexAttrib4fv ||
284 NULL == fVertexAttribPointer) {
285 return false;
286 }
287 return true;
288}
289
290bool GrGLInterface::validateFixedFunctions() const {
291 if (NULL == fClientActiveTexture ||
292 NULL == fColor4ub ||
293 NULL == fColorPointer ||
294 NULL == fDisableClientState ||
295 NULL == fEnableClientState ||
296 NULL == fLoadMatrixf ||
297 NULL == fMatrixMode ||
298 NULL == fPointSize ||
299 NULL == fShadeModel ||
300 NULL == fTexCoordPointer ||
bsalomon@google.com4b9b6a22011-05-04 15:01:16 +0000301 NULL == fTexEnvi ||
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000302 NULL == fVertexPointer) {
303 return false;
304 }
305 return true;
306}
307
308bool GrGLInterface::validate(GrEngine engine) const {
309
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000310 bool isDesktop = this->supportsDesktop();
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000311
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000312 bool isES = this->supportsES();
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000313
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000314 if (isDesktop == isES) {
315 // must have one, don't support both in same interface
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000316 return false;
317 }
318
319 // functions that are always required
320 if (NULL == fActiveTexture ||
321 NULL == fBindBuffer ||
322 NULL == fBindTexture ||
323 NULL == fBlendFunc ||
324 NULL == fBufferData ||
325 NULL == fBufferSubData ||
326 NULL == fClear ||
327 NULL == fClearColor ||
328 NULL == fClearStencil ||
329 NULL == fColorMask ||
330 NULL == fCullFace ||
331 NULL == fDeleteBuffers ||
332 NULL == fDeleteTextures ||
333 NULL == fDepthMask ||
334 NULL == fDisable ||
335 NULL == fDrawArrays ||
336 NULL == fDrawElements ||
337 NULL == fEnable ||
338 NULL == fFrontFace ||
339 NULL == fGenBuffers ||
340 NULL == fGenTextures ||
341 NULL == fGetBufferParameteriv ||
342 NULL == fGetError ||
343 NULL == fGetIntegerv ||
344 NULL == fGetString ||
345 NULL == fPixelStorei ||
346 NULL == fReadPixels ||
347 NULL == fScissor ||
348 NULL == fStencilFunc ||
349 NULL == fStencilMask ||
350 NULL == fStencilOp ||
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000351 NULL == fTexImage2D ||
352 NULL == fTexParameteri ||
353 NULL == fTexSubImage2D ||
354 NULL == fViewport ||
355 NULL == fBindFramebuffer ||
356 NULL == fBindRenderbuffer ||
357 NULL == fCheckFramebufferStatus ||
358 NULL == fDeleteFramebuffers ||
359 NULL == fDeleteRenderbuffers ||
bsalomon@google.com373a6632011-10-19 20:43:20 +0000360 NULL == fFinish ||
361 NULL == fFlush ||
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000362 NULL == fFramebufferRenderbuffer ||
363 NULL == fFramebufferTexture2D ||
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000364 NULL == fGetFramebufferAttachmentParameteriv ||
365 NULL == fGetRenderbufferParameteriv ||
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000366 NULL == fGenFramebuffers ||
367 NULL == fGenRenderbuffers ||
368 NULL == fRenderbufferStorage) {
369 return false;
370 }
371
372 switch (engine) {
373 case kOpenGL_Shaders_GrEngine:
374 if (kES1_GrGLBinding == fBindingsExported) {
375 return false;
376 }
377 if (!this->validateShaderFunctions()) {
378 return false;
379 }
380 break;
381 case kOpenGL_Fixed_GrEngine:
382 if (kES1_GrGLBinding == fBindingsExported) {
383 return false;
384 }
385 if (!this->validateFixedFunctions()) {
386 return false;
387 }
388 break;
389 default:
390 return false;
391 }
392
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000393 const char* ext;
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000394 GrGLVersion glVer = GrGLGetVersion(this);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000395 ext = (const char*)fGetString(GR_GL_EXTENSIONS);
396
397 // Now check that baseline ES/Desktop fns not covered above are present
398 // and that we have fn pointers for any advertised extensions that we will
399 // try to use.
400
401 // these functions are part of ES2, we assume they are available
402 // On the desktop we assume they are available if the extension
403 // is present or GL version is high enough.
404 if ((kES2_GrGLBinding & fBindingsExported)) {
405 if (NULL == fBlendColor ||
406 NULL == fStencilFuncSeparate ||
407 NULL == fStencilMaskSeparate ||
408 NULL == fStencilOpSeparate) {
409 return false;
410 }
411 } else if (kDesktop_GrGLBinding == fBindingsExported) {
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000412 if (glVer >= GR_GL_VER(2,0)) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000413 if (NULL == fStencilFuncSeparate ||
414 NULL == fStencilMaskSeparate ||
415 NULL == fStencilOpSeparate) {
416 return false;
417 }
418 }
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000419 if (glVer >= GR_GL_VER(3,0) && NULL == fBindFragDataLocation) {
bsalomon@google.combc5cf512011-09-21 16:21:07 +0000420 return false;
421 }
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000422 if (glVer >= GR_GL_VER(2,0) ||
423 GrGLHasExtensionFromString("GL_ARB_draw_buffers", ext)) {
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000424 if (NULL == fDrawBuffers) {
425 return false;
426 }
427 }
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000428 if (glVer >= GR_GL_VER(1,4) ||
429 GrGLHasExtensionFromString("GL_EXT_blend_color", ext)) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000430 if (NULL == fBlendColor) {
431 return false;
432 }
433 }
bsalomon@google.com373a6632011-10-19 20:43:20 +0000434 if (glVer >= GR_GL_VER(1,5) ||
435 GrGLHasExtensionFromString("GL_ARB_occlusion_query", ext)) {
436 if (NULL == fGenQueries ||
437 NULL == fDeleteQueries ||
438 NULL == fBeginQuery ||
439 NULL == fEndQuery ||
440 NULL == fGetQueryiv ||
441 NULL == fGetQueryObjectiv ||
442 NULL == fGetQueryObjectuiv) {
443 return false;
444 }
445 }
446 if (glVer >= GR_GL_VER(3,3) ||
447 GrGLHasExtensionFromString("GL_ARB_timer_query", ext) ||
448 GrGLHasExtensionFromString("GL_EXT_timer_query", ext)) {
449 if (NULL == fGetQueryObjecti64v ||
450 NULL == fGetQueryObjectui64v) {
451 return false;
452 }
453 }
454 if (glVer >= GR_GL_VER(3,3) ||
455 GrGLHasExtensionFromString("GL_ARB_timer_query", ext)) {
456 if (NULL == fQueryCounter) {
457 return false;
458 }
459 }
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000460 }
461
462 // optional function on desktop before 1.3
463 if (kDesktop_GrGLBinding != fBindingsExported ||
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000464 (glVer >= GR_GL_VER(1,3) ||
465 GrGLHasExtensionFromString("GL_ARB_texture_compression", ext))) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000466 if (NULL == fCompressedTexImage2D) {
467 return false;
468 }
469 }
470
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000471 // part of desktop GL, but not ES
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000472 if (kDesktop_GrGLBinding == fBindingsExported &&
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000473 (NULL == fLineWidth ||
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000474 NULL == fGetTexLevelParameteriv ||
bsalomon@google.comc49d66b2011-08-03 14:22:30 +0000475 NULL == fDrawBuffer ||
476 NULL == fReadBuffer)) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000477 return false;
478 }
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000479
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000480 // FBO MSAA
481 if (kDesktop_GrGLBinding == fBindingsExported) {
482 // GL 3.0 and the ARB extension have multisample + blit
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000483 if (glVer >= GR_GL_VER(3,0) || GrGLHasExtensionFromString("GL_ARB_framebuffer_object", ext)) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000484 if (NULL == fRenderbufferStorageMultisample ||
485 NULL == fBlitFramebuffer) {
486 return false;
487 }
488 } else {
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000489 if (GrGLHasExtensionFromString("GL_EXT_framebuffer_blit", ext) &&
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000490 NULL == fBlitFramebuffer) {
491 return false;
492 }
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000493 if (GrGLHasExtensionFromString("GL_EXT_framebuffer_multisample", ext) &&
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000494 NULL == fRenderbufferStorageMultisample) {
495 return false;
496 }
497 }
498 } else {
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000499 if (GrGLHasExtensionFromString("GL_CHROMIUM_framebuffer_multisample", ext)) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000500 if (NULL == fRenderbufferStorageMultisample ||
501 NULL == fBlitFramebuffer) {
502 return false;
503 }
504 }
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000505 if (GrGLHasExtensionFromString("GL_APPLE_framebuffer_multisample", ext)) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000506 if (NULL == fRenderbufferStorageMultisample ||
507 NULL == fResolveMultisampleFramebuffer) {
508 return false;
509 }
510 }
511 }
512
513 // On ES buffer mapping is an extension. On Desktop
514 // buffer mapping was part of original VBO extension
515 // which we require.
516 if (kDesktop_GrGLBinding == fBindingsExported ||
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000517 GrGLHasExtensionFromString("GL_OES_mapbuffer", ext)) {
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000518 if (NULL == fMapBuffer ||
519 NULL == fUnmapBuffer) {
520 return false;
521 }
522 }
523
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000524 // Dual source blending
525 if (kDesktop_GrGLBinding == fBindingsExported &&
bsalomon@google.comc82b8892011-09-22 14:10:33 +0000526 (glVer >= GR_GL_VER(3,3) ||
527 GrGLHasExtensionFromString("GL_ARB_blend_func_extended", ext))) {
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000528 if (NULL == fBindFragDataLocationIndexed) {
529 return false;
530 }
531 }
532
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000533 return true;
534}
535