From af73929c6713fdb53f6a35620bc472caac4c40d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 4 Jul 2020 14:30:17 +0200 Subject: [PATCH] GL: implemented WEBGL_blend_equation_advanced_coherent. --- doc/changelog.dox | 3 + doc/opengl-support.dox | 1 + src/Magnum/GL/Context.cpp | 1 + src/Magnum/GL/Extensions.h | 1 + src/Magnum/GL/Renderer.h | 70 ++++++++++--------- .../OpenGL/GLES2/Emscripten/extensions.txt | 9 +++ .../OpenGL/GLES2/flextGLEmscripten.h | 18 +++++ .../OpenGL/GLES3/Emscripten/extensions.txt | 9 +++ .../OpenGL/GLES3/flextGLEmscripten.h | 22 ++++++ 9 files changed, 100 insertions(+), 34 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 81596ae4e..7920049aa 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -46,6 +46,9 @@ See also: @webgl_extension{EXT,texture_norm16} ES and WebGL extensions, making normalized 16-bit texture and renderbuffer formats available on all platforms +- Implemented @webgl_extension{WEBGL,blend_equation_advanced_coherent} + extension, making advanced @ref GL::Renderer::BlendEquation values + available on all platforms @subsubsection changelog-latest-new-math Math library diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 3f27f66d8..c84e5e6a8 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -561,6 +561,7 @@ Extension | Status @webgl_extension{WEBGL,compressed_texture_pvrtc} | done @webgl_extension{WEBGL,compressed_texture_astc} | done @webgl_extension{WEBGL,compressed_texture_s3tc_srgb} | done +@webgl_extension{WEBGL,blend_equation_advanced_coherent} | done @section opengl-unsupported Unsupported OpenGL features diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index dd1dbf203..1da7bd97f 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -280,6 +280,7 @@ constexpr Extension ExtensionList[]{ #ifndef MAGNUM_TARGET_GLES2 _extension(OVR,multiview2), #endif + _extension(WEBGL,blend_equation_advanced_coherent), _extension(WEBGL,compressed_texture_astc), _extension(WEBGL,compressed_texture_pvrtc), _extension(WEBGL,compressed_texture_s3tc), diff --git a/src/Magnum/GL/Extensions.h b/src/Magnum/GL/Extensions.h index dca431138..f5ca8ee56 100644 --- a/src/Magnum/GL/Extensions.h +++ b/src/Magnum/GL/Extensions.h @@ -335,6 +335,7 @@ namespace ANGLE { #endif _extension(30,WEBGL,compressed_texture_astc, GLES200, None) // #30 _extension(31,WEBGL,compressed_texture_s3tc_srgb, GLES200, None) // #32 + _extension(32,WEBGL,blend_equation_advanced_coherent,GLES200,None) // #42 } namespace MAGNUM { #ifndef MAGNUM_TARGET_GLES2 _extension(40,MAGNUM,shader_vertex_id, GLES300, GLES300) diff --git a/src/Magnum/GL/Renderer.h b/src/Magnum/GL/Renderer.h index 2cf39ae6a..af4d11fe5 100644 --- a/src/Magnum/GL/Renderer.h +++ b/src/Magnum/GL/Renderer.h @@ -91,7 +91,9 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in WebGL. + * @requires_gles Enabled by default on WebGL if the + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} + * is available. */ BlendAdvancedCoherent = GL_BLEND_ADVANCED_COHERENT_KHR, #endif @@ -1265,7 +1267,6 @@ class MAGNUM_GL_EXPORT Renderer { Max = GL_MAX_EXT, #endif - #ifndef MAGNUM_TARGET_WEBGL /** * Multiply. Not accepted as separate parameters in * @ref setBlendEquation(BlendEquation, BlendEquation), only in @@ -1274,8 +1275,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ Multiply = GL_MULTIPLY_KHR, @@ -1287,8 +1288,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ Screen = GL_SCREEN_KHR, @@ -1300,8 +1301,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ Overlay = GL_OVERLAY_KHR, @@ -1313,8 +1314,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ Darken = GL_DARKEN_KHR, @@ -1326,8 +1327,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ Lighten = GL_LIGHTEN_KHR, @@ -1339,8 +1340,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ ColorDodge = GL_COLORDODGE_KHR, @@ -1352,8 +1353,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ ColorBurn = GL_COLORBURN_KHR, @@ -1365,8 +1366,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ HardLight = GL_HARDLIGHT_KHR, @@ -1378,8 +1379,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ SoftLight = GL_SOFTLIGHT_KHR, @@ -1391,8 +1392,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ Difference = GL_DIFFERENCE_KHR, @@ -1404,8 +1405,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ Exclusion = GL_EXCLUSION_KHR, @@ -1417,8 +1418,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ HslHue = GL_HSL_HUE_KHR, @@ -1430,8 +1431,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ HslSaturation = GL_HSL_SATURATION_KHR, @@ -1443,8 +1444,8 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ HslColor = GL_HSL_COLOR_KHR, @@ -1456,11 +1457,10 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in - * WebGL. + * @requires_webgl_extension Extension + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} */ HslLuminosity = GL_HSL_LUMINOSITY_KHR - #endif }; /** @@ -1762,7 +1762,9 @@ class MAGNUM_GL_EXPORT Renderer { * @requires_extension Extension @gl_extension{KHR,blend_equation_advanced} * @requires_gles32 Extension @gl_extension{ANDROID,extension_pack_es31a} / * @gl_extension{KHR,blend_equation_advanced} - * @requires_gles Advanced blend equations are not available in WebGL. + * @requires_gles Enabled by default on WebGL if the + * @webgl_extension{WEBGL,blend_equation_advanced_coherent} + * is available. */ static void blendBarrier() { glBlendBarrierKHR(); } #endif diff --git a/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt b/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt index 01e6368c2..3a3a378f2 100644 --- a/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt @@ -33,4 +33,13 @@ extension EXT_texture_compression_s3tc_srgb optional extension IMG_texture_compression_pvrtc optional extension KHR_texture_compression_astc_ldr optional +# WEBGL_blend_equation_advanced_coherent includes just the enums but not the +# barrier +extension KHR_blend_equation_advanced optional + +begin functions blacklist + # Not present in WEBGL_blend_equation_advanced_coherent + BlendBarrierKHR +end functions blacklist + # kate: hl python diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h b/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h index 0fba0ae1d..daa7b1a44 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h @@ -569,6 +569,24 @@ typedef khronos_uint64_t GLuint64; #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +/* GL_KHR_blend_equation_advanced */ + +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 + /* Function prototypes */ /* GL_ANGLE_instanced_arrays */ diff --git a/src/MagnumExternal/OpenGL/GLES3/Emscripten/extensions.txt b/src/MagnumExternal/OpenGL/GLES3/Emscripten/extensions.txt index 8de829ec4..864728091 100644 --- a/src/MagnumExternal/OpenGL/GLES3/Emscripten/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES3/Emscripten/extensions.txt @@ -22,4 +22,13 @@ extension EXT_texture_compression_s3tc_srgb optional extension IMG_texture_compression_pvrtc optional extension KHR_texture_compression_astc_ldr optional +# WEBGL_blend_equation_advanced_coherent includes just the enums but not the +# barrier +extension KHR_blend_equation_advanced optional + +begin functions blacklist + # Not present in WEBGL_blend_equation_advanced_coherent + BlendBarrierKHR +end functions blacklist + # kate: hl python diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGLEmscripten.h b/src/MagnumExternal/OpenGL/GLES3/flextGLEmscripten.h index a67942352..3cb9ef2d8 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGLEmscripten.h +++ b/src/MagnumExternal/OpenGL/GLES3/flextGLEmscripten.h @@ -860,6 +860,28 @@ typedef struct __GLsync *GLsync; #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +/* GL_KHR_blend_equation_advanced_coherent */ + +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 + +/* GL_KHR_blend_equation_advanced */ + +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 + /* Function prototypes */ /* GL_ES_VERSION_2_0 */