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