blob: e804dd605a4029b003e40e33afb59c49b67ff5ed [file] [log] [blame]
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +00001/*
2 * Copyright 2014 Google Inc.
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
8
bsalomon062bd862016-03-31 10:22:20 -07009#include "gl/GrGLAssembleInterface.h"
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +000010#include "GrGLUtil.h"
11
12#define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F)
13#define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F #S)
14#define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl" #F)
15
bsalomon7ea33f52015-11-22 14:51:00 -080016#define GET_EGL_PROC_SUFFIX(F, S) functions->fEGL ## F = (GrEGL ## F ## Proc) get(ctx, "egl" #F #S)
bsalomonb1a32ad2015-11-16 06:48:44 -080017
bsalomona721c812014-08-26 11:35:23 -070018const GrGLInterface* GrGLAssembleInterface(void* ctx, GrGLGetProc get) {
19 GET_PROC_LOCAL(GetString);
halcanary96fcdcc2015-08-27 07:41:13 -070020 if (nullptr == GetString) {
21 return nullptr;
bsalomona721c812014-08-26 11:35:23 -070022 }
23
24 const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION));
halcanary96fcdcc2015-08-27 07:41:13 -070025 if (nullptr == verStr) {
26 return nullptr;
bsalomona721c812014-08-26 11:35:23 -070027 }
28
29 GrGLStandard standard = GrGLGetStandardInUseFromString(verStr);
30
31 if (kGLES_GrGLStandard == standard) {
32 return GrGLAssembleGLESInterface(ctx, get);
33 } else if (kGL_GrGLStandard == standard) {
34 return GrGLAssembleGLInterface(ctx, get);
35 }
halcanary96fcdcc2015-08-27 07:41:13 -070036 return nullptr;
bsalomona721c812014-08-26 11:35:23 -070037}
38
bsalomonb1a32ad2015-11-16 06:48:44 -080039static void get_egl_query_and_display(GrEGLQueryStringProc* queryString, GrEGLDisplay* display,
40 void* ctx, GrGLGetProc get) {
41 *queryString = (GrEGLQueryStringProc) get(ctx, "eglQueryString");
42 *display = GR_EGL_NO_DISPLAY;
43 if (*queryString) {
44 GrEGLGetCurrentDisplayProc getCurrentDisplay =
45 (GrEGLGetCurrentDisplayProc) get(ctx, "eglGetCurrentDisplay");
46 if (getCurrentDisplay) {
47 *display = getCurrentDisplay();
48 } else {
49 *queryString = nullptr;
50 }
51 }
52}
53
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +000054const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
55 GET_PROC_LOCAL(GetString);
56 GET_PROC_LOCAL(GetStringi);
57 GET_PROC_LOCAL(GetIntegerv);
58
halcanary96fcdcc2015-08-27 07:41:13 -070059 // GetStringi may be nullptr depending on the GL version.
60 if (nullptr == GetString || nullptr == GetIntegerv) {
61 return nullptr;
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +000062 }
63
64 const char* versionString = (const char*) GetString(GR_GL_VERSION);
65 GrGLVersion glVer = GrGLGetVersionFromString(versionString);
66
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +000067 if (glVer < GR_GL_VER(1,5) || GR_GL_INVALID_VER == glVer) {
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +000068 // We must have array and element_array buffer objects.
halcanary96fcdcc2015-08-27 07:41:13 -070069 return nullptr;
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +000070 }
71
bsalomonb1a32ad2015-11-16 06:48:44 -080072 GrEGLQueryStringProc queryString;
73 GrEGLDisplay display;
74 get_egl_query_and_display(&queryString, &display, ctx, get);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +000075 GrGLExtensions extensions;
bsalomonb1a32ad2015-11-16 06:48:44 -080076 if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString,
77 display)) {
halcanary96fcdcc2015-08-27 07:41:13 -070078 return nullptr;
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +000079 }
80
halcanary385fe4d2015-08-26 13:07:48 -070081 GrGLInterface* interface = new GrGLInterface();
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +000082 GrGLInterface::Functions* functions = &interface->fFunctions;
83
84 GET_PROC(ActiveTexture);
85 GET_PROC(AttachShader);
86 GET_PROC(BindAttribLocation);
87 GET_PROC(BindBuffer);
88 if (glVer >= GR_GL_VER(3,0)) {
89 GET_PROC(BindFragDataLocation);
90 }
91 GET_PROC(BeginQuery);
92 GET_PROC(BindTexture);
tomhudson2575f312015-04-21 14:16:53 -070093
cdaltonbae6f6c2015-04-22 10:39:03 -070094 if (extensions.has("GL_KHR_blend_equation_advanced")) {
95 GET_PROC_SUFFIX(BlendBarrier, KHR);
96 } else if (extensions.has("GL_NV_blend_equation_advanced")) {
97 GET_PROC_SUFFIX(BlendBarrier, NV);
tomhudson2575f312015-04-21 14:16:53 -070098 }
99
cdaltonbae6f6c2015-04-22 10:39:03 -0700100 if (glVer >= GR_GL_VER(1,4) ||
101 extensions.has("GL_ARB_imaging")) {
102 GET_PROC(BlendColor);
103 } else if (extensions.has("GL_EXT_blend_color")) {
104 GET_PROC_SUFFIX(BlendColor, EXT);
105 }
106
107 if (glVer >= GR_GL_VER(1,4) ||
108 extensions.has("GL_ARB_imaging")) {
109 GET_PROC(BlendEquation);
110 } else if (extensions.has("GL_EXT_blend_subtract")) {
111 GET_PROC_SUFFIX(BlendEquation, EXT);
112 }
113
114 GET_PROC(BlendFunc);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000115 GET_PROC(BufferData);
116 GET_PROC(BufferSubData);
117 GET_PROC(Clear);
118 GET_PROC(ClearColor);
119 GET_PROC(ClearStencil);
120 GET_PROC(ColorMask);
121 GET_PROC(CompileShader);
122 GET_PROC(CompressedTexImage2D);
krajcevski37d20f72014-06-11 10:38:47 -0700123 GET_PROC(CompressedTexSubImage2D);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000124 GET_PROC(CopyTexSubImage2D);
125 GET_PROC(CreateProgram);
126 GET_PROC(CreateShader);
127 GET_PROC(CullFace);
128 GET_PROC(DeleteBuffers);
129 GET_PROC(DeleteProgram);
130 GET_PROC(DeleteQueries);
131 GET_PROC(DeleteShader);
132 GET_PROC(DeleteTextures);
133 GET_PROC(DepthMask);
134 GET_PROC(Disable);
135 GET_PROC(DisableVertexAttribArray);
136 GET_PROC(DrawArrays);
137 GET_PROC(DrawBuffer);
138 GET_PROC(DrawBuffers);
139 GET_PROC(DrawElements);
cdalton06604b92016-02-05 10:09:51 -0800140
141 if (glVer >= GR_GL_VER(3,1) || extensions.has("GL_ARB_draw_instanced") ||
142 extensions.has("GL_EXT_draw_instanced")) {
143 GET_PROC(DrawArraysInstanced);
144 GET_PROC(DrawElementsInstanced);
145 }
146
csmartdalton5cebf8c2016-06-03 08:28:47 -0700147 if (glVer >= GR_GL_VER(4,0) || extensions.has("GL_ARB_draw_indirect")) {
cdalton06604b92016-02-05 10:09:51 -0800148 GET_PROC(DrawArraysIndirect);
149 GET_PROC(DrawElementsIndirect);
150 }
bsalomonfc9527a2016-08-29 09:18:39 -0700151 if (glVer >= GR_GL_VER(2,0)) {
152 GET_PROC(DrawRangeElements);
153 }
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000154 GET_PROC(Enable);
155 GET_PROC(EnableVertexAttribArray);
156 GET_PROC(EndQuery);
157 GET_PROC(Finish);
158 GET_PROC(Flush);
159 GET_PROC(FrontFace);
160 GET_PROC(GenBuffers);
161 GET_PROC(GenerateMipmap);
162 GET_PROC(GetBufferParameteriv);
163 GET_PROC(GetError);
164 GET_PROC(GetIntegerv);
cdaltoneb79eea2016-02-26 10:39:34 -0800165 if (glVer >= GR_GL_VER(3,2) || extensions.has("GL_ARB_texture_multisample")) {
166 GET_PROC(GetMultisamplefv);
167 }
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000168 GET_PROC(GetQueryObjectiv);
169 GET_PROC(GetQueryObjectuiv);
170 if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) {
171 GET_PROC(GetQueryObjecti64v);
172 GET_PROC(GetQueryObjectui64v);
173 GET_PROC(QueryCounter);
174 } else if (extensions.has("GL_EXT_timer_query")) {
175 GET_PROC_SUFFIX(GetQueryObjecti64v, EXT);
176 GET_PROC_SUFFIX(GetQueryObjectui64v, EXT);
177 }
178 GET_PROC(GetQueryiv);
179 GET_PROC(GetProgramInfoLog);
180 GET_PROC(GetProgramiv);
181 GET_PROC(GetShaderInfoLog);
182 GET_PROC(GetShaderiv);
183 GET_PROC(GetString);
184 GET_PROC(GetStringi);
bsalomonee64d6e2014-12-03 10:46:08 -0800185 GET_PROC(GetShaderPrecisionFormat);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000186 GET_PROC(GetTexLevelParameteriv);
187 GET_PROC(GenQueries);
188 GET_PROC(GenTextures);
189 GET_PROC(GetUniformLocation);
bsalomon6dc6f5f2015-06-18 09:12:16 -0700190 GET_PROC(IsTexture);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000191 GET_PROC(LineWidth);
192 GET_PROC(LinkProgram);
193 GET_PROC(MapBuffer);
csmartdalton5cebf8c2016-06-03 08:28:47 -0700194
195 if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_multi_draw_indirect")) {
196 GET_PROC(MultiDrawArraysIndirect);
197 GET_PROC(MultiDrawElementsIndirect);
198 }
199
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000200 GET_PROC(PixelStorei);
cdalton0edea2c2015-05-21 08:27:44 -0700201 if (extensions.has("GL_EXT_raster_multisample")) {
202 GET_PROC_SUFFIX(RasterSamples, EXT);
203 }
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000204 GET_PROC(ReadBuffer);
205 GET_PROC(ReadPixels);
206 GET_PROC(Scissor);
207 GET_PROC(ShaderSource);
208 GET_PROC(StencilFunc);
209 GET_PROC(StencilFuncSeparate);
210 GET_PROC(StencilMask);
211 GET_PROC(StencilMaskSeparate);
212 GET_PROC(StencilOp);
213 GET_PROC(StencilOpSeparate);
cdaltonc04ce672016-03-11 14:07:38 -0800214 if (glVer >= GR_GL_VER(3,1)) {
215 GET_PROC(TexBuffer);
216 }
cdaltonf8a6ce82016-04-11 13:02:05 -0700217 if (glVer >= GR_GL_VER(4,3)) {
218 GET_PROC(TexBufferRange);
219 }
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000220 GET_PROC(TexImage2D);
221 GET_PROC(TexParameteri);
222 GET_PROC(TexParameteriv);
223 if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) {
224 GET_PROC(TexStorage2D);
225 } else if (extensions.has("GL_EXT_texture_storage")) {
226 GET_PROC_SUFFIX(TexStorage2D, EXT);
227 }
228 GET_PROC(TexSubImage2D);
cdaltonfd4167d2015-04-21 11:45:56 -0700229 if (glVer >= GR_GL_VER(4,5) || extensions.has("GL_ARB_texture_barrier")) {
230 GET_PROC(TextureBarrier);
231 } else if (extensions.has("GL_NV_texture_barrier")) {
232 GET_PROC_SUFFIX(TextureBarrier, NV);
233 }
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000234 GET_PROC(Uniform1f);
235 GET_PROC(Uniform1i);
236 GET_PROC(Uniform1fv);
237 GET_PROC(Uniform1iv);
238 GET_PROC(Uniform2f);
239 GET_PROC(Uniform2i);
240 GET_PROC(Uniform2fv);
241 GET_PROC(Uniform2iv);
242 GET_PROC(Uniform3f);
243 GET_PROC(Uniform3i);
244 GET_PROC(Uniform3fv);
245 GET_PROC(Uniform3iv);
246 GET_PROC(Uniform4f);
247 GET_PROC(Uniform4i);
248 GET_PROC(Uniform4fv);
249 GET_PROC(Uniform4iv);
250 GET_PROC(UniformMatrix2fv);
251 GET_PROC(UniformMatrix3fv);
252 GET_PROC(UniformMatrix4fv);
253 GET_PROC(UnmapBuffer);
254 GET_PROC(UseProgram);
egdaniel27c15212014-10-24 15:00:50 -0700255 GET_PROC(VertexAttrib1f);
256 GET_PROC(VertexAttrib2fv);
257 GET_PROC(VertexAttrib3fv);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000258 GET_PROC(VertexAttrib4fv);
cdalton06604b92016-02-05 10:09:51 -0800259
260 if (glVer >= GR_GL_VER(3,2) || extensions.has("GL_ARB_instanced_arrays")) {
261 GET_PROC(VertexAttribDivisor);
262 }
263
cdalton793dc262016-02-08 10:11:47 -0800264 if (glVer >= GR_GL_VER(3,0)) {
265 GET_PROC(VertexAttribIPointer);
266 }
267
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000268 GET_PROC(VertexAttribPointer);
269 GET_PROC(Viewport);
270 GET_PROC(BindFragDataLocationIndexed);
271
272 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) {
273 // no ARB suffix for GL_ARB_vertex_array_object
274 GET_PROC(BindVertexArray);
275 GET_PROC(GenVertexArrays);
276 GET_PROC(DeleteVertexArrays);
tomhudson612e9262014-11-24 11:22:36 -0800277 } else if (extensions.has("GL_APPLE_vertex_array_object")) {
278 GET_PROC_SUFFIX(BindVertexArray, APPLE);
279 GET_PROC_SUFFIX(GenVertexArrays, APPLE);
280 GET_PROC_SUFFIX(DeleteVertexArrays, APPLE);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000281 }
282
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000283 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_map_buffer_range")) {
284 GET_PROC(MapBufferRange);
285 GET_PROC(FlushMappedBufferRange);
286 }
287
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000288 // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
289 // GL_ARB_framebuffer_object doesn't use ARB suffix.)
290 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) {
291 GET_PROC(GenFramebuffers);
292 GET_PROC(GetFramebufferAttachmentParameteriv);
293 GET_PROC(GetRenderbufferParameteriv);
294 GET_PROC(BindFramebuffer);
295 GET_PROC(FramebufferTexture2D);
296 GET_PROC(CheckFramebufferStatus);
297 GET_PROC(DeleteFramebuffers);
298 GET_PROC(RenderbufferStorage);
299 GET_PROC(GenRenderbuffers);
300 GET_PROC(DeleteRenderbuffers);
301 GET_PROC(FramebufferRenderbuffer);
302 GET_PROC(BindRenderbuffer);
303 GET_PROC(RenderbufferStorageMultisample);
304 GET_PROC(BlitFramebuffer);
305 } else if (extensions.has("GL_EXT_framebuffer_object")) {
306 GET_PROC_SUFFIX(GenFramebuffers, EXT);
307 GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
308 GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
309 GET_PROC_SUFFIX(BindFramebuffer, EXT);
310 GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
311 GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
312 GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
313 GET_PROC_SUFFIX(RenderbufferStorage, EXT);
314 GET_PROC_SUFFIX(GenRenderbuffers, EXT);
315 GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
316 GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
317 GET_PROC_SUFFIX(BindRenderbuffer, EXT);
318 if (extensions.has("GL_EXT_framebuffer_multisample")) {
319 GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
320 }
321 if (extensions.has("GL_EXT_framebuffer_blit")) {
322 GET_PROC_SUFFIX(BlitFramebuffer, EXT);
323 }
324 } else {
325 // we must have FBOs
326 delete interface;
halcanary96fcdcc2015-08-27 07:41:13 -0700327 return nullptr;
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000328 }
329
330 if (extensions.has("GL_NV_path_rendering")) {
cdalton626e1ff2015-06-12 13:56:46 -0700331 GET_PROC_SUFFIX(MatrixLoadf, EXT);
332 GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000333 GET_PROC_SUFFIX(PathCommands, NV);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000334 GET_PROC_SUFFIX(PathParameteri, NV);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000335 GET_PROC_SUFFIX(PathParameterf, NV);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000336 GET_PROC_SUFFIX(GenPaths, NV);
337 GET_PROC_SUFFIX(DeletePaths, NV);
cdalton8dd90cb2014-07-17 09:28:36 -0700338 GET_PROC_SUFFIX(IsPath, NV);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000339 GET_PROC_SUFFIX(PathStencilFunc, NV);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000340 GET_PROC_SUFFIX(StencilFillPath, NV);
341 GET_PROC_SUFFIX(StencilStrokePath, NV);
342 GET_PROC_SUFFIX(StencilFillPathInstanced, NV);
343 GET_PROC_SUFFIX(StencilStrokePathInstanced, NV);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000344 GET_PROC_SUFFIX(CoverFillPath, NV);
345 GET_PROC_SUFFIX(CoverStrokePath, NV);
346 GET_PROC_SUFFIX(CoverFillPathInstanced, NV);
347 GET_PROC_SUFFIX(CoverStrokePathInstanced, NV);
cdaltonc8f52042014-07-29 15:25:51 -0700348 GET_PROC_SUFFIX(StencilThenCoverFillPath, NV);
349 GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV);
350 GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV);
351 GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV);
kkinnunen32b9a3b2014-07-02 22:56:35 -0700352 GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV);
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000353 }
354
vbuzinov08b4d292015-04-01 06:29:49 -0700355 if (extensions.has("GL_NV_framebuffer_mixed_samples")) {
356 GET_PROC_SUFFIX(CoverageModulation, NV);
357 }
358
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000359 if (extensions.has("GL_EXT_debug_marker")) {
360 GET_PROC_SUFFIX(InsertEventMarker, EXT);
361 GET_PROC_SUFFIX(PushGroupMarker, EXT);
362 GET_PROC_SUFFIX(PopGroupMarker, EXT);
363 }
364
365 if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) {
366 GET_PROC(InvalidateBufferData);
367 GET_PROC(InvalidateBufferSubData);
368 GET_PROC(InvalidateFramebuffer);
369 GET_PROC(InvalidateSubFramebuffer);
370 GET_PROC(InvalidateTexImage);
371 GET_PROC(InvalidateTexSubImage);
372 }
373
kkinnunen32b9a3b2014-07-02 22:56:35 -0700374 if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_program_interface_query")) {
375 GET_PROC(GetProgramResourceLocation);
376 }
377
cdalton626e1ff2015-06-12 13:56:46 -0700378 if (extensions.has("GL_NV_bindless_texture")) {
379 GET_PROC_SUFFIX(GetTextureHandle, NV);
380 GET_PROC_SUFFIX(GetTextureSamplerHandle, NV);
381 GET_PROC_SUFFIX(MakeTextureHandleResident, NV);
382 GET_PROC_SUFFIX(MakeTextureHandleNonResident, NV);
383 GET_PROC_SUFFIX(GetImageHandle, NV);
384 GET_PROC_SUFFIX(MakeImageHandleResident, NV);
385 GET_PROC_SUFFIX(MakeImageHandleNonResident, NV);
386 GET_PROC_SUFFIX(IsTextureHandleResident, NV);
387 GET_PROC_SUFFIX(IsImageHandleResident, NV);
388 GET_PROC_SUFFIX(UniformHandleui64, NV);
389 GET_PROC_SUFFIX(UniformHandleui64v, NV);
390 GET_PROC_SUFFIX(ProgramUniformHandleui64, NV);
391 GET_PROC_SUFFIX(ProgramUniformHandleui64v, NV);
392 }
393
394 if (extensions.has("GL_EXT_direct_state_access")) {
395 GET_PROC_SUFFIX(TextureParameteri, EXT);
396 GET_PROC_SUFFIX(TextureParameteriv, EXT);
397 GET_PROC_SUFFIX(TextureParameterf, EXT);
398 GET_PROC_SUFFIX(TextureParameterfv, EXT);
399 GET_PROC_SUFFIX(TextureImage1D, EXT);
400 GET_PROC_SUFFIX(TextureImage2D, EXT);
401 GET_PROC_SUFFIX(TextureSubImage1D, EXT);
402 GET_PROC_SUFFIX(TextureSubImage2D, EXT);
403 GET_PROC_SUFFIX(CopyTextureImage1D, EXT);
404 GET_PROC_SUFFIX(CopyTextureImage2D, EXT);
405 GET_PROC_SUFFIX(CopyTextureSubImage1D, EXT);
406 GET_PROC_SUFFIX(CopyTextureSubImage2D, EXT);
407 GET_PROC_SUFFIX(GetTextureImage, EXT);
408 GET_PROC_SUFFIX(GetTextureParameterfv, EXT);
409 GET_PROC_SUFFIX(GetTextureParameteriv, EXT);
410 GET_PROC_SUFFIX(GetTextureLevelParameterfv, EXT);
411 GET_PROC_SUFFIX(GetTextureLevelParameteriv, EXT);
412 if (glVer >= GR_GL_VER(1,2)) {
413 GET_PROC_SUFFIX(TextureImage3D, EXT);
414 GET_PROC_SUFFIX(TextureSubImage3D, EXT);
415 GET_PROC_SUFFIX(CopyTextureSubImage3D, EXT);
416 GET_PROC_SUFFIX(CompressedTextureImage3D, EXT);
417 GET_PROC_SUFFIX(CompressedTextureImage2D, EXT);
418 GET_PROC_SUFFIX(CompressedTextureImage1D, EXT);
419 GET_PROC_SUFFIX(CompressedTextureSubImage3D, EXT);
420 GET_PROC_SUFFIX(CompressedTextureSubImage2D, EXT);
421 GET_PROC_SUFFIX(CompressedTextureSubImage1D, EXT);
422 GET_PROC_SUFFIX(GetCompressedTextureImage, EXT);
423 }
424 if (glVer >= GR_GL_VER(1,5)) {
425 GET_PROC_SUFFIX(NamedBufferData, EXT);
426 GET_PROC_SUFFIX(NamedBufferSubData, EXT);
427 GET_PROC_SUFFIX(MapNamedBuffer, EXT);
428 GET_PROC_SUFFIX(UnmapNamedBuffer, EXT);
429 GET_PROC_SUFFIX(GetNamedBufferParameteriv, EXT);
430 GET_PROC_SUFFIX(GetNamedBufferPointerv, EXT);
431 GET_PROC_SUFFIX(GetNamedBufferSubData, EXT);
432 }
433 if (glVer >= GR_GL_VER(2,0)) {
434 GET_PROC_SUFFIX(ProgramUniform1f, EXT);
435 GET_PROC_SUFFIX(ProgramUniform2f, EXT);
436 GET_PROC_SUFFIX(ProgramUniform3f, EXT);
437 GET_PROC_SUFFIX(ProgramUniform4f, EXT);
438 GET_PROC_SUFFIX(ProgramUniform1i, EXT);
439 GET_PROC_SUFFIX(ProgramUniform2i, EXT);
440 GET_PROC_SUFFIX(ProgramUniform3i, EXT);
441 GET_PROC_SUFFIX(ProgramUniform4i, EXT);
442 GET_PROC_SUFFIX(ProgramUniform1fv, EXT);
443 GET_PROC_SUFFIX(ProgramUniform2fv, EXT);
444 GET_PROC_SUFFIX(ProgramUniform3fv, EXT);
445 GET_PROC_SUFFIX(ProgramUniform4fv, EXT);
446 GET_PROC_SUFFIX(ProgramUniform1iv, EXT);
447 GET_PROC_SUFFIX(ProgramUniform2iv, EXT);
448 GET_PROC_SUFFIX(ProgramUniform3iv, EXT);
449 GET_PROC_SUFFIX(ProgramUniform4iv, EXT);
450 GET_PROC_SUFFIX(ProgramUniformMatrix2fv, EXT);
451 GET_PROC_SUFFIX(ProgramUniformMatrix3fv, EXT);
452 GET_PROC_SUFFIX(ProgramUniformMatrix4fv, EXT);
453 }
454 if (glVer >= GR_GL_VER(2,1)) {
455 GET_PROC_SUFFIX(ProgramUniformMatrix2x3fv, EXT);
456 GET_PROC_SUFFIX(ProgramUniformMatrix3x2fv, EXT);
457 GET_PROC_SUFFIX(ProgramUniformMatrix2x4fv, EXT);
458 GET_PROC_SUFFIX(ProgramUniformMatrix4x2fv, EXT);
459 GET_PROC_SUFFIX(ProgramUniformMatrix3x4fv, EXT);
460 GET_PROC_SUFFIX(ProgramUniformMatrix4x3fv, EXT);
461 }
462 if (glVer >= GR_GL_VER(3,0)) {
463 GET_PROC_SUFFIX(NamedRenderbufferStorage, EXT);
464 GET_PROC_SUFFIX(GetNamedRenderbufferParameteriv, EXT);
465 GET_PROC_SUFFIX(NamedRenderbufferStorageMultisample, EXT);
466 GET_PROC_SUFFIX(CheckNamedFramebufferStatus, EXT);
467 GET_PROC_SUFFIX(NamedFramebufferTexture1D, EXT);
468 GET_PROC_SUFFIX(NamedFramebufferTexture2D, EXT);
469 GET_PROC_SUFFIX(NamedFramebufferTexture3D, EXT);
470 GET_PROC_SUFFIX(NamedFramebufferRenderbuffer, EXT);
471 GET_PROC_SUFFIX(GetNamedFramebufferAttachmentParameteriv, EXT);
472 GET_PROC_SUFFIX(GenerateTextureMipmap, EXT);
473 GET_PROC_SUFFIX(FramebufferDrawBuffer, EXT);
474 GET_PROC_SUFFIX(FramebufferDrawBuffers, EXT);
475 GET_PROC_SUFFIX(FramebufferReadBuffer, EXT);
476 GET_PROC_SUFFIX(GetFramebufferParameteriv, EXT);
477 GET_PROC_SUFFIX(NamedCopyBufferSubData, EXT);
478 GET_PROC_SUFFIX(VertexArrayVertexOffset, EXT);
479 GET_PROC_SUFFIX(VertexArrayColorOffset, EXT);
480 GET_PROC_SUFFIX(VertexArrayEdgeFlagOffset, EXT);
481 GET_PROC_SUFFIX(VertexArrayIndexOffset, EXT);
482 GET_PROC_SUFFIX(VertexArrayNormalOffset, EXT);
483 GET_PROC_SUFFIX(VertexArrayTexCoordOffset, EXT);
484 GET_PROC_SUFFIX(VertexArrayMultiTexCoordOffset, EXT);
485 GET_PROC_SUFFIX(VertexArrayFogCoordOffset, EXT);
486 GET_PROC_SUFFIX(VertexArraySecondaryColorOffset, EXT);
487 GET_PROC_SUFFIX(VertexArrayVertexAttribOffset, EXT);
488 GET_PROC_SUFFIX(VertexArrayVertexAttribIOffset, EXT);
489 GET_PROC_SUFFIX(EnableVertexArray, EXT);
490 GET_PROC_SUFFIX(DisableVertexArray, EXT);
491 GET_PROC_SUFFIX(EnableVertexArrayAttrib, EXT);
492 GET_PROC_SUFFIX(DisableVertexArrayAttrib, EXT);
493 GET_PROC_SUFFIX(GetVertexArrayIntegerv, EXT);
494 GET_PROC_SUFFIX(GetVertexArrayPointerv, EXT);
495 GET_PROC_SUFFIX(GetVertexArrayIntegeri_v, EXT);
496 GET_PROC_SUFFIX(GetVertexArrayPointeri_v, EXT);
497 GET_PROC_SUFFIX(MapNamedBufferRange, EXT);
498 GET_PROC_SUFFIX(FlushMappedNamedBufferRange, EXT);
499 }
cdaltonc04ce672016-03-11 14:07:38 -0800500 if (glVer >= GR_GL_VER(3,1)) {
501 GET_PROC_SUFFIX(TextureBuffer, EXT);
502 }
cdalton626e1ff2015-06-12 13:56:46 -0700503 }
504
505 if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_KHR_debug")) {
506 // KHR_debug defines these methods to have no suffix in an OpenGL (not ES) context.
507 GET_PROC(DebugMessageControl);
508 GET_PROC(DebugMessageInsert);
509 GET_PROC(DebugMessageCallback);
510 GET_PROC(GetDebugMessageLog);
511 GET_PROC(PushDebugGroup);
512 GET_PROC(PopDebugGroup);
513 GET_PROC(ObjectLabel);
514 }
515
csmartdalton9bc11872016-08-09 12:42:47 -0700516 if (extensions.has("GL_EXT_window_rectangles")) {
517 GET_PROC_SUFFIX(WindowRectangles, EXT);
518 }
519
bsalomonb1a32ad2015-11-16 06:48:44 -0800520 if (extensions.has("EGL_KHR_image") || extensions.has("EGL_KHR_image_base")) {
521 GET_EGL_PROC_SUFFIX(CreateImage, KHR);
522 GET_EGL_PROC_SUFFIX(DestroyImage, KHR);
523 }
524
ethannicholas28ef4452016-03-25 09:26:03 -0700525 if (glVer >= GR_GL_VER(4,0) || extensions.has("GL_ARB_sample_shading")) {
526 GET_PROC(MinSampleShading);
527 }
528
commit-bot@chromium.org9add5dc2014-04-29 20:06:22 +0000529 interface->fStandard = kGL_GrGLStandard;
530 interface->fExtensions.swap(&extensions);
531
532 return interface;
533}
bsalomona721c812014-08-26 11:35:23 -0700534
535const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
536 GET_PROC_LOCAL(GetString);
halcanary96fcdcc2015-08-27 07:41:13 -0700537 if (nullptr == GetString) {
538 return nullptr;
bsalomona721c812014-08-26 11:35:23 -0700539 }
540
541 const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION));
542 GrGLVersion version = GrGLGetVersionFromString(verStr);
543
544 if (version < GR_GL_VER(2,0)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700545 return nullptr;
bsalomona721c812014-08-26 11:35:23 -0700546 }
547
548 GET_PROC_LOCAL(GetIntegerv);
549 GET_PROC_LOCAL(GetStringi);
bsalomonb1a32ad2015-11-16 06:48:44 -0800550 GrEGLQueryStringProc queryString;
551 GrEGLDisplay display;
552 get_egl_query_and_display(&queryString, &display, ctx, get);
bsalomona721c812014-08-26 11:35:23 -0700553 GrGLExtensions extensions;
bsalomonb1a32ad2015-11-16 06:48:44 -0800554 if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString,
555 display)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700556 return nullptr;
bsalomona721c812014-08-26 11:35:23 -0700557 }
558
halcanary385fe4d2015-08-26 13:07:48 -0700559 GrGLInterface* interface = new GrGLInterface;
bsalomona721c812014-08-26 11:35:23 -0700560 GrGLInterface::Functions* functions = &interface->fFunctions;
561
562 GET_PROC(ActiveTexture);
563 GET_PROC(AttachShader);
564 GET_PROC(BindAttribLocation);
565 GET_PROC(BindBuffer);
566 GET_PROC(BindTexture);
567 GET_PROC_SUFFIX(BindVertexArray, OES);
cdaltonbae6f6c2015-04-22 10:39:03 -0700568
kkinnunend94708e2015-07-30 22:47:04 -0700569 if (version >= GR_GL_VER(3,0) && extensions.has("GL_EXT_blend_func_extended")) {
570 GET_PROC_SUFFIX(BindFragDataLocation, EXT);
571 GET_PROC_SUFFIX(BindFragDataLocationIndexed, EXT);
572 }
573
cdaltonbae6f6c2015-04-22 10:39:03 -0700574 if (extensions.has("GL_KHR_blend_equation_advanced")) {
575 GET_PROC_SUFFIX(BlendBarrier, KHR);
576 } else if (extensions.has("GL_NV_blend_equation_advanced")) {
577 GET_PROC_SUFFIX(BlendBarrier, NV);
578 }
579
bsalomona721c812014-08-26 11:35:23 -0700580 GET_PROC(BlendColor);
cdaltonbae6f6c2015-04-22 10:39:03 -0700581 GET_PROC(BlendEquation);
bsalomona721c812014-08-26 11:35:23 -0700582 GET_PROC(BlendFunc);
583 GET_PROC(BufferData);
584 GET_PROC(BufferSubData);
585 GET_PROC(Clear);
586 GET_PROC(ClearColor);
587 GET_PROC(ClearStencil);
588 GET_PROC(ColorMask);
589 GET_PROC(CompileShader);
590 GET_PROC(CompressedTexImage2D);
591 GET_PROC(CompressedTexSubImage2D);
592 GET_PROC(CopyTexSubImage2D);
593 GET_PROC(CreateProgram);
594 GET_PROC(CreateShader);
595 GET_PROC(CullFace);
596 GET_PROC(DeleteBuffers);
597 GET_PROC(DeleteProgram);
598 GET_PROC(DeleteShader);
599 GET_PROC(DeleteTextures);
600 GET_PROC_SUFFIX(DeleteVertexArrays, OES);
601 GET_PROC(DepthMask);
602 GET_PROC(Disable);
603 GET_PROC(DisableVertexAttribArray);
604 GET_PROC(DrawArrays);
cdalton06604b92016-02-05 10:09:51 -0800605
606 if (version >= GR_GL_VER(3,0)) {
607 GET_PROC(DrawArraysInstanced);
608 GET_PROC(DrawElementsInstanced);
609 } else if (extensions.has("GL_EXT_draw_instanced")) {
610 GET_PROC_SUFFIX(DrawArraysInstanced, EXT);
611 GET_PROC_SUFFIX(DrawElementsInstanced, EXT);
612 }
613
614 if (version >= GR_GL_VER(3,1)) {
615 GET_PROC(DrawArraysIndirect);
616 GET_PROC(DrawElementsIndirect);
617 }
618
bsalomona721c812014-08-26 11:35:23 -0700619 GET_PROC(DrawElements);
bsalomonfc9527a2016-08-29 09:18:39 -0700620 if (version >= GR_GL_VER(3,0)) {
621 GET_PROC(DrawRangeElements);
622 }
bsalomona721c812014-08-26 11:35:23 -0700623 GET_PROC(Enable);
624 GET_PROC(EnableVertexAttribArray);
625 GET_PROC(Finish);
626 GET_PROC(Flush);
627 GET_PROC(FrontFace);
628 GET_PROC(GenBuffers);
629 GET_PROC(GenerateMipmap);
630 GET_PROC(GenTextures);
631 GET_PROC_SUFFIX(GenVertexArrays, OES);
632 GET_PROC(GetBufferParameteriv);
633 GET_PROC(GetError);
634 GET_PROC(GetIntegerv);
cdaltoneb79eea2016-02-26 10:39:34 -0800635
636 if (version >= GR_GL_VER(3,1)) {
637 GET_PROC(GetMultisamplefv);
638 }
639
bsalomona721c812014-08-26 11:35:23 -0700640 GET_PROC(GetProgramInfoLog);
641 GET_PROC(GetProgramiv);
642 GET_PROC(GetShaderInfoLog);
bsalomonee64d6e2014-12-03 10:46:08 -0800643 GET_PROC(GetShaderPrecisionFormat);
bsalomona721c812014-08-26 11:35:23 -0700644 GET_PROC(GetShaderiv);
645 GET_PROC(GetString);
646 GET_PROC(GetStringi);
647 GET_PROC(GetUniformLocation);
bsalomon6dc6f5f2015-06-18 09:12:16 -0700648 GET_PROC(IsTexture);
bsalomona721c812014-08-26 11:35:23 -0700649 GET_PROC(LineWidth);
650 GET_PROC(LinkProgram);
csmartdalton5cebf8c2016-06-03 08:28:47 -0700651
652 if (extensions.has("GL_EXT_multi_draw_indirect")) {
653 GET_PROC_SUFFIX(MultiDrawArraysIndirect, EXT);
654 GET_PROC_SUFFIX(MultiDrawElementsIndirect, EXT);
655 }
656
bsalomona721c812014-08-26 11:35:23 -0700657 GET_PROC(PixelStorei);
cdalton0edea2c2015-05-21 08:27:44 -0700658
659 if (extensions.has("GL_EXT_raster_multisample")) {
660 GET_PROC_SUFFIX(RasterSamples, EXT);
661 }
662
bsalomona721c812014-08-26 11:35:23 -0700663 GET_PROC(ReadPixels);
664 GET_PROC(Scissor);
665 GET_PROC(ShaderSource);
666 GET_PROC(StencilFunc);
667 GET_PROC(StencilFuncSeparate);
668 GET_PROC(StencilMask);
669 GET_PROC(StencilMaskSeparate);
670 GET_PROC(StencilOp);
671 GET_PROC(StencilOpSeparate);
cdaltonc04ce672016-03-11 14:07:38 -0800672
673 if (version >= GR_GL_VER(3,2)) {
674 GET_PROC(TexBuffer);
cdaltonf8a6ce82016-04-11 13:02:05 -0700675 GET_PROC(TexBufferRange);
cdaltonc04ce672016-03-11 14:07:38 -0800676 } else if (extensions.has("GL_OES_texture_buffer")) {
677 GET_PROC_SUFFIX(TexBuffer, OES);
cdaltonf8a6ce82016-04-11 13:02:05 -0700678 GET_PROC_SUFFIX(TexBufferRange, OES);
cdaltonc04ce672016-03-11 14:07:38 -0800679 } else if (extensions.has("GL_EXT_texture_buffer")) {
680 GET_PROC_SUFFIX(TexBuffer, EXT);
cdaltonf8a6ce82016-04-11 13:02:05 -0700681 GET_PROC_SUFFIX(TexBufferRange, EXT);
cdaltonc04ce672016-03-11 14:07:38 -0800682 }
683
bsalomona721c812014-08-26 11:35:23 -0700684 GET_PROC(TexImage2D);
685 GET_PROC(TexParameteri);
686 GET_PROC(TexParameteriv);
687 GET_PROC(TexSubImage2D);
688
689 if (version >= GR_GL_VER(3,0)) {
690 GET_PROC(TexStorage2D);
691 } else {
692 GET_PROC_SUFFIX(TexStorage2D, EXT);
693 }
694
cdaltonfd4167d2015-04-21 11:45:56 -0700695 if (extensions.has("GL_NV_texture_barrier")) {
696 GET_PROC_SUFFIX(TextureBarrier, NV);
697 }
698
bsalomona721c812014-08-26 11:35:23 -0700699 GET_PROC_SUFFIX(DiscardFramebuffer, EXT);
700 GET_PROC(Uniform1f);
701 GET_PROC(Uniform1i);
702 GET_PROC(Uniform1fv);
703 GET_PROC(Uniform1iv);
704 GET_PROC(Uniform2f);
705 GET_PROC(Uniform2i);
706 GET_PROC(Uniform2fv);
707 GET_PROC(Uniform2iv);
708 GET_PROC(Uniform3f);
709 GET_PROC(Uniform3i);
710 GET_PROC(Uniform3fv);
711 GET_PROC(Uniform3iv);
712 GET_PROC(Uniform4f);
713 GET_PROC(Uniform4i);
714 GET_PROC(Uniform4fv);
715 GET_PROC(Uniform4iv);
716 GET_PROC(UniformMatrix2fv);
717 GET_PROC(UniformMatrix3fv);
718 GET_PROC(UniformMatrix4fv);
719 GET_PROC(UseProgram);
egdaniel27c15212014-10-24 15:00:50 -0700720 GET_PROC(VertexAttrib1f);
721 GET_PROC(VertexAttrib2fv);
722 GET_PROC(VertexAttrib3fv);
bsalomona721c812014-08-26 11:35:23 -0700723 GET_PROC(VertexAttrib4fv);
cdalton06604b92016-02-05 10:09:51 -0800724
725 if (version >= GR_GL_VER(3,0)) {
726 GET_PROC(VertexAttribDivisor);
727 } else if (extensions.has("GL_EXT_instanced_arrays")) {
728 GET_PROC_SUFFIX(VertexAttribDivisor, EXT);
729 }
730
cdalton793dc262016-02-08 10:11:47 -0800731 if (version >= GR_GL_VER(3,0)) {
732 GET_PROC(VertexAttribIPointer);
733 }
734
bsalomona721c812014-08-26 11:35:23 -0700735 GET_PROC(VertexAttribPointer);
736 GET_PROC(Viewport);
737 GET_PROC(BindFramebuffer);
738 GET_PROC(BindRenderbuffer);
739 GET_PROC(CheckFramebufferStatus);
740 GET_PROC(DeleteFramebuffers);
741 GET_PROC(DeleteRenderbuffers);
742 GET_PROC(FramebufferRenderbuffer);
743 GET_PROC(FramebufferTexture2D);
744
hendrikw1ae488f2015-07-22 09:30:08 -0700745 if (extensions.has("GL_CHROMIUM_framebuffer_multisample")) {
746 GET_PROC_SUFFIX(RenderbufferStorageMultisample, CHROMIUM);
747 GET_PROC_SUFFIX(BlitFramebuffer, CHROMIUM);
748 } else if (version >= GR_GL_VER(3,0)) {
bsalomona721c812014-08-26 11:35:23 -0700749 GET_PROC(RenderbufferStorageMultisample);
750 GET_PROC(BlitFramebuffer);
751 }
752
hendrikw1ae488f2015-07-22 09:30:08 -0700753 if (extensions.has("GL_CHROMIUM_map_sub")) {
754 GET_PROC_SUFFIX(MapBufferSubData, CHROMIUM);
755 GET_PROC_SUFFIX(MapTexSubImage2D, CHROMIUM);
756 GET_PROC_SUFFIX(UnmapBufferSubData, CHROMIUM);
757 GET_PROC_SUFFIX(UnmapTexSubImage2D, CHROMIUM);
758 }
759
bsalomona721c812014-08-26 11:35:23 -0700760 if (extensions.has("GL_EXT_multisampled_render_to_texture")) {
761 GET_PROC_SUFFIX(FramebufferTexture2DMultisample, EXT);
762 functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleEXT");
763 } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) {
764 GET_PROC_SUFFIX(FramebufferTexture2DMultisample, IMG);
765 functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleIMG");
766 } else if (extensions.has("GL_APPLE_framebuffer_multisample")) {
767 functions->fRenderbufferStorageMultisampleES2APPLE = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleAPPLE");
768 GET_PROC_SUFFIX(ResolveMultisampleFramebuffer, APPLE);
769 }
770
771 GET_PROC(GenFramebuffers);
772 GET_PROC(GenRenderbuffers);
773 GET_PROC(GetFramebufferAttachmentParameteriv);
774 GET_PROC(GetRenderbufferParameteriv);
775 GET_PROC(RenderbufferStorage);
776
777 GET_PROC_SUFFIX(MapBuffer, OES);
778 GET_PROC_SUFFIX(UnmapBuffer, OES);
779
780 if (version >= GR_GL_VER(3,0)) {
781 GET_PROC(MapBufferRange);
782 GET_PROC(FlushMappedBufferRange);
783 } else if (extensions.has("GL_EXT_map_buffer_range")) {
784 GET_PROC_SUFFIX(MapBufferRange, EXT);
785 GET_PROC_SUFFIX(FlushMappedBufferRange, EXT);
786 }
787
788 if (extensions.has("GL_EXT_debug_marker")) {
789 GET_PROC(InsertEventMarker);
790 GET_PROC(PushGroupMarker);
791 GET_PROC(PopGroupMarker);
792 // The below check is here because a device has been found that has the extension string but
halcanary96fcdcc2015-08-27 07:41:13 -0700793 // returns nullptr from the eglGetProcAddress for the functions
794 if (nullptr == functions->fInsertEventMarker ||
795 nullptr == functions->fPushGroupMarker ||
796 nullptr == functions->fPopGroupMarker) {
bsalomona721c812014-08-26 11:35:23 -0700797 extensions.remove("GL_EXT_debug_marker");
798 }
799 }
800
801 GET_PROC(InvalidateFramebuffer);
802 GET_PROC(InvalidateSubFramebuffer);
803 GET_PROC(InvalidateBufferData);
804 GET_PROC(InvalidateBufferSubData);
805 GET_PROC(InvalidateTexImage);
806 GET_PROC(InvalidateTexSubImage);
807
808 if (version >= GR_GL_VER(3,1)) {
809 GET_PROC(GetProgramResourceLocation);
810 }
811
812 if (extensions.has("GL_NV_path_rendering")) {
813 GET_PROC_SUFFIX(MatrixLoadf, EXT);
814 GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
815 GET_PROC_SUFFIX(PathCommands, NV);
bsalomona721c812014-08-26 11:35:23 -0700816 GET_PROC_SUFFIX(PathParameteri, NV);
817 GET_PROC_SUFFIX(PathParameterf, NV);
818 GET_PROC_SUFFIX(GenPaths, NV);
819 GET_PROC_SUFFIX(DeletePaths, NV);
820 GET_PROC_SUFFIX(IsPath, NV);
821 GET_PROC_SUFFIX(PathStencilFunc, NV);
822 GET_PROC_SUFFIX(StencilFillPath, NV);
823 GET_PROC_SUFFIX(StencilStrokePath, NV);
824 GET_PROC_SUFFIX(StencilFillPathInstanced, NV);
825 GET_PROC_SUFFIX(StencilStrokePathInstanced, NV);
826 GET_PROC_SUFFIX(CoverFillPath, NV);
827 GET_PROC_SUFFIX(CoverStrokePath, NV);
828 GET_PROC_SUFFIX(CoverFillPathInstanced, NV);
829 GET_PROC_SUFFIX(CoverStrokePathInstanced, NV);
830 GET_PROC_SUFFIX(StencilThenCoverFillPath, NV);
831 GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV);
832 GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV);
833 GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV);
834 GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV);
835 }
836
kkinnunen2ca29c02015-12-09 22:58:34 -0800837 if (extensions.has("GL_CHROMIUM_path_rendering")) {
838 GET_PROC_SUFFIX(MatrixLoadf, CHROMIUM);
839 GET_PROC_SUFFIX(MatrixLoadIdentity, CHROMIUM);
840 GET_PROC_SUFFIX(PathCommands, CHROMIUM);
841 GET_PROC_SUFFIX(PathParameteri, CHROMIUM);
842 GET_PROC_SUFFIX(PathParameterf, CHROMIUM);
843 GET_PROC_SUFFIX(GenPaths, CHROMIUM);
844 GET_PROC_SUFFIX(DeletePaths, CHROMIUM);
845 GET_PROC_SUFFIX(IsPath, CHROMIUM);
846 GET_PROC_SUFFIX(PathStencilFunc, CHROMIUM);
847 GET_PROC_SUFFIX(StencilFillPath, CHROMIUM);
848 GET_PROC_SUFFIX(StencilStrokePath, CHROMIUM);
849 GET_PROC_SUFFIX(StencilFillPathInstanced, CHROMIUM);
850 GET_PROC_SUFFIX(StencilStrokePathInstanced, CHROMIUM);
851 GET_PROC_SUFFIX(CoverFillPath, CHROMIUM);
852 GET_PROC_SUFFIX(CoverStrokePath, CHROMIUM);
853 GET_PROC_SUFFIX(CoverFillPathInstanced, CHROMIUM);
854 GET_PROC_SUFFIX(CoverStrokePathInstanced, CHROMIUM);
855 GET_PROC_SUFFIX(StencilThenCoverFillPath, CHROMIUM);
856 GET_PROC_SUFFIX(StencilThenCoverStrokePath, CHROMIUM);
857 GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, CHROMIUM);
858 GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, CHROMIUM);
859 GET_PROC_SUFFIX(ProgramPathFragmentInputGen, CHROMIUM);
860 // GL_CHROMIUM_path_rendering additions:
861 GET_PROC_SUFFIX(BindFragmentInputLocation, CHROMIUM);
862 }
863
vbuzinov08b4d292015-04-01 06:29:49 -0700864 if (extensions.has("GL_NV_framebuffer_mixed_samples")) {
865 GET_PROC_SUFFIX(CoverageModulation, NV);
866 }
kkinnunenea409432015-12-10 01:21:59 -0800867 if (extensions.has("GL_CHROMIUM_framebuffer_mixed_samples")) {
868 GET_PROC_SUFFIX(CoverageModulation, CHROMIUM);
869 }
vbuzinov08b4d292015-04-01 06:29:49 -0700870
cdalton626e1ff2015-06-12 13:56:46 -0700871 if (extensions.has("GL_NV_bindless_texture")) {
872 GET_PROC_SUFFIX(GetTextureHandle, NV);
873 GET_PROC_SUFFIX(GetTextureSamplerHandle, NV);
874 GET_PROC_SUFFIX(MakeTextureHandleResident, NV);
875 GET_PROC_SUFFIX(MakeTextureHandleNonResident, NV);
876 GET_PROC_SUFFIX(GetImageHandle, NV);
877 GET_PROC_SUFFIX(MakeImageHandleResident, NV);
878 GET_PROC_SUFFIX(MakeImageHandleNonResident, NV);
879 GET_PROC_SUFFIX(IsTextureHandleResident, NV);
880 GET_PROC_SUFFIX(IsImageHandleResident, NV);
881 GET_PROC_SUFFIX(UniformHandleui64, NV);
882 GET_PROC_SUFFIX(UniformHandleui64v, NV);
883 GET_PROC_SUFFIX(ProgramUniformHandleui64, NV);
884 GET_PROC_SUFFIX(ProgramUniformHandleui64v, NV);
885 }
886
887 if (extensions.has("GL_KHR_debug")) {
888 GET_PROC_SUFFIX(DebugMessageControl, KHR);
889 GET_PROC_SUFFIX(DebugMessageInsert, KHR);
890 GET_PROC_SUFFIX(DebugMessageCallback, KHR);
891 GET_PROC_SUFFIX(GetDebugMessageLog, KHR);
892 GET_PROC_SUFFIX(PushDebugGroup, KHR);
893 GET_PROC_SUFFIX(PopDebugGroup, KHR);
894 GET_PROC_SUFFIX(ObjectLabel, KHR);
bsalomondb9f6642015-10-02 08:34:28 -0700895 // In general we have a policy against removing extension strings when the driver does
896 // not provide function pointers for an advertised extension. However, because there is a
897 // known device that advertises GL_KHR_debug but fails to provide the functions and this is
898 // a debugging- only extension we've made an exception. This also can happen when using
899 // APITRACE.
900 if (!interface->fFunctions.fDebugMessageControl) {
901 extensions.remove("GL_KHR_debug");
902 }
cdalton626e1ff2015-06-12 13:56:46 -0700903 }
904
kkinnunen0adfffb2015-10-13 12:58:37 -0700905 if (extensions.has("GL_CHROMIUM_bind_uniform_location")) {
906 GET_PROC_SUFFIX(BindUniformLocation, CHROMIUM);
907 }
908
csmartdalton9bc11872016-08-09 12:42:47 -0700909 if (extensions.has("GL_EXT_window_rectangles")) {
910 GET_PROC_SUFFIX(WindowRectangles, EXT);
911 }
912
bsalomonb1a32ad2015-11-16 06:48:44 -0800913 if (extensions.has("EGL_KHR_image") || extensions.has("EGL_KHR_image_base")) {
914 GET_EGL_PROC_SUFFIX(CreateImage, KHR);
915 GET_EGL_PROC_SUFFIX(DestroyImage, KHR);
916 }
917
ethannicholas28ef4452016-03-25 09:26:03 -0700918 if (extensions.has("GL_OES_sample_shading")) {
919 GET_PROC_SUFFIX(MinSampleShading, OES);
920 }
921
bsalomona721c812014-08-26 11:35:23 -0700922 interface->fStandard = kGLES_GrGLStandard;
923 interface->fExtensions.swap(&extensions);
924
925 return interface;
926}