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/. */
26 // Define MOZ_GL_DEBUG unconditionally to enable GL debugging in opt
29 # define MOZ_GL_DEBUG 1
32 #include "mozilla/RefPtr.h"
33 #include "mozilla/UniquePtr.h"
34 #include "mozilla/ThreadLocal.h"
36 #include "MozFramebuffer.h"
39 #include "GLLibraryLoader.h"
40 #include "nsISupportsImpl.h"
41 #include "nsRegionFwd.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"
55 class DataSourceSurface
;
61 class GLBlitTextureImageHelper
;
64 class GLReadTexImageHelper
;
69 class ColorTextureLayerProgram
;
73 class CompositorWidget
;
75 } // namespace mozilla
80 enum class GLFeature
{
91 EXT_color_buffer_float
,
95 framebuffer_multisample
,
97 framebuffer_object_EXT_OES
,
99 get_integer64_indexed
,
100 get_query_object_i64v
,
104 instanced_non_arrays
,
105 internalformat_query
,
106 invalidate_framebuffer
,
110 occlusion_query_boolean
,
112 packed_depth_stencil
,
119 renderbuffer_color_float
,
120 renderbuffer_color_half_float
,
121 robust_buffer_access_behavior
,
125 seamless_cube_map_opt_in
,
128 standard_derivatives
,
131 texture_3D_compressed
,
133 texture_compression_bptc
,
134 texture_compression_rgtc
,
136 texture_float_linear
,
138 texture_half_float_linear
,
139 texture_non_power_of_two
,
145 uniform_buffer_object
,
146 uniform_matrix_nonsquare
,
151 enum class ContextProfile
: uint8_t {
158 enum class GLVendor
{
171 enum class GLRenderer
{
189 MicrosoftBasicRenderDriver
,
193 class GLContext
: public GenericAtomicRefCounted
, public SupportsWeakPtr
{
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
;
207 explicit TlsScope(GLContext
* const gl
)
208 : mGL(gl
), mWasTlsOk(gl
&& gl
->mUseTLSIsCurrent
) {
210 mGL
->mUseTLSIsCurrent
= true;
216 mGL
->mUseTLSIsCurrent
= mWasTlsOk
;
221 // -----------------------------------------------------------------------------
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
) {
273 return profile
== mProfile
;
277 * Return the version of the context.
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
;
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
362 AMD_compressed_ATC_texture
,
364 ANGLE_framebuffer_blit
,
365 ANGLE_framebuffer_multisample
,
366 ANGLE_instanced_arrays
,
368 ANGLE_texture_compression_dxt3
,
369 ANGLE_texture_compression_dxt5
,
371 APPLE_client_storage
,
373 APPLE_framebuffer_multisample
,
376 APPLE_vertex_array_object
,
377 ARB_ES2_compatibility
,
378 ARB_ES3_compatibility
,
379 ARB_color_buffer_float
,
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
,
398 ARB_seamless_cube_map
,
399 ARB_shader_texture_lod
,
401 ARB_texture_compression
,
402 ARB_texture_compression_bptc
,
403 ARB_texture_compression_rgtc
,
405 ARB_texture_non_power_of_two
,
406 ARB_texture_rectangle
,
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
,
418 EXT_color_buffer_float
,
419 EXT_color_buffer_half_float
,
421 EXT_disjoint_timer_query
,
427 EXT_framebuffer_blit
,
428 EXT_framebuffer_multisample
,
429 EXT_framebuffer_object
,
430 EXT_framebuffer_sRGB
,
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
,
439 EXT_sRGB_write_control
,
440 EXT_shader_texture_lod
,
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
,
453 EXT_transform_feedback
,
456 IMG_texture_compression_pvrtc
,
459 KHR_parallel_shader_compile
,
460 KHR_robust_buffer_access_behavior
,
462 KHR_texture_compression_astc_hdr
,
463 KHR_texture_compression_astc_ldr
,
467 NV_geometry_program4
,
470 NV_primitive_restart
,
472 NV_transform_feedback
,
473 NV_transform_feedback2
,
475 OES_EGL_image_external
,
477 OES_compressed_ETC1_RGB8_texture
,
481 OES_element_index_uint
,
482 OES_fbo_render_mipmap
,
483 OES_framebuffer_object
,
484 OES_packed_depth_stencil
,
486 OES_standard_derivatives
,
490 OES_texture_float_linear
,
491 OES_texture_half_float
,
492 OES_texture_half_float_linear
,
494 OES_vertex_array_object
,
500 bool IsExtensionSupported(GLExtensions aKnownExtension
) const {
501 return mAvailableExtensions
[aKnownExtension
];
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 // -----------------------------------------------------------------------------
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
523 bool IsSupported(GLFeature feature
) const {
524 return mAvailableFeatures
[size_t(feature
)];
527 static const char* GetFeatureName(GLFeature feature
);
530 std::bitset
<size_t(GLFeature::EnumMax
)> mAvailableFeatures
;
533 * Init features regarding OpenGL extension and context version and profile
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 // -----------------------------------------------------------------------------
551 mutable bool mContextLost
= false;
552 mutable GLenum mTopError
= 0;
555 void OnContextLostError() const;
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
;
567 mutable std::stack
<const LocalErrorScope
*> mLocalErrorScopeStack
;
568 mutable UniquePtr
<LocalErrorScope
> mDebugErrorScope
;
570 ////////////////////////////////////
571 // Use this safer option.
574 class LocalErrorScope
{
575 const GLContext
& mGL
;
577 bool mHasBeenChecked
;
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.
588 MOZ_ASSERT(!mHasBeenChecked
);
589 mHasBeenChecked
= true;
591 const auto ret
= mGL
.GetError();
592 if (ret
== LOCAL_GL_CONTEXT_LOST
) return 0;
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
;
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
);
624 static void GLAPIENTRY
StaticDebugCallback(GLenum source
, GLenum type
,
625 GLuint id
, GLenum severity
,
627 const GLchar
* message
,
628 const GLvoid
* userParam
);
630 // -----------------------------------------------------------------------------
631 // MOZ_GL_DEBUG implementation
633 #ifndef MOZ_FUNCTION_NAME
635 # define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__
636 # elif defined(_MSC_VER)
637 # define MOZ_FUNCTION_NAME __FUNCTION__
639 # define MOZ_FUNCTION_NAME \
640 __func__ // defined in C99, supported in various C++ compilers. Just raw
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);
649 # define ANDROID_ONLY_PROFILER_LABEL
652 #define BEFORE_GL_CALL \
653 ANDROID_ONLY_PROFILER_LABEL \
654 if (MOZ_LIKELY(BeforeGLCall(MOZ_FUNCTION_NAME))) { \
658 #define AFTER_GL_CALL \
659 AfterGLCall(MOZ_FUNCTION_NAME); \
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())) {
672 OnImplicitMakeCurrentFailure(funcName
);
677 MOZ_GL_ASSERT(this, IsCurrentImpl());
679 if (MOZ_UNLIKELY(mDebugFlags
)) {
680 BeforeGLCall_Debug(funcName
);
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
;
697 static void AssertNotPassingStackBufferToTheGL(const void* ptr
);
701 # define TRACKING_CONTEXT(a) \
703 TrackingContext()->a; \
706 # define ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(ptr) \
707 AssertNotPassingStackBufferToTheGL(ptr)
709 # define ASSERT_SYMBOL_PRESENT(func) \
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", \
716 MOZ_CRASH("GFX: Uninitialized GL function"); \
720 #else // ifdef MOZ_GL_DEBUG
722 # define TRACKING_CONTEXT(a) \
725 # define ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(ptr) \
728 # define ASSERT_SYMBOL_PRESENT(func) \
732 #endif // ifdef MOZ_GL_DEBUG
734 // Do whatever setup is necessary to draw to our offscreen FBO, if it's
736 void BeforeGLDrawCall() {}
738 // Do whatever tear-down is necessary after drawing to our offscreen FBO,
740 void AfterGLDrawCall() { mHeavyGLCallsSinceLastFlush
= true; }
742 // Do whatever setup is necessary to read from our offscreen FBO, if it's
744 void BeforeGLReadCall() {}
746 // Do whatever tear-down is necessary after reading from our offscreen FBO,
748 void AfterGLReadCall() {}
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
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;
772 void fActiveTexture(GLenum texture
) {
774 mSymbols
.fActiveTexture(texture
);
778 void fAttachShader(GLuint program
, GLuint shader
) {
780 mSymbols
.fAttachShader(program
, shader
);
784 void fBeginQuery(GLenum target
, GLuint id
) {
786 ASSERT_SYMBOL_PRESENT(fBeginQuery
);
787 mSymbols
.fBeginQuery(target
, id
);
791 void fBindAttribLocation(GLuint program
, GLuint index
, const GLchar
* name
) {
793 mSymbols
.fBindAttribLocation(program
, index
, name
);
797 void fBindBuffer(GLenum target
, GLuint buffer
) {
799 mSymbols
.fBindBuffer(target
, buffer
);
803 void fInvalidateFramebuffer(GLenum target
, GLsizei numAttachments
,
804 const GLenum
* attachments
) {
807 ASSERT_SYMBOL_PRESENT(fInvalidateFramebuffer
);
808 mSymbols
.fInvalidateFramebuffer(target
, numAttachments
, attachments
);
813 void fInvalidateSubFramebuffer(GLenum target
, GLsizei numAttachments
,
814 const GLenum
* attachments
, GLint x
, GLint y
,
815 GLsizei width
, GLsizei height
) {
818 ASSERT_SYMBOL_PRESENT(fInvalidateSubFramebuffer
);
819 mSymbols
.fInvalidateSubFramebuffer(target
, numAttachments
, attachments
, x
,
825 void fBindTexture(GLenum target
, GLuint texture
) {
827 mSymbols
.fBindTexture(target
, texture
);
831 void fBlendColor(GLfloat red
, GLfloat green
, GLfloat blue
, GLfloat alpha
) {
833 mSymbols
.fBlendColor(red
, green
, blue
, alpha
);
837 void fBlendEquation(GLenum mode
) {
839 mSymbols
.fBlendEquation(mode
);
843 void fBlendEquationSeparate(GLenum modeRGB
, GLenum modeAlpha
) {
845 mSymbols
.fBlendEquationSeparate(modeRGB
, modeAlpha
);
849 void fBlendFunc(GLenum sfactor
, GLenum dfactor
) {
851 mSymbols
.fBlendFunc(sfactor
, dfactor
);
855 void fBlendFuncSeparate(GLenum sfactorRGB
, GLenum dfactorRGB
,
856 GLenum sfactorAlpha
, GLenum dfactorAlpha
) {
858 mSymbols
.fBlendFuncSeparate(sfactorRGB
, dfactorRGB
, sfactorAlpha
,
864 void raw_fBufferData(GLenum target
, GLsizeiptr size
, const GLvoid
* data
,
866 ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(data
);
868 mSymbols
.fBufferData(target
, size
, data
, usage
);
871 mHeavyGLCallsSinceLastFlush
= true;
875 void fBufferData(GLenum target
, GLsizeiptr size
, const GLvoid
* data
,
877 raw_fBufferData(target
, size
, data
, usage
);
880 if (WorkAroundDriverBugs() && !data
&& Vendor() == GLVendor::NVIDIA
) {
881 UniquePtr
<char[]> buf
= MakeUnique
<char[]>(1);
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
);
891 mSymbols
.fBufferSubData(target
, offset
, size
, data
);
893 mHeavyGLCallsSinceLastFlush
= true;
897 void raw_fClear(GLbitfield mask
) {
899 mSymbols
.fClear(mask
);
904 void fClear(GLbitfield mask
) {
910 void fClearBufferfi(GLenum buffer
, GLint drawbuffer
, GLfloat depth
,
914 mSymbols
.fClearBufferfi(buffer
, drawbuffer
, depth
, stencil
);
919 void fClearBufferfv(GLenum buffer
, GLint drawbuffer
, const GLfloat
* value
) {
922 mSymbols
.fClearBufferfv(buffer
, drawbuffer
, value
);
927 void fClearBufferiv(GLenum buffer
, GLint drawbuffer
, const GLint
* value
) {
930 mSymbols
.fClearBufferiv(buffer
, drawbuffer
, value
);
935 void fClearBufferuiv(GLenum buffer
, GLint drawbuffer
, const GLuint
* value
) {
938 mSymbols
.fClearBufferuiv(buffer
, drawbuffer
, value
);
943 void fClearColor(GLfloat r
, GLfloat g
, GLfloat b
, GLfloat a
) {
945 mSymbols
.fClearColor(r
, g
, b
, a
);
949 void fClearStencil(GLint s
) {
951 mSymbols
.fClearStencil(s
);
955 void fClientActiveTexture(GLenum texture
) {
957 mSymbols
.fClientActiveTexture(texture
);
961 void fColorMask(realGLboolean red
, realGLboolean green
, realGLboolean blue
,
962 realGLboolean alpha
) {
964 mSymbols
.fColorMask(red
, green
, blue
, alpha
);
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
);
973 mSymbols
.fCompressedTexImage2D(target
, level
, internalformat
, width
, height
,
974 border
, imageSize
, pixels
);
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
);
985 mSymbols
.fCompressedTexSubImage2D(target
, level
, xoffset
, yoffset
, width
,
986 height
, format
, imageSize
, pixels
);
988 mHeavyGLCallsSinceLastFlush
= true;
991 void fCopyTexImage2D(GLenum target
, GLint level
, GLenum internalformat
,
992 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
995 void fCopyTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
996 GLint yoffset
, GLint x
, GLint y
, GLsizei width
,
999 raw_fCopyTexSubImage2D(target
, level
, xoffset
, yoffset
, x
, y
, width
,
1004 void fCullFace(GLenum mode
) {
1006 mSymbols
.fCullFace(mode
);
1010 void fDebugMessageCallback(GLDEBUGPROC callback
, const GLvoid
* userParam
) {
1012 ASSERT_SYMBOL_PRESENT(fDebugMessageCallback
);
1013 mSymbols
.fDebugMessageCallback(callback
, userParam
);
1017 void fDebugMessageControl(GLenum source
, GLenum type
, GLenum severity
,
1018 GLsizei count
, const GLuint
* ids
,
1019 realGLboolean enabled
) {
1021 ASSERT_SYMBOL_PRESENT(fDebugMessageControl
);
1022 mSymbols
.fDebugMessageControl(source
, type
, severity
, count
, ids
, enabled
);
1026 void fDebugMessageInsert(GLenum source
, GLenum type
, GLuint id
,
1027 GLenum severity
, GLsizei length
, const GLchar
* buf
) {
1029 ASSERT_SYMBOL_PRESENT(fDebugMessageInsert
);
1030 mSymbols
.fDebugMessageInsert(source
, type
, id
, severity
, length
, buf
);
1034 void fDetachShader(GLuint program
, GLuint shader
) {
1036 mSymbols
.fDetachShader(program
, shader
);
1040 void fDepthFunc(GLenum func
) {
1042 mSymbols
.fDepthFunc(func
);
1046 void fDepthMask(realGLboolean flag
) {
1048 mSymbols
.fDepthMask(flag
);
1052 void fDisable(GLenum capability
) {
1054 mSymbols
.fDisable(capability
);
1058 void fDisableClientState(GLenum capability
) {
1060 mSymbols
.fDisableClientState(capability
);
1064 void fDisableVertexAttribArray(GLuint index
) {
1066 mSymbols
.fDisableVertexAttribArray(index
);
1070 void fDrawBuffer(GLenum mode
) {
1072 mSymbols
.fDrawBuffer(mode
);
1077 void raw_fDrawArrays(GLenum mode
, GLint first
, GLsizei count
) {
1079 mSymbols
.fDrawArrays(mode
, first
, count
);
1083 void raw_fDrawElements(GLenum mode
, GLsizei count
, GLenum type
,
1084 const GLvoid
* indices
) {
1086 mSymbols
.fDrawElements(mode
, count
, type
, indices
);
1091 void fDrawArrays(GLenum mode
, GLint first
, GLsizei count
) {
1093 raw_fDrawArrays(mode
, first
, count
);
1097 void fDrawElements(GLenum mode
, GLsizei count
, GLenum type
,
1098 const GLvoid
* indices
) {
1100 raw_fDrawElements(mode
, count
, type
, indices
);
1104 void fEnable(GLenum capability
) {
1106 mSymbols
.fEnable(capability
);
1110 void fEnableClientState(GLenum capability
) {
1112 mSymbols
.fEnableClientState(capability
);
1116 void fEnableVertexAttribArray(GLuint index
) {
1118 mSymbols
.fEnableVertexAttribArray(index
);
1122 void fEndQuery(GLenum target
) {
1124 ASSERT_SYMBOL_PRESENT(fEndQuery
);
1125 mSymbols
.fEndQuery(target
);
1134 mHeavyGLCallsSinceLastFlush
= false;
1141 mHeavyGLCallsSinceLastFlush
= false;
1144 void fFrontFace(GLenum face
) {
1146 mSymbols
.fFrontFace(face
);
1150 void fGetActiveAttrib(GLuint program
, GLuint index
, GLsizei maxLength
,
1151 GLsizei
* length
, GLint
* size
, GLenum
* type
,
1154 mSymbols
.fGetActiveAttrib(program
, index
, maxLength
, length
, size
, type
,
1160 void fGetActiveUniform(GLuint program
, GLuint index
, GLsizei maxLength
,
1161 GLsizei
* length
, GLint
* size
, GLenum
* type
,
1164 mSymbols
.fGetActiveUniform(program
, index
, maxLength
, length
, size
, type
,
1170 void fGetAttachedShaders(GLuint program
, GLsizei maxCount
, GLsizei
* count
,
1173 mSymbols
.fGetAttachedShaders(program
, maxCount
, count
, shaders
);
1178 GLint
fGetAttribLocation(GLuint program
, const GLchar
* name
) {
1181 retval
= mSymbols
.fGetAttribLocation(program
, name
);
1188 void raw_fGetIntegerv(GLenum pname
, GLint
* params
) const {
1190 mSymbols
.fGetIntegerv(pname
, params
);
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.");
1212 fGetIntegerv(pname
, (GLint
*)&ret
);
1216 void fGetFloatv(GLenum pname
, GLfloat
* params
) const {
1218 mSymbols
.fGetFloatv(pname
, params
);
1223 void fGetBooleanv(GLenum pname
, realGLboolean
* params
) const {
1225 mSymbols
.fGetBooleanv(pname
, params
);
1230 void fGetBufferParameteriv(GLenum target
, GLenum pname
, GLint
* params
) {
1232 mSymbols
.fGetBufferParameteriv(target
, pname
, params
);
1237 GLuint
fGetDebugMessageLog(GLuint count
, GLsizei bufsize
, GLenum
* sources
,
1238 GLenum
* types
, GLuint
* ids
, GLenum
* severities
,
1239 GLsizei
* lengths
, GLchar
* messageLog
) {
1242 ASSERT_SYMBOL_PRESENT(fGetDebugMessageLog
);
1243 ret
= mSymbols
.fGetDebugMessageLog(count
, bufsize
, sources
, types
, ids
,
1244 severities
, lengths
, messageLog
);
1250 void fGetPointerv(GLenum pname
, GLvoid
** params
) {
1252 ASSERT_SYMBOL_PRESENT(fGetPointerv
);
1253 mSymbols
.fGetPointerv(pname
, params
);
1258 void fGetObjectLabel(GLenum identifier
, GLuint name
, GLsizei bufSize
,
1259 GLsizei
* length
, GLchar
* label
) {
1261 ASSERT_SYMBOL_PRESENT(fGetObjectLabel
);
1262 mSymbols
.fGetObjectLabel(identifier
, name
, bufSize
, length
, label
);
1267 void fGetObjectPtrLabel(const GLvoid
* ptr
, GLsizei bufSize
, GLsizei
* length
,
1270 ASSERT_SYMBOL_PRESENT(fGetObjectPtrLabel
);
1271 mSymbols
.fGetObjectPtrLabel(ptr
, bufSize
, length
, label
);
1276 void fGenerateMipmap(GLenum target
) {
1278 mSymbols
.fGenerateMipmap(target
);
1282 void fGetProgramiv(GLuint program
, GLenum pname
, GLint
* param
) {
1284 mSymbols
.fGetProgramiv(program
, pname
, param
);
1289 void fGetProgramInfoLog(GLuint program
, GLsizei bufSize
, GLsizei
* length
,
1292 mSymbols
.fGetProgramInfoLog(program
, bufSize
, length
, infoLog
);
1297 void fTexParameteri(GLenum target
, GLenum pname
, GLint param
) {
1299 mSymbols
.fTexParameteri(target
, pname
, param
);
1303 void fTexParameteriv(GLenum target
, GLenum pname
, const GLint
* params
) {
1305 mSymbols
.fTexParameteriv(target
, pname
, params
);
1309 void fTexParameterf(GLenum target
, GLenum pname
, GLfloat param
) {
1311 mSymbols
.fTexParameterf(target
, pname
, param
);
1315 const GLubyte
* fGetString(GLenum name
) {
1316 const GLubyte
* result
= nullptr;
1318 result
= mSymbols
.fGetString(name
);
1324 void fGetTexImage(GLenum target
, GLint level
, GLenum format
, GLenum type
,
1327 ASSERT_SYMBOL_PRESENT(fGetTexImage
);
1328 mSymbols
.fGetTexImage(target
, level
, format
, type
, img
);
1333 void fGetTexLevelParameteriv(GLenum target
, GLint level
, GLenum pname
,
1336 ASSERT_SYMBOL_PRESENT(fGetTexLevelParameteriv
);
1337 mSymbols
.fGetTexLevelParameteriv(target
, level
, pname
, params
);
1342 void fGetTexParameterfv(GLenum target
, GLenum pname
, GLfloat
* params
) {
1344 mSymbols
.fGetTexParameterfv(target
, pname
, params
);
1349 void fGetTexParameteriv(GLenum target
, GLenum pname
, GLint
* params
) {
1351 mSymbols
.fGetTexParameteriv(target
, pname
, params
);
1356 void fGetUniformfv(GLuint program
, GLint location
, GLfloat
* params
) {
1358 mSymbols
.fGetUniformfv(program
, location
, params
);
1363 void fGetUniformiv(GLuint program
, GLint location
, GLint
* params
) {
1365 mSymbols
.fGetUniformiv(program
, location
, params
);
1370 void fGetUniformuiv(GLuint program
, GLint location
, GLuint
* params
) {
1372 ASSERT_SYMBOL_PRESENT(fGetUniformuiv
);
1373 mSymbols
.fGetUniformuiv(program
, location
, params
);
1378 GLint
fGetUniformLocation(GLuint programObj
, const GLchar
* name
) {
1381 retval
= mSymbols
.fGetUniformLocation(programObj
, name
);
1387 void fGetVertexAttribfv(GLuint index
, GLenum pname
, GLfloat
* retval
) {
1389 mSymbols
.fGetVertexAttribfv(index
, pname
, retval
);
1394 void fGetVertexAttribiv(GLuint index
, GLenum pname
, GLint
* retval
) {
1396 mSymbols
.fGetVertexAttribiv(index
, pname
, retval
);
1401 void fGetVertexAttribPointerv(GLuint index
, GLenum pname
, GLvoid
** retval
) {
1403 mSymbols
.fGetVertexAttribPointerv(index
, pname
, retval
);
1408 void fHint(GLenum target
, GLenum mode
) {
1410 mSymbols
.fHint(target
, mode
);
1414 realGLboolean
fIsBuffer(GLuint buffer
) {
1415 realGLboolean retval
= false;
1417 retval
= mSymbols
.fIsBuffer(buffer
);
1423 realGLboolean
fIsEnabled(GLenum capability
) {
1424 realGLboolean retval
= false;
1426 retval
= mSymbols
.fIsEnabled(capability
);
1431 void SetEnabled(const GLenum cap
, const bool val
) {
1439 bool PushEnabled(const GLenum cap
, const bool newVal
) {
1440 const bool oldVal
= fIsEnabled(cap
);
1441 if (oldVal
!= newVal
) {
1442 SetEnabled(cap
, newVal
);
1447 realGLboolean
fIsProgram(GLuint program
) {
1448 realGLboolean retval
= false;
1450 retval
= mSymbols
.fIsProgram(program
);
1455 realGLboolean
fIsShader(GLuint shader
) {
1456 realGLboolean retval
= false;
1458 retval
= mSymbols
.fIsShader(shader
);
1463 realGLboolean
fIsTexture(GLuint texture
) {
1464 realGLboolean retval
= false;
1466 retval
= mSymbols
.fIsTexture(texture
);
1471 void fLineWidth(GLfloat width
) {
1473 mSymbols
.fLineWidth(width
);
1477 void fLinkProgram(GLuint program
) {
1479 mSymbols
.fLinkProgram(program
);
1483 void fObjectLabel(GLenum identifier
, GLuint name
, GLsizei length
,
1484 const GLchar
* label
) {
1486 ASSERT_SYMBOL_PRESENT(fObjectLabel
);
1487 mSymbols
.fObjectLabel(identifier
, name
, length
, label
);
1491 void fObjectPtrLabel(const GLvoid
* ptr
, GLsizei length
, const GLchar
* label
) {
1493 ASSERT_SYMBOL_PRESENT(fObjectPtrLabel
);
1494 mSymbols
.fObjectPtrLabel(ptr
, length
, label
);
1498 void fLoadIdentity() {
1500 mSymbols
.fLoadIdentity();
1504 void fLoadMatrixf(const GLfloat
* matrix
) {
1506 mSymbols
.fLoadMatrixf(matrix
);
1510 void fMatrixMode(GLenum mode
) {
1512 mSymbols
.fMatrixMode(mode
);
1516 void fPixelStorei(GLenum pname
, GLint param
) {
1518 mSymbols
.fPixelStorei(pname
, param
);
1522 void fTextureRangeAPPLE(GLenum target
, GLsizei length
, GLvoid
* pointer
) {
1523 ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pointer
);
1525 mSymbols
.fTextureRangeAPPLE(target
, length
, pointer
);
1529 void fPointParameterf(GLenum pname
, GLfloat param
) {
1531 mSymbols
.fPointParameterf(pname
, param
);
1535 void fPolygonMode(GLenum face
, GLenum mode
) {
1537 mSymbols
.fPolygonMode(face
, mode
);
1541 void fPolygonOffset(GLfloat factor
, GLfloat bias
) {
1543 mSymbols
.fPolygonOffset(factor
, bias
);
1547 void fPopDebugGroup() {
1549 ASSERT_SYMBOL_PRESENT(fPopDebugGroup
);
1550 mSymbols
.fPopDebugGroup();
1554 void fPushDebugGroup(GLenum source
, GLuint id
, GLsizei length
,
1555 const GLchar
* message
) {
1557 ASSERT_SYMBOL_PRESENT(fPushDebugGroup
);
1558 mSymbols
.fPushDebugGroup(source
, id
, length
, message
);
1562 void fReadBuffer(GLenum mode
) {
1564 mSymbols
.fReadBuffer(mode
);
1568 void raw_fReadPixels(GLint x
, GLint y
, GLsizei width
, GLsizei height
,
1569 GLenum format
, GLenum type
, GLvoid
* pixels
) {
1571 mSymbols
.fReadPixels(x
, y
, width
, height
, format
, type
, pixels
);
1574 mHeavyGLCallsSinceLastFlush
= true;
1577 void fReadPixels(GLint x
, GLint y
, GLsizei width
, GLsizei height
,
1578 GLenum format
, GLenum type
, GLvoid
* pixels
);
1581 void fSampleCoverage(GLclampf value
, realGLboolean invert
) {
1583 mSymbols
.fSampleCoverage(value
, invert
);
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
) {
1592 mScissorRect
[0] = x
;
1593 mScissorRect
[1] = y
;
1594 mScissorRect
[2] = width
;
1595 mScissorRect
[3] = height
;
1597 mSymbols
.fScissor(x
, y
, width
, height
);
1601 void fStencilFunc(GLenum func
, GLint reference
, GLuint mask
) {
1603 mSymbols
.fStencilFunc(func
, reference
, mask
);
1607 void fStencilFuncSeparate(GLenum frontfunc
, GLenum backfunc
, GLint reference
,
1610 mSymbols
.fStencilFuncSeparate(frontfunc
, backfunc
, reference
, mask
);
1614 void fStencilMask(GLuint mask
) {
1616 mSymbols
.fStencilMask(mask
);
1620 void fStencilMaskSeparate(GLenum face
, GLuint mask
) {
1622 mSymbols
.fStencilMaskSeparate(face
, mask
);
1626 void fStencilOp(GLenum fail
, GLenum zfail
, GLenum zpass
) {
1628 mSymbols
.fStencilOp(fail
, zfail
, zpass
);
1632 void fStencilOpSeparate(GLenum face
, GLenum sfail
, GLenum dpfail
,
1635 mSymbols
.fStencilOpSeparate(face
, sfail
, dpfail
, dppass
);
1639 void fTexGeni(GLenum coord
, GLenum pname
, GLint param
) {
1641 mSymbols
.fTexGeni(coord
, pname
, param
);
1645 void fTexGenf(GLenum coord
, GLenum pname
, GLfloat param
) {
1647 mSymbols
.fTexGenf(coord
, pname
, param
);
1651 void fTexGenfv(GLenum coord
, GLenum pname
, const GLfloat
* params
) {
1653 mSymbols
.fTexGenfv(coord
, pname
, params
);
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
);
1663 mSymbols
.fTexImage2D(target
, level
, internalformat
, width
, height
, border
,
1664 format
, type
, pixels
);
1666 mHeavyGLCallsSinceLastFlush
= true;
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
);
1679 mSymbols
.fTexSubImage2D(target
, level
, xoffset
, yoffset
, width
, height
,
1680 format
, type
, pixels
);
1682 mHeavyGLCallsSinceLastFlush
= true;
1685 void fUniform1f(GLint location
, GLfloat v0
) {
1687 mSymbols
.fUniform1f(location
, v0
);
1691 void fUniform1fv(GLint location
, GLsizei count
, const GLfloat
* value
) {
1693 mSymbols
.fUniform1fv(location
, count
, value
);
1697 void fUniform1i(GLint location
, GLint v0
) {
1699 mSymbols
.fUniform1i(location
, v0
);
1703 void fUniform1iv(GLint location
, GLsizei count
, const GLint
* value
) {
1705 mSymbols
.fUniform1iv(location
, count
, value
);
1709 void fUniform2f(GLint location
, GLfloat v0
, GLfloat v1
) {
1711 mSymbols
.fUniform2f(location
, v0
, v1
);
1715 void fUniform2fv(GLint location
, GLsizei count
, const GLfloat
* value
) {
1717 mSymbols
.fUniform2fv(location
, count
, value
);
1721 void fUniform2i(GLint location
, GLint v0
, GLint v1
) {
1723 mSymbols
.fUniform2i(location
, v0
, v1
);
1727 void fUniform2iv(GLint location
, GLsizei count
, const GLint
* value
) {
1729 mSymbols
.fUniform2iv(location
, count
, value
);
1733 void fUniform3f(GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
) {
1735 mSymbols
.fUniform3f(location
, v0
, v1
, v2
);
1739 void fUniform3fv(GLint location
, GLsizei count
, const GLfloat
* value
) {
1741 mSymbols
.fUniform3fv(location
, count
, value
);
1745 void fUniform3i(GLint location
, GLint v0
, GLint v1
, GLint v2
) {
1747 mSymbols
.fUniform3i(location
, v0
, v1
, v2
);
1751 void fUniform3iv(GLint location
, GLsizei count
, const GLint
* value
) {
1753 mSymbols
.fUniform3iv(location
, count
, value
);
1757 void fUniform4f(GLint location
, GLfloat v0
, GLfloat v1
, GLfloat v2
,
1760 mSymbols
.fUniform4f(location
, v0
, v1
, v2
, v3
);
1764 void fUniform4fv(GLint location
, GLsizei count
, const GLfloat
* value
) {
1766 mSymbols
.fUniform4fv(location
, count
, value
);
1770 void fUniform4i(GLint location
, GLint v0
, GLint v1
, GLint v2
, GLint v3
) {
1772 mSymbols
.fUniform4i(location
, v0
, v1
, v2
, v3
);
1776 void fUniform4iv(GLint location
, GLsizei count
, const GLint
* value
) {
1778 mSymbols
.fUniform4iv(location
, count
, value
);
1782 void fUniformMatrix2fv(GLint location
, GLsizei count
, realGLboolean transpose
,
1783 const GLfloat
* value
) {
1785 mSymbols
.fUniformMatrix2fv(location
, count
, transpose
, value
);
1789 void fUniformMatrix2x3fv(GLint location
, GLsizei count
,
1790 realGLboolean transpose
, const GLfloat
* value
) {
1792 ASSERT_SYMBOL_PRESENT(fUniformMatrix2x3fv
);
1793 mSymbols
.fUniformMatrix2x3fv(location
, count
, transpose
, value
);
1797 void fUniformMatrix2x4fv(GLint location
, GLsizei count
,
1798 realGLboolean transpose
, const GLfloat
* value
) {
1800 ASSERT_SYMBOL_PRESENT(fUniformMatrix2x4fv
);
1801 mSymbols
.fUniformMatrix2x4fv(location
, count
, transpose
, value
);
1805 void fUniformMatrix3fv(GLint location
, GLsizei count
, realGLboolean transpose
,
1806 const GLfloat
* value
) {
1808 mSymbols
.fUniformMatrix3fv(location
, count
, transpose
, value
);
1812 void fUniformMatrix3x2fv(GLint location
, GLsizei count
,
1813 realGLboolean transpose
, const GLfloat
* value
) {
1815 ASSERT_SYMBOL_PRESENT(fUniformMatrix3x2fv
);
1816 mSymbols
.fUniformMatrix3x2fv(location
, count
, transpose
, value
);
1820 void fUniformMatrix3x4fv(GLint location
, GLsizei count
,
1821 realGLboolean transpose
, const GLfloat
* value
) {
1823 ASSERT_SYMBOL_PRESENT(fUniformMatrix3x4fv
);
1824 mSymbols
.fUniformMatrix3x4fv(location
, count
, transpose
, value
);
1828 void fUniformMatrix4fv(GLint location
, GLsizei count
, realGLboolean transpose
,
1829 const GLfloat
* value
) {
1831 mSymbols
.fUniformMatrix4fv(location
, count
, transpose
, value
);
1835 void fUniformMatrix4x2fv(GLint location
, GLsizei count
,
1836 realGLboolean transpose
, const GLfloat
* value
) {
1838 ASSERT_SYMBOL_PRESENT(fUniformMatrix4x2fv
);
1839 mSymbols
.fUniformMatrix4x2fv(location
, count
, transpose
, value
);
1843 void fUniformMatrix4x3fv(GLint location
, GLsizei count
,
1844 realGLboolean transpose
, const GLfloat
* value
) {
1846 ASSERT_SYMBOL_PRESENT(fUniformMatrix4x3fv
);
1847 mSymbols
.fUniformMatrix4x3fv(location
, count
, transpose
, value
);
1851 void fUseProgram(GLuint program
) {
1853 mSymbols
.fUseProgram(program
);
1857 void fValidateProgram(GLuint program
) {
1859 mSymbols
.fValidateProgram(program
);
1863 void fVertexAttribPointer(GLuint index
, GLint size
, GLenum type
,
1864 realGLboolean normalized
, GLsizei stride
,
1865 const GLvoid
* pointer
) {
1867 mSymbols
.fVertexAttribPointer(index
, size
, type
, normalized
, stride
,
1872 void fVertexAttrib1f(GLuint index
, GLfloat x
) {
1874 mSymbols
.fVertexAttrib1f(index
, x
);
1878 void fVertexAttrib2f(GLuint index
, GLfloat x
, GLfloat y
) {
1880 mSymbols
.fVertexAttrib2f(index
, x
, y
);
1884 void fVertexAttrib3f(GLuint index
, GLfloat x
, GLfloat y
, GLfloat z
) {
1886 mSymbols
.fVertexAttrib3f(index
, x
, y
, z
);
1890 void fVertexAttrib4f(GLuint index
, GLfloat x
, GLfloat y
, GLfloat z
,
1893 mSymbols
.fVertexAttrib4f(index
, x
, y
, z
, w
);
1897 void fVertexAttrib1fv(GLuint index
, const GLfloat
* v
) {
1899 mSymbols
.fVertexAttrib1fv(index
, v
);
1903 void fVertexAttrib2fv(GLuint index
, const GLfloat
* v
) {
1905 mSymbols
.fVertexAttrib2fv(index
, v
);
1909 void fVertexAttrib3fv(GLuint index
, const GLfloat
* v
) {
1911 mSymbols
.fVertexAttrib3fv(index
, v
);
1915 void fVertexAttrib4fv(GLuint index
, const GLfloat
* v
) {
1917 mSymbols
.fVertexAttrib4fv(index
, v
);
1921 void fVertexPointer(GLint size
, GLenum type
, GLsizei stride
,
1922 const GLvoid
* pointer
) {
1924 mSymbols
.fVertexPointer(size
, type
, stride
, pointer
);
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
) {
1933 mViewportRect
[0] = x
;
1934 mViewportRect
[1] = y
;
1935 mViewportRect
[2] = width
;
1936 mViewportRect
[3] = height
;
1938 mSymbols
.fViewport(x
, y
, width
, height
);
1942 void fCompileShader(GLuint shader
) {
1944 mSymbols
.fCompileShader(shader
);
1949 friend class SharedSurface_IOSurface
;
1951 void raw_fCopyTexImage2D(GLenum target
, GLint level
, GLenum internalformat
,
1952 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
1955 mSymbols
.fCopyTexImage2D(target
, level
, internalformat
, x
, y
, width
, height
,
1960 void raw_fCopyTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
1961 GLint yoffset
, GLint x
, GLint y
, GLsizei width
,
1964 mSymbols
.fCopyTexSubImage2D(target
, level
, xoffset
, yoffset
, x
, y
, width
,
1970 void fGetShaderiv(GLuint shader
, GLenum pname
, GLint
* param
) {
1972 mSymbols
.fGetShaderiv(shader
, pname
, param
);
1977 void fGetShaderInfoLog(GLuint shader
, GLsizei bufSize
, GLsizei
* length
,
1980 mSymbols
.fGetShaderInfoLog(shader
, bufSize
, length
, infoLog
);
1986 void raw_fGetShaderPrecisionFormat(GLenum shadertype
, GLenum precisiontype
,
1987 GLint
* range
, GLint
* precision
) {
1988 MOZ_ASSERT(IsGLES());
1991 ASSERT_SYMBOL_PRESENT(fGetShaderPrecisionFormat
);
1992 mSymbols
.fGetShaderPrecisionFormat(shadertype
, precisiontype
, range
,
1999 void fGetShaderPrecisionFormat(GLenum shadertype
, GLenum precisiontype
,
2000 GLint
* range
, GLint
* precision
) {
2002 raw_fGetShaderPrecisionFormat(shadertype
, precisiontype
, range
,
2005 // Fall back to automatic values because almost all desktop hardware
2006 // supports the OpenGL standard precisions.
2007 GetShaderPrecisionFormatNonES2(shadertype
, precisiontype
, range
,
2012 void fGetShaderSource(GLint obj
, GLsizei maxLength
, GLsizei
* length
,
2015 mSymbols
.fGetShaderSource(obj
, maxLength
, length
, source
);
2020 void fShaderSource(GLuint shader
, GLsizei count
, const GLchar
* const* strings
,
2021 const GLint
* lengths
) {
2023 mSymbols
.fShaderSource(shader
, count
, strings
, lengths
);
2027 void fBindFramebuffer(GLenum target
, GLuint framebuffer
) {
2029 mSymbols
.fBindFramebuffer(target
, framebuffer
);
2033 void fBindRenderbuffer(GLenum target
, GLuint renderbuffer
) {
2035 mSymbols
.fBindRenderbuffer(target
, renderbuffer
);
2039 GLenum
fCheckFramebufferStatus(GLenum target
) {
2042 retval
= mSymbols
.fCheckFramebufferStatus(target
);
2048 void fFramebufferRenderbuffer(GLenum target
, GLenum attachmentPoint
,
2049 GLenum renderbufferTarget
,
2050 GLuint renderbuffer
) {
2052 mSymbols
.fFramebufferRenderbuffer(target
, attachmentPoint
,
2053 renderbufferTarget
, renderbuffer
);
2057 void fFramebufferTexture2D(GLenum target
, GLenum attachmentPoint
,
2058 GLenum textureTarget
, GLuint texture
,
2061 mSymbols
.fFramebufferTexture2D(target
, attachmentPoint
, textureTarget
,
2064 if (mNeedsCheckAfterAttachTextureToFb
) {
2065 fCheckFramebufferStatus(target
);
2069 void fFramebufferTextureLayer(GLenum target
, GLenum attachment
,
2070 GLuint texture
, GLint level
, GLint layer
) {
2072 ASSERT_SYMBOL_PRESENT(fFramebufferTextureLayer
);
2073 mSymbols
.fFramebufferTextureLayer(target
, attachment
, texture
, level
,
2078 void fGetFramebufferAttachmentParameteriv(GLenum target
, GLenum attachment
,
2079 GLenum pname
, GLint
* value
) {
2081 mSymbols
.fGetFramebufferAttachmentParameteriv(target
, attachment
, pname
,
2087 void fGetRenderbufferParameteriv(GLenum target
, GLenum pname
, GLint
* value
) {
2089 mSymbols
.fGetRenderbufferParameteriv(target
, pname
, value
);
2094 realGLboolean
fIsFramebuffer(GLuint framebuffer
) {
2095 realGLboolean retval
= false;
2097 retval
= mSymbols
.fIsFramebuffer(framebuffer
);
2104 realGLboolean
fIsRenderbuffer(GLuint renderbuffer
) {
2105 realGLboolean retval
= false;
2107 retval
= mSymbols
.fIsRenderbuffer(renderbuffer
);
2113 void fRenderbufferStorage(GLenum target
, GLenum internalFormat
, GLsizei width
,
2116 mSymbols
.fRenderbufferStorage(target
, internalFormat
, width
, height
);
2121 void raw_fDepthRange(GLclampf a
, GLclampf b
) {
2122 MOZ_ASSERT(!IsGLES());
2125 ASSERT_SYMBOL_PRESENT(fDepthRange
);
2126 mSymbols
.fDepthRange(a
, b
);
2130 void raw_fDepthRangef(GLclampf a
, GLclampf b
) {
2131 MOZ_ASSERT(IsGLES());
2134 ASSERT_SYMBOL_PRESENT(fDepthRangef
);
2135 mSymbols
.fDepthRangef(a
, b
);
2139 void raw_fClearDepth(GLclampf v
) {
2140 MOZ_ASSERT(!IsGLES());
2143 ASSERT_SYMBOL_PRESENT(fClearDepth
);
2144 mSymbols
.fClearDepth(v
);
2148 void raw_fClearDepthf(GLclampf v
) {
2149 MOZ_ASSERT(IsGLES());
2152 ASSERT_SYMBOL_PRESENT(fClearDepthf
);
2153 mSymbols
.fClearDepthf(v
);
2158 void fDepthRange(GLclampf a
, GLclampf b
) {
2160 raw_fDepthRangef(a
, b
);
2162 raw_fDepthRange(a
, b
);
2166 void fClearDepth(GLclampf v
) {
2168 raw_fClearDepthf(v
);
2174 void* fMapBuffer(GLenum target
, GLenum access
) {
2175 void* ret
= nullptr;
2177 ASSERT_SYMBOL_PRESENT(fMapBuffer
);
2178 ret
= mSymbols
.fMapBuffer(target
, access
);
2184 realGLboolean
fUnmapBuffer(GLenum target
) {
2185 realGLboolean ret
= false;
2187 ASSERT_SYMBOL_PRESENT(fUnmapBuffer
);
2188 ret
= mSymbols
.fUnmapBuffer(target
);
2194 GLuint
raw_fCreateProgram() {
2197 ret
= mSymbols
.fCreateProgram();
2202 GLuint
raw_fCreateShader(GLenum t
) {
2205 ret
= mSymbols
.fCreateShader(t
);
2210 void raw_fGenBuffers(GLsizei n
, GLuint
* names
) {
2212 mSymbols
.fGenBuffers(n
, names
);
2217 void raw_fGenFramebuffers(GLsizei n
, GLuint
* names
) {
2219 mSymbols
.fGenFramebuffers(n
, names
);
2224 void raw_fGenRenderbuffers(GLsizei n
, GLuint
* names
) {
2226 mSymbols
.fGenRenderbuffers(n
, names
);
2231 void raw_fGenTextures(GLsizei n
, GLuint
* names
) {
2233 mSymbols
.fGenTextures(n
, names
);
2239 GLuint
fCreateProgram() {
2240 GLuint ret
= raw_fCreateProgram();
2241 TRACKING_CONTEXT(CreatedProgram(this, ret
));
2245 GLuint
fCreateShader(GLenum t
) {
2246 GLuint ret
= raw_fCreateShader(t
);
2247 TRACKING_CONTEXT(CreatedShader(this, 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
));
2272 void raw_fDeleteProgram(GLuint program
) {
2274 mSymbols
.fDeleteProgram(program
);
2278 void raw_fDeleteShader(GLuint shader
) {
2280 mSymbols
.fDeleteShader(shader
);
2284 void raw_fDeleteBuffers(GLsizei n
, const GLuint
* names
) {
2286 mSymbols
.fDeleteBuffers(n
, names
);
2290 void raw_fDeleteFramebuffers(GLsizei n
, const GLuint
* names
) {
2292 mSymbols
.fDeleteFramebuffers(n
, names
);
2296 void raw_fDeleteRenderbuffers(GLsizei n
, const GLuint
* names
) {
2298 mSymbols
.fDeleteRenderbuffers(n
, names
);
2302 void raw_fDeleteTextures(GLsizei n
, const GLuint
* names
) {
2304 mSymbols
.fDeleteTextures(n
, names
);
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
) {
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.
2339 raw_fDeleteTextures(n
, names
);
2340 TRACKING_CONTEXT(DeletedTextures(this, n
, names
));
2343 // -----------------------------------------------------------------------------
2344 // Extension ARB_sync (GL)
2346 GLsync
fFenceSync(GLenum condition
, GLbitfield flags
) {
2349 ASSERT_SYMBOL_PRESENT(fFenceSync
);
2350 ret
= mSymbols
.fFenceSync(condition
, flags
);
2356 realGLboolean
fIsSync(GLsync sync
) {
2357 realGLboolean ret
= false;
2359 ASSERT_SYMBOL_PRESENT(fIsSync
);
2360 ret
= mSymbols
.fIsSync(sync
);
2366 void fDeleteSync(GLsync sync
) {
2368 ASSERT_SYMBOL_PRESENT(fDeleteSync
);
2369 mSymbols
.fDeleteSync(sync
);
2373 GLenum
fClientWaitSync(GLsync sync
, GLbitfield flags
, GLuint64 timeout
) {
2376 ASSERT_SYMBOL_PRESENT(fClientWaitSync
);
2377 ret
= mSymbols
.fClientWaitSync(sync
, flags
, timeout
);
2383 void fWaitSync(GLsync sync
, GLbitfield flags
, GLuint64 timeout
) {
2385 ASSERT_SYMBOL_PRESENT(fWaitSync
);
2386 mSymbols
.fWaitSync(sync
, flags
, timeout
);
2390 void fGetInteger64v(GLenum pname
, GLint64
* params
) {
2392 ASSERT_SYMBOL_PRESENT(fGetInteger64v
);
2393 mSymbols
.fGetInteger64v(pname
, params
);
2397 void fGetSynciv(GLsync sync
, GLenum pname
, GLsizei bufSize
, GLsizei
* length
,
2400 ASSERT_SYMBOL_PRESENT(fGetSynciv
);
2401 mSymbols
.fGetSynciv(sync
, pname
, bufSize
, length
, values
);
2406 // -----------------------------------------------------------------------------
2407 // Extension OES_EGL_image (GLES)
2409 void fEGLImageTargetTexture2D(GLenum target
, GLeglImage image
) {
2411 ASSERT_SYMBOL_PRESENT(fEGLImageTargetTexture2D
);
2412 mSymbols
.fEGLImageTargetTexture2D(target
, image
);
2414 mHeavyGLCallsSinceLastFlush
= true;
2417 void fEGLImageTargetRenderbufferStorage(GLenum target
, GLeglImage image
) {
2419 ASSERT_SYMBOL_PRESENT(fEGLImageTargetRenderbufferStorage
);
2420 mSymbols
.fEGLImageTargetRenderbufferStorage(target
, image
);
2424 // -----------------------------------------------------------------------------
2425 // Package XXX_bind_buffer_offset
2427 void fBindBufferOffset(GLenum target
, GLuint index
, GLuint buffer
,
2430 ASSERT_SYMBOL_PRESENT(fBindBufferOffset
);
2431 mSymbols
.fBindBufferOffset(target
, index
, buffer
, offset
);
2435 // -----------------------------------------------------------------------------
2436 // Package XXX_draw_buffers
2438 void fDrawBuffers(GLsizei n
, const GLenum
* bufs
) {
2440 ASSERT_SYMBOL_PRESENT(fDrawBuffers
);
2441 mSymbols
.fDrawBuffers(n
, bufs
);
2445 // -----------------------------------------------------------------------------
2446 // Package XXX_draw_instanced
2448 void fDrawArraysInstanced(GLenum mode
, GLint first
, GLsizei count
,
2449 GLsizei primcount
) {
2451 raw_fDrawArraysInstanced(mode
, first
, count
, primcount
);
2455 void fDrawElementsInstanced(GLenum mode
, GLsizei count
, GLenum type
,
2456 const GLvoid
* indices
, GLsizei primcount
) {
2458 raw_fDrawElementsInstanced(mode
, count
, type
, indices
, primcount
);
2463 void raw_fDrawArraysInstanced(GLenum mode
, GLint first
, GLsizei count
,
2464 GLsizei primcount
) {
2466 ASSERT_SYMBOL_PRESENT(fDrawArraysInstanced
);
2467 mSymbols
.fDrawArraysInstanced(mode
, first
, count
, primcount
);
2471 void raw_fDrawElementsInstanced(GLenum mode
, GLsizei count
, GLenum type
,
2472 const GLvoid
* indices
, GLsizei primcount
) {
2474 ASSERT_SYMBOL_PRESENT(fDrawElementsInstanced
);
2475 mSymbols
.fDrawElementsInstanced(mode
, count
, type
, indices
, primcount
);
2479 // -----------------------------------------------------------------------------
2480 // Package XXX_framebuffer_blit
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
) {
2488 raw_fBlitFramebuffer(srcX0
, srcY0
, srcX1
, srcY1
, dstX0
, dstY0
, dstX1
, dstY1
,
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
) {
2499 ASSERT_SYMBOL_PRESENT(fBlitFramebuffer
);
2500 mSymbols
.fBlitFramebuffer(srcX0
, srcY0
, srcX1
, srcY1
, dstX0
, dstY0
, dstX1
,
2501 dstY1
, mask
, filter
);
2505 // -----------------------------------------------------------------------------
2506 // Package XXX_framebuffer_multisample
2508 void fRenderbufferStorageMultisample(GLenum target
, GLsizei samples
,
2509 GLenum internalFormat
, GLsizei width
,
2512 ASSERT_SYMBOL_PRESENT(fRenderbufferStorageMultisample
);
2513 mSymbols
.fRenderbufferStorageMultisample(target
, samples
, internalFormat
,
2518 // -----------------------------------------------------------------------------
2519 // GL 3.0, GL ES 3.0 & EXT_gpu_shader4
2521 void fGetVertexAttribIiv(GLuint index
, GLenum pname
, GLint
* params
) {
2522 ASSERT_SYMBOL_PRESENT(fGetVertexAttribIiv
);
2524 mSymbols
.fGetVertexAttribIiv(index
, pname
, params
);
2529 void fGetVertexAttribIuiv(GLuint index
, GLenum pname
, GLuint
* params
) {
2530 ASSERT_SYMBOL_PRESENT(fGetVertexAttribIuiv
);
2532 mSymbols
.fGetVertexAttribIuiv(index
, pname
, params
);
2537 void fVertexAttribI4i(GLuint index
, GLint x
, GLint y
, GLint z
, GLint w
) {
2539 ASSERT_SYMBOL_PRESENT(fVertexAttribI4i
);
2540 mSymbols
.fVertexAttribI4i(index
, x
, y
, z
, w
);
2544 void fVertexAttribI4iv(GLuint index
, const GLint
* v
) {
2546 ASSERT_SYMBOL_PRESENT(fVertexAttribI4iv
);
2547 mSymbols
.fVertexAttribI4iv(index
, v
);
2551 void fVertexAttribI4ui(GLuint index
, GLuint x
, GLuint y
, GLuint z
, GLuint w
) {
2553 ASSERT_SYMBOL_PRESENT(fVertexAttribI4ui
);
2554 mSymbols
.fVertexAttribI4ui(index
, x
, y
, z
, w
);
2558 void fVertexAttribI4uiv(GLuint index
, const GLuint
* v
) {
2560 ASSERT_SYMBOL_PRESENT(fVertexAttribI4uiv
);
2561 mSymbols
.fVertexAttribI4uiv(index
, v
);
2565 void fVertexAttribIPointer(GLuint index
, GLint size
, GLenum type
,
2566 GLsizei stride
, const GLvoid
* offset
) {
2568 ASSERT_SYMBOL_PRESENT(fVertexAttribIPointer
);
2569 mSymbols
.fVertexAttribIPointer(index
, size
, type
, stride
, offset
);
2573 void fUniform1ui(GLint location
, GLuint v0
) {
2575 ASSERT_SYMBOL_PRESENT(fUniform1ui
);
2576 mSymbols
.fUniform1ui(location
, v0
);
2580 void fUniform2ui(GLint location
, GLuint v0
, GLuint v1
) {
2582 ASSERT_SYMBOL_PRESENT(fUniform2ui
);
2583 mSymbols
.fUniform2ui(location
, v0
, v1
);
2587 void fUniform3ui(GLint location
, GLuint v0
, GLuint v1
, GLuint v2
) {
2589 ASSERT_SYMBOL_PRESENT(fUniform3ui
);
2590 mSymbols
.fUniform3ui(location
, v0
, v1
, v2
);
2594 void fUniform4ui(GLint location
, GLuint v0
, GLuint v1
, GLuint v2
, GLuint v3
) {
2596 ASSERT_SYMBOL_PRESENT(fUniform4ui
);
2597 mSymbols
.fUniform4ui(location
, v0
, v1
, v2
, v3
);
2601 void fUniform1uiv(GLint location
, GLsizei count
, const GLuint
* value
) {
2603 ASSERT_SYMBOL_PRESENT(fUniform1uiv
);
2604 mSymbols
.fUniform1uiv(location
, count
, value
);
2608 void fUniform2uiv(GLint location
, GLsizei count
, const GLuint
* value
) {
2610 ASSERT_SYMBOL_PRESENT(fUniform2uiv
);
2611 mSymbols
.fUniform2uiv(location
, count
, value
);
2615 void fUniform3uiv(GLint location
, GLsizei count
, const GLuint
* value
) {
2617 ASSERT_SYMBOL_PRESENT(fUniform3uiv
);
2618 mSymbols
.fUniform3uiv(location
, count
, value
);
2622 void fUniform4uiv(GLint location
, GLsizei count
, const GLuint
* value
) {
2624 ASSERT_SYMBOL_PRESENT(fUniform4uiv
);
2625 mSymbols
.fUniform4uiv(location
, count
, value
);
2629 GLint
fGetFragDataLocation(GLuint program
, const GLchar
* name
) {
2632 ASSERT_SYMBOL_PRESENT(fGetFragDataLocation
);
2633 result
= mSymbols
.fGetFragDataLocation(program
, name
);
2639 // -----------------------------------------------------------------------------
2640 // Package XXX_instanced_arrays
2642 void fVertexAttribDivisor(GLuint index
, GLuint divisor
) {
2644 ASSERT_SYMBOL_PRESENT(fVertexAttribDivisor
);
2645 mSymbols
.fVertexAttribDivisor(index
, divisor
);
2649 // -----------------------------------------------------------------------------
2650 // Feature internalformat_query
2652 void fGetInternalformativ(GLenum target
, GLenum internalformat
, GLenum pname
,
2653 GLsizei bufSize
, GLint
* params
) {
2655 ASSERT_SYMBOL_PRESENT(fGetInternalformativ
);
2656 mSymbols
.fGetInternalformativ(target
, internalformat
, pname
, bufSize
,
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
2671 void fQueryCounter(GLuint id
, GLenum target
) {
2673 ASSERT_SYMBOL_PRESENT(fQueryCounter
);
2674 mSymbols
.fQueryCounter(id
, target
);
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
2693 void fDeleteQueries(GLsizei n
, const GLuint
* names
) {
2695 ASSERT_SYMBOL_PRESENT(fDeleteQueries
);
2696 mSymbols
.fDeleteQueries(n
, names
);
2698 TRACKING_CONTEXT(DeletedQueries(this, n
, names
));
2701 void fGenQueries(GLsizei n
, GLuint
* names
) {
2703 ASSERT_SYMBOL_PRESENT(fGenQueries
);
2704 mSymbols
.fGenQueries(n
, names
);
2706 TRACKING_CONTEXT(CreatedQueries(this, n
, names
));
2709 void fGetQueryiv(GLenum target
, GLenum pname
, GLint
* params
) {
2711 ASSERT_SYMBOL_PRESENT(fGetQueryiv
);
2712 mSymbols
.fGetQueryiv(target
, pname
, params
);
2717 void fGetQueryObjectuiv(GLuint id
, GLenum pname
, GLuint
* params
) {
2719 ASSERT_SYMBOL_PRESENT(fGetQueryObjectuiv
);
2720 mSymbols
.fGetQueryObjectuiv(id
, pname
, params
);
2725 realGLboolean
fIsQuery(GLuint query
) {
2726 realGLboolean retval
= false;
2728 ASSERT_SYMBOL_PRESENT(fIsQuery
);
2729 retval
= mSymbols
.fIsQuery(query
);
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
2743 void fGetQueryObjecti64v(GLuint id
, GLenum pname
, GLint64
* params
) {
2745 ASSERT_SYMBOL_PRESENT(fGetQueryObjecti64v
);
2746 mSymbols
.fGetQueryObjecti64v(id
, pname
, params
);
2751 void fGetQueryObjectui64v(GLuint id
, GLenum pname
, GLuint64
* params
) {
2753 ASSERT_SYMBOL_PRESENT(fGetQueryObjectui64v
);
2754 mSymbols
.fGetQueryObjectui64v(id
, pname
, params
);
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
2771 void fGetQueryObjectiv(GLuint id
, GLenum pname
, GLint
* params
) {
2773 ASSERT_SYMBOL_PRESENT(fGetQueryObjectiv
);
2774 mSymbols
.fGetQueryObjectiv(id
, pname
, params
);
2779 // -----------------------------------------------------------------------------
2780 // GL 4.0, GL ES 3.0, ARB_transform_feedback2, NV_transform_feedback2
2782 void fBindBufferBase(GLenum target
, GLuint index
, GLuint buffer
) {
2784 ASSERT_SYMBOL_PRESENT(fBindBufferBase
);
2785 mSymbols
.fBindBufferBase(target
, index
, buffer
);
2789 void fBindBufferRange(GLenum target
, GLuint index
, GLuint buffer
,
2790 GLintptr offset
, GLsizeiptr size
) {
2792 ASSERT_SYMBOL_PRESENT(fBindBufferRange
);
2793 mSymbols
.fBindBufferRange(target
, index
, buffer
, offset
, size
);
2797 void fGenTransformFeedbacks(GLsizei n
, GLuint
* ids
) {
2799 ASSERT_SYMBOL_PRESENT(fGenTransformFeedbacks
);
2800 mSymbols
.fGenTransformFeedbacks(n
, ids
);
2805 void fDeleteTransformFeedbacks(GLsizei n
, const GLuint
* ids
) {
2807 ASSERT_SYMBOL_PRESENT(fDeleteTransformFeedbacks
);
2808 mSymbols
.fDeleteTransformFeedbacks(n
, ids
);
2812 realGLboolean
fIsTransformFeedback(GLuint id
) {
2813 realGLboolean result
= false;
2815 ASSERT_SYMBOL_PRESENT(fIsTransformFeedback
);
2816 result
= mSymbols
.fIsTransformFeedback(id
);
2822 void fBindTransformFeedback(GLenum target
, GLuint id
) {
2824 ASSERT_SYMBOL_PRESENT(fBindTransformFeedback
);
2825 mSymbols
.fBindTransformFeedback(target
, id
);
2829 void fBeginTransformFeedback(GLenum primitiveMode
) {
2831 ASSERT_SYMBOL_PRESENT(fBeginTransformFeedback
);
2832 mSymbols
.fBeginTransformFeedback(primitiveMode
);
2836 void fEndTransformFeedback() {
2838 ASSERT_SYMBOL_PRESENT(fEndTransformFeedback
);
2839 mSymbols
.fEndTransformFeedback();
2843 void fTransformFeedbackVaryings(GLuint program
, GLsizei count
,
2844 const GLchar
* const* varyings
,
2845 GLenum bufferMode
) {
2847 ASSERT_SYMBOL_PRESENT(fTransformFeedbackVaryings
);
2848 mSymbols
.fTransformFeedbackVaryings(program
, count
, varyings
, bufferMode
);
2852 void fGetTransformFeedbackVarying(GLuint program
, GLuint index
,
2853 GLsizei bufSize
, GLsizei
* length
,
2854 GLsizei
* size
, GLenum
* type
, GLchar
* name
) {
2856 ASSERT_SYMBOL_PRESENT(fGetTransformFeedbackVarying
);
2857 mSymbols
.fGetTransformFeedbackVarying(program
, index
, bufSize
, length
, size
,
2863 void fPauseTransformFeedback() {
2865 ASSERT_SYMBOL_PRESENT(fPauseTransformFeedback
);
2866 mSymbols
.fPauseTransformFeedback();
2870 void fResumeTransformFeedback() {
2872 ASSERT_SYMBOL_PRESENT(fResumeTransformFeedback
);
2873 mSymbols
.fResumeTransformFeedback();
2877 void fGetIntegeri_v(GLenum param
, GLuint index
, GLint
* values
) {
2879 ASSERT_SYMBOL_PRESENT(fGetIntegeri_v
);
2880 mSymbols
.fGetIntegeri_v(param
, index
, values
);
2885 void fGetInteger64i_v(GLenum target
, GLuint index
, GLint64
* data
) {
2886 ASSERT_SYMBOL_PRESENT(fGetInteger64i_v
);
2888 mSymbols
.fGetInteger64i_v(target
, index
, data
);
2893 // -----------------------------------------------------------------------------
2894 // Package XXX_vertex_array_object
2896 void fBindVertexArray(GLuint array
) {
2898 ASSERT_SYMBOL_PRESENT(fBindVertexArray
);
2899 mSymbols
.fBindVertexArray(array
);
2903 void fDeleteVertexArrays(GLsizei n
, const GLuint
* arrays
) {
2905 ASSERT_SYMBOL_PRESENT(fDeleteVertexArrays
);
2906 mSymbols
.fDeleteVertexArrays(n
, arrays
);
2910 void fGenVertexArrays(GLsizei n
, GLuint
* arrays
) {
2912 ASSERT_SYMBOL_PRESENT(fGenVertexArrays
);
2913 mSymbols
.fGenVertexArrays(n
, arrays
);
2917 realGLboolean
fIsVertexArray(GLuint array
) {
2918 realGLboolean ret
= false;
2920 ASSERT_SYMBOL_PRESENT(fIsVertexArray
);
2921 ret
= mSymbols
.fIsVertexArray(array
);
2927 // -----------------------------------------------------------------------------
2928 // Extension NV_fence
2930 void fGenFences(GLsizei n
, GLuint
* fences
) {
2931 ASSERT_SYMBOL_PRESENT(fGenFences
);
2933 mSymbols
.fGenFences(n
, fences
);
2937 void fDeleteFences(GLsizei n
, const GLuint
* fences
) {
2938 ASSERT_SYMBOL_PRESENT(fDeleteFences
);
2940 mSymbols
.fDeleteFences(n
, fences
);
2944 void fSetFence(GLuint fence
, GLenum condition
) {
2945 ASSERT_SYMBOL_PRESENT(fSetFence
);
2947 mSymbols
.fSetFence(fence
, condition
);
2951 realGLboolean
fTestFence(GLuint fence
) {
2952 realGLboolean ret
= false;
2953 ASSERT_SYMBOL_PRESENT(fTestFence
);
2955 ret
= mSymbols
.fTestFence(fence
);
2961 void fFinishFence(GLuint fence
) {
2962 ASSERT_SYMBOL_PRESENT(fFinishFence
);
2964 mSymbols
.fFinishFence(fence
);
2969 realGLboolean
fIsFence(GLuint fence
) {
2970 realGLboolean ret
= false;
2971 ASSERT_SYMBOL_PRESENT(fIsFence
);
2973 ret
= mSymbols
.fIsFence(fence
);
2979 void fGetFenceiv(GLuint fence
, GLenum pname
, GLint
* params
) {
2980 ASSERT_SYMBOL_PRESENT(fGetFenceiv
);
2982 mSymbols
.fGetFenceiv(fence
, pname
, params
);
2987 // -----------------------------------------------------------------------------
2988 // Extension NV_texture_barrier
2990 void fTextureBarrier() {
2991 ASSERT_SYMBOL_PRESENT(fTextureBarrier
);
2993 mSymbols
.fTextureBarrier();
2997 // Core GL & Extension ARB_copy_buffer
2999 void fCopyBufferSubData(GLenum readtarget
, GLenum writetarget
,
3000 GLintptr readoffset
, GLintptr writeoffset
,
3003 ASSERT_SYMBOL_PRESENT(fCopyBufferSubData
);
3004 mSymbols
.fCopyBufferSubData(readtarget
, writetarget
, readoffset
,
3009 // -----------------------------------------------------------------------------
3010 // Core GL & Extension ARB_map_buffer_range
3012 void* fMapBufferRange(GLenum target
, GLintptr offset
, GLsizeiptr length
,
3013 GLbitfield access
) {
3014 void* data
= nullptr;
3015 ASSERT_SYMBOL_PRESENT(fMapBufferRange
);
3017 data
= mSymbols
.fMapBufferRange(target
, offset
, length
, access
);
3023 void fFlushMappedBufferRange(GLenum target
, GLintptr offset
,
3024 GLsizeiptr length
) {
3025 ASSERT_SYMBOL_PRESENT(fFlushMappedBufferRange
);
3027 mSymbols
.fFlushMappedBufferRange(target
, offset
, length
);
3031 // -----------------------------------------------------------------------------
3032 // Core GL & Extension ARB_sampler_objects
3034 void fGenSamplers(GLsizei count
, GLuint
* samplers
) {
3036 ASSERT_SYMBOL_PRESENT(fGenSamplers
);
3037 mSymbols
.fGenSamplers(count
, samplers
);
3041 void fDeleteSamplers(GLsizei count
, const GLuint
* samplers
) {
3043 ASSERT_SYMBOL_PRESENT(fDeleteSamplers
);
3044 mSymbols
.fDeleteSamplers(count
, samplers
);
3048 realGLboolean
fIsSampler(GLuint sampler
) {
3049 realGLboolean result
= false;
3051 ASSERT_SYMBOL_PRESENT(fIsSampler
);
3052 result
= mSymbols
.fIsSampler(sampler
);
3058 void fBindSampler(GLuint unit
, GLuint sampler
) {
3060 ASSERT_SYMBOL_PRESENT(fBindSampler
);
3061 mSymbols
.fBindSampler(unit
, sampler
);
3065 void fSamplerParameteri(GLuint sampler
, GLenum pname
, GLint param
) {
3067 ASSERT_SYMBOL_PRESENT(fSamplerParameteri
);
3068 mSymbols
.fSamplerParameteri(sampler
, pname
, param
);
3072 void fSamplerParameteriv(GLuint sampler
, GLenum pname
, const GLint
* param
) {
3074 ASSERT_SYMBOL_PRESENT(fSamplerParameteriv
);
3075 mSymbols
.fSamplerParameteriv(sampler
, pname
, param
);
3079 void fSamplerParameterf(GLuint sampler
, GLenum pname
, GLfloat param
) {
3081 ASSERT_SYMBOL_PRESENT(fSamplerParameterf
);
3082 mSymbols
.fSamplerParameterf(sampler
, pname
, param
);
3086 void fSamplerParameterfv(GLuint sampler
, GLenum pname
, const GLfloat
* param
) {
3088 ASSERT_SYMBOL_PRESENT(fSamplerParameterfv
);
3089 mSymbols
.fSamplerParameterfv(sampler
, pname
, param
);
3093 void fGetSamplerParameteriv(GLuint sampler
, GLenum pname
, GLint
* params
) {
3095 ASSERT_SYMBOL_PRESENT(fGetSamplerParameteriv
);
3096 mSymbols
.fGetSamplerParameteriv(sampler
, pname
, params
);
3100 void fGetSamplerParameterfv(GLuint sampler
, GLenum pname
, GLfloat
* params
) {
3102 ASSERT_SYMBOL_PRESENT(fGetSamplerParameterfv
);
3103 mSymbols
.fGetSamplerParameterfv(sampler
, pname
, params
);
3107 // -----------------------------------------------------------------------------
3108 // Core GL & Extension ARB_uniform_buffer_object
3110 void fGetUniformIndices(GLuint program
, GLsizei uniformCount
,
3111 const GLchar
* const* uniformNames
,
3112 GLuint
* uniformIndices
) {
3113 ASSERT_SYMBOL_PRESENT(fGetUniformIndices
);
3115 mSymbols
.fGetUniformIndices(program
, uniformCount
, uniformNames
,
3121 void fGetActiveUniformsiv(GLuint program
, GLsizei uniformCount
,
3122 const GLuint
* uniformIndices
, GLenum pname
,
3124 ASSERT_SYMBOL_PRESENT(fGetActiveUniformsiv
);
3126 mSymbols
.fGetActiveUniformsiv(program
, uniformCount
, uniformIndices
, pname
,
3132 GLuint
fGetUniformBlockIndex(GLuint program
, const GLchar
* uniformBlockName
) {
3134 ASSERT_SYMBOL_PRESENT(fGetUniformBlockIndex
);
3136 result
= mSymbols
.fGetUniformBlockIndex(program
, uniformBlockName
);
3142 void fGetActiveUniformBlockiv(GLuint program
, GLuint uniformBlockIndex
,
3143 GLenum pname
, GLint
* params
) {
3144 ASSERT_SYMBOL_PRESENT(fGetActiveUniformBlockiv
);
3146 mSymbols
.fGetActiveUniformBlockiv(program
, uniformBlockIndex
, pname
,
3152 void fGetActiveUniformBlockName(GLuint program
, GLuint uniformBlockIndex
,
3153 GLsizei bufSize
, GLsizei
* length
,
3154 GLchar
* uniformBlockName
) {
3155 ASSERT_SYMBOL_PRESENT(fGetActiveUniformBlockName
);
3157 mSymbols
.fGetActiveUniformBlockName(program
, uniformBlockIndex
, bufSize
,
3158 length
, uniformBlockName
);
3163 void fUniformBlockBinding(GLuint program
, GLuint uniformBlockIndex
,
3164 GLuint uniformBlockBinding
) {
3165 ASSERT_SYMBOL_PRESENT(fUniformBlockBinding
);
3167 mSymbols
.fUniformBlockBinding(program
, uniformBlockIndex
,
3168 uniformBlockBinding
);
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
) {
3177 ASSERT_SYMBOL_PRESENT(fTexStorage2D
);
3178 mSymbols
.fTexStorage2D(target
, levels
, internalformat
, width
, height
);
3183 void fTexStorage3D(GLenum target
, GLsizei levels
, GLenum internalformat
,
3184 GLsizei width
, GLsizei height
, GLsizei depth
) {
3186 ASSERT_SYMBOL_PRESENT(fTexStorage3D
);
3187 mSymbols
.fTexStorage3D(target
, levels
, internalformat
, width
, height
,
3193 // -----------------------------------------------------------------------------
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
) {
3199 ASSERT_SYMBOL_PRESENT(fTexImage3D
);
3200 mSymbols
.fTexImage3D(target
, level
, internalFormat
, width
, height
, depth
,
3201 border
, format
, type
, data
);
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
) {
3211 ASSERT_SYMBOL_PRESENT(fTexSubImage3D
);
3212 mSymbols
.fTexSubImage3D(target
, level
, xoffset
, yoffset
, zoffset
, width
,
3213 height
, depth
, format
, type
, pixels
);
3218 void fCopyTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
3219 GLint yoffset
, GLint zoffset
, GLint x
, GLint y
,
3220 GLsizei width
, GLsizei height
) {
3223 ASSERT_SYMBOL_PRESENT(fCopyTexSubImage3D
);
3224 mSymbols
.fCopyTexSubImage3D(target
, level
, xoffset
, yoffset
, zoffset
, x
, y
,
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
) {
3235 ASSERT_SYMBOL_PRESENT(fCompressedTexImage3D
);
3236 mSymbols
.fCompressedTexImage3D(target
, level
, internalformat
, width
, height
,
3237 depth
, border
, imageSize
, data
);
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
) {
3246 ASSERT_SYMBOL_PRESENT(fCompressedTexSubImage3D
);
3247 mSymbols
.fCompressedTexSubImage3D(target
, level
, xoffset
, yoffset
, zoffset
,
3248 width
, height
, depth
, format
, imageSize
,
3253 // -----------------------------------------------------------------------------
3256 const GLubyte
* fGetStringi(GLenum name
, GLuint index
) {
3257 const GLubyte
* ret
= nullptr;
3259 ASSERT_SYMBOL_PRESENT(fGetStringi
);
3260 ret
= mSymbols
.fGetStringi(name
, index
);
3266 // -----------------------------------------------------------------------------
3267 // APPLE_framebuffer_multisample
3269 void fResolveMultisampleFramebufferAPPLE() {
3271 ASSERT_SYMBOL_PRESENT(fResolveMultisampleFramebufferAPPLE
);
3272 mSymbols
.fResolveMultisampleFramebufferAPPLE();
3276 // -----------------------------------------------------------------------------
3279 void fFinishObjectAPPLE(GLenum object
, GLint name
) {
3281 ASSERT_SYMBOL_PRESENT(fFinishObjectAPPLE
);
3282 mSymbols
.fFinishObjectAPPLE(object
, name
);
3286 realGLboolean
fTestObjectAPPLE(GLenum object
, GLint name
) {
3287 realGLboolean ret
= false;
3289 ASSERT_SYMBOL_PRESENT(fTestObjectAPPLE
);
3290 ret
= mSymbols
.fTestObjectAPPLE(object
, name
);
3295 // -----------------------------------------------------------------------------
3298 void fPrimitiveRestartIndex(GLuint index
) {
3300 ASSERT_SYMBOL_PRESENT(fPrimitiveRestartIndex
);
3301 mSymbols
.fPrimitiveRestartIndex(index
);
3305 // -----------------------------------------------------------------------------
3308 void fFramebufferTextureMultiview(GLenum target
, GLenum attachment
,
3309 GLuint texture
, GLint level
,
3310 GLint baseViewIndex
,
3311 GLsizei numViews
) const {
3313 ASSERT_SYMBOL_PRESENT(fFramebufferTextureMultiview
);
3314 mSymbols
.fFramebufferTextureMultiview(target
, attachment
, texture
, level
,
3315 baseViewIndex
, numViews
);
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 // -----------------------------------------------------------------------------
3328 explicit GLContext(const GLContextDesc
&, GLContext
* sharedContext
= nullptr,
3329 bool canUseTLSIsCurrent
= false);
3331 // -----------------------------------------------------------------------------
3334 virtual ~GLContext();
3336 // Mark this context as destroyed. This will nullptr out all
3337 // the GL function pointers!
3338 void MarkDestroyed();
3341 virtual void OnMarkDestroyed() {}
3343 // -----------------------------------------------------------------------------
3344 // Everything that isn't standard GL APIs
3346 typedef gfx::SurfaceFormat SurfaceFormat
;
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();
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());
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
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
3451 virtual GLenum
GetPreferredARGB32Format() const { return LOCAL_GL_RGBA
; }
3453 virtual GLenum
GetPreferredEGLImageTextureTarget() const {
3455 return LOCAL_GL_TEXTURE_2D
;
3457 return IsExtensionSupported(OES_EGL_image_external
)
3458 ? LOCAL_GL_TEXTURE_EXTERNAL
3459 : LOCAL_GL_TEXTURE_2D
;
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
);
3471 DebugFlagEnabled
= 1 << 0,
3472 DebugFlagTrace
= 1 << 1,
3473 DebugFlagAbortOnError
= 1 << 2
3476 const uint8_t mDebugFlags
;
3477 static uint8_t ChooseDebugFlags(CreateContextFlags createFlags
);
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
;
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
);
3524 SharedSurface
* mLockedSurface
= nullptr;
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();
3546 void LoadMoreSymbols(const SymbolLoader
& loader
);
3547 bool LoadExtSymbols(const SymbolLoader
& loader
, const SymLoadStruct
* list
,
3549 bool LoadFeatureSymbols(const SymbolLoader
& loader
, const SymLoadStruct
* list
,
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
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
3585 return width
<= maxSize
&& height
<= maxSize
;
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
; }
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) {}
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;
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
;
3650 bool mHeavyGLCallsSinceLastFlush
= false;
3653 void FlushIfHeavyGLCallsSinceLastFlush();
3654 static bool ShouldSpew();
3655 static bool ShouldDumpExts();
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
);
3668 GLuint
CreateFramebuffer() {
3670 fGenFramebuffers(1, &x
);
3673 GLuint
CreateRenderbuffer() {
3675 fGenRenderbuffers(1, &x
);
3678 GLuint
CreateTexture() {
3680 fGenTextures(1, &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
);
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;
3708 void MarkBitfieldByStrings(const std::vector
<nsCString
>& strList
,
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
);
3716 printf_stderr(" %s%s\n", str
.BeginReading(), wasMarked
? "(*)" : "");
3722 class Renderbuffer final
{
3724 const WeakPtr
<GLContext
> weakGl
;
3728 static GLuint
Create(GLContext
& gl
) {
3730 gl
.fGenRenderbuffers(1, &ret
);
3735 explicit Renderbuffer(GLContext
& gl
) : weakGl(&gl
), name(Create(gl
)) {}
3738 const RefPtr
<GLContext
> gl
= weakGl
.get();
3739 if (!gl
|| !gl
->MakeCurrent()) return;
3740 gl
->fDeleteRenderbuffers(1, &name
);
3746 class Texture final
{
3748 const WeakPtr
<GLContext
> weakGl
;
3752 static GLuint
Create(GLContext
& gl
) {
3754 gl
.fGenTextures(1, &ret
);
3759 explicit Texture(GLContext
& gl
) : weakGl(&gl
), name(Create(gl
)) {}
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_ */