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); |
| 19 | if (NULL == GetString) { |
| 20 | return NULL; |
| 21 | } |
| 22 | |
| 23 | const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); |
| 24 | if (NULL == verStr) { |
| 25 | return NULL; |
| 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 | } |
| 35 | return NULL; |
| 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 | |
| 43 | // GetStringi may be NULL depending on the GL version. |
| 44 | if (NULL == GetString || NULL == GetIntegerv) { |
| 45 | return NULL; |
| 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. |
| 53 | return NULL; |
| 54 | } |
| 55 | |
| 56 | GrGLExtensions extensions; |
| 57 | if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv)) { |
| 58 | return NULL; |
| 59 | } |
| 60 | |
| 61 | GrGLInterface* interface = SkNEW(GrGLInterface()); |
| 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); |
| 73 | GET_PROC(BlendFunc); |
| 74 | |
| 75 | if (glVer >= GR_GL_VER(1,4) || |
| 76 | extensions.has("GL_ARB_imaging") || |
| 77 | extensions.has("GL_EXT_blend_color")) { |
| 78 | GET_PROC(BlendColor); |
| 79 | } |
| 80 | |
| 81 | GET_PROC(BufferData); |
| 82 | GET_PROC(BufferSubData); |
| 83 | GET_PROC(Clear); |
| 84 | GET_PROC(ClearColor); |
| 85 | GET_PROC(ClearStencil); |
| 86 | GET_PROC(ColorMask); |
| 87 | GET_PROC(CompileShader); |
| 88 | GET_PROC(CompressedTexImage2D); |
krajcevski | 37d20f7 | 2014-06-11 10:38:47 -0700 | [diff] [blame] | 89 | GET_PROC(CompressedTexSubImage2D); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 90 | GET_PROC(CopyTexSubImage2D); |
| 91 | GET_PROC(CreateProgram); |
| 92 | GET_PROC(CreateShader); |
| 93 | GET_PROC(CullFace); |
| 94 | GET_PROC(DeleteBuffers); |
| 95 | GET_PROC(DeleteProgram); |
| 96 | GET_PROC(DeleteQueries); |
| 97 | GET_PROC(DeleteShader); |
| 98 | GET_PROC(DeleteTextures); |
| 99 | GET_PROC(DepthMask); |
| 100 | GET_PROC(Disable); |
| 101 | GET_PROC(DisableVertexAttribArray); |
| 102 | GET_PROC(DrawArrays); |
| 103 | GET_PROC(DrawBuffer); |
| 104 | GET_PROC(DrawBuffers); |
| 105 | GET_PROC(DrawElements); |
| 106 | GET_PROC(Enable); |
| 107 | GET_PROC(EnableVertexAttribArray); |
| 108 | GET_PROC(EndQuery); |
| 109 | GET_PROC(Finish); |
| 110 | GET_PROC(Flush); |
| 111 | GET_PROC(FrontFace); |
| 112 | GET_PROC(GenBuffers); |
| 113 | GET_PROC(GenerateMipmap); |
| 114 | GET_PROC(GetBufferParameteriv); |
| 115 | GET_PROC(GetError); |
| 116 | GET_PROC(GetIntegerv); |
| 117 | GET_PROC(GetQueryObjectiv); |
| 118 | GET_PROC(GetQueryObjectuiv); |
| 119 | if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) { |
| 120 | GET_PROC(GetQueryObjecti64v); |
| 121 | GET_PROC(GetQueryObjectui64v); |
| 122 | GET_PROC(QueryCounter); |
| 123 | } else if (extensions.has("GL_EXT_timer_query")) { |
| 124 | GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); |
| 125 | GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); |
| 126 | } |
| 127 | GET_PROC(GetQueryiv); |
| 128 | GET_PROC(GetProgramInfoLog); |
| 129 | GET_PROC(GetProgramiv); |
| 130 | GET_PROC(GetShaderInfoLog); |
| 131 | GET_PROC(GetShaderiv); |
| 132 | GET_PROC(GetString); |
| 133 | GET_PROC(GetStringi); |
| 134 | GET_PROC(GetTexLevelParameteriv); |
| 135 | GET_PROC(GenQueries); |
| 136 | GET_PROC(GenTextures); |
| 137 | GET_PROC(GetUniformLocation); |
| 138 | GET_PROC(LineWidth); |
| 139 | GET_PROC(LinkProgram); |
| 140 | GET_PROC(MapBuffer); |
| 141 | if (extensions.has("GL_EXT_direct_state_access")) { |
| 142 | GET_PROC_SUFFIX(MatrixLoadf, EXT); |
| 143 | GET_PROC_SUFFIX(MatrixLoadIdentity, EXT); |
| 144 | } |
| 145 | GET_PROC(PixelStorei); |
| 146 | GET_PROC(ReadBuffer); |
| 147 | GET_PROC(ReadPixels); |
| 148 | GET_PROC(Scissor); |
| 149 | GET_PROC(ShaderSource); |
| 150 | GET_PROC(StencilFunc); |
| 151 | GET_PROC(StencilFuncSeparate); |
| 152 | GET_PROC(StencilMask); |
| 153 | GET_PROC(StencilMaskSeparate); |
| 154 | GET_PROC(StencilOp); |
| 155 | GET_PROC(StencilOpSeparate); |
| 156 | GET_PROC(TexImage2D); |
| 157 | GET_PROC(TexParameteri); |
| 158 | GET_PROC(TexParameteriv); |
| 159 | if (glVer >= GR_GL_VER(4,2) || extensions.has("GL_ARB_texture_storage")) { |
| 160 | GET_PROC(TexStorage2D); |
| 161 | } else if (extensions.has("GL_EXT_texture_storage")) { |
| 162 | GET_PROC_SUFFIX(TexStorage2D, EXT); |
| 163 | } |
| 164 | GET_PROC(TexSubImage2D); |
| 165 | GET_PROC(Uniform1f); |
| 166 | GET_PROC(Uniform1i); |
| 167 | GET_PROC(Uniform1fv); |
| 168 | GET_PROC(Uniform1iv); |
| 169 | GET_PROC(Uniform2f); |
| 170 | GET_PROC(Uniform2i); |
| 171 | GET_PROC(Uniform2fv); |
| 172 | GET_PROC(Uniform2iv); |
| 173 | GET_PROC(Uniform3f); |
| 174 | GET_PROC(Uniform3i); |
| 175 | GET_PROC(Uniform3fv); |
| 176 | GET_PROC(Uniform3iv); |
| 177 | GET_PROC(Uniform4f); |
| 178 | GET_PROC(Uniform4i); |
| 179 | GET_PROC(Uniform4fv); |
| 180 | GET_PROC(Uniform4iv); |
| 181 | GET_PROC(UniformMatrix2fv); |
| 182 | GET_PROC(UniformMatrix3fv); |
| 183 | GET_PROC(UniformMatrix4fv); |
| 184 | GET_PROC(UnmapBuffer); |
| 185 | GET_PROC(UseProgram); |
| 186 | GET_PROC(VertexAttrib4fv); |
| 187 | GET_PROC(VertexAttribPointer); |
| 188 | GET_PROC(Viewport); |
| 189 | GET_PROC(BindFragDataLocationIndexed); |
| 190 | |
| 191 | if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) { |
| 192 | // no ARB suffix for GL_ARB_vertex_array_object |
| 193 | GET_PROC(BindVertexArray); |
| 194 | GET_PROC(GenVertexArrays); |
| 195 | GET_PROC(DeleteVertexArrays); |
| 196 | } |
| 197 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 198 | if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_map_buffer_range")) { |
| 199 | GET_PROC(MapBufferRange); |
| 200 | GET_PROC(FlushMappedBufferRange); |
| 201 | } |
| 202 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 203 | // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since |
| 204 | // GL_ARB_framebuffer_object doesn't use ARB suffix.) |
| 205 | if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) { |
| 206 | GET_PROC(GenFramebuffers); |
| 207 | GET_PROC(GetFramebufferAttachmentParameteriv); |
| 208 | GET_PROC(GetRenderbufferParameteriv); |
| 209 | GET_PROC(BindFramebuffer); |
| 210 | GET_PROC(FramebufferTexture2D); |
| 211 | GET_PROC(CheckFramebufferStatus); |
| 212 | GET_PROC(DeleteFramebuffers); |
| 213 | GET_PROC(RenderbufferStorage); |
| 214 | GET_PROC(GenRenderbuffers); |
| 215 | GET_PROC(DeleteRenderbuffers); |
| 216 | GET_PROC(FramebufferRenderbuffer); |
| 217 | GET_PROC(BindRenderbuffer); |
| 218 | GET_PROC(RenderbufferStorageMultisample); |
| 219 | GET_PROC(BlitFramebuffer); |
| 220 | } else if (extensions.has("GL_EXT_framebuffer_object")) { |
| 221 | GET_PROC_SUFFIX(GenFramebuffers, EXT); |
| 222 | GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); |
| 223 | GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); |
| 224 | GET_PROC_SUFFIX(BindFramebuffer, EXT); |
| 225 | GET_PROC_SUFFIX(FramebufferTexture2D, EXT); |
| 226 | GET_PROC_SUFFIX(CheckFramebufferStatus, EXT); |
| 227 | GET_PROC_SUFFIX(DeleteFramebuffers, EXT); |
| 228 | GET_PROC_SUFFIX(RenderbufferStorage, EXT); |
| 229 | GET_PROC_SUFFIX(GenRenderbuffers, EXT); |
| 230 | GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); |
| 231 | GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); |
| 232 | GET_PROC_SUFFIX(BindRenderbuffer, EXT); |
| 233 | if (extensions.has("GL_EXT_framebuffer_multisample")) { |
| 234 | GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); |
| 235 | } |
| 236 | if (extensions.has("GL_EXT_framebuffer_blit")) { |
| 237 | GET_PROC_SUFFIX(BlitFramebuffer, EXT); |
| 238 | } |
| 239 | } else { |
| 240 | // we must have FBOs |
| 241 | delete interface; |
| 242 | return NULL; |
| 243 | } |
| 244 | |
| 245 | if (extensions.has("GL_NV_path_rendering")) { |
| 246 | GET_PROC_SUFFIX(PathCommands, NV); |
| 247 | GET_PROC_SUFFIX(PathCoords, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 248 | GET_PROC_SUFFIX(PathParameteri, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 249 | GET_PROC_SUFFIX(PathParameterf, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 250 | GET_PROC_SUFFIX(GenPaths, NV); |
| 251 | GET_PROC_SUFFIX(DeletePaths, NV); |
cdalton | 8dd90cb | 2014-07-17 09:28:36 -0700 | [diff] [blame] | 252 | GET_PROC_SUFFIX(IsPath, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 253 | GET_PROC_SUFFIX(PathStencilFunc, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 254 | GET_PROC_SUFFIX(StencilFillPath, NV); |
| 255 | GET_PROC_SUFFIX(StencilStrokePath, NV); |
| 256 | GET_PROC_SUFFIX(StencilFillPathInstanced, NV); |
| 257 | GET_PROC_SUFFIX(StencilStrokePathInstanced, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 258 | GET_PROC_SUFFIX(PathTexGen, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 259 | GET_PROC_SUFFIX(CoverFillPath, NV); |
| 260 | GET_PROC_SUFFIX(CoverStrokePath, NV); |
| 261 | GET_PROC_SUFFIX(CoverFillPathInstanced, NV); |
| 262 | GET_PROC_SUFFIX(CoverStrokePathInstanced, NV); |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 263 | // NV_path_rendering v1.2 (These methods may not be present) |
cdalton | c8f5204 | 2014-07-29 15:25:51 -0700 | [diff] [blame] | 264 | GET_PROC_SUFFIX(StencilThenCoverFillPath, NV); |
| 265 | GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV); |
| 266 | GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV); |
| 267 | GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV); |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 268 | // NV_path_rendering v1.3 (These methods may not be present) |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 269 | GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV); |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | if (extensions.has("GL_EXT_debug_marker")) { |
| 273 | GET_PROC_SUFFIX(InsertEventMarker, EXT); |
| 274 | GET_PROC_SUFFIX(PushGroupMarker, EXT); |
| 275 | GET_PROC_SUFFIX(PopGroupMarker, EXT); |
| 276 | } |
| 277 | |
| 278 | if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) { |
| 279 | GET_PROC(InvalidateBufferData); |
| 280 | GET_PROC(InvalidateBufferSubData); |
| 281 | GET_PROC(InvalidateFramebuffer); |
| 282 | GET_PROC(InvalidateSubFramebuffer); |
| 283 | GET_PROC(InvalidateTexImage); |
| 284 | GET_PROC(InvalidateTexSubImage); |
| 285 | } |
| 286 | |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 287 | if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_program_interface_query")) { |
| 288 | GET_PROC(GetProgramResourceLocation); |
| 289 | } |
| 290 | |
commit-bot@chromium.org | 9add5dc | 2014-04-29 20:06:22 +0000 | [diff] [blame] | 291 | interface->fStandard = kGL_GrGLStandard; |
| 292 | interface->fExtensions.swap(&extensions); |
| 293 | |
| 294 | return interface; |
| 295 | } |
bsalomon | a721c81 | 2014-08-26 11:35:23 -0700 | [diff] [blame^] | 296 | |
| 297 | const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) { |
| 298 | GET_PROC_LOCAL(GetString); |
| 299 | if (NULL == GetString) { |
| 300 | return NULL; |
| 301 | } |
| 302 | |
| 303 | const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); |
| 304 | GrGLVersion version = GrGLGetVersionFromString(verStr); |
| 305 | |
| 306 | if (version < GR_GL_VER(2,0)) { |
| 307 | return NULL; |
| 308 | } |
| 309 | |
| 310 | GET_PROC_LOCAL(GetIntegerv); |
| 311 | GET_PROC_LOCAL(GetStringi); |
| 312 | GrGLExtensions extensions; |
| 313 | if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv)) { |
| 314 | return NULL; |
| 315 | } |
| 316 | |
| 317 | GrGLInterface* interface = SkNEW(GrGLInterface); |
| 318 | GrGLInterface::Functions* functions = &interface->fFunctions; |
| 319 | |
| 320 | GET_PROC(ActiveTexture); |
| 321 | GET_PROC(AttachShader); |
| 322 | GET_PROC(BindAttribLocation); |
| 323 | GET_PROC(BindBuffer); |
| 324 | GET_PROC(BindTexture); |
| 325 | GET_PROC_SUFFIX(BindVertexArray, OES); |
| 326 | GET_PROC(BlendColor); |
| 327 | GET_PROC(BlendFunc); |
| 328 | GET_PROC(BufferData); |
| 329 | GET_PROC(BufferSubData); |
| 330 | GET_PROC(Clear); |
| 331 | GET_PROC(ClearColor); |
| 332 | GET_PROC(ClearStencil); |
| 333 | GET_PROC(ColorMask); |
| 334 | GET_PROC(CompileShader); |
| 335 | GET_PROC(CompressedTexImage2D); |
| 336 | GET_PROC(CompressedTexSubImage2D); |
| 337 | GET_PROC(CopyTexSubImage2D); |
| 338 | GET_PROC(CreateProgram); |
| 339 | GET_PROC(CreateShader); |
| 340 | GET_PROC(CullFace); |
| 341 | GET_PROC(DeleteBuffers); |
| 342 | GET_PROC(DeleteProgram); |
| 343 | GET_PROC(DeleteShader); |
| 344 | GET_PROC(DeleteTextures); |
| 345 | GET_PROC_SUFFIX(DeleteVertexArrays, OES); |
| 346 | GET_PROC(DepthMask); |
| 347 | GET_PROC(Disable); |
| 348 | GET_PROC(DisableVertexAttribArray); |
| 349 | GET_PROC(DrawArrays); |
| 350 | GET_PROC(DrawElements); |
| 351 | GET_PROC(Enable); |
| 352 | GET_PROC(EnableVertexAttribArray); |
| 353 | GET_PROC(Finish); |
| 354 | GET_PROC(Flush); |
| 355 | GET_PROC(FrontFace); |
| 356 | GET_PROC(GenBuffers); |
| 357 | GET_PROC(GenerateMipmap); |
| 358 | GET_PROC(GenTextures); |
| 359 | GET_PROC_SUFFIX(GenVertexArrays, OES); |
| 360 | GET_PROC(GetBufferParameteriv); |
| 361 | GET_PROC(GetError); |
| 362 | GET_PROC(GetIntegerv); |
| 363 | GET_PROC(GetProgramInfoLog); |
| 364 | GET_PROC(GetProgramiv); |
| 365 | GET_PROC(GetShaderInfoLog); |
| 366 | GET_PROC(GetShaderiv); |
| 367 | GET_PROC(GetString); |
| 368 | GET_PROC(GetStringi); |
| 369 | GET_PROC(GetUniformLocation); |
| 370 | GET_PROC(LineWidth); |
| 371 | GET_PROC(LinkProgram); |
| 372 | GET_PROC(PixelStorei); |
| 373 | GET_PROC(ReadPixels); |
| 374 | GET_PROC(Scissor); |
| 375 | GET_PROC(ShaderSource); |
| 376 | GET_PROC(StencilFunc); |
| 377 | GET_PROC(StencilFuncSeparate); |
| 378 | GET_PROC(StencilMask); |
| 379 | GET_PROC(StencilMaskSeparate); |
| 380 | GET_PROC(StencilOp); |
| 381 | GET_PROC(StencilOpSeparate); |
| 382 | GET_PROC(TexImage2D); |
| 383 | GET_PROC(TexParameteri); |
| 384 | GET_PROC(TexParameteriv); |
| 385 | GET_PROC(TexSubImage2D); |
| 386 | |
| 387 | if (version >= GR_GL_VER(3,0)) { |
| 388 | GET_PROC(TexStorage2D); |
| 389 | } else { |
| 390 | GET_PROC_SUFFIX(TexStorage2D, EXT); |
| 391 | } |
| 392 | |
| 393 | GET_PROC_SUFFIX(DiscardFramebuffer, EXT); |
| 394 | GET_PROC(Uniform1f); |
| 395 | GET_PROC(Uniform1i); |
| 396 | GET_PROC(Uniform1fv); |
| 397 | GET_PROC(Uniform1iv); |
| 398 | GET_PROC(Uniform2f); |
| 399 | GET_PROC(Uniform2i); |
| 400 | GET_PROC(Uniform2fv); |
| 401 | GET_PROC(Uniform2iv); |
| 402 | GET_PROC(Uniform3f); |
| 403 | GET_PROC(Uniform3i); |
| 404 | GET_PROC(Uniform3fv); |
| 405 | GET_PROC(Uniform3iv); |
| 406 | GET_PROC(Uniform4f); |
| 407 | GET_PROC(Uniform4i); |
| 408 | GET_PROC(Uniform4fv); |
| 409 | GET_PROC(Uniform4iv); |
| 410 | GET_PROC(UniformMatrix2fv); |
| 411 | GET_PROC(UniformMatrix3fv); |
| 412 | GET_PROC(UniformMatrix4fv); |
| 413 | GET_PROC(UseProgram); |
| 414 | GET_PROC(VertexAttrib4fv); |
| 415 | GET_PROC(VertexAttribPointer); |
| 416 | GET_PROC(Viewport); |
| 417 | GET_PROC(BindFramebuffer); |
| 418 | GET_PROC(BindRenderbuffer); |
| 419 | GET_PROC(CheckFramebufferStatus); |
| 420 | GET_PROC(DeleteFramebuffers); |
| 421 | GET_PROC(DeleteRenderbuffers); |
| 422 | GET_PROC(FramebufferRenderbuffer); |
| 423 | GET_PROC(FramebufferTexture2D); |
| 424 | |
| 425 | if (version >= GR_GL_VER(3,0)) { |
| 426 | GET_PROC(RenderbufferStorageMultisample); |
| 427 | GET_PROC(BlitFramebuffer); |
| 428 | } |
| 429 | |
| 430 | if (extensions.has("GL_EXT_multisampled_render_to_texture")) { |
| 431 | GET_PROC_SUFFIX(FramebufferTexture2DMultisample, EXT); |
| 432 | functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleEXT"); |
| 433 | } else if (extensions.has("GL_IMG_multisampled_render_to_texture")) { |
| 434 | GET_PROC_SUFFIX(FramebufferTexture2DMultisample, IMG); |
| 435 | functions->fRenderbufferStorageMultisampleES2EXT = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleIMG"); |
| 436 | } else if (extensions.has("GL_APPLE_framebuffer_multisample")) { |
| 437 | functions->fRenderbufferStorageMultisampleES2APPLE = (GrGLRenderbufferStorageMultisampleProc) get(ctx, "glRenderbufferStorageMultisampleAPPLE"); |
| 438 | GET_PROC_SUFFIX(ResolveMultisampleFramebuffer, APPLE); |
| 439 | } |
| 440 | |
| 441 | GET_PROC(GenFramebuffers); |
| 442 | GET_PROC(GenRenderbuffers); |
| 443 | GET_PROC(GetFramebufferAttachmentParameteriv); |
| 444 | GET_PROC(GetRenderbufferParameteriv); |
| 445 | GET_PROC(RenderbufferStorage); |
| 446 | |
| 447 | GET_PROC_SUFFIX(MapBuffer, OES); |
| 448 | GET_PROC_SUFFIX(UnmapBuffer, OES); |
| 449 | |
| 450 | if (version >= GR_GL_VER(3,0)) { |
| 451 | GET_PROC(MapBufferRange); |
| 452 | GET_PROC(FlushMappedBufferRange); |
| 453 | } else if (extensions.has("GL_EXT_map_buffer_range")) { |
| 454 | GET_PROC_SUFFIX(MapBufferRange, EXT); |
| 455 | GET_PROC_SUFFIX(FlushMappedBufferRange, EXT); |
| 456 | } |
| 457 | |
| 458 | if (extensions.has("GL_EXT_debug_marker")) { |
| 459 | GET_PROC(InsertEventMarker); |
| 460 | GET_PROC(PushGroupMarker); |
| 461 | GET_PROC(PopGroupMarker); |
| 462 | // The below check is here because a device has been found that has the extension string but |
| 463 | // returns NULL from the eglGetProcAddress for the functions |
| 464 | if (NULL == functions->fInsertEventMarker || |
| 465 | NULL == functions->fPushGroupMarker || |
| 466 | NULL == functions->fPopGroupMarker) { |
| 467 | extensions.remove("GL_EXT_debug_marker"); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | GET_PROC(InvalidateFramebuffer); |
| 472 | GET_PROC(InvalidateSubFramebuffer); |
| 473 | GET_PROC(InvalidateBufferData); |
| 474 | GET_PROC(InvalidateBufferSubData); |
| 475 | GET_PROC(InvalidateTexImage); |
| 476 | GET_PROC(InvalidateTexSubImage); |
| 477 | |
| 478 | if (version >= GR_GL_VER(3,1)) { |
| 479 | GET_PROC(GetProgramResourceLocation); |
| 480 | } |
| 481 | |
| 482 | if (extensions.has("GL_NV_path_rendering")) { |
| 483 | GET_PROC_SUFFIX(MatrixLoadf, EXT); |
| 484 | GET_PROC_SUFFIX(MatrixLoadIdentity, EXT); |
| 485 | GET_PROC_SUFFIX(PathCommands, NV); |
| 486 | GET_PROC_SUFFIX(PathCoords, NV); |
| 487 | GET_PROC_SUFFIX(PathParameteri, NV); |
| 488 | GET_PROC_SUFFIX(PathParameterf, NV); |
| 489 | GET_PROC_SUFFIX(GenPaths, NV); |
| 490 | GET_PROC_SUFFIX(DeletePaths, NV); |
| 491 | GET_PROC_SUFFIX(IsPath, NV); |
| 492 | GET_PROC_SUFFIX(PathStencilFunc, NV); |
| 493 | GET_PROC_SUFFIX(StencilFillPath, NV); |
| 494 | GET_PROC_SUFFIX(StencilStrokePath, NV); |
| 495 | GET_PROC_SUFFIX(StencilFillPathInstanced, NV); |
| 496 | GET_PROC_SUFFIX(StencilStrokePathInstanced, NV); |
| 497 | GET_PROC_SUFFIX(CoverFillPath, NV); |
| 498 | GET_PROC_SUFFIX(CoverStrokePath, NV); |
| 499 | GET_PROC_SUFFIX(CoverFillPathInstanced, NV); |
| 500 | GET_PROC_SUFFIX(CoverStrokePathInstanced, NV); |
| 501 | GET_PROC_SUFFIX(StencilThenCoverFillPath, NV); |
| 502 | GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV); |
| 503 | GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV); |
| 504 | GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV); |
| 505 | GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV); |
| 506 | } |
| 507 | |
| 508 | interface->fStandard = kGLES_GrGLStandard; |
| 509 | interface->fExtensions.swap(&extensions); |
| 510 | |
| 511 | return interface; |
| 512 | } |