• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  *
7  * THIS FILE IS AUTOGENERATED
8  * Make edits to tools/gpu/gl/interface/templates.go or they will
9  * be overwritten.
10  */
11 
12 #include "include/gpu/gl/GrGLAssembleHelpers.h"
13 #include "include/gpu/gl/GrGLAssembleInterface.h"
14 #include "src/gpu/gl/GrGLUtil.h"
15 
16 #define GET_PROC(F) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F)
17 #define GET_PROC_SUFFIX(F, S) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F #S)
18 #define GET_PROC_LOCAL(F) GrGL##F##Fn* F = (GrGL##F##Fn*)get(ctx, "gl" #F)
19 
20 #define GET_EGL_PROC_SUFFIX(F, S) functions->fEGL##F = (GrEGL##F##Fn*)get(ctx, "egl" #F #S)
21 
22 #if SK_DISABLE_GL_INTERFACE
GrGLMakeAssembledGLInterface(void * ctx,GrGLGetProc get)23 sk_sp<const GrGLInterface> GrGLMakeAssembledGLInterface(void *ctx, GrGLGetProc get) {
24     return nullptr;
25 }
26 #else
GrGLMakeAssembledGLInterface(void * ctx,GrGLGetProc get)27 sk_sp<const GrGLInterface> GrGLMakeAssembledGLInterface(void *ctx, GrGLGetProc get) {
28     GET_PROC_LOCAL(GetString);
29     GET_PROC_LOCAL(GetStringi);
30     GET_PROC_LOCAL(GetIntegerv);
31 
32     // GetStringi may be nullptr depending on the GL version.
33     if (nullptr == GetString || nullptr == GetIntegerv) {
34         return nullptr;
35     }
36 
37     const char* versionString = (const char*) GetString(GR_GL_VERSION);
38     GrGLVersion glVer = GrGLGetVersionFromString(versionString);
39 
40     if (glVer < GR_GL_VER(2,0) || GR_GL_INVALID_VER == glVer) {
41         // This is our minimum for non-ES GL.
42         return nullptr;
43     }
44 
45     GrEGLQueryStringFn* queryString;
46     GrEGLDisplay display;
47     GrGetEGLQueryAndDisplay(&queryString, &display, ctx, get);
48     GrGLExtensions extensions;
49     if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString,
50                          display)) {
51         return nullptr;
52     }
53 
54     sk_sp<GrGLInterface> interface(new GrGLInterface());
55     GrGLInterface::Functions* functions = &interface->fFunctions;
56 
57     // Autogenerated content follows
58     GET_PROC(ActiveTexture);
59     GET_PROC(AttachShader);
60     GET_PROC(BindAttribLocation);
61     GET_PROC(BindBuffer);
62     GET_PROC(BindTexture);
63     GET_PROC(BlendColor);
64     GET_PROC(BlendEquation);
65     GET_PROC(BlendFunc);
66     GET_PROC(BufferData);
67     GET_PROC(BufferSubData);
68     GET_PROC(Clear);
69     GET_PROC(ClearColor);
70     GET_PROC(ClearStencil);
71     GET_PROC(ColorMask);
72     GET_PROC(CompileShader);
73     GET_PROC(CompressedTexImage2D);
74     GET_PROC(CompressedTexSubImage2D);
75     GET_PROC(CopyTexSubImage2D);
76     GET_PROC(CreateProgram);
77     GET_PROC(CreateShader);
78     GET_PROC(CullFace);
79     GET_PROC(DeleteBuffers);
80     GET_PROC(DeleteProgram);
81     GET_PROC(DeleteShader);
82     GET_PROC(DeleteTextures);
83     GET_PROC(DepthMask);
84     GET_PROC(Disable);
85     GET_PROC(DisableVertexAttribArray);
86     GET_PROC(DrawArrays);
87     GET_PROC(DrawElements);
88     GET_PROC(Enable);
89     GET_PROC(EnableVertexAttribArray);
90     GET_PROC(Finish);
91     GET_PROC(Flush);
92     GET_PROC(FrontFace);
93     GET_PROC(GenBuffers);
94     GET_PROC(GenTextures);
95     GET_PROC(GetBufferParameteriv);
96     GET_PROC(GetError);
97     GET_PROC(GetIntegerv);
98     GET_PROC(GetProgramInfoLog);
99     GET_PROC(GetProgramiv);
100     GET_PROC(GetShaderInfoLog);
101     GET_PROC(GetShaderiv);
102     GET_PROC(GetString);
103     GET_PROC(GetUniformLocation);
104     GET_PROC(IsTexture);
105     GET_PROC(LineWidth);
106     GET_PROC(LinkProgram);
107     GET_PROC(PixelStorei);
108     GET_PROC(ReadPixels);
109     GET_PROC(Scissor);
110     GET_PROC(ShaderSource);
111     GET_PROC(StencilFunc);
112     GET_PROC(StencilFuncSeparate);
113     GET_PROC(StencilMask);
114     GET_PROC(StencilMaskSeparate);
115     GET_PROC(StencilOp);
116     GET_PROC(StencilOpSeparate);
117     GET_PROC(TexImage2D);
118     GET_PROC(TexParameterf);
119     GET_PROC(TexParameterfv);
120     GET_PROC(TexParameteri);
121     GET_PROC(TexParameteriv);
122     GET_PROC(TexSubImage2D);
123     GET_PROC(Uniform1f);
124     GET_PROC(Uniform1fv);
125     GET_PROC(Uniform1i);
126     GET_PROC(Uniform1iv);
127     GET_PROC(Uniform2f);
128     GET_PROC(Uniform2fv);
129     GET_PROC(Uniform2i);
130     GET_PROC(Uniform2iv);
131     GET_PROC(Uniform3f);
132     GET_PROC(Uniform3fv);
133     GET_PROC(Uniform3i);
134     GET_PROC(Uniform3iv);
135     GET_PROC(Uniform4f);
136     GET_PROC(Uniform4fv);
137     GET_PROC(Uniform4i);
138     GET_PROC(Uniform4iv);
139     GET_PROC(UniformMatrix2fv);
140     GET_PROC(UniformMatrix3fv);
141     GET_PROC(UniformMatrix4fv);
142     GET_PROC(UseProgram);
143     GET_PROC(VertexAttrib1f);
144     GET_PROC(VertexAttrib2fv);
145     GET_PROC(VertexAttrib3fv);
146     GET_PROC(VertexAttrib4fv);
147     GET_PROC(VertexAttribPointer);
148     GET_PROC(Viewport);
149 
150     GET_PROC(DrawBuffer);
151     GET_PROC(PolygonMode);
152 
153     if (glVer >= GR_GL_VER(3,0)) {
154         GET_PROC(GetStringi);
155     }
156 
157     GET_PROC(BindVertexArray);
158     GET_PROC(DeleteVertexArrays);
159     GET_PROC(GenVertexArrays);
160 
161     if (glVer >= GR_GL_VER(3,0)) {
162         GET_PROC(BindFragDataLocation);
163     }
164 
165     if (glVer >= GR_GL_VER(3,3)) {
166         GET_PROC(BindFragDataLocationIndexed);
167     } else if (extensions.has("GL_ARB_blend_func_extended")) {
168         GET_PROC(BindFragDataLocationIndexed);
169     }
170 
171     if (extensions.has("GL_KHR_blend_equation_advanced")) {
172         GET_PROC_SUFFIX(BlendBarrier, KHR);
173     } else if (extensions.has("GL_NV_blend_equation_advanced")) {
174         GET_PROC_SUFFIX(BlendBarrier, NV);
175     }
176 
177     if (glVer >= GR_GL_VER(4,4)) {
178         GET_PROC(ClearTexImage);
179         GET_PROC(ClearTexSubImage);
180     } else if (extensions.has("GL_ARB_clear_texture")) {
181         GET_PROC(ClearTexImage);
182         GET_PROC(ClearTexSubImage);
183     }
184 
185     if (glVer >= GR_GL_VER(3,1)) {
186         GET_PROC(DrawArraysInstanced);
187         GET_PROC(DrawElementsInstanced);
188     } else if (extensions.has("GL_ARB_draw_instanced")) {
189         GET_PROC(DrawArraysInstanced);
190         GET_PROC(DrawElementsInstanced);
191     } else if (extensions.has("GL_EXT_draw_instanced")) {
192         GET_PROC_SUFFIX(DrawArraysInstanced, EXT);
193         GET_PROC_SUFFIX(DrawElementsInstanced, EXT);
194     }
195 
196     GET_PROC(DrawBuffers);
197     GET_PROC(ReadBuffer);
198 
199     if (glVer >= GR_GL_VER(4,0)) {
200         GET_PROC(DrawArraysIndirect);
201         GET_PROC(DrawElementsIndirect);
202     } else if (extensions.has("GL_ARB_draw_indirect")) {
203         GET_PROC(DrawArraysIndirect);
204         GET_PROC(DrawElementsIndirect);
205     }
206 
207     GET_PROC(DrawRangeElements);
208 
209     if (glVer >= GR_GL_VER(3,2)) {
210         GET_PROC(GetMultisamplefv);
211     } else if (extensions.has("GL_ARB_texture_multisample")) {
212         GET_PROC(GetMultisamplefv);
213     }
214 
215     GET_PROC(GetTexLevelParameteriv);
216 
217     if (glVer >= GR_GL_VER(4,3)) {
218         GET_PROC(MultiDrawArraysIndirect);
219         GET_PROC(MultiDrawElementsIndirect);
220     } else if (extensions.has("GL_ARB_multi_draw_indirect")) {
221         GET_PROC(MultiDrawArraysIndirect);
222         GET_PROC(MultiDrawElementsIndirect);
223     }
224 
225     if (glVer >= GR_GL_VER(3,1)) {
226         GET_PROC(TexBuffer);
227     }
228 
229     if (glVer >= GR_GL_VER(4,3)) {
230         GET_PROC(TexBufferRange);
231     }
232 
233     if (glVer >= GR_GL_VER(4,2)) {
234         GET_PROC(TexStorage2D);
235     } else if (extensions.has("GL_ARB_texture_storage")) {
236         GET_PROC(TexStorage2D);
237     } else if (extensions.has("GL_EXT_texture_storage")) {
238         GET_PROC_SUFFIX(TexStorage2D, EXT);
239     }
240 
241     if (glVer >= GR_GL_VER(4,5)) {
242         GET_PROC(TextureBarrier);
243     } else if (extensions.has("GL_ARB_texture_barrier")) {
244         GET_PROC(TextureBarrier);
245     } else if (extensions.has("GL_NV_texture_barrier")) {
246         GET_PROC_SUFFIX(TextureBarrier, NV);
247     }
248 
249     if (glVer >= GR_GL_VER(3,2)) {
250         GET_PROC(VertexAttribDivisor);
251     } else if (extensions.has("GL_ARB_instanced_arrays")) {
252         GET_PROC(VertexAttribDivisor);
253     }
254 
255     if (glVer >= GR_GL_VER(3,0)) {
256         GET_PROC(VertexAttribIPointer);
257     }
258 
259     if (glVer >= GR_GL_VER(3,0)) {
260         GET_PROC(BindFramebuffer);
261         GET_PROC(BindRenderbuffer);
262         GET_PROC(CheckFramebufferStatus);
263         GET_PROC(DeleteFramebuffers);
264         GET_PROC(DeleteRenderbuffers);
265         GET_PROC(FramebufferRenderbuffer);
266         GET_PROC(FramebufferTexture2D);
267         GET_PROC(GenFramebuffers);
268         GET_PROC(GenRenderbuffers);
269         GET_PROC(GenerateMipmap);
270         GET_PROC(GetFramebufferAttachmentParameteriv);
271         GET_PROC(GetRenderbufferParameteriv);
272         GET_PROC(RenderbufferStorage);
273     } else if (extensions.has("GL_ARB_framebuffer_object")) {
274         GET_PROC(BindFramebuffer);
275         GET_PROC(BindRenderbuffer);
276         GET_PROC(CheckFramebufferStatus);
277         GET_PROC(DeleteFramebuffers);
278         GET_PROC(DeleteRenderbuffers);
279         GET_PROC(FramebufferRenderbuffer);
280         GET_PROC(FramebufferTexture2D);
281         GET_PROC(GenFramebuffers);
282         GET_PROC(GenRenderbuffers);
283         GET_PROC(GenerateMipmap);
284         GET_PROC(GetFramebufferAttachmentParameteriv);
285         GET_PROC(GetRenderbufferParameteriv);
286         GET_PROC(RenderbufferStorage);
287     } else if (extensions.has("GL_EXT_framebuffer_object")) {
288         GET_PROC_SUFFIX(BindFramebuffer, EXT);
289         GET_PROC_SUFFIX(BindRenderbuffer, EXT);
290         GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
291         GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
292         GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
293         GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
294         GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
295         GET_PROC_SUFFIX(GenFramebuffers, EXT);
296         GET_PROC_SUFFIX(GenRenderbuffers, EXT);
297         GET_PROC_SUFFIX(GenerateMipmap, EXT);
298         GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
299         GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
300         GET_PROC_SUFFIX(RenderbufferStorage, EXT);
301     }
302 
303     if (glVer >= GR_GL_VER(3,0)) {
304         GET_PROC(BlitFramebuffer);
305     } else if (extensions.has("GL_ARB_framebuffer_object")) {
306         GET_PROC(BlitFramebuffer);
307     } else if (extensions.has("GL_EXT_framebuffer_blit")) {
308         GET_PROC_SUFFIX(BlitFramebuffer, EXT);
309     }
310 
311     if (glVer >= GR_GL_VER(3,0)) {
312         GET_PROC(RenderbufferStorageMultisample);
313     } else if (extensions.has("GL_ARB_framebuffer_object")) {
314         GET_PROC(RenderbufferStorageMultisample);
315     } else if (extensions.has("GL_EXT_framebuffer_multisample")) {
316         GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
317     }
318 
319     GET_PROC(MapBuffer);
320 
321     GET_PROC(UnmapBuffer);
322 
323     if (glVer >= GR_GL_VER(3,0)) {
324         GET_PROC(FlushMappedBufferRange);
325         GET_PROC(MapBufferRange);
326     } else if (extensions.has("GL_ARB_map_buffer_range")) {
327         GET_PROC(FlushMappedBufferRange);
328         GET_PROC(MapBufferRange);
329     }
330 
331     if (extensions.has("GL_EXT_debug_marker")) {
332         GET_PROC_SUFFIX(InsertEventMarker, EXT);
333         GET_PROC_SUFFIX(PopGroupMarker, EXT);
334         GET_PROC_SUFFIX(PushGroupMarker, EXT);
335     }
336 
337     if (glVer >= GR_GL_VER(4,3)) {
338         GET_PROC(GetProgramResourceLocation);
339     } else if (extensions.has("GL_ARB_program_interface_query")) {
340         GET_PROC(GetProgramResourceLocation);
341     }
342 
343     if (extensions.has("GL_NV_path_rendering")) {
344         GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
345         GET_PROC_SUFFIX(MatrixLoadf, EXT);
346     }
347 
348     if (extensions.has("GL_NV_path_rendering")) {
349         GET_PROC_SUFFIX(CoverFillPath, NV);
350         GET_PROC_SUFFIX(CoverFillPathInstanced, NV);
351         GET_PROC_SUFFIX(CoverStrokePath, NV);
352         GET_PROC_SUFFIX(CoverStrokePathInstanced, NV);
353         GET_PROC_SUFFIX(DeletePaths, NV);
354         GET_PROC_SUFFIX(GenPaths, NV);
355         GET_PROC_SUFFIX(IsPath, NV);
356         GET_PROC_SUFFIX(PathCommands, NV);
357         GET_PROC_SUFFIX(PathParameterf, NV);
358         GET_PROC_SUFFIX(PathParameteri, NV);
359         GET_PROC_SUFFIX(PathStencilFunc, NV);
360         GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV);
361         GET_PROC_SUFFIX(StencilFillPath, NV);
362         GET_PROC_SUFFIX(StencilFillPathInstanced, NV);
363         GET_PROC_SUFFIX(StencilStrokePath, NV);
364         GET_PROC_SUFFIX(StencilStrokePathInstanced, NV);
365         GET_PROC_SUFFIX(StencilThenCoverFillPath, NV);
366         GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV);
367         GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV);
368         GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV);
369     }
370 
371     if (extensions.has("GL_NV_framebuffer_mixed_samples")) {
372         GET_PROC_SUFFIX(CoverageModulation, NV);
373     }
374 
375     if (glVer >= GR_GL_VER(4,3)) {
376         GET_PROC(DebugMessageCallback);
377         GET_PROC(DebugMessageControl);
378         GET_PROC(DebugMessageInsert);
379         GET_PROC(GetDebugMessageLog);
380         GET_PROC(ObjectLabel);
381         GET_PROC(PopDebugGroup);
382         GET_PROC(PushDebugGroup);
383     } else if (extensions.has("GL_KHR_debug")) {
384         GET_PROC(DebugMessageCallback);
385         GET_PROC(DebugMessageControl);
386         GET_PROC(DebugMessageInsert);
387         GET_PROC(GetDebugMessageLog);
388         GET_PROC(ObjectLabel);
389         GET_PROC(PopDebugGroup);
390         GET_PROC(PushDebugGroup);
391     }
392 
393     if (extensions.has("GL_EXT_window_rectangles")) {
394         GET_PROC_SUFFIX(WindowRectangles, EXT);
395     }
396 
397     if (glVer >= GR_GL_VER(3,2)) {
398         GET_PROC(ClientWaitSync);
399         GET_PROC(DeleteSync);
400         GET_PROC(FenceSync);
401         GET_PROC(IsSync);
402         GET_PROC(WaitSync);
403     } else if (extensions.has("GL_ARB_sync")) {
404         GET_PROC(ClientWaitSync);
405         GET_PROC(DeleteSync);
406         GET_PROC(FenceSync);
407         GET_PROC(IsSync);
408         GET_PROC(WaitSync);
409     }
410 
411     if (glVer >= GR_GL_VER(4,2)) {
412         GET_PROC(GetInternalformativ);
413     } else if (extensions.has("GL_ARB_internalformat_query")) {
414         GET_PROC(GetInternalformativ);
415     }
416 
417     if (glVer >= GR_GL_VER(4,1)) {
418         GET_PROC(GetProgramBinary);
419         GET_PROC(ProgramBinary);
420     }
421 
422     if (glVer >= GR_GL_VER(4,1)) {
423         GET_PROC(ProgramParameteri);
424     }
425 
426     if (glVer >= GR_GL_VER(3,2)) {
427         GET_PROC(BindSampler);
428         GET_PROC(DeleteSamplers);
429         GET_PROC(GenSamplers);
430         GET_PROC(SamplerParameteri);
431         GET_PROC(SamplerParameteriv);
432     } else if (extensions.has("GL_ARB_sampler_objects")) {
433         GET_PROC(BindSampler);
434         GET_PROC(DeleteSamplers);
435         GET_PROC(GenSamplers);
436         GET_PROC(SamplerParameteri);
437         GET_PROC(SamplerParameteriv);
438     }
439 
440     GET_PROC(GetQueryObjectiv);
441 
442 #if GR_TEST_UTILS
443     GET_PROC(BeginQuery);
444     GET_PROC(DeleteQueries);
445     GET_PROC(EndQuery);
446     GET_PROC(GenQueries);
447     GET_PROC(GetQueryObjectuiv);
448     GET_PROC(GetQueryiv);
449 #endif
450 
451     if (glVer >= GR_GL_VER(3,3)) {
452         GET_PROC(GetQueryObjecti64v);
453         GET_PROC(GetQueryObjectui64v);
454     } else if (extensions.has("GL_ARB_timer_query")) {
455         GET_PROC(GetQueryObjecti64v);
456         GET_PROC(GetQueryObjectui64v);
457     } else if (extensions.has("GL_EXT_timer_query")) {
458         GET_PROC_SUFFIX(GetQueryObjecti64v, EXT);
459         GET_PROC_SUFFIX(GetQueryObjectui64v, EXT);
460     }
461 
462     if (glVer >= GR_GL_VER(3,3)) {
463         GET_PROC(QueryCounter);
464     } else if (extensions.has("GL_ARB_timer_query")) {
465         GET_PROC(QueryCounter);
466     }
467 
468     if (glVer >= GR_GL_VER(4,3)) {
469         GET_PROC(InvalidateBufferData);
470         GET_PROC(InvalidateBufferSubData);
471         GET_PROC(InvalidateTexImage);
472         GET_PROC(InvalidateTexSubImage);
473     } else if (extensions.has("GL_ARB_invalidate_subdata")) {
474         GET_PROC(InvalidateBufferData);
475         GET_PROC(InvalidateBufferSubData);
476         GET_PROC(InvalidateTexImage);
477         GET_PROC(InvalidateTexSubImage);
478     }
479 
480     if (glVer >= GR_GL_VER(4,3)) {
481         GET_PROC(InvalidateFramebuffer);
482         GET_PROC(InvalidateSubFramebuffer);
483     } else if (extensions.has("GL_ARB_invalidate_subdata")) {
484         GET_PROC(InvalidateFramebuffer);
485         GET_PROC(InvalidateSubFramebuffer);
486     }
487 
488     if (glVer >= GR_GL_VER(4,3)) {
489         GET_PROC(GetShaderPrecisionFormat);
490     } else if (extensions.has("GL_ARB_ES2_compatibility")) {
491         GET_PROC(GetShaderPrecisionFormat);
492     }
493 
494 
495     // End autogenerated content
496     interface->fStandard = kGL_GrGLStandard;
497     interface->fExtensions.swap(&extensions);
498 
499     return interface;
500 }
501 #endif
502