From 042f28a90eed6359b1958da8bbcfd523974743a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 2 Jan 2022 12:25:37 +0100 Subject: [PATCH] GL: hook up EXT_texture_sRGB_RG8 for desktop GL as well. Was browsing the extension registry looking for something else and found this instead. It used to be ES catching up with desktop, now it's the other way around. --- doc/changelog.dox | 3 +++ doc/opengl-support.dox | 1 + src/Magnum/GL/AbstractTexture.cpp | 8 ++------ src/Magnum/GL/Context.cpp | 1 + src/Magnum/GL/Extensions.h | 3 ++- src/Magnum/GL/Implementation/pixelFormatMapping.hpp | 4 ---- src/Magnum/GL/Test/PixelFormatTest.cpp | 4 ++-- src/Magnum/GL/TextureFormat.cpp | 6 +----- src/Magnum/GL/TextureFormat.h | 11 +++-------- src/MagnumExternal/OpenGL/GL/extensions.txt | 1 + src/MagnumExternal/OpenGL/GL/flextGL.h | 4 ++++ 11 files changed, 20 insertions(+), 26 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 4273447ef..a90454223 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -88,6 +88,9 @@ See also: @webgl_extension{EXT,texture_norm16} ES and WebGL extensions, making normalized 16-bit texture and renderbuffer formats available on all platforms +- The @gl_extension{EXT,texture_sRGB_RG8} extension is now available on + desktop OpenGL as well, exposing a two-component sRGB format in addition to + the already present one-, three- and four-component formats - Implemented @webgl_extension{WEBGL,blend_equation_advanced_coherent} extension, making advanced @ref GL::Renderer::BlendEquation values available on all platforms diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index be3879ab4..5fa2e2252 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -323,6 +323,7 @@ Extension | Status @gl_extension{EXT,debug_label} | missing pipeline and sampler label @gl_extension{EXT,debug_marker} | done @gl_extension{EXT,texture_sRGB_R8} | done +@gl_extension{EXT,texture_sRGB_RG8} | done @gl_extension{GREMEDY,string_marker} | done @gl_extension{NV,sample_locations} | | @gl_extension{NV,fragment_shader_barycentric} | done (shading language only) diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index e016256b9..51294a550 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -610,7 +610,7 @@ PixelFormat pixelFormatForInternalFormat(const TextureFormat internalFormat) { #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RG8Snorm: #endif - #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) + #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::SRG8: #endif #ifndef MAGNUM_TARGET_GLES2 @@ -917,14 +917,10 @@ PixelType pixelTypeForInternalFormat(const TextureFormat internalFormat) { case TextureFormat::Luminance: case TextureFormat::LuminanceAlpha: #endif - #ifndef MAGNUM_TARGET_WEBGL - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) case TextureFormat::SR8: - #endif - #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) case TextureFormat::SRG8: #endif - #endif #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) case TextureFormat::SRGB: case TextureFormat::SRGBAlpha: diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index b15b5a0fd..de9a3e1c1 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -98,6 +98,7 @@ constexpr Extension ExtensionList[]{ Extensions::EXT::texture_filter_anisotropic{}, Extensions::EXT::texture_mirror_clamp{}, Extensions::EXT::texture_sRGB_R8{}, + Extensions::EXT::texture_sRGB_RG8{}, Extensions::EXT::texture_sRGB_decode{}, Extensions::GREMEDY::string_marker{}, Extensions::KHR::blend_equation_advanced{}, diff --git a/src/Magnum/GL/Extensions.h b/src/Magnum/GL/Extensions.h index 9c2750da1..b245e59f3 100644 --- a/src/Magnum/GL/Extensions.h +++ b/src/Magnum/GL/Extensions.h @@ -242,8 +242,9 @@ namespace AMD { _extension(154,EXT,debug_label, GL210, None) // #439 _extension(155,EXT,debug_marker, GL210, None) // #440 _extension(156,EXT,texture_sRGB_R8, GL210, None) // #534 + _extension(157,EXT,texture_sRGB_RG8, GL210, None) // #555 } namespace GREMEDY { - _extension(157,GREMEDY,string_marker, GL210, None) // #311 + _extension(158,GREMEDY,string_marker, GL210, None) // #311 } namespace KHR { _extension(160,KHR,texture_compression_astc_ldr, GL210, None) // #118 _extension(161,KHR,texture_compression_astc_hdr, GL210, None) // #118 diff --git a/src/Magnum/GL/Implementation/pixelFormatMapping.hpp b/src/Magnum/GL/Implementation/pixelFormatMapping.hpp index 8a0c14111..6ad10bc15 100644 --- a/src/Magnum/GL/Implementation/pixelFormatMapping.hpp +++ b/src/Magnum/GL/Implementation/pixelFormatMapping.hpp @@ -59,12 +59,8 @@ _s(RGBA8Snorm) #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_WEBGL _c(R8Srgb, Red, UnsignedByte, SR8) -#ifdef MAGNUM_TARGET_GLES _c(RG8Srgb, RG, UnsignedByte, SRG8) #else -_n(RG8Srgb, RG, UnsignedByte) -#endif -#else _n(R8Srgb, Red, UnsignedByte) _n(RG8Srgb, RG, UnsignedByte) #endif diff --git a/src/Magnum/GL/Test/PixelFormatTest.cpp b/src/Magnum/GL/Test/PixelFormatTest.cpp index 5c5fbd35b..bf6dcf58b 100644 --- a/src/Magnum/GL/Test/PixelFormatTest.cpp +++ b/src/Magnum/GL/Test/PixelFormatTest.cpp @@ -311,8 +311,8 @@ void PixelFormatTest::mapTextureFormatUnsupported() { std::ostringstream out; Error redirectError{&out}; - textureFormat(Magnum::PixelFormat::RG8Srgb); - CORRADE_COMPARE(out.str(), "GL::textureFormat(): format PixelFormat::RG8Srgb is not supported on this target\n"); + textureFormat(Magnum::PixelFormat::Depth16UnormStencil8UI); + CORRADE_COMPARE(out.str(), "GL::textureFormat(): format PixelFormat::Depth16UnormStencil8UI is not supported on this target\n"); #endif } diff --git a/src/Magnum/GL/TextureFormat.cpp b/src/Magnum/GL/TextureFormat.cpp index 8ef426937..435eabed3 100644 --- a/src/Magnum/GL/TextureFormat.cpp +++ b/src/Magnum/GL/TextureFormat.cpp @@ -63,14 +63,10 @@ Debug& operator<<(Debug& debug, const TextureFormat value) { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) _c(RGBA8) #endif - #ifndef MAGNUM_TARGET_WEBGL - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) _c(SR8) - #endif - #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) _c(SRG8) #endif - #endif #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) _c(SRGB) #endif diff --git a/src/Magnum/GL/TextureFormat.h b/src/Magnum/GL/TextureFormat.h index 9a870c0e3..b7a36bb0c 100644 --- a/src/Magnum/GL/TextureFormat.h +++ b/src/Magnum/GL/TextureFormat.h @@ -195,8 +195,7 @@ enum class TextureFormat: GLenum { #endif #endif - #ifndef MAGNUM_TARGET_WEBGL - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) /** * sRGB-encoded red component, normalized unsigned byte. * @requires_extension Extension @gl_extension{EXT,texture_sRGB_R8} @@ -208,23 +207,19 @@ enum class TextureFormat: GLenum { * @m_since{2019,10} */ SR8 = GL_SR8_EXT, - #endif - #if (defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2)) || defined(DOXYGEN_GENERATING_OUTPUT) /** * sRGB-encoded red and green component, normalized unsigned byte. + * @requires_extension Extension @gl_extension{EXT,texture_sRGB_RG8} * @requires_es_extension OpenGL ES 3.0 and extension * @gl_extension{EXT,texture_sRGB_RG8} * @requires_gles One- and two-component sRGB texture formats are not * available in WebGL, use @ref TextureFormat::SRGB8 or - * @ref TextureFormat::SRGB8Alpha8 instead. Only - * @ref TextureFormat::SR8, @ref TextureFormat::SRGB8 or - * @ref TextureFormat::SRGB8Alpha8 is available in desktop OpenGL. + * @ref TextureFormat::SRGB8Alpha8 instead. * @m_since{2019,10} */ SRG8 = GL_SRG8_EXT, #endif - #endif #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) /** diff --git a/src/MagnumExternal/OpenGL/GL/extensions.txt b/src/MagnumExternal/OpenGL/GL/extensions.txt index 6730c237c..cb8f6593f 100644 --- a/src/MagnumExternal/OpenGL/GL/extensions.txt +++ b/src/MagnumExternal/OpenGL/GL/extensions.txt @@ -34,6 +34,7 @@ extension EXT_shader_integer_mix optional extension EXT_debug_label optional extension EXT_debug_marker optional extension EXT_texture_sRGB_R8 optional +extension EXT_texture_sRGB_RG8 optional extension GREMEDY_string_marker optional extension KHR_texture_compression_astc_ldr optional # extension KHR_texture_compression_astc_hdr optional diff --git a/src/MagnumExternal/OpenGL/GL/flextGL.h b/src/MagnumExternal/OpenGL/GL/flextGL.h index e3fa1ee3e..b38a763d0 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGL.h +++ b/src/MagnumExternal/OpenGL/GL/flextGL.h @@ -1716,6 +1716,10 @@ typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum #define GL_SR8_EXT 0x8FBD +/* GL_EXT_texture_sRGB_RG8 */ + +#define GL_SRG8_EXT 0x8FBE + /* GL_KHR_texture_compression_astc_ldr */ #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0