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