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