commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2014 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | #include "GrGLAssembleInterface.h" |
| 11 | #include "GrGLUtil.h" |
| 12 | |
| 13 | #define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F) |
| 14 | #define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F #S) |
| 15 | #define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl" #F) |
| 16 | |
bsalomon | 7ea33f5 | 2015-11-22 14:51:00 -0800 | [diff] [blame] | 17 | #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] | 18 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 19 | const GrGLInterface* GrGLAssembleInterface(void* ctx, GrGLGetProc get) { |
| 20 | GET_PROC_LOCAL(GetString); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 21 | if (nullptr == GetString) { |
| 22 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 26 | if (nullptr == verStr) { |
| 27 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); |
| 31 | |
| 32 | if (kGLES_GrGLStandard == standard) { |
| 33 | return GrGLAssembleGLESInterface(ctx, get); |
| 34 | } else if (kGL_GrGLStandard == standard) { |
| 35 | return GrGLAssembleGLInterface(ctx, get); |
| 36 | } |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 37 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 38 | } |
| 39 | |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 40 | static void get_egl_query_and_display(GrEGLQueryStringProc* queryString, GrEGLDisplay* display, |
| 41 | void* ctx, GrGLGetProc get) { |
| 42 | *queryString = (GrEGLQueryStringProc) get(ctx, "eglQueryString"); |
| 43 | *display = GR_EGL_NO_DISPLAY; |
| 44 | if (*queryString) { |
| 45 | GrEGLGetCurrentDisplayProc getCurrentDisplay = |
| 46 | (GrEGLGetCurrentDisplayProc) get(ctx, "eglGetCurrentDisplay"); |
| 47 | if (getCurrentDisplay) { |
| 48 | *display = getCurrentDisplay(); |
| 49 | } else { |
| 50 | *queryString = nullptr; |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 55 | const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) { |
| 56 | GET_PROC_LOCAL(GetString); |
| 57 | GET_PROC_LOCAL(GetStringi); |
| 58 | GET_PROC_LOCAL(GetIntegerv); |
| 59 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 60 | // GetStringi may be nullptr depending on the GL version. |
| 61 | if (nullptr == GetString || nullptr == GetIntegerv) { |
| 62 | return nullptr; |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | const char* versionString = (const char*) GetString(GR_GL_VERSION); |
| 66 | GrGLVersion glVer = GrGLGetVersionFromString(versionString); |
| 67 | |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 68 | 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] | 69 | // We must have array and element_array buffer objects. |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 70 | return nullptr; |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 71 | } |
| 72 | |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 73 | GrEGLQueryStringProc queryString; |
| 74 | GrEGLDisplay display; |
| 75 | get_egl_query_and_display(&queryString, &display, ctx, get); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 76 | GrGLExtensions extensions; |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 77 | if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, |
| 78 | display)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 79 | return nullptr; |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 80 | } |
| 81 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 82 | GrGLInterface* interface = new GrGLInterface(); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 83 | GrGLInterface::Functions* functions = &interface->fFunctions; |
| 84 | |
| 85 | GET_PROC(ActiveTexture); |
| 86 | GET_PROC(AttachShader); |
| 87 | GET_PROC(BindAttribLocation); |
| 88 | GET_PROC(BindBuffer); |
| 89 | if (glVer >= GR_GL_VER(3,0)) { |
| 90 | GET_PROC(BindFragDataLocation); |
| 91 | } |
| 92 | GET_PROC(BeginQuery); |
| 93 | GET_PROC(BindTexture); |
tomhudson | 2575f31 | 2015-04-21 14:16:53 -0700 | [diff] [blame] | 94 | |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 95 | if (extensions.has("GL_KHR_blend_equation_advanced")) { |
| 96 | GET_PROC_SUFFIX(BlendBarrier, KHR); |
| 97 | } else if (extensions.has("GL_NV_blend_equation_advanced")) { |
| 98 | GET_PROC_SUFFIX(BlendBarrier, NV); |
tomhudson | 2575f31 | 2015-04-21 14:16:53 -0700 | [diff] [blame] | 99 | } |
| 100 | |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 101 | if (glVer >= GR_GL_VER(1,4) || |
| 102 | extensions.has("GL_ARB_imaging")) { |
| 103 | GET_PROC(BlendColor); |
| 104 | } else if (extensions.has("GL_EXT_blend_color")) { |
| 105 | GET_PROC_SUFFIX(BlendColor, EXT); |
| 106 | } |
| 107 | |
| 108 | if (glVer >= GR_GL_VER(1,4) || |
| 109 | extensions.has("GL_ARB_imaging")) { |
| 110 | GET_PROC(BlendEquation); |
| 111 | } else if (extensions.has("GL_EXT_blend_subtract")) { |
| 112 | GET_PROC_SUFFIX(BlendEquation, EXT); |
| 113 | } |
| 114 | |
| 115 | GET_PROC(BlendFunc); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 116 | GET_PROC(BufferData); |
| 117 | GET_PROC(BufferSubData); |
| 118 | GET_PROC(Clear); |
| 119 | GET_PROC(ClearColor); |
| 120 | GET_PROC(ClearStencil); |
| 121 | GET_PROC(ColorMask); |
| 122 | GET_PROC(CompileShader); |
| 123 | GET_PROC(CompressedTexImage2D); |
krajcevski | 37d20f7 | 2014-06-11 10:38:47 -0700 | [diff] [blame] | 124 | GET_PROC(CompressedTexSubImage2D); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 125 | GET_PROC(CopyTexSubImage2D); |
| 126 | GET_PROC(CreateProgram); |
| 127 | GET_PROC(CreateShader); |
| 128 | GET_PROC(CullFace); |
| 129 | GET_PROC(DeleteBuffers); |
| 130 | GET_PROC(DeleteProgram); |
| 131 | GET_PROC(DeleteQueries); |
| 132 | GET_PROC(DeleteShader); |
| 133 | GET_PROC(DeleteTextures); |
| 134 | GET_PROC(DepthMask); |
| 135 | GET_PROC(Disable); |
| 136 | GET_PROC(DisableVertexAttribArray); |
| 137 | GET_PROC(DrawArrays); |
| 138 | GET_PROC(DrawBuffer); |
| 139 | GET_PROC(DrawBuffers); |
| 140 | GET_PROC(DrawElements); |
| 141 | GET_PROC(Enable); |
| 142 | GET_PROC(EnableVertexAttribArray); |
| 143 | GET_PROC(EndQuery); |
| 144 | GET_PROC(Finish); |
| 145 | GET_PROC(Flush); |
| 146 | GET_PROC(FrontFace); |
| 147 | GET_PROC(GenBuffers); |
| 148 | GET_PROC(GenerateMipmap); |
| 149 | GET_PROC(GetBufferParameteriv); |
| 150 | GET_PROC(GetError); |
| 151 | GET_PROC(GetIntegerv); |
| 152 | GET_PROC(GetQueryObjectiv); |
| 153 | GET_PROC(GetQueryObjectuiv); |
| 154 | if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { |
| 155 | GET_PROC(GetQueryObjecti64v); |
| 156 | GET_PROC(GetQueryObjectui64v); |
| 157 | GET_PROC(QueryCounter); |
| 158 | } else if (extensions.has("GL_EXT_timer_query")) { |
| 159 | GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); |
| 160 | GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); |
| 161 | } |
| 162 | GET_PROC(GetQueryiv); |
| 163 | GET_PROC(GetProgramInfoLog); |
| 164 | GET_PROC(GetProgramiv); |
| 165 | GET_PROC(GetShaderInfoLog); |
| 166 | GET_PROC(GetShaderiv); |
| 167 | GET_PROC(GetString); |
| 168 | GET_PROC(GetStringi); |
bsalomon | ee64d6e | 2014-12-03 10:46:08 -0800 | [diff] [blame] | 169 | GET_PROC(GetShaderPrecisionFormat); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 170 | GET_PROC(GetTexLevelParameteriv); |
| 171 | GET_PROC(GenQueries); |
| 172 | GET_PROC(GenTextures); |
| 173 | GET_PROC(GetUniformLocation); |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 174 | GET_PROC(IsTexture); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 175 | GET_PROC(LineWidth); |
| 176 | GET_PROC(LinkProgram); |
| 177 | GET_PROC(MapBuffer); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 178 | GET_PROC(PixelStorei); |
cdalton | 0edea2c | 2015-05-21 08:27:44 -0700 | [diff] [blame] | 179 | if (extensions.has("GL_EXT_raster_multisample")) { |
| 180 | GET_PROC_SUFFIX(RasterSamples, EXT); |
| 181 | } |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 182 | GET_PROC(ReadBuffer); |
| 183 | GET_PROC(ReadPixels); |
| 184 | GET_PROC(Scissor); |
| 185 | GET_PROC(ShaderSource); |
| 186 | GET_PROC(StencilFunc); |
| 187 | GET_PROC(StencilFuncSeparate); |
| 188 | GET_PROC(StencilMask); |
| 189 | GET_PROC(StencilMaskSeparate); |
| 190 | GET_PROC(StencilOp); |
| 191 | GET_PROC(StencilOpSeparate); |
| 192 | GET_PROC(TexImage2D); |
| 193 | GET_PROC(TexParameteri); |
| 194 | GET_PROC(TexParameteriv); |
| 195 | if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { |
| 196 | GET_PROC(TexStorage2D); |
| 197 | } else if (extensions.has("GL_EXT_texture_storage")) { |
| 198 | GET_PROC_SUFFIX(TexStorage2D, EXT); |
| 199 | } |
| 200 | GET_PROC(TexSubImage2D); |
cdalton | fd4167d | 2015-04-21 11:45:56 -0700 | [diff] [blame] | 201 | if (glVer >= GR_GL_VER(4,5) || extensions.has("GL_ARB_texture_barrier")) { |
| 202 | GET_PROC(TextureBarrier); |
| 203 | } else if (extensions.has("GL_NV_texture_barrier")) { |
| 204 | GET_PROC_SUFFIX(TextureBarrier, NV); |
| 205 | } |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 206 | GET_PROC(Uniform1f); |
| 207 | GET_PROC(Uniform1i); |
| 208 | GET_PROC(Uniform1fv); |
| 209 | GET_PROC(Uniform1iv); |
| 210 | GET_PROC(Uniform2f); |
| 211 | GET_PROC(Uniform2i); |
| 212 | GET_PROC(Uniform2fv); |
| 213 | GET_PROC(Uniform2iv); |
| 214 | GET_PROC(Uniform3f); |
| 215 | GET_PROC(Uniform3i); |
| 216 | GET_PROC(Uniform3fv); |
| 217 | GET_PROC(Uniform3iv); |
| 218 | GET_PROC(Uniform4f); |
| 219 | GET_PROC(Uniform4i); |
| 220 | GET_PROC(Uniform4fv); |
| 221 | GET_PROC(Uniform4iv); |
| 222 | GET_PROC(UniformMatrix2fv); |
| 223 | GET_PROC(UniformMatrix3fv); |
| 224 | GET_PROC(UniformMatrix4fv); |
| 225 | GET_PROC(UnmapBuffer); |
| 226 | GET_PROC(UseProgram); |
egdaniel | 27c1521 | 2014-10-24 15:00:50 -0700 | [diff] [blame] | 227 | GET_PROC(VertexAttrib1f); |
| 228 | GET_PROC(VertexAttrib2fv); |
| 229 | GET_PROC(VertexAttrib3fv); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 230 | GET_PROC(VertexAttrib4fv); |
| 231 | GET_PROC(VertexAttribPointer); |
| 232 | GET_PROC(Viewport); |
| 233 | GET_PROC(BindFragDataLocationIndexed); |
| 234 | |
| 235 | if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) { |
| 236 | // no ARB suffix for GL_ARB_vertex_array_object |
| 237 | GET_PROC(BindVertexArray); |
| 238 | GET_PROC(GenVertexArrays); |
| 239 | GET_PROC(DeleteVertexArrays); |
tomhudson | 612e926 | 2014-11-24 11:22:36 -0800 | [diff] [blame] | 240 | } else if (extensions.has("GL_APPLE_vertex_array_object")) { |
| 241 | GET_PROC_SUFFIX(BindVertexArray, APPLE); |
| 242 | GET_PROC_SUFFIX(GenVertexArrays, APPLE); |
| 243 | GET_PROC_SUFFIX(DeleteVertexArrays, APPLE); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 244 | } |
| 245 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 246 | if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_map_buffer_range")) { |
| 247 | GET_PROC(MapBufferRange); |
| 248 | GET_PROC(FlushMappedBufferRange); |
| 249 | } |
| 250 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 251 | // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since |
| 252 | // GL_ARB_framebuffer_object doesn't use ARB suffix.) |
| 253 | if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { |
| 254 | GET_PROC(GenFramebuffers); |
| 255 | GET_PROC(GetFramebufferAttachmentParameteriv); |
| 256 | GET_PROC(GetRenderbufferParameteriv); |
| 257 | GET_PROC(BindFramebuffer); |
| 258 | GET_PROC(FramebufferTexture2D); |
| 259 | GET_PROC(CheckFramebufferStatus); |
| 260 | GET_PROC(DeleteFramebuffers); |
| 261 | GET_PROC(RenderbufferStorage); |
| 262 | GET_PROC(GenRenderbuffers); |
| 263 | GET_PROC(DeleteRenderbuffers); |
| 264 | GET_PROC(FramebufferRenderbuffer); |
| 265 | GET_PROC(BindRenderbuffer); |
| 266 | GET_PROC(RenderbufferStorageMultisample); |
| 267 | GET_PROC(BlitFramebuffer); |
| 268 | } else if (extensions.has("GL_EXT_framebuffer_object")) { |
| 269 | GET_PROC_SUFFIX(GenFramebuffers, EXT); |
| 270 | GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); |
| 271 | GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); |
| 272 | GET_PROC_SUFFIX(BindFramebuffer, EXT); |
| 273 | GET_PROC_SUFFIX(FramebufferTexture2D, EXT); |
| 274 | GET_PROC_SUFFIX(CheckFramebufferStatus, EXT); |
| 275 | GET_PROC_SUFFIX(DeleteFramebuffers, EXT); |
| 276 | GET_PROC_SUFFIX(RenderbufferStorage, EXT); |
| 277 | GET_PROC_SUFFIX(GenRenderbuffers, EXT); |
| 278 | GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); |
| 279 | GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); |
| 280 | GET_PROC_SUFFIX(BindRenderbuffer, EXT); |
| 281 | if (extensions.has("GL_EXT_framebuffer_multisample")) { |
| 282 | GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); |
| 283 | } |
| 284 | if (extensions.has("GL_EXT_framebuffer_blit")) { |
| 285 | GET_PROC_SUFFIX(BlitFramebuffer, EXT); |
| 286 | } |
| 287 | } else { |
| 288 | // we must have FBOs |
| 289 | delete interface; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 290 | return nullptr; |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | if (extensions.has("GL_NV_path_rendering")) { |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 294 | GET_PROC_SUFFIX(MatrixLoadf, EXT); |
| 295 | GET_PROC_SUFFIX(MatrixLoadIdentity, EXT); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 296 | GET_PROC_SUFFIX(PathCommands, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 297 | GET_PROC_SUFFIX(PathParameteri, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 298 | GET_PROC_SUFFIX(PathParameterf, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 299 | GET_PROC_SUFFIX(GenPaths, NV); |
| 300 | GET_PROC_SUFFIX(DeletePaths, NV); |
cdalton | 8dd90cb | 2014-07-17 09:28:36 -0700 | [diff] [blame] | 301 | GET_PROC_SUFFIX(IsPath, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 302 | GET_PROC_SUFFIX(PathStencilFunc, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 303 | GET_PROC_SUFFIX(StencilFillPath, NV); |
| 304 | GET_PROC_SUFFIX(StencilStrokePath, NV); |
| 305 | GET_PROC_SUFFIX(StencilFillPathInstanced, NV); |
| 306 | GET_PROC_SUFFIX(StencilStrokePathInstanced, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 307 | GET_PROC_SUFFIX(CoverFillPath, NV); |
| 308 | GET_PROC_SUFFIX(CoverStrokePath, NV); |
| 309 | GET_PROC_SUFFIX(CoverFillPathInstanced, NV); |
| 310 | GET_PROC_SUFFIX(CoverStrokePathInstanced, NV); |
cdalton | c8f5204 | 2014-07-29 15:25:51 -0700 | [diff] [blame] | 311 | GET_PROC_SUFFIX(StencilThenCoverFillPath, NV); |
| 312 | GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV); |
| 313 | GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV); |
| 314 | GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV); |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 315 | GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 316 | } |
| 317 | |
vbuzinov | 08b4d29 | 2015-04-01 06:29:49 -0700 | [diff] [blame] | 318 | if (extensions.has("GL_NV_framebuffer_mixed_samples")) { |
| 319 | GET_PROC_SUFFIX(CoverageModulation, NV); |
| 320 | } |
| 321 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 322 | if (extensions.has("GL_EXT_debug_marker")) { |
| 323 | GET_PROC_SUFFIX(InsertEventMarker, EXT); |
| 324 | GET_PROC_SUFFIX(PushGroupMarker, EXT); |
| 325 | GET_PROC_SUFFIX(PopGroupMarker, EXT); |
| 326 | } |
| 327 | |
| 328 | if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) { |
| 329 | GET_PROC(InvalidateBufferData); |
| 330 | GET_PROC(InvalidateBufferSubData); |
| 331 | GET_PROC(InvalidateFramebuffer); |
| 332 | GET_PROC(InvalidateSubFramebuffer); |
| 333 | GET_PROC(InvalidateTexImage); |
| 334 | GET_PROC(InvalidateTexSubImage); |
| 335 | } |
| 336 | |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 337 | if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_program_interface_query")) { |
| 338 | GET_PROC(GetProgramResourceLocation); |
| 339 | } |
| 340 | |
hendrikw | b3f1636 | 2015-10-19 06:13:55 -0700 | [diff] [blame] | 341 | if (glVer >= GR_GL_VER(3,1) || extensions.has("GL_ARB_draw_instanced") || |
| 342 | extensions.has("GL_EXT_draw_instanced")) { |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 343 | GET_PROC(DrawArraysInstanced); |
| 344 | GET_PROC(DrawElementsInstanced); |
| 345 | } |
| 346 | |
| 347 | if (glVer >= GR_GL_VER(3,2) || extensions.has("GL_ARB_instanced_arrays")) { |
| 348 | GET_PROC(VertexAttribDivisor); |
| 349 | } |
| 350 | |
| 351 | if (extensions.has("GL_NV_bindless_texture")) { |
| 352 | GET_PROC_SUFFIX(GetTextureHandle, NV); |
| 353 | GET_PROC_SUFFIX(GetTextureSamplerHandle, NV); |
| 354 | GET_PROC_SUFFIX(MakeTextureHandleResident, NV); |
| 355 | GET_PROC_SUFFIX(MakeTextureHandleNonResident, NV); |
| 356 | GET_PROC_SUFFIX(GetImageHandle, NV); |
| 357 | GET_PROC_SUFFIX(MakeImageHandleResident, NV); |
| 358 | GET_PROC_SUFFIX(MakeImageHandleNonResident, NV); |
| 359 | GET_PROC_SUFFIX(IsTextureHandleResident, NV); |
| 360 | GET_PROC_SUFFIX(IsImageHandleResident, NV); |
| 361 | GET_PROC_SUFFIX(UniformHandleui64, NV); |
| 362 | GET_PROC_SUFFIX(UniformHandleui64v, NV); |
| 363 | GET_PROC_SUFFIX(ProgramUniformHandleui64, NV); |
| 364 | GET_PROC_SUFFIX(ProgramUniformHandleui64v, NV); |
| 365 | } |
| 366 | |
| 367 | if (extensions.has("GL_EXT_direct_state_access")) { |
| 368 | GET_PROC_SUFFIX(TextureParameteri, EXT); |
| 369 | GET_PROC_SUFFIX(TextureParameteriv, EXT); |
| 370 | GET_PROC_SUFFIX(TextureParameterf, EXT); |
| 371 | GET_PROC_SUFFIX(TextureParameterfv, EXT); |
| 372 | GET_PROC_SUFFIX(TextureImage1D, EXT); |
| 373 | GET_PROC_SUFFIX(TextureImage2D, EXT); |
| 374 | GET_PROC_SUFFIX(TextureSubImage1D, EXT); |
| 375 | GET_PROC_SUFFIX(TextureSubImage2D, EXT); |
| 376 | GET_PROC_SUFFIX(CopyTextureImage1D, EXT); |
| 377 | GET_PROC_SUFFIX(CopyTextureImage2D, EXT); |
| 378 | GET_PROC_SUFFIX(CopyTextureSubImage1D, EXT); |
| 379 | GET_PROC_SUFFIX(CopyTextureSubImage2D, EXT); |
| 380 | GET_PROC_SUFFIX(GetTextureImage, EXT); |
| 381 | GET_PROC_SUFFIX(GetTextureParameterfv, EXT); |
| 382 | GET_PROC_SUFFIX(GetTextureParameteriv, EXT); |
| 383 | GET_PROC_SUFFIX(GetTextureLevelParameterfv, EXT); |
| 384 | GET_PROC_SUFFIX(GetTextureLevelParameteriv, EXT); |
| 385 | if (glVer >= GR_GL_VER(1,2)) { |
| 386 | GET_PROC_SUFFIX(TextureImage3D, EXT); |
| 387 | GET_PROC_SUFFIX(TextureSubImage3D, EXT); |
| 388 | GET_PROC_SUFFIX(CopyTextureSubImage3D, EXT); |
| 389 | GET_PROC_SUFFIX(CompressedTextureImage3D, EXT); |
| 390 | GET_PROC_SUFFIX(CompressedTextureImage2D, EXT); |
| 391 | GET_PROC_SUFFIX(CompressedTextureImage1D, EXT); |
| 392 | GET_PROC_SUFFIX(CompressedTextureSubImage3D, EXT); |
| 393 | GET_PROC_SUFFIX(CompressedTextureSubImage2D, EXT); |
| 394 | GET_PROC_SUFFIX(CompressedTextureSubImage1D, EXT); |
| 395 | GET_PROC_SUFFIX(GetCompressedTextureImage, EXT); |
| 396 | } |
| 397 | if (glVer >= GR_GL_VER(1,5)) { |
| 398 | GET_PROC_SUFFIX(NamedBufferData, EXT); |
| 399 | GET_PROC_SUFFIX(NamedBufferSubData, EXT); |
| 400 | GET_PROC_SUFFIX(MapNamedBuffer, EXT); |
| 401 | GET_PROC_SUFFIX(UnmapNamedBuffer, EXT); |
| 402 | GET_PROC_SUFFIX(GetNamedBufferParameteriv, EXT); |
| 403 | GET_PROC_SUFFIX(GetNamedBufferPointerv, EXT); |
| 404 | GET_PROC_SUFFIX(GetNamedBufferSubData, EXT); |
| 405 | } |
| 406 | if (glVer >= GR_GL_VER(2,0)) { |
| 407 | GET_PROC_SUFFIX(ProgramUniform1f, EXT); |
| 408 | GET_PROC_SUFFIX(ProgramUniform2f, EXT); |
| 409 | GET_PROC_SUFFIX(ProgramUniform3f, EXT); |
| 410 | GET_PROC_SUFFIX(ProgramUniform4f, EXT); |
| 411 | GET_PROC_SUFFIX(ProgramUniform1i, EXT); |
| 412 | GET_PROC_SUFFIX(ProgramUniform2i, EXT); |
| 413 | GET_PROC_SUFFIX(ProgramUniform3i, EXT); |
| 414 | GET_PROC_SUFFIX(ProgramUniform4i, EXT); |
| 415 | GET_PROC_SUFFIX(ProgramUniform1fv, EXT); |
| 416 | GET_PROC_SUFFIX(ProgramUniform2fv, EXT); |
| 417 | GET_PROC_SUFFIX(ProgramUniform3fv, EXT); |
| 418 | GET_PROC_SUFFIX(ProgramUniform4fv, EXT); |
| 419 | GET_PROC_SUFFIX(ProgramUniform1iv, EXT); |
| 420 | GET_PROC_SUFFIX(ProgramUniform2iv, EXT); |
| 421 | GET_PROC_SUFFIX(ProgramUniform3iv, EXT); |
| 422 | GET_PROC_SUFFIX(ProgramUniform4iv, EXT); |
| 423 | GET_PROC_SUFFIX(ProgramUniformMatrix2fv, EXT); |
| 424 | GET_PROC_SUFFIX(ProgramUniformMatrix3fv, EXT); |
| 425 | GET_PROC_SUFFIX(ProgramUniformMatrix4fv, EXT); |
| 426 | } |
| 427 | if (glVer >= GR_GL_VER(2,1)) { |
| 428 | GET_PROC_SUFFIX(ProgramUniformMatrix2x3fv, EXT); |
| 429 | GET_PROC_SUFFIX(ProgramUniformMatrix3x2fv, EXT); |
| 430 | GET_PROC_SUFFIX(ProgramUniformMatrix2x4fv, EXT); |
| 431 | GET_PROC_SUFFIX(ProgramUniformMatrix4x2fv, EXT); |
| 432 | GET_PROC_SUFFIX(ProgramUniformMatrix3x4fv, EXT); |
| 433 | GET_PROC_SUFFIX(ProgramUniformMatrix4x3fv, EXT); |
| 434 | } |
| 435 | if (glVer >= GR_GL_VER(3,0)) { |
| 436 | GET_PROC_SUFFIX(NamedRenderbufferStorage, EXT); |
| 437 | GET_PROC_SUFFIX(GetNamedRenderbufferParameteriv, EXT); |
| 438 | GET_PROC_SUFFIX(NamedRenderbufferStorageMultisample, EXT); |
| 439 | GET_PROC_SUFFIX(CheckNamedFramebufferStatus, EXT); |
| 440 | GET_PROC_SUFFIX(NamedFramebufferTexture1D, EXT); |
| 441 | GET_PROC_SUFFIX(NamedFramebufferTexture2D, EXT); |
| 442 | GET_PROC_SUFFIX(NamedFramebufferTexture3D, EXT); |
| 443 | GET_PROC_SUFFIX(NamedFramebufferRenderbuffer, EXT); |
| 444 | GET_PROC_SUFFIX(GetNamedFramebufferAttachmentParameteriv, EXT); |
| 445 | GET_PROC_SUFFIX(GenerateTextureMipmap, EXT); |
| 446 | GET_PROC_SUFFIX(FramebufferDrawBuffer, EXT); |
| 447 | GET_PROC_SUFFIX(FramebufferDrawBuffers, EXT); |
| 448 | GET_PROC_SUFFIX(FramebufferReadBuffer, EXT); |
| 449 | GET_PROC_SUFFIX(GetFramebufferParameteriv, EXT); |
| 450 | GET_PROC_SUFFIX(NamedCopyBufferSubData, EXT); |
| 451 | GET_PROC_SUFFIX(VertexArrayVertexOffset, EXT); |
| 452 | GET_PROC_SUFFIX(VertexArrayColorOffset, EXT); |
| 453 | GET_PROC_SUFFIX(VertexArrayEdgeFlagOffset, EXT); |
| 454 | GET_PROC_SUFFIX(VertexArrayIndexOffset, EXT); |
| 455 | GET_PROC_SUFFIX(VertexArrayNormalOffset, EXT); |
| 456 | GET_PROC_SUFFIX(VertexArrayTexCoordOffset, EXT); |
| 457 | GET_PROC_SUFFIX(VertexArrayMultiTexCoordOffset, EXT); |
| 458 | GET_PROC_SUFFIX(VertexArrayFogCoordOffset, EXT); |
| 459 | GET_PROC_SUFFIX(VertexArraySecondaryColorOffset, EXT); |
| 460 | GET_PROC_SUFFIX(VertexArrayVertexAttribOffset, EXT); |
| 461 | GET_PROC_SUFFIX(VertexArrayVertexAttribIOffset, EXT); |
| 462 | GET_PROC_SUFFIX(EnableVertexArray, EXT); |
| 463 | GET_PROC_SUFFIX(DisableVertexArray, EXT); |
| 464 | GET_PROC_SUFFIX(EnableVertexArrayAttrib, EXT); |
| 465 | GET_PROC_SUFFIX(DisableVertexArrayAttrib, EXT); |
| 466 | GET_PROC_SUFFIX(GetVertexArrayIntegerv, EXT); |
| 467 | GET_PROC_SUFFIX(GetVertexArrayPointerv, EXT); |
| 468 | GET_PROC_SUFFIX(GetVertexArrayIntegeri_v, EXT); |
| 469 | GET_PROC_SUFFIX(GetVertexArrayPointeri_v, EXT); |
| 470 | GET_PROC_SUFFIX(MapNamedBufferRange, EXT); |
| 471 | GET_PROC_SUFFIX(FlushMappedNamedBufferRange, EXT); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_KHR_debug")) { |
| 476 | // KHR_debug defines these methods to have no suffix in an OpenGL (not ES) context. |
| 477 | GET_PROC(DebugMessageControl); |
| 478 | GET_PROC(DebugMessageInsert); |
| 479 | GET_PROC(DebugMessageCallback); |
| 480 | GET_PROC(GetDebugMessageLog); |
| 481 | GET_PROC(PushDebugGroup); |
| 482 | GET_PROC(PopDebugGroup); |
| 483 | GET_PROC(ObjectLabel); |
| 484 | } |
| 485 | |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 486 | if (extensions.has("EGL_KHR_image") || extensions.has("EGL_KHR_image_base")) { |
| 487 | GET_EGL_PROC_SUFFIX(CreateImage, KHR); |
| 488 | GET_EGL_PROC_SUFFIX(DestroyImage, KHR); |
| 489 | } |
| 490 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 491 | interface->fStandard = kGL_GrGLStandard; |
| 492 | interface->fExtensions.swap(&extensions); |
| 493 | |
| 494 | return interface; |
| 495 | } |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 496 | |
| 497 | const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) { |
| 498 | GET_PROC_LOCAL(GetString); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 499 | if (nullptr == GetString) { |
| 500 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); |
| 504 | GrGLVersion version = GrGLGetVersionFromString(verStr); |
| 505 | |
| 506 | if (version < GR_GL_VER(2,0)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 507 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | GET_PROC_LOCAL(GetIntegerv); |
| 511 | GET_PROC_LOCAL(GetStringi); |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 512 | GrEGLQueryStringProc queryString; |
| 513 | GrEGLDisplay display; |
| 514 | get_egl_query_and_display(&queryString, &display, ctx, get); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 515 | GrGLExtensions extensions; |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 516 | if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, |
| 517 | display)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 518 | return nullptr; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 519 | } |
| 520 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 521 | GrGLInterface* interface = new GrGLInterface; |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 522 | GrGLInterface::Functions* functions = &interface->fFunctions; |
| 523 | |
| 524 | GET_PROC(ActiveTexture); |
| 525 | GET_PROC(AttachShader); |
| 526 | GET_PROC(BindAttribLocation); |
| 527 | GET_PROC(BindBuffer); |
| 528 | GET_PROC(BindTexture); |
| 529 | GET_PROC_SUFFIX(BindVertexArray, OES); |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 530 | |
kkinnunen | d94708e | 2015-07-30 22:47:04 -0700 | [diff] [blame] | 531 | if (version >= GR_GL_VER(3,0) && extensions.has("GL_EXT_blend_func_extended")) { |
| 532 | GET_PROC_SUFFIX(BindFragDataLocation, EXT); |
| 533 | GET_PROC_SUFFIX(BindFragDataLocationIndexed, EXT); |
| 534 | } |
| 535 | |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 536 | if (extensions.has("GL_KHR_blend_equation_advanced")) { |
| 537 | GET_PROC_SUFFIX(BlendBarrier, KHR); |
| 538 | } else if (extensions.has("GL_NV_blend_equation_advanced")) { |
| 539 | GET_PROC_SUFFIX(BlendBarrier, NV); |
| 540 | } |
| 541 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 542 | GET_PROC(BlendColor); |
cdalton | bae6f6c | 2015-04-22 10:39:03 -0700 | [diff] [blame] | 543 | GET_PROC(BlendEquation); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 544 | GET_PROC(BlendFunc); |
| 545 | GET_PROC(BufferData); |
| 546 | GET_PROC(BufferSubData); |
| 547 | GET_PROC(Clear); |
| 548 | GET_PROC(ClearColor); |
| 549 | GET_PROC(ClearStencil); |
| 550 | GET_PROC(ColorMask); |
| 551 | GET_PROC(CompileShader); |
| 552 | GET_PROC(CompressedTexImage2D); |
| 553 | GET_PROC(CompressedTexSubImage2D); |
| 554 | GET_PROC(CopyTexSubImage2D); |
| 555 | GET_PROC(CreateProgram); |
| 556 | GET_PROC(CreateShader); |
| 557 | GET_PROC(CullFace); |
| 558 | GET_PROC(DeleteBuffers); |
| 559 | GET_PROC(DeleteProgram); |
| 560 | GET_PROC(DeleteShader); |
| 561 | GET_PROC(DeleteTextures); |
| 562 | GET_PROC_SUFFIX(DeleteVertexArrays, OES); |
| 563 | GET_PROC(DepthMask); |
| 564 | GET_PROC(Disable); |
| 565 | GET_PROC(DisableVertexAttribArray); |
| 566 | GET_PROC(DrawArrays); |
| 567 | GET_PROC(DrawElements); |
| 568 | GET_PROC(Enable); |
| 569 | GET_PROC(EnableVertexAttribArray); |
| 570 | GET_PROC(Finish); |
| 571 | GET_PROC(Flush); |
| 572 | GET_PROC(FrontFace); |
| 573 | GET_PROC(GenBuffers); |
| 574 | GET_PROC(GenerateMipmap); |
| 575 | GET_PROC(GenTextures); |
| 576 | GET_PROC_SUFFIX(GenVertexArrays, OES); |
| 577 | GET_PROC(GetBufferParameteriv); |
| 578 | GET_PROC(GetError); |
| 579 | GET_PROC(GetIntegerv); |
| 580 | GET_PROC(GetProgramInfoLog); |
| 581 | GET_PROC(GetProgramiv); |
| 582 | GET_PROC(GetShaderInfoLog); |
bsalomon | ee64d6e | 2014-12-03 10:46:08 -0800 | [diff] [blame] | 583 | GET_PROC(GetShaderPrecisionFormat); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 584 | GET_PROC(GetShaderiv); |
| 585 | GET_PROC(GetString); |
| 586 | GET_PROC(GetStringi); |
| 587 | GET_PROC(GetUniformLocation); |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 588 | GET_PROC(IsTexture); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 589 | GET_PROC(LineWidth); |
| 590 | GET_PROC(LinkProgram); |
| 591 | GET_PROC(PixelStorei); |
cdalton | 0edea2c | 2015-05-21 08:27:44 -0700 | [diff] [blame] | 592 | |
| 593 | if (extensions.has("GL_EXT_raster_multisample")) { |
| 594 | GET_PROC_SUFFIX(RasterSamples, EXT); |
| 595 | } |
| 596 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 597 | GET_PROC(ReadPixels); |
| 598 | GET_PROC(Scissor); |
| 599 | GET_PROC(ShaderSource); |
| 600 | GET_PROC(StencilFunc); |
| 601 | GET_PROC(StencilFuncSeparate); |
| 602 | GET_PROC(StencilMask); |
| 603 | GET_PROC(StencilMaskSeparate); |
| 604 | GET_PROC(StencilOp); |
| 605 | GET_PROC(StencilOpSeparate); |
| 606 | GET_PROC(TexImage2D); |
| 607 | GET_PROC(TexParameteri); |
| 608 | GET_PROC(TexParameteriv); |
| 609 | GET_PROC(TexSubImage2D); |
| 610 | |
| 611 | if (version >= GR_GL_VER(3,0)) { |
| 612 | GET_PROC(TexStorage2D); |
| 613 | } else { |
| 614 | GET_PROC_SUFFIX(TexStorage2D, EXT); |
| 615 | } |
| 616 | |
cdalton | fd4167d | 2015-04-21 11:45:56 -0700 | [diff] [blame] | 617 | if (extensions.has("GL_NV_texture_barrier")) { |
| 618 | GET_PROC_SUFFIX(TextureBarrier, NV); |
| 619 | } |
| 620 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 621 | GET_PROC_SUFFIX(DiscardFramebuffer, EXT); |
| 622 | GET_PROC(Uniform1f); |
| 623 | GET_PROC(Uniform1i); |
| 624 | GET_PROC(Uniform1fv); |
| 625 | GET_PROC(Uniform1iv); |
| 626 | GET_PROC(Uniform2f); |
| 627 | GET_PROC(Uniform2i); |
| 628 | GET_PROC(Uniform2fv); |
| 629 | GET_PROC(Uniform2iv); |
| 630 | GET_PROC(Uniform3f); |
| 631 | GET_PROC(Uniform3i); |
| 632 | GET_PROC(Uniform3fv); |
| 633 | GET_PROC(Uniform3iv); |
| 634 | GET_PROC(Uniform4f); |
| 635 | GET_PROC(Uniform4i); |
| 636 | GET_PROC(Uniform4fv); |
| 637 | GET_PROC(Uniform4iv); |
| 638 | GET_PROC(UniformMatrix2fv); |
| 639 | GET_PROC(UniformMatrix3fv); |
| 640 | GET_PROC(UniformMatrix4fv); |
| 641 | GET_PROC(UseProgram); |
egdaniel | 27c1521 | 2014-10-24 15:00:50 -0700 | [diff] [blame] | 642 | GET_PROC(VertexAttrib1f); |
| 643 | GET_PROC(VertexAttrib2fv); |
| 644 | GET_PROC(VertexAttrib3fv); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 645 | GET_PROC(VertexAttrib4fv); |
| 646 | GET_PROC(VertexAttribPointer); |
| 647 | GET_PROC(Viewport); |
| 648 | GET_PROC(BindFramebuffer); |
| 649 | GET_PROC(BindRenderbuffer); |
| 650 | GET_PROC(CheckFramebufferStatus); |
| 651 | GET_PROC(DeleteFramebuffers); |
| 652 | GET_PROC(DeleteRenderbuffers); |
| 653 | GET_PROC(FramebufferRenderbuffer); |
| 654 | GET_PROC(FramebufferTexture2D); |
| 655 | |
hendrikw | 1ae488f | 2015-07-22 09:30:08 -0700 | [diff] [blame] | 656 | if (extensions.has("GL_CHROMIUM_framebuffer_multisample")) { |
| 657 | GET_PROC_SUFFIX(RenderbufferStorageMultisample, CHROMIUM); |
| 658 | GET_PROC_SUFFIX(BlitFramebuffer, CHROMIUM); |
| 659 | } else if (version >= GR_GL_VER(3,0)) { |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 660 | GET_PROC(RenderbufferStorageMultisample); |
| 661 | GET_PROC(BlitFramebuffer); |
| 662 | } |
| 663 | |
hendrikw | 1ae488f | 2015-07-22 09:30:08 -0700 | [diff] [blame] | 664 | if (extensions.has("GL_CHROMIUM_map_sub")) { |
| 665 | GET_PROC_SUFFIX(MapBufferSubData, CHROMIUM); |
| 666 | GET_PROC_SUFFIX(MapTexSubImage2D, CHROMIUM); |
| 667 | GET_PROC_SUFFIX(UnmapBufferSubData, CHROMIUM); |
| 668 | GET_PROC_SUFFIX(UnmapTexSubImage2D, CHROMIUM); |
| 669 | } |
| 670 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 671 | if (extensions.has("GL_EXT_multisampled_render_to_texture")) { |
| 672 | GET_PROC_SUFFIX(FramebufferTexture2DMultisample, EXT); |
| 673 | functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleEXT"); |
| 674 | } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) { |
| 675 | GET_PROC_SUFFIX(FramebufferTexture2DMultisample, IMG); |
| 676 | functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleIMG"); |
| 677 | } else if (extensions.has("GL_APPLE_framebuffer_multisample")) { |
| 678 | functions->fRenderbufferStorageMultisampleES2APPLE = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleAPPLE"); |
| 679 | GET_PROC_SUFFIX(ResolveMultisampleFramebuffer, APPLE); |
| 680 | } |
| 681 | |
| 682 | GET_PROC(GenFramebuffers); |
| 683 | GET_PROC(GenRenderbuffers); |
| 684 | GET_PROC(GetFramebufferAttachmentParameteriv); |
| 685 | GET_PROC(GetRenderbufferParameteriv); |
| 686 | GET_PROC(RenderbufferStorage); |
| 687 | |
| 688 | GET_PROC_SUFFIX(MapBuffer, OES); |
| 689 | GET_PROC_SUFFIX(UnmapBuffer, OES); |
| 690 | |
| 691 | if (version >= GR_GL_VER(3,0)) { |
| 692 | GET_PROC(MapBufferRange); |
| 693 | GET_PROC(FlushMappedBufferRange); |
| 694 | } else if (extensions.has("GL_EXT_map_buffer_range")) { |
| 695 | GET_PROC_SUFFIX(MapBufferRange, EXT); |
| 696 | GET_PROC_SUFFIX(FlushMappedBufferRange, EXT); |
| 697 | } |
| 698 | |
| 699 | if (extensions.has("GL_EXT_debug_marker")) { |
| 700 | GET_PROC(InsertEventMarker); |
| 701 | GET_PROC(PushGroupMarker); |
| 702 | GET_PROC(PopGroupMarker); |
| 703 | // 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] | 704 | // returns nullptr from the eglGetProcAddress for the functions |
| 705 | if (nullptr == functions->fInsertEventMarker || |
| 706 | nullptr == functions->fPushGroupMarker || |
| 707 | nullptr == functions->fPopGroupMarker) { |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 708 | extensions.remove("GL_EXT_debug_marker"); |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | GET_PROC(InvalidateFramebuffer); |
| 713 | GET_PROC(InvalidateSubFramebuffer); |
| 714 | GET_PROC(InvalidateBufferData); |
| 715 | GET_PROC(InvalidateBufferSubData); |
| 716 | GET_PROC(InvalidateTexImage); |
| 717 | GET_PROC(InvalidateTexSubImage); |
| 718 | |
| 719 | if (version >= GR_GL_VER(3,1)) { |
| 720 | GET_PROC(GetProgramResourceLocation); |
| 721 | } |
| 722 | |
| 723 | if (extensions.has("GL_NV_path_rendering")) { |
| 724 | GET_PROC_SUFFIX(MatrixLoadf, EXT); |
| 725 | GET_PROC_SUFFIX(MatrixLoadIdentity, EXT); |
| 726 | GET_PROC_SUFFIX(PathCommands, NV); |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 727 | GET_PROC_SUFFIX(PathParameteri, NV); |
| 728 | GET_PROC_SUFFIX(PathParameterf, NV); |
| 729 | GET_PROC_SUFFIX(GenPaths, NV); |
| 730 | GET_PROC_SUFFIX(DeletePaths, NV); |
| 731 | GET_PROC_SUFFIX(IsPath, NV); |
| 732 | GET_PROC_SUFFIX(PathStencilFunc, NV); |
| 733 | GET_PROC_SUFFIX(StencilFillPath, NV); |
| 734 | GET_PROC_SUFFIX(StencilStrokePath, NV); |
| 735 | GET_PROC_SUFFIX(StencilFillPathInstanced, NV); |
| 736 | GET_PROC_SUFFIX(StencilStrokePathInstanced, NV); |
| 737 | GET_PROC_SUFFIX(CoverFillPath, NV); |
| 738 | GET_PROC_SUFFIX(CoverStrokePath, NV); |
| 739 | GET_PROC_SUFFIX(CoverFillPathInstanced, NV); |
| 740 | GET_PROC_SUFFIX(CoverStrokePathInstanced, NV); |
| 741 | GET_PROC_SUFFIX(StencilThenCoverFillPath, NV); |
| 742 | GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV); |
| 743 | GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV); |
| 744 | GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV); |
| 745 | GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV); |
| 746 | } |
| 747 | |
kkinnunen | 2ca29c0 | 2015-12-09 22:58:34 -0800 | [diff] [blame] | 748 | if (extensions.has("GL_CHROMIUM_path_rendering")) { |
| 749 | GET_PROC_SUFFIX(MatrixLoadf, CHROMIUM); |
| 750 | GET_PROC_SUFFIX(MatrixLoadIdentity, CHROMIUM); |
| 751 | GET_PROC_SUFFIX(PathCommands, CHROMIUM); |
| 752 | GET_PROC_SUFFIX(PathParameteri, CHROMIUM); |
| 753 | GET_PROC_SUFFIX(PathParameterf, CHROMIUM); |
| 754 | GET_PROC_SUFFIX(GenPaths, CHROMIUM); |
| 755 | GET_PROC_SUFFIX(DeletePaths, CHROMIUM); |
| 756 | GET_PROC_SUFFIX(IsPath, CHROMIUM); |
| 757 | GET_PROC_SUFFIX(PathStencilFunc, CHROMIUM); |
| 758 | GET_PROC_SUFFIX(StencilFillPath, CHROMIUM); |
| 759 | GET_PROC_SUFFIX(StencilStrokePath, CHROMIUM); |
| 760 | GET_PROC_SUFFIX(StencilFillPathInstanced, CHROMIUM); |
| 761 | GET_PROC_SUFFIX(StencilStrokePathInstanced, CHROMIUM); |
| 762 | GET_PROC_SUFFIX(CoverFillPath, CHROMIUM); |
| 763 | GET_PROC_SUFFIX(CoverStrokePath, CHROMIUM); |
| 764 | GET_PROC_SUFFIX(CoverFillPathInstanced, CHROMIUM); |
| 765 | GET_PROC_SUFFIX(CoverStrokePathInstanced, CHROMIUM); |
| 766 | GET_PROC_SUFFIX(StencilThenCoverFillPath, CHROMIUM); |
| 767 | GET_PROC_SUFFIX(StencilThenCoverStrokePath, CHROMIUM); |
| 768 | GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, CHROMIUM); |
| 769 | GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, CHROMIUM); |
| 770 | GET_PROC_SUFFIX(ProgramPathFragmentInputGen, CHROMIUM); |
| 771 | // GL_CHROMIUM_path_rendering additions: |
| 772 | GET_PROC_SUFFIX(BindFragmentInputLocation, CHROMIUM); |
| 773 | } |
| 774 | |
vbuzinov | 08b4d29 | 2015-04-01 06:29:49 -0700 | [diff] [blame] | 775 | if (extensions.has("GL_NV_framebuffer_mixed_samples")) { |
| 776 | GET_PROC_SUFFIX(CoverageModulation, NV); |
| 777 | } |
kkinnunen | ea40943 | 2015-12-10 01:21:59 -0800 | [diff] [blame] | 778 | if (extensions.has("GL_CHROMIUM_framebuffer_mixed_samples")) { |
| 779 | GET_PROC_SUFFIX(CoverageModulation, CHROMIUM); |
| 780 | } |
vbuzinov | 08b4d29 | 2015-04-01 06:29:49 -0700 | [diff] [blame] | 781 | |
cdalton | 1250944 | 2015-12-17 11:11:40 -0800 | [diff] [blame] | 782 | if (version >= GR_GL_VER(3,0)) { |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 783 | GET_PROC(DrawArraysInstanced); |
| 784 | GET_PROC(DrawElementsInstanced); |
cdalton | 1250944 | 2015-12-17 11:11:40 -0800 | [diff] [blame] | 785 | } else if (extensions.has("GL_EXT_draw_instanced")) { |
| 786 | GET_PROC_SUFFIX(DrawArraysInstanced, EXT); |
| 787 | GET_PROC_SUFFIX(DrawElementsInstanced, EXT); |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 788 | } |
| 789 | |
cdalton | 1250944 | 2015-12-17 11:11:40 -0800 | [diff] [blame] | 790 | if (version >= GR_GL_VER(3,0)) { |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 791 | GET_PROC(VertexAttribDivisor); |
cdalton | 1250944 | 2015-12-17 11:11:40 -0800 | [diff] [blame] | 792 | } else if (extensions.has("GL_EXT_instanced_arrays")) { |
| 793 | GET_PROC_SUFFIX(VertexAttribDivisor, EXT); |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | if (extensions.has("GL_NV_bindless_texture")) { |
| 797 | GET_PROC_SUFFIX(GetTextureHandle, NV); |
| 798 | GET_PROC_SUFFIX(GetTextureSamplerHandle, NV); |
| 799 | GET_PROC_SUFFIX(MakeTextureHandleResident, NV); |
| 800 | GET_PROC_SUFFIX(MakeTextureHandleNonResident, NV); |
| 801 | GET_PROC_SUFFIX(GetImageHandle, NV); |
| 802 | GET_PROC_SUFFIX(MakeImageHandleResident, NV); |
| 803 | GET_PROC_SUFFIX(MakeImageHandleNonResident, NV); |
| 804 | GET_PROC_SUFFIX(IsTextureHandleResident, NV); |
| 805 | GET_PROC_SUFFIX(IsImageHandleResident, NV); |
| 806 | GET_PROC_SUFFIX(UniformHandleui64, NV); |
| 807 | GET_PROC_SUFFIX(UniformHandleui64v, NV); |
| 808 | GET_PROC_SUFFIX(ProgramUniformHandleui64, NV); |
| 809 | GET_PROC_SUFFIX(ProgramUniformHandleui64v, NV); |
| 810 | } |
| 811 | |
| 812 | if (extensions.has("GL_KHR_debug")) { |
| 813 | GET_PROC_SUFFIX(DebugMessageControl, KHR); |
| 814 | GET_PROC_SUFFIX(DebugMessageInsert, KHR); |
| 815 | GET_PROC_SUFFIX(DebugMessageCallback, KHR); |
| 816 | GET_PROC_SUFFIX(GetDebugMessageLog, KHR); |
| 817 | GET_PROC_SUFFIX(PushDebugGroup, KHR); |
| 818 | GET_PROC_SUFFIX(PopDebugGroup, KHR); |
| 819 | GET_PROC_SUFFIX(ObjectLabel, KHR); |
bsalomon | db9f664 | 2015-10-02 08:34:28 -0700 | [diff] [blame] | 820 | // In general we have a policy against removing extension strings when the driver does |
| 821 | // not provide function pointers for an advertised extension. However, because there is a |
| 822 | // known device that advertises GL_KHR_debug but fails to provide the functions and this is |
| 823 | // a debugging- only extension we've made an exception. This also can happen when using |
| 824 | // APITRACE. |
| 825 | if (!interface->fFunctions.fDebugMessageControl) { |
| 826 | extensions.remove("GL_KHR_debug"); |
| 827 | } |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 828 | } |
| 829 | |
kkinnunen | 0adfffb | 2015-10-13 12:58:37 -0700 | [diff] [blame] | 830 | if (extensions.has("GL_CHROMIUM_bind_uniform_location")) { |
| 831 | GET_PROC_SUFFIX(BindUniformLocation, CHROMIUM); |
| 832 | } |
| 833 | |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 834 | if (extensions.has("EGL_KHR_image") || extensions.has("EGL_KHR_image_base")) { |
| 835 | GET_EGL_PROC_SUFFIX(CreateImage, KHR); |
| 836 | GET_EGL_PROC_SUFFIX(DestroyImage, KHR); |
| 837 | } |
| 838 | |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame] | 839 | interface->fStandard = kGLES_GrGLStandard; |
| 840 | interface->fExtensions.swap(&extensions); |
| 841 | |
| 842 | return interface; |
| 843 | } |