1 
2 /*
3  * Copyright 2014 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.
7  */
8 
9 
10 #include "GrGLAssembleInterface.h"
11 #include "GrGLUtil.h"
12 
13 #define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F)
14 #define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F #S)
15 #define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl" #F)
16 
GrGLAssembleInterface(void * ctx,GrGLGetProc get)17 const GrGLInterface* GrGLAssembleInterface(void* ctx, GrGLGetProc get) {
18     GET_PROC_LOCAL(GetString);
19     if (NULL == GetString) {
20         return NULL;
21     }
22 
23     const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION));
24     if (NULL == verStr) {
25         return NULL;
26     }
27 
28     GrGLStandard standard = GrGLGetStandardInUseFromString(verStr);
29 
30     if (kGLES_GrGLStandard == standard) {
31         return GrGLAssembleGLESInterface(ctx, get);
32     } else if (kGL_GrGLStandard == standard) {
33         return GrGLAssembleGLInterface(ctx, get);
34     }
35     return NULL;
36 }
37 
GrGLAssembleGLInterface(void * ctx,GrGLGetProc get)38 const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
39     GET_PROC_LOCAL(GetString);
40     GET_PROC_LOCAL(GetStringi);
41     GET_PROC_LOCAL(GetIntegerv);
42 
43     // GetStringi may be NULL depending on the GL version.
44     if (NULL == GetString || NULL == GetIntegerv) {
45         return NULL;
46     }
47 
48     const char* versionString = (const char*) GetString(GR_GL_VERSION);
49     GrGLVersion glVer = GrGLGetVersionFromString(versionString);
50 
51     if (glVer < GR_GL_VER(1,5) || GR_GL_INVALID_VER == glVer) {
52         // We must have array and element_array buffer objects.
53         return NULL;
54     }
55 
56     GrGLExtensions extensions;
57     if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv)) {
58         return NULL;
59     }
60 
61     GrGLInterface* interface = SkNEW(GrGLInterface());
62     GrGLInterface::Functions* functions = &interface->fFunctions;
63 
64     GET_PROC(ActiveTexture);
65     GET_PROC(AttachShader);
66     GET_PROC(BindAttribLocation);
67     GET_PROC(BindBuffer);
68     if (glVer >= GR_GL_VER(3,0)) {
69         GET_PROC(BindFragDataLocation);
70     }
71     GET_PROC(BeginQuery);
72     GET_PROC(BindTexture);
73 
74     if (extensions.has("GL_KHR_blend_equation_advanced")) {
75         GET_PROC_SUFFIX(BlendBarrier, KHR);
76     } else if (extensions.has("GL_NV_blend_equation_advanced")) {
77         GET_PROC_SUFFIX(BlendBarrier, NV);
78     }
79 
80     if (glVer >= GR_GL_VER(1,4) ||
81         extensions.has("GL_ARB_imaging")) {
82         GET_PROC(BlendColor);
83     } else if (extensions.has("GL_EXT_blend_color")) {
84         GET_PROC_SUFFIX(BlendColor, EXT);
85     }
86 
87     if (glVer >= GR_GL_VER(1,4) ||
88         extensions.has("GL_ARB_imaging")) {
89         GET_PROC(BlendEquation);
90     } else if (extensions.has("GL_EXT_blend_subtract")) {
91         GET_PROC_SUFFIX(BlendEquation, EXT);
92     }
93 
94     GET_PROC(BlendFunc);
95     GET_PROC(BufferData);
96     GET_PROC(BufferSubData);
97     GET_PROC(Clear);
98     GET_PROC(ClearColor);
99     GET_PROC(ClearStencil);
100     GET_PROC(ColorMask);
101     GET_PROC(CompileShader);
102     GET_PROC(CompressedTexImage2D);
103     GET_PROC(CompressedTexSubImage2D);
104     GET_PROC(CopyTexSubImage2D);
105     GET_PROC(CreateProgram);
106     GET_PROC(CreateShader);
107     GET_PROC(CullFace);
108     GET_PROC(DeleteBuffers);
109     GET_PROC(DeleteProgram);
110     GET_PROC(DeleteQueries);
111     GET_PROC(DeleteShader);
112     GET_PROC(DeleteTextures);
113     GET_PROC(DepthMask);
114     GET_PROC(Disable);
115     GET_PROC(DisableVertexAttribArray);
116     GET_PROC(DrawArrays);
117     GET_PROC(DrawBuffer);
118     GET_PROC(DrawBuffers);
119     GET_PROC(DrawElements);
120     GET_PROC(Enable);
121     GET_PROC(EnableVertexAttribArray);
122     GET_PROC(EndQuery);
123     GET_PROC(Finish);
124     GET_PROC(Flush);
125     GET_PROC(FrontFace);
126     GET_PROC(GenBuffers);
127     GET_PROC(GenerateMipmap);
128     GET_PROC(GetBufferParameteriv);
129     GET_PROC(GetError);
130     GET_PROC(GetIntegerv);
131     GET_PROC(GetQueryObjectiv);
132     GET_PROC(GetQueryObjectuiv);
133     if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) {
134         GET_PROC(GetQueryObjecti64v);
135         GET_PROC(GetQueryObjectui64v);
136         GET_PROC(QueryCounter);
137     } else if (extensions.has("GL_EXT_timer_query")) {
138         GET_PROC_SUFFIX(GetQueryObjecti64v, EXT);
139         GET_PROC_SUFFIX(GetQueryObjectui64v, EXT);
140     }
141     GET_PROC(GetQueryiv);
142     GET_PROC(GetProgramInfoLog);
143     GET_PROC(GetProgramiv);
144     GET_PROC(GetShaderInfoLog);
145     GET_PROC(GetShaderiv);
146     GET_PROC(GetString);
147     GET_PROC(GetStringi);
148     GET_PROC(GetShaderPrecisionFormat);
149     GET_PROC(GetTexLevelParameteriv);
150     GET_PROC(GenQueries);
151     GET_PROC(GenTextures);
152     GET_PROC(GetUniformLocation);
153     GET_PROC(LineWidth);
154     GET_PROC(LinkProgram);
155     GET_PROC(MapBuffer);
156     if (extensions.has("GL_EXT_direct_state_access")) {
157         GET_PROC_SUFFIX(MatrixLoadf, EXT);
158         GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
159     }
160     GET_PROC(PixelStorei);
161     GET_PROC(ReadBuffer);
162     GET_PROC(ReadPixels);
163     GET_PROC(Scissor);
164     GET_PROC(ShaderSource);
165     GET_PROC(StencilFunc);
166     GET_PROC(StencilFuncSeparate);
167     GET_PROC(StencilMask);
168     GET_PROC(StencilMaskSeparate);
169     GET_PROC(StencilOp);
170     GET_PROC(StencilOpSeparate);
171     GET_PROC(TexImage2D);
172     GET_PROC(TexParameteri);
173     GET_PROC(TexParameteriv);
174     if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) {
175         GET_PROC(TexStorage2D);
176     } else if (extensions.has("GL_EXT_texture_storage")) {
177         GET_PROC_SUFFIX(TexStorage2D, EXT);
178     }
179     GET_PROC(TexSubImage2D);
180     if (glVer >= GR_GL_VER(4,5) || extensions.has("GL_ARB_texture_barrier")) {
181         GET_PROC(TextureBarrier);
182     } else if (extensions.has("GL_NV_texture_barrier")) {
183         GET_PROC_SUFFIX(TextureBarrier, NV);
184     }
185     GET_PROC(Uniform1f);
186     GET_PROC(Uniform1i);
187     GET_PROC(Uniform1fv);
188     GET_PROC(Uniform1iv);
189     GET_PROC(Uniform2f);
190     GET_PROC(Uniform2i);
191     GET_PROC(Uniform2fv);
192     GET_PROC(Uniform2iv);
193     GET_PROC(Uniform3f);
194     GET_PROC(Uniform3i);
195     GET_PROC(Uniform3fv);
196     GET_PROC(Uniform3iv);
197     GET_PROC(Uniform4f);
198     GET_PROC(Uniform4i);
199     GET_PROC(Uniform4fv);
200     GET_PROC(Uniform4iv);
201     GET_PROC(UniformMatrix2fv);
202     GET_PROC(UniformMatrix3fv);
203     GET_PROC(UniformMatrix4fv);
204     GET_PROC(UnmapBuffer);
205     GET_PROC(UseProgram);
206     GET_PROC(VertexAttrib1f);
207     GET_PROC(VertexAttrib2fv);
208     GET_PROC(VertexAttrib3fv);
209     GET_PROC(VertexAttrib4fv);
210     GET_PROC(VertexAttribPointer);
211     GET_PROC(Viewport);
212     GET_PROC(BindFragDataLocationIndexed);
213 
214     if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) {
215         // no ARB suffix for GL_ARB_vertex_array_object
216         GET_PROC(BindVertexArray);
217         GET_PROC(GenVertexArrays);
218         GET_PROC(DeleteVertexArrays);
219     } else if (extensions.has("GL_APPLE_vertex_array_object")) {
220         GET_PROC_SUFFIX(BindVertexArray, APPLE);
221         GET_PROC_SUFFIX(GenVertexArrays, APPLE);
222         GET_PROC_SUFFIX(DeleteVertexArrays, APPLE);
223     }
224 
225     if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_map_buffer_range")) {
226         GET_PROC(MapBufferRange);
227         GET_PROC(FlushMappedBufferRange);
228     }
229 
230     // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
231     // GL_ARB_framebuffer_object doesn't use ARB suffix.)
232     if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) {
233         GET_PROC(GenFramebuffers);
234         GET_PROC(GetFramebufferAttachmentParameteriv);
235         GET_PROC(GetRenderbufferParameteriv);
236         GET_PROC(BindFramebuffer);
237         GET_PROC(FramebufferTexture2D);
238         GET_PROC(CheckFramebufferStatus);
239         GET_PROC(DeleteFramebuffers);
240         GET_PROC(RenderbufferStorage);
241         GET_PROC(GenRenderbuffers);
242         GET_PROC(DeleteRenderbuffers);
243         GET_PROC(FramebufferRenderbuffer);
244         GET_PROC(BindRenderbuffer);
245         GET_PROC(RenderbufferStorageMultisample);
246         GET_PROC(BlitFramebuffer);
247     } else if (extensions.has("GL_EXT_framebuffer_object")) {
248         GET_PROC_SUFFIX(GenFramebuffers, EXT);
249         GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
250         GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
251         GET_PROC_SUFFIX(BindFramebuffer, EXT);
252         GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
253         GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
254         GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
255         GET_PROC_SUFFIX(RenderbufferStorage, EXT);
256         GET_PROC_SUFFIX(GenRenderbuffers, EXT);
257         GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
258         GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
259         GET_PROC_SUFFIX(BindRenderbuffer, EXT);
260         if (extensions.has("GL_EXT_framebuffer_multisample")) {
261             GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
262         }
263         if (extensions.has("GL_EXT_framebuffer_blit")) {
264             GET_PROC_SUFFIX(BlitFramebuffer, EXT);
265         }
266     } else {
267         // we must have FBOs
268         delete interface;
269         return NULL;
270     }
271 
272     if (extensions.has("GL_NV_path_rendering")) {
273         GET_PROC_SUFFIX(PathCommands, NV);
274         GET_PROC_SUFFIX(PathCoords, NV);
275         GET_PROC_SUFFIX(PathParameteri, NV);
276         GET_PROC_SUFFIX(PathParameterf, NV);
277         GET_PROC_SUFFIX(GenPaths, NV);
278         GET_PROC_SUFFIX(DeletePaths, NV);
279         GET_PROC_SUFFIX(IsPath, NV);
280         GET_PROC_SUFFIX(PathStencilFunc, NV);
281         GET_PROC_SUFFIX(StencilFillPath, NV);
282         GET_PROC_SUFFIX(StencilStrokePath, NV);
283         GET_PROC_SUFFIX(StencilFillPathInstanced, NV);
284         GET_PROC_SUFFIX(StencilStrokePathInstanced, NV);
285         GET_PROC_SUFFIX(PathTexGen, NV);
286         GET_PROC_SUFFIX(CoverFillPath, NV);
287         GET_PROC_SUFFIX(CoverStrokePath, NV);
288         GET_PROC_SUFFIX(CoverFillPathInstanced, NV);
289         GET_PROC_SUFFIX(CoverStrokePathInstanced, NV);
290         // NV_path_rendering v1.2 (These methods may not be present)
291         GET_PROC_SUFFIX(StencilThenCoverFillPath, NV);
292         GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV);
293         GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV);
294         GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV);
295         // NV_path_rendering v1.3 (These methods may not be present)
296         GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV);
297         GET_PROC_SUFFIX(PathMemoryGlyphIndexArray, NV);
298     }
299 
300     if (extensions.has("GL_NV_framebuffer_mixed_samples")) {
301         GET_PROC_SUFFIX(CoverageModulation, NV);
302     }
303 
304     if (extensions.has("GL_EXT_debug_marker")) {
305         GET_PROC_SUFFIX(InsertEventMarker, EXT);
306         GET_PROC_SUFFIX(PushGroupMarker, EXT);
307         GET_PROC_SUFFIX(PopGroupMarker, EXT);
308     }
309 
310     if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) {
311         GET_PROC(InvalidateBufferData);
312         GET_PROC(InvalidateBufferSubData);
313         GET_PROC(InvalidateFramebuffer);
314         GET_PROC(InvalidateSubFramebuffer);
315         GET_PROC(InvalidateTexImage);
316         GET_PROC(InvalidateTexSubImage);
317     }
318 
319     if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_program_interface_query")) {
320         GET_PROC(GetProgramResourceLocation);
321     }
322 
323     interface->fStandard = kGL_GrGLStandard;
324     interface->fExtensions.swap(&extensions);
325 
326     return interface;
327 }
328 
GrGLAssembleGLESInterface(void * ctx,GrGLGetProc get)329 const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
330     GET_PROC_LOCAL(GetString);
331     if (NULL == GetString) {
332         return NULL;
333     }
334 
335     const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION));
336     GrGLVersion version = GrGLGetVersionFromString(verStr);
337 
338     if (version < GR_GL_VER(2,0)) {
339         return NULL;
340     }
341 
342     GET_PROC_LOCAL(GetIntegerv);
343     GET_PROC_LOCAL(GetStringi);
344     GrGLExtensions extensions;
345     if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv)) {
346         return NULL;
347     }
348 
349     GrGLInterface* interface = SkNEW(GrGLInterface);
350     GrGLInterface::Functions* functions = &interface->fFunctions;
351 
352     GET_PROC(ActiveTexture);
353     GET_PROC(AttachShader);
354     GET_PROC(BindAttribLocation);
355     GET_PROC(BindBuffer);
356     GET_PROC(BindTexture);
357     GET_PROC_SUFFIX(BindVertexArray, OES);
358 
359     if (extensions.has("GL_KHR_blend_equation_advanced")) {
360         GET_PROC_SUFFIX(BlendBarrier, KHR);
361     } else if (extensions.has("GL_NV_blend_equation_advanced")) {
362         GET_PROC_SUFFIX(BlendBarrier, NV);
363     }
364 
365     GET_PROC(BlendColor);
366     GET_PROC(BlendEquation);
367     GET_PROC(BlendFunc);
368     GET_PROC(BufferData);
369     GET_PROC(BufferSubData);
370     GET_PROC(Clear);
371     GET_PROC(ClearColor);
372     GET_PROC(ClearStencil);
373     GET_PROC(ColorMask);
374     GET_PROC(CompileShader);
375     GET_PROC(CompressedTexImage2D);
376     GET_PROC(CompressedTexSubImage2D);
377     GET_PROC(CopyTexSubImage2D);
378     GET_PROC(CreateProgram);
379     GET_PROC(CreateShader);
380     GET_PROC(CullFace);
381     GET_PROC(DeleteBuffers);
382     GET_PROC(DeleteProgram);
383     GET_PROC(DeleteShader);
384     GET_PROC(DeleteTextures);
385     GET_PROC_SUFFIX(DeleteVertexArrays, OES);
386     GET_PROC(DepthMask);
387     GET_PROC(Disable);
388     GET_PROC(DisableVertexAttribArray);
389     GET_PROC(DrawArrays);
390     GET_PROC(DrawElements);
391     GET_PROC(Enable);
392     GET_PROC(EnableVertexAttribArray);
393     GET_PROC(Finish);
394     GET_PROC(Flush);
395     GET_PROC(FrontFace);
396     GET_PROC(GenBuffers);
397     GET_PROC(GenerateMipmap);
398     GET_PROC(GenTextures);
399     GET_PROC_SUFFIX(GenVertexArrays, OES);
400     GET_PROC(GetBufferParameteriv);
401     GET_PROC(GetError);
402     GET_PROC(GetIntegerv);
403     GET_PROC(GetProgramInfoLog);
404     GET_PROC(GetProgramiv);
405     GET_PROC(GetShaderInfoLog);
406     GET_PROC(GetShaderPrecisionFormat);
407     GET_PROC(GetShaderiv);
408     GET_PROC(GetString);
409     GET_PROC(GetStringi);
410     GET_PROC(GetUniformLocation);
411     GET_PROC(LineWidth);
412     GET_PROC(LinkProgram);
413     GET_PROC(PixelStorei);
414     GET_PROC(ReadPixels);
415     GET_PROC(Scissor);
416     GET_PROC(ShaderSource);
417     GET_PROC(StencilFunc);
418     GET_PROC(StencilFuncSeparate);
419     GET_PROC(StencilMask);
420     GET_PROC(StencilMaskSeparate);
421     GET_PROC(StencilOp);
422     GET_PROC(StencilOpSeparate);
423     GET_PROC(TexImage2D);
424     GET_PROC(TexParameteri);
425     GET_PROC(TexParameteriv);
426     GET_PROC(TexSubImage2D);
427 
428     if (version >= GR_GL_VER(3,0)) {
429         GET_PROC(TexStorage2D);
430     } else {
431         GET_PROC_SUFFIX(TexStorage2D, EXT);
432     }
433 
434     if (extensions.has("GL_NV_texture_barrier")) {
435         GET_PROC_SUFFIX(TextureBarrier, NV);
436     }
437 
438     GET_PROC_SUFFIX(DiscardFramebuffer, EXT);
439     GET_PROC(Uniform1f);
440     GET_PROC(Uniform1i);
441     GET_PROC(Uniform1fv);
442     GET_PROC(Uniform1iv);
443     GET_PROC(Uniform2f);
444     GET_PROC(Uniform2i);
445     GET_PROC(Uniform2fv);
446     GET_PROC(Uniform2iv);
447     GET_PROC(Uniform3f);
448     GET_PROC(Uniform3i);
449     GET_PROC(Uniform3fv);
450     GET_PROC(Uniform3iv);
451     GET_PROC(Uniform4f);
452     GET_PROC(Uniform4i);
453     GET_PROC(Uniform4fv);
454     GET_PROC(Uniform4iv);
455     GET_PROC(UniformMatrix2fv);
456     GET_PROC(UniformMatrix3fv);
457     GET_PROC(UniformMatrix4fv);
458     GET_PROC(UseProgram);
459     GET_PROC(VertexAttrib1f);
460     GET_PROC(VertexAttrib2fv);
461     GET_PROC(VertexAttrib3fv);
462     GET_PROC(VertexAttrib4fv);
463     GET_PROC(VertexAttribPointer);
464     GET_PROC(Viewport);
465     GET_PROC(BindFramebuffer);
466     GET_PROC(BindRenderbuffer);
467     GET_PROC(CheckFramebufferStatus);
468     GET_PROC(DeleteFramebuffers);
469     GET_PROC(DeleteRenderbuffers);
470     GET_PROC(FramebufferRenderbuffer);
471     GET_PROC(FramebufferTexture2D);
472 
473     if (version >= GR_GL_VER(3,0)) {
474         GET_PROC(RenderbufferStorageMultisample);
475         GET_PROC(BlitFramebuffer);
476     }
477 
478     if (extensions.has("GL_EXT_multisampled_render_to_texture")) {
479         GET_PROC_SUFFIX(FramebufferTexture2DMultisample, EXT);
480         functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleEXT");
481     } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) {
482         GET_PROC_SUFFIX(FramebufferTexture2DMultisample, IMG);
483         functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleIMG");
484     } else if (extensions.has("GL_APPLE_framebuffer_multisample")) {
485         functions->fRenderbufferStorageMultisampleES2APPLE = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleAPPLE");
486         GET_PROC_SUFFIX(ResolveMultisampleFramebuffer, APPLE);
487     }
488 
489     GET_PROC(GenFramebuffers);
490     GET_PROC(GenRenderbuffers);
491     GET_PROC(GetFramebufferAttachmentParameteriv);
492     GET_PROC(GetRenderbufferParameteriv);
493     GET_PROC(RenderbufferStorage);
494 
495     GET_PROC_SUFFIX(MapBuffer, OES);
496     GET_PROC_SUFFIX(UnmapBuffer, OES);
497 
498     if (version >= GR_GL_VER(3,0)) {
499         GET_PROC(MapBufferRange);
500         GET_PROC(FlushMappedBufferRange);
501     } else if (extensions.has("GL_EXT_map_buffer_range")) {
502         GET_PROC_SUFFIX(MapBufferRange, EXT);
503         GET_PROC_SUFFIX(FlushMappedBufferRange, EXT);
504     }
505 
506     if (extensions.has("GL_EXT_debug_marker")) {
507         GET_PROC(InsertEventMarker);
508         GET_PROC(PushGroupMarker);
509         GET_PROC(PopGroupMarker);
510         // The below check is here because a device has been found that has the extension string but
511         // returns NULL from the eglGetProcAddress for the functions
512         if (NULL == functions->fInsertEventMarker ||
513             NULL == functions->fPushGroupMarker ||
514             NULL == functions->fPopGroupMarker) {
515             extensions.remove("GL_EXT_debug_marker");
516         }
517     }
518 
519     GET_PROC(InvalidateFramebuffer);
520     GET_PROC(InvalidateSubFramebuffer);
521     GET_PROC(InvalidateBufferData);
522     GET_PROC(InvalidateBufferSubData);
523     GET_PROC(InvalidateTexImage);
524     GET_PROC(InvalidateTexSubImage);
525 
526     if (version >= GR_GL_VER(3,1)) {
527         GET_PROC(GetProgramResourceLocation);
528     }
529 
530     if (extensions.has("GL_NV_path_rendering")) {
531         GET_PROC_SUFFIX(MatrixLoadf, EXT);
532         GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
533         GET_PROC_SUFFIX(PathCommands, NV);
534         GET_PROC_SUFFIX(PathCoords, NV);
535         GET_PROC_SUFFIX(PathParameteri, NV);
536         GET_PROC_SUFFIX(PathParameterf, NV);
537         GET_PROC_SUFFIX(GenPaths, NV);
538         GET_PROC_SUFFIX(DeletePaths, NV);
539         GET_PROC_SUFFIX(IsPath, NV);
540         GET_PROC_SUFFIX(PathStencilFunc, NV);
541         GET_PROC_SUFFIX(StencilFillPath, NV);
542         GET_PROC_SUFFIX(StencilStrokePath, NV);
543         GET_PROC_SUFFIX(StencilFillPathInstanced, NV);
544         GET_PROC_SUFFIX(StencilStrokePathInstanced, NV);
545         GET_PROC_SUFFIX(CoverFillPath, NV);
546         GET_PROC_SUFFIX(CoverStrokePath, NV);
547         GET_PROC_SUFFIX(CoverFillPathInstanced, NV);
548         GET_PROC_SUFFIX(CoverStrokePathInstanced, NV);
549         GET_PROC_SUFFIX(StencilThenCoverFillPath, NV);
550         GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV);
551         GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV);
552         GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV);
553         GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV);
554         GET_PROC_SUFFIX(PathMemoryGlyphIndexArray, NV);
555     }
556 
557     if (extensions.has("GL_NV_framebuffer_mixed_samples")) {
558         GET_PROC_SUFFIX(CoverageModulation, NV);
559     }
560 
561     interface->fStandard = kGLES_GrGLStandard;
562     interface->fExtensions.swap(&extensions);
563 
564     return interface;
565 }
566