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
23sk_sp<const GrGLInterface> GrGLMakeAssembledGLInterface(void *ctx, GrGLGetProc get) {
24 return nullptr;
25}
26#else
27sk_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 if (glVer >= GR_GL_VER(4,2)) {
158 GET_PROC(MemoryBarrier);
159 }
160
161 GET_PROC(BindVertexArray);
162 GET_PROC(DeleteVertexArrays);
163 GET_PROC(GenVertexArrays);
164
165 if (glVer >= GR_GL_VER(4,0)) {
166 GET_PROC(PatchParameteri);
167 } else if (extensions.has("GL_ARB_tessellation_shader")) {
168 GET_PROC(PatchParameteri);
169 }
170
171 if (glVer >= GR_GL_VER(3,0)) {
172 GET_PROC(BindFragDataLocation);
173 }
174
175 if (glVer >= GR_GL_VER(3,3)) {
176 GET_PROC(BindFragDataLocationIndexed);
177 } else if (extensions.has("GL_ARB_blend_func_extended")) {
178 GET_PROC(BindFragDataLocationIndexed);
179 }
180
181 if (extensions.has("GL_KHR_blend_equation_advanced")) {
182 GET_PROC_SUFFIX(BlendBarrier, KHR);
183 } else if (extensions.has("GL_NV_blend_equation_advanced")) {
184 GET_PROC_SUFFIX(BlendBarrier, NV);
185 }
186
187 if (glVer >= GR_GL_VER(4,4)) {
188 GET_PROC(ClearTexImage);
189 GET_PROC(ClearTexSubImage);
190 } else if (extensions.has("GL_ARB_clear_texture")) {
191 GET_PROC(ClearTexImage);
192 GET_PROC(ClearTexSubImage);
193 }
194
195 if (glVer >= GR_GL_VER(3,1)) {
196 GET_PROC(DrawArraysInstanced);
197 GET_PROC(DrawElementsInstanced);
198 } else if (extensions.has("GL_ARB_draw_instanced")) {
199 GET_PROC(DrawArraysInstanced);
200 GET_PROC(DrawElementsInstanced);
201 } else if (extensions.has("GL_EXT_draw_instanced")) {
202 GET_PROC_SUFFIX(DrawArraysInstanced, EXT);
203 GET_PROC_SUFFIX(DrawElementsInstanced, EXT);
204 }
205
206 if (glVer >= GR_GL_VER(4,2)) {
207 GET_PROC(DrawArraysInstancedBaseInstance);
208 GET_PROC(DrawElementsInstancedBaseVertexBaseInstance);
209 } else if (extensions.has("GL_ARB_base_instance")) {
210 GET_PROC(DrawArraysInstancedBaseInstance);
211 GET_PROC(DrawElementsInstancedBaseVertexBaseInstance);
212 }
213
214 GET_PROC(DrawBuffers);
215 GET_PROC(ReadBuffer);
216
217 if (glVer >= GR_GL_VER(4,0)) {
218 GET_PROC(DrawArraysIndirect);
219 GET_PROC(DrawElementsIndirect);
220 } else if (extensions.has("GL_ARB_draw_indirect")) {
221 GET_PROC(DrawArraysIndirect);
222 GET_PROC(DrawElementsIndirect);
223 }
224
225 GET_PROC(DrawRangeElements);
226
227 if (glVer >= GR_GL_VER(3,2)) {
228 GET_PROC(GetMultisamplefv);
229 } else if (extensions.has("GL_ARB_texture_multisample")) {
230 GET_PROC(GetMultisamplefv);
231 }
232
233 GET_PROC(GetTexLevelParameteriv);
234
235 if (glVer >= GR_GL_VER(4,3)) {
236 GET_PROC(MultiDrawArraysIndirect);
237 GET_PROC(MultiDrawElementsIndirect);
238 } else if (extensions.has("GL_ARB_multi_draw_indirect")) {
239 GET_PROC(MultiDrawArraysIndirect);
240 GET_PROC(MultiDrawElementsIndirect);
241 }
242
243 if (glVer >= GR_GL_VER(3,1)) {
244 GET_PROC(TexBuffer);
245 }
246
247 if (glVer >= GR_GL_VER(4,3)) {
248 GET_PROC(TexBufferRange);
249 }
250
251 if (glVer >= GR_GL_VER(4,2)) {
252 GET_PROC(TexStorage2D);
253 } else if (extensions.has("GL_ARB_texture_storage")) {
254 GET_PROC(TexStorage2D);
255 } else if (extensions.has("GL_EXT_texture_storage")) {
256 GET_PROC_SUFFIX(TexStorage2D, EXT);
257 }
258
259 if (glVer >= GR_GL_VER(4,5)) {
260 GET_PROC(TextureBarrier);
261 } else if (extensions.has("GL_ARB_texture_barrier")) {
262 GET_PROC(TextureBarrier);
263 } else if (extensions.has("GL_NV_texture_barrier")) {
264 GET_PROC_SUFFIX(TextureBarrier, NV);
265 }
266
267 if (glVer >= GR_GL_VER(3,2)) {
268 GET_PROC(VertexAttribDivisor);
269 } else if (extensions.has("GL_ARB_instanced_arrays")) {
270 GET_PROC(VertexAttribDivisor);
271 }
272
273 if (glVer >= GR_GL_VER(3,0)) {
274 GET_PROC(VertexAttribIPointer);
275 }
276
277 if (glVer >= GR_GL_VER(3,0)) {
278 GET_PROC(BindFramebuffer);
279 GET_PROC(BindRenderbuffer);
280 GET_PROC(CheckFramebufferStatus);
281 GET_PROC(DeleteFramebuffers);
282 GET_PROC(DeleteRenderbuffers);
283 GET_PROC(FramebufferRenderbuffer);
284 GET_PROC(FramebufferTexture2D);
285 GET_PROC(GenFramebuffers);
286 GET_PROC(GenRenderbuffers);
287 GET_PROC(GenerateMipmap);
288 GET_PROC(GetFramebufferAttachmentParameteriv);
289 GET_PROC(GetRenderbufferParameteriv);
290 GET_PROC(RenderbufferStorage);
291 } else if (extensions.has("GL_ARB_framebuffer_object")) {
292 GET_PROC(BindFramebuffer);
293 GET_PROC(BindRenderbuffer);
294 GET_PROC(CheckFramebufferStatus);
295 GET_PROC(DeleteFramebuffers);
296 GET_PROC(DeleteRenderbuffers);
297 GET_PROC(FramebufferRenderbuffer);
298 GET_PROC(FramebufferTexture2D);
299 GET_PROC(GenFramebuffers);
300 GET_PROC(GenRenderbuffers);
301 GET_PROC(GenerateMipmap);
302 GET_PROC(GetFramebufferAttachmentParameteriv);
303 GET_PROC(GetRenderbufferParameteriv);
304 GET_PROC(RenderbufferStorage);
305 } else if (extensions.has("GL_EXT_framebuffer_object")) {
306 GET_PROC_SUFFIX(BindFramebuffer, EXT);
307 GET_PROC_SUFFIX(BindRenderbuffer, EXT);
308 GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
309 GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
310 GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
311 GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
312 GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
313 GET_PROC_SUFFIX(GenFramebuffers, EXT);
314 GET_PROC_SUFFIX(GenRenderbuffers, EXT);
315 GET_PROC_SUFFIX(GenerateMipmap, EXT);
316 GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
317 GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
318 GET_PROC_SUFFIX(RenderbufferStorage, EXT);
319 }
320
321 if (glVer >= GR_GL_VER(3,0)) {
322 GET_PROC(BlitFramebuffer);
323 } else if (extensions.has("GL_ARB_framebuffer_object")) {
324 GET_PROC(BlitFramebuffer);
325 } else if (extensions.has("GL_EXT_framebuffer_blit")) {
326 GET_PROC_SUFFIX(BlitFramebuffer, EXT);
327 }
328
329 if (glVer >= GR_GL_VER(3,0)) {
330 GET_PROC(RenderbufferStorageMultisample);
331 } else if (extensions.has("GL_ARB_framebuffer_object")) {
332 GET_PROC(RenderbufferStorageMultisample);
333 } else if (extensions.has("GL_EXT_framebuffer_multisample")) {
334 GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
335 }
336
337 GET_PROC(MapBuffer);
338
339 GET_PROC(UnmapBuffer);
340
341 if (glVer >= GR_GL_VER(3,0)) {
342 GET_PROC(FlushMappedBufferRange);
343 GET_PROC(MapBufferRange);
344 } else if (extensions.has("GL_ARB_map_buffer_range")) {
345 GET_PROC(FlushMappedBufferRange);
346 GET_PROC(MapBufferRange);
347 }
348
349 if (extensions.has("GL_EXT_debug_marker")) {
350 GET_PROC_SUFFIX(InsertEventMarker, EXT);
351 GET_PROC_SUFFIX(PopGroupMarker, EXT);
352 GET_PROC_SUFFIX(PushGroupMarker, EXT);
353 }
354
355 if (glVer >= GR_GL_VER(4,3)) {
356 GET_PROC(GetProgramResourceLocation);
357 } else if (extensions.has("GL_ARB_program_interface_query")) {
358 GET_PROC(GetProgramResourceLocation);
359 }
360
361 if (extensions.has("GL_NV_path_rendering")) {
362 GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
363 GET_PROC_SUFFIX(MatrixLoadf, EXT);
364 }
365
366 if (extensions.has("GL_NV_path_rendering")) {
367 GET_PROC_SUFFIX(CoverFillPath, NV);
368 GET_PROC_SUFFIX(CoverFillPathInstanced, NV);
369 GET_PROC_SUFFIX(CoverStrokePath, NV);
370 GET_PROC_SUFFIX(CoverStrokePathInstanced, NV);
371 GET_PROC_SUFFIX(DeletePaths, NV);
372 GET_PROC_SUFFIX(GenPaths, NV);
373 GET_PROC_SUFFIX(IsPath, NV);
374 GET_PROC_SUFFIX(PathCommands, NV);
375 GET_PROC_SUFFIX(PathParameterf, NV);
376 GET_PROC_SUFFIX(PathParameteri, NV);
377 GET_PROC_SUFFIX(PathStencilFunc, NV);
378 GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV);
379 GET_PROC_SUFFIX(StencilFillPath, NV);
380 GET_PROC_SUFFIX(StencilFillPathInstanced, NV);
381 GET_PROC_SUFFIX(StencilStrokePath, NV);
382 GET_PROC_SUFFIX(StencilStrokePathInstanced, NV);
383 GET_PROC_SUFFIX(StencilThenCoverFillPath, NV);
384 GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV);
385 GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV);
386 GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV);
387 }
388
389 if (extensions.has("GL_NV_framebuffer_mixed_samples")) {
390 GET_PROC_SUFFIX(CoverageModulation, NV);
391 }
392
393 if (glVer >= GR_GL_VER(4,3)) {
394 GET_PROC(DebugMessageCallback);
395 GET_PROC(DebugMessageControl);
396 GET_PROC(DebugMessageInsert);
397 GET_PROC(GetDebugMessageLog);
398 GET_PROC(ObjectLabel);
399 GET_PROC(PopDebugGroup);
400 GET_PROC(PushDebugGroup);
401 } else if (extensions.has("GL_KHR_debug")) {
402 GET_PROC(DebugMessageCallback);
403 GET_PROC(DebugMessageControl);
404 GET_PROC(DebugMessageInsert);
405 GET_PROC(GetDebugMessageLog);
406 GET_PROC(ObjectLabel);
407 GET_PROC(PopDebugGroup);
408 GET_PROC(PushDebugGroup);
409 }
410
411 if (extensions.has("GL_EXT_window_rectangles")) {
412 GET_PROC_SUFFIX(WindowRectangles, EXT);
413 }
414
415 if (glVer >= GR_GL_VER(3,2)) {
416 GET_PROC(ClientWaitSync);
417 GET_PROC(DeleteSync);
418 GET_PROC(FenceSync);
419 GET_PROC(IsSync);
420 GET_PROC(WaitSync);
421 } else if (extensions.has("GL_ARB_sync")) {
422 GET_PROC(ClientWaitSync);
423 GET_PROC(DeleteSync);
424 GET_PROC(FenceSync);
425 GET_PROC(IsSync);
426 GET_PROC(WaitSync);
427 }
428
429 if (glVer >= GR_GL_VER(4,2)) {
430 GET_PROC(GetInternalformativ);
431 } else if (extensions.has("GL_ARB_internalformat_query")) {
432 GET_PROC(GetInternalformativ);
433 }
434
435 if (glVer >= GR_GL_VER(4,1)) {
436 GET_PROC(GetProgramBinary);
437 GET_PROC(ProgramBinary);
438 }
439
440 if (glVer >= GR_GL_VER(4,1)) {
441 GET_PROC(ProgramParameteri);
442 }
443
444 if (glVer >= GR_GL_VER(3,2)) {
445 GET_PROC(BindSampler);
446 GET_PROC(DeleteSamplers);
447 GET_PROC(GenSamplers);
448 GET_PROC(SamplerParameteri);
449 GET_PROC(SamplerParameteriv);
450 } else if (extensions.has("GL_ARB_sampler_objects")) {
451 GET_PROC(BindSampler);
452 GET_PROC(DeleteSamplers);
453 GET_PROC(GenSamplers);
454 GET_PROC(SamplerParameteri);
455 GET_PROC(SamplerParameteriv);
456 }
457
458 GET_PROC(GetQueryObjectiv);
459
460#if GR_TEST_UTILS
461 GET_PROC(BeginQuery);
462 GET_PROC(DeleteQueries);
463 GET_PROC(EndQuery);
464 GET_PROC(GenQueries);
465 GET_PROC(GetQueryObjectuiv);
466 GET_PROC(GetQueryiv);
467#endif
468
469 if (glVer >= GR_GL_VER(3,3)) {
470 GET_PROC(GetQueryObjecti64v);
471 GET_PROC(GetQueryObjectui64v);
472 } else if (extensions.has("GL_ARB_timer_query")) {
473 GET_PROC(GetQueryObjecti64v);
474 GET_PROC(GetQueryObjectui64v);
475 } else if (extensions.has("GL_EXT_timer_query")) {
476 GET_PROC_SUFFIX(GetQueryObjecti64v, EXT);
477 GET_PROC_SUFFIX(GetQueryObjectui64v, EXT);
478 }
479
480 if (glVer >= GR_GL_VER(3,3)) {
481 GET_PROC(QueryCounter);
482 } else if (extensions.has("GL_ARB_timer_query")) {
483 GET_PROC(QueryCounter);
484 }
485
486 if (glVer >= GR_GL_VER(4,3)) {
487 GET_PROC(InvalidateBufferData);
488 GET_PROC(InvalidateBufferSubData);
489 GET_PROC(InvalidateTexImage);
490 GET_PROC(InvalidateTexSubImage);
491 } else if (extensions.has("GL_ARB_invalidate_subdata")) {
492 GET_PROC(InvalidateBufferData);
493 GET_PROC(InvalidateBufferSubData);
494 GET_PROC(InvalidateTexImage);
495 GET_PROC(InvalidateTexSubImage);
496 }
497
498 if (glVer >= GR_GL_VER(4,3)) {
499 GET_PROC(InvalidateFramebuffer);
500 GET_PROC(InvalidateSubFramebuffer);
501 } else if (extensions.has("GL_ARB_invalidate_subdata")) {
502 GET_PROC(InvalidateFramebuffer);
503 GET_PROC(InvalidateSubFramebuffer);
504 }
505
506 if (glVer >= GR_GL_VER(4,3)) {
507 GET_PROC(GetShaderPrecisionFormat);
508 } else if (extensions.has("GL_ARB_ES2_compatibility")) {
509 GET_PROC(GetShaderPrecisionFormat);
510 }
511
512 if (extensions.has("GL_NV_fence")) {
513 GET_PROC_SUFFIX(DeleteFences, NV);
514 GET_PROC_SUFFIX(FinishFence, NV);
515 GET_PROC_SUFFIX(GenFences, NV);
516 GET_PROC_SUFFIX(SetFence, NV);
517 GET_PROC_SUFFIX(TestFence, NV);
518 }
519
520
521 // End autogenerated content
522 interface->fStandard = kGL_GrGLStandard;
523 interface->fExtensions.swap(&extensions);
524
525 return std::move(interface);
526}
527#endif
528