Bug 1666648 [wpt PR 25683] - Fix #23969: Use inexact test type for DUPLICATE-BASENAME...
[gecko.git] / gfx / gl / GLContext.h
blob67155d24400c3436679717d98168d890d894cc75
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef GLCONTEXT_H_
8 #define GLCONTEXT_H_
10 #include <bitset>
11 #include <ctype.h>
12 #include <stdint.h>
13 #include <stdio.h>
14 #include <map>
15 #include <queue>
16 #include <stack>
18 #ifdef DEBUG
19 # include <string.h>
20 #endif
22 #ifdef GetClassName
23 # undef GetClassName
24 #endif
26 // Define MOZ_GL_DEBUG unconditionally to enable GL debugging in opt
27 // builds.
28 #ifdef DEBUG
29 # define MOZ_GL_DEBUG 1
30 #endif
32 #include "mozilla/RefPtr.h"
33 #include "mozilla/UniquePtr.h"
34 #include "mozilla/ThreadLocal.h"
36 #include "MozFramebuffer.h"
37 #include "nsTArray.h"
38 #include "GLDefs.h"
39 #include "GLLibraryLoader.h"
40 #include "nsISupportsImpl.h"
41 #include "nsRegionFwd.h"
42 #include "nsString.h"
43 #include "plstr.h"
44 #include "GLContextTypes.h"
45 #include "SurfaceTypes.h"
46 #include "GLContextSymbols.h"
47 #include "base/platform_thread.h" // for PlatformThreadId
48 #include "mozilla/GenericRefCounted.h"
49 #include "mozilla/WeakPtr.h"
50 #include "gfx2DGlue.h"
51 #include "GeckoProfiler.h"
53 namespace mozilla {
54 namespace gfx {
55 class DataSourceSurface;
56 class SourceSurface;
57 } // namespace gfx
59 namespace gl {
60 class GLBlitHelper;
61 class GLBlitTextureImageHelper;
62 class GLContext;
63 class GLLibraryEGL;
64 class GLReadTexImageHelper;
65 class SharedSurface;
66 } // namespace gl
68 namespace layers {
69 class ColorTextureLayerProgram;
70 } // namespace layers
72 namespace widget {
73 class CompositorWidget;
74 } // namespace widget
75 } // namespace mozilla
77 namespace mozilla {
78 namespace gl {
80 enum class GLFeature {
81 bind_buffer_offset,
82 blend_minmax,
83 clear_buffers,
84 copy_buffer,
85 depth_texture,
86 draw_buffers,
87 draw_instanced,
88 element_index_uint,
89 ES2_compatibility,
90 ES3_compatibility,
91 EXT_color_buffer_float,
92 frag_color_float,
93 frag_depth,
94 framebuffer_blit,
95 framebuffer_multisample,
96 framebuffer_object,
97 framebuffer_object_EXT_OES,
98 get_integer_indexed,
99 get_integer64_indexed,
100 get_query_object_i64v,
101 get_query_object_iv,
102 gpu_shader4,
103 instanced_arrays,
104 instanced_non_arrays,
105 internalformat_query,
106 invalidate_framebuffer,
107 map_buffer_range,
108 multiview,
109 occlusion_query,
110 occlusion_query_boolean,
111 occlusion_query2,
112 packed_depth_stencil,
113 prim_restart,
114 prim_restart_fixed,
115 query_counter,
116 query_objects,
117 query_time_elapsed,
118 read_buffer,
119 renderbuffer_color_float,
120 renderbuffer_color_half_float,
121 robust_buffer_access_behavior,
122 robustness,
123 sRGB,
124 sampler_objects,
125 seamless_cube_map_opt_in,
126 shader_texture_lod,
127 split_framebuffer,
128 standard_derivatives,
129 sync,
130 texture_3D,
131 texture_3D_compressed,
132 texture_3D_copy,
133 texture_compression_bptc,
134 texture_compression_rgtc,
135 texture_float,
136 texture_float_linear,
137 texture_half_float,
138 texture_half_float_linear,
139 texture_non_power_of_two,
140 texture_norm16,
141 texture_rg,
142 texture_storage,
143 texture_swizzle,
144 transform_feedback2,
145 uniform_buffer_object,
146 uniform_matrix_nonsquare,
147 vertex_array_object,
148 EnumMax
151 enum class ContextProfile : uint8_t {
152 Unknown = 0,
153 OpenGLCore,
154 OpenGLCompatibility,
155 OpenGLES
158 enum class GLVendor {
159 Intel,
160 NVIDIA,
161 ATI,
162 Qualcomm,
163 Imagination,
164 Nouveau,
165 Vivante,
166 VMware,
167 ARM,
168 Other
171 enum class GLRenderer {
172 Adreno200,
173 Adreno205,
174 AdrenoTM200,
175 AdrenoTM205,
176 AdrenoTM305,
177 AdrenoTM320,
178 AdrenoTM330,
179 AdrenoTM420,
180 Mali400MP,
181 Mali450MP,
182 SGX530,
183 SGX540,
184 SGX544MP,
185 Tegra,
186 AndroidEmulator,
187 GalliumLlvmpipe,
188 IntelHD3000,
189 MicrosoftBasicRenderDriver,
190 Other
193 class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
194 public:
195 static MOZ_THREAD_LOCAL(uintptr_t) sCurrentContext;
197 const GLContextDesc mDesc;
199 bool mImplicitMakeCurrent = false;
200 bool mUseTLSIsCurrent;
202 class TlsScope final {
203 const WeakPtr<GLContext> mGL;
204 const bool mWasTlsOk;
206 public:
207 explicit TlsScope(GLContext* const gl)
208 : mGL(gl), mWasTlsOk(gl && gl->mUseTLSIsCurrent) {
209 if (mGL) {
210 mGL->mUseTLSIsCurrent = true;
214 ~TlsScope() {
215 if (mGL) {
216 mGL->mUseTLSIsCurrent = mWasTlsOk;
221 // -----------------------------------------------------------------------------
222 // basic getters
223 public:
225 * Returns true if the context is using ANGLE. This should only be overridden
226 * for an ANGLE implementation.
228 virtual bool IsANGLE() const { return false; }
231 * Returns true if the context is using WARP. This should only be overridden
232 * for an ANGLE implementation.
234 virtual bool IsWARP() const { return false; }
236 virtual void GetWSIInfo(nsCString* const out) const = 0;
239 * Return true if we are running on a OpenGL core profile context
241 inline bool IsCoreProfile() const {
242 MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile");
244 return mProfile == ContextProfile::OpenGLCore;
248 * Return true if we are running on a OpenGL compatibility profile context
249 * (legacy profile 2.1 on Max OS X)
251 inline bool IsCompatibilityProfile() const {
252 MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile");
254 return mProfile == ContextProfile::OpenGLCompatibility;
257 inline bool IsGLES() const {
258 MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile");
260 return mProfile == ContextProfile::OpenGLES;
263 inline bool IsAtLeast(ContextProfile profile, unsigned int version) const {
264 MOZ_ASSERT(profile != ContextProfile::Unknown,
265 "IsAtLeast: bad <profile> parameter");
266 MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile");
267 MOZ_ASSERT(mVersion != 0, "unknown context version");
269 if (version > mVersion) {
270 return false;
273 return profile == mProfile;
277 * Return the version of the context.
278 * Example :
279 * If this a OpenGL 2.1, that will return 210
281 inline uint32_t Version() const { return mVersion; }
283 inline uint32_t ShadingLanguageVersion() const {
284 return mShadingLanguageVersion;
287 GLVendor Vendor() const { return mVendor; }
289 GLRenderer Renderer() const { return mRenderer; }
291 bool IsContextLost() const { return mContextLost; }
293 bool CheckContextLost() const {
294 mTopError = GetError();
295 return IsContextLost();
298 bool HasPBOState() const { return (!IsGLES() || Version() >= 300); }
301 * If this context is double-buffered, returns TRUE.
303 virtual bool IsDoubleBuffered() const { return false; }
305 virtual GLContextType GetContextType() const = 0;
307 virtual bool IsCurrentImpl() const = 0;
308 virtual bool MakeCurrentImpl() const = 0;
310 bool IsCurrent() const {
311 if (mImplicitMakeCurrent) return MakeCurrent();
313 return IsCurrentImpl();
316 bool MakeCurrent(bool aForce = false) const;
319 * Get the default framebuffer for this context.
321 UniquePtr<MozFramebuffer> mOffscreenDefaultFb;
323 bool CreateOffscreenDefaultFb(const gfx::IntSize& size);
325 virtual GLuint GetDefaultFramebuffer() {
326 if (mOffscreenDefaultFb) {
327 return mOffscreenDefaultFb->mFB;
329 return 0;
333 * mVersion store the OpenGL's version, multiplied by 100. For example, if
334 * the context is an OpenGL 2.1 context, mVersion value will be 210.
336 uint32_t mVersion = 0;
337 ContextProfile mProfile = ContextProfile::Unknown;
339 uint32_t mShadingLanguageVersion = 0;
341 GLVendor mVendor = GLVendor::Other;
342 GLRenderer mRenderer = GLRenderer::Other;
344 // -----------------------------------------------------------------------------
345 // Extensions management
347 * This mechanism is designed to know if an extension is supported. In the
348 * long term, we would like to only use the extension group queries XXX_* to
349 * have full compatibility with context version and profiles (especialy the
350 * core that officialy don't bring any extensions).
354 * Known GL extensions that can be queried by
355 * IsExtensionSupported. The results of this are cached, and as
356 * such it's safe to use this even in performance critical code.
357 * If you add to this array, remember to add to the string names
358 * in GLContext.cpp.
360 enum GLExtensions {
361 Extension_None = 0,
362 AMD_compressed_ATC_texture,
363 ANGLE_depth_texture,
364 ANGLE_framebuffer_blit,
365 ANGLE_framebuffer_multisample,
366 ANGLE_instanced_arrays,
367 ANGLE_multiview,
368 ANGLE_texture_compression_dxt3,
369 ANGLE_texture_compression_dxt5,
370 ANGLE_timer_query,
371 APPLE_client_storage,
372 APPLE_fence,
373 APPLE_framebuffer_multisample,
374 APPLE_sync,
375 APPLE_texture_range,
376 APPLE_vertex_array_object,
377 ARB_ES2_compatibility,
378 ARB_ES3_compatibility,
379 ARB_color_buffer_float,
380 ARB_compatibility,
381 ARB_copy_buffer,
382 ARB_depth_texture,
383 ARB_draw_buffers,
384 ARB_draw_instanced,
385 ARB_framebuffer_object,
386 ARB_framebuffer_sRGB,
387 ARB_geometry_shader4,
388 ARB_half_float_pixel,
389 ARB_instanced_arrays,
390 ARB_internalformat_query,
391 ARB_invalidate_subdata,
392 ARB_map_buffer_range,
393 ARB_occlusion_query2,
394 ARB_pixel_buffer_object,
395 ARB_robust_buffer_access_behavior,
396 ARB_robustness,
397 ARB_sampler_objects,
398 ARB_seamless_cube_map,
399 ARB_shader_texture_lod,
400 ARB_sync,
401 ARB_texture_compression,
402 ARB_texture_compression_bptc,
403 ARB_texture_compression_rgtc,
404 ARB_texture_float,
405 ARB_texture_non_power_of_two,
406 ARB_texture_rectangle,
407 ARB_texture_rg,
408 ARB_texture_storage,
409 ARB_texture_swizzle,
410 ARB_timer_query,
411 ARB_transform_feedback2,
412 ARB_uniform_buffer_object,
413 ARB_vertex_array_object,
414 CHROMIUM_color_buffer_float_rgb,
415 CHROMIUM_color_buffer_float_rgba,
416 EXT_bgra,
417 EXT_blend_minmax,
418 EXT_color_buffer_float,
419 EXT_color_buffer_half_float,
420 EXT_copy_texture,
421 EXT_disjoint_timer_query,
422 EXT_draw_buffers,
423 EXT_draw_buffers2,
424 EXT_draw_instanced,
425 EXT_float_blend,
426 EXT_frag_depth,
427 EXT_framebuffer_blit,
428 EXT_framebuffer_multisample,
429 EXT_framebuffer_object,
430 EXT_framebuffer_sRGB,
431 EXT_gpu_shader4,
432 EXT_map_buffer_range,
433 EXT_multisampled_render_to_texture,
434 EXT_occlusion_query_boolean,
435 EXT_packed_depth_stencil,
436 EXT_read_format_bgra,
437 EXT_robustness,
438 EXT_sRGB,
439 EXT_sRGB_write_control,
440 EXT_shader_texture_lod,
441 EXT_texture3D,
442 EXT_texture_compression_bptc,
443 EXT_texture_compression_dxt1,
444 EXT_texture_compression_rgtc,
445 EXT_texture_compression_s3tc,
446 EXT_texture_compression_s3tc_srgb,
447 EXT_texture_filter_anisotropic,
448 EXT_texture_format_BGRA8888,
449 EXT_texture_norm16,
450 EXT_texture_sRGB,
451 EXT_texture_storage,
452 EXT_timer_query,
453 EXT_transform_feedback,
454 EXT_unpack_subimage,
455 IMG_read_format,
456 IMG_texture_compression_pvrtc,
457 IMG_texture_npot,
458 KHR_debug,
459 KHR_parallel_shader_compile,
460 KHR_robust_buffer_access_behavior,
461 KHR_robustness,
462 KHR_texture_compression_astc_hdr,
463 KHR_texture_compression_astc_ldr,
464 NV_draw_instanced,
465 NV_fence,
466 NV_framebuffer_blit,
467 NV_geometry_program4,
468 NV_half_float,
469 NV_instanced_arrays,
470 NV_primitive_restart,
471 NV_texture_barrier,
472 NV_transform_feedback,
473 NV_transform_feedback2,
474 OES_EGL_image,
475 OES_EGL_image_external,
476 OES_EGL_sync,
477 OES_compressed_ETC1_RGB8_texture,
478 OES_depth24,
479 OES_depth32,
480 OES_depth_texture,
481 OES_element_index_uint,
482 OES_fbo_render_mipmap,
483 OES_framebuffer_object,
484 OES_packed_depth_stencil,
485 OES_rgb8_rgba8,
486 OES_standard_derivatives,
487 OES_stencil8,
488 OES_texture_3D,
489 OES_texture_float,
490 OES_texture_float_linear,
491 OES_texture_half_float,
492 OES_texture_half_float_linear,
493 OES_texture_npot,
494 OES_vertex_array_object,
495 OVR_multiview2,
496 Extensions_Max,
497 Extensions_End
500 bool IsExtensionSupported(GLExtensions aKnownExtension) const {
501 return mAvailableExtensions[aKnownExtension];
504 protected:
505 void MarkExtensionUnsupported(GLExtensions aKnownExtension) {
506 mAvailableExtensions[aKnownExtension] = 0;
509 void MarkExtensionSupported(GLExtensions aKnownExtension) {
510 mAvailableExtensions[aKnownExtension] = 1;
513 std::bitset<Extensions_Max> mAvailableExtensions;
515 // -----------------------------------------------------------------------------
516 // Feature queries
518 * This mecahnism introduces a new way to check if a OpenGL feature is
519 * supported, regardless of whether it is supported by an extension or
520 * natively by the context version/profile
522 public:
523 bool IsSupported(GLFeature feature) const {
524 return mAvailableFeatures[size_t(feature)];
527 static const char* GetFeatureName(GLFeature feature);
529 private:
530 std::bitset<size_t(GLFeature::EnumMax)> mAvailableFeatures;
533 * Init features regarding OpenGL extension and context version and profile
535 void InitFeatures();
538 * Mark the feature and associated extensions as unsupported
540 void MarkUnsupported(GLFeature feature);
543 * Is this feature supported using the core (unsuffixed) symbols?
545 bool IsFeatureProvidedByCoreSymbols(GLFeature feature);
547 // -----------------------------------------------------------------------------
548 // Error handling
550 private:
551 mutable bool mContextLost = false;
552 mutable GLenum mTopError = 0;
554 protected:
555 void OnContextLostError() const;
557 public:
558 static std::string GLErrorToString(GLenum aError);
560 static bool IsBadCallError(const GLenum err) {
561 return !(err == 0 || err == LOCAL_GL_CONTEXT_LOST);
564 class LocalErrorScope;
566 private:
567 mutable std::stack<const LocalErrorScope*> mLocalErrorScopeStack;
568 mutable UniquePtr<LocalErrorScope> mDebugErrorScope;
570 ////////////////////////////////////
571 // Use this safer option.
573 public:
574 class LocalErrorScope {
575 const GLContext& mGL;
576 GLenum mOldTop;
577 bool mHasBeenChecked;
579 public:
580 explicit LocalErrorScope(const GLContext& gl)
581 : mGL(gl), mHasBeenChecked(false) {
582 mGL.mLocalErrorScopeStack.push(this);
583 mOldTop = mGL.GetError();
586 /// Never returns CONTEXT_LOST.
587 GLenum GetError() {
588 MOZ_ASSERT(!mHasBeenChecked);
589 mHasBeenChecked = true;
591 const auto ret = mGL.GetError();
592 if (ret == LOCAL_GL_CONTEXT_LOST) return 0;
593 return ret;
596 ~LocalErrorScope() {
597 MOZ_ASSERT(mHasBeenChecked);
599 MOZ_ASSERT(!IsBadCallError(mGL.GetError()));
601 MOZ_ASSERT(mGL.mLocalErrorScopeStack.top() == this);
602 mGL.mLocalErrorScopeStack.pop();
604 mGL.mTopError = mOldTop;
608 // -
610 bool GetPotentialInteger(GLenum pname, GLint* param) {
611 LocalErrorScope localError(*this);
613 fGetIntegerv(pname, param);
615 GLenum err = localError.GetError();
616 MOZ_ASSERT_IF(err != LOCAL_GL_NO_ERROR, err == LOCAL_GL_INVALID_ENUM);
617 return err == LOCAL_GL_NO_ERROR;
620 void DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity,
621 GLsizei length, const GLchar* message);
623 private:
624 static void GLAPIENTRY StaticDebugCallback(GLenum source, GLenum type,
625 GLuint id, GLenum severity,
626 GLsizei length,
627 const GLchar* message,
628 const GLvoid* userParam);
630 // -----------------------------------------------------------------------------
631 // MOZ_GL_DEBUG implementation
632 private:
633 #ifndef MOZ_FUNCTION_NAME
634 # ifdef __GNUC__
635 # define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__
636 # elif defined(_MSC_VER)
637 # define MOZ_FUNCTION_NAME __FUNCTION__
638 # else
639 # define MOZ_FUNCTION_NAME \
640 __func__ // defined in C99, supported in various C++ compilers. Just raw
641 // function name.
642 # endif
643 #endif
645 #ifdef MOZ_WIDGET_ANDROID
646 // Record the name of the GL call for better hang stacks on Android.
647 # define ANDROID_ONLY_PROFILER_LABEL AUTO_PROFILER_LABEL(__func__, GRAPHICS);
648 #else
649 # define ANDROID_ONLY_PROFILER_LABEL
650 #endif
652 #define BEFORE_GL_CALL \
653 ANDROID_ONLY_PROFILER_LABEL \
654 if (MOZ_LIKELY(BeforeGLCall(MOZ_FUNCTION_NAME))) { \
655 do { \
656 } while (0)
658 #define AFTER_GL_CALL \
659 AfterGLCall(MOZ_FUNCTION_NAME); \
661 do { \
662 } while (0)
664 void BeforeGLCall_Debug(const char* funcName) const;
665 void AfterGLCall_Debug(const char* funcName) const;
666 static void OnImplicitMakeCurrentFailure(const char* funcName);
668 bool BeforeGLCall(const char* const funcName) const {
669 if (mImplicitMakeCurrent) {
670 if (MOZ_UNLIKELY(!MakeCurrent())) {
671 if (!mContextLost) {
672 OnImplicitMakeCurrentFailure(funcName);
674 return false;
677 MOZ_GL_ASSERT(this, IsCurrentImpl());
679 if (MOZ_UNLIKELY(mDebugFlags)) {
680 BeforeGLCall_Debug(funcName);
682 return true;
685 void AfterGLCall(const char* const funcName) const {
686 if (MOZ_UNLIKELY(mDebugFlags)) {
687 AfterGLCall_Debug(funcName);
691 GLContext* TrackingContext() {
692 GLContext* tip = this;
693 while (tip->mSharedContext) tip = tip->mSharedContext;
694 return tip;
697 static void AssertNotPassingStackBufferToTheGL(const void* ptr);
699 #ifdef MOZ_GL_DEBUG
701 # define TRACKING_CONTEXT(a) \
702 do { \
703 TrackingContext()->a; \
704 } while (0)
706 # define ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(ptr) \
707 AssertNotPassingStackBufferToTheGL(ptr)
709 # define ASSERT_SYMBOL_PRESENT(func) \
710 do { \
711 MOZ_ASSERT(strstr(MOZ_FUNCTION_NAME, #func) != nullptr, \
712 "Mismatched symbol check."); \
713 if (MOZ_UNLIKELY(!mSymbols.func)) { \
714 printf_stderr("RUNTIME ASSERT: Uninitialized GL function: %s\n", \
715 #func); \
716 MOZ_CRASH("GFX: Uninitialized GL function"); \
718 } while (0)
720 #else // ifdef MOZ_GL_DEBUG
722 # define TRACKING_CONTEXT(a) \
723 do { \
724 } while (0)
725 # define ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(ptr) \
726 do { \
727 } while (0)
728 # define ASSERT_SYMBOL_PRESENT(func) \
729 do { \
730 } while (0)
732 #endif // ifdef MOZ_GL_DEBUG
734 // Do whatever setup is necessary to draw to our offscreen FBO, if it's
735 // bound.
736 void BeforeGLDrawCall() {}
738 // Do whatever tear-down is necessary after drawing to our offscreen FBO,
739 // if it's bound.
740 void AfterGLDrawCall() { mHeavyGLCallsSinceLastFlush = true; }
742 // Do whatever setup is necessary to read from our offscreen FBO, if it's
743 // bound.
744 void BeforeGLReadCall() {}
746 // Do whatever tear-down is necessary after reading from our offscreen FBO,
747 // if it's bound.
748 void AfterGLReadCall() {}
750 public:
751 void OnSyncCall() const { mSyncGLCallCount++; }
753 uint64_t GetSyncCallCount() const { return mSyncGLCallCount; }
755 void ResetSyncCallCount(const char* resetReason) const;
757 // -----------------------------------------------------------------------------
758 // GL official entry points
759 public:
760 // We smash all errors together, so you never have to loop on this. We
761 // guarantee that immediately after this call, there are no errors left.
762 // Always returns the top-most error, except if followed by CONTEXT_LOST, then
763 // return that instead.
764 GLenum GetError() const;
766 GLenum fGetError() { return GetError(); }
768 GLenum fGetGraphicsResetStatus() const;
770 // -
772 void fActiveTexture(GLenum texture) {
773 BEFORE_GL_CALL;
774 mSymbols.fActiveTexture(texture);
775 AFTER_GL_CALL;
778 void fAttachShader(GLuint program, GLuint shader) {
779 BEFORE_GL_CALL;
780 mSymbols.fAttachShader(program, shader);
781 AFTER_GL_CALL;
784 void fBeginQuery(GLenum target, GLuint id) {
785 BEFORE_GL_CALL;
786 ASSERT_SYMBOL_PRESENT(fBeginQuery);
787 mSymbols.fBeginQuery(target, id);
788 AFTER_GL_CALL;
791 void fBindAttribLocation(GLuint program, GLuint index, const GLchar* name) {
792 BEFORE_GL_CALL;
793 mSymbols.fBindAttribLocation(program, index, name);
794 AFTER_GL_CALL;
797 void fBindBuffer(GLenum target, GLuint buffer) {
798 BEFORE_GL_CALL;
799 mSymbols.fBindBuffer(target, buffer);
800 AFTER_GL_CALL;
803 void fInvalidateFramebuffer(GLenum target, GLsizei numAttachments,
804 const GLenum* attachments) {
805 BeforeGLDrawCall();
806 BEFORE_GL_CALL;
807 ASSERT_SYMBOL_PRESENT(fInvalidateFramebuffer);
808 mSymbols.fInvalidateFramebuffer(target, numAttachments, attachments);
809 AFTER_GL_CALL;
810 AfterGLDrawCall();
813 void fInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
814 const GLenum* attachments, GLint x, GLint y,
815 GLsizei width, GLsizei height) {
816 BeforeGLDrawCall();
817 BEFORE_GL_CALL;
818 ASSERT_SYMBOL_PRESENT(fInvalidateSubFramebuffer);
819 mSymbols.fInvalidateSubFramebuffer(target, numAttachments, attachments, x,
820 y, width, height);
821 AFTER_GL_CALL;
822 AfterGLDrawCall();
825 void fBindTexture(GLenum target, GLuint texture) {
826 BEFORE_GL_CALL;
827 mSymbols.fBindTexture(target, texture);
828 AFTER_GL_CALL;
831 void fBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
832 BEFORE_GL_CALL;
833 mSymbols.fBlendColor(red, green, blue, alpha);
834 AFTER_GL_CALL;
837 void fBlendEquation(GLenum mode) {
838 BEFORE_GL_CALL;
839 mSymbols.fBlendEquation(mode);
840 AFTER_GL_CALL;
843 void fBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
844 BEFORE_GL_CALL;
845 mSymbols.fBlendEquationSeparate(modeRGB, modeAlpha);
846 AFTER_GL_CALL;
849 void fBlendFunc(GLenum sfactor, GLenum dfactor) {
850 BEFORE_GL_CALL;
851 mSymbols.fBlendFunc(sfactor, dfactor);
852 AFTER_GL_CALL;
855 void fBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB,
856 GLenum sfactorAlpha, GLenum dfactorAlpha) {
857 BEFORE_GL_CALL;
858 mSymbols.fBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha,
859 dfactorAlpha);
860 AFTER_GL_CALL;
863 private:
864 void raw_fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data,
865 GLenum usage) {
866 ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(data);
867 BEFORE_GL_CALL;
868 mSymbols.fBufferData(target, size, data, usage);
869 OnSyncCall();
870 AFTER_GL_CALL;
871 mHeavyGLCallsSinceLastFlush = true;
874 public:
875 void fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data,
876 GLenum usage) {
877 raw_fBufferData(target, size, data, usage);
879 // bug 744888
880 if (WorkAroundDriverBugs() && !data && Vendor() == GLVendor::NVIDIA) {
881 UniquePtr<char[]> buf = MakeUnique<char[]>(1);
882 buf[0] = 0;
883 fBufferSubData(target, size - 1, 1, buf.get());
887 void fBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
888 const GLvoid* data) {
889 ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(data);
890 BEFORE_GL_CALL;
891 mSymbols.fBufferSubData(target, offset, size, data);
892 AFTER_GL_CALL;
893 mHeavyGLCallsSinceLastFlush = true;
896 private:
897 void raw_fClear(GLbitfield mask) {
898 BEFORE_GL_CALL;
899 mSymbols.fClear(mask);
900 AFTER_GL_CALL;
903 public:
904 void fClear(GLbitfield mask) {
905 BeforeGLDrawCall();
906 raw_fClear(mask);
907 AfterGLDrawCall();
910 void fClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth,
911 GLint stencil) {
912 BeforeGLDrawCall();
913 BEFORE_GL_CALL;
914 mSymbols.fClearBufferfi(buffer, drawbuffer, depth, stencil);
915 AFTER_GL_CALL;
916 AfterGLDrawCall();
919 void fClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) {
920 BeforeGLDrawCall();
921 BEFORE_GL_CALL;
922 mSymbols.fClearBufferfv(buffer, drawbuffer, value);
923 AFTER_GL_CALL;
924 AfterGLDrawCall();
927 void fClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) {
928 BeforeGLDrawCall();
929 BEFORE_GL_CALL;
930 mSymbols.fClearBufferiv(buffer, drawbuffer, value);
931 AFTER_GL_CALL;
932 AfterGLDrawCall();
935 void fClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) {
936 BeforeGLDrawCall();
937 BEFORE_GL_CALL;
938 mSymbols.fClearBufferuiv(buffer, drawbuffer, value);
939 AFTER_GL_CALL;
940 AfterGLDrawCall();
943 void fClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
944 BEFORE_GL_CALL;
945 mSymbols.fClearColor(r, g, b, a);
946 AFTER_GL_CALL;
949 void fClearStencil(GLint s) {
950 BEFORE_GL_CALL;
951 mSymbols.fClearStencil(s);
952 AFTER_GL_CALL;
955 void fClientActiveTexture(GLenum texture) {
956 BEFORE_GL_CALL;
957 mSymbols.fClientActiveTexture(texture);
958 AFTER_GL_CALL;
961 void fColorMask(realGLboolean red, realGLboolean green, realGLboolean blue,
962 realGLboolean alpha) {
963 BEFORE_GL_CALL;
964 mSymbols.fColorMask(red, green, blue, alpha);
965 AFTER_GL_CALL;
968 void fCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
969 GLsizei width, GLsizei height, GLint border,
970 GLsizei imageSize, const GLvoid* pixels) {
971 ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pixels);
972 BEFORE_GL_CALL;
973 mSymbols.fCompressedTexImage2D(target, level, internalformat, width, height,
974 border, imageSize, pixels);
975 AFTER_GL_CALL;
976 mHeavyGLCallsSinceLastFlush = true;
979 void fCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
980 GLint yoffset, GLsizei width, GLsizei height,
981 GLenum format, GLsizei imageSize,
982 const GLvoid* pixels) {
983 ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pixels);
984 BEFORE_GL_CALL;
985 mSymbols.fCompressedTexSubImage2D(target, level, xoffset, yoffset, width,
986 height, format, imageSize, pixels);
987 AFTER_GL_CALL;
988 mHeavyGLCallsSinceLastFlush = true;
991 void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat,
992 GLint x, GLint y, GLsizei width, GLsizei height,
993 GLint border);
995 void fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset,
996 GLint yoffset, GLint x, GLint y, GLsizei width,
997 GLsizei height) {
998 BeforeGLReadCall();
999 raw_fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width,
1000 height);
1001 AfterGLReadCall();
1004 void fCullFace(GLenum mode) {
1005 BEFORE_GL_CALL;
1006 mSymbols.fCullFace(mode);
1007 AFTER_GL_CALL;
1010 void fDebugMessageCallback(GLDEBUGPROC callback, const GLvoid* userParam) {
1011 BEFORE_GL_CALL;
1012 ASSERT_SYMBOL_PRESENT(fDebugMessageCallback);
1013 mSymbols.fDebugMessageCallback(callback, userParam);
1014 AFTER_GL_CALL;
1017 void fDebugMessageControl(GLenum source, GLenum type, GLenum severity,
1018 GLsizei count, const GLuint* ids,
1019 realGLboolean enabled) {
1020 BEFORE_GL_CALL;
1021 ASSERT_SYMBOL_PRESENT(fDebugMessageControl);
1022 mSymbols.fDebugMessageControl(source, type, severity, count, ids, enabled);
1023 AFTER_GL_CALL;
1026 void fDebugMessageInsert(GLenum source, GLenum type, GLuint id,
1027 GLenum severity, GLsizei length, const GLchar* buf) {
1028 BEFORE_GL_CALL;
1029 ASSERT_SYMBOL_PRESENT(fDebugMessageInsert);
1030 mSymbols.fDebugMessageInsert(source, type, id, severity, length, buf);
1031 AFTER_GL_CALL;
1034 void fDetachShader(GLuint program, GLuint shader) {
1035 BEFORE_GL_CALL;
1036 mSymbols.fDetachShader(program, shader);
1037 AFTER_GL_CALL;
1040 void fDepthFunc(GLenum func) {
1041 BEFORE_GL_CALL;
1042 mSymbols.fDepthFunc(func);
1043 AFTER_GL_CALL;
1046 void fDepthMask(realGLboolean flag) {
1047 BEFORE_GL_CALL;
1048 mSymbols.fDepthMask(flag);
1049 AFTER_GL_CALL;
1052 void fDisable(GLenum capability) {
1053 BEFORE_GL_CALL;
1054 mSymbols.fDisable(capability);
1055 AFTER_GL_CALL;
1058 void fDisableClientState(GLenum capability) {
1059 BEFORE_GL_CALL;
1060 mSymbols.fDisableClientState(capability);
1061 AFTER_GL_CALL;
1064 void fDisableVertexAttribArray(GLuint index) {
1065 BEFORE_GL_CALL;
1066 mSymbols.fDisableVertexAttribArray(index);
1067 AFTER_GL_CALL;
1070 void fDrawBuffer(GLenum mode) {
1071 BEFORE_GL_CALL;
1072 mSymbols.fDrawBuffer(mode);
1073 AFTER_GL_CALL;
1076 private:
1077 void raw_fDrawArrays(GLenum mode, GLint first, GLsizei count) {
1078 BEFORE_GL_CALL;
1079 mSymbols.fDrawArrays(mode, first, count);
1080 AFTER_GL_CALL;
1083 void raw_fDrawElements(GLenum mode, GLsizei count, GLenum type,
1084 const GLvoid* indices) {
1085 BEFORE_GL_CALL;
1086 mSymbols.fDrawElements(mode, count, type, indices);
1087 AFTER_GL_CALL;
1090 public:
1091 void fDrawArrays(GLenum mode, GLint first, GLsizei count) {
1092 BeforeGLDrawCall();
1093 raw_fDrawArrays(mode, first, count);
1094 AfterGLDrawCall();
1097 void fDrawElements(GLenum mode, GLsizei count, GLenum type,
1098 const GLvoid* indices) {
1099 BeforeGLDrawCall();
1100 raw_fDrawElements(mode, count, type, indices);
1101 AfterGLDrawCall();
1104 void fEnable(GLenum capability) {
1105 BEFORE_GL_CALL;
1106 mSymbols.fEnable(capability);
1107 AFTER_GL_CALL;
1110 void fEnableClientState(GLenum capability) {
1111 BEFORE_GL_CALL;
1112 mSymbols.fEnableClientState(capability);
1113 AFTER_GL_CALL;
1116 void fEnableVertexAttribArray(GLuint index) {
1117 BEFORE_GL_CALL;
1118 mSymbols.fEnableVertexAttribArray(index);
1119 AFTER_GL_CALL;
1122 void fEndQuery(GLenum target) {
1123 BEFORE_GL_CALL;
1124 ASSERT_SYMBOL_PRESENT(fEndQuery);
1125 mSymbols.fEndQuery(target);
1126 AFTER_GL_CALL;
1129 void fFinish() {
1130 BEFORE_GL_CALL;
1131 mSymbols.fFinish();
1132 OnSyncCall();
1133 AFTER_GL_CALL;
1134 mHeavyGLCallsSinceLastFlush = false;
1137 void fFlush() {
1138 BEFORE_GL_CALL;
1139 mSymbols.fFlush();
1140 AFTER_GL_CALL;
1141 mHeavyGLCallsSinceLastFlush = false;
1144 void fFrontFace(GLenum face) {
1145 BEFORE_GL_CALL;
1146 mSymbols.fFrontFace(face);
1147 AFTER_GL_CALL;
1150 void fGetActiveAttrib(GLuint program, GLuint index, GLsizei maxLength,
1151 GLsizei* length, GLint* size, GLenum* type,
1152 GLchar* name) {
1153 BEFORE_GL_CALL;
1154 mSymbols.fGetActiveAttrib(program, index, maxLength, length, size, type,
1155 name);
1156 OnSyncCall();
1157 AFTER_GL_CALL;
1160 void fGetActiveUniform(GLuint program, GLuint index, GLsizei maxLength,
1161 GLsizei* length, GLint* size, GLenum* type,
1162 GLchar* name) {
1163 BEFORE_GL_CALL;
1164 mSymbols.fGetActiveUniform(program, index, maxLength, length, size, type,
1165 name);
1166 OnSyncCall();
1167 AFTER_GL_CALL;
1170 void fGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count,
1171 GLuint* shaders) {
1172 BEFORE_GL_CALL;
1173 mSymbols.fGetAttachedShaders(program, maxCount, count, shaders);
1174 OnSyncCall();
1175 AFTER_GL_CALL;
1178 GLint fGetAttribLocation(GLuint program, const GLchar* name) {
1179 GLint retval = 0;
1180 BEFORE_GL_CALL;
1181 retval = mSymbols.fGetAttribLocation(program, name);
1182 OnSyncCall();
1183 AFTER_GL_CALL;
1184 return retval;
1187 private:
1188 void raw_fGetIntegerv(GLenum pname, GLint* params) const {
1189 BEFORE_GL_CALL;
1190 mSymbols.fGetIntegerv(pname, params);
1191 OnSyncCall();
1192 AFTER_GL_CALL;
1195 public:
1196 void fGetIntegerv(GLenum pname, GLint* params) const;
1198 template <typename T>
1199 void GetInt(const GLenum pname, T* const params) const {
1200 static_assert(sizeof(T) == sizeof(GLint), "Invalid T.");
1201 fGetIntegerv(pname, reinterpret_cast<GLint*>(params));
1204 void GetUIntegerv(GLenum pname, GLuint* params) const {
1205 GetInt(pname, params);
1208 template <typename T>
1209 T GetIntAs(GLenum pname) const {
1210 static_assert(sizeof(T) == sizeof(GLint), "Invalid T.");
1211 T ret = 0;
1212 fGetIntegerv(pname, (GLint*)&ret);
1213 return ret;
1216 void fGetFloatv(GLenum pname, GLfloat* params) const {
1217 BEFORE_GL_CALL;
1218 mSymbols.fGetFloatv(pname, params);
1219 OnSyncCall();
1220 AFTER_GL_CALL;
1223 void fGetBooleanv(GLenum pname, realGLboolean* params) const {
1224 BEFORE_GL_CALL;
1225 mSymbols.fGetBooleanv(pname, params);
1226 OnSyncCall();
1227 AFTER_GL_CALL;
1230 void fGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
1231 BEFORE_GL_CALL;
1232 mSymbols.fGetBufferParameteriv(target, pname, params);
1233 OnSyncCall();
1234 AFTER_GL_CALL;
1237 GLuint fGetDebugMessageLog(GLuint count, GLsizei bufsize, GLenum* sources,
1238 GLenum* types, GLuint* ids, GLenum* severities,
1239 GLsizei* lengths, GLchar* messageLog) {
1240 GLuint ret = 0;
1241 BEFORE_GL_CALL;
1242 ASSERT_SYMBOL_PRESENT(fGetDebugMessageLog);
1243 ret = mSymbols.fGetDebugMessageLog(count, bufsize, sources, types, ids,
1244 severities, lengths, messageLog);
1245 OnSyncCall();
1246 AFTER_GL_CALL;
1247 return ret;
1250 void fGetPointerv(GLenum pname, GLvoid** params) {
1251 BEFORE_GL_CALL;
1252 ASSERT_SYMBOL_PRESENT(fGetPointerv);
1253 mSymbols.fGetPointerv(pname, params);
1254 OnSyncCall();
1255 AFTER_GL_CALL;
1258 void fGetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize,
1259 GLsizei* length, GLchar* label) {
1260 BEFORE_GL_CALL;
1261 ASSERT_SYMBOL_PRESENT(fGetObjectLabel);
1262 mSymbols.fGetObjectLabel(identifier, name, bufSize, length, label);
1263 OnSyncCall();
1264 AFTER_GL_CALL;
1267 void fGetObjectPtrLabel(const GLvoid* ptr, GLsizei bufSize, GLsizei* length,
1268 GLchar* label) {
1269 BEFORE_GL_CALL;
1270 ASSERT_SYMBOL_PRESENT(fGetObjectPtrLabel);
1271 mSymbols.fGetObjectPtrLabel(ptr, bufSize, length, label);
1272 OnSyncCall();
1273 AFTER_GL_CALL;
1276 void fGenerateMipmap(GLenum target) {
1277 BEFORE_GL_CALL;
1278 mSymbols.fGenerateMipmap(target);
1279 AFTER_GL_CALL;
1282 void fGetProgramiv(GLuint program, GLenum pname, GLint* param) {
1283 BEFORE_GL_CALL;
1284 mSymbols.fGetProgramiv(program, pname, param);
1285 OnSyncCall();
1286 AFTER_GL_CALL;
1289 void fGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length,
1290 GLchar* infoLog) {
1291 BEFORE_GL_CALL;
1292 mSymbols.fGetProgramInfoLog(program, bufSize, length, infoLog);
1293 OnSyncCall();
1294 AFTER_GL_CALL;
1297 void fTexParameteri(GLenum target, GLenum pname, GLint param) {
1298 BEFORE_GL_CALL;
1299 mSymbols.fTexParameteri(target, pname, param);
1300 AFTER_GL_CALL;
1303 void fTexParameteriv(GLenum target, GLenum pname, const GLint* params) {
1304 BEFORE_GL_CALL;
1305 mSymbols.fTexParameteriv(target, pname, params);
1306 AFTER_GL_CALL;
1309 void fTexParameterf(GLenum target, GLenum pname, GLfloat param) {
1310 BEFORE_GL_CALL;
1311 mSymbols.fTexParameterf(target, pname, param);
1312 AFTER_GL_CALL;
1315 const GLubyte* fGetString(GLenum name) {
1316 const GLubyte* result = nullptr;
1317 BEFORE_GL_CALL;
1318 result = mSymbols.fGetString(name);
1319 OnSyncCall();
1320 AFTER_GL_CALL;
1321 return result;
1324 void fGetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
1325 GLvoid* img) {
1326 BEFORE_GL_CALL;
1327 ASSERT_SYMBOL_PRESENT(fGetTexImage);
1328 mSymbols.fGetTexImage(target, level, format, type, img);
1329 OnSyncCall();
1330 AFTER_GL_CALL;
1333 void fGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname,
1334 GLint* params) {
1335 BEFORE_GL_CALL;
1336 ASSERT_SYMBOL_PRESENT(fGetTexLevelParameteriv);
1337 mSymbols.fGetTexLevelParameteriv(target, level, pname, params);
1338 OnSyncCall();
1339 AFTER_GL_CALL;
1342 void fGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) {
1343 BEFORE_GL_CALL;
1344 mSymbols.fGetTexParameterfv(target, pname, params);
1345 OnSyncCall();
1346 AFTER_GL_CALL;
1349 void fGetTexParameteriv(GLenum target, GLenum pname, GLint* params) {
1350 BEFORE_GL_CALL;
1351 mSymbols.fGetTexParameteriv(target, pname, params);
1352 OnSyncCall();
1353 AFTER_GL_CALL;
1356 void fGetUniformfv(GLuint program, GLint location, GLfloat* params) {
1357 BEFORE_GL_CALL;
1358 mSymbols.fGetUniformfv(program, location, params);
1359 OnSyncCall();
1360 AFTER_GL_CALL;
1363 void fGetUniformiv(GLuint program, GLint location, GLint* params) {
1364 BEFORE_GL_CALL;
1365 mSymbols.fGetUniformiv(program, location, params);
1366 OnSyncCall();
1367 AFTER_GL_CALL;
1370 void fGetUniformuiv(GLuint program, GLint location, GLuint* params) {
1371 BEFORE_GL_CALL;
1372 ASSERT_SYMBOL_PRESENT(fGetUniformuiv);
1373 mSymbols.fGetUniformuiv(program, location, params);
1374 OnSyncCall();
1375 AFTER_GL_CALL;
1378 GLint fGetUniformLocation(GLuint programObj, const GLchar* name) {
1379 GLint retval = 0;
1380 BEFORE_GL_CALL;
1381 retval = mSymbols.fGetUniformLocation(programObj, name);
1382 OnSyncCall();
1383 AFTER_GL_CALL;
1384 return retval;
1387 void fGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* retval) {
1388 BEFORE_GL_CALL;
1389 mSymbols.fGetVertexAttribfv(index, pname, retval);
1390 OnSyncCall();
1391 AFTER_GL_CALL;
1394 void fGetVertexAttribiv(GLuint index, GLenum pname, GLint* retval) {
1395 BEFORE_GL_CALL;
1396 mSymbols.fGetVertexAttribiv(index, pname, retval);
1397 OnSyncCall();
1398 AFTER_GL_CALL;
1401 void fGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** retval) {
1402 BEFORE_GL_CALL;
1403 mSymbols.fGetVertexAttribPointerv(index, pname, retval);
1404 OnSyncCall();
1405 AFTER_GL_CALL;
1408 void fHint(GLenum target, GLenum mode) {
1409 BEFORE_GL_CALL;
1410 mSymbols.fHint(target, mode);
1411 AFTER_GL_CALL;
1414 realGLboolean fIsBuffer(GLuint buffer) {
1415 realGLboolean retval = false;
1416 BEFORE_GL_CALL;
1417 retval = mSymbols.fIsBuffer(buffer);
1418 OnSyncCall();
1419 AFTER_GL_CALL;
1420 return retval;
1423 realGLboolean fIsEnabled(GLenum capability) {
1424 realGLboolean retval = false;
1425 BEFORE_GL_CALL;
1426 retval = mSymbols.fIsEnabled(capability);
1427 AFTER_GL_CALL;
1428 return retval;
1431 void SetEnabled(const GLenum cap, const bool val) {
1432 if (val) {
1433 fEnable(cap);
1434 } else {
1435 fDisable(cap);
1439 bool PushEnabled(const GLenum cap, const bool newVal) {
1440 const bool oldVal = fIsEnabled(cap);
1441 if (oldVal != newVal) {
1442 SetEnabled(cap, newVal);
1444 return oldVal;
1447 realGLboolean fIsProgram(GLuint program) {
1448 realGLboolean retval = false;
1449 BEFORE_GL_CALL;
1450 retval = mSymbols.fIsProgram(program);
1451 AFTER_GL_CALL;
1452 return retval;
1455 realGLboolean fIsShader(GLuint shader) {
1456 realGLboolean retval = false;
1457 BEFORE_GL_CALL;
1458 retval = mSymbols.fIsShader(shader);
1459 AFTER_GL_CALL;
1460 return retval;
1463 realGLboolean fIsTexture(GLuint texture) {
1464 realGLboolean retval = false;
1465 BEFORE_GL_CALL;
1466 retval = mSymbols.fIsTexture(texture);
1467 AFTER_GL_CALL;
1468 return retval;
1471 void fLineWidth(GLfloat width) {
1472 BEFORE_GL_CALL;
1473 mSymbols.fLineWidth(width);
1474 AFTER_GL_CALL;
1477 void fLinkProgram(GLuint program) {
1478 BEFORE_GL_CALL;
1479 mSymbols.fLinkProgram(program);
1480 AFTER_GL_CALL;
1483 void fObjectLabel(GLenum identifier, GLuint name, GLsizei length,
1484 const GLchar* label) {
1485 BEFORE_GL_CALL;
1486 ASSERT_SYMBOL_PRESENT(fObjectLabel);
1487 mSymbols.fObjectLabel(identifier, name, length, label);
1488 AFTER_GL_CALL;
1491 void fObjectPtrLabel(const GLvoid* ptr, GLsizei length, const GLchar* label) {
1492 BEFORE_GL_CALL;
1493 ASSERT_SYMBOL_PRESENT(fObjectPtrLabel);
1494 mSymbols.fObjectPtrLabel(ptr, length, label);
1495 AFTER_GL_CALL;
1498 void fLoadIdentity() {
1499 BEFORE_GL_CALL;
1500 mSymbols.fLoadIdentity();
1501 AFTER_GL_CALL;
1504 void fLoadMatrixf(const GLfloat* matrix) {
1505 BEFORE_GL_CALL;
1506 mSymbols.fLoadMatrixf(matrix);
1507 AFTER_GL_CALL;
1510 void fMatrixMode(GLenum mode) {
1511 BEFORE_GL_CALL;
1512 mSymbols.fMatrixMode(mode);
1513 AFTER_GL_CALL;
1516 void fPixelStorei(GLenum pname, GLint param) {
1517 BEFORE_GL_CALL;
1518 mSymbols.fPixelStorei(pname, param);
1519 AFTER_GL_CALL;
1522 void fTextureRangeAPPLE(GLenum target, GLsizei length, GLvoid* pointer) {
1523 ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pointer);
1524 BEFORE_GL_CALL;
1525 mSymbols.fTextureRangeAPPLE(target, length, pointer);
1526 AFTER_GL_CALL;
1529 void fPointParameterf(GLenum pname, GLfloat param) {
1530 BEFORE_GL_CALL;
1531 mSymbols.fPointParameterf(pname, param);
1532 AFTER_GL_CALL;
1535 void fPolygonMode(GLenum face, GLenum mode) {
1536 BEFORE_GL_CALL;
1537 mSymbols.fPolygonMode(face, mode);
1538 AFTER_GL_CALL;
1541 void fPolygonOffset(GLfloat factor, GLfloat bias) {
1542 BEFORE_GL_CALL;
1543 mSymbols.fPolygonOffset(factor, bias);
1544 AFTER_GL_CALL;
1547 void fPopDebugGroup() {
1548 BEFORE_GL_CALL;
1549 ASSERT_SYMBOL_PRESENT(fPopDebugGroup);
1550 mSymbols.fPopDebugGroup();
1551 AFTER_GL_CALL;
1554 void fPushDebugGroup(GLenum source, GLuint id, GLsizei length,
1555 const GLchar* message) {
1556 BEFORE_GL_CALL;
1557 ASSERT_SYMBOL_PRESENT(fPushDebugGroup);
1558 mSymbols.fPushDebugGroup(source, id, length, message);
1559 AFTER_GL_CALL;
1562 void fReadBuffer(GLenum mode) {
1563 BEFORE_GL_CALL;
1564 mSymbols.fReadBuffer(mode);
1565 AFTER_GL_CALL;
1568 void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
1569 GLenum format, GLenum type, GLvoid* pixels) {
1570 BEFORE_GL_CALL;
1571 mSymbols.fReadPixels(x, y, width, height, format, type, pixels);
1572 OnSyncCall();
1573 AFTER_GL_CALL;
1574 mHeavyGLCallsSinceLastFlush = true;
1577 void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
1578 GLenum format, GLenum type, GLvoid* pixels);
1580 public:
1581 void fSampleCoverage(GLclampf value, realGLboolean invert) {
1582 BEFORE_GL_CALL;
1583 mSymbols.fSampleCoverage(value, invert);
1584 AFTER_GL_CALL;
1587 void fScissor(GLint x, GLint y, GLsizei width, GLsizei height) {
1588 if (mScissorRect[0] == x && mScissorRect[1] == y &&
1589 mScissorRect[2] == width && mScissorRect[3] == height) {
1590 return;
1592 mScissorRect[0] = x;
1593 mScissorRect[1] = y;
1594 mScissorRect[2] = width;
1595 mScissorRect[3] = height;
1596 BEFORE_GL_CALL;
1597 mSymbols.fScissor(x, y, width, height);
1598 AFTER_GL_CALL;
1601 void fStencilFunc(GLenum func, GLint reference, GLuint mask) {
1602 BEFORE_GL_CALL;
1603 mSymbols.fStencilFunc(func, reference, mask);
1604 AFTER_GL_CALL;
1607 void fStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint reference,
1608 GLuint mask) {
1609 BEFORE_GL_CALL;
1610 mSymbols.fStencilFuncSeparate(frontfunc, backfunc, reference, mask);
1611 AFTER_GL_CALL;
1614 void fStencilMask(GLuint mask) {
1615 BEFORE_GL_CALL;
1616 mSymbols.fStencilMask(mask);
1617 AFTER_GL_CALL;
1620 void fStencilMaskSeparate(GLenum face, GLuint mask) {
1621 BEFORE_GL_CALL;
1622 mSymbols.fStencilMaskSeparate(face, mask);
1623 AFTER_GL_CALL;
1626 void fStencilOp(GLenum fail, GLenum zfail, GLenum zpass) {
1627 BEFORE_GL_CALL;
1628 mSymbols.fStencilOp(fail, zfail, zpass);
1629 AFTER_GL_CALL;
1632 void fStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail,
1633 GLenum dppass) {
1634 BEFORE_GL_CALL;
1635 mSymbols.fStencilOpSeparate(face, sfail, dpfail, dppass);
1636 AFTER_GL_CALL;
1639 void fTexGeni(GLenum coord, GLenum pname, GLint param) {
1640 BEFORE_GL_CALL;
1641 mSymbols.fTexGeni(coord, pname, param);
1642 AFTER_GL_CALL;
1645 void fTexGenf(GLenum coord, GLenum pname, GLfloat param) {
1646 BEFORE_GL_CALL;
1647 mSymbols.fTexGenf(coord, pname, param);
1648 AFTER_GL_CALL;
1651 void fTexGenfv(GLenum coord, GLenum pname, const GLfloat* params) {
1652 BEFORE_GL_CALL;
1653 mSymbols.fTexGenfv(coord, pname, params);
1654 AFTER_GL_CALL;
1657 private:
1658 void raw_fTexImage2D(GLenum target, GLint level, GLint internalformat,
1659 GLsizei width, GLsizei height, GLint border,
1660 GLenum format, GLenum type, const GLvoid* pixels) {
1661 ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pixels);
1662 BEFORE_GL_CALL;
1663 mSymbols.fTexImage2D(target, level, internalformat, width, height, border,
1664 format, type, pixels);
1665 AFTER_GL_CALL;
1666 mHeavyGLCallsSinceLastFlush = true;
1669 public:
1670 void fTexImage2D(GLenum target, GLint level, GLint internalformat,
1671 GLsizei width, GLsizei height, GLint border, GLenum format,
1672 GLenum type, const GLvoid* pixels);
1674 void fTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
1675 GLsizei width, GLsizei height, GLenum format, GLenum type,
1676 const GLvoid* pixels) {
1677 ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pixels);
1678 BEFORE_GL_CALL;
1679 mSymbols.fTexSubImage2D(target, level, xoffset, yoffset, width, height,
1680 format, type, pixels);
1681 AFTER_GL_CALL;
1682 mHeavyGLCallsSinceLastFlush = true;
1685 void fUniform1f(GLint location, GLfloat v0) {
1686 BEFORE_GL_CALL;
1687 mSymbols.fUniform1f(location, v0);
1688 AFTER_GL_CALL;
1691 void fUniform1fv(GLint location, GLsizei count, const GLfloat* value) {
1692 BEFORE_GL_CALL;
1693 mSymbols.fUniform1fv(location, count, value);
1694 AFTER_GL_CALL;
1697 void fUniform1i(GLint location, GLint v0) {
1698 BEFORE_GL_CALL;
1699 mSymbols.fUniform1i(location, v0);
1700 AFTER_GL_CALL;
1703 void fUniform1iv(GLint location, GLsizei count, const GLint* value) {
1704 BEFORE_GL_CALL;
1705 mSymbols.fUniform1iv(location, count, value);
1706 AFTER_GL_CALL;
1709 void fUniform2f(GLint location, GLfloat v0, GLfloat v1) {
1710 BEFORE_GL_CALL;
1711 mSymbols.fUniform2f(location, v0, v1);
1712 AFTER_GL_CALL;
1715 void fUniform2fv(GLint location, GLsizei count, const GLfloat* value) {
1716 BEFORE_GL_CALL;
1717 mSymbols.fUniform2fv(location, count, value);
1718 AFTER_GL_CALL;
1721 void fUniform2i(GLint location, GLint v0, GLint v1) {
1722 BEFORE_GL_CALL;
1723 mSymbols.fUniform2i(location, v0, v1);
1724 AFTER_GL_CALL;
1727 void fUniform2iv(GLint location, GLsizei count, const GLint* value) {
1728 BEFORE_GL_CALL;
1729 mSymbols.fUniform2iv(location, count, value);
1730 AFTER_GL_CALL;
1733 void fUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
1734 BEFORE_GL_CALL;
1735 mSymbols.fUniform3f(location, v0, v1, v2);
1736 AFTER_GL_CALL;
1739 void fUniform3fv(GLint location, GLsizei count, const GLfloat* value) {
1740 BEFORE_GL_CALL;
1741 mSymbols.fUniform3fv(location, count, value);
1742 AFTER_GL_CALL;
1745 void fUniform3i(GLint location, GLint v0, GLint v1, GLint v2) {
1746 BEFORE_GL_CALL;
1747 mSymbols.fUniform3i(location, v0, v1, v2);
1748 AFTER_GL_CALL;
1751 void fUniform3iv(GLint location, GLsizei count, const GLint* value) {
1752 BEFORE_GL_CALL;
1753 mSymbols.fUniform3iv(location, count, value);
1754 AFTER_GL_CALL;
1757 void fUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2,
1758 GLfloat v3) {
1759 BEFORE_GL_CALL;
1760 mSymbols.fUniform4f(location, v0, v1, v2, v3);
1761 AFTER_GL_CALL;
1764 void fUniform4fv(GLint location, GLsizei count, const GLfloat* value) {
1765 BEFORE_GL_CALL;
1766 mSymbols.fUniform4fv(location, count, value);
1767 AFTER_GL_CALL;
1770 void fUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
1771 BEFORE_GL_CALL;
1772 mSymbols.fUniform4i(location, v0, v1, v2, v3);
1773 AFTER_GL_CALL;
1776 void fUniform4iv(GLint location, GLsizei count, const GLint* value) {
1777 BEFORE_GL_CALL;
1778 mSymbols.fUniform4iv(location, count, value);
1779 AFTER_GL_CALL;
1782 void fUniformMatrix2fv(GLint location, GLsizei count, realGLboolean transpose,
1783 const GLfloat* value) {
1784 BEFORE_GL_CALL;
1785 mSymbols.fUniformMatrix2fv(location, count, transpose, value);
1786 AFTER_GL_CALL;
1789 void fUniformMatrix2x3fv(GLint location, GLsizei count,
1790 realGLboolean transpose, const GLfloat* value) {
1791 BEFORE_GL_CALL;
1792 ASSERT_SYMBOL_PRESENT(fUniformMatrix2x3fv);
1793 mSymbols.fUniformMatrix2x3fv(location, count, transpose, value);
1794 AFTER_GL_CALL;
1797 void fUniformMatrix2x4fv(GLint location, GLsizei count,
1798 realGLboolean transpose, const GLfloat* value) {
1799 BEFORE_GL_CALL;
1800 ASSERT_SYMBOL_PRESENT(fUniformMatrix2x4fv);
1801 mSymbols.fUniformMatrix2x4fv(location, count, transpose, value);
1802 AFTER_GL_CALL;
1805 void fUniformMatrix3fv(GLint location, GLsizei count, realGLboolean transpose,
1806 const GLfloat* value) {
1807 BEFORE_GL_CALL;
1808 mSymbols.fUniformMatrix3fv(location, count, transpose, value);
1809 AFTER_GL_CALL;
1812 void fUniformMatrix3x2fv(GLint location, GLsizei count,
1813 realGLboolean transpose, const GLfloat* value) {
1814 BEFORE_GL_CALL;
1815 ASSERT_SYMBOL_PRESENT(fUniformMatrix3x2fv);
1816 mSymbols.fUniformMatrix3x2fv(location, count, transpose, value);
1817 AFTER_GL_CALL;
1820 void fUniformMatrix3x4fv(GLint location, GLsizei count,
1821 realGLboolean transpose, const GLfloat* value) {
1822 BEFORE_GL_CALL;
1823 ASSERT_SYMBOL_PRESENT(fUniformMatrix3x4fv);
1824 mSymbols.fUniformMatrix3x4fv(location, count, transpose, value);
1825 AFTER_GL_CALL;
1828 void fUniformMatrix4fv(GLint location, GLsizei count, realGLboolean transpose,
1829 const GLfloat* value) {
1830 BEFORE_GL_CALL;
1831 mSymbols.fUniformMatrix4fv(location, count, transpose, value);
1832 AFTER_GL_CALL;
1835 void fUniformMatrix4x2fv(GLint location, GLsizei count,
1836 realGLboolean transpose, const GLfloat* value) {
1837 BEFORE_GL_CALL;
1838 ASSERT_SYMBOL_PRESENT(fUniformMatrix4x2fv);
1839 mSymbols.fUniformMatrix4x2fv(location, count, transpose, value);
1840 AFTER_GL_CALL;
1843 void fUniformMatrix4x3fv(GLint location, GLsizei count,
1844 realGLboolean transpose, const GLfloat* value) {
1845 BEFORE_GL_CALL;
1846 ASSERT_SYMBOL_PRESENT(fUniformMatrix4x3fv);
1847 mSymbols.fUniformMatrix4x3fv(location, count, transpose, value);
1848 AFTER_GL_CALL;
1851 void fUseProgram(GLuint program) {
1852 BEFORE_GL_CALL;
1853 mSymbols.fUseProgram(program);
1854 AFTER_GL_CALL;
1857 void fValidateProgram(GLuint program) {
1858 BEFORE_GL_CALL;
1859 mSymbols.fValidateProgram(program);
1860 AFTER_GL_CALL;
1863 void fVertexAttribPointer(GLuint index, GLint size, GLenum type,
1864 realGLboolean normalized, GLsizei stride,
1865 const GLvoid* pointer) {
1866 BEFORE_GL_CALL;
1867 mSymbols.fVertexAttribPointer(index, size, type, normalized, stride,
1868 pointer);
1869 AFTER_GL_CALL;
1872 void fVertexAttrib1f(GLuint index, GLfloat x) {
1873 BEFORE_GL_CALL;
1874 mSymbols.fVertexAttrib1f(index, x);
1875 AFTER_GL_CALL;
1878 void fVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) {
1879 BEFORE_GL_CALL;
1880 mSymbols.fVertexAttrib2f(index, x, y);
1881 AFTER_GL_CALL;
1884 void fVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) {
1885 BEFORE_GL_CALL;
1886 mSymbols.fVertexAttrib3f(index, x, y, z);
1887 AFTER_GL_CALL;
1890 void fVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z,
1891 GLfloat w) {
1892 BEFORE_GL_CALL;
1893 mSymbols.fVertexAttrib4f(index, x, y, z, w);
1894 AFTER_GL_CALL;
1897 void fVertexAttrib1fv(GLuint index, const GLfloat* v) {
1898 BEFORE_GL_CALL;
1899 mSymbols.fVertexAttrib1fv(index, v);
1900 AFTER_GL_CALL;
1903 void fVertexAttrib2fv(GLuint index, const GLfloat* v) {
1904 BEFORE_GL_CALL;
1905 mSymbols.fVertexAttrib2fv(index, v);
1906 AFTER_GL_CALL;
1909 void fVertexAttrib3fv(GLuint index, const GLfloat* v) {
1910 BEFORE_GL_CALL;
1911 mSymbols.fVertexAttrib3fv(index, v);
1912 AFTER_GL_CALL;
1915 void fVertexAttrib4fv(GLuint index, const GLfloat* v) {
1916 BEFORE_GL_CALL;
1917 mSymbols.fVertexAttrib4fv(index, v);
1918 AFTER_GL_CALL;
1921 void fVertexPointer(GLint size, GLenum type, GLsizei stride,
1922 const GLvoid* pointer) {
1923 BEFORE_GL_CALL;
1924 mSymbols.fVertexPointer(size, type, stride, pointer);
1925 AFTER_GL_CALL;
1928 void fViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
1929 if (mViewportRect[0] == x && mViewportRect[1] == y &&
1930 mViewportRect[2] == width && mViewportRect[3] == height) {
1931 return;
1933 mViewportRect[0] = x;
1934 mViewportRect[1] = y;
1935 mViewportRect[2] = width;
1936 mViewportRect[3] = height;
1937 BEFORE_GL_CALL;
1938 mSymbols.fViewport(x, y, width, height);
1939 AFTER_GL_CALL;
1942 void fCompileShader(GLuint shader) {
1943 BEFORE_GL_CALL;
1944 mSymbols.fCompileShader(shader);
1945 AFTER_GL_CALL;
1948 private:
1949 friend class SharedSurface_IOSurface;
1951 void raw_fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat,
1952 GLint x, GLint y, GLsizei width, GLsizei height,
1953 GLint border) {
1954 BEFORE_GL_CALL;
1955 mSymbols.fCopyTexImage2D(target, level, internalformat, x, y, width, height,
1956 border);
1957 AFTER_GL_CALL;
1960 void raw_fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset,
1961 GLint yoffset, GLint x, GLint y, GLsizei width,
1962 GLsizei height) {
1963 BEFORE_GL_CALL;
1964 mSymbols.fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width,
1965 height);
1966 AFTER_GL_CALL;
1969 public:
1970 void fGetShaderiv(GLuint shader, GLenum pname, GLint* param) {
1971 BEFORE_GL_CALL;
1972 mSymbols.fGetShaderiv(shader, pname, param);
1973 OnSyncCall();
1974 AFTER_GL_CALL;
1977 void fGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length,
1978 GLchar* infoLog) {
1979 BEFORE_GL_CALL;
1980 mSymbols.fGetShaderInfoLog(shader, bufSize, length, infoLog);
1981 OnSyncCall();
1982 AFTER_GL_CALL;
1985 private:
1986 void raw_fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype,
1987 GLint* range, GLint* precision) {
1988 MOZ_ASSERT(IsGLES());
1990 BEFORE_GL_CALL;
1991 ASSERT_SYMBOL_PRESENT(fGetShaderPrecisionFormat);
1992 mSymbols.fGetShaderPrecisionFormat(shadertype, precisiontype, range,
1993 precision);
1994 OnSyncCall();
1995 AFTER_GL_CALL;
1998 public:
1999 void fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype,
2000 GLint* range, GLint* precision) {
2001 if (IsGLES()) {
2002 raw_fGetShaderPrecisionFormat(shadertype, precisiontype, range,
2003 precision);
2004 } else {
2005 // Fall back to automatic values because almost all desktop hardware
2006 // supports the OpenGL standard precisions.
2007 GetShaderPrecisionFormatNonES2(shadertype, precisiontype, range,
2008 precision);
2012 void fGetShaderSource(GLint obj, GLsizei maxLength, GLsizei* length,
2013 GLchar* source) {
2014 BEFORE_GL_CALL;
2015 mSymbols.fGetShaderSource(obj, maxLength, length, source);
2016 OnSyncCall();
2017 AFTER_GL_CALL;
2020 void fShaderSource(GLuint shader, GLsizei count, const GLchar* const* strings,
2021 const GLint* lengths) {
2022 BEFORE_GL_CALL;
2023 mSymbols.fShaderSource(shader, count, strings, lengths);
2024 AFTER_GL_CALL;
2027 void fBindFramebuffer(GLenum target, GLuint framebuffer) {
2028 BEFORE_GL_CALL;
2029 mSymbols.fBindFramebuffer(target, framebuffer);
2030 AFTER_GL_CALL;
2033 void fBindRenderbuffer(GLenum target, GLuint renderbuffer) {
2034 BEFORE_GL_CALL;
2035 mSymbols.fBindRenderbuffer(target, renderbuffer);
2036 AFTER_GL_CALL;
2039 GLenum fCheckFramebufferStatus(GLenum target) {
2040 GLenum retval = 0;
2041 BEFORE_GL_CALL;
2042 retval = mSymbols.fCheckFramebufferStatus(target);
2043 OnSyncCall();
2044 AFTER_GL_CALL;
2045 return retval;
2048 void fFramebufferRenderbuffer(GLenum target, GLenum attachmentPoint,
2049 GLenum renderbufferTarget,
2050 GLuint renderbuffer) {
2051 BEFORE_GL_CALL;
2052 mSymbols.fFramebufferRenderbuffer(target, attachmentPoint,
2053 renderbufferTarget, renderbuffer);
2054 AFTER_GL_CALL;
2057 void fFramebufferTexture2D(GLenum target, GLenum attachmentPoint,
2058 GLenum textureTarget, GLuint texture,
2059 GLint level) {
2060 BEFORE_GL_CALL;
2061 mSymbols.fFramebufferTexture2D(target, attachmentPoint, textureTarget,
2062 texture, level);
2063 AFTER_GL_CALL;
2064 if (mNeedsCheckAfterAttachTextureToFb) {
2065 fCheckFramebufferStatus(target);
2069 void fFramebufferTextureLayer(GLenum target, GLenum attachment,
2070 GLuint texture, GLint level, GLint layer) {
2071 BEFORE_GL_CALL;
2072 ASSERT_SYMBOL_PRESENT(fFramebufferTextureLayer);
2073 mSymbols.fFramebufferTextureLayer(target, attachment, texture, level,
2074 layer);
2075 AFTER_GL_CALL;
2078 void fGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
2079 GLenum pname, GLint* value) {
2080 BEFORE_GL_CALL;
2081 mSymbols.fGetFramebufferAttachmentParameteriv(target, attachment, pname,
2082 value);
2083 OnSyncCall();
2084 AFTER_GL_CALL;
2087 void fGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* value) {
2088 BEFORE_GL_CALL;
2089 mSymbols.fGetRenderbufferParameteriv(target, pname, value);
2090 OnSyncCall();
2091 AFTER_GL_CALL;
2094 realGLboolean fIsFramebuffer(GLuint framebuffer) {
2095 realGLboolean retval = false;
2096 BEFORE_GL_CALL;
2097 retval = mSymbols.fIsFramebuffer(framebuffer);
2098 OnSyncCall();
2099 AFTER_GL_CALL;
2100 return retval;
2103 public:
2104 realGLboolean fIsRenderbuffer(GLuint renderbuffer) {
2105 realGLboolean retval = false;
2106 BEFORE_GL_CALL;
2107 retval = mSymbols.fIsRenderbuffer(renderbuffer);
2108 OnSyncCall();
2109 AFTER_GL_CALL;
2110 return retval;
2113 void fRenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width,
2114 GLsizei height) {
2115 BEFORE_GL_CALL;
2116 mSymbols.fRenderbufferStorage(target, internalFormat, width, height);
2117 AFTER_GL_CALL;
2120 private:
2121 void raw_fDepthRange(GLclampf a, GLclampf b) {
2122 MOZ_ASSERT(!IsGLES());
2124 BEFORE_GL_CALL;
2125 ASSERT_SYMBOL_PRESENT(fDepthRange);
2126 mSymbols.fDepthRange(a, b);
2127 AFTER_GL_CALL;
2130 void raw_fDepthRangef(GLclampf a, GLclampf b) {
2131 MOZ_ASSERT(IsGLES());
2133 BEFORE_GL_CALL;
2134 ASSERT_SYMBOL_PRESENT(fDepthRangef);
2135 mSymbols.fDepthRangef(a, b);
2136 AFTER_GL_CALL;
2139 void raw_fClearDepth(GLclampf v) {
2140 MOZ_ASSERT(!IsGLES());
2142 BEFORE_GL_CALL;
2143 ASSERT_SYMBOL_PRESENT(fClearDepth);
2144 mSymbols.fClearDepth(v);
2145 AFTER_GL_CALL;
2148 void raw_fClearDepthf(GLclampf v) {
2149 MOZ_ASSERT(IsGLES());
2151 BEFORE_GL_CALL;
2152 ASSERT_SYMBOL_PRESENT(fClearDepthf);
2153 mSymbols.fClearDepthf(v);
2154 AFTER_GL_CALL;
2157 public:
2158 void fDepthRange(GLclampf a, GLclampf b) {
2159 if (IsGLES()) {
2160 raw_fDepthRangef(a, b);
2161 } else {
2162 raw_fDepthRange(a, b);
2166 void fClearDepth(GLclampf v) {
2167 if (IsGLES()) {
2168 raw_fClearDepthf(v);
2169 } else {
2170 raw_fClearDepth(v);
2174 void* fMapBuffer(GLenum target, GLenum access) {
2175 void* ret = nullptr;
2176 BEFORE_GL_CALL;
2177 ASSERT_SYMBOL_PRESENT(fMapBuffer);
2178 ret = mSymbols.fMapBuffer(target, access);
2179 OnSyncCall();
2180 AFTER_GL_CALL;
2181 return ret;
2184 realGLboolean fUnmapBuffer(GLenum target) {
2185 realGLboolean ret = false;
2186 BEFORE_GL_CALL;
2187 ASSERT_SYMBOL_PRESENT(fUnmapBuffer);
2188 ret = mSymbols.fUnmapBuffer(target);
2189 AFTER_GL_CALL;
2190 return ret;
2193 private:
2194 GLuint raw_fCreateProgram() {
2195 GLuint ret = 0;
2196 BEFORE_GL_CALL;
2197 ret = mSymbols.fCreateProgram();
2198 AFTER_GL_CALL;
2199 return ret;
2202 GLuint raw_fCreateShader(GLenum t) {
2203 GLuint ret = 0;
2204 BEFORE_GL_CALL;
2205 ret = mSymbols.fCreateShader(t);
2206 AFTER_GL_CALL;
2207 return ret;
2210 void raw_fGenBuffers(GLsizei n, GLuint* names) {
2211 BEFORE_GL_CALL;
2212 mSymbols.fGenBuffers(n, names);
2213 OnSyncCall();
2214 AFTER_GL_CALL;
2217 void raw_fGenFramebuffers(GLsizei n, GLuint* names) {
2218 BEFORE_GL_CALL;
2219 mSymbols.fGenFramebuffers(n, names);
2220 OnSyncCall();
2221 AFTER_GL_CALL;
2224 void raw_fGenRenderbuffers(GLsizei n, GLuint* names) {
2225 BEFORE_GL_CALL;
2226 mSymbols.fGenRenderbuffers(n, names);
2227 OnSyncCall();
2228 AFTER_GL_CALL;
2231 void raw_fGenTextures(GLsizei n, GLuint* names) {
2232 BEFORE_GL_CALL;
2233 mSymbols.fGenTextures(n, names);
2234 OnSyncCall();
2235 AFTER_GL_CALL;
2238 public:
2239 GLuint fCreateProgram() {
2240 GLuint ret = raw_fCreateProgram();
2241 TRACKING_CONTEXT(CreatedProgram(this, ret));
2242 return ret;
2245 GLuint fCreateShader(GLenum t) {
2246 GLuint ret = raw_fCreateShader(t);
2247 TRACKING_CONTEXT(CreatedShader(this, ret));
2248 return ret;
2251 void fGenBuffers(GLsizei n, GLuint* names) {
2252 raw_fGenBuffers(n, names);
2253 TRACKING_CONTEXT(CreatedBuffers(this, n, names));
2256 void fGenFramebuffers(GLsizei n, GLuint* names) {
2257 raw_fGenFramebuffers(n, names);
2258 TRACKING_CONTEXT(CreatedFramebuffers(this, n, names));
2261 void fGenRenderbuffers(GLsizei n, GLuint* names) {
2262 raw_fGenRenderbuffers(n, names);
2263 TRACKING_CONTEXT(CreatedRenderbuffers(this, n, names));
2266 void fGenTextures(GLsizei n, GLuint* names) {
2267 raw_fGenTextures(n, names);
2268 TRACKING_CONTEXT(CreatedTextures(this, n, names));
2271 private:
2272 void raw_fDeleteProgram(GLuint program) {
2273 BEFORE_GL_CALL;
2274 mSymbols.fDeleteProgram(program);
2275 AFTER_GL_CALL;
2278 void raw_fDeleteShader(GLuint shader) {
2279 BEFORE_GL_CALL;
2280 mSymbols.fDeleteShader(shader);
2281 AFTER_GL_CALL;
2284 void raw_fDeleteBuffers(GLsizei n, const GLuint* names) {
2285 BEFORE_GL_CALL;
2286 mSymbols.fDeleteBuffers(n, names);
2287 AFTER_GL_CALL;
2290 void raw_fDeleteFramebuffers(GLsizei n, const GLuint* names) {
2291 BEFORE_GL_CALL;
2292 mSymbols.fDeleteFramebuffers(n, names);
2293 AFTER_GL_CALL;
2296 void raw_fDeleteRenderbuffers(GLsizei n, const GLuint* names) {
2297 BEFORE_GL_CALL;
2298 mSymbols.fDeleteRenderbuffers(n, names);
2299 AFTER_GL_CALL;
2302 void raw_fDeleteTextures(GLsizei n, const GLuint* names) {
2303 BEFORE_GL_CALL;
2304 mSymbols.fDeleteTextures(n, names);
2305 AFTER_GL_CALL;
2308 public:
2309 void fDeleteProgram(GLuint program) {
2310 raw_fDeleteProgram(program);
2311 TRACKING_CONTEXT(DeletedProgram(this, program));
2314 void fDeleteShader(GLuint shader) {
2315 raw_fDeleteShader(shader);
2316 TRACKING_CONTEXT(DeletedShader(this, shader));
2319 void fDeleteBuffers(GLsizei n, const GLuint* names) {
2320 raw_fDeleteBuffers(n, names);
2321 TRACKING_CONTEXT(DeletedBuffers(this, n, names));
2324 void fDeleteFramebuffers(GLsizei n, const GLuint* names);
2326 void fDeleteRenderbuffers(GLsizei n, const GLuint* names) {
2327 raw_fDeleteRenderbuffers(n, names);
2328 TRACKING_CONTEXT(DeletedRenderbuffers(this, n, names));
2331 void fDeleteTextures(GLsizei n, const GLuint* names) {
2332 #ifdef XP_MACOSX
2333 // On the Mac the call to fDeleteTextures() triggers a flush. But it
2334 // happens at the wrong time, which can lead to crashes. To work around
2335 // this we call fFlush() explicitly ourselves, before the call to
2336 // fDeleteTextures(). This fixes bug 1666293.
2337 fFlush();
2338 #endif
2339 raw_fDeleteTextures(n, names);
2340 TRACKING_CONTEXT(DeletedTextures(this, n, names));
2343 // -----------------------------------------------------------------------------
2344 // Extension ARB_sync (GL)
2345 public:
2346 GLsync fFenceSync(GLenum condition, GLbitfield flags) {
2347 GLsync ret = 0;
2348 BEFORE_GL_CALL;
2349 ASSERT_SYMBOL_PRESENT(fFenceSync);
2350 ret = mSymbols.fFenceSync(condition, flags);
2351 OnSyncCall();
2352 AFTER_GL_CALL;
2353 return ret;
2356 realGLboolean fIsSync(GLsync sync) {
2357 realGLboolean ret = false;
2358 BEFORE_GL_CALL;
2359 ASSERT_SYMBOL_PRESENT(fIsSync);
2360 ret = mSymbols.fIsSync(sync);
2361 OnSyncCall();
2362 AFTER_GL_CALL;
2363 return ret;
2366 void fDeleteSync(GLsync sync) {
2367 BEFORE_GL_CALL;
2368 ASSERT_SYMBOL_PRESENT(fDeleteSync);
2369 mSymbols.fDeleteSync(sync);
2370 AFTER_GL_CALL;
2373 GLenum fClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) {
2374 GLenum ret = 0;
2375 BEFORE_GL_CALL;
2376 ASSERT_SYMBOL_PRESENT(fClientWaitSync);
2377 ret = mSymbols.fClientWaitSync(sync, flags, timeout);
2378 OnSyncCall();
2379 AFTER_GL_CALL;
2380 return ret;
2383 void fWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) {
2384 BEFORE_GL_CALL;
2385 ASSERT_SYMBOL_PRESENT(fWaitSync);
2386 mSymbols.fWaitSync(sync, flags, timeout);
2387 AFTER_GL_CALL;
2390 void fGetInteger64v(GLenum pname, GLint64* params) {
2391 BEFORE_GL_CALL;
2392 ASSERT_SYMBOL_PRESENT(fGetInteger64v);
2393 mSymbols.fGetInteger64v(pname, params);
2394 AFTER_GL_CALL;
2397 void fGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length,
2398 GLint* values) {
2399 BEFORE_GL_CALL;
2400 ASSERT_SYMBOL_PRESENT(fGetSynciv);
2401 mSymbols.fGetSynciv(sync, pname, bufSize, length, values);
2402 OnSyncCall();
2403 AFTER_GL_CALL;
2406 // -----------------------------------------------------------------------------
2407 // Extension OES_EGL_image (GLES)
2408 public:
2409 void fEGLImageTargetTexture2D(GLenum target, GLeglImage image) {
2410 BEFORE_GL_CALL;
2411 ASSERT_SYMBOL_PRESENT(fEGLImageTargetTexture2D);
2412 mSymbols.fEGLImageTargetTexture2D(target, image);
2413 AFTER_GL_CALL;
2414 mHeavyGLCallsSinceLastFlush = true;
2417 void fEGLImageTargetRenderbufferStorage(GLenum target, GLeglImage image) {
2418 BEFORE_GL_CALL;
2419 ASSERT_SYMBOL_PRESENT(fEGLImageTargetRenderbufferStorage);
2420 mSymbols.fEGLImageTargetRenderbufferStorage(target, image);
2421 AFTER_GL_CALL;
2424 // -----------------------------------------------------------------------------
2425 // Package XXX_bind_buffer_offset
2426 public:
2427 void fBindBufferOffset(GLenum target, GLuint index, GLuint buffer,
2428 GLintptr offset) {
2429 BEFORE_GL_CALL;
2430 ASSERT_SYMBOL_PRESENT(fBindBufferOffset);
2431 mSymbols.fBindBufferOffset(target, index, buffer, offset);
2432 AFTER_GL_CALL;
2435 // -----------------------------------------------------------------------------
2436 // Package XXX_draw_buffers
2437 public:
2438 void fDrawBuffers(GLsizei n, const GLenum* bufs) {
2439 BEFORE_GL_CALL;
2440 ASSERT_SYMBOL_PRESENT(fDrawBuffers);
2441 mSymbols.fDrawBuffers(n, bufs);
2442 AFTER_GL_CALL;
2445 // -----------------------------------------------------------------------------
2446 // Package XXX_draw_instanced
2447 public:
2448 void fDrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
2449 GLsizei primcount) {
2450 BeforeGLDrawCall();
2451 raw_fDrawArraysInstanced(mode, first, count, primcount);
2452 AfterGLDrawCall();
2455 void fDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
2456 const GLvoid* indices, GLsizei primcount) {
2457 BeforeGLDrawCall();
2458 raw_fDrawElementsInstanced(mode, count, type, indices, primcount);
2459 AfterGLDrawCall();
2462 private:
2463 void raw_fDrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
2464 GLsizei primcount) {
2465 BEFORE_GL_CALL;
2466 ASSERT_SYMBOL_PRESENT(fDrawArraysInstanced);
2467 mSymbols.fDrawArraysInstanced(mode, first, count, primcount);
2468 AFTER_GL_CALL;
2471 void raw_fDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
2472 const GLvoid* indices, GLsizei primcount) {
2473 BEFORE_GL_CALL;
2474 ASSERT_SYMBOL_PRESENT(fDrawElementsInstanced);
2475 mSymbols.fDrawElementsInstanced(mode, count, type, indices, primcount);
2476 AFTER_GL_CALL;
2479 // -----------------------------------------------------------------------------
2480 // Package XXX_framebuffer_blit
2481 public:
2482 // Draw/Read
2483 void fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
2484 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
2485 GLbitfield mask, GLenum filter) {
2486 BeforeGLDrawCall();
2487 BeforeGLReadCall();
2488 raw_fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
2489 mask, filter);
2490 AfterGLReadCall();
2491 AfterGLDrawCall();
2494 private:
2495 void raw_fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
2496 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
2497 GLbitfield mask, GLenum filter) {
2498 BEFORE_GL_CALL;
2499 ASSERT_SYMBOL_PRESENT(fBlitFramebuffer);
2500 mSymbols.fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1,
2501 dstY1, mask, filter);
2502 AFTER_GL_CALL;
2505 // -----------------------------------------------------------------------------
2506 // Package XXX_framebuffer_multisample
2507 public:
2508 void fRenderbufferStorageMultisample(GLenum target, GLsizei samples,
2509 GLenum internalFormat, GLsizei width,
2510 GLsizei height) {
2511 BEFORE_GL_CALL;
2512 ASSERT_SYMBOL_PRESENT(fRenderbufferStorageMultisample);
2513 mSymbols.fRenderbufferStorageMultisample(target, samples, internalFormat,
2514 width, height);
2515 AFTER_GL_CALL;
2518 // -----------------------------------------------------------------------------
2519 // GL 3.0, GL ES 3.0 & EXT_gpu_shader4
2520 public:
2521 void fGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) {
2522 ASSERT_SYMBOL_PRESENT(fGetVertexAttribIiv);
2523 BEFORE_GL_CALL;
2524 mSymbols.fGetVertexAttribIiv(index, pname, params);
2525 OnSyncCall();
2526 AFTER_GL_CALL;
2529 void fGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) {
2530 ASSERT_SYMBOL_PRESENT(fGetVertexAttribIuiv);
2531 BEFORE_GL_CALL;
2532 mSymbols.fGetVertexAttribIuiv(index, pname, params);
2533 OnSyncCall();
2534 AFTER_GL_CALL;
2537 void fVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) {
2538 BEFORE_GL_CALL;
2539 ASSERT_SYMBOL_PRESENT(fVertexAttribI4i);
2540 mSymbols.fVertexAttribI4i(index, x, y, z, w);
2541 AFTER_GL_CALL;
2544 void fVertexAttribI4iv(GLuint index, const GLint* v) {
2545 BEFORE_GL_CALL;
2546 ASSERT_SYMBOL_PRESENT(fVertexAttribI4iv);
2547 mSymbols.fVertexAttribI4iv(index, v);
2548 AFTER_GL_CALL;
2551 void fVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) {
2552 BEFORE_GL_CALL;
2553 ASSERT_SYMBOL_PRESENT(fVertexAttribI4ui);
2554 mSymbols.fVertexAttribI4ui(index, x, y, z, w);
2555 AFTER_GL_CALL;
2558 void fVertexAttribI4uiv(GLuint index, const GLuint* v) {
2559 BEFORE_GL_CALL;
2560 ASSERT_SYMBOL_PRESENT(fVertexAttribI4uiv);
2561 mSymbols.fVertexAttribI4uiv(index, v);
2562 AFTER_GL_CALL;
2565 void fVertexAttribIPointer(GLuint index, GLint size, GLenum type,
2566 GLsizei stride, const GLvoid* offset) {
2567 BEFORE_GL_CALL;
2568 ASSERT_SYMBOL_PRESENT(fVertexAttribIPointer);
2569 mSymbols.fVertexAttribIPointer(index, size, type, stride, offset);
2570 AFTER_GL_CALL;
2573 void fUniform1ui(GLint location, GLuint v0) {
2574 BEFORE_GL_CALL;
2575 ASSERT_SYMBOL_PRESENT(fUniform1ui);
2576 mSymbols.fUniform1ui(location, v0);
2577 AFTER_GL_CALL;
2580 void fUniform2ui(GLint location, GLuint v0, GLuint v1) {
2581 BEFORE_GL_CALL;
2582 ASSERT_SYMBOL_PRESENT(fUniform2ui);
2583 mSymbols.fUniform2ui(location, v0, v1);
2584 AFTER_GL_CALL;
2587 void fUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) {
2588 BEFORE_GL_CALL;
2589 ASSERT_SYMBOL_PRESENT(fUniform3ui);
2590 mSymbols.fUniform3ui(location, v0, v1, v2);
2591 AFTER_GL_CALL;
2594 void fUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
2595 BEFORE_GL_CALL;
2596 ASSERT_SYMBOL_PRESENT(fUniform4ui);
2597 mSymbols.fUniform4ui(location, v0, v1, v2, v3);
2598 AFTER_GL_CALL;
2601 void fUniform1uiv(GLint location, GLsizei count, const GLuint* value) {
2602 BEFORE_GL_CALL;
2603 ASSERT_SYMBOL_PRESENT(fUniform1uiv);
2604 mSymbols.fUniform1uiv(location, count, value);
2605 AFTER_GL_CALL;
2608 void fUniform2uiv(GLint location, GLsizei count, const GLuint* value) {
2609 BEFORE_GL_CALL;
2610 ASSERT_SYMBOL_PRESENT(fUniform2uiv);
2611 mSymbols.fUniform2uiv(location, count, value);
2612 AFTER_GL_CALL;
2615 void fUniform3uiv(GLint location, GLsizei count, const GLuint* value) {
2616 BEFORE_GL_CALL;
2617 ASSERT_SYMBOL_PRESENT(fUniform3uiv);
2618 mSymbols.fUniform3uiv(location, count, value);
2619 AFTER_GL_CALL;
2622 void fUniform4uiv(GLint location, GLsizei count, const GLuint* value) {
2623 BEFORE_GL_CALL;
2624 ASSERT_SYMBOL_PRESENT(fUniform4uiv);
2625 mSymbols.fUniform4uiv(location, count, value);
2626 AFTER_GL_CALL;
2629 GLint fGetFragDataLocation(GLuint program, const GLchar* name) {
2630 GLint result = 0;
2631 BEFORE_GL_CALL;
2632 ASSERT_SYMBOL_PRESENT(fGetFragDataLocation);
2633 result = mSymbols.fGetFragDataLocation(program, name);
2634 OnSyncCall();
2635 AFTER_GL_CALL;
2636 return result;
2639 // -----------------------------------------------------------------------------
2640 // Package XXX_instanced_arrays
2641 public:
2642 void fVertexAttribDivisor(GLuint index, GLuint divisor) {
2643 BEFORE_GL_CALL;
2644 ASSERT_SYMBOL_PRESENT(fVertexAttribDivisor);
2645 mSymbols.fVertexAttribDivisor(index, divisor);
2646 AFTER_GL_CALL;
2649 // -----------------------------------------------------------------------------
2650 // Feature internalformat_query
2651 public:
2652 void fGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
2653 GLsizei bufSize, GLint* params) {
2654 BEFORE_GL_CALL;
2655 ASSERT_SYMBOL_PRESENT(fGetInternalformativ);
2656 mSymbols.fGetInternalformativ(target, internalformat, pname, bufSize,
2657 params);
2658 OnSyncCall();
2659 AFTER_GL_CALL;
2662 // -----------------------------------------------------------------------------
2663 // Package XXX_query_counter
2665 * XXX_query_counter:
2666 * - depends on XXX_query_objects
2667 * - provide all followed entry points
2668 * - provide GL_TIMESTAMP
2670 public:
2671 void fQueryCounter(GLuint id, GLenum target) {
2672 BEFORE_GL_CALL;
2673 ASSERT_SYMBOL_PRESENT(fQueryCounter);
2674 mSymbols.fQueryCounter(id, target);
2675 AFTER_GL_CALL;
2678 // -----------------------------------------------------------------------------
2679 // Package XXX_query_objects
2681 * XXX_query_objects:
2682 * - provide all followed entry points
2684 * XXX_occlusion_query2:
2685 * - depends on XXX_query_objects
2686 * - provide ANY_SAMPLES_PASSED
2688 * XXX_occlusion_query_boolean:
2689 * - depends on XXX_occlusion_query2
2690 * - provide ANY_SAMPLES_PASSED_CONSERVATIVE
2692 public:
2693 void fDeleteQueries(GLsizei n, const GLuint* names) {
2694 BEFORE_GL_CALL;
2695 ASSERT_SYMBOL_PRESENT(fDeleteQueries);
2696 mSymbols.fDeleteQueries(n, names);
2697 AFTER_GL_CALL;
2698 TRACKING_CONTEXT(DeletedQueries(this, n, names));
2701 void fGenQueries(GLsizei n, GLuint* names) {
2702 BEFORE_GL_CALL;
2703 ASSERT_SYMBOL_PRESENT(fGenQueries);
2704 mSymbols.fGenQueries(n, names);
2705 AFTER_GL_CALL;
2706 TRACKING_CONTEXT(CreatedQueries(this, n, names));
2709 void fGetQueryiv(GLenum target, GLenum pname, GLint* params) {
2710 BEFORE_GL_CALL;
2711 ASSERT_SYMBOL_PRESENT(fGetQueryiv);
2712 mSymbols.fGetQueryiv(target, pname, params);
2713 OnSyncCall();
2714 AFTER_GL_CALL;
2717 void fGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) {
2718 BEFORE_GL_CALL;
2719 ASSERT_SYMBOL_PRESENT(fGetQueryObjectuiv);
2720 mSymbols.fGetQueryObjectuiv(id, pname, params);
2721 OnSyncCall();
2722 AFTER_GL_CALL;
2725 realGLboolean fIsQuery(GLuint query) {
2726 realGLboolean retval = false;
2727 BEFORE_GL_CALL;
2728 ASSERT_SYMBOL_PRESENT(fIsQuery);
2729 retval = mSymbols.fIsQuery(query);
2730 OnSyncCall();
2731 AFTER_GL_CALL;
2732 return retval;
2735 // -----------------------------------------------------------------------------
2736 // Package XXX_get_query_object_i64v
2738 * XXX_get_query_object_i64v:
2739 * - depends on XXX_query_objects
2740 * - provide the followed entry point
2742 public:
2743 void fGetQueryObjecti64v(GLuint id, GLenum pname, GLint64* params) {
2744 BEFORE_GL_CALL;
2745 ASSERT_SYMBOL_PRESENT(fGetQueryObjecti64v);
2746 mSymbols.fGetQueryObjecti64v(id, pname, params);
2747 OnSyncCall();
2748 AFTER_GL_CALL;
2751 void fGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64* params) {
2752 BEFORE_GL_CALL;
2753 ASSERT_SYMBOL_PRESENT(fGetQueryObjectui64v);
2754 mSymbols.fGetQueryObjectui64v(id, pname, params);
2755 OnSyncCall();
2756 AFTER_GL_CALL;
2759 // -----------------------------------------------------------------------------
2760 // Package XXX_get_query_object_iv
2762 * XXX_get_query_object_iv:
2763 * - depends on XXX_query_objects
2764 * - provide the followed entry point
2766 * XXX_occlusion_query:
2767 * - depends on XXX_get_query_object_iv
2768 * - provide LOCAL_GL_SAMPLES_PASSED
2770 public:
2771 void fGetQueryObjectiv(GLuint id, GLenum pname, GLint* params) {
2772 BEFORE_GL_CALL;
2773 ASSERT_SYMBOL_PRESENT(fGetQueryObjectiv);
2774 mSymbols.fGetQueryObjectiv(id, pname, params);
2775 OnSyncCall();
2776 AFTER_GL_CALL;
2779 // -----------------------------------------------------------------------------
2780 // GL 4.0, GL ES 3.0, ARB_transform_feedback2, NV_transform_feedback2
2781 public:
2782 void fBindBufferBase(GLenum target, GLuint index, GLuint buffer) {
2783 BEFORE_GL_CALL;
2784 ASSERT_SYMBOL_PRESENT(fBindBufferBase);
2785 mSymbols.fBindBufferBase(target, index, buffer);
2786 AFTER_GL_CALL;
2789 void fBindBufferRange(GLenum target, GLuint index, GLuint buffer,
2790 GLintptr offset, GLsizeiptr size) {
2791 BEFORE_GL_CALL;
2792 ASSERT_SYMBOL_PRESENT(fBindBufferRange);
2793 mSymbols.fBindBufferRange(target, index, buffer, offset, size);
2794 AFTER_GL_CALL;
2797 void fGenTransformFeedbacks(GLsizei n, GLuint* ids) {
2798 BEFORE_GL_CALL;
2799 ASSERT_SYMBOL_PRESENT(fGenTransformFeedbacks);
2800 mSymbols.fGenTransformFeedbacks(n, ids);
2801 OnSyncCall();
2802 AFTER_GL_CALL;
2805 void fDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) {
2806 BEFORE_GL_CALL;
2807 ASSERT_SYMBOL_PRESENT(fDeleteTransformFeedbacks);
2808 mSymbols.fDeleteTransformFeedbacks(n, ids);
2809 AFTER_GL_CALL;
2812 realGLboolean fIsTransformFeedback(GLuint id) {
2813 realGLboolean result = false;
2814 BEFORE_GL_CALL;
2815 ASSERT_SYMBOL_PRESENT(fIsTransformFeedback);
2816 result = mSymbols.fIsTransformFeedback(id);
2817 OnSyncCall();
2818 AFTER_GL_CALL;
2819 return result;
2822 void fBindTransformFeedback(GLenum target, GLuint id) {
2823 BEFORE_GL_CALL;
2824 ASSERT_SYMBOL_PRESENT(fBindTransformFeedback);
2825 mSymbols.fBindTransformFeedback(target, id);
2826 AFTER_GL_CALL;
2829 void fBeginTransformFeedback(GLenum primitiveMode) {
2830 BEFORE_GL_CALL;
2831 ASSERT_SYMBOL_PRESENT(fBeginTransformFeedback);
2832 mSymbols.fBeginTransformFeedback(primitiveMode);
2833 AFTER_GL_CALL;
2836 void fEndTransformFeedback() {
2837 BEFORE_GL_CALL;
2838 ASSERT_SYMBOL_PRESENT(fEndTransformFeedback);
2839 mSymbols.fEndTransformFeedback();
2840 AFTER_GL_CALL;
2843 void fTransformFeedbackVaryings(GLuint program, GLsizei count,
2844 const GLchar* const* varyings,
2845 GLenum bufferMode) {
2846 BEFORE_GL_CALL;
2847 ASSERT_SYMBOL_PRESENT(fTransformFeedbackVaryings);
2848 mSymbols.fTransformFeedbackVaryings(program, count, varyings, bufferMode);
2849 AFTER_GL_CALL;
2852 void fGetTransformFeedbackVarying(GLuint program, GLuint index,
2853 GLsizei bufSize, GLsizei* length,
2854 GLsizei* size, GLenum* type, GLchar* name) {
2855 BEFORE_GL_CALL;
2856 ASSERT_SYMBOL_PRESENT(fGetTransformFeedbackVarying);
2857 mSymbols.fGetTransformFeedbackVarying(program, index, bufSize, length, size,
2858 type, name);
2859 OnSyncCall();
2860 AFTER_GL_CALL;
2863 void fPauseTransformFeedback() {
2864 BEFORE_GL_CALL;
2865 ASSERT_SYMBOL_PRESENT(fPauseTransformFeedback);
2866 mSymbols.fPauseTransformFeedback();
2867 AFTER_GL_CALL;
2870 void fResumeTransformFeedback() {
2871 BEFORE_GL_CALL;
2872 ASSERT_SYMBOL_PRESENT(fResumeTransformFeedback);
2873 mSymbols.fResumeTransformFeedback();
2874 AFTER_GL_CALL;
2877 void fGetIntegeri_v(GLenum param, GLuint index, GLint* values) {
2878 BEFORE_GL_CALL;
2879 ASSERT_SYMBOL_PRESENT(fGetIntegeri_v);
2880 mSymbols.fGetIntegeri_v(param, index, values);
2881 OnSyncCall();
2882 AFTER_GL_CALL;
2885 void fGetInteger64i_v(GLenum target, GLuint index, GLint64* data) {
2886 ASSERT_SYMBOL_PRESENT(fGetInteger64i_v);
2887 BEFORE_GL_CALL;
2888 mSymbols.fGetInteger64i_v(target, index, data);
2889 OnSyncCall();
2890 AFTER_GL_CALL;
2893 // -----------------------------------------------------------------------------
2894 // Package XXX_vertex_array_object
2895 public:
2896 void fBindVertexArray(GLuint array) {
2897 BEFORE_GL_CALL;
2898 ASSERT_SYMBOL_PRESENT(fBindVertexArray);
2899 mSymbols.fBindVertexArray(array);
2900 AFTER_GL_CALL;
2903 void fDeleteVertexArrays(GLsizei n, const GLuint* arrays) {
2904 BEFORE_GL_CALL;
2905 ASSERT_SYMBOL_PRESENT(fDeleteVertexArrays);
2906 mSymbols.fDeleteVertexArrays(n, arrays);
2907 AFTER_GL_CALL;
2910 void fGenVertexArrays(GLsizei n, GLuint* arrays) {
2911 BEFORE_GL_CALL;
2912 ASSERT_SYMBOL_PRESENT(fGenVertexArrays);
2913 mSymbols.fGenVertexArrays(n, arrays);
2914 AFTER_GL_CALL;
2917 realGLboolean fIsVertexArray(GLuint array) {
2918 realGLboolean ret = false;
2919 BEFORE_GL_CALL;
2920 ASSERT_SYMBOL_PRESENT(fIsVertexArray);
2921 ret = mSymbols.fIsVertexArray(array);
2922 OnSyncCall();
2923 AFTER_GL_CALL;
2924 return ret;
2927 // -----------------------------------------------------------------------------
2928 // Extension NV_fence
2929 public:
2930 void fGenFences(GLsizei n, GLuint* fences) {
2931 ASSERT_SYMBOL_PRESENT(fGenFences);
2932 BEFORE_GL_CALL;
2933 mSymbols.fGenFences(n, fences);
2934 AFTER_GL_CALL;
2937 void fDeleteFences(GLsizei n, const GLuint* fences) {
2938 ASSERT_SYMBOL_PRESENT(fDeleteFences);
2939 BEFORE_GL_CALL;
2940 mSymbols.fDeleteFences(n, fences);
2941 AFTER_GL_CALL;
2944 void fSetFence(GLuint fence, GLenum condition) {
2945 ASSERT_SYMBOL_PRESENT(fSetFence);
2946 BEFORE_GL_CALL;
2947 mSymbols.fSetFence(fence, condition);
2948 AFTER_GL_CALL;
2951 realGLboolean fTestFence(GLuint fence) {
2952 realGLboolean ret = false;
2953 ASSERT_SYMBOL_PRESENT(fTestFence);
2954 BEFORE_GL_CALL;
2955 ret = mSymbols.fTestFence(fence);
2956 OnSyncCall();
2957 AFTER_GL_CALL;
2958 return ret;
2961 void fFinishFence(GLuint fence) {
2962 ASSERT_SYMBOL_PRESENT(fFinishFence);
2963 BEFORE_GL_CALL;
2964 mSymbols.fFinishFence(fence);
2965 OnSyncCall();
2966 AFTER_GL_CALL;
2969 realGLboolean fIsFence(GLuint fence) {
2970 realGLboolean ret = false;
2971 ASSERT_SYMBOL_PRESENT(fIsFence);
2972 BEFORE_GL_CALL;
2973 ret = mSymbols.fIsFence(fence);
2974 OnSyncCall();
2975 AFTER_GL_CALL;
2976 return ret;
2979 void fGetFenceiv(GLuint fence, GLenum pname, GLint* params) {
2980 ASSERT_SYMBOL_PRESENT(fGetFenceiv);
2981 BEFORE_GL_CALL;
2982 mSymbols.fGetFenceiv(fence, pname, params);
2983 OnSyncCall();
2984 AFTER_GL_CALL;
2987 // -----------------------------------------------------------------------------
2988 // Extension NV_texture_barrier
2989 public:
2990 void fTextureBarrier() {
2991 ASSERT_SYMBOL_PRESENT(fTextureBarrier);
2992 BEFORE_GL_CALL;
2993 mSymbols.fTextureBarrier();
2994 AFTER_GL_CALL;
2997 // Core GL & Extension ARB_copy_buffer
2998 public:
2999 void fCopyBufferSubData(GLenum readtarget, GLenum writetarget,
3000 GLintptr readoffset, GLintptr writeoffset,
3001 GLsizeiptr size) {
3002 BEFORE_GL_CALL;
3003 ASSERT_SYMBOL_PRESENT(fCopyBufferSubData);
3004 mSymbols.fCopyBufferSubData(readtarget, writetarget, readoffset,
3005 writeoffset, size);
3006 AFTER_GL_CALL;
3009 // -----------------------------------------------------------------------------
3010 // Core GL & Extension ARB_map_buffer_range
3011 public:
3012 void* fMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
3013 GLbitfield access) {
3014 void* data = nullptr;
3015 ASSERT_SYMBOL_PRESENT(fMapBufferRange);
3016 BEFORE_GL_CALL;
3017 data = mSymbols.fMapBufferRange(target, offset, length, access);
3018 OnSyncCall();
3019 AFTER_GL_CALL;
3020 return data;
3023 void fFlushMappedBufferRange(GLenum target, GLintptr offset,
3024 GLsizeiptr length) {
3025 ASSERT_SYMBOL_PRESENT(fFlushMappedBufferRange);
3026 BEFORE_GL_CALL;
3027 mSymbols.fFlushMappedBufferRange(target, offset, length);
3028 AFTER_GL_CALL;
3031 // -----------------------------------------------------------------------------
3032 // Core GL & Extension ARB_sampler_objects
3033 public:
3034 void fGenSamplers(GLsizei count, GLuint* samplers) {
3035 BEFORE_GL_CALL;
3036 ASSERT_SYMBOL_PRESENT(fGenSamplers);
3037 mSymbols.fGenSamplers(count, samplers);
3038 AFTER_GL_CALL;
3041 void fDeleteSamplers(GLsizei count, const GLuint* samplers) {
3042 BEFORE_GL_CALL;
3043 ASSERT_SYMBOL_PRESENT(fDeleteSamplers);
3044 mSymbols.fDeleteSamplers(count, samplers);
3045 AFTER_GL_CALL;
3048 realGLboolean fIsSampler(GLuint sampler) {
3049 realGLboolean result = false;
3050 BEFORE_GL_CALL;
3051 ASSERT_SYMBOL_PRESENT(fIsSampler);
3052 result = mSymbols.fIsSampler(sampler);
3053 OnSyncCall();
3054 AFTER_GL_CALL;
3055 return result;
3058 void fBindSampler(GLuint unit, GLuint sampler) {
3059 BEFORE_GL_CALL;
3060 ASSERT_SYMBOL_PRESENT(fBindSampler);
3061 mSymbols.fBindSampler(unit, sampler);
3062 AFTER_GL_CALL;
3065 void fSamplerParameteri(GLuint sampler, GLenum pname, GLint param) {
3066 BEFORE_GL_CALL;
3067 ASSERT_SYMBOL_PRESENT(fSamplerParameteri);
3068 mSymbols.fSamplerParameteri(sampler, pname, param);
3069 AFTER_GL_CALL;
3072 void fSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) {
3073 BEFORE_GL_CALL;
3074 ASSERT_SYMBOL_PRESENT(fSamplerParameteriv);
3075 mSymbols.fSamplerParameteriv(sampler, pname, param);
3076 AFTER_GL_CALL;
3079 void fSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) {
3080 BEFORE_GL_CALL;
3081 ASSERT_SYMBOL_PRESENT(fSamplerParameterf);
3082 mSymbols.fSamplerParameterf(sampler, pname, param);
3083 AFTER_GL_CALL;
3086 void fSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) {
3087 BEFORE_GL_CALL;
3088 ASSERT_SYMBOL_PRESENT(fSamplerParameterfv);
3089 mSymbols.fSamplerParameterfv(sampler, pname, param);
3090 AFTER_GL_CALL;
3093 void fGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) {
3094 BEFORE_GL_CALL;
3095 ASSERT_SYMBOL_PRESENT(fGetSamplerParameteriv);
3096 mSymbols.fGetSamplerParameteriv(sampler, pname, params);
3097 AFTER_GL_CALL;
3100 void fGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) {
3101 BEFORE_GL_CALL;
3102 ASSERT_SYMBOL_PRESENT(fGetSamplerParameterfv);
3103 mSymbols.fGetSamplerParameterfv(sampler, pname, params);
3104 AFTER_GL_CALL;
3107 // -----------------------------------------------------------------------------
3108 // Core GL & Extension ARB_uniform_buffer_object
3109 public:
3110 void fGetUniformIndices(GLuint program, GLsizei uniformCount,
3111 const GLchar* const* uniformNames,
3112 GLuint* uniformIndices) {
3113 ASSERT_SYMBOL_PRESENT(fGetUniformIndices);
3114 BEFORE_GL_CALL;
3115 mSymbols.fGetUniformIndices(program, uniformCount, uniformNames,
3116 uniformIndices);
3117 OnSyncCall();
3118 AFTER_GL_CALL;
3121 void fGetActiveUniformsiv(GLuint program, GLsizei uniformCount,
3122 const GLuint* uniformIndices, GLenum pname,
3123 GLint* params) {
3124 ASSERT_SYMBOL_PRESENT(fGetActiveUniformsiv);
3125 BEFORE_GL_CALL;
3126 mSymbols.fGetActiveUniformsiv(program, uniformCount, uniformIndices, pname,
3127 params);
3128 OnSyncCall();
3129 AFTER_GL_CALL;
3132 GLuint fGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) {
3133 GLuint result = 0;
3134 ASSERT_SYMBOL_PRESENT(fGetUniformBlockIndex);
3135 BEFORE_GL_CALL;
3136 result = mSymbols.fGetUniformBlockIndex(program, uniformBlockName);
3137 OnSyncCall();
3138 AFTER_GL_CALL;
3139 return result;
3142 void fGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex,
3143 GLenum pname, GLint* params) {
3144 ASSERT_SYMBOL_PRESENT(fGetActiveUniformBlockiv);
3145 BEFORE_GL_CALL;
3146 mSymbols.fGetActiveUniformBlockiv(program, uniformBlockIndex, pname,
3147 params);
3148 OnSyncCall();
3149 AFTER_GL_CALL;
3152 void fGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex,
3153 GLsizei bufSize, GLsizei* length,
3154 GLchar* uniformBlockName) {
3155 ASSERT_SYMBOL_PRESENT(fGetActiveUniformBlockName);
3156 BEFORE_GL_CALL;
3157 mSymbols.fGetActiveUniformBlockName(program, uniformBlockIndex, bufSize,
3158 length, uniformBlockName);
3159 OnSyncCall();
3160 AFTER_GL_CALL;
3163 void fUniformBlockBinding(GLuint program, GLuint uniformBlockIndex,
3164 GLuint uniformBlockBinding) {
3165 ASSERT_SYMBOL_PRESENT(fUniformBlockBinding);
3166 BEFORE_GL_CALL;
3167 mSymbols.fUniformBlockBinding(program, uniformBlockIndex,
3168 uniformBlockBinding);
3169 AFTER_GL_CALL;
3172 // -----------------------------------------------------------------------------
3173 // Core GL 4.2, GL ES 3.0 & Extension ARB_texture_storage/EXT_texture_storage
3174 void fTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat,
3175 GLsizei width, GLsizei height) {
3176 BEFORE_GL_CALL;
3177 ASSERT_SYMBOL_PRESENT(fTexStorage2D);
3178 mSymbols.fTexStorage2D(target, levels, internalformat, width, height);
3179 OnSyncCall();
3180 AFTER_GL_CALL;
3183 void fTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat,
3184 GLsizei width, GLsizei height, GLsizei depth) {
3185 BEFORE_GL_CALL;
3186 ASSERT_SYMBOL_PRESENT(fTexStorage3D);
3187 mSymbols.fTexStorage3D(target, levels, internalformat, width, height,
3188 depth);
3189 OnSyncCall();
3190 AFTER_GL_CALL;
3193 // -----------------------------------------------------------------------------
3194 // 3D Textures
3195 void fTexImage3D(GLenum target, GLint level, GLint internalFormat,
3196 GLsizei width, GLsizei height, GLsizei depth, GLint border,
3197 GLenum format, GLenum type, const GLvoid* data) {
3198 BEFORE_GL_CALL;
3199 ASSERT_SYMBOL_PRESENT(fTexImage3D);
3200 mSymbols.fTexImage3D(target, level, internalFormat, width, height, depth,
3201 border, format, type, data);
3202 OnSyncCall();
3203 AFTER_GL_CALL;
3206 void fTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
3207 GLint zoffset, GLsizei width, GLsizei height,
3208 GLsizei depth, GLenum format, GLenum type,
3209 const GLvoid* pixels) {
3210 BEFORE_GL_CALL;
3211 ASSERT_SYMBOL_PRESENT(fTexSubImage3D);
3212 mSymbols.fTexSubImage3D(target, level, xoffset, yoffset, zoffset, width,
3213 height, depth, format, type, pixels);
3214 OnSyncCall();
3215 AFTER_GL_CALL;
3218 void fCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset,
3219 GLint yoffset, GLint zoffset, GLint x, GLint y,
3220 GLsizei width, GLsizei height) {
3221 BeforeGLReadCall();
3222 BEFORE_GL_CALL;
3223 ASSERT_SYMBOL_PRESENT(fCopyTexSubImage3D);
3224 mSymbols.fCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y,
3225 width, height);
3226 AFTER_GL_CALL;
3227 AfterGLReadCall();
3230 void fCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat,
3231 GLsizei width, GLsizei height, GLsizei depth,
3232 GLint border, GLsizei imageSize,
3233 const GLvoid* data) {
3234 BEFORE_GL_CALL;
3235 ASSERT_SYMBOL_PRESENT(fCompressedTexImage3D);
3236 mSymbols.fCompressedTexImage3D(target, level, internalformat, width, height,
3237 depth, border, imageSize, data);
3238 AFTER_GL_CALL;
3241 void fCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
3242 GLint yoffset, GLint zoffset, GLsizei width,
3243 GLsizei height, GLsizei depth, GLenum format,
3244 GLsizei imageSize, const GLvoid* data) {
3245 BEFORE_GL_CALL;
3246 ASSERT_SYMBOL_PRESENT(fCompressedTexSubImage3D);
3247 mSymbols.fCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset,
3248 width, height, depth, format, imageSize,
3249 data);
3250 AFTER_GL_CALL;
3253 // -----------------------------------------------------------------------------
3254 // GL3+, ES3+
3256 const GLubyte* fGetStringi(GLenum name, GLuint index) {
3257 const GLubyte* ret = nullptr;
3258 BEFORE_GL_CALL;
3259 ASSERT_SYMBOL_PRESENT(fGetStringi);
3260 ret = mSymbols.fGetStringi(name, index);
3261 OnSyncCall();
3262 AFTER_GL_CALL;
3263 return ret;
3266 // -----------------------------------------------------------------------------
3267 // APPLE_framebuffer_multisample
3269 void fResolveMultisampleFramebufferAPPLE() {
3270 BEFORE_GL_CALL;
3271 ASSERT_SYMBOL_PRESENT(fResolveMultisampleFramebufferAPPLE);
3272 mSymbols.fResolveMultisampleFramebufferAPPLE();
3273 AFTER_GL_CALL;
3276 // -----------------------------------------------------------------------------
3277 // APPLE_fence
3279 void fFinishObjectAPPLE(GLenum object, GLint name) {
3280 BEFORE_GL_CALL;
3281 ASSERT_SYMBOL_PRESENT(fFinishObjectAPPLE);
3282 mSymbols.fFinishObjectAPPLE(object, name);
3283 AFTER_GL_CALL;
3286 realGLboolean fTestObjectAPPLE(GLenum object, GLint name) {
3287 realGLboolean ret = false;
3288 BEFORE_GL_CALL;
3289 ASSERT_SYMBOL_PRESENT(fTestObjectAPPLE);
3290 ret = mSymbols.fTestObjectAPPLE(object, name);
3291 AFTER_GL_CALL;
3292 return ret;
3295 // -----------------------------------------------------------------------------
3296 // prim_restart
3298 void fPrimitiveRestartIndex(GLuint index) {
3299 BEFORE_GL_CALL;
3300 ASSERT_SYMBOL_PRESENT(fPrimitiveRestartIndex);
3301 mSymbols.fPrimitiveRestartIndex(index);
3302 AFTER_GL_CALL;
3305 // -----------------------------------------------------------------------------
3306 // multiview
3308 void fFramebufferTextureMultiview(GLenum target, GLenum attachment,
3309 GLuint texture, GLint level,
3310 GLint baseViewIndex,
3311 GLsizei numViews) const {
3312 BEFORE_GL_CALL;
3313 ASSERT_SYMBOL_PRESENT(fFramebufferTextureMultiview);
3314 mSymbols.fFramebufferTextureMultiview(target, attachment, texture, level,
3315 baseViewIndex, numViews);
3316 AFTER_GL_CALL;
3319 #undef BEFORE_GL_CALL
3320 #undef AFTER_GL_CALL
3321 #undef ASSERT_SYMBOL_PRESENT
3322 // #undef TRACKING_CONTEXT // Needed in GLContext.cpp
3323 #undef ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL
3325 // -----------------------------------------------------------------------------
3326 // Constructor
3327 protected:
3328 explicit GLContext(const GLContextDesc&, GLContext* sharedContext = nullptr,
3329 bool canUseTLSIsCurrent = false);
3331 // -----------------------------------------------------------------------------
3332 // Destructor
3333 public:
3334 virtual ~GLContext();
3336 // Mark this context as destroyed. This will nullptr out all
3337 // the GL function pointers!
3338 void MarkDestroyed();
3340 protected:
3341 virtual void OnMarkDestroyed() {}
3343 // -----------------------------------------------------------------------------
3344 // Everything that isn't standard GL APIs
3345 protected:
3346 typedef gfx::SurfaceFormat SurfaceFormat;
3348 public:
3349 virtual void ReleaseSurface() {}
3351 bool IsDestroyed() const {
3352 // MarkDestroyed will mark all these as null.
3353 return mContextLost && mSymbols.fUseProgram == nullptr;
3356 GLContext* GetSharedContext() { return mSharedContext; }
3359 * Returns true if the thread on which this context was created is the
3360 * currently executing thread.
3362 bool IsOwningThreadCurrent();
3364 static void PlatformStartup();
3366 public:
3368 * If this context wraps a double-buffered target, swap the back
3369 * and front buffers. It should be assumed that after a swap, the
3370 * contents of the new back buffer are undefined.
3372 virtual bool SwapBuffers() { return false; }
3375 * Stores a damage region (in origin bottom left coordinates), which
3376 * makes the next SwapBuffers call do eglSwapBuffersWithDamage if supported.
3378 * Note that even if only part of the context is damaged, the entire buffer
3379 * needs to be filled with up-to-date contents. This region is only a hint
3380 * telling the system compositor which parts of the buffer were updated.
3382 virtual void SetDamage(const nsIntRegion& aDamageRegion) {}
3385 * Defines a two-dimensional texture image for context target surface
3387 virtual bool BindTexImage() { return false; }
3389 * Releases a color buffer that is being used as a texture
3391 virtual bool ReleaseTexImage() { return false; }
3393 virtual Maybe<SymbolLoader> GetSymbolLoader() const = 0;
3395 void BindFB(GLuint fb) {
3396 fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, fb);
3397 MOZ_GL_ASSERT(this, !fb || fIsFramebuffer(fb));
3400 void BindDrawFB(GLuint fb) {
3401 fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT, fb);
3404 void BindReadFB(GLuint fb) {
3405 fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT, fb);
3408 GLuint GetDrawFB() const {
3409 return GetIntAs<GLuint>(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT);
3412 GLuint GetReadFB() const {
3413 auto bindEnum = LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT;
3414 if (!IsSupported(GLFeature::split_framebuffer)) {
3415 bindEnum = LOCAL_GL_FRAMEBUFFER_BINDING;
3417 return GetIntAs<GLuint>(bindEnum);
3420 GLuint GetFB() const {
3421 const auto ret = GetDrawFB();
3422 MOZ_ASSERT(ret == GetReadFB());
3423 return ret;
3426 private:
3427 void GetShaderPrecisionFormatNonES2(GLenum shadertype, GLenum precisiontype,
3428 GLint* range, GLint* precision) {
3429 switch (precisiontype) {
3430 case LOCAL_GL_LOW_FLOAT:
3431 case LOCAL_GL_MEDIUM_FLOAT:
3432 case LOCAL_GL_HIGH_FLOAT:
3433 // Assume IEEE 754 precision
3434 range[0] = 127;
3435 range[1] = 127;
3436 *precision = 23;
3437 break;
3438 case LOCAL_GL_LOW_INT:
3439 case LOCAL_GL_MEDIUM_INT:
3440 case LOCAL_GL_HIGH_INT:
3441 // Some (most) hardware only supports single-precision floating-point
3442 // numbers, which can accurately represent integers up to +/-16777216
3443 range[0] = 24;
3444 range[1] = 24;
3445 *precision = 0;
3446 break;
3450 public:
3451 virtual GLenum GetPreferredARGB32Format() const { return LOCAL_GL_RGBA; }
3453 virtual GLenum GetPreferredEGLImageTextureTarget() const {
3454 #ifdef MOZ_WAYLAND
3455 return LOCAL_GL_TEXTURE_2D;
3456 #else
3457 return IsExtensionSupported(OES_EGL_image_external)
3458 ? LOCAL_GL_TEXTURE_EXTERNAL
3459 : LOCAL_GL_TEXTURE_2D;
3460 #endif
3463 virtual bool RenewSurface(widget::CompositorWidget* aWidget) { return false; }
3465 // Shared code for GL extensions and GLX extensions.
3466 static bool ListHasExtension(const GLubyte* extensions,
3467 const char* extension);
3469 public:
3470 enum {
3471 DebugFlagEnabled = 1 << 0,
3472 DebugFlagTrace = 1 << 1,
3473 DebugFlagAbortOnError = 1 << 2
3476 const uint8_t mDebugFlags;
3477 static uint8_t ChooseDebugFlags(CreateContextFlags createFlags);
3479 protected:
3480 RefPtr<GLContext> mSharedContext;
3482 // The thread id which this context was created.
3483 PlatformThreadId mOwningThreadId;
3485 GLContextSymbols mSymbols = {};
3487 UniquePtr<GLBlitHelper> mBlitHelper;
3488 UniquePtr<GLReadTexImageHelper> mReadTexImageHelper;
3490 public:
3491 GLBlitHelper* BlitHelper();
3492 GLBlitTextureImageHelper* BlitTextureImageHelper();
3493 GLReadTexImageHelper* ReadTexImageHelper();
3495 // Assumes shares are created by all sharing with the same global context.
3496 bool SharesWith(const GLContext* other) const {
3497 MOZ_ASSERT(!this->mSharedContext || !this->mSharedContext->mSharedContext);
3498 MOZ_ASSERT(!other->mSharedContext ||
3499 !other->mSharedContext->mSharedContext);
3500 MOZ_ASSERT(!this->mSharedContext || !other->mSharedContext ||
3501 this->mSharedContext == other->mSharedContext);
3503 const GLContext* thisShared =
3504 this->mSharedContext ? this->mSharedContext : this;
3505 const GLContext* otherShared =
3506 other->mSharedContext ? other->mSharedContext : other;
3508 return thisShared == otherShared;
3511 bool IsFramebufferComplete(GLuint fb, GLenum* status = nullptr);
3513 // Does not check completeness.
3514 void AttachBuffersToFB(GLuint colorTex, GLuint colorRB, GLuint depthRB,
3515 GLuint stencilRB, GLuint fb,
3516 GLenum target = LOCAL_GL_TEXTURE_2D);
3518 // Passing null is fine if the value you'd get is 0.
3519 bool AssembleOffscreenFBs(const GLuint colorMSRB, const GLuint depthRB,
3520 const GLuint stencilRB, const GLuint texture,
3521 GLuint* drawFB, GLuint* readFB);
3523 protected:
3524 SharedSurface* mLockedSurface = nullptr;
3526 public:
3527 void LockSurface(SharedSurface* surf) { mLockedSurface = surf; }
3529 void UnlockSurface(SharedSurface* surf) {
3530 MOZ_ASSERT(mLockedSurface == surf);
3531 mLockedSurface = nullptr;
3534 SharedSurface* GetLockedSurface() const { return mLockedSurface; }
3536 bool IsOffscreen() const { return mDesc.isOffscreen; }
3538 bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; }
3540 bool IsOffscreenSizeAllowed(const gfx::IntSize& aSize) const;
3542 virtual bool Init();
3544 private:
3545 bool InitImpl();
3546 void LoadMoreSymbols(const SymbolLoader& loader);
3547 bool LoadExtSymbols(const SymbolLoader& loader, const SymLoadStruct* list,
3548 GLExtensions ext);
3549 bool LoadFeatureSymbols(const SymbolLoader& loader, const SymLoadStruct* list,
3550 GLFeature feature);
3552 protected:
3553 void InitExtensions();
3555 GLint mViewportRect[4] = {};
3556 GLint mScissorRect[4] = {};
3558 uint32_t mMaxTexOrRbSize = 0;
3559 GLint mMaxTextureSize = 0;
3560 GLint mMaxCubeMapTextureSize = 0;
3561 GLint mMaxRenderbufferSize = 0;
3562 GLint mMaxViewportDims[2] = {};
3563 GLsizei mMaxSamples = 0;
3564 bool mNeedsTextureSizeChecks = false;
3565 bool mNeedsFlushBeforeDeleteFB = false;
3566 bool mTextureAllocCrashesOnMapFailure = false;
3567 bool mNeedsCheckAfterAttachTextureToFb = false;
3568 const bool mWorkAroundDriverBugs;
3569 mutable uint64_t mSyncGLCallCount = 0;
3571 bool IsTextureSizeSafeToPassToDriver(GLenum target, GLsizei width,
3572 GLsizei height) const {
3573 if (mNeedsTextureSizeChecks) {
3574 // some drivers incorrectly handle some large texture sizes that are below
3575 // the max texture size that they report. So we check ourselves against
3576 // our own values (mMax[CubeMap]TextureSize). see bug 737182 for Mac Intel
3577 // 2D textures see bug 684882 for Mac Intel cube map textures see bug
3578 // 814716 for Mesa Nouveau
3579 GLsizei maxSize =
3580 target == LOCAL_GL_TEXTURE_CUBE_MAP ||
3581 (target >= LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
3582 target <= LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
3583 ? mMaxCubeMapTextureSize
3584 : mMaxTextureSize;
3585 return width <= maxSize && height <= maxSize;
3587 return true;
3590 public:
3591 auto MaxSamples() const { return uint32_t(mMaxSamples); }
3592 auto MaxTextureSize() const { return uint32_t(mMaxTextureSize); }
3593 auto MaxRenderbufferSize() const { return uint32_t(mMaxRenderbufferSize); }
3594 auto MaxTexOrRbSize() const { return mMaxTexOrRbSize; }
3596 #ifdef MOZ_GL_DEBUG
3597 void CreatedProgram(GLContext* aOrigin, GLuint aName);
3598 void CreatedShader(GLContext* aOrigin, GLuint aName);
3599 void CreatedBuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
3600 void CreatedQueries(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
3601 void CreatedTextures(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
3602 void CreatedFramebuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
3603 void CreatedRenderbuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
3604 void DeletedProgram(GLContext* aOrigin, GLuint aName);
3605 void DeletedShader(GLContext* aOrigin, GLuint aName);
3606 void DeletedBuffers(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames);
3607 void DeletedQueries(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames);
3608 void DeletedTextures(GLContext* aOrigin, GLsizei aCount,
3609 const GLuint* aNames);
3610 void DeletedFramebuffers(GLContext* aOrigin, GLsizei aCount,
3611 const GLuint* aNames);
3612 void DeletedRenderbuffers(GLContext* aOrigin, GLsizei aCount,
3613 const GLuint* aNames);
3615 void SharedContextDestroyed(GLContext* aChild);
3616 void ReportOutstandingNames();
3618 struct NamedResource {
3619 NamedResource() : origin(nullptr), name(0), originDeleted(false) {}
3621 NamedResource(GLContext* aOrigin, GLuint aName)
3622 : origin(aOrigin), name(aName), originDeleted(false) {}
3624 GLContext* origin;
3625 GLuint name;
3626 bool originDeleted;
3628 // for sorting
3629 bool operator<(const NamedResource& aOther) const {
3630 if (intptr_t(origin) < intptr_t(aOther.origin)) return true;
3631 if (name < aOther.name) return true;
3632 return false;
3634 bool operator==(const NamedResource& aOther) const {
3635 return origin == aOther.origin && name == aOther.name &&
3636 originDeleted == aOther.originDeleted;
3640 nsTArray<NamedResource> mTrackedPrograms;
3641 nsTArray<NamedResource> mTrackedShaders;
3642 nsTArray<NamedResource> mTrackedTextures;
3643 nsTArray<NamedResource> mTrackedFramebuffers;
3644 nsTArray<NamedResource> mTrackedRenderbuffers;
3645 nsTArray<NamedResource> mTrackedBuffers;
3646 nsTArray<NamedResource> mTrackedQueries;
3647 #endif
3649 protected:
3650 bool mHeavyGLCallsSinceLastFlush = false;
3652 public:
3653 void FlushIfHeavyGLCallsSinceLastFlush();
3654 static bool ShouldSpew();
3655 static bool ShouldDumpExts();
3657 // --
3659 void TexParams_SetClampNoMips(GLenum target = LOCAL_GL_TEXTURE_2D) {
3660 fTexParameteri(target, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
3661 fTexParameteri(target, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
3662 fTexParameteri(target, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_NEAREST);
3663 fTexParameteri(target, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_NEAREST);
3666 // --
3668 GLuint CreateFramebuffer() {
3669 GLuint x = 0;
3670 fGenFramebuffers(1, &x);
3671 return x;
3673 GLuint CreateRenderbuffer() {
3674 GLuint x = 0;
3675 fGenRenderbuffers(1, &x);
3676 return x;
3678 GLuint CreateTexture() {
3679 GLuint x = 0;
3680 fGenTextures(1, &x);
3681 return x;
3684 void DeleteFramebuffer(const GLuint x) { fDeleteFramebuffers(1, &x); }
3685 void DeleteRenderbuffer(const GLuint x) { fDeleteRenderbuffers(1, &x); }
3686 void DeleteTexture(const GLuint x) { fDeleteTextures(1, &x); }
3689 bool DoesStringMatch(const char* aString, const char* aWantedString);
3691 void SplitByChar(const nsACString& str, const char delim,
3692 std::vector<nsCString>* const out);
3694 template <size_t N>
3695 bool MarkBitfieldByString(const nsACString& str,
3696 const char* const (&markStrList)[N],
3697 std::bitset<N>* const out_markList) {
3698 for (size_t i = 0; i < N; i++) {
3699 if (str.Equals(markStrList[i])) {
3700 (*out_markList)[i] = 1;
3701 return true;
3704 return false;
3707 template <size_t N>
3708 void MarkBitfieldByStrings(const std::vector<nsCString>& strList,
3709 bool dumpStrings,
3710 const char* const (&markStrList)[N],
3711 std::bitset<N>* const out_markList) {
3712 for (auto itr = strList.begin(); itr != strList.end(); ++itr) {
3713 const nsACString& str = *itr;
3714 const bool wasMarked = MarkBitfieldByString(str, markStrList, out_markList);
3715 if (dumpStrings)
3716 printf_stderr(" %s%s\n", str.BeginReading(), wasMarked ? "(*)" : "");
3720 // -
3722 class Renderbuffer final {
3723 public:
3724 const WeakPtr<GLContext> weakGl;
3725 const GLuint name;
3727 private:
3728 static GLuint Create(GLContext& gl) {
3729 GLuint ret = 0;
3730 gl.fGenRenderbuffers(1, &ret);
3731 return ret;
3734 public:
3735 explicit Renderbuffer(GLContext& gl) : weakGl(&gl), name(Create(gl)) {}
3737 ~Renderbuffer() {
3738 const RefPtr<GLContext> gl = weakGl.get();
3739 if (!gl || !gl->MakeCurrent()) return;
3740 gl->fDeleteRenderbuffers(1, &name);
3744 // -
3746 class Texture final {
3747 public:
3748 const WeakPtr<GLContext> weakGl;
3749 const GLuint name;
3751 private:
3752 static GLuint Create(GLContext& gl) {
3753 GLuint ret = 0;
3754 gl.fGenTextures(1, &ret);
3755 return ret;
3758 public:
3759 explicit Texture(GLContext& gl) : weakGl(&gl), name(Create(gl)) {}
3761 ~Texture() {
3762 const RefPtr<GLContext> gl = weakGl.get();
3763 if (!gl || !gl->MakeCurrent()) return;
3764 gl->fDeleteTextures(1, &name);
3769 * Helper function that creates a 2D texture aSize.width x aSize.height with
3770 * storage type specified by aFormats. Returns GL texture object id.
3772 * See mozilla::gl::CreateTexture.
3774 UniquePtr<Texture> CreateTexture(GLContext&, const gfx::IntSize& size);
3777 * Helper function that calculates the number of bytes required per
3778 * texel for a texture from its format and type.
3780 uint32_t GetBytesPerTexel(GLenum format, GLenum type);
3782 } /* namespace gl */
3783 } /* namespace mozilla */
3785 #endif /* GLCONTEXT_H_ */