1 // GENERATED FILE - DO NOT EDIT.
2 // Generated by generate_entry_points.py using data from gl.xml.
3 //
4 // Copyright 2020 The ANGLE Project Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style license that can be
6 // found in the LICENSE file.
7 //
8 // entry_points_gles_2_0_autogen.cpp:
9 //   Defines the GLES 2.0 entry points.
10 
11 #include "libGLESv2/entry_points_gles_2_0_autogen.h"
12 
13 #include "libANGLE/Context.h"
14 #include "libANGLE/Context.inl.h"
15 #include "libANGLE/capture_gles_2_0_autogen.h"
16 #include "libANGLE/entry_points_utils.h"
17 #include "libANGLE/gl_enum_utils.h"
18 #include "libANGLE/validationES2.h"
19 #include "libGLESv2/global_state.h"
20 
21 namespace gl
22 {
ActiveTexture(GLenum texture)23 void GL_APIENTRY ActiveTexture(GLenum texture)
24 {
25     Context *context = GetValidGlobalContext();
26     EVENT("glActiveTexture", "context = %d, GLenum texture = %s", CID(context),
27           GLenumToString(GLenumGroup::TextureUnit, texture));
28 
29     if (context)
30     {
31         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
32         bool isCallValid = (context->skipValidation() || ValidateActiveTexture(context, texture));
33         if (isCallValid)
34         {
35             context->activeTexture(texture);
36         }
37         ANGLE_CAPTURE(ActiveTexture, isCallValid, context, texture);
38     }
39 }
40 
AttachShader(GLuint program,GLuint shader)41 void GL_APIENTRY AttachShader(GLuint program, GLuint shader)
42 {
43     Context *context = GetValidGlobalContext();
44     EVENT("glAttachShader", "context = %d, GLuint program = %u, GLuint shader = %u", CID(context),
45           program, shader);
46 
47     if (context)
48     {
49         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
50         ShaderProgramID shaderPacked                          = FromGL<ShaderProgramID>(shader);
51         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
52         bool isCallValid                                      = (context->skipValidation() ||
53                             ValidateAttachShader(context, programPacked, shaderPacked));
54         if (isCallValid)
55         {
56             context->attachShader(programPacked, shaderPacked);
57         }
58         ANGLE_CAPTURE(AttachShader, isCallValid, context, programPacked, shaderPacked);
59     }
60 }
61 
BindAttribLocation(GLuint program,GLuint index,const GLchar * name)62 void GL_APIENTRY BindAttribLocation(GLuint program, GLuint index, const GLchar *name)
63 {
64     Context *context = GetValidGlobalContext();
65     EVENT(
66         "glBindAttribLocation",
67         "context = %d, GLuint program = %u, GLuint index = %u, const GLchar *name = 0x%016" PRIxPTR
68         "",
69         CID(context), program, index, (uintptr_t)name);
70 
71     if (context)
72     {
73         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
74         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
75         bool isCallValid                                      = (context->skipValidation() ||
76                             ValidateBindAttribLocation(context, programPacked, index, name));
77         if (isCallValid)
78         {
79             context->bindAttribLocation(programPacked, index, name);
80         }
81         ANGLE_CAPTURE(BindAttribLocation, isCallValid, context, programPacked, index, name);
82     }
83 }
84 
BindBuffer(GLenum target,GLuint buffer)85 void GL_APIENTRY BindBuffer(GLenum target, GLuint buffer)
86 {
87     Context *context = GetValidGlobalContext();
88     EVENT("glBindBuffer", "context = %d, GLenum target = %s, GLuint buffer = %u", CID(context),
89           GLenumToString(GLenumGroup::BufferTargetARB, target), buffer);
90 
91     if (context)
92     {
93         BufferBinding targetPacked                            = FromGL<BufferBinding>(target);
94         BufferID bufferPacked                                 = FromGL<BufferID>(buffer);
95         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
96         bool isCallValid =
97             (context->skipValidation() || ValidateBindBuffer(context, targetPacked, bufferPacked));
98         if (isCallValid)
99         {
100             context->bindBuffer(targetPacked, bufferPacked);
101         }
102         ANGLE_CAPTURE(BindBuffer, isCallValid, context, targetPacked, bufferPacked);
103     }
104 }
105 
BindFramebuffer(GLenum target,GLuint framebuffer)106 void GL_APIENTRY BindFramebuffer(GLenum target, GLuint framebuffer)
107 {
108     Context *context = GetValidGlobalContext();
109     EVENT("glBindFramebuffer", "context = %d, GLenum target = %s, GLuint framebuffer = %u",
110           CID(context), GLenumToString(GLenumGroup::FramebufferTarget, target), framebuffer);
111 
112     if (context)
113     {
114         FramebufferID framebufferPacked                       = FromGL<FramebufferID>(framebuffer);
115         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
116         bool isCallValid                                      = (context->skipValidation() ||
117                             ValidateBindFramebuffer(context, target, framebufferPacked));
118         if (isCallValid)
119         {
120             context->bindFramebuffer(target, framebufferPacked);
121         }
122         ANGLE_CAPTURE(BindFramebuffer, isCallValid, context, target, framebufferPacked);
123     }
124 }
125 
BindRenderbuffer(GLenum target,GLuint renderbuffer)126 void GL_APIENTRY BindRenderbuffer(GLenum target, GLuint renderbuffer)
127 {
128     Context *context = GetValidGlobalContext();
129     EVENT("glBindRenderbuffer", "context = %d, GLenum target = %s, GLuint renderbuffer = %u",
130           CID(context), GLenumToString(GLenumGroup::RenderbufferTarget, target), renderbuffer);
131 
132     if (context)
133     {
134         RenderbufferID renderbufferPacked = FromGL<RenderbufferID>(renderbuffer);
135         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
136         bool isCallValid                                      = (context->skipValidation() ||
137                             ValidateBindRenderbuffer(context, target, renderbufferPacked));
138         if (isCallValid)
139         {
140             context->bindRenderbuffer(target, renderbufferPacked);
141         }
142         ANGLE_CAPTURE(BindRenderbuffer, isCallValid, context, target, renderbufferPacked);
143     }
144 }
145 
BindTexture(GLenum target,GLuint texture)146 void GL_APIENTRY BindTexture(GLenum target, GLuint texture)
147 {
148     Context *context = GetValidGlobalContext();
149     EVENT("glBindTexture", "context = %d, GLenum target = %s, GLuint texture = %u", CID(context),
150           GLenumToString(GLenumGroup::TextureTarget, target), texture);
151 
152     if (context)
153     {
154         TextureType targetPacked                              = FromGL<TextureType>(target);
155         TextureID texturePacked                               = FromGL<TextureID>(texture);
156         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
157         bool isCallValid                                      = (context->skipValidation() ||
158                             ValidateBindTexture(context, targetPacked, texturePacked));
159         if (isCallValid)
160         {
161             context->bindTexture(targetPacked, texturePacked);
162         }
163         ANGLE_CAPTURE(BindTexture, isCallValid, context, targetPacked, texturePacked);
164     }
165 }
166 
BlendColor(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)167 void GL_APIENTRY BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
168 {
169     Context *context = GetValidGlobalContext();
170     EVENT(
171         "glBlendColor",
172         "context = %d, GLfloat red = %f, GLfloat green = %f, GLfloat blue = %f, GLfloat alpha = %f",
173         CID(context), red, green, blue, alpha);
174 
175     if (context)
176     {
177         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
178         bool isCallValid =
179             (context->skipValidation() || ValidateBlendColor(context, red, green, blue, alpha));
180         if (isCallValid)
181         {
182             context->blendColor(red, green, blue, alpha);
183         }
184         ANGLE_CAPTURE(BlendColor, isCallValid, context, red, green, blue, alpha);
185     }
186 }
187 
BlendEquation(GLenum mode)188 void GL_APIENTRY BlendEquation(GLenum mode)
189 {
190     Context *context = GetValidGlobalContext();
191     EVENT("glBlendEquation", "context = %d, GLenum mode = %s", CID(context),
192           GLenumToString(GLenumGroup::BlendEquationModeEXT, mode));
193 
194     if (context)
195     {
196         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
197         bool isCallValid = (context->skipValidation() || ValidateBlendEquation(context, mode));
198         if (isCallValid)
199         {
200             context->blendEquation(mode);
201         }
202         ANGLE_CAPTURE(BlendEquation, isCallValid, context, mode);
203     }
204 }
205 
BlendEquationSeparate(GLenum modeRGB,GLenum modeAlpha)206 void GL_APIENTRY BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
207 {
208     Context *context = GetValidGlobalContext();
209     EVENT("glBlendEquationSeparate", "context = %d, GLenum modeRGB = %s, GLenum modeAlpha = %s",
210           CID(context), GLenumToString(GLenumGroup::BlendEquationModeEXT, modeRGB),
211           GLenumToString(GLenumGroup::BlendEquationModeEXT, modeAlpha));
212 
213     if (context)
214     {
215         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
216         bool isCallValid                                      = (context->skipValidation() ||
217                             ValidateBlendEquationSeparate(context, modeRGB, modeAlpha));
218         if (isCallValid)
219         {
220             context->blendEquationSeparate(modeRGB, modeAlpha);
221         }
222         ANGLE_CAPTURE(BlendEquationSeparate, isCallValid, context, modeRGB, modeAlpha);
223     }
224 }
225 
BlendFunc(GLenum sfactor,GLenum dfactor)226 void GL_APIENTRY BlendFunc(GLenum sfactor, GLenum dfactor)
227 {
228     Context *context = GetValidGlobalContext();
229     EVENT("glBlendFunc", "context = %d, GLenum sfactor = %s, GLenum dfactor = %s", CID(context),
230           GLenumToString(GLenumGroup::BlendingFactor, sfactor),
231           GLenumToString(GLenumGroup::BlendingFactor, dfactor));
232 
233     if (context)
234     {
235         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
236         bool isCallValid =
237             (context->skipValidation() || ValidateBlendFunc(context, sfactor, dfactor));
238         if (isCallValid)
239         {
240             context->blendFunc(sfactor, dfactor);
241         }
242         ANGLE_CAPTURE(BlendFunc, isCallValid, context, sfactor, dfactor);
243     }
244 }
245 
BlendFuncSeparate(GLenum sfactorRGB,GLenum dfactorRGB,GLenum sfactorAlpha,GLenum dfactorAlpha)246 void GL_APIENTRY BlendFuncSeparate(GLenum sfactorRGB,
247                                    GLenum dfactorRGB,
248                                    GLenum sfactorAlpha,
249                                    GLenum dfactorAlpha)
250 {
251     Context *context = GetValidGlobalContext();
252     EVENT("glBlendFuncSeparate",
253           "context = %d, GLenum sfactorRGB = %s, GLenum dfactorRGB = %s, GLenum sfactorAlpha = %s, "
254           "GLenum dfactorAlpha = %s",
255           CID(context), GLenumToString(GLenumGroup::BlendingFactor, sfactorRGB),
256           GLenumToString(GLenumGroup::BlendingFactor, dfactorRGB),
257           GLenumToString(GLenumGroup::BlendingFactor, sfactorAlpha),
258           GLenumToString(GLenumGroup::BlendingFactor, dfactorAlpha));
259 
260     if (context)
261     {
262         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
263         bool isCallValid =
264             (context->skipValidation() || ValidateBlendFuncSeparate(context, sfactorRGB, dfactorRGB,
265                                                                     sfactorAlpha, dfactorAlpha));
266         if (isCallValid)
267         {
268             context->blendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
269         }
270         ANGLE_CAPTURE(BlendFuncSeparate, isCallValid, context, sfactorRGB, dfactorRGB, sfactorAlpha,
271                       dfactorAlpha);
272     }
273 }
274 
BufferData(GLenum target,GLsizeiptr size,const void * data,GLenum usage)275 void GL_APIENTRY BufferData(GLenum target, GLsizeiptr size, const void *data, GLenum usage)
276 {
277     Context *context = GetValidGlobalContext();
278     EVENT("glBufferData",
279           "context = %d, GLenum target = %s, GLsizeiptr size = %llu, const void *data = "
280           "0x%016" PRIxPTR ", GLenum usage = %s",
281           CID(context), GLenumToString(GLenumGroup::BufferTargetARB, target),
282           static_cast<unsigned long long>(size), (uintptr_t)data,
283           GLenumToString(GLenumGroup::BufferUsageARB, usage));
284 
285     if (context)
286     {
287         BufferBinding targetPacked                            = FromGL<BufferBinding>(target);
288         BufferUsage usagePacked                               = FromGL<BufferUsage>(usage);
289         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
290         bool isCallValid                                      = (context->skipValidation() ||
291                             ValidateBufferData(context, targetPacked, size, data, usagePacked));
292         if (isCallValid)
293         {
294             context->bufferData(targetPacked, size, data, usagePacked);
295         }
296         ANGLE_CAPTURE(BufferData, isCallValid, context, targetPacked, size, data, usagePacked);
297     }
298 }
299 
BufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const void * data)300 void GL_APIENTRY BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void *data)
301 {
302     Context *context = GetValidGlobalContext();
303     EVENT("glBufferSubData",
304           "context = %d, GLenum target = %s, GLintptr offset = %llu, GLsizeiptr size = %llu, const "
305           "void *data = 0x%016" PRIxPTR "",
306           CID(context), GLenumToString(GLenumGroup::BufferTargetARB, target),
307           static_cast<unsigned long long>(offset), static_cast<unsigned long long>(size),
308           (uintptr_t)data);
309 
310     if (context)
311     {
312         BufferBinding targetPacked                            = FromGL<BufferBinding>(target);
313         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
314         bool isCallValid                                      = (context->skipValidation() ||
315                             ValidateBufferSubData(context, targetPacked, offset, size, data));
316         if (isCallValid)
317         {
318             context->bufferSubData(targetPacked, offset, size, data);
319         }
320         ANGLE_CAPTURE(BufferSubData, isCallValid, context, targetPacked, offset, size, data);
321     }
322 }
323 
CheckFramebufferStatus(GLenum target)324 GLenum GL_APIENTRY CheckFramebufferStatus(GLenum target)
325 {
326     Context *context = GetValidGlobalContext();
327     EVENT("glCheckFramebufferStatus", "context = %d, GLenum target = %s", CID(context),
328           GLenumToString(GLenumGroup::FramebufferTarget, target));
329 
330     GLenum returnValue;
331     if (context)
332     {
333         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
334         bool isCallValid =
335             (context->skipValidation() || ValidateCheckFramebufferStatus(context, target));
336         if (isCallValid)
337         {
338             returnValue = context->checkFramebufferStatus(target);
339         }
340         else
341         {
342             returnValue = GetDefaultReturnValue<EntryPoint::CheckFramebufferStatus, GLenum>();
343         }
344         ANGLE_CAPTURE(CheckFramebufferStatus, isCallValid, context, target, returnValue);
345     }
346     else
347     {
348         returnValue = GetDefaultReturnValue<EntryPoint::CheckFramebufferStatus, GLenum>();
349     }
350     return returnValue;
351 }
352 
Clear(GLbitfield mask)353 void GL_APIENTRY Clear(GLbitfield mask)
354 {
355     Context *context = GetValidGlobalContext();
356     EVENT("glClear", "context = %d, GLbitfield mask = %s", CID(context),
357           GLbitfieldToString(GLenumGroup::ClearBufferMask, mask).c_str());
358 
359     if (context)
360     {
361         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
362         bool isCallValid = (context->skipValidation() || ValidateClear(context, mask));
363         if (isCallValid)
364         {
365             context->clear(mask);
366         }
367         ANGLE_CAPTURE(Clear, isCallValid, context, mask);
368     }
369 }
370 
ClearColor(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)371 void GL_APIENTRY ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
372 {
373     Context *context = GetValidGlobalContext();
374     EVENT(
375         "glClearColor",
376         "context = %d, GLfloat red = %f, GLfloat green = %f, GLfloat blue = %f, GLfloat alpha = %f",
377         CID(context), red, green, blue, alpha);
378 
379     if (context)
380     {
381         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
382         bool isCallValid =
383             (context->skipValidation() || ValidateClearColor(context, red, green, blue, alpha));
384         if (isCallValid)
385         {
386             context->clearColor(red, green, blue, alpha);
387         }
388         ANGLE_CAPTURE(ClearColor, isCallValid, context, red, green, blue, alpha);
389     }
390 }
391 
ClearDepthf(GLfloat d)392 void GL_APIENTRY ClearDepthf(GLfloat d)
393 {
394     Context *context = GetValidGlobalContext();
395     EVENT("glClearDepthf", "context = %d, GLfloat d = %f", CID(context), d);
396 
397     if (context)
398     {
399         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
400         bool isCallValid = (context->skipValidation() || ValidateClearDepthf(context, d));
401         if (isCallValid)
402         {
403             context->clearDepthf(d);
404         }
405         ANGLE_CAPTURE(ClearDepthf, isCallValid, context, d);
406     }
407 }
408 
ClearStencil(GLint s)409 void GL_APIENTRY ClearStencil(GLint s)
410 {
411     Context *context = GetValidGlobalContext();
412     EVENT("glClearStencil", "context = %d, GLint s = %d", CID(context), s);
413 
414     if (context)
415     {
416         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
417         bool isCallValid = (context->skipValidation() || ValidateClearStencil(context, s));
418         if (isCallValid)
419         {
420             context->clearStencil(s);
421         }
422         ANGLE_CAPTURE(ClearStencil, isCallValid, context, s);
423     }
424 }
425 
ColorMask(GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)426 void GL_APIENTRY ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
427 {
428     Context *context = GetValidGlobalContext();
429     EVENT("glColorMask",
430           "context = %d, GLboolean red = %s, GLboolean green = %s, GLboolean blue = %s, GLboolean "
431           "alpha = %s",
432           CID(context), GLbooleanToString(red), GLbooleanToString(green), GLbooleanToString(blue),
433           GLbooleanToString(alpha));
434 
435     if (context)
436     {
437         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
438         bool isCallValid =
439             (context->skipValidation() || ValidateColorMask(context, red, green, blue, alpha));
440         if (isCallValid)
441         {
442             context->colorMask(red, green, blue, alpha);
443         }
444         ANGLE_CAPTURE(ColorMask, isCallValid, context, red, green, blue, alpha);
445     }
446 }
447 
CompileShader(GLuint shader)448 void GL_APIENTRY CompileShader(GLuint shader)
449 {
450     Context *context = GetValidGlobalContext();
451     EVENT("glCompileShader", "context = %d, GLuint shader = %u", CID(context), shader);
452 
453     if (context)
454     {
455         ShaderProgramID shaderPacked                          = FromGL<ShaderProgramID>(shader);
456         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
457         bool isCallValid =
458             (context->skipValidation() || ValidateCompileShader(context, shaderPacked));
459         if (isCallValid)
460         {
461             context->compileShader(shaderPacked);
462         }
463         ANGLE_CAPTURE(CompileShader, isCallValid, context, shaderPacked);
464     }
465 }
466 
CompressedTexImage2D(GLenum target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const void * data)467 void GL_APIENTRY CompressedTexImage2D(GLenum target,
468                                       GLint level,
469                                       GLenum internalformat,
470                                       GLsizei width,
471                                       GLsizei height,
472                                       GLint border,
473                                       GLsizei imageSize,
474                                       const void *data)
475 {
476     Context *context = GetValidGlobalContext();
477     EVENT("glCompressedTexImage2D",
478           "context = %d, GLenum target = %s, GLint level = %d, GLenum internalformat = %s, GLsizei "
479           "width = %d, GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const void "
480           "*data = 0x%016" PRIxPTR "",
481           CID(context), GLenumToString(GLenumGroup::TextureTarget, target), level,
482           GLenumToString(GLenumGroup::InternalFormat, internalformat), width, height, border,
483           imageSize, (uintptr_t)data);
484 
485     if (context)
486     {
487         TextureTarget targetPacked                            = FromGL<TextureTarget>(target);
488         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
489         bool isCallValid =
490             (context->skipValidation() ||
491              ValidateCompressedTexImage2D(context, targetPacked, level, internalformat, width,
492                                           height, border, imageSize, data));
493         if (isCallValid)
494         {
495             context->compressedTexImage2D(targetPacked, level, internalformat, width, height,
496                                           border, imageSize, data);
497         }
498         ANGLE_CAPTURE(CompressedTexImage2D, isCallValid, context, targetPacked, level,
499                       internalformat, width, height, border, imageSize, data);
500     }
501 }
502 
CompressedTexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const void * data)503 void GL_APIENTRY CompressedTexSubImage2D(GLenum target,
504                                          GLint level,
505                                          GLint xoffset,
506                                          GLint yoffset,
507                                          GLsizei width,
508                                          GLsizei height,
509                                          GLenum format,
510                                          GLsizei imageSize,
511                                          const void *data)
512 {
513     Context *context = GetValidGlobalContext();
514     EVENT("glCompressedTexSubImage2D",
515           "context = %d, GLenum target = %s, GLint level = %d, GLint xoffset = %d, GLint yoffset = "
516           "%d, GLsizei width = %d, GLsizei height = %d, GLenum format = %s, GLsizei imageSize = "
517           "%d, const void *data = 0x%016" PRIxPTR "",
518           CID(context), GLenumToString(GLenumGroup::TextureTarget, target), level, xoffset, yoffset,
519           width, height, GLenumToString(GLenumGroup::PixelFormat, format), imageSize,
520           (uintptr_t)data);
521 
522     if (context)
523     {
524         TextureTarget targetPacked                            = FromGL<TextureTarget>(target);
525         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
526         bool isCallValid =
527             (context->skipValidation() ||
528              ValidateCompressedTexSubImage2D(context, targetPacked, level, xoffset, yoffset, width,
529                                              height, format, imageSize, data));
530         if (isCallValid)
531         {
532             context->compressedTexSubImage2D(targetPacked, level, xoffset, yoffset, width, height,
533                                              format, imageSize, data);
534         }
535         ANGLE_CAPTURE(CompressedTexSubImage2D, isCallValid, context, targetPacked, level, xoffset,
536                       yoffset, width, height, format, imageSize, data);
537     }
538 }
539 
CopyTexImage2D(GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)540 void GL_APIENTRY CopyTexImage2D(GLenum target,
541                                 GLint level,
542                                 GLenum internalformat,
543                                 GLint x,
544                                 GLint y,
545                                 GLsizei width,
546                                 GLsizei height,
547                                 GLint border)
548 {
549     Context *context = GetValidGlobalContext();
550     EVENT("glCopyTexImage2D",
551           "context = %d, GLenum target = %s, GLint level = %d, GLenum internalformat = %s, GLint x "
552           "= %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d",
553           CID(context), GLenumToString(GLenumGroup::TextureTarget, target), level,
554           GLenumToString(GLenumGroup::InternalFormat, internalformat), x, y, width, height, border);
555 
556     if (context)
557     {
558         TextureTarget targetPacked                            = FromGL<TextureTarget>(target);
559         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
560         bool isCallValid                                      = (context->skipValidation() ||
561                             ValidateCopyTexImage2D(context, targetPacked, level, internalformat, x,
562                                                    y, width, height, border));
563         if (isCallValid)
564         {
565             context->copyTexImage2D(targetPacked, level, internalformat, x, y, width, height,
566                                     border);
567         }
568         ANGLE_CAPTURE(CopyTexImage2D, isCallValid, context, targetPacked, level, internalformat, x,
569                       y, width, height, border);
570     }
571 }
572 
CopyTexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLsizei height)573 void GL_APIENTRY CopyTexSubImage2D(GLenum target,
574                                    GLint level,
575                                    GLint xoffset,
576                                    GLint yoffset,
577                                    GLint x,
578                                    GLint y,
579                                    GLsizei width,
580                                    GLsizei height)
581 {
582     Context *context = GetValidGlobalContext();
583     EVENT("glCopyTexSubImage2D",
584           "context = %d, GLenum target = %s, GLint level = %d, GLint xoffset = %d, GLint yoffset = "
585           "%d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d",
586           CID(context), GLenumToString(GLenumGroup::TextureTarget, target), level, xoffset, yoffset,
587           x, y, width, height);
588 
589     if (context)
590     {
591         TextureTarget targetPacked                            = FromGL<TextureTarget>(target);
592         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
593         bool isCallValid                                      = (context->skipValidation() ||
594                             ValidateCopyTexSubImage2D(context, targetPacked, level, xoffset,
595                                                       yoffset, x, y, width, height));
596         if (isCallValid)
597         {
598             context->copyTexSubImage2D(targetPacked, level, xoffset, yoffset, x, y, width, height);
599         }
600         ANGLE_CAPTURE(CopyTexSubImage2D, isCallValid, context, targetPacked, level, xoffset,
601                       yoffset, x, y, width, height);
602     }
603 }
604 
CreateProgram()605 GLuint GL_APIENTRY CreateProgram()
606 {
607     Context *context = GetValidGlobalContext();
608     EVENT("glCreateProgram", "context = %d", CID(context));
609 
610     GLuint returnValue;
611     if (context)
612     {
613         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
614         bool isCallValid = (context->skipValidation() || ValidateCreateProgram(context));
615         if (isCallValid)
616         {
617             returnValue = context->createProgram();
618         }
619         else
620         {
621             returnValue = GetDefaultReturnValue<EntryPoint::CreateProgram, GLuint>();
622         }
623         ANGLE_CAPTURE(CreateProgram, isCallValid, context, returnValue);
624     }
625     else
626     {
627         returnValue = GetDefaultReturnValue<EntryPoint::CreateProgram, GLuint>();
628     }
629     return returnValue;
630 }
631 
CreateShader(GLenum type)632 GLuint GL_APIENTRY CreateShader(GLenum type)
633 {
634     Context *context = GetValidGlobalContext();
635     EVENT("glCreateShader", "context = %d, GLenum type = %s", CID(context),
636           GLenumToString(GLenumGroup::ShaderType, type));
637 
638     GLuint returnValue;
639     if (context)
640     {
641         ShaderType typePacked                                 = FromGL<ShaderType>(type);
642         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
643         bool isCallValid = (context->skipValidation() || ValidateCreateShader(context, typePacked));
644         if (isCallValid)
645         {
646             returnValue = context->createShader(typePacked);
647         }
648         else
649         {
650             returnValue = GetDefaultReturnValue<EntryPoint::CreateShader, GLuint>();
651         }
652         ANGLE_CAPTURE(CreateShader, isCallValid, context, typePacked, returnValue);
653     }
654     else
655     {
656         returnValue = GetDefaultReturnValue<EntryPoint::CreateShader, GLuint>();
657     }
658     return returnValue;
659 }
660 
CullFace(GLenum mode)661 void GL_APIENTRY CullFace(GLenum mode)
662 {
663     Context *context = GetValidGlobalContext();
664     EVENT("glCullFace", "context = %d, GLenum mode = %s", CID(context),
665           GLenumToString(GLenumGroup::CullFaceMode, mode));
666 
667     if (context)
668     {
669         CullFaceMode modePacked                               = FromGL<CullFaceMode>(mode);
670         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
671         bool isCallValid = (context->skipValidation() || ValidateCullFace(context, modePacked));
672         if (isCallValid)
673         {
674             context->cullFace(modePacked);
675         }
676         ANGLE_CAPTURE(CullFace, isCallValid, context, modePacked);
677     }
678 }
679 
DeleteBuffers(GLsizei n,const GLuint * buffers)680 void GL_APIENTRY DeleteBuffers(GLsizei n, const GLuint *buffers)
681 {
682     Context *context = GetValidGlobalContext();
683     EVENT("glDeleteBuffers",
684           "context = %d, GLsizei n = %d, const GLuint *buffers = 0x%016" PRIxPTR "", CID(context),
685           n, (uintptr_t)buffers);
686 
687     if (context)
688     {
689         const BufferID *buffersPacked                         = FromGL<const BufferID *>(buffers);
690         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
691         bool isCallValid =
692             (context->skipValidation() || ValidateDeleteBuffers(context, n, buffersPacked));
693         if (isCallValid)
694         {
695             context->deleteBuffers(n, buffersPacked);
696         }
697         ANGLE_CAPTURE(DeleteBuffers, isCallValid, context, n, buffersPacked);
698     }
699 }
700 
DeleteFramebuffers(GLsizei n,const GLuint * framebuffers)701 void GL_APIENTRY DeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
702 {
703     Context *context = GetValidGlobalContext();
704     EVENT("glDeleteFramebuffers",
705           "context = %d, GLsizei n = %d, const GLuint *framebuffers = 0x%016" PRIxPTR "",
706           CID(context), n, (uintptr_t)framebuffers);
707 
708     if (context)
709     {
710         const FramebufferID *framebuffersPacked = FromGL<const FramebufferID *>(framebuffers);
711         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
712         bool isCallValid                                      = (context->skipValidation() ||
713                             ValidateDeleteFramebuffers(context, n, framebuffersPacked));
714         if (isCallValid)
715         {
716             context->deleteFramebuffers(n, framebuffersPacked);
717         }
718         ANGLE_CAPTURE(DeleteFramebuffers, isCallValid, context, n, framebuffersPacked);
719     }
720 }
721 
DeleteProgram(GLuint program)722 void GL_APIENTRY DeleteProgram(GLuint program)
723 {
724     Context *context = GetValidGlobalContext();
725     EVENT("glDeleteProgram", "context = %d, GLuint program = %u", CID(context), program);
726 
727     if (context)
728     {
729         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
730         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
731         bool isCallValid =
732             (context->skipValidation() || ValidateDeleteProgram(context, programPacked));
733         if (isCallValid)
734         {
735             context->deleteProgram(programPacked);
736         }
737         ANGLE_CAPTURE(DeleteProgram, isCallValid, context, programPacked);
738     }
739 }
740 
DeleteRenderbuffers(GLsizei n,const GLuint * renderbuffers)741 void GL_APIENTRY DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
742 {
743     Context *context = GetValidGlobalContext();
744     EVENT("glDeleteRenderbuffers",
745           "context = %d, GLsizei n = %d, const GLuint *renderbuffers = 0x%016" PRIxPTR "",
746           CID(context), n, (uintptr_t)renderbuffers);
747 
748     if (context)
749     {
750         const RenderbufferID *renderbuffersPacked = FromGL<const RenderbufferID *>(renderbuffers);
751         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
752         bool isCallValid                                      = (context->skipValidation() ||
753                             ValidateDeleteRenderbuffers(context, n, renderbuffersPacked));
754         if (isCallValid)
755         {
756             context->deleteRenderbuffers(n, renderbuffersPacked);
757         }
758         ANGLE_CAPTURE(DeleteRenderbuffers, isCallValid, context, n, renderbuffersPacked);
759     }
760 }
761 
DeleteShader(GLuint shader)762 void GL_APIENTRY DeleteShader(GLuint shader)
763 {
764     Context *context = GetValidGlobalContext();
765     EVENT("glDeleteShader", "context = %d, GLuint shader = %u", CID(context), shader);
766 
767     if (context)
768     {
769         ShaderProgramID shaderPacked                          = FromGL<ShaderProgramID>(shader);
770         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
771         bool isCallValid =
772             (context->skipValidation() || ValidateDeleteShader(context, shaderPacked));
773         if (isCallValid)
774         {
775             context->deleteShader(shaderPacked);
776         }
777         ANGLE_CAPTURE(DeleteShader, isCallValid, context, shaderPacked);
778     }
779 }
780 
DeleteTextures(GLsizei n,const GLuint * textures)781 void GL_APIENTRY DeleteTextures(GLsizei n, const GLuint *textures)
782 {
783     Context *context = GetValidGlobalContext();
784     EVENT("glDeleteTextures",
785           "context = %d, GLsizei n = %d, const GLuint *textures = 0x%016" PRIxPTR "", CID(context),
786           n, (uintptr_t)textures);
787 
788     if (context)
789     {
790         const TextureID *texturesPacked                       = FromGL<const TextureID *>(textures);
791         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
792         bool isCallValid =
793             (context->skipValidation() || ValidateDeleteTextures(context, n, texturesPacked));
794         if (isCallValid)
795         {
796             context->deleteTextures(n, texturesPacked);
797         }
798         ANGLE_CAPTURE(DeleteTextures, isCallValid, context, n, texturesPacked);
799     }
800 }
801 
DepthFunc(GLenum func)802 void GL_APIENTRY DepthFunc(GLenum func)
803 {
804     Context *context = GetValidGlobalContext();
805     EVENT("glDepthFunc", "context = %d, GLenum func = %s", CID(context),
806           GLenumToString(GLenumGroup::DepthFunction, func));
807 
808     if (context)
809     {
810         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
811         bool isCallValid = (context->skipValidation() || ValidateDepthFunc(context, func));
812         if (isCallValid)
813         {
814             context->depthFunc(func);
815         }
816         ANGLE_CAPTURE(DepthFunc, isCallValid, context, func);
817     }
818 }
819 
DepthMask(GLboolean flag)820 void GL_APIENTRY DepthMask(GLboolean flag)
821 {
822     Context *context = GetValidGlobalContext();
823     EVENT("glDepthMask", "context = %d, GLboolean flag = %s", CID(context),
824           GLbooleanToString(flag));
825 
826     if (context)
827     {
828         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
829         bool isCallValid = (context->skipValidation() || ValidateDepthMask(context, flag));
830         if (isCallValid)
831         {
832             context->depthMask(flag);
833         }
834         ANGLE_CAPTURE(DepthMask, isCallValid, context, flag);
835     }
836 }
837 
DepthRangef(GLfloat n,GLfloat f)838 void GL_APIENTRY DepthRangef(GLfloat n, GLfloat f)
839 {
840     Context *context = GetValidGlobalContext();
841     EVENT("glDepthRangef", "context = %d, GLfloat n = %f, GLfloat f = %f", CID(context), n, f);
842 
843     if (context)
844     {
845         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
846         bool isCallValid = (context->skipValidation() || ValidateDepthRangef(context, n, f));
847         if (isCallValid)
848         {
849             context->depthRangef(n, f);
850         }
851         ANGLE_CAPTURE(DepthRangef, isCallValid, context, n, f);
852     }
853 }
854 
DetachShader(GLuint program,GLuint shader)855 void GL_APIENTRY DetachShader(GLuint program, GLuint shader)
856 {
857     Context *context = GetValidGlobalContext();
858     EVENT("glDetachShader", "context = %d, GLuint program = %u, GLuint shader = %u", CID(context),
859           program, shader);
860 
861     if (context)
862     {
863         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
864         ShaderProgramID shaderPacked                          = FromGL<ShaderProgramID>(shader);
865         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
866         bool isCallValid                                      = (context->skipValidation() ||
867                             ValidateDetachShader(context, programPacked, shaderPacked));
868         if (isCallValid)
869         {
870             context->detachShader(programPacked, shaderPacked);
871         }
872         ANGLE_CAPTURE(DetachShader, isCallValid, context, programPacked, shaderPacked);
873     }
874 }
875 
Disable(GLenum cap)876 void GL_APIENTRY Disable(GLenum cap)
877 {
878     Context *context = GetValidGlobalContext();
879     EVENT("glDisable", "context = %d, GLenum cap = %s", CID(context),
880           GLenumToString(GLenumGroup::EnableCap, cap));
881 
882     if (context)
883     {
884         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
885         bool isCallValid = (context->skipValidation() || ValidateDisable(context, cap));
886         if (isCallValid)
887         {
888             context->disable(cap);
889         }
890         ANGLE_CAPTURE(Disable, isCallValid, context, cap);
891     }
892 }
893 
DisableVertexAttribArray(GLuint index)894 void GL_APIENTRY DisableVertexAttribArray(GLuint index)
895 {
896     Context *context = GetValidGlobalContext();
897     EVENT("glDisableVertexAttribArray", "context = %d, GLuint index = %u", CID(context), index);
898 
899     if (context)
900     {
901         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
902         bool isCallValid =
903             (context->skipValidation() || ValidateDisableVertexAttribArray(context, index));
904         if (isCallValid)
905         {
906             context->disableVertexAttribArray(index);
907         }
908         ANGLE_CAPTURE(DisableVertexAttribArray, isCallValid, context, index);
909     }
910 }
911 
DrawArrays(GLenum mode,GLint first,GLsizei count)912 void GL_APIENTRY DrawArrays(GLenum mode, GLint first, GLsizei count)
913 {
914     Context *context = GetValidGlobalContext();
915     EVENT("glDrawArrays", "context = %d, GLenum mode = %s, GLint first = %d, GLsizei count = %d",
916           CID(context), GLenumToString(GLenumGroup::PrimitiveType, mode), first, count);
917 
918     if (context)
919     {
920         PrimitiveMode modePacked                              = FromGL<PrimitiveMode>(mode);
921         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
922         bool isCallValid =
923             (context->skipValidation() || ValidateDrawArrays(context, modePacked, first, count));
924         if (isCallValid)
925         {
926             context->drawArrays(modePacked, first, count);
927         }
928         ANGLE_CAPTURE(DrawArrays, isCallValid, context, modePacked, first, count);
929     }
930 }
931 
DrawElements(GLenum mode,GLsizei count,GLenum type,const void * indices)932 void GL_APIENTRY DrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices)
933 {
934     Context *context = GetValidGlobalContext();
935     EVENT("glDrawElements",
936           "context = %d, GLenum mode = %s, GLsizei count = %d, GLenum type = %s, const void "
937           "*indices = 0x%016" PRIxPTR "",
938           CID(context), GLenumToString(GLenumGroup::PrimitiveType, mode), count,
939           GLenumToString(GLenumGroup::DrawElementsType, type), (uintptr_t)indices);
940 
941     if (context)
942     {
943         PrimitiveMode modePacked                              = FromGL<PrimitiveMode>(mode);
944         DrawElementsType typePacked                           = FromGL<DrawElementsType>(type);
945         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
946         bool isCallValid                                      = (context->skipValidation() ||
947                             ValidateDrawElements(context, modePacked, count, typePacked, indices));
948         if (isCallValid)
949         {
950             context->drawElements(modePacked, count, typePacked, indices);
951         }
952         ANGLE_CAPTURE(DrawElements, isCallValid, context, modePacked, count, typePacked, indices);
953     }
954 }
955 
Enable(GLenum cap)956 void GL_APIENTRY Enable(GLenum cap)
957 {
958     Context *context = GetValidGlobalContext();
959     EVENT("glEnable", "context = %d, GLenum cap = %s", CID(context),
960           GLenumToString(GLenumGroup::EnableCap, cap));
961 
962     if (context)
963     {
964         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
965         bool isCallValid = (context->skipValidation() || ValidateEnable(context, cap));
966         if (isCallValid)
967         {
968             context->enable(cap);
969         }
970         ANGLE_CAPTURE(Enable, isCallValid, context, cap);
971     }
972 }
973 
EnableVertexAttribArray(GLuint index)974 void GL_APIENTRY EnableVertexAttribArray(GLuint index)
975 {
976     Context *context = GetValidGlobalContext();
977     EVENT("glEnableVertexAttribArray", "context = %d, GLuint index = %u", CID(context), index);
978 
979     if (context)
980     {
981         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
982         bool isCallValid =
983             (context->skipValidation() || ValidateEnableVertexAttribArray(context, index));
984         if (isCallValid)
985         {
986             context->enableVertexAttribArray(index);
987         }
988         ANGLE_CAPTURE(EnableVertexAttribArray, isCallValid, context, index);
989     }
990 }
991 
Finish()992 void GL_APIENTRY Finish()
993 {
994     Context *context = GetValidGlobalContext();
995     EVENT("glFinish", "context = %d", CID(context));
996 
997     if (context)
998     {
999         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1000         bool isCallValid = (context->skipValidation() || ValidateFinish(context));
1001         if (isCallValid)
1002         {
1003             context->finish();
1004         }
1005         ANGLE_CAPTURE(Finish, isCallValid, context);
1006     }
1007 }
1008 
Flush()1009 void GL_APIENTRY Flush()
1010 {
1011     Context *context = GetValidGlobalContext();
1012     EVENT("glFlush", "context = %d", CID(context));
1013 
1014     if (context)
1015     {
1016         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1017         bool isCallValid = (context->skipValidation() || ValidateFlush(context));
1018         if (isCallValid)
1019         {
1020             context->flush();
1021         }
1022         ANGLE_CAPTURE(Flush, isCallValid, context);
1023     }
1024 }
1025 
FramebufferRenderbuffer(GLenum target,GLenum attachment,GLenum renderbuffertarget,GLuint renderbuffer)1026 void GL_APIENTRY FramebufferRenderbuffer(GLenum target,
1027                                          GLenum attachment,
1028                                          GLenum renderbuffertarget,
1029                                          GLuint renderbuffer)
1030 {
1031     Context *context = GetValidGlobalContext();
1032     EVENT("glFramebufferRenderbuffer",
1033           "context = %d, GLenum target = %s, GLenum attachment = %s, GLenum renderbuffertarget = "
1034           "%s, GLuint renderbuffer = %u",
1035           CID(context), GLenumToString(GLenumGroup::FramebufferTarget, target),
1036           GLenumToString(GLenumGroup::FramebufferAttachment, attachment),
1037           GLenumToString(GLenumGroup::RenderbufferTarget, renderbuffertarget), renderbuffer);
1038 
1039     if (context)
1040     {
1041         RenderbufferID renderbufferPacked = FromGL<RenderbufferID>(renderbuffer);
1042         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1043         bool isCallValid =
1044             (context->skipValidation() ||
1045              ValidateFramebufferRenderbuffer(context, target, attachment, renderbuffertarget,
1046                                              renderbufferPacked));
1047         if (isCallValid)
1048         {
1049             context->framebufferRenderbuffer(target, attachment, renderbuffertarget,
1050                                              renderbufferPacked);
1051         }
1052         ANGLE_CAPTURE(FramebufferRenderbuffer, isCallValid, context, target, attachment,
1053                       renderbuffertarget, renderbufferPacked);
1054     }
1055 }
1056 
FramebufferTexture2D(GLenum target,GLenum attachment,GLenum textarget,GLuint texture,GLint level)1057 void GL_APIENTRY FramebufferTexture2D(GLenum target,
1058                                       GLenum attachment,
1059                                       GLenum textarget,
1060                                       GLuint texture,
1061                                       GLint level)
1062 {
1063     Context *context = GetValidGlobalContext();
1064     EVENT("glFramebufferTexture2D",
1065           "context = %d, GLenum target = %s, GLenum attachment = %s, GLenum textarget = %s, GLuint "
1066           "texture = %u, GLint level = %d",
1067           CID(context), GLenumToString(GLenumGroup::FramebufferTarget, target),
1068           GLenumToString(GLenumGroup::FramebufferAttachment, attachment),
1069           GLenumToString(GLenumGroup::TextureTarget, textarget), texture, level);
1070 
1071     if (context)
1072     {
1073         TextureTarget textargetPacked                         = FromGL<TextureTarget>(textarget);
1074         TextureID texturePacked                               = FromGL<TextureID>(texture);
1075         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1076         bool isCallValid                                      = (context->skipValidation() ||
1077                             ValidateFramebufferTexture2D(context, target, attachment,
1078                                                          textargetPacked, texturePacked, level));
1079         if (isCallValid)
1080         {
1081             context->framebufferTexture2D(target, attachment, textargetPacked, texturePacked,
1082                                           level);
1083         }
1084         ANGLE_CAPTURE(FramebufferTexture2D, isCallValid, context, target, attachment,
1085                       textargetPacked, texturePacked, level);
1086     }
1087 }
1088 
FrontFace(GLenum mode)1089 void GL_APIENTRY FrontFace(GLenum mode)
1090 {
1091     Context *context = GetValidGlobalContext();
1092     EVENT("glFrontFace", "context = %d, GLenum mode = %s", CID(context),
1093           GLenumToString(GLenumGroup::FrontFaceDirection, mode));
1094 
1095     if (context)
1096     {
1097         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1098         bool isCallValid = (context->skipValidation() || ValidateFrontFace(context, mode));
1099         if (isCallValid)
1100         {
1101             context->frontFace(mode);
1102         }
1103         ANGLE_CAPTURE(FrontFace, isCallValid, context, mode);
1104     }
1105 }
1106 
GenBuffers(GLsizei n,GLuint * buffers)1107 void GL_APIENTRY GenBuffers(GLsizei n, GLuint *buffers)
1108 {
1109     Context *context = GetValidGlobalContext();
1110     EVENT("glGenBuffers", "context = %d, GLsizei n = %d, GLuint *buffers = 0x%016" PRIxPTR "",
1111           CID(context), n, (uintptr_t)buffers);
1112 
1113     if (context)
1114     {
1115         BufferID *buffersPacked                               = FromGL<BufferID *>(buffers);
1116         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1117         bool isCallValid =
1118             (context->skipValidation() || ValidateGenBuffers(context, n, buffersPacked));
1119         if (isCallValid)
1120         {
1121             context->genBuffers(n, buffersPacked);
1122         }
1123         ANGLE_CAPTURE(GenBuffers, isCallValid, context, n, buffersPacked);
1124     }
1125 }
1126 
GenFramebuffers(GLsizei n,GLuint * framebuffers)1127 void GL_APIENTRY GenFramebuffers(GLsizei n, GLuint *framebuffers)
1128 {
1129     Context *context = GetValidGlobalContext();
1130     EVENT("glGenFramebuffers",
1131           "context = %d, GLsizei n = %d, GLuint *framebuffers = 0x%016" PRIxPTR "", CID(context), n,
1132           (uintptr_t)framebuffers);
1133 
1134     if (context)
1135     {
1136         FramebufferID *framebuffersPacked = FromGL<FramebufferID *>(framebuffers);
1137         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1138         bool isCallValid =
1139             (context->skipValidation() || ValidateGenFramebuffers(context, n, framebuffersPacked));
1140         if (isCallValid)
1141         {
1142             context->genFramebuffers(n, framebuffersPacked);
1143         }
1144         ANGLE_CAPTURE(GenFramebuffers, isCallValid, context, n, framebuffersPacked);
1145     }
1146 }
1147 
GenRenderbuffers(GLsizei n,GLuint * renderbuffers)1148 void GL_APIENTRY GenRenderbuffers(GLsizei n, GLuint *renderbuffers)
1149 {
1150     Context *context = GetValidGlobalContext();
1151     EVENT("glGenRenderbuffers",
1152           "context = %d, GLsizei n = %d, GLuint *renderbuffers = 0x%016" PRIxPTR "", CID(context),
1153           n, (uintptr_t)renderbuffers);
1154 
1155     if (context)
1156     {
1157         RenderbufferID *renderbuffersPacked = FromGL<RenderbufferID *>(renderbuffers);
1158         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1159         bool isCallValid                                      = (context->skipValidation() ||
1160                             ValidateGenRenderbuffers(context, n, renderbuffersPacked));
1161         if (isCallValid)
1162         {
1163             context->genRenderbuffers(n, renderbuffersPacked);
1164         }
1165         ANGLE_CAPTURE(GenRenderbuffers, isCallValid, context, n, renderbuffersPacked);
1166     }
1167 }
1168 
GenTextures(GLsizei n,GLuint * textures)1169 void GL_APIENTRY GenTextures(GLsizei n, GLuint *textures)
1170 {
1171     Context *context = GetValidGlobalContext();
1172     EVENT("glGenTextures", "context = %d, GLsizei n = %d, GLuint *textures = 0x%016" PRIxPTR "",
1173           CID(context), n, (uintptr_t)textures);
1174 
1175     if (context)
1176     {
1177         TextureID *texturesPacked                             = FromGL<TextureID *>(textures);
1178         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1179         bool isCallValid =
1180             (context->skipValidation() || ValidateGenTextures(context, n, texturesPacked));
1181         if (isCallValid)
1182         {
1183             context->genTextures(n, texturesPacked);
1184         }
1185         ANGLE_CAPTURE(GenTextures, isCallValid, context, n, texturesPacked);
1186     }
1187 }
1188 
GenerateMipmap(GLenum target)1189 void GL_APIENTRY GenerateMipmap(GLenum target)
1190 {
1191     Context *context = GetValidGlobalContext();
1192     EVENT("glGenerateMipmap", "context = %d, GLenum target = %s", CID(context),
1193           GLenumToString(GLenumGroup::TextureTarget, target));
1194 
1195     if (context)
1196     {
1197         TextureType targetPacked                              = FromGL<TextureType>(target);
1198         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1199         bool isCallValid =
1200             (context->skipValidation() || ValidateGenerateMipmap(context, targetPacked));
1201         if (isCallValid)
1202         {
1203             context->generateMipmap(targetPacked);
1204         }
1205         ANGLE_CAPTURE(GenerateMipmap, isCallValid, context, targetPacked);
1206     }
1207 }
1208 
GetActiveAttrib(GLuint program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name)1209 void GL_APIENTRY GetActiveAttrib(GLuint program,
1210                                  GLuint index,
1211                                  GLsizei bufSize,
1212                                  GLsizei *length,
1213                                  GLint *size,
1214                                  GLenum *type,
1215                                  GLchar *name)
1216 {
1217     Context *context = GetValidGlobalContext();
1218     EVENT("glGetActiveAttrib",
1219           "context = %d, GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei "
1220           "*length = 0x%016" PRIxPTR ", GLint *size = 0x%016" PRIxPTR
1221           ", GLenum *type = 0x%016" PRIxPTR ", GLchar *name = 0x%016" PRIxPTR "",
1222           CID(context), program, index, bufSize, (uintptr_t)length, (uintptr_t)size,
1223           (uintptr_t)type, (uintptr_t)name);
1224 
1225     if (context)
1226     {
1227         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1228         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1229         bool isCallValid                                      = (context->skipValidation() ||
1230                             ValidateGetActiveAttrib(context, programPacked, index, bufSize, length,
1231                                                     size, type, name));
1232         if (isCallValid)
1233         {
1234             context->getActiveAttrib(programPacked, index, bufSize, length, size, type, name);
1235         }
1236         ANGLE_CAPTURE(GetActiveAttrib, isCallValid, context, programPacked, index, bufSize, length,
1237                       size, type, name);
1238     }
1239 }
1240 
GetActiveUniform(GLuint program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name)1241 void GL_APIENTRY GetActiveUniform(GLuint program,
1242                                   GLuint index,
1243                                   GLsizei bufSize,
1244                                   GLsizei *length,
1245                                   GLint *size,
1246                                   GLenum *type,
1247                                   GLchar *name)
1248 {
1249     Context *context = GetValidGlobalContext();
1250     EVENT("glGetActiveUniform",
1251           "context = %d, GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei "
1252           "*length = 0x%016" PRIxPTR ", GLint *size = 0x%016" PRIxPTR
1253           ", GLenum *type = 0x%016" PRIxPTR ", GLchar *name = 0x%016" PRIxPTR "",
1254           CID(context), program, index, bufSize, (uintptr_t)length, (uintptr_t)size,
1255           (uintptr_t)type, (uintptr_t)name);
1256 
1257     if (context)
1258     {
1259         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1260         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1261         bool isCallValid                                      = (context->skipValidation() ||
1262                             ValidateGetActiveUniform(context, programPacked, index, bufSize, length,
1263                                                      size, type, name));
1264         if (isCallValid)
1265         {
1266             context->getActiveUniform(programPacked, index, bufSize, length, size, type, name);
1267         }
1268         ANGLE_CAPTURE(GetActiveUniform, isCallValid, context, programPacked, index, bufSize, length,
1269                       size, type, name);
1270     }
1271 }
1272 
GetAttachedShaders(GLuint program,GLsizei maxCount,GLsizei * count,GLuint * shaders)1273 void GL_APIENTRY GetAttachedShaders(GLuint program,
1274                                     GLsizei maxCount,
1275                                     GLsizei *count,
1276                                     GLuint *shaders)
1277 {
1278     Context *context = GetValidGlobalContext();
1279     EVENT(
1280         "glGetAttachedShaders",
1281         "context = %d, GLuint program = %u, GLsizei maxCount = %d, GLsizei *count = 0x%016" PRIxPTR
1282         ", GLuint *shaders = 0x%016" PRIxPTR "",
1283         CID(context), program, maxCount, (uintptr_t)count, (uintptr_t)shaders);
1284 
1285     if (context)
1286     {
1287         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1288         ShaderProgramID *shadersPacked                        = FromGL<ShaderProgramID *>(shaders);
1289         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1290         bool isCallValid =
1291             (context->skipValidation() ||
1292              ValidateGetAttachedShaders(context, programPacked, maxCount, count, shadersPacked));
1293         if (isCallValid)
1294         {
1295             context->getAttachedShaders(programPacked, maxCount, count, shadersPacked);
1296         }
1297         ANGLE_CAPTURE(GetAttachedShaders, isCallValid, context, programPacked, maxCount, count,
1298                       shadersPacked);
1299     }
1300 }
1301 
GetAttribLocation(GLuint program,const GLchar * name)1302 GLint GL_APIENTRY GetAttribLocation(GLuint program, const GLchar *name)
1303 {
1304     Context *context = GetValidGlobalContext();
1305     EVENT("glGetAttribLocation",
1306           "context = %d, GLuint program = %u, const GLchar *name = 0x%016" PRIxPTR "", CID(context),
1307           program, (uintptr_t)name);
1308 
1309     GLint returnValue;
1310     if (context)
1311     {
1312         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1313         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1314         bool isCallValid =
1315             (context->skipValidation() || ValidateGetAttribLocation(context, programPacked, name));
1316         if (isCallValid)
1317         {
1318             returnValue = context->getAttribLocation(programPacked, name);
1319         }
1320         else
1321         {
1322             returnValue = GetDefaultReturnValue<EntryPoint::GetAttribLocation, GLint>();
1323         }
1324         ANGLE_CAPTURE(GetAttribLocation, isCallValid, context, programPacked, name, returnValue);
1325     }
1326     else
1327     {
1328         returnValue = GetDefaultReturnValue<EntryPoint::GetAttribLocation, GLint>();
1329     }
1330     return returnValue;
1331 }
1332 
GetBooleanv(GLenum pname,GLboolean * data)1333 void GL_APIENTRY GetBooleanv(GLenum pname, GLboolean *data)
1334 {
1335     Context *context = GetValidGlobalContext();
1336     EVENT("glGetBooleanv", "context = %d, GLenum pname = %s, GLboolean *data = 0x%016" PRIxPTR "",
1337           CID(context), GLenumToString(GLenumGroup::GetPName, pname), (uintptr_t)data);
1338 
1339     if (context)
1340     {
1341         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1342         bool isCallValid = (context->skipValidation() || ValidateGetBooleanv(context, pname, data));
1343         if (isCallValid)
1344         {
1345             context->getBooleanv(pname, data);
1346         }
1347         ANGLE_CAPTURE(GetBooleanv, isCallValid, context, pname, data);
1348     }
1349 }
1350 
GetBufferParameteriv(GLenum target,GLenum pname,GLint * params)1351 void GL_APIENTRY GetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
1352 {
1353     Context *context = GetValidGlobalContext();
1354     EVENT("glGetBufferParameteriv",
1355           "context = %d, GLenum target = %s, GLenum pname = %s, GLint *params = 0x%016" PRIxPTR "",
1356           CID(context), GLenumToString(GLenumGroup::BufferTargetARB, target),
1357           GLenumToString(GLenumGroup::DefaultGroup, pname), (uintptr_t)params);
1358 
1359     if (context)
1360     {
1361         BufferBinding targetPacked                            = FromGL<BufferBinding>(target);
1362         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1363         bool isCallValid                                      = (context->skipValidation() ||
1364                             ValidateGetBufferParameteriv(context, targetPacked, pname, params));
1365         if (isCallValid)
1366         {
1367             context->getBufferParameteriv(targetPacked, pname, params);
1368         }
1369         ANGLE_CAPTURE(GetBufferParameteriv, isCallValid, context, targetPacked, pname, params);
1370     }
1371 }
1372 
GetError()1373 GLenum GL_APIENTRY GetError()
1374 {
1375     Context *context = GetGlobalContext();
1376     EVENT("glGetError", "context = %d", CID(context));
1377 
1378     GLenum returnValue;
1379     if (context)
1380     {
1381         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1382         bool isCallValid = (context->skipValidation() || ValidateGetError(context));
1383         if (isCallValid)
1384         {
1385             returnValue = context->getError();
1386         }
1387         else
1388         {
1389             returnValue = GetDefaultReturnValue<EntryPoint::GetError, GLenum>();
1390         }
1391         ANGLE_CAPTURE(GetError, isCallValid, context, returnValue);
1392     }
1393     else
1394     {
1395         returnValue = GetDefaultReturnValue<EntryPoint::GetError, GLenum>();
1396     }
1397     return returnValue;
1398 }
1399 
GetFloatv(GLenum pname,GLfloat * data)1400 void GL_APIENTRY GetFloatv(GLenum pname, GLfloat *data)
1401 {
1402     Context *context = GetValidGlobalContext();
1403     EVENT("glGetFloatv", "context = %d, GLenum pname = %s, GLfloat *data = 0x%016" PRIxPTR "",
1404           CID(context), GLenumToString(GLenumGroup::GetPName, pname), (uintptr_t)data);
1405 
1406     if (context)
1407     {
1408         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1409         bool isCallValid = (context->skipValidation() || ValidateGetFloatv(context, pname, data));
1410         if (isCallValid)
1411         {
1412             context->getFloatv(pname, data);
1413         }
1414         ANGLE_CAPTURE(GetFloatv, isCallValid, context, pname, data);
1415     }
1416 }
1417 
GetFramebufferAttachmentParameteriv(GLenum target,GLenum attachment,GLenum pname,GLint * params)1418 void GL_APIENTRY GetFramebufferAttachmentParameteriv(GLenum target,
1419                                                      GLenum attachment,
1420                                                      GLenum pname,
1421                                                      GLint *params)
1422 {
1423     Context *context = GetValidGlobalContext();
1424     EVENT("glGetFramebufferAttachmentParameteriv",
1425           "context = %d, GLenum target = %s, GLenum attachment = %s, GLenum pname = %s, GLint "
1426           "*params = 0x%016" PRIxPTR "",
1427           CID(context), GLenumToString(GLenumGroup::FramebufferTarget, target),
1428           GLenumToString(GLenumGroup::FramebufferAttachment, attachment),
1429           GLenumToString(GLenumGroup::FramebufferAttachmentParameterName, pname),
1430           (uintptr_t)params);
1431 
1432     if (context)
1433     {
1434         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1435         bool isCallValid =
1436             (context->skipValidation() || ValidateGetFramebufferAttachmentParameteriv(
1437                                               context, target, attachment, pname, params));
1438         if (isCallValid)
1439         {
1440             context->getFramebufferAttachmentParameteriv(target, attachment, pname, params);
1441         }
1442         ANGLE_CAPTURE(GetFramebufferAttachmentParameteriv, isCallValid, context, target, attachment,
1443                       pname, params);
1444     }
1445 }
1446 
GetIntegerv(GLenum pname,GLint * data)1447 void GL_APIENTRY GetIntegerv(GLenum pname, GLint *data)
1448 {
1449     Context *context = GetValidGlobalContext();
1450     EVENT("glGetIntegerv", "context = %d, GLenum pname = %s, GLint *data = 0x%016" PRIxPTR "",
1451           CID(context), GLenumToString(GLenumGroup::GetPName, pname), (uintptr_t)data);
1452 
1453     if (context)
1454     {
1455         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1456         bool isCallValid = (context->skipValidation() || ValidateGetIntegerv(context, pname, data));
1457         if (isCallValid)
1458         {
1459             context->getIntegerv(pname, data);
1460         }
1461         ANGLE_CAPTURE(GetIntegerv, isCallValid, context, pname, data);
1462     }
1463 }
1464 
GetProgramInfoLog(GLuint program,GLsizei bufSize,GLsizei * length,GLchar * infoLog)1465 void GL_APIENTRY GetProgramInfoLog(GLuint program,
1466                                    GLsizei bufSize,
1467                                    GLsizei *length,
1468                                    GLchar *infoLog)
1469 {
1470     Context *context = GetValidGlobalContext();
1471     EVENT(
1472         "glGetProgramInfoLog",
1473         "context = %d, GLuint program = %u, GLsizei bufSize = %d, GLsizei *length = 0x%016" PRIxPTR
1474         ", GLchar *infoLog = 0x%016" PRIxPTR "",
1475         CID(context), program, bufSize, (uintptr_t)length, (uintptr_t)infoLog);
1476 
1477     if (context)
1478     {
1479         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1480         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1481         bool isCallValid =
1482             (context->skipValidation() ||
1483              ValidateGetProgramInfoLog(context, programPacked, bufSize, length, infoLog));
1484         if (isCallValid)
1485         {
1486             context->getProgramInfoLog(programPacked, bufSize, length, infoLog);
1487         }
1488         ANGLE_CAPTURE(GetProgramInfoLog, isCallValid, context, programPacked, bufSize, length,
1489                       infoLog);
1490     }
1491 }
1492 
GetProgramiv(GLuint program,GLenum pname,GLint * params)1493 void GL_APIENTRY GetProgramiv(GLuint program, GLenum pname, GLint *params)
1494 {
1495     Context *context = GetGlobalContext();
1496     EVENT("glGetProgramiv",
1497           "context = %d, GLuint program = %u, GLenum pname = %s, GLint *params = 0x%016" PRIxPTR "",
1498           CID(context), program, GLenumToString(GLenumGroup::ProgramPropertyARB, pname),
1499           (uintptr_t)params);
1500 
1501     if (context)
1502     {
1503         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1504         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1505         bool isCallValid                                      = (context->skipValidation() ||
1506                             ValidateGetProgramiv(context, programPacked, pname, params));
1507         if (isCallValid)
1508         {
1509             context->getProgramiv(programPacked, pname, params);
1510         }
1511         ANGLE_CAPTURE(GetProgramiv, isCallValid, context, programPacked, pname, params);
1512     }
1513 }
1514 
GetRenderbufferParameteriv(GLenum target,GLenum pname,GLint * params)1515 void GL_APIENTRY GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
1516 {
1517     Context *context = GetValidGlobalContext();
1518     EVENT("glGetRenderbufferParameteriv",
1519           "context = %d, GLenum target = %s, GLenum pname = %s, GLint *params = 0x%016" PRIxPTR "",
1520           CID(context), GLenumToString(GLenumGroup::RenderbufferTarget, target),
1521           GLenumToString(GLenumGroup::RenderbufferParameterName, pname), (uintptr_t)params);
1522 
1523     if (context)
1524     {
1525         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1526         bool isCallValid                                      = (context->skipValidation() ||
1527                             ValidateGetRenderbufferParameteriv(context, target, pname, params));
1528         if (isCallValid)
1529         {
1530             context->getRenderbufferParameteriv(target, pname, params);
1531         }
1532         ANGLE_CAPTURE(GetRenderbufferParameteriv, isCallValid, context, target, pname, params);
1533     }
1534 }
1535 
GetShaderInfoLog(GLuint shader,GLsizei bufSize,GLsizei * length,GLchar * infoLog)1536 void GL_APIENTRY GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)
1537 {
1538     Context *context = GetValidGlobalContext();
1539     EVENT("glGetShaderInfoLog",
1540           "context = %d, GLuint shader = %u, GLsizei bufSize = %d, GLsizei *length = 0x%016" PRIxPTR
1541           ", GLchar *infoLog = 0x%016" PRIxPTR "",
1542           CID(context), shader, bufSize, (uintptr_t)length, (uintptr_t)infoLog);
1543 
1544     if (context)
1545     {
1546         ShaderProgramID shaderPacked                          = FromGL<ShaderProgramID>(shader);
1547         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1548         bool isCallValid =
1549             (context->skipValidation() ||
1550              ValidateGetShaderInfoLog(context, shaderPacked, bufSize, length, infoLog));
1551         if (isCallValid)
1552         {
1553             context->getShaderInfoLog(shaderPacked, bufSize, length, infoLog);
1554         }
1555         ANGLE_CAPTURE(GetShaderInfoLog, isCallValid, context, shaderPacked, bufSize, length,
1556                       infoLog);
1557     }
1558 }
1559 
GetShaderPrecisionFormat(GLenum shadertype,GLenum precisiontype,GLint * range,GLint * precision)1560 void GL_APIENTRY GetShaderPrecisionFormat(GLenum shadertype,
1561                                           GLenum precisiontype,
1562                                           GLint *range,
1563                                           GLint *precision)
1564 {
1565     Context *context = GetValidGlobalContext();
1566     EVENT("glGetShaderPrecisionFormat",
1567           "context = %d, GLenum shadertype = %s, GLenum precisiontype = %s, GLint *range = "
1568           "0x%016" PRIxPTR ", GLint *precision = 0x%016" PRIxPTR "",
1569           CID(context), GLenumToString(GLenumGroup::ShaderType, shadertype),
1570           GLenumToString(GLenumGroup::PrecisionType, precisiontype), (uintptr_t)range,
1571           (uintptr_t)precision);
1572 
1573     if (context)
1574     {
1575         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1576         bool isCallValid                                      = (context->skipValidation() ||
1577                             ValidateGetShaderPrecisionFormat(context, shadertype, precisiontype,
1578                                                              range, precision));
1579         if (isCallValid)
1580         {
1581             context->getShaderPrecisionFormat(shadertype, precisiontype, range, precision);
1582         }
1583         ANGLE_CAPTURE(GetShaderPrecisionFormat, isCallValid, context, shadertype, precisiontype,
1584                       range, precision);
1585     }
1586 }
1587 
GetShaderSource(GLuint shader,GLsizei bufSize,GLsizei * length,GLchar * source)1588 void GL_APIENTRY GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source)
1589 {
1590     Context *context = GetValidGlobalContext();
1591     EVENT("glGetShaderSource",
1592           "context = %d, GLuint shader = %u, GLsizei bufSize = %d, GLsizei *length = 0x%016" PRIxPTR
1593           ", GLchar *source = 0x%016" PRIxPTR "",
1594           CID(context), shader, bufSize, (uintptr_t)length, (uintptr_t)source);
1595 
1596     if (context)
1597     {
1598         ShaderProgramID shaderPacked                          = FromGL<ShaderProgramID>(shader);
1599         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1600         bool isCallValid =
1601             (context->skipValidation() ||
1602              ValidateGetShaderSource(context, shaderPacked, bufSize, length, source));
1603         if (isCallValid)
1604         {
1605             context->getShaderSource(shaderPacked, bufSize, length, source);
1606         }
1607         ANGLE_CAPTURE(GetShaderSource, isCallValid, context, shaderPacked, bufSize, length, source);
1608     }
1609 }
1610 
GetShaderiv(GLuint shader,GLenum pname,GLint * params)1611 void GL_APIENTRY GetShaderiv(GLuint shader, GLenum pname, GLint *params)
1612 {
1613     Context *context = GetGlobalContext();
1614     EVENT("glGetShaderiv",
1615           "context = %d, GLuint shader = %u, GLenum pname = %s, GLint *params = 0x%016" PRIxPTR "",
1616           CID(context), shader, GLenumToString(GLenumGroup::ShaderParameterName, pname),
1617           (uintptr_t)params);
1618 
1619     if (context)
1620     {
1621         ShaderProgramID shaderPacked                          = FromGL<ShaderProgramID>(shader);
1622         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1623         bool isCallValid                                      = (context->skipValidation() ||
1624                             ValidateGetShaderiv(context, shaderPacked, pname, params));
1625         if (isCallValid)
1626         {
1627             context->getShaderiv(shaderPacked, pname, params);
1628         }
1629         ANGLE_CAPTURE(GetShaderiv, isCallValid, context, shaderPacked, pname, params);
1630     }
1631 }
1632 
GetString(GLenum name)1633 const GLubyte *GL_APIENTRY GetString(GLenum name)
1634 {
1635     Context *context = GetValidGlobalContext();
1636     EVENT("glGetString", "context = %d, GLenum name = %s", CID(context),
1637           GLenumToString(GLenumGroup::StringName, name));
1638 
1639     const GLubyte *returnValue;
1640     if (context)
1641     {
1642         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1643         bool isCallValid = (context->skipValidation() || ValidateGetString(context, name));
1644         if (isCallValid)
1645         {
1646             returnValue = context->getString(name);
1647         }
1648         else
1649         {
1650             returnValue = GetDefaultReturnValue<EntryPoint::GetString, const GLubyte *>();
1651         }
1652         ANGLE_CAPTURE(GetString, isCallValid, context, name, returnValue);
1653     }
1654     else
1655     {
1656         returnValue = GetDefaultReturnValue<EntryPoint::GetString, const GLubyte *>();
1657     }
1658     return returnValue;
1659 }
1660 
GetTexParameterfv(GLenum target,GLenum pname,GLfloat * params)1661 void GL_APIENTRY GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
1662 {
1663     Context *context = GetValidGlobalContext();
1664     EVENT("glGetTexParameterfv",
1665           "context = %d, GLenum target = %s, GLenum pname = %s, GLfloat *params = 0x%016" PRIxPTR
1666           "",
1667           CID(context), GLenumToString(GLenumGroup::TextureTarget, target),
1668           GLenumToString(GLenumGroup::GetTextureParameter, pname), (uintptr_t)params);
1669 
1670     if (context)
1671     {
1672         TextureType targetPacked                              = FromGL<TextureType>(target);
1673         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1674         bool isCallValid                                      = (context->skipValidation() ||
1675                             ValidateGetTexParameterfv(context, targetPacked, pname, params));
1676         if (isCallValid)
1677         {
1678             context->getTexParameterfv(targetPacked, pname, params);
1679         }
1680         ANGLE_CAPTURE(GetTexParameterfv, isCallValid, context, targetPacked, pname, params);
1681     }
1682 }
1683 
GetTexParameteriv(GLenum target,GLenum pname,GLint * params)1684 void GL_APIENTRY GetTexParameteriv(GLenum target, GLenum pname, GLint *params)
1685 {
1686     Context *context = GetValidGlobalContext();
1687     EVENT("glGetTexParameteriv",
1688           "context = %d, GLenum target = %s, GLenum pname = %s, GLint *params = 0x%016" PRIxPTR "",
1689           CID(context), GLenumToString(GLenumGroup::TextureTarget, target),
1690           GLenumToString(GLenumGroup::GetTextureParameter, pname), (uintptr_t)params);
1691 
1692     if (context)
1693     {
1694         TextureType targetPacked                              = FromGL<TextureType>(target);
1695         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1696         bool isCallValid                                      = (context->skipValidation() ||
1697                             ValidateGetTexParameteriv(context, targetPacked, pname, params));
1698         if (isCallValid)
1699         {
1700             context->getTexParameteriv(targetPacked, pname, params);
1701         }
1702         ANGLE_CAPTURE(GetTexParameteriv, isCallValid, context, targetPacked, pname, params);
1703     }
1704 }
1705 
GetUniformLocation(GLuint program,const GLchar * name)1706 GLint GL_APIENTRY GetUniformLocation(GLuint program, const GLchar *name)
1707 {
1708     Context *context = GetValidGlobalContext();
1709     EVENT("glGetUniformLocation",
1710           "context = %d, GLuint program = %u, const GLchar *name = 0x%016" PRIxPTR "", CID(context),
1711           program, (uintptr_t)name);
1712 
1713     GLint returnValue;
1714     if (context)
1715     {
1716         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1717         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1718         bool isCallValid =
1719             (context->skipValidation() || ValidateGetUniformLocation(context, programPacked, name));
1720         if (isCallValid)
1721         {
1722             returnValue = context->getUniformLocation(programPacked, name);
1723         }
1724         else
1725         {
1726             returnValue = GetDefaultReturnValue<EntryPoint::GetUniformLocation, GLint>();
1727         }
1728         ANGLE_CAPTURE(GetUniformLocation, isCallValid, context, programPacked, name, returnValue);
1729     }
1730     else
1731     {
1732         returnValue = GetDefaultReturnValue<EntryPoint::GetUniformLocation, GLint>();
1733     }
1734     return returnValue;
1735 }
1736 
GetUniformfv(GLuint program,GLint location,GLfloat * params)1737 void GL_APIENTRY GetUniformfv(GLuint program, GLint location, GLfloat *params)
1738 {
1739     Context *context = GetValidGlobalContext();
1740     EVENT("glGetUniformfv",
1741           "context = %d, GLuint program = %u, GLint location = %d, GLfloat *params = 0x%016" PRIxPTR
1742           "",
1743           CID(context), program, location, (uintptr_t)params);
1744 
1745     if (context)
1746     {
1747         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1748         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
1749         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1750         bool isCallValid                                      = (context->skipValidation() ||
1751                             ValidateGetUniformfv(context, programPacked, locationPacked, params));
1752         if (isCallValid)
1753         {
1754             context->getUniformfv(programPacked, locationPacked, params);
1755         }
1756         ANGLE_CAPTURE(GetUniformfv, isCallValid, context, programPacked, locationPacked, params);
1757     }
1758 }
1759 
GetUniformiv(GLuint program,GLint location,GLint * params)1760 void GL_APIENTRY GetUniformiv(GLuint program, GLint location, GLint *params)
1761 {
1762     Context *context = GetValidGlobalContext();
1763     EVENT("glGetUniformiv",
1764           "context = %d, GLuint program = %u, GLint location = %d, GLint *params = 0x%016" PRIxPTR
1765           "",
1766           CID(context), program, location, (uintptr_t)params);
1767 
1768     if (context)
1769     {
1770         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1771         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
1772         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1773         bool isCallValid                                      = (context->skipValidation() ||
1774                             ValidateGetUniformiv(context, programPacked, locationPacked, params));
1775         if (isCallValid)
1776         {
1777             context->getUniformiv(programPacked, locationPacked, params);
1778         }
1779         ANGLE_CAPTURE(GetUniformiv, isCallValid, context, programPacked, locationPacked, params);
1780     }
1781 }
1782 
GetVertexAttribPointerv(GLuint index,GLenum pname,void ** pointer)1783 void GL_APIENTRY GetVertexAttribPointerv(GLuint index, GLenum pname, void **pointer)
1784 {
1785     Context *context = GetValidGlobalContext();
1786     EVENT("glGetVertexAttribPointerv",
1787           "context = %d, GLuint index = %u, GLenum pname = %s, void **pointer = 0x%016" PRIxPTR "",
1788           CID(context), index, GLenumToString(GLenumGroup::DefaultGroup, pname),
1789           (uintptr_t)pointer);
1790 
1791     if (context)
1792     {
1793         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1794         bool isCallValid                                      = (context->skipValidation() ||
1795                             ValidateGetVertexAttribPointerv(context, index, pname, pointer));
1796         if (isCallValid)
1797         {
1798             context->getVertexAttribPointerv(index, pname, pointer);
1799         }
1800         ANGLE_CAPTURE(GetVertexAttribPointerv, isCallValid, context, index, pname, pointer);
1801     }
1802 }
1803 
GetVertexAttribfv(GLuint index,GLenum pname,GLfloat * params)1804 void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
1805 {
1806     Context *context = GetValidGlobalContext();
1807     EVENT("glGetVertexAttribfv",
1808           "context = %d, GLuint index = %u, GLenum pname = %s, GLfloat *params = 0x%016" PRIxPTR "",
1809           CID(context), index, GLenumToString(GLenumGroup::DefaultGroup, pname), (uintptr_t)params);
1810 
1811     if (context)
1812     {
1813         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1814         bool isCallValid =
1815             (context->skipValidation() || ValidateGetVertexAttribfv(context, index, pname, params));
1816         if (isCallValid)
1817         {
1818             context->getVertexAttribfv(index, pname, params);
1819         }
1820         ANGLE_CAPTURE(GetVertexAttribfv, isCallValid, context, index, pname, params);
1821     }
1822 }
1823 
GetVertexAttribiv(GLuint index,GLenum pname,GLint * params)1824 void GL_APIENTRY GetVertexAttribiv(GLuint index, GLenum pname, GLint *params)
1825 {
1826     Context *context = GetValidGlobalContext();
1827     EVENT("glGetVertexAttribiv",
1828           "context = %d, GLuint index = %u, GLenum pname = %s, GLint *params = 0x%016" PRIxPTR "",
1829           CID(context), index, GLenumToString(GLenumGroup::DefaultGroup, pname), (uintptr_t)params);
1830 
1831     if (context)
1832     {
1833         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1834         bool isCallValid =
1835             (context->skipValidation() || ValidateGetVertexAttribiv(context, index, pname, params));
1836         if (isCallValid)
1837         {
1838             context->getVertexAttribiv(index, pname, params);
1839         }
1840         ANGLE_CAPTURE(GetVertexAttribiv, isCallValid, context, index, pname, params);
1841     }
1842 }
1843 
Hint(GLenum target,GLenum mode)1844 void GL_APIENTRY Hint(GLenum target, GLenum mode)
1845 {
1846     Context *context = GetValidGlobalContext();
1847     EVENT("glHint", "context = %d, GLenum target = %s, GLenum mode = %s", CID(context),
1848           GLenumToString(GLenumGroup::HintTarget, target),
1849           GLenumToString(GLenumGroup::HintMode, mode));
1850 
1851     if (context)
1852     {
1853         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1854         bool isCallValid = (context->skipValidation() || ValidateHint(context, target, mode));
1855         if (isCallValid)
1856         {
1857             context->hint(target, mode);
1858         }
1859         ANGLE_CAPTURE(Hint, isCallValid, context, target, mode);
1860     }
1861 }
1862 
IsBuffer(GLuint buffer)1863 GLboolean GL_APIENTRY IsBuffer(GLuint buffer)
1864 {
1865     Context *context = GetValidGlobalContext();
1866     EVENT("glIsBuffer", "context = %d, GLuint buffer = %u", CID(context), buffer);
1867 
1868     GLboolean returnValue;
1869     if (context)
1870     {
1871         BufferID bufferPacked                                 = FromGL<BufferID>(buffer);
1872         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1873         bool isCallValid = (context->skipValidation() || ValidateIsBuffer(context, bufferPacked));
1874         if (isCallValid)
1875         {
1876             returnValue = context->isBuffer(bufferPacked);
1877         }
1878         else
1879         {
1880             returnValue = GetDefaultReturnValue<EntryPoint::IsBuffer, GLboolean>();
1881         }
1882         ANGLE_CAPTURE(IsBuffer, isCallValid, context, bufferPacked, returnValue);
1883     }
1884     else
1885     {
1886         returnValue = GetDefaultReturnValue<EntryPoint::IsBuffer, GLboolean>();
1887     }
1888     return returnValue;
1889 }
1890 
IsEnabled(GLenum cap)1891 GLboolean GL_APIENTRY IsEnabled(GLenum cap)
1892 {
1893     Context *context = GetValidGlobalContext();
1894     EVENT("glIsEnabled", "context = %d, GLenum cap = %s", CID(context),
1895           GLenumToString(GLenumGroup::EnableCap, cap));
1896 
1897     GLboolean returnValue;
1898     if (context)
1899     {
1900         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1901         bool isCallValid = (context->skipValidation() || ValidateIsEnabled(context, cap));
1902         if (isCallValid)
1903         {
1904             returnValue = context->isEnabled(cap);
1905         }
1906         else
1907         {
1908             returnValue = GetDefaultReturnValue<EntryPoint::IsEnabled, GLboolean>();
1909         }
1910         ANGLE_CAPTURE(IsEnabled, isCallValid, context, cap, returnValue);
1911     }
1912     else
1913     {
1914         returnValue = GetDefaultReturnValue<EntryPoint::IsEnabled, GLboolean>();
1915     }
1916     return returnValue;
1917 }
1918 
IsFramebuffer(GLuint framebuffer)1919 GLboolean GL_APIENTRY IsFramebuffer(GLuint framebuffer)
1920 {
1921     Context *context = GetValidGlobalContext();
1922     EVENT("glIsFramebuffer", "context = %d, GLuint framebuffer = %u", CID(context), framebuffer);
1923 
1924     GLboolean returnValue;
1925     if (context)
1926     {
1927         FramebufferID framebufferPacked                       = FromGL<FramebufferID>(framebuffer);
1928         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1929         bool isCallValid =
1930             (context->skipValidation() || ValidateIsFramebuffer(context, framebufferPacked));
1931         if (isCallValid)
1932         {
1933             returnValue = context->isFramebuffer(framebufferPacked);
1934         }
1935         else
1936         {
1937             returnValue = GetDefaultReturnValue<EntryPoint::IsFramebuffer, GLboolean>();
1938         }
1939         ANGLE_CAPTURE(IsFramebuffer, isCallValid, context, framebufferPacked, returnValue);
1940     }
1941     else
1942     {
1943         returnValue = GetDefaultReturnValue<EntryPoint::IsFramebuffer, GLboolean>();
1944     }
1945     return returnValue;
1946 }
1947 
IsProgram(GLuint program)1948 GLboolean GL_APIENTRY IsProgram(GLuint program)
1949 {
1950     Context *context = GetValidGlobalContext();
1951     EVENT("glIsProgram", "context = %d, GLuint program = %u", CID(context), program);
1952 
1953     GLboolean returnValue;
1954     if (context)
1955     {
1956         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
1957         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1958         bool isCallValid = (context->skipValidation() || ValidateIsProgram(context, programPacked));
1959         if (isCallValid)
1960         {
1961             returnValue = context->isProgram(programPacked);
1962         }
1963         else
1964         {
1965             returnValue = GetDefaultReturnValue<EntryPoint::IsProgram, GLboolean>();
1966         }
1967         ANGLE_CAPTURE(IsProgram, isCallValid, context, programPacked, returnValue);
1968     }
1969     else
1970     {
1971         returnValue = GetDefaultReturnValue<EntryPoint::IsProgram, GLboolean>();
1972     }
1973     return returnValue;
1974 }
1975 
IsRenderbuffer(GLuint renderbuffer)1976 GLboolean GL_APIENTRY IsRenderbuffer(GLuint renderbuffer)
1977 {
1978     Context *context = GetValidGlobalContext();
1979     EVENT("glIsRenderbuffer", "context = %d, GLuint renderbuffer = %u", CID(context), renderbuffer);
1980 
1981     GLboolean returnValue;
1982     if (context)
1983     {
1984         RenderbufferID renderbufferPacked = FromGL<RenderbufferID>(renderbuffer);
1985         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
1986         bool isCallValid =
1987             (context->skipValidation() || ValidateIsRenderbuffer(context, renderbufferPacked));
1988         if (isCallValid)
1989         {
1990             returnValue = context->isRenderbuffer(renderbufferPacked);
1991         }
1992         else
1993         {
1994             returnValue = GetDefaultReturnValue<EntryPoint::IsRenderbuffer, GLboolean>();
1995         }
1996         ANGLE_CAPTURE(IsRenderbuffer, isCallValid, context, renderbufferPacked, returnValue);
1997     }
1998     else
1999     {
2000         returnValue = GetDefaultReturnValue<EntryPoint::IsRenderbuffer, GLboolean>();
2001     }
2002     return returnValue;
2003 }
2004 
IsShader(GLuint shader)2005 GLboolean GL_APIENTRY IsShader(GLuint shader)
2006 {
2007     Context *context = GetValidGlobalContext();
2008     EVENT("glIsShader", "context = %d, GLuint shader = %u", CID(context), shader);
2009 
2010     GLboolean returnValue;
2011     if (context)
2012     {
2013         ShaderProgramID shaderPacked                          = FromGL<ShaderProgramID>(shader);
2014         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2015         bool isCallValid = (context->skipValidation() || ValidateIsShader(context, shaderPacked));
2016         if (isCallValid)
2017         {
2018             returnValue = context->isShader(shaderPacked);
2019         }
2020         else
2021         {
2022             returnValue = GetDefaultReturnValue<EntryPoint::IsShader, GLboolean>();
2023         }
2024         ANGLE_CAPTURE(IsShader, isCallValid, context, shaderPacked, returnValue);
2025     }
2026     else
2027     {
2028         returnValue = GetDefaultReturnValue<EntryPoint::IsShader, GLboolean>();
2029     }
2030     return returnValue;
2031 }
2032 
IsTexture(GLuint texture)2033 GLboolean GL_APIENTRY IsTexture(GLuint texture)
2034 {
2035     Context *context = GetValidGlobalContext();
2036     EVENT("glIsTexture", "context = %d, GLuint texture = %u", CID(context), texture);
2037 
2038     GLboolean returnValue;
2039     if (context)
2040     {
2041         TextureID texturePacked                               = FromGL<TextureID>(texture);
2042         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2043         bool isCallValid = (context->skipValidation() || ValidateIsTexture(context, texturePacked));
2044         if (isCallValid)
2045         {
2046             returnValue = context->isTexture(texturePacked);
2047         }
2048         else
2049         {
2050             returnValue = GetDefaultReturnValue<EntryPoint::IsTexture, GLboolean>();
2051         }
2052         ANGLE_CAPTURE(IsTexture, isCallValid, context, texturePacked, returnValue);
2053     }
2054     else
2055     {
2056         returnValue = GetDefaultReturnValue<EntryPoint::IsTexture, GLboolean>();
2057     }
2058     return returnValue;
2059 }
2060 
LineWidth(GLfloat width)2061 void GL_APIENTRY LineWidth(GLfloat width)
2062 {
2063     Context *context = GetValidGlobalContext();
2064     EVENT("glLineWidth", "context = %d, GLfloat width = %f", CID(context), width);
2065 
2066     if (context)
2067     {
2068         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2069         bool isCallValid = (context->skipValidation() || ValidateLineWidth(context, width));
2070         if (isCallValid)
2071         {
2072             context->lineWidth(width);
2073         }
2074         ANGLE_CAPTURE(LineWidth, isCallValid, context, width);
2075     }
2076 }
2077 
LinkProgram(GLuint program)2078 void GL_APIENTRY LinkProgram(GLuint program)
2079 {
2080     Context *context = GetValidGlobalContext();
2081     EVENT("glLinkProgram", "context = %d, GLuint program = %u", CID(context), program);
2082 
2083     if (context)
2084     {
2085         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
2086         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2087         bool isCallValid =
2088             (context->skipValidation() || ValidateLinkProgram(context, programPacked));
2089         if (isCallValid)
2090         {
2091             context->linkProgram(programPacked);
2092         }
2093         ANGLE_CAPTURE(LinkProgram, isCallValid, context, programPacked);
2094     }
2095 }
2096 
PixelStorei(GLenum pname,GLint param)2097 void GL_APIENTRY PixelStorei(GLenum pname, GLint param)
2098 {
2099     Context *context = GetValidGlobalContext();
2100     EVENT("glPixelStorei", "context = %d, GLenum pname = %s, GLint param = %d", CID(context),
2101           GLenumToString(GLenumGroup::PixelStoreParameter, pname), param);
2102 
2103     if (context)
2104     {
2105         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2106         bool isCallValid =
2107             (context->skipValidation() || ValidatePixelStorei(context, pname, param));
2108         if (isCallValid)
2109         {
2110             context->pixelStorei(pname, param);
2111         }
2112         ANGLE_CAPTURE(PixelStorei, isCallValid, context, pname, param);
2113     }
2114 }
2115 
PolygonOffset(GLfloat factor,GLfloat units)2116 void GL_APIENTRY PolygonOffset(GLfloat factor, GLfloat units)
2117 {
2118     Context *context = GetValidGlobalContext();
2119     EVENT("glPolygonOffset", "context = %d, GLfloat factor = %f, GLfloat units = %f", CID(context),
2120           factor, units);
2121 
2122     if (context)
2123     {
2124         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2125         bool isCallValid =
2126             (context->skipValidation() || ValidatePolygonOffset(context, factor, units));
2127         if (isCallValid)
2128         {
2129             context->polygonOffset(factor, units);
2130         }
2131         ANGLE_CAPTURE(PolygonOffset, isCallValid, context, factor, units);
2132     }
2133 }
2134 
ReadPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,void * pixels)2135 void GL_APIENTRY ReadPixels(GLint x,
2136                             GLint y,
2137                             GLsizei width,
2138                             GLsizei height,
2139                             GLenum format,
2140                             GLenum type,
2141                             void *pixels)
2142 {
2143     Context *context = GetValidGlobalContext();
2144     EVENT("glReadPixels",
2145           "context = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
2146           "GLenum format = %s, GLenum type = %s, void *pixels = 0x%016" PRIxPTR "",
2147           CID(context), x, y, width, height, GLenumToString(GLenumGroup::PixelFormat, format),
2148           GLenumToString(GLenumGroup::PixelType, type), (uintptr_t)pixels);
2149 
2150     if (context)
2151     {
2152         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2153         bool isCallValid                                      = (context->skipValidation() ||
2154                             ValidateReadPixels(context, x, y, width, height, format, type, pixels));
2155         if (isCallValid)
2156         {
2157             context->readPixels(x, y, width, height, format, type, pixels);
2158         }
2159         ANGLE_CAPTURE(ReadPixels, isCallValid, context, x, y, width, height, format, type, pixels);
2160     }
2161 }
2162 
ReleaseShaderCompiler()2163 void GL_APIENTRY ReleaseShaderCompiler()
2164 {
2165     Context *context = GetValidGlobalContext();
2166     EVENT("glReleaseShaderCompiler", "context = %d", CID(context));
2167 
2168     if (context)
2169     {
2170         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2171         bool isCallValid = (context->skipValidation() || ValidateReleaseShaderCompiler(context));
2172         if (isCallValid)
2173         {
2174             context->releaseShaderCompiler();
2175         }
2176         ANGLE_CAPTURE(ReleaseShaderCompiler, isCallValid, context);
2177     }
2178 }
2179 
RenderbufferStorage(GLenum target,GLenum internalformat,GLsizei width,GLsizei height)2180 void GL_APIENTRY RenderbufferStorage(GLenum target,
2181                                      GLenum internalformat,
2182                                      GLsizei width,
2183                                      GLsizei height)
2184 {
2185     Context *context = GetValidGlobalContext();
2186     EVENT("glRenderbufferStorage",
2187           "context = %d, GLenum target = %s, GLenum internalformat = %s, GLsizei width = %d, "
2188           "GLsizei height = %d",
2189           CID(context), GLenumToString(GLenumGroup::RenderbufferTarget, target),
2190           GLenumToString(GLenumGroup::InternalFormat, internalformat), width, height);
2191 
2192     if (context)
2193     {
2194         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2195         bool isCallValid =
2196             (context->skipValidation() ||
2197              ValidateRenderbufferStorage(context, target, internalformat, width, height));
2198         if (isCallValid)
2199         {
2200             context->renderbufferStorage(target, internalformat, width, height);
2201         }
2202         ANGLE_CAPTURE(RenderbufferStorage, isCallValid, context, target, internalformat, width,
2203                       height);
2204     }
2205 }
2206 
SampleCoverage(GLfloat value,GLboolean invert)2207 void GL_APIENTRY SampleCoverage(GLfloat value, GLboolean invert)
2208 {
2209     Context *context = GetValidGlobalContext();
2210     EVENT("glSampleCoverage", "context = %d, GLfloat value = %f, GLboolean invert = %s",
2211           CID(context), value, GLbooleanToString(invert));
2212 
2213     if (context)
2214     {
2215         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2216         bool isCallValid =
2217             (context->skipValidation() || ValidateSampleCoverage(context, value, invert));
2218         if (isCallValid)
2219         {
2220             context->sampleCoverage(value, invert);
2221         }
2222         ANGLE_CAPTURE(SampleCoverage, isCallValid, context, value, invert);
2223     }
2224 }
2225 
Scissor(GLint x,GLint y,GLsizei width,GLsizei height)2226 void GL_APIENTRY Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
2227 {
2228     Context *context = GetValidGlobalContext();
2229     EVENT("glScissor",
2230           "context = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d",
2231           CID(context), x, y, width, height);
2232 
2233     if (context)
2234     {
2235         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2236         bool isCallValid =
2237             (context->skipValidation() || ValidateScissor(context, x, y, width, height));
2238         if (isCallValid)
2239         {
2240             context->scissor(x, y, width, height);
2241         }
2242         ANGLE_CAPTURE(Scissor, isCallValid, context, x, y, width, height);
2243     }
2244 }
2245 
ShaderBinary(GLsizei count,const GLuint * shaders,GLenum binaryformat,const void * binary,GLsizei length)2246 void GL_APIENTRY ShaderBinary(GLsizei count,
2247                               const GLuint *shaders,
2248                               GLenum binaryformat,
2249                               const void *binary,
2250                               GLsizei length)
2251 {
2252     Context *context = GetValidGlobalContext();
2253     EVENT("glShaderBinary",
2254           "context = %d, GLsizei count = %d, const GLuint *shaders = 0x%016" PRIxPTR
2255           ", GLenum binaryformat = %s, const void *binary = 0x%016" PRIxPTR ", GLsizei length = %d",
2256           CID(context), count, (uintptr_t)shaders,
2257           GLenumToString(GLenumGroup::DefaultGroup, binaryformat), (uintptr_t)binary, length);
2258 
2259     if (context)
2260     {
2261         const ShaderProgramID *shadersPacked = FromGL<const ShaderProgramID *>(shaders);
2262         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2263         bool isCallValid =
2264             (context->skipValidation() ||
2265              ValidateShaderBinary(context, count, shadersPacked, binaryformat, binary, length));
2266         if (isCallValid)
2267         {
2268             context->shaderBinary(count, shadersPacked, binaryformat, binary, length);
2269         }
2270         ANGLE_CAPTURE(ShaderBinary, isCallValid, context, count, shadersPacked, binaryformat,
2271                       binary, length);
2272     }
2273 }
2274 
ShaderSource(GLuint shader,GLsizei count,const GLchar * const * string,const GLint * length)2275 void GL_APIENTRY ShaderSource(GLuint shader,
2276                               GLsizei count,
2277                               const GLchar *const *string,
2278                               const GLint *length)
2279 {
2280     Context *context = GetValidGlobalContext();
2281     EVENT("glShaderSource",
2282           "context = %d, GLuint shader = %u, GLsizei count = %d, const GLchar *const*string = "
2283           "0x%016" PRIxPTR ", const GLint *length = 0x%016" PRIxPTR "",
2284           CID(context), shader, count, (uintptr_t)string, (uintptr_t)length);
2285 
2286     if (context)
2287     {
2288         ShaderProgramID shaderPacked                          = FromGL<ShaderProgramID>(shader);
2289         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2290         bool isCallValid                                      = (context->skipValidation() ||
2291                             ValidateShaderSource(context, shaderPacked, count, string, length));
2292         if (isCallValid)
2293         {
2294             context->shaderSource(shaderPacked, count, string, length);
2295         }
2296         ANGLE_CAPTURE(ShaderSource, isCallValid, context, shaderPacked, count, string, length);
2297     }
2298 }
2299 
StencilFunc(GLenum func,GLint ref,GLuint mask)2300 void GL_APIENTRY StencilFunc(GLenum func, GLint ref, GLuint mask)
2301 {
2302     Context *context = GetValidGlobalContext();
2303     EVENT("glStencilFunc", "context = %d, GLenum func = %s, GLint ref = %d, GLuint mask = %u",
2304           CID(context), GLenumToString(GLenumGroup::StencilFunction, func), ref, mask);
2305 
2306     if (context)
2307     {
2308         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2309         bool isCallValid =
2310             (context->skipValidation() || ValidateStencilFunc(context, func, ref, mask));
2311         if (isCallValid)
2312         {
2313             context->stencilFunc(func, ref, mask);
2314         }
2315         ANGLE_CAPTURE(StencilFunc, isCallValid, context, func, ref, mask);
2316     }
2317 }
2318 
StencilFuncSeparate(GLenum face,GLenum func,GLint ref,GLuint mask)2319 void GL_APIENTRY StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
2320 {
2321     Context *context = GetValidGlobalContext();
2322     EVENT("glStencilFuncSeparate",
2323           "context = %d, GLenum face = %s, GLenum func = %s, GLint ref = %d, GLuint mask = %u",
2324           CID(context), GLenumToString(GLenumGroup::StencilFaceDirection, face),
2325           GLenumToString(GLenumGroup::StencilFunction, func), ref, mask);
2326 
2327     if (context)
2328     {
2329         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2330         bool isCallValid                                      = (context->skipValidation() ||
2331                             ValidateStencilFuncSeparate(context, face, func, ref, mask));
2332         if (isCallValid)
2333         {
2334             context->stencilFuncSeparate(face, func, ref, mask);
2335         }
2336         ANGLE_CAPTURE(StencilFuncSeparate, isCallValid, context, face, func, ref, mask);
2337     }
2338 }
2339 
StencilMask(GLuint mask)2340 void GL_APIENTRY StencilMask(GLuint mask)
2341 {
2342     Context *context = GetValidGlobalContext();
2343     EVENT("glStencilMask", "context = %d, GLuint mask = %u", CID(context), mask);
2344 
2345     if (context)
2346     {
2347         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2348         bool isCallValid = (context->skipValidation() || ValidateStencilMask(context, mask));
2349         if (isCallValid)
2350         {
2351             context->stencilMask(mask);
2352         }
2353         ANGLE_CAPTURE(StencilMask, isCallValid, context, mask);
2354     }
2355 }
2356 
StencilMaskSeparate(GLenum face,GLuint mask)2357 void GL_APIENTRY StencilMaskSeparate(GLenum face, GLuint mask)
2358 {
2359     Context *context = GetValidGlobalContext();
2360     EVENT("glStencilMaskSeparate", "context = %d, GLenum face = %s, GLuint mask = %u", CID(context),
2361           GLenumToString(GLenumGroup::StencilFaceDirection, face), mask);
2362 
2363     if (context)
2364     {
2365         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2366         bool isCallValid =
2367             (context->skipValidation() || ValidateStencilMaskSeparate(context, face, mask));
2368         if (isCallValid)
2369         {
2370             context->stencilMaskSeparate(face, mask);
2371         }
2372         ANGLE_CAPTURE(StencilMaskSeparate, isCallValid, context, face, mask);
2373     }
2374 }
2375 
StencilOp(GLenum fail,GLenum zfail,GLenum zpass)2376 void GL_APIENTRY StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
2377 {
2378     Context *context = GetValidGlobalContext();
2379     EVENT("glStencilOp", "context = %d, GLenum fail = %s, GLenum zfail = %s, GLenum zpass = %s",
2380           CID(context), GLenumToString(GLenumGroup::StencilOp, fail),
2381           GLenumToString(GLenumGroup::StencilOp, zfail),
2382           GLenumToString(GLenumGroup::StencilOp, zpass));
2383 
2384     if (context)
2385     {
2386         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2387         bool isCallValid =
2388             (context->skipValidation() || ValidateStencilOp(context, fail, zfail, zpass));
2389         if (isCallValid)
2390         {
2391             context->stencilOp(fail, zfail, zpass);
2392         }
2393         ANGLE_CAPTURE(StencilOp, isCallValid, context, fail, zfail, zpass);
2394     }
2395 }
2396 
StencilOpSeparate(GLenum face,GLenum sfail,GLenum dpfail,GLenum dppass)2397 void GL_APIENTRY StencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)
2398 {
2399     Context *context = GetValidGlobalContext();
2400     EVENT(
2401         "glStencilOpSeparate",
2402         "context = %d, GLenum face = %s, GLenum sfail = %s, GLenum dpfail = %s, GLenum dppass = %s",
2403         CID(context), GLenumToString(GLenumGroup::StencilFaceDirection, face),
2404         GLenumToString(GLenumGroup::StencilOp, sfail),
2405         GLenumToString(GLenumGroup::StencilOp, dpfail),
2406         GLenumToString(GLenumGroup::StencilOp, dppass));
2407 
2408     if (context)
2409     {
2410         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2411         bool isCallValid                                      = (context->skipValidation() ||
2412                             ValidateStencilOpSeparate(context, face, sfail, dpfail, dppass));
2413         if (isCallValid)
2414         {
2415             context->stencilOpSeparate(face, sfail, dpfail, dppass);
2416         }
2417         ANGLE_CAPTURE(StencilOpSeparate, isCallValid, context, face, sfail, dpfail, dppass);
2418     }
2419 }
2420 
TexImage2D(GLenum target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const void * pixels)2421 void GL_APIENTRY TexImage2D(GLenum target,
2422                             GLint level,
2423                             GLint internalformat,
2424                             GLsizei width,
2425                             GLsizei height,
2426                             GLint border,
2427                             GLenum format,
2428                             GLenum type,
2429                             const void *pixels)
2430 {
2431     Context *context = GetValidGlobalContext();
2432     EVENT("glTexImage2D",
2433           "context = %d, GLenum target = %s, GLint level = %d, GLint internalformat = %d, GLsizei "
2434           "width = %d, GLsizei height = %d, GLint border = %d, GLenum format = %s, GLenum type = "
2435           "%s, const void *pixels = 0x%016" PRIxPTR "",
2436           CID(context), GLenumToString(GLenumGroup::TextureTarget, target), level, internalformat,
2437           width, height, border, GLenumToString(GLenumGroup::PixelFormat, format),
2438           GLenumToString(GLenumGroup::PixelType, type), (uintptr_t)pixels);
2439 
2440     if (context)
2441     {
2442         TextureTarget targetPacked                            = FromGL<TextureTarget>(target);
2443         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2444         bool isCallValid                                      = (context->skipValidation() ||
2445                             ValidateTexImage2D(context, targetPacked, level, internalformat, width,
2446                                                height, border, format, type, pixels));
2447         if (isCallValid)
2448         {
2449             context->texImage2D(targetPacked, level, internalformat, width, height, border, format,
2450                                 type, pixels);
2451         }
2452         ANGLE_CAPTURE(TexImage2D, isCallValid, context, targetPacked, level, internalformat, width,
2453                       height, border, format, type, pixels);
2454     }
2455 }
2456 
TexParameterf(GLenum target,GLenum pname,GLfloat param)2457 void GL_APIENTRY TexParameterf(GLenum target, GLenum pname, GLfloat param)
2458 {
2459     Context *context = GetValidGlobalContext();
2460     EVENT("glTexParameterf",
2461           "context = %d, GLenum target = %s, GLenum pname = %s, GLfloat param = %f", CID(context),
2462           GLenumToString(GLenumGroup::TextureTarget, target),
2463           GLenumToString(GLenumGroup::TextureParameterName, pname), param);
2464 
2465     if (context)
2466     {
2467         TextureType targetPacked                              = FromGL<TextureType>(target);
2468         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2469         bool isCallValid                                      = (context->skipValidation() ||
2470                             ValidateTexParameterf(context, targetPacked, pname, param));
2471         if (isCallValid)
2472         {
2473             context->texParameterf(targetPacked, pname, param);
2474         }
2475         ANGLE_CAPTURE(TexParameterf, isCallValid, context, targetPacked, pname, param);
2476     }
2477 }
2478 
TexParameterfv(GLenum target,GLenum pname,const GLfloat * params)2479 void GL_APIENTRY TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
2480 {
2481     Context *context = GetValidGlobalContext();
2482     EVENT("glTexParameterfv",
2483           "context = %d, GLenum target = %s, GLenum pname = %s, const GLfloat *params = "
2484           "0x%016" PRIxPTR "",
2485           CID(context), GLenumToString(GLenumGroup::TextureTarget, target),
2486           GLenumToString(GLenumGroup::TextureParameterName, pname), (uintptr_t)params);
2487 
2488     if (context)
2489     {
2490         TextureType targetPacked                              = FromGL<TextureType>(target);
2491         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2492         bool isCallValid                                      = (context->skipValidation() ||
2493                             ValidateTexParameterfv(context, targetPacked, pname, params));
2494         if (isCallValid)
2495         {
2496             context->texParameterfv(targetPacked, pname, params);
2497         }
2498         ANGLE_CAPTURE(TexParameterfv, isCallValid, context, targetPacked, pname, params);
2499     }
2500 }
2501 
TexParameteri(GLenum target,GLenum pname,GLint param)2502 void GL_APIENTRY TexParameteri(GLenum target, GLenum pname, GLint param)
2503 {
2504     Context *context = GetValidGlobalContext();
2505     EVENT("glTexParameteri",
2506           "context = %d, GLenum target = %s, GLenum pname = %s, GLint param = %d", CID(context),
2507           GLenumToString(GLenumGroup::TextureTarget, target),
2508           GLenumToString(GLenumGroup::TextureParameterName, pname), param);
2509 
2510     if (context)
2511     {
2512         TextureType targetPacked                              = FromGL<TextureType>(target);
2513         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2514         bool isCallValid                                      = (context->skipValidation() ||
2515                             ValidateTexParameteri(context, targetPacked, pname, param));
2516         if (isCallValid)
2517         {
2518             context->texParameteri(targetPacked, pname, param);
2519         }
2520         ANGLE_CAPTURE(TexParameteri, isCallValid, context, targetPacked, pname, param);
2521     }
2522 }
2523 
TexParameteriv(GLenum target,GLenum pname,const GLint * params)2524 void GL_APIENTRY TexParameteriv(GLenum target, GLenum pname, const GLint *params)
2525 {
2526     Context *context = GetValidGlobalContext();
2527     EVENT(
2528         "glTexParameteriv",
2529         "context = %d, GLenum target = %s, GLenum pname = %s, const GLint *params = 0x%016" PRIxPTR
2530         "",
2531         CID(context), GLenumToString(GLenumGroup::TextureTarget, target),
2532         GLenumToString(GLenumGroup::TextureParameterName, pname), (uintptr_t)params);
2533 
2534     if (context)
2535     {
2536         TextureType targetPacked                              = FromGL<TextureType>(target);
2537         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2538         bool isCallValid                                      = (context->skipValidation() ||
2539                             ValidateTexParameteriv(context, targetPacked, pname, params));
2540         if (isCallValid)
2541         {
2542             context->texParameteriv(targetPacked, pname, params);
2543         }
2544         ANGLE_CAPTURE(TexParameteriv, isCallValid, context, targetPacked, pname, params);
2545     }
2546 }
2547 
TexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const void * pixels)2548 void GL_APIENTRY TexSubImage2D(GLenum target,
2549                                GLint level,
2550                                GLint xoffset,
2551                                GLint yoffset,
2552                                GLsizei width,
2553                                GLsizei height,
2554                                GLenum format,
2555                                GLenum type,
2556                                const void *pixels)
2557 {
2558     Context *context = GetValidGlobalContext();
2559     EVENT("glTexSubImage2D",
2560           "context = %d, GLenum target = %s, GLint level = %d, GLint xoffset = %d, GLint yoffset = "
2561           "%d, GLsizei width = %d, GLsizei height = %d, GLenum format = %s, GLenum type = %s, "
2562           "const void *pixels = 0x%016" PRIxPTR "",
2563           CID(context), GLenumToString(GLenumGroup::TextureTarget, target), level, xoffset, yoffset,
2564           width, height, GLenumToString(GLenumGroup::PixelFormat, format),
2565           GLenumToString(GLenumGroup::PixelType, type), (uintptr_t)pixels);
2566 
2567     if (context)
2568     {
2569         TextureTarget targetPacked                            = FromGL<TextureTarget>(target);
2570         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2571         bool isCallValid                                      = (context->skipValidation() ||
2572                             ValidateTexSubImage2D(context, targetPacked, level, xoffset, yoffset,
2573                                                   width, height, format, type, pixels));
2574         if (isCallValid)
2575         {
2576             context->texSubImage2D(targetPacked, level, xoffset, yoffset, width, height, format,
2577                                    type, pixels);
2578         }
2579         ANGLE_CAPTURE(TexSubImage2D, isCallValid, context, targetPacked, level, xoffset, yoffset,
2580                       width, height, format, type, pixels);
2581     }
2582 }
2583 
Uniform1f(GLint location,GLfloat v0)2584 void GL_APIENTRY Uniform1f(GLint location, GLfloat v0)
2585 {
2586     Context *context = GetValidGlobalContext();
2587     EVENT("glUniform1f", "context = %d, GLint location = %d, GLfloat v0 = %f", CID(context),
2588           location, v0);
2589 
2590     if (context)
2591     {
2592         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2593         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2594         bool isCallValid =
2595             (context->skipValidation() || ValidateUniform1f(context, locationPacked, v0));
2596         if (isCallValid)
2597         {
2598             context->uniform1f(locationPacked, v0);
2599         }
2600         ANGLE_CAPTURE(Uniform1f, isCallValid, context, locationPacked, v0);
2601     }
2602 }
2603 
Uniform1fv(GLint location,GLsizei count,const GLfloat * value)2604 void GL_APIENTRY Uniform1fv(GLint location, GLsizei count, const GLfloat *value)
2605 {
2606     Context *context = GetValidGlobalContext();
2607     EVENT("glUniform1fv",
2608           "context = %d, GLint location = %d, GLsizei count = %d, const GLfloat *value = "
2609           "0x%016" PRIxPTR "",
2610           CID(context), location, count, (uintptr_t)value);
2611 
2612     if (context)
2613     {
2614         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2615         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2616         bool isCallValid                                      = (context->skipValidation() ||
2617                             ValidateUniform1fv(context, locationPacked, count, value));
2618         if (isCallValid)
2619         {
2620             context->uniform1fv(locationPacked, count, value);
2621         }
2622         ANGLE_CAPTURE(Uniform1fv, isCallValid, context, locationPacked, count, value);
2623     }
2624 }
2625 
Uniform1i(GLint location,GLint v0)2626 void GL_APIENTRY Uniform1i(GLint location, GLint v0)
2627 {
2628     Context *context = GetValidGlobalContext();
2629     EVENT("glUniform1i", "context = %d, GLint location = %d, GLint v0 = %d", CID(context), location,
2630           v0);
2631 
2632     if (context)
2633     {
2634         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2635         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2636         bool isCallValid =
2637             (context->skipValidation() || ValidateUniform1i(context, locationPacked, v0));
2638         if (isCallValid)
2639         {
2640             context->uniform1i(locationPacked, v0);
2641         }
2642         ANGLE_CAPTURE(Uniform1i, isCallValid, context, locationPacked, v0);
2643     }
2644 }
2645 
Uniform1iv(GLint location,GLsizei count,const GLint * value)2646 void GL_APIENTRY Uniform1iv(GLint location, GLsizei count, const GLint *value)
2647 {
2648     Context *context = GetValidGlobalContext();
2649     EVENT(
2650         "glUniform1iv",
2651         "context = %d, GLint location = %d, GLsizei count = %d, const GLint *value = 0x%016" PRIxPTR
2652         "",
2653         CID(context), location, count, (uintptr_t)value);
2654 
2655     if (context)
2656     {
2657         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2658         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2659         bool isCallValid                                      = (context->skipValidation() ||
2660                             ValidateUniform1iv(context, locationPacked, count, value));
2661         if (isCallValid)
2662         {
2663             context->uniform1iv(locationPacked, count, value);
2664         }
2665         ANGLE_CAPTURE(Uniform1iv, isCallValid, context, locationPacked, count, value);
2666     }
2667 }
2668 
Uniform2f(GLint location,GLfloat v0,GLfloat v1)2669 void GL_APIENTRY Uniform2f(GLint location, GLfloat v0, GLfloat v1)
2670 {
2671     Context *context = GetValidGlobalContext();
2672     EVENT("glUniform2f", "context = %d, GLint location = %d, GLfloat v0 = %f, GLfloat v1 = %f",
2673           CID(context), location, v0, v1);
2674 
2675     if (context)
2676     {
2677         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2678         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2679         bool isCallValid =
2680             (context->skipValidation() || ValidateUniform2f(context, locationPacked, v0, v1));
2681         if (isCallValid)
2682         {
2683             context->uniform2f(locationPacked, v0, v1);
2684         }
2685         ANGLE_CAPTURE(Uniform2f, isCallValid, context, locationPacked, v0, v1);
2686     }
2687 }
2688 
Uniform2fv(GLint location,GLsizei count,const GLfloat * value)2689 void GL_APIENTRY Uniform2fv(GLint location, GLsizei count, const GLfloat *value)
2690 {
2691     Context *context = GetValidGlobalContext();
2692     EVENT("glUniform2fv",
2693           "context = %d, GLint location = %d, GLsizei count = %d, const GLfloat *value = "
2694           "0x%016" PRIxPTR "",
2695           CID(context), location, count, (uintptr_t)value);
2696 
2697     if (context)
2698     {
2699         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2700         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2701         bool isCallValid                                      = (context->skipValidation() ||
2702                             ValidateUniform2fv(context, locationPacked, count, value));
2703         if (isCallValid)
2704         {
2705             context->uniform2fv(locationPacked, count, value);
2706         }
2707         ANGLE_CAPTURE(Uniform2fv, isCallValid, context, locationPacked, count, value);
2708     }
2709 }
2710 
Uniform2i(GLint location,GLint v0,GLint v1)2711 void GL_APIENTRY Uniform2i(GLint location, GLint v0, GLint v1)
2712 {
2713     Context *context = GetValidGlobalContext();
2714     EVENT("glUniform2i", "context = %d, GLint location = %d, GLint v0 = %d, GLint v1 = %d",
2715           CID(context), location, v0, v1);
2716 
2717     if (context)
2718     {
2719         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2720         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2721         bool isCallValid =
2722             (context->skipValidation() || ValidateUniform2i(context, locationPacked, v0, v1));
2723         if (isCallValid)
2724         {
2725             context->uniform2i(locationPacked, v0, v1);
2726         }
2727         ANGLE_CAPTURE(Uniform2i, isCallValid, context, locationPacked, v0, v1);
2728     }
2729 }
2730 
Uniform2iv(GLint location,GLsizei count,const GLint * value)2731 void GL_APIENTRY Uniform2iv(GLint location, GLsizei count, const GLint *value)
2732 {
2733     Context *context = GetValidGlobalContext();
2734     EVENT(
2735         "glUniform2iv",
2736         "context = %d, GLint location = %d, GLsizei count = %d, const GLint *value = 0x%016" PRIxPTR
2737         "",
2738         CID(context), location, count, (uintptr_t)value);
2739 
2740     if (context)
2741     {
2742         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2743         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2744         bool isCallValid                                      = (context->skipValidation() ||
2745                             ValidateUniform2iv(context, locationPacked, count, value));
2746         if (isCallValid)
2747         {
2748             context->uniform2iv(locationPacked, count, value);
2749         }
2750         ANGLE_CAPTURE(Uniform2iv, isCallValid, context, locationPacked, count, value);
2751     }
2752 }
2753 
Uniform3f(GLint location,GLfloat v0,GLfloat v1,GLfloat v2)2754 void GL_APIENTRY Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
2755 {
2756     Context *context = GetValidGlobalContext();
2757     EVENT("glUniform3f",
2758           "context = %d, GLint location = %d, GLfloat v0 = %f, GLfloat v1 = %f, GLfloat v2 = %f",
2759           CID(context), location, v0, v1, v2);
2760 
2761     if (context)
2762     {
2763         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2764         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2765         bool isCallValid =
2766             (context->skipValidation() || ValidateUniform3f(context, locationPacked, v0, v1, v2));
2767         if (isCallValid)
2768         {
2769             context->uniform3f(locationPacked, v0, v1, v2);
2770         }
2771         ANGLE_CAPTURE(Uniform3f, isCallValid, context, locationPacked, v0, v1, v2);
2772     }
2773 }
2774 
Uniform3fv(GLint location,GLsizei count,const GLfloat * value)2775 void GL_APIENTRY Uniform3fv(GLint location, GLsizei count, const GLfloat *value)
2776 {
2777     Context *context = GetValidGlobalContext();
2778     EVENT("glUniform3fv",
2779           "context = %d, GLint location = %d, GLsizei count = %d, const GLfloat *value = "
2780           "0x%016" PRIxPTR "",
2781           CID(context), location, count, (uintptr_t)value);
2782 
2783     if (context)
2784     {
2785         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2786         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2787         bool isCallValid                                      = (context->skipValidation() ||
2788                             ValidateUniform3fv(context, locationPacked, count, value));
2789         if (isCallValid)
2790         {
2791             context->uniform3fv(locationPacked, count, value);
2792         }
2793         ANGLE_CAPTURE(Uniform3fv, isCallValid, context, locationPacked, count, value);
2794     }
2795 }
2796 
Uniform3i(GLint location,GLint v0,GLint v1,GLint v2)2797 void GL_APIENTRY Uniform3i(GLint location, GLint v0, GLint v1, GLint v2)
2798 {
2799     Context *context = GetValidGlobalContext();
2800     EVENT("glUniform3i",
2801           "context = %d, GLint location = %d, GLint v0 = %d, GLint v1 = %d, GLint v2 = %d",
2802           CID(context), location, v0, v1, v2);
2803 
2804     if (context)
2805     {
2806         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2807         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2808         bool isCallValid =
2809             (context->skipValidation() || ValidateUniform3i(context, locationPacked, v0, v1, v2));
2810         if (isCallValid)
2811         {
2812             context->uniform3i(locationPacked, v0, v1, v2);
2813         }
2814         ANGLE_CAPTURE(Uniform3i, isCallValid, context, locationPacked, v0, v1, v2);
2815     }
2816 }
2817 
Uniform3iv(GLint location,GLsizei count,const GLint * value)2818 void GL_APIENTRY Uniform3iv(GLint location, GLsizei count, const GLint *value)
2819 {
2820     Context *context = GetValidGlobalContext();
2821     EVENT(
2822         "glUniform3iv",
2823         "context = %d, GLint location = %d, GLsizei count = %d, const GLint *value = 0x%016" PRIxPTR
2824         "",
2825         CID(context), location, count, (uintptr_t)value);
2826 
2827     if (context)
2828     {
2829         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2830         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2831         bool isCallValid                                      = (context->skipValidation() ||
2832                             ValidateUniform3iv(context, locationPacked, count, value));
2833         if (isCallValid)
2834         {
2835             context->uniform3iv(locationPacked, count, value);
2836         }
2837         ANGLE_CAPTURE(Uniform3iv, isCallValid, context, locationPacked, count, value);
2838     }
2839 }
2840 
Uniform4f(GLint location,GLfloat v0,GLfloat v1,GLfloat v2,GLfloat v3)2841 void GL_APIENTRY Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
2842 {
2843     Context *context = GetValidGlobalContext();
2844     EVENT("glUniform4f",
2845           "context = %d, GLint location = %d, GLfloat v0 = %f, GLfloat v1 = %f, GLfloat v2 = %f, "
2846           "GLfloat v3 = %f",
2847           CID(context), location, v0, v1, v2, v3);
2848 
2849     if (context)
2850     {
2851         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2852         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2853         bool isCallValid                                      = (context->skipValidation() ||
2854                             ValidateUniform4f(context, locationPacked, v0, v1, v2, v3));
2855         if (isCallValid)
2856         {
2857             context->uniform4f(locationPacked, v0, v1, v2, v3);
2858         }
2859         ANGLE_CAPTURE(Uniform4f, isCallValid, context, locationPacked, v0, v1, v2, v3);
2860     }
2861 }
2862 
Uniform4fv(GLint location,GLsizei count,const GLfloat * value)2863 void GL_APIENTRY Uniform4fv(GLint location, GLsizei count, const GLfloat *value)
2864 {
2865     Context *context = GetValidGlobalContext();
2866     EVENT("glUniform4fv",
2867           "context = %d, GLint location = %d, GLsizei count = %d, const GLfloat *value = "
2868           "0x%016" PRIxPTR "",
2869           CID(context), location, count, (uintptr_t)value);
2870 
2871     if (context)
2872     {
2873         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2874         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2875         bool isCallValid                                      = (context->skipValidation() ||
2876                             ValidateUniform4fv(context, locationPacked, count, value));
2877         if (isCallValid)
2878         {
2879             context->uniform4fv(locationPacked, count, value);
2880         }
2881         ANGLE_CAPTURE(Uniform4fv, isCallValid, context, locationPacked, count, value);
2882     }
2883 }
2884 
Uniform4i(GLint location,GLint v0,GLint v1,GLint v2,GLint v3)2885 void GL_APIENTRY Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
2886 {
2887     Context *context = GetValidGlobalContext();
2888     EVENT("glUniform4i",
2889           "context = %d, GLint location = %d, GLint v0 = %d, GLint v1 = %d, GLint v2 = %d, GLint "
2890           "v3 = %d",
2891           CID(context), location, v0, v1, v2, v3);
2892 
2893     if (context)
2894     {
2895         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2896         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2897         bool isCallValid                                      = (context->skipValidation() ||
2898                             ValidateUniform4i(context, locationPacked, v0, v1, v2, v3));
2899         if (isCallValid)
2900         {
2901             context->uniform4i(locationPacked, v0, v1, v2, v3);
2902         }
2903         ANGLE_CAPTURE(Uniform4i, isCallValid, context, locationPacked, v0, v1, v2, v3);
2904     }
2905 }
2906 
Uniform4iv(GLint location,GLsizei count,const GLint * value)2907 void GL_APIENTRY Uniform4iv(GLint location, GLsizei count, const GLint *value)
2908 {
2909     Context *context = GetValidGlobalContext();
2910     EVENT(
2911         "glUniform4iv",
2912         "context = %d, GLint location = %d, GLsizei count = %d, const GLint *value = 0x%016" PRIxPTR
2913         "",
2914         CID(context), location, count, (uintptr_t)value);
2915 
2916     if (context)
2917     {
2918         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2919         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2920         bool isCallValid                                      = (context->skipValidation() ||
2921                             ValidateUniform4iv(context, locationPacked, count, value));
2922         if (isCallValid)
2923         {
2924             context->uniform4iv(locationPacked, count, value);
2925         }
2926         ANGLE_CAPTURE(Uniform4iv, isCallValid, context, locationPacked, count, value);
2927     }
2928 }
2929 
UniformMatrix2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)2930 void GL_APIENTRY UniformMatrix2fv(GLint location,
2931                                   GLsizei count,
2932                                   GLboolean transpose,
2933                                   const GLfloat *value)
2934 {
2935     Context *context = GetValidGlobalContext();
2936     EVENT("glUniformMatrix2fv",
2937           "context = %d, GLint location = %d, GLsizei count = %d, GLboolean transpose = %s, const "
2938           "GLfloat *value = 0x%016" PRIxPTR "",
2939           CID(context), location, count, GLbooleanToString(transpose), (uintptr_t)value);
2940 
2941     if (context)
2942     {
2943         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2944         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2945         bool isCallValid =
2946             (context->skipValidation() ||
2947              ValidateUniformMatrix2fv(context, locationPacked, count, transpose, value));
2948         if (isCallValid)
2949         {
2950             context->uniformMatrix2fv(locationPacked, count, transpose, value);
2951         }
2952         ANGLE_CAPTURE(UniformMatrix2fv, isCallValid, context, locationPacked, count, transpose,
2953                       value);
2954     }
2955 }
2956 
UniformMatrix3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)2957 void GL_APIENTRY UniformMatrix3fv(GLint location,
2958                                   GLsizei count,
2959                                   GLboolean transpose,
2960                                   const GLfloat *value)
2961 {
2962     Context *context = GetValidGlobalContext();
2963     EVENT("glUniformMatrix3fv",
2964           "context = %d, GLint location = %d, GLsizei count = %d, GLboolean transpose = %s, const "
2965           "GLfloat *value = 0x%016" PRIxPTR "",
2966           CID(context), location, count, GLbooleanToString(transpose), (uintptr_t)value);
2967 
2968     if (context)
2969     {
2970         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2971         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2972         bool isCallValid =
2973             (context->skipValidation() ||
2974              ValidateUniformMatrix3fv(context, locationPacked, count, transpose, value));
2975         if (isCallValid)
2976         {
2977             context->uniformMatrix3fv(locationPacked, count, transpose, value);
2978         }
2979         ANGLE_CAPTURE(UniformMatrix3fv, isCallValid, context, locationPacked, count, transpose,
2980                       value);
2981     }
2982 }
2983 
UniformMatrix4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)2984 void GL_APIENTRY UniformMatrix4fv(GLint location,
2985                                   GLsizei count,
2986                                   GLboolean transpose,
2987                                   const GLfloat *value)
2988 {
2989     Context *context = GetValidGlobalContext();
2990     EVENT("glUniformMatrix4fv",
2991           "context = %d, GLint location = %d, GLsizei count = %d, GLboolean transpose = %s, const "
2992           "GLfloat *value = 0x%016" PRIxPTR "",
2993           CID(context), location, count, GLbooleanToString(transpose), (uintptr_t)value);
2994 
2995     if (context)
2996     {
2997         UniformLocation locationPacked                        = FromGL<UniformLocation>(location);
2998         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
2999         bool isCallValid =
3000             (context->skipValidation() ||
3001              ValidateUniformMatrix4fv(context, locationPacked, count, transpose, value));
3002         if (isCallValid)
3003         {
3004             context->uniformMatrix4fv(locationPacked, count, transpose, value);
3005         }
3006         ANGLE_CAPTURE(UniformMatrix4fv, isCallValid, context, locationPacked, count, transpose,
3007                       value);
3008     }
3009 }
3010 
UseProgram(GLuint program)3011 void GL_APIENTRY UseProgram(GLuint program)
3012 {
3013     Context *context = GetValidGlobalContext();
3014     EVENT("glUseProgram", "context = %d, GLuint program = %u", CID(context), program);
3015 
3016     if (context)
3017     {
3018         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
3019         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3020         bool isCallValid =
3021             (context->skipValidation() || ValidateUseProgram(context, programPacked));
3022         if (isCallValid)
3023         {
3024             context->useProgram(programPacked);
3025         }
3026         ANGLE_CAPTURE(UseProgram, isCallValid, context, programPacked);
3027     }
3028 }
3029 
ValidateProgram(GLuint program)3030 void GL_APIENTRY ValidateProgram(GLuint program)
3031 {
3032     Context *context = GetValidGlobalContext();
3033     EVENT("glValidateProgram", "context = %d, GLuint program = %u", CID(context), program);
3034 
3035     if (context)
3036     {
3037         ShaderProgramID programPacked                         = FromGL<ShaderProgramID>(program);
3038         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3039         bool isCallValid =
3040             (context->skipValidation() || ValidateValidateProgram(context, programPacked));
3041         if (isCallValid)
3042         {
3043             context->validateProgram(programPacked);
3044         }
3045         ANGLE_CAPTURE(ValidateProgram, isCallValid, context, programPacked);
3046     }
3047 }
3048 
VertexAttrib1f(GLuint index,GLfloat x)3049 void GL_APIENTRY VertexAttrib1f(GLuint index, GLfloat x)
3050 {
3051     Context *context = GetValidGlobalContext();
3052     EVENT("glVertexAttrib1f", "context = %d, GLuint index = %u, GLfloat x = %f", CID(context),
3053           index, x);
3054 
3055     if (context)
3056     {
3057         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3058         bool isCallValid = (context->skipValidation() || ValidateVertexAttrib1f(context, index, x));
3059         if (isCallValid)
3060         {
3061             context->vertexAttrib1f(index, x);
3062         }
3063         ANGLE_CAPTURE(VertexAttrib1f, isCallValid, context, index, x);
3064     }
3065 }
3066 
VertexAttrib1fv(GLuint index,const GLfloat * v)3067 void GL_APIENTRY VertexAttrib1fv(GLuint index, const GLfloat *v)
3068 {
3069     Context *context = GetValidGlobalContext();
3070     EVENT("glVertexAttrib1fv",
3071           "context = %d, GLuint index = %u, const GLfloat *v = 0x%016" PRIxPTR "", CID(context),
3072           index, (uintptr_t)v);
3073 
3074     if (context)
3075     {
3076         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3077         bool isCallValid =
3078             (context->skipValidation() || ValidateVertexAttrib1fv(context, index, v));
3079         if (isCallValid)
3080         {
3081             context->vertexAttrib1fv(index, v);
3082         }
3083         ANGLE_CAPTURE(VertexAttrib1fv, isCallValid, context, index, v);
3084     }
3085 }
3086 
VertexAttrib2f(GLuint index,GLfloat x,GLfloat y)3087 void GL_APIENTRY VertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
3088 {
3089     Context *context = GetValidGlobalContext();
3090     EVENT("glVertexAttrib2f", "context = %d, GLuint index = %u, GLfloat x = %f, GLfloat y = %f",
3091           CID(context), index, x, y);
3092 
3093     if (context)
3094     {
3095         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3096         bool isCallValid =
3097             (context->skipValidation() || ValidateVertexAttrib2f(context, index, x, y));
3098         if (isCallValid)
3099         {
3100             context->vertexAttrib2f(index, x, y);
3101         }
3102         ANGLE_CAPTURE(VertexAttrib2f, isCallValid, context, index, x, y);
3103     }
3104 }
3105 
VertexAttrib2fv(GLuint index,const GLfloat * v)3106 void GL_APIENTRY VertexAttrib2fv(GLuint index, const GLfloat *v)
3107 {
3108     Context *context = GetValidGlobalContext();
3109     EVENT("glVertexAttrib2fv",
3110           "context = %d, GLuint index = %u, const GLfloat *v = 0x%016" PRIxPTR "", CID(context),
3111           index, (uintptr_t)v);
3112 
3113     if (context)
3114     {
3115         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3116         bool isCallValid =
3117             (context->skipValidation() || ValidateVertexAttrib2fv(context, index, v));
3118         if (isCallValid)
3119         {
3120             context->vertexAttrib2fv(index, v);
3121         }
3122         ANGLE_CAPTURE(VertexAttrib2fv, isCallValid, context, index, v);
3123     }
3124 }
3125 
VertexAttrib3f(GLuint index,GLfloat x,GLfloat y,GLfloat z)3126 void GL_APIENTRY VertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
3127 {
3128     Context *context = GetValidGlobalContext();
3129     EVENT("glVertexAttrib3f",
3130           "context = %d, GLuint index = %u, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f",
3131           CID(context), index, x, y, z);
3132 
3133     if (context)
3134     {
3135         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3136         bool isCallValid =
3137             (context->skipValidation() || ValidateVertexAttrib3f(context, index, x, y, z));
3138         if (isCallValid)
3139         {
3140             context->vertexAttrib3f(index, x, y, z);
3141         }
3142         ANGLE_CAPTURE(VertexAttrib3f, isCallValid, context, index, x, y, z);
3143     }
3144 }
3145 
VertexAttrib3fv(GLuint index,const GLfloat * v)3146 void GL_APIENTRY VertexAttrib3fv(GLuint index, const GLfloat *v)
3147 {
3148     Context *context = GetValidGlobalContext();
3149     EVENT("glVertexAttrib3fv",
3150           "context = %d, GLuint index = %u, const GLfloat *v = 0x%016" PRIxPTR "", CID(context),
3151           index, (uintptr_t)v);
3152 
3153     if (context)
3154     {
3155         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3156         bool isCallValid =
3157             (context->skipValidation() || ValidateVertexAttrib3fv(context, index, v));
3158         if (isCallValid)
3159         {
3160             context->vertexAttrib3fv(index, v);
3161         }
3162         ANGLE_CAPTURE(VertexAttrib3fv, isCallValid, context, index, v);
3163     }
3164 }
3165 
VertexAttrib4f(GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)3166 void GL_APIENTRY VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
3167 {
3168     Context *context = GetValidGlobalContext();
3169     EVENT("glVertexAttrib4f",
3170           "context = %d, GLuint index = %u, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, "
3171           "GLfloat w = %f",
3172           CID(context), index, x, y, z, w);
3173 
3174     if (context)
3175     {
3176         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3177         bool isCallValid =
3178             (context->skipValidation() || ValidateVertexAttrib4f(context, index, x, y, z, w));
3179         if (isCallValid)
3180         {
3181             context->vertexAttrib4f(index, x, y, z, w);
3182         }
3183         ANGLE_CAPTURE(VertexAttrib4f, isCallValid, context, index, x, y, z, w);
3184     }
3185 }
3186 
VertexAttrib4fv(GLuint index,const GLfloat * v)3187 void GL_APIENTRY VertexAttrib4fv(GLuint index, const GLfloat *v)
3188 {
3189     Context *context = GetValidGlobalContext();
3190     EVENT("glVertexAttrib4fv",
3191           "context = %d, GLuint index = %u, const GLfloat *v = 0x%016" PRIxPTR "", CID(context),
3192           index, (uintptr_t)v);
3193 
3194     if (context)
3195     {
3196         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3197         bool isCallValid =
3198             (context->skipValidation() || ValidateVertexAttrib4fv(context, index, v));
3199         if (isCallValid)
3200         {
3201             context->vertexAttrib4fv(index, v);
3202         }
3203         ANGLE_CAPTURE(VertexAttrib4fv, isCallValid, context, index, v);
3204     }
3205 }
3206 
VertexAttribPointer(GLuint index,GLint size,GLenum type,GLboolean normalized,GLsizei stride,const void * pointer)3207 void GL_APIENTRY VertexAttribPointer(GLuint index,
3208                                      GLint size,
3209                                      GLenum type,
3210                                      GLboolean normalized,
3211                                      GLsizei stride,
3212                                      const void *pointer)
3213 {
3214     Context *context = GetValidGlobalContext();
3215     EVENT("glVertexAttribPointer",
3216           "context = %d, GLuint index = %u, GLint size = %d, GLenum type = %s, GLboolean "
3217           "normalized = %s, GLsizei stride = %d, const void *pointer = 0x%016" PRIxPTR "",
3218           CID(context), index, size, GLenumToString(GLenumGroup::VertexAttribPointerType, type),
3219           GLbooleanToString(normalized), stride, (uintptr_t)pointer);
3220 
3221     if (context)
3222     {
3223         VertexAttribType typePacked                           = FromGL<VertexAttribType>(type);
3224         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3225         bool isCallValid                                      = (context->skipValidation() ||
3226                             ValidateVertexAttribPointer(context, index, size, typePacked,
3227                                                         normalized, stride, pointer));
3228         if (isCallValid)
3229         {
3230             context->vertexAttribPointer(index, size, typePacked, normalized, stride, pointer);
3231         }
3232         ANGLE_CAPTURE(VertexAttribPointer, isCallValid, context, index, size, typePacked,
3233                       normalized, stride, pointer);
3234     }
3235 }
3236 
Viewport(GLint x,GLint y,GLsizei width,GLsizei height)3237 void GL_APIENTRY Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
3238 {
3239     Context *context = GetValidGlobalContext();
3240     EVENT("glViewport",
3241           "context = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d",
3242           CID(context), x, y, width, height);
3243 
3244     if (context)
3245     {
3246         std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
3247         bool isCallValid =
3248             (context->skipValidation() || ValidateViewport(context, x, y, width, height));
3249         if (isCallValid)
3250         {
3251             context->viewport(x, y, width, height);
3252         }
3253         ANGLE_CAPTURE(Viewport, isCallValid, context, x, y, width, height);
3254     }
3255 }
3256 }  // namespace gl
3257