| 1 |
/* |
| 2 |
* Copyright 2019 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
* |
| 7 |
* THIS FILE IS AUTOGENERATED |
| 8 |
* Make edits to tools/ganesh/gl/interface/templates.go or they will |
| 9 |
* be overwritten. |
| 10 |
*/ |
| 11 |
#include "include/core/SkRefCnt.h" |
| 12 |
#include "include/gpu/ganesh/gl/GrGLAssembleInterface.h" |
| 13 |
|
| 14 |
#if SK_DISABLE_WEBGL_INTERFACE || !defined(__EMSCRIPTEN__) |
| 15 |
struct GrGLInterface; |
| 16 |
sk_sp<const GrGLInterface> GrGLMakeAssembledWebGLInterface(void *ctx, GrGLGetProc get) { |
| 17 |
return nullptr; |
| 18 |
} |
| 19 |
#else |
| 20 |
|
| 21 |
#include "include/gpu/ganesh/gl/GrGLAssembleHelpers.h" |
| 22 |
#include "src/gpu/ganesh/gl/GrGLUtil.h" |
| 23 |
|
| 24 |
// Located https://github.com/emscripten-core/emscripten/tree/7ba7700902c46734987585409502f3c63beb650f/system/include/webgl |
| 25 |
#include <webgl/webgl1.h> |
| 26 |
#include <webgl/webgl1_ext.h> |
| 27 |
#include <webgl/webgl2.h> |
| 28 |
#include <webgl/webgl2_ext.h> |
| 29 |
|
| 30 |
#define GET_PROC(F) functions->f##F = emscripten_gl##F |
| 31 |
#define GET_PROC_SUFFIX(F, S) functions->f##F = emscripten_gl##F##S |
| 32 |
|
| 33 |
sk_sp<const GrGLInterface> GrGLMakeAssembledWebGLInterface(void *ctx, GrGLGetProc get) { |
| 34 |
const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION)); |
| 35 |
GrGLVersion glVer = GrGLGetVersionFromString(verStr); |
| 36 |
if (glVer < GR_GL_VER(1,0)) { |
| 37 |
return nullptr; |
| 38 |
} |
| 39 |
|
| 40 |
GrGLExtensions extensions; |
| 41 |
if (!extensions.init(kWebGL_GrGLStandard, glGetString, glGetStringi, glGetIntegerv)) { |
| 42 |
return nullptr; |
| 43 |
} |
| 44 |
|
| 45 |
sk_sp<GrGLInterface> interface(new GrGLInterface); |
| 46 |
GrGLInterface::Functions* functions = &interface->fFunctions; |
| 47 |
|
| 48 |
// Autogenerated content follows |
| 49 |
GET_PROC(ActiveTexture); |
| 50 |
GET_PROC(AttachShader); |
| 51 |
GET_PROC(BindAttribLocation); |
| 52 |
GET_PROC(BindBuffer); |
| 53 |
GET_PROC(BindTexture); |
| 54 |
GET_PROC(BlendColor); |
| 55 |
GET_PROC(BlendEquation); |
| 56 |
GET_PROC(BlendFunc); |
| 57 |
GET_PROC(BufferData); |
| 58 |
GET_PROC(BufferSubData); |
| 59 |
GET_PROC(Clear); |
| 60 |
GET_PROC(ClearColor); |
| 61 |
GET_PROC(ClearStencil); |
| 62 |
GET_PROC(ColorMask); |
| 63 |
GET_PROC(CompileShader); |
| 64 |
GET_PROC(CompressedTexImage2D); |
| 65 |
GET_PROC(CompressedTexSubImage2D); |
| 66 |
GET_PROC(CopyTexSubImage2D); |
| 67 |
GET_PROC(CreateProgram); |
| 68 |
GET_PROC(CreateShader); |
| 69 |
GET_PROC(CullFace); |
| 70 |
GET_PROC(DeleteBuffers); |
| 71 |
GET_PROC(DeleteProgram); |
| 72 |
GET_PROC(DeleteShader); |
| 73 |
GET_PROC(DeleteTextures); |
| 74 |
GET_PROC(DepthMask); |
| 75 |
GET_PROC(Disable); |
| 76 |
GET_PROC(DisableVertexAttribArray); |
| 77 |
GET_PROC(DrawArrays); |
| 78 |
GET_PROC(DrawElements); |
| 79 |
GET_PROC(Enable); |
| 80 |
GET_PROC(EnableVertexAttribArray); |
| 81 |
GET_PROC(Finish); |
| 82 |
GET_PROC(Flush); |
| 83 |
GET_PROC(FrontFace); |
| 84 |
GET_PROC(GenBuffers); |
| 85 |
GET_PROC(GenTextures); |
| 86 |
GET_PROC(GetBufferParameteriv); |
| 87 |
GET_PROC(GetError); |
| 88 |
GET_PROC(GetFloatv); |
| 89 |
GET_PROC(GetIntegerv); |
| 90 |
GET_PROC(GetProgramInfoLog); |
| 91 |
GET_PROC(GetProgramiv); |
| 92 |
GET_PROC(GetShaderInfoLog); |
| 93 |
GET_PROC(GetShaderiv); |
| 94 |
GET_PROC(GetString); |
| 95 |
GET_PROC(GetUniformLocation); |
| 96 |
GET_PROC(IsTexture); |
| 97 |
GET_PROC(LineWidth); |
| 98 |
GET_PROC(LinkProgram); |
| 99 |
GET_PROC(PixelStorei); |
| 100 |
GET_PROC(ReadPixels); |
| 101 |
GET_PROC(Scissor); |
| 102 |
GET_PROC(ShaderSource); |
| 103 |
GET_PROC(StencilFunc); |
| 104 |
GET_PROC(StencilFuncSeparate); |
| 105 |
GET_PROC(StencilMask); |
| 106 |
GET_PROC(StencilMaskSeparate); |
| 107 |
GET_PROC(StencilOp); |
| 108 |
GET_PROC(StencilOpSeparate); |
| 109 |
GET_PROC(TexImage2D); |
| 110 |
GET_PROC(TexParameterf); |
| 111 |
GET_PROC(TexParameterfv); |
| 112 |
GET_PROC(TexParameteri); |
| 113 |
GET_PROC(TexParameteriv); |
| 114 |
GET_PROC(TexSubImage2D); |
| 115 |
GET_PROC(Uniform1f); |
| 116 |
GET_PROC(Uniform1fv); |
| 117 |
GET_PROC(Uniform1i); |
| 118 |
GET_PROC(Uniform1iv); |
| 119 |
GET_PROC(Uniform2f); |
| 120 |
GET_PROC(Uniform2fv); |
| 121 |
GET_PROC(Uniform2i); |
| 122 |
GET_PROC(Uniform2iv); |
| 123 |
GET_PROC(Uniform3f); |
| 124 |
GET_PROC(Uniform3fv); |
| 125 |
GET_PROC(Uniform3i); |
| 126 |
GET_PROC(Uniform3iv); |
| 127 |
GET_PROC(Uniform4f); |
| 128 |
GET_PROC(Uniform4fv); |
| 129 |
GET_PROC(Uniform4i); |
| 130 |
GET_PROC(Uniform4iv); |
| 131 |
GET_PROC(UniformMatrix2fv); |
| 132 |
GET_PROC(UniformMatrix3fv); |
| 133 |
GET_PROC(UniformMatrix4fv); |
| 134 |
GET_PROC(UseProgram); |
| 135 |
GET_PROC(VertexAttrib1f); |
| 136 |
GET_PROC(VertexAttrib2fv); |
| 137 |
GET_PROC(VertexAttrib3fv); |
| 138 |
GET_PROC(VertexAttrib4fv); |
| 139 |
GET_PROC(VertexAttribPointer); |
| 140 |
GET_PROC(Viewport); |
| 141 |
|
| 142 |
if (glVer >= GR_GL_VER(2,0)) { |
| 143 |
GET_PROC(GetStringi); |
| 144 |
} |
| 145 |
|
| 146 |
if (glVer >= GR_GL_VER(2,0)) { |
| 147 |
GET_PROC(BindVertexArray); |
| 148 |
GET_PROC(DeleteVertexArrays); |
| 149 |
GET_PROC(GenVertexArrays); |
| 150 |
} else if (extensions.has("GL_OES_vertex_array_object")) { |
| 151 |
GET_PROC_SUFFIX(BindVertexArray, OES); |
| 152 |
GET_PROC_SUFFIX(DeleteVertexArrays, OES); |
| 153 |
GET_PROC_SUFFIX(GenVertexArrays, OES); |
| 154 |
} else if (extensions.has("OES_vertex_array_object")) { |
| 155 |
GET_PROC_SUFFIX(BindVertexArray, OES); |
| 156 |
GET_PROC_SUFFIX(DeleteVertexArrays, OES); |
| 157 |
GET_PROC_SUFFIX(GenVertexArrays, OES); |
| 158 |
} |
| 159 |
|
| 160 |
if (glVer >= GR_GL_VER(2,0)) { |
| 161 |
GET_PROC(DrawArraysInstanced); |
| 162 |
GET_PROC(DrawElementsInstanced); |
| 163 |
} |
| 164 |
|
| 165 |
if (extensions.has("GL_WEBGL_draw_instanced_base_vertex_base_instance")) { |
| 166 |
GET_PROC_SUFFIX(DrawArraysInstancedBaseInstance, WEBGL); |
| 167 |
GET_PROC_SUFFIX(DrawElementsInstancedBaseVertexBaseInstance, WEBGL); |
| 168 |
} |
| 169 |
|
| 170 |
if (glVer >= GR_GL_VER(2,0)) { |
| 171 |
GET_PROC(DrawBuffers); |
| 172 |
GET_PROC(ReadBuffer); |
| 173 |
} |
| 174 |
|
| 175 |
if (extensions.has("GL_WEBGL_multi_draw_instanced_base_vertex_base_instance")) { |
| 176 |
GET_PROC_SUFFIX(MultiDrawArraysInstancedBaseInstance, WEBGL); |
| 177 |
GET_PROC_SUFFIX(MultiDrawElementsInstancedBaseVertexBaseInstance, WEBGL); |
| 178 |
} |
| 179 |
|
| 180 |
if (glVer >= GR_GL_VER(2,0)) { |
| 181 |
GET_PROC(DrawRangeElements); |
| 182 |
} |
| 183 |
|
| 184 |
if (glVer >= GR_GL_VER(2,0)) { |
| 185 |
GET_PROC(TexStorage2D); |
| 186 |
} |
| 187 |
|
| 188 |
if (glVer >= GR_GL_VER(2,0)) { |
| 189 |
GET_PROC(VertexAttribDivisor); |
| 190 |
} |
| 191 |
|
| 192 |
if (glVer >= GR_GL_VER(2,0)) { |
| 193 |
GET_PROC(VertexAttribIPointer); |
| 194 |
} |
| 195 |
|
| 196 |
GET_PROC(BindFramebuffer); |
| 197 |
GET_PROC(BindRenderbuffer); |
| 198 |
GET_PROC(CheckFramebufferStatus); |
| 199 |
GET_PROC(DeleteFramebuffers); |
| 200 |
GET_PROC(DeleteRenderbuffers); |
| 201 |
GET_PROC(FramebufferRenderbuffer); |
| 202 |
GET_PROC(FramebufferTexture2D); |
| 203 |
GET_PROC(GenFramebuffers); |
| 204 |
GET_PROC(GenRenderbuffers); |
| 205 |
GET_PROC(GenerateMipmap); |
| 206 |
GET_PROC(GetFramebufferAttachmentParameteriv); |
| 207 |
GET_PROC(GetRenderbufferParameteriv); |
| 208 |
GET_PROC(RenderbufferStorage); |
| 209 |
|
| 210 |
if (glVer >= GR_GL_VER(2,0)) { |
| 211 |
GET_PROC(BlitFramebuffer); |
| 212 |
} |
| 213 |
|
| 214 |
if (glVer >= GR_GL_VER(2,0)) { |
| 215 |
GET_PROC(RenderbufferStorageMultisample); |
| 216 |
} |
| 217 |
|
| 218 |
if (glVer >= GR_GL_VER(2,0)) { |
| 219 |
GET_PROC(CopyBufferSubData); |
| 220 |
} |
| 221 |
|
| 222 |
if (glVer >= GR_GL_VER(2,0)) { |
| 223 |
GET_PROC(ClientWaitSync); |
| 224 |
GET_PROC(DeleteSync); |
| 225 |
GET_PROC(FenceSync); |
| 226 |
GET_PROC(IsSync); |
| 227 |
GET_PROC(WaitSync); |
| 228 |
} |
| 229 |
|
| 230 |
if (glVer >= GR_GL_VER(2,0)) { |
| 231 |
GET_PROC(BindSampler); |
| 232 |
GET_PROC(DeleteSamplers); |
| 233 |
GET_PROC(GenSamplers); |
| 234 |
GET_PROC(SamplerParameterf); |
| 235 |
GET_PROC(SamplerParameteri); |
| 236 |
GET_PROC(SamplerParameteriv); |
| 237 |
} |
| 238 |
|
| 239 |
if (glVer >= GR_GL_VER(2,0)) { |
| 240 |
GET_PROC(BeginQuery); |
| 241 |
GET_PROC(DeleteQueries); |
| 242 |
GET_PROC(EndQuery); |
| 243 |
GET_PROC(GenQueries); |
| 244 |
GET_PROC(GetQueryObjectuiv); |
| 245 |
GET_PROC(GetQueryiv); |
| 246 |
} else if (extensions.has("GL_EXT_disjoint_timer_query")) { |
| 247 |
GET_PROC_SUFFIX(BeginQuery, EXT); |
| 248 |
GET_PROC_SUFFIX(DeleteQueries, EXT); |
| 249 |
GET_PROC_SUFFIX(EndQuery, EXT); |
| 250 |
GET_PROC_SUFFIX(GenQueries, EXT); |
| 251 |
GET_PROC_SUFFIX(GetQueryObjectuiv, EXT); |
| 252 |
GET_PROC_SUFFIX(GetQueryiv, EXT); |
| 253 |
} else if (extensions.has("EXT_disjoint_timer_query")) { |
| 254 |
GET_PROC_SUFFIX(BeginQuery, EXT); |
| 255 |
GET_PROC_SUFFIX(DeleteQueries, EXT); |
| 256 |
GET_PROC_SUFFIX(EndQuery, EXT); |
| 257 |
GET_PROC_SUFFIX(GenQueries, EXT); |
| 258 |
GET_PROC_SUFFIX(GetQueryObjectuiv, EXT); |
| 259 |
GET_PROC_SUFFIX(GetQueryiv, EXT); |
| 260 |
} |
| 261 |
|
| 262 |
if (extensions.has("GL_EXT_disjoint_timer_query")) { |
| 263 |
GET_PROC_SUFFIX(QueryCounter, EXT); |
| 264 |
} else if (extensions.has("EXT_disjoint_timer_query")) { |
| 265 |
GET_PROC_SUFFIX(QueryCounter, EXT); |
| 266 |
} else if (extensions.has("GL_EXT_disjoint_timer_query_webgl2")) { |
| 267 |
GET_PROC_SUFFIX(QueryCounter, EXT); |
| 268 |
} else if (extensions.has("EXT_disjoint_timer_query_webgl2")) { |
| 269 |
GET_PROC_SUFFIX(QueryCounter, EXT); |
| 270 |
} |
| 271 |
|
| 272 |
if (extensions.has("GL_EXT_disjoint_timer_query")) { |
| 273 |
GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); |
| 274 |
GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); |
| 275 |
} else if (extensions.has("EXT_disjoint_timer_query")) { |
| 276 |
GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); |
| 277 |
GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); |
| 278 |
} else if (extensions.has("GL_EXT_disjoint_timer_query_webgl2")) { |
| 279 |
GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); |
| 280 |
GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); |
| 281 |
} else if (extensions.has("EXT_disjoint_timer_query_webgl2")) { |
| 282 |
GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); |
| 283 |
GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); |
| 284 |
} |
| 285 |
|
| 286 |
if (glVer >= GR_GL_VER(2,0)) { |
| 287 |
GET_PROC(InvalidateFramebuffer); |
| 288 |
GET_PROC(InvalidateSubFramebuffer); |
| 289 |
} |
| 290 |
|
| 291 |
GET_PROC(GetShaderPrecisionFormat); |
| 292 |
|
| 293 |
|
| 294 |
// End autogenerated content |
| 295 |
|
| 296 |
interface->fStandard = kWebGL_GrGLStandard; |
| 297 |
interface->fExtensions.swap(&extensions); |
| 298 |
|
| 299 |
return interface; |
| 300 |
} |
| 301 |
#endif |