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