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