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