From 93fa1b9f943a15f8919cc9c9ed10ccc7b129a062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 24 Feb 2021 20:26:25 +0100 Subject: [PATCH] GL: EXT_texture_norm16 is not on WebGL 1 anymore. It got changed shortly after the original implementation in 083ecf72b8a3de8b92cd2df2a597722a636c19da to be WebGL 2 only. --- src/Magnum/GL/AbstractTexture.cpp | 20 +++----------- src/Magnum/GL/Context.cpp | 2 ++ src/Magnum/GL/Extensions.h | 2 +- .../GL/Implementation/pixelFormatMapping.hpp | 8 +----- src/Magnum/GL/PixelFormat.cpp | 6 ++--- src/Magnum/GL/PixelFormat.h | 14 +++++----- src/Magnum/GL/RenderbufferFormat.h | 21 +++++++++------ src/Magnum/GL/TextureFormat.cpp | 2 +- src/Magnum/GL/TextureFormat.h | 27 ++++++++++++------- .../OpenGL/GLES2/Emscripten/extensions.txt | 1 - .../OpenGL/GLES2/flextGLEmscripten.h | 11 -------- 11 files changed, 49 insertions(+), 65 deletions(-) diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index 275035e57..24fc8f128 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -662,8 +662,7 @@ PixelFormat pixelFormatForInternalFormat(const TextureFormat internalFormat) { #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RGB8Snorm: #endif - /* Available everywhere except ES2 (WebGL 1 has it) */ - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RGB16: case TextureFormat::RGB16Snorm: #endif @@ -741,8 +740,7 @@ PixelFormat pixelFormatForInternalFormat(const TextureFormat internalFormat) { #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RGBA8Snorm: #endif - /* Available everywhere except ES2 (WebGL 1 has it) */ - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RGBA16: case TextureFormat::RGBA16Snorm: #endif @@ -853,16 +851,8 @@ PixelFormat pixelFormatForInternalFormat(const TextureFormat internalFormat) { #ifdef MAGNUM_TARGET_GLES2 case TextureFormat::Luminance: - #ifdef MAGNUM_TARGET_WEBGL - case TextureFormat::R16: - case TextureFormat::R16Snorm: - #endif return PixelFormat::Luminance; case TextureFormat::LuminanceAlpha: - #ifdef MAGNUM_TARGET_WEBGL - case TextureFormat::RG16: - case TextureFormat::RG16Snorm: - #endif return PixelFormat::LuminanceAlpha; #endif @@ -1058,8 +1048,7 @@ PixelType pixelTypeForInternalFormat(const TextureFormat internalFormat) { #endif #endif - /* Available everywhere except ES2 (WebGL 1 has it) */ - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::R16: case TextureFormat::RG16: case TextureFormat::RGB16: @@ -1080,8 +1069,7 @@ PixelType pixelTypeForInternalFormat(const TextureFormat internalFormat) { #endif return PixelType::UnsignedShort; - /* Available everywhere except ES2 (WebGL 1 has it) */ - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::R16Snorm: case TextureFormat::RG16Snorm: case TextureFormat::RGB16Snorm: diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index 7a438e941..e47604bf6 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -285,7 +285,9 @@ constexpr Extension ExtensionList[]{ Extensions::EXT::texture_compression_bptc{}, Extensions::EXT::texture_compression_rgtc{}, Extensions::EXT::texture_filter_anisotropic{}, + #ifndef MAGNUM_TARGET_GLES2 Extensions::EXT::texture_norm16{}, + #endif Extensions::OES::texture_float_linear{}, #ifndef MAGNUM_TARGET_GLES2 Extensions::OVR::multiview2{}, diff --git a/src/Magnum/GL/Extensions.h b/src/Magnum/GL/Extensions.h index b03b8e944..92db6ce13 100644 --- a/src/Magnum/GL/Extensions.h +++ b/src/Magnum/GL/Extensions.h @@ -301,8 +301,8 @@ namespace ANGLE { _extension(13,EXT,texture_compression_bptc, GLES200, None) // #39 #ifndef MAGNUM_TARGET_GLES2 _extension(14,EXT,clip_cull_distance, GLES300, None) // #43 + _extension(15,EXT,texture_norm16, GLES300, None) // #44 #endif - _extension(15,EXT,texture_norm16, GLES200, None) // #44 #ifndef MAGNUM_TARGET_GLES2 _extension(16,EXT,draw_buffers_indexed, GLES300, None) // #45 #endif diff --git a/src/Magnum/GL/Implementation/pixelFormatMapping.hpp b/src/Magnum/GL/Implementation/pixelFormatMapping.hpp index 37a8e22e3..0d487f6b4 100644 --- a/src/Magnum/GL/Implementation/pixelFormatMapping.hpp +++ b/src/Magnum/GL/Implementation/pixelFormatMapping.hpp @@ -115,17 +115,11 @@ _n(RG16Unorm, LuminanceAlpha, UnsignedShort) _n(RGB16Unorm, RGB, UnsignedShort) _n(RGBA16Unorm, RGBA, UnsignedShort) #endif -/* Available everywhere except ES2 (WebGL 1 has it) */ -#ifndef MAGNUM_TARGET_GLES2 +#ifndef MAGNUM_TARGET_GLES _c(R16Snorm, Red, Short, R16Snorm) _c(RG16Snorm, RG, Short, RG16Snorm) _c(RGB16Snorm, RGB, Short, RGB16Snorm) _c(RGBA16Snorm, RGBA, Short, RGBA16Snorm) -#elif defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL) -_c(R16Snorm, Luminance, Short, R16Snorm) -_c(RG16Snorm, LuminanceAlpha, Short, RG16Snorm) -_c(RGB16Snorm, RGB, Short, RGB16Snorm) -_c(RGBA16Snorm, RGBA, Short, RGBA16Snorm) #else _s(R16Snorm) _s(RG16Snorm) diff --git a/src/Magnum/GL/PixelFormat.cpp b/src/Magnum/GL/PixelFormat.cpp index e9bd60574..155629a41 100644 --- a/src/Magnum/GL/PixelFormat.cpp +++ b/src/Magnum/GL/PixelFormat.cpp @@ -135,8 +135,7 @@ UnsignedInt pixelSize(const PixelFormat format, const PixelType type) { #endif size = 1; break; case PixelType::UnsignedShort: - /* Available everywhere except ES2 (WebGL 1 has it) */ - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 case PixelType::Short: #endif case PixelType::Half: @@ -345,8 +344,7 @@ Debug& operator<<(Debug& debug, const PixelType value) { _c(Byte) #endif _c(UnsignedShort) - /* Available everywhere except ES2 (WebGL 1 has it) */ - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 _c(Short) #endif _c(UnsignedInt) diff --git a/src/Magnum/GL/PixelFormat.h b/src/Magnum/GL/PixelFormat.h index 8b3efb5f5..46c631f82 100644 --- a/src/Magnum/GL/PixelFormat.h +++ b/src/Magnum/GL/PixelFormat.h @@ -376,21 +376,23 @@ enum class PixelType: GLenum { * for color texture data * @requires_webgl20 Extension @webgl_extension{WEBGL,depth_texture} in * WebGL 1.0 for depth texture data - * @requires_webgl_extension @webgl_extension{EXT,texture_norm16} for color - * texture data + * @requires_webgl20 For integer color texture data + * @requires_webgl_extension WebGL 2.0 and + * @webgl_extension{EXT,texture_norm16} for normalized color texture + * data */ UnsignedShort = GL_UNSIGNED_SHORT, - /* Available everywhere except ES2 (WebGL 1 has it) */ - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 /** * Each component signed short. * @requires_gl Can't be used for framebuffer reading in OpenGL ES or * WebGL. * @requires_gles30 For texture data only, only @ref PixelType::UnsignedShort * is available in OpenGL ES 2.0. - * @requires_webgl20 For texture data only, @webgl_extension{EXT,texture_norm16} - * in WebGL 1.0. + * @requires_webgl20 For integer texture data. Not available in WebGL 1.0. + * @requires_webgl_extension WebGL 2.0 and + * @webgl_extension{EXT,texture_norm16} for normalized texture data */ Short = GL_SHORT, #endif diff --git a/src/Magnum/GL/RenderbufferFormat.h b/src/Magnum/GL/RenderbufferFormat.h index 8b32b23ad..0d037d79c 100644 --- a/src/Magnum/GL/RenderbufferFormat.h +++ b/src/Magnum/GL/RenderbufferFormat.h @@ -125,16 +125,17 @@ enum class RenderbufferFormat: GLenum { #endif #endif - /* Available everywhere except ES2 (WebGL 1 has it) */ - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 /** * Red component, normalized unsigned short. * @requires_gl30 Extension @gl_extension{ARB,texture_rg} * @requires_gles31 Only byte-sized normalized formats (such as * @ref RenderbufferFormat::RG8) are available in OpenGL ES 3.0 and * older; not defined on ES2 - * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_es_extension OpenGL ES 3.1 and extension + * @gl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES R16 = GL_R16, @@ -148,8 +149,10 @@ enum class RenderbufferFormat: GLenum { * @requires_gles31 Only byte-sized normalized formats (such as * @ref RenderbufferFormat::RG8) are available in OpenGL ES 3.0 and * older; not defined on ES2 - * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_es_extension OpenGL ES 3.1 and extension + * @gl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES RG16 = GL_RG16, @@ -171,8 +174,10 @@ enum class RenderbufferFormat: GLenum { * @requires_gles31 Only byte-sized normalized formats (such as * @ref RenderbufferFormat::RG8) are available in OpenGL ES 3.0 and * older; not defined on ES2 - * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_es_extension OpenGL ES 3.1 and extension + * @gl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES RGBA16 = GL_RGBA16, diff --git a/src/Magnum/GL/TextureFormat.cpp b/src/Magnum/GL/TextureFormat.cpp index 6d43e02e4..8ef426937 100644 --- a/src/Magnum/GL/TextureFormat.cpp +++ b/src/Magnum/GL/TextureFormat.cpp @@ -89,7 +89,7 @@ Debug& operator<<(Debug& debug, const TextureFormat value) { _c(RGB8Snorm) _c(RGBA8Snorm) #endif - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 _c(R16) _c(RG16) _c(RGB16) diff --git a/src/Magnum/GL/TextureFormat.h b/src/Magnum/GL/TextureFormat.h index a9638cf0a..623243ecf 100644 --- a/src/Magnum/GL/TextureFormat.h +++ b/src/Magnum/GL/TextureFormat.h @@ -335,15 +335,15 @@ enum class TextureFormat: GLenum { RGBA8Snorm = GL_RGBA8_SNORM, #endif - /* Available everywhere except ES2 (WebGL 1 has it) */ - #if !(defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)) + #ifndef MAGNUM_TARGET_GLES2 /** * Red component, normalized unsigned short. * @requires_gl30 Extension @gl_extension{ARB,texture_rg} * @requires_gles30 Only byte-sized normalized formats are available in * OpenGL ES 2.0 * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES R16 = GL_R16, @@ -357,7 +357,8 @@ enum class TextureFormat: GLenum { * @requires_gles31 Only byte-sized normalized formats are available in * OpenGL ES 3.0 and older; not defined on ES2 * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES RG16 = GL_RG16, @@ -370,7 +371,8 @@ enum class TextureFormat: GLenum { * @requires_gles31 Only byte-sized normalized formats are available in * OpenGL ES 3.0 and older; not defined on ES2 * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES RGB16 = GL_RGB16, @@ -383,7 +385,8 @@ enum class TextureFormat: GLenum { * @requires_gles31 Only byte-sized normalized formats are available in * OpenGL ES 3.0 and older; not defined on ES2 * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES RGBA16 = GL_RGBA16, @@ -397,7 +400,8 @@ enum class TextureFormat: GLenum { * @requires_gles31 Only byte-sized normalized formats are available in * OpenGL ES 3.0 and older; not defined on ES2 * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES R16Snorm = GL_R16_SNORM, @@ -411,7 +415,8 @@ enum class TextureFormat: GLenum { * @requires_gles31 Only byte-sized normalized formats are available in * OpenGL ES 3.0 and older; not defined on ES2 * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES RG16Snorm = GL_RG16_SNORM, @@ -425,7 +430,8 @@ enum class TextureFormat: GLenum { * @requires_gles31 Only byte-sized normalized formats are available in * OpenGL ES 3.0 and older; not defined on ES2 * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES RGB16Snorm = GL_RGB16_SNORM, @@ -439,7 +445,8 @@ enum class TextureFormat: GLenum { * @requires_gles31 Only byte-sized normalized formats are available in * OpenGL ES 3.0 and older; not defined on ES2 * @requires_es_extension OpenGL ES 3.1 and @gl_extension{EXT,texture_norm16} - * @requires_webgl_extension Extension @webgl_extension{EXT,texture_norm16} + * @requires_webgl_extension WebGL 2.0 and extension + * @webgl_extension{EXT,texture_norm16} */ #ifndef MAGNUM_TARGET_GLES RGBA16Snorm = GL_RGBA16_SNORM, diff --git a/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt b/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt index a95e95b8c..dfb959d2b 100644 --- a/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt @@ -27,7 +27,6 @@ extension EXT_texture_filter_anisotropic optional extension EXT_disjoint_timer_query optional extension EXT_texture_compression_rgtc optional extension EXT_texture_compression_bptc optional -extension EXT_texture_norm16 optional # These are used as a base for WEBGL_* extensions extension EXT_color_buffer_float optional extension EXT_texture_compression_s3tc optional diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h b/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h index c357e5a57..58638b680 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h @@ -506,17 +506,6 @@ typedef khronos_uint64_t GLuint64; #define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT 0x8E8E #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT 0x8E8F -/* GL_EXT_texture_norm16 */ - -#define GL_R16_EXT 0x822A -#define GL_RG16_EXT 0x822C -#define GL_RGBA16_EXT 0x805B -#define GL_RGB16_EXT 0x8054 -#define GL_R16_SNORM_EXT 0x8F98 -#define GL_RG16_SNORM_EXT 0x8F99 -#define GL_RGB16_SNORM_EXT 0x8F9A -#define GL_RGBA16_SNORM_EXT 0x8F9B - /* GL_EXT_texture_compression_s3tc */ #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0