commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
bsalomon | 062bd86 | 2016-03-31 10:22:20 -0700 | [diff] [blame] | 9 | #include "gl/GrGLAssembleInterface.h" |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 10 | #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 | |
bsalomon | 7ea33f5 | 2015-11-22 14:51:00 -0800 | [diff] [blame] | 16 | #define GET_EGL_PROC_SUFFIX(F, S) functions->fEGL ## F = (GrEGL ## F ## Proc) get(ctx, "egl" #F #S) |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 17 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 18 | const GrGLInterface* GrGLAssembleInterface(void* ctx, GrGLGetProc get) { |
| 19 | GET_PROC_LOCAL(GetString); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 20 | if (nullptr == GetString) { |
| 21 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 25 | if (nullptr == verStr) { |
| 26 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 27 | } |
| 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 | } |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 36 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 37 | } |
| 38 | |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 39 | static 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.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 54 | const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) { |
| 55 | GET_PROC_LOCAL(GetString); |
| 56 | GET_PROC_LOCAL(GetStringi); |
| 57 | GET_PROC_LOCAL(GetIntegerv); |
| 58 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 59 | // GetStringi may be nullptr depending on the GL version. |
| 60 | if (nullptr == GetString || nullptr == GetIntegerv) { |
| 61 | return nullptr; |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | const char* versionString = (const char*) GetString(GR_GL_VERSION); |
| 65 | GrGLVersion glVer = GrGLGetVersionFromString(versionString); |
| 66 | |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 67 | if (glVer < GR_GL_VER(1,5) || GR_GL_INVALID_VER == glVer) { |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 68 | // We must have array and element_array buffer objects. |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 69 | return nullptr; |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 70 | } |
| 71 | |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 72 | GrEGLQueryStringProc queryString; |
| 73 | GrEGLDisplay display; |
| 74 | get_egl_query_and_display(&queryString, &display, ctx, get); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 75 | GrGLExtensions extensions; |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 76 | if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, |
| 77 | display)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 78 | return nullptr; |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 79 | } |
| 80 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 81 | GrGLInterface* interface = new GrGLInterface(); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 82 | 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); |
tomhudson | 2575f31 | 2015-04-21 14:16:53 -0700 | [diff] [blame] | 93 | |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 94 | 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); |
tomhudson | 2575f31 | 2015-04-21 14:16:53 -0700 | [diff] [blame] | 98 | } |
| 99 | |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 100 | 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.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 115 | 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); |
krajcevski | 37d20f7 | 2014-06-11 10:38:47 -0700 | [diff] [blame] | 123 | GET_PROC(CompressedTexSubImage2D); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 124 | 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); |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 140 | |
| 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 | |
csmartdalton | 5cebf8c | 2016-06-03 08:28:47 -0700 | [diff] [blame] | 147 | if (glVer >= GR_GL_VER(4,0) || extensions.has("GL_ARB_draw_indirect")) { |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 148 | GET_PROC(DrawArraysIndirect); |
| 149 | GET_PROC(DrawElementsIndirect); |
| 150 | } |
bsalomon | fc9527a | 2016-08-29 09:18:39 -0700 | [diff] [blame^] | 151 | if (glVer >= GR_GL_VER(2,0)) { |
| 152 | GET_PROC(DrawRangeElements); |
| 153 | } |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 154 | 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); |
cdalton | eb79eea | 2016-02-26 10:39:34 -0800 | [diff] [blame] | 165 | if (glVer >= GR_GL_VER(3,2) || extensions.has("GL_ARB_texture_multisample")) { |
| 166 | GET_PROC(GetMultisamplefv); |
| 167 | } |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 168 | 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); |
bsalomon | ee64d6e | 2014-12-03 10:46:08 -0800 | [diff] [blame] | 185 | GET_PROC(GetShaderPrecisionFormat); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 186 | GET_PROC(GetTexLevelParameteriv); |
| 187 | GET_PROC(GenQueries); |
| 188 | GET_PROC(GenTextures); |
| 189 | GET_PROC(GetUniformLocation); |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 190 | GET_PROC(IsTexture); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 191 | GET_PROC(LineWidth); |
| 192 | GET_PROC(LinkProgram); |
| 193 | GET_PROC(MapBuffer); |
csmartdalton | 5cebf8c | 2016-06-03 08:28:47 -0700 | [diff] [blame] | 194 | |
| 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.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 200 | GET_PROC(PixelStorei); |
cdalton | 0edea2c | 2015-05-21 08:27:44 -0700 | [diff] [blame] | 201 | if (extensions.has("GL_EXT_raster_multisample")) { |
| 202 | GET_PROC_SUFFIX(RasterSamples, EXT); |
| 203 | } |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 204 | 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); |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 214 | if (glVer >= GR_GL_VER(3,1)) { |
| 215 | GET_PROC(TexBuffer); |
| 216 | } |
cdalton | f8a6ce8 | 2016-04-11 13:02:05 -0700 | [diff] [blame] | 217 | if (glVer >= GR_GL_VER(4,3)) { |
| 218 | GET_PROC(TexBufferRange); |
| 219 | } |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 220 | 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); |
cdalton | fd4167d | 2015-04-21 11:45:56 -0700 | [diff] [blame] | 229 | 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.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 234 | 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); |
egdaniel | 27c1521 | 2014-10-24 15:00:50 -0700 | [diff] [blame] | 255 | GET_PROC(VertexAttrib1f); |
| 256 | GET_PROC(VertexAttrib2fv); |
| 257 | GET_PROC(VertexAttrib3fv); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 258 | GET_PROC(VertexAttrib4fv); |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 259 | |
| 260 | if (glVer >= GR_GL_VER(3,2) || extensions.has("GL_ARB_instanced_arrays")) { |
| 261 | GET_PROC(VertexAttribDivisor); |
| 262 | } |
| 263 | |
cdalton | 793dc26 | 2016-02-08 10:11:47 -0800 | [diff] [blame] | 264 | if (glVer >= GR_GL_VER(3,0)) { |
| 265 | GET_PROC(VertexAttribIPointer); |
| 266 | } |
| 267 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 268 | 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); |
tomhudson | 612e926 | 2014-11-24 11:22:36 -0800 | [diff] [blame] | 277 | } 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.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 281 | } |
| 282 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 283 | 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.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 288 | // 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; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 327 | return nullptr; |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | if (extensions.has("GL_NV_path_rendering")) { |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 331 | GET_PROC_SUFFIX(MatrixLoadf, EXT); |
| 332 | GET_PROC_SUFFIX(MatrixLoadIdentity, EXT); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 333 | GET_PROC_SUFFIX(PathCommands, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 334 | GET_PROC_SUFFIX(PathParameteri, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 335 | GET_PROC_SUFFIX(PathParameterf, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 336 | GET_PROC_SUFFIX(GenPaths, NV); |
| 337 | GET_PROC_SUFFIX(DeletePaths, NV); |
cdalton | 8dd90cb | 2014-07-17 09:28:36 -0700 | [diff] [blame] | 338 | GET_PROC_SUFFIX(IsPath, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 339 | GET_PROC_SUFFIX(PathStencilFunc, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 340 | 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.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 344 | GET_PROC_SUFFIX(CoverFillPath, NV); |
| 345 | GET_PROC_SUFFIX(CoverStrokePath, NV); |
| 346 | GET_PROC_SUFFIX(CoverFillPathInstanced, NV); |
| 347 | GET_PROC_SUFFIX(CoverStrokePathInstanced, NV); |
cdalton | c8f5204 | 2014-07-29 15:25:51 -0700 | [diff] [blame] | 348 | GET_PROC_SUFFIX(StencilThenCoverFillPath, NV); |
| 349 | GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV); |
| 350 | GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV); |
| 351 | GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV); |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 352 | GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 353 | } |
| 354 | |
vbuzinov | 08b4d29 | 2015-04-01 06:29:49 -0700 | [diff] [blame] | 355 | if (extensions.has("GL_NV_framebuffer_mixed_samples")) { |
| 356 | GET_PROC_SUFFIX(CoverageModulation, NV); |
| 357 | } |
| 358 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 359 | 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 | |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 374 | if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_program_interface_query")) { |
| 375 | GET_PROC(GetProgramResourceLocation); |
| 376 | } |
| 377 | |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 378 | 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 | } |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 500 | if (glVer >= GR_GL_VER(3,1)) { |
| 501 | GET_PROC_SUFFIX(TextureBuffer, EXT); |
| 502 | } |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 503 | } |
| 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 | |
csmartdalton | 9bc1187 | 2016-08-09 12:42:47 -0700 | [diff] [blame] | 516 | if (extensions.has("GL_EXT_window_rectangles")) { |
| 517 | GET_PROC_SUFFIX(WindowRectangles, EXT); |
| 518 | } |
| 519 | |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 520 | 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 | |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 525 | if (glVer >= GR_GL_VER(4,0) || extensions.has("GL_ARB_sample_shading")) { |
| 526 | GET_PROC(MinSampleShading); |
| 527 | } |
| 528 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 529 | interface->fStandard = kGL_GrGLStandard; |
| 530 | interface->fExtensions.swap(&extensions); |
| 531 | |
| 532 | return interface; |
| 533 | } |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 534 | |
| 535 | const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) { |
| 536 | GET_PROC_LOCAL(GetString); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 537 | if (nullptr == GetString) { |
| 538 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 539 | } |
| 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)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 545 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | GET_PROC_LOCAL(GetIntegerv); |
| 549 | GET_PROC_LOCAL(GetStringi); |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 550 | GrEGLQueryStringProc queryString; |
| 551 | GrEGLDisplay display; |
| 552 | get_egl_query_and_display(&queryString, &display, ctx, get); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 553 | GrGLExtensions extensions; |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 554 | if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, |
| 555 | display)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 556 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 557 | } |
| 558 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 559 | GrGLInterface* interface = new GrGLInterface; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 560 | 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); |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 568 | |
kkinnunen | d94708e | 2015-07-30 22:47:04 -0700 | [diff] [blame] | 569 | 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 | |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 574 | 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 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 580 | GET_PROC(BlendColor); |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 581 | GET_PROC(BlendEquation); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 582 | 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); |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 605 | |
| 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 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 619 | GET_PROC(DrawElements); |
bsalomon | fc9527a | 2016-08-29 09:18:39 -0700 | [diff] [blame^] | 620 | if (version >= GR_GL_VER(3,0)) { |
| 621 | GET_PROC(DrawRangeElements); |
| 622 | } |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 623 | 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); |
cdalton | eb79eea | 2016-02-26 10:39:34 -0800 | [diff] [blame] | 635 | |
| 636 | if (version >= GR_GL_VER(3,1)) { |
| 637 | GET_PROC(GetMultisamplefv); |
| 638 | } |
| 639 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 640 | GET_PROC(GetProgramInfoLog); |
| 641 | GET_PROC(GetProgramiv); |
| 642 | GET_PROC(GetShaderInfoLog); |
bsalomon | ee64d6e | 2014-12-03 10:46:08 -0800 | [diff] [blame] | 643 | GET_PROC(GetShaderPrecisionFormat); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 644 | GET_PROC(GetShaderiv); |
| 645 | GET_PROC(GetString); |
| 646 | GET_PROC(GetStringi); |
| 647 | GET_PROC(GetUniformLocation); |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 648 | GET_PROC(IsTexture); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 649 | GET_PROC(LineWidth); |
| 650 | GET_PROC(LinkProgram); |
csmartdalton | 5cebf8c | 2016-06-03 08:28:47 -0700 | [diff] [blame] | 651 | |
| 652 | if (extensions.has("GL_EXT_multi_draw_indirect")) { |
| 653 | GET_PROC_SUFFIX(MultiDrawArraysIndirect, EXT); |
| 654 | GET_PROC_SUFFIX(MultiDrawElementsIndirect, EXT); |
| 655 | } |
| 656 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 657 | GET_PROC(PixelStorei); |
cdalton | 0edea2c | 2015-05-21 08:27:44 -0700 | [diff] [blame] | 658 | |
| 659 | if (extensions.has("GL_EXT_raster_multisample")) { |
| 660 | GET_PROC_SUFFIX(RasterSamples, EXT); |
| 661 | } |
| 662 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 663 | 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); |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 672 | |
| 673 | if (version >= GR_GL_VER(3,2)) { |
| 674 | GET_PROC(TexBuffer); |
cdalton | f8a6ce8 | 2016-04-11 13:02:05 -0700 | [diff] [blame] | 675 | GET_PROC(TexBufferRange); |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 676 | } else if (extensions.has("GL_OES_texture_buffer")) { |
| 677 | GET_PROC_SUFFIX(TexBuffer, OES); |
cdalton | f8a6ce8 | 2016-04-11 13:02:05 -0700 | [diff] [blame] | 678 | GET_PROC_SUFFIX(TexBufferRange, OES); |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 679 | } else if (extensions.has("GL_EXT_texture_buffer")) { |
| 680 | GET_PROC_SUFFIX(TexBuffer, EXT); |
cdalton | f8a6ce8 | 2016-04-11 13:02:05 -0700 | [diff] [blame] | 681 | GET_PROC_SUFFIX(TexBufferRange, EXT); |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 682 | } |
| 683 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 684 | 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 | |
cdalton | fd4167d | 2015-04-21 11:45:56 -0700 | [diff] [blame] | 695 | if (extensions.has("GL_NV_texture_barrier")) { |
| 696 | GET_PROC_SUFFIX(TextureBarrier, NV); |
| 697 | } |
| 698 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 699 | 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); |
egdaniel | 27c1521 | 2014-10-24 15:00:50 -0700 | [diff] [blame] | 720 | GET_PROC(VertexAttrib1f); |
| 721 | GET_PROC(VertexAttrib2fv); |
| 722 | GET_PROC(VertexAttrib3fv); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 723 | GET_PROC(VertexAttrib4fv); |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 724 | |
| 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 | |
cdalton | 793dc26 | 2016-02-08 10:11:47 -0800 | [diff] [blame] | 731 | if (version >= GR_GL_VER(3,0)) { |
| 732 | GET_PROC(VertexAttribIPointer); |
| 733 | } |
| 734 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 735 | 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 | |
hendrikw | 1ae488f | 2015-07-22 09:30:08 -0700 | [diff] [blame] | 745 | 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)) { |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 749 | GET_PROC(RenderbufferStorageMultisample); |
| 750 | GET_PROC(BlitFramebuffer); |
| 751 | } |
| 752 | |
hendrikw | 1ae488f | 2015-07-22 09:30:08 -0700 | [diff] [blame] | 753 | 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 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 760 | 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 |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 793 | // returns nullptr from the eglGetProcAddress for the functions |
| 794 | if (nullptr == functions->fInsertEventMarker || |
| 795 | nullptr == functions->fPushGroupMarker || |
| 796 | nullptr == functions->fPopGroupMarker) { |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 797 | 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); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 816 | 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 | |
kkinnunen | 2ca29c0 | 2015-12-09 22:58:34 -0800 | [diff] [blame] | 837 | 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 | |
vbuzinov | 08b4d29 | 2015-04-01 06:29:49 -0700 | [diff] [blame] | 864 | if (extensions.has("GL_NV_framebuffer_mixed_samples")) { |
| 865 | GET_PROC_SUFFIX(CoverageModulation, NV); |
| 866 | } |
kkinnunen | ea40943 | 2015-12-10 01:21:59 -0800 | [diff] [blame] | 867 | if (extensions.has("GL_CHROMIUM_framebuffer_mixed_samples")) { |
| 868 | GET_PROC_SUFFIX(CoverageModulation, CHROMIUM); |
| 869 | } |
vbuzinov | 08b4d29 | 2015-04-01 06:29:49 -0700 | [diff] [blame] | 870 | |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 871 | 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); |
bsalomon | db9f664 | 2015-10-02 08:34:28 -0700 | [diff] [blame] | 895 | // 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 | } |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 903 | } |
| 904 | |
kkinnunen | 0adfffb | 2015-10-13 12:58:37 -0700 | [diff] [blame] | 905 | if (extensions.has("GL_CHROMIUM_bind_uniform_location")) { |
| 906 | GET_PROC_SUFFIX(BindUniformLocation, CHROMIUM); |
| 907 | } |
| 908 | |
csmartdalton | 9bc1187 | 2016-08-09 12:42:47 -0700 | [diff] [blame] | 909 | if (extensions.has("GL_EXT_window_rectangles")) { |
| 910 | GET_PROC_SUFFIX(WindowRectangles, EXT); |
| 911 | } |
| 912 | |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 913 | 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 | |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 918 | if (extensions.has("GL_OES_sample_shading")) { |
| 919 | GET_PROC_SUFFIX(MinSampleShading, OES); |
| 920 | } |
| 921 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 922 | interface->fStandard = kGLES_GrGLStandard; |
| 923 | interface->fExtensions.swap(&extensions); |
| 924 | |
| 925 | return interface; |
| 926 | } |