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 | |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 525 | if (glVer >= GR_GL_VER(4, 0) || extensions.has("GL_ARB_sample_shading")) { |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 526 | GET_PROC(MinSampleShading); |
| 527 | } |
| 528 | |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 529 | if (glVer >= GR_GL_VER(3, 2) || extensions.has("GL_ARB_sync")) { |
| 530 | GET_PROC(FenceSync); |
| 531 | GET_PROC(ClientWaitSync); |
| 532 | GET_PROC(DeleteSync); |
| 533 | } |
| 534 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 535 | interface->fStandard = kGL_GrGLStandard; |
| 536 | interface->fExtensions.swap(&extensions); |
| 537 | |
| 538 | return interface; |
| 539 | } |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 540 | |
| 541 | const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) { |
| 542 | GET_PROC_LOCAL(GetString); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 543 | if (nullptr == GetString) { |
| 544 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); |
| 548 | GrGLVersion version = GrGLGetVersionFromString(verStr); |
| 549 | |
| 550 | if (version < GR_GL_VER(2,0)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 551 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | GET_PROC_LOCAL(GetIntegerv); |
| 555 | GET_PROC_LOCAL(GetStringi); |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 556 | GrEGLQueryStringProc queryString; |
| 557 | GrEGLDisplay display; |
| 558 | get_egl_query_and_display(&queryString, &display, ctx, get); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 559 | GrGLExtensions extensions; |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 560 | if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, |
| 561 | display)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 562 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 563 | } |
| 564 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 565 | GrGLInterface* interface = new GrGLInterface; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 566 | GrGLInterface::Functions* functions = &interface->fFunctions; |
| 567 | |
| 568 | GET_PROC(ActiveTexture); |
| 569 | GET_PROC(AttachShader); |
| 570 | GET_PROC(BindAttribLocation); |
| 571 | GET_PROC(BindBuffer); |
| 572 | GET_PROC(BindTexture); |
| 573 | GET_PROC_SUFFIX(BindVertexArray, OES); |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 574 | |
kkinnunen | d94708e | 2015-07-30 22:47:04 -0700 | [diff] [blame] | 575 | if (version >= GR_GL_VER(3,0) && extensions.has("GL_EXT_blend_func_extended")) { |
| 576 | GET_PROC_SUFFIX(BindFragDataLocation, EXT); |
| 577 | GET_PROC_SUFFIX(BindFragDataLocationIndexed, EXT); |
| 578 | } |
| 579 | |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 580 | if (extensions.has("GL_KHR_blend_equation_advanced")) { |
| 581 | GET_PROC_SUFFIX(BlendBarrier, KHR); |
| 582 | } else if (extensions.has("GL_NV_blend_equation_advanced")) { |
| 583 | GET_PROC_SUFFIX(BlendBarrier, NV); |
| 584 | } |
| 585 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 586 | GET_PROC(BlendColor); |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 587 | GET_PROC(BlendEquation); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 588 | GET_PROC(BlendFunc); |
| 589 | GET_PROC(BufferData); |
| 590 | GET_PROC(BufferSubData); |
| 591 | GET_PROC(Clear); |
| 592 | GET_PROC(ClearColor); |
| 593 | GET_PROC(ClearStencil); |
| 594 | GET_PROC(ColorMask); |
| 595 | GET_PROC(CompileShader); |
| 596 | GET_PROC(CompressedTexImage2D); |
| 597 | GET_PROC(CompressedTexSubImage2D); |
| 598 | GET_PROC(CopyTexSubImage2D); |
| 599 | GET_PROC(CreateProgram); |
| 600 | GET_PROC(CreateShader); |
| 601 | GET_PROC(CullFace); |
| 602 | GET_PROC(DeleteBuffers); |
| 603 | GET_PROC(DeleteProgram); |
| 604 | GET_PROC(DeleteShader); |
| 605 | GET_PROC(DeleteTextures); |
| 606 | GET_PROC_SUFFIX(DeleteVertexArrays, OES); |
| 607 | GET_PROC(DepthMask); |
| 608 | GET_PROC(Disable); |
| 609 | GET_PROC(DisableVertexAttribArray); |
| 610 | GET_PROC(DrawArrays); |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 611 | |
| 612 | if (version >= GR_GL_VER(3,0)) { |
| 613 | GET_PROC(DrawArraysInstanced); |
| 614 | GET_PROC(DrawElementsInstanced); |
| 615 | } else if (extensions.has("GL_EXT_draw_instanced")) { |
| 616 | GET_PROC_SUFFIX(DrawArraysInstanced, EXT); |
| 617 | GET_PROC_SUFFIX(DrawElementsInstanced, EXT); |
| 618 | } |
| 619 | |
| 620 | if (version >= GR_GL_VER(3,1)) { |
| 621 | GET_PROC(DrawArraysIndirect); |
| 622 | GET_PROC(DrawElementsIndirect); |
| 623 | } |
| 624 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 625 | GET_PROC(DrawElements); |
bsalomon | fc9527a | 2016-08-29 09:18:39 -0700 | [diff] [blame] | 626 | if (version >= GR_GL_VER(3,0)) { |
| 627 | GET_PROC(DrawRangeElements); |
| 628 | } |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 629 | GET_PROC(Enable); |
| 630 | GET_PROC(EnableVertexAttribArray); |
| 631 | GET_PROC(Finish); |
| 632 | GET_PROC(Flush); |
| 633 | GET_PROC(FrontFace); |
| 634 | GET_PROC(GenBuffers); |
| 635 | GET_PROC(GenerateMipmap); |
| 636 | GET_PROC(GenTextures); |
| 637 | GET_PROC_SUFFIX(GenVertexArrays, OES); |
| 638 | GET_PROC(GetBufferParameteriv); |
| 639 | GET_PROC(GetError); |
| 640 | GET_PROC(GetIntegerv); |
cdalton | eb79eea | 2016-02-26 10:39:34 -0800 | [diff] [blame] | 641 | |
| 642 | if (version >= GR_GL_VER(3,1)) { |
| 643 | GET_PROC(GetMultisamplefv); |
| 644 | } |
| 645 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 646 | GET_PROC(GetProgramInfoLog); |
| 647 | GET_PROC(GetProgramiv); |
| 648 | GET_PROC(GetShaderInfoLog); |
bsalomon | ee64d6e | 2014-12-03 10:46:08 -0800 | [diff] [blame] | 649 | GET_PROC(GetShaderPrecisionFormat); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 650 | GET_PROC(GetShaderiv); |
| 651 | GET_PROC(GetString); |
| 652 | GET_PROC(GetStringi); |
| 653 | GET_PROC(GetUniformLocation); |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 654 | GET_PROC(IsTexture); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 655 | GET_PROC(LineWidth); |
| 656 | GET_PROC(LinkProgram); |
csmartdalton | 5cebf8c | 2016-06-03 08:28:47 -0700 | [diff] [blame] | 657 | |
| 658 | if (extensions.has("GL_EXT_multi_draw_indirect")) { |
| 659 | GET_PROC_SUFFIX(MultiDrawArraysIndirect, EXT); |
| 660 | GET_PROC_SUFFIX(MultiDrawElementsIndirect, EXT); |
| 661 | } |
| 662 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 663 | GET_PROC(PixelStorei); |
cdalton | 0edea2c | 2015-05-21 08:27:44 -0700 | [diff] [blame] | 664 | |
| 665 | if (extensions.has("GL_EXT_raster_multisample")) { |
| 666 | GET_PROC_SUFFIX(RasterSamples, EXT); |
| 667 | } |
| 668 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 669 | GET_PROC(ReadPixels); |
| 670 | GET_PROC(Scissor); |
| 671 | GET_PROC(ShaderSource); |
| 672 | GET_PROC(StencilFunc); |
| 673 | GET_PROC(StencilFuncSeparate); |
| 674 | GET_PROC(StencilMask); |
| 675 | GET_PROC(StencilMaskSeparate); |
| 676 | GET_PROC(StencilOp); |
| 677 | GET_PROC(StencilOpSeparate); |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 678 | |
| 679 | if (version >= GR_GL_VER(3,2)) { |
| 680 | GET_PROC(TexBuffer); |
cdalton | f8a6ce8 | 2016-04-11 13:02:05 -0700 | [diff] [blame] | 681 | GET_PROC(TexBufferRange); |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 682 | } else if (extensions.has("GL_OES_texture_buffer")) { |
| 683 | GET_PROC_SUFFIX(TexBuffer, OES); |
cdalton | f8a6ce8 | 2016-04-11 13:02:05 -0700 | [diff] [blame] | 684 | GET_PROC_SUFFIX(TexBufferRange, OES); |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 685 | } else if (extensions.has("GL_EXT_texture_buffer")) { |
| 686 | GET_PROC_SUFFIX(TexBuffer, EXT); |
cdalton | f8a6ce8 | 2016-04-11 13:02:05 -0700 | [diff] [blame] | 687 | GET_PROC_SUFFIX(TexBufferRange, EXT); |
cdalton | c04ce67 | 2016-03-11 14:07:38 -0800 | [diff] [blame] | 688 | } |
| 689 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 690 | GET_PROC(TexImage2D); |
| 691 | GET_PROC(TexParameteri); |
| 692 | GET_PROC(TexParameteriv); |
| 693 | GET_PROC(TexSubImage2D); |
| 694 | |
| 695 | if (version >= GR_GL_VER(3,0)) { |
| 696 | GET_PROC(TexStorage2D); |
| 697 | } else { |
| 698 | GET_PROC_SUFFIX(TexStorage2D, EXT); |
| 699 | } |
| 700 | |
cdalton | fd4167d | 2015-04-21 11:45:56 -0700 | [diff] [blame] | 701 | if (extensions.has("GL_NV_texture_barrier")) { |
| 702 | GET_PROC_SUFFIX(TextureBarrier, NV); |
| 703 | } |
| 704 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 705 | GET_PROC_SUFFIX(DiscardFramebuffer, EXT); |
| 706 | GET_PROC(Uniform1f); |
| 707 | GET_PROC(Uniform1i); |
| 708 | GET_PROC(Uniform1fv); |
| 709 | GET_PROC(Uniform1iv); |
| 710 | GET_PROC(Uniform2f); |
| 711 | GET_PROC(Uniform2i); |
| 712 | GET_PROC(Uniform2fv); |
| 713 | GET_PROC(Uniform2iv); |
| 714 | GET_PROC(Uniform3f); |
| 715 | GET_PROC(Uniform3i); |
| 716 | GET_PROC(Uniform3fv); |
| 717 | GET_PROC(Uniform3iv); |
| 718 | GET_PROC(Uniform4f); |
| 719 | GET_PROC(Uniform4i); |
| 720 | GET_PROC(Uniform4fv); |
| 721 | GET_PROC(Uniform4iv); |
| 722 | GET_PROC(UniformMatrix2fv); |
| 723 | GET_PROC(UniformMatrix3fv); |
| 724 | GET_PROC(UniformMatrix4fv); |
| 725 | GET_PROC(UseProgram); |
egdaniel | 27c1521 | 2014-10-24 15:00:50 -0700 | [diff] [blame] | 726 | GET_PROC(VertexAttrib1f); |
| 727 | GET_PROC(VertexAttrib2fv); |
| 728 | GET_PROC(VertexAttrib3fv); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 729 | GET_PROC(VertexAttrib4fv); |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 730 | |
| 731 | if (version >= GR_GL_VER(3,0)) { |
| 732 | GET_PROC(VertexAttribDivisor); |
| 733 | } else if (extensions.has("GL_EXT_instanced_arrays")) { |
| 734 | GET_PROC_SUFFIX(VertexAttribDivisor, EXT); |
| 735 | } |
| 736 | |
cdalton | 793dc26 | 2016-02-08 10:11:47 -0800 | [diff] [blame] | 737 | if (version >= GR_GL_VER(3,0)) { |
| 738 | GET_PROC(VertexAttribIPointer); |
| 739 | } |
| 740 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 741 | GET_PROC(VertexAttribPointer); |
| 742 | GET_PROC(Viewport); |
| 743 | GET_PROC(BindFramebuffer); |
| 744 | GET_PROC(BindRenderbuffer); |
| 745 | GET_PROC(CheckFramebufferStatus); |
| 746 | GET_PROC(DeleteFramebuffers); |
| 747 | GET_PROC(DeleteRenderbuffers); |
| 748 | GET_PROC(FramebufferRenderbuffer); |
| 749 | GET_PROC(FramebufferTexture2D); |
| 750 | |
Brian Salomon | c5eceb0 | 2016-10-18 10:21:43 -0400 | [diff] [blame^] | 751 | if (version >= GR_GL_VER(3,0)) { |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 752 | GET_PROC(RenderbufferStorageMultisample); |
| 753 | GET_PROC(BlitFramebuffer); |
Brian Salomon | c5eceb0 | 2016-10-18 10:21:43 -0400 | [diff] [blame^] | 754 | } else if (extensions.has("GL_CHROMIUM_framebuffer_multisample")) { |
| 755 | GET_PROC_SUFFIX(RenderbufferStorageMultisample, CHROMIUM); |
| 756 | GET_PROC_SUFFIX(BlitFramebuffer, CHROMIUM); |
| 757 | } else { |
| 758 | if (extensions.has("GL_ANGLE_framebuffer_multisample")) { |
| 759 | GET_PROC_SUFFIX(RenderbufferStorageMultisample, ANGLE); |
| 760 | } |
| 761 | if (extensions.has("GL_ANGLE_framebuffer_blit")) { |
| 762 | GET_PROC_SUFFIX(BlitFramebuffer, ANGLE); |
| 763 | } |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 764 | } |
| 765 | |
hendrikw | 1ae488f | 2015-07-22 09:30:08 -0700 | [diff] [blame] | 766 | if (extensions.has("GL_CHROMIUM_map_sub")) { |
| 767 | GET_PROC_SUFFIX(MapBufferSubData, CHROMIUM); |
| 768 | GET_PROC_SUFFIX(MapTexSubImage2D, CHROMIUM); |
| 769 | GET_PROC_SUFFIX(UnmapBufferSubData, CHROMIUM); |
| 770 | GET_PROC_SUFFIX(UnmapTexSubImage2D, CHROMIUM); |
| 771 | } |
| 772 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 773 | if (extensions.has("GL_EXT_multisampled_render_to_texture")) { |
| 774 | GET_PROC_SUFFIX(FramebufferTexture2DMultisample, EXT); |
| 775 | functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleEXT"); |
| 776 | } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) { |
| 777 | GET_PROC_SUFFIX(FramebufferTexture2DMultisample, IMG); |
| 778 | functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleIMG"); |
| 779 | } else if (extensions.has("GL_APPLE_framebuffer_multisample")) { |
| 780 | functions->fRenderbufferStorageMultisampleES2APPLE = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleAPPLE"); |
| 781 | GET_PROC_SUFFIX(ResolveMultisampleFramebuffer, APPLE); |
| 782 | } |
| 783 | |
| 784 | GET_PROC(GenFramebuffers); |
| 785 | GET_PROC(GenRenderbuffers); |
| 786 | GET_PROC(GetFramebufferAttachmentParameteriv); |
| 787 | GET_PROC(GetRenderbufferParameteriv); |
| 788 | GET_PROC(RenderbufferStorage); |
| 789 | |
| 790 | GET_PROC_SUFFIX(MapBuffer, OES); |
| 791 | GET_PROC_SUFFIX(UnmapBuffer, OES); |
| 792 | |
| 793 | if (version >= GR_GL_VER(3,0)) { |
| 794 | GET_PROC(MapBufferRange); |
| 795 | GET_PROC(FlushMappedBufferRange); |
| 796 | } else if (extensions.has("GL_EXT_map_buffer_range")) { |
| 797 | GET_PROC_SUFFIX(MapBufferRange, EXT); |
| 798 | GET_PROC_SUFFIX(FlushMappedBufferRange, EXT); |
| 799 | } |
| 800 | |
| 801 | if (extensions.has("GL_EXT_debug_marker")) { |
| 802 | GET_PROC(InsertEventMarker); |
| 803 | GET_PROC(PushGroupMarker); |
| 804 | GET_PROC(PopGroupMarker); |
| 805 | // 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] | 806 | // returns nullptr from the eglGetProcAddress for the functions |
| 807 | if (nullptr == functions->fInsertEventMarker || |
| 808 | nullptr == functions->fPushGroupMarker || |
| 809 | nullptr == functions->fPopGroupMarker) { |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 810 | extensions.remove("GL_EXT_debug_marker"); |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | GET_PROC(InvalidateFramebuffer); |
| 815 | GET_PROC(InvalidateSubFramebuffer); |
| 816 | GET_PROC(InvalidateBufferData); |
| 817 | GET_PROC(InvalidateBufferSubData); |
| 818 | GET_PROC(InvalidateTexImage); |
| 819 | GET_PROC(InvalidateTexSubImage); |
| 820 | |
| 821 | if (version >= GR_GL_VER(3,1)) { |
| 822 | GET_PROC(GetProgramResourceLocation); |
| 823 | } |
| 824 | |
| 825 | if (extensions.has("GL_NV_path_rendering")) { |
| 826 | GET_PROC_SUFFIX(MatrixLoadf, EXT); |
| 827 | GET_PROC_SUFFIX(MatrixLoadIdentity, EXT); |
| 828 | GET_PROC_SUFFIX(PathCommands, NV); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 829 | GET_PROC_SUFFIX(PathParameteri, NV); |
| 830 | GET_PROC_SUFFIX(PathParameterf, NV); |
| 831 | GET_PROC_SUFFIX(GenPaths, NV); |
| 832 | GET_PROC_SUFFIX(DeletePaths, NV); |
| 833 | GET_PROC_SUFFIX(IsPath, NV); |
| 834 | GET_PROC_SUFFIX(PathStencilFunc, NV); |
| 835 | GET_PROC_SUFFIX(StencilFillPath, NV); |
| 836 | GET_PROC_SUFFIX(StencilStrokePath, NV); |
| 837 | GET_PROC_SUFFIX(StencilFillPathInstanced, NV); |
| 838 | GET_PROC_SUFFIX(StencilStrokePathInstanced, NV); |
| 839 | GET_PROC_SUFFIX(CoverFillPath, NV); |
| 840 | GET_PROC_SUFFIX(CoverStrokePath, NV); |
| 841 | GET_PROC_SUFFIX(CoverFillPathInstanced, NV); |
| 842 | GET_PROC_SUFFIX(CoverStrokePathInstanced, NV); |
| 843 | GET_PROC_SUFFIX(StencilThenCoverFillPath, NV); |
| 844 | GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV); |
| 845 | GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV); |
| 846 | GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV); |
| 847 | GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV); |
| 848 | } |
| 849 | |
kkinnunen | 2ca29c0 | 2015-12-09 22:58:34 -0800 | [diff] [blame] | 850 | if (extensions.has("GL_CHROMIUM_path_rendering")) { |
| 851 | GET_PROC_SUFFIX(MatrixLoadf, CHROMIUM); |
| 852 | GET_PROC_SUFFIX(MatrixLoadIdentity, CHROMIUM); |
| 853 | GET_PROC_SUFFIX(PathCommands, CHROMIUM); |
| 854 | GET_PROC_SUFFIX(PathParameteri, CHROMIUM); |
| 855 | GET_PROC_SUFFIX(PathParameterf, CHROMIUM); |
| 856 | GET_PROC_SUFFIX(GenPaths, CHROMIUM); |
| 857 | GET_PROC_SUFFIX(DeletePaths, CHROMIUM); |
| 858 | GET_PROC_SUFFIX(IsPath, CHROMIUM); |
| 859 | GET_PROC_SUFFIX(PathStencilFunc, CHROMIUM); |
| 860 | GET_PROC_SUFFIX(StencilFillPath, CHROMIUM); |
| 861 | GET_PROC_SUFFIX(StencilStrokePath, CHROMIUM); |
| 862 | GET_PROC_SUFFIX(StencilFillPathInstanced, CHROMIUM); |
| 863 | GET_PROC_SUFFIX(StencilStrokePathInstanced, CHROMIUM); |
| 864 | GET_PROC_SUFFIX(CoverFillPath, CHROMIUM); |
| 865 | GET_PROC_SUFFIX(CoverStrokePath, CHROMIUM); |
| 866 | GET_PROC_SUFFIX(CoverFillPathInstanced, CHROMIUM); |
| 867 | GET_PROC_SUFFIX(CoverStrokePathInstanced, CHROMIUM); |
| 868 | GET_PROC_SUFFIX(StencilThenCoverFillPath, CHROMIUM); |
| 869 | GET_PROC_SUFFIX(StencilThenCoverStrokePath, CHROMIUM); |
| 870 | GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, CHROMIUM); |
| 871 | GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, CHROMIUM); |
| 872 | GET_PROC_SUFFIX(ProgramPathFragmentInputGen, CHROMIUM); |
| 873 | // GL_CHROMIUM_path_rendering additions: |
| 874 | GET_PROC_SUFFIX(BindFragmentInputLocation, CHROMIUM); |
| 875 | } |
| 876 | |
vbuzinov | 08b4d29 | 2015-04-01 06:29:49 -0700 | [diff] [blame] | 877 | if (extensions.has("GL_NV_framebuffer_mixed_samples")) { |
| 878 | GET_PROC_SUFFIX(CoverageModulation, NV); |
| 879 | } |
kkinnunen | ea40943 | 2015-12-10 01:21:59 -0800 | [diff] [blame] | 880 | if (extensions.has("GL_CHROMIUM_framebuffer_mixed_samples")) { |
| 881 | GET_PROC_SUFFIX(CoverageModulation, CHROMIUM); |
| 882 | } |
vbuzinov | 08b4d29 | 2015-04-01 06:29:49 -0700 | [diff] [blame] | 883 | |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 884 | if (extensions.has("GL_NV_bindless_texture")) { |
| 885 | GET_PROC_SUFFIX(GetTextureHandle, NV); |
| 886 | GET_PROC_SUFFIX(GetTextureSamplerHandle, NV); |
| 887 | GET_PROC_SUFFIX(MakeTextureHandleResident, NV); |
| 888 | GET_PROC_SUFFIX(MakeTextureHandleNonResident, NV); |
| 889 | GET_PROC_SUFFIX(GetImageHandle, NV); |
| 890 | GET_PROC_SUFFIX(MakeImageHandleResident, NV); |
| 891 | GET_PROC_SUFFIX(MakeImageHandleNonResident, NV); |
| 892 | GET_PROC_SUFFIX(IsTextureHandleResident, NV); |
| 893 | GET_PROC_SUFFIX(IsImageHandleResident, NV); |
| 894 | GET_PROC_SUFFIX(UniformHandleui64, NV); |
| 895 | GET_PROC_SUFFIX(UniformHandleui64v, NV); |
| 896 | GET_PROC_SUFFIX(ProgramUniformHandleui64, NV); |
| 897 | GET_PROC_SUFFIX(ProgramUniformHandleui64v, NV); |
| 898 | } |
| 899 | |
| 900 | if (extensions.has("GL_KHR_debug")) { |
| 901 | GET_PROC_SUFFIX(DebugMessageControl, KHR); |
| 902 | GET_PROC_SUFFIX(DebugMessageInsert, KHR); |
| 903 | GET_PROC_SUFFIX(DebugMessageCallback, KHR); |
| 904 | GET_PROC_SUFFIX(GetDebugMessageLog, KHR); |
| 905 | GET_PROC_SUFFIX(PushDebugGroup, KHR); |
| 906 | GET_PROC_SUFFIX(PopDebugGroup, KHR); |
| 907 | GET_PROC_SUFFIX(ObjectLabel, KHR); |
bsalomon | db9f664 | 2015-10-02 08:34:28 -0700 | [diff] [blame] | 908 | // In general we have a policy against removing extension strings when the driver does |
| 909 | // not provide function pointers for an advertised extension. However, because there is a |
| 910 | // known device that advertises GL_KHR_debug but fails to provide the functions and this is |
| 911 | // a debugging- only extension we've made an exception. This also can happen when using |
| 912 | // APITRACE. |
| 913 | if (!interface->fFunctions.fDebugMessageControl) { |
| 914 | extensions.remove("GL_KHR_debug"); |
| 915 | } |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 916 | } |
| 917 | |
kkinnunen | 0adfffb | 2015-10-13 12:58:37 -0700 | [diff] [blame] | 918 | if (extensions.has("GL_CHROMIUM_bind_uniform_location")) { |
| 919 | GET_PROC_SUFFIX(BindUniformLocation, CHROMIUM); |
| 920 | } |
| 921 | |
csmartdalton | 9bc1187 | 2016-08-09 12:42:47 -0700 | [diff] [blame] | 922 | if (extensions.has("GL_EXT_window_rectangles")) { |
| 923 | GET_PROC_SUFFIX(WindowRectangles, EXT); |
| 924 | } |
| 925 | |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 926 | if (extensions.has("EGL_KHR_image") || extensions.has("EGL_KHR_image_base")) { |
| 927 | GET_EGL_PROC_SUFFIX(CreateImage, KHR); |
| 928 | GET_EGL_PROC_SUFFIX(DestroyImage, KHR); |
| 929 | } |
| 930 | |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 931 | if (extensions.has("GL_OES_sample_shading")) { |
| 932 | GET_PROC_SUFFIX(MinSampleShading, OES); |
| 933 | } |
| 934 | |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 935 | if (version >= GR_GL_VER(3, 0)) { |
| 936 | GET_PROC(FenceSync); |
| 937 | GET_PROC(ClientWaitSync); |
| 938 | GET_PROC(DeleteSync); |
| 939 | } |
| 940 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 941 | interface->fStandard = kGLES_GrGLStandard; |
| 942 | interface->fExtensions.swap(&extensions); |
| 943 | |
| 944 | return interface; |
| 945 | } |