Browse Source

GL: fix EXT_color_buffer_half_float to be presennt also in WebGL 2.

It was mistakenly thought to be replaced by the EXT_color_buffer_float
(which replaces WEBGL_color_buffer_float and in addition lists both 16-
and 32-bit float variants). But since there are still those stupid
patents for rendering to 32-bit float attachments, certain hardware
supports only rendering to 16-bit and not 32-bit, so the "superset"
extension isn't enough to be able to discover which hardware can
render to half-floats.

Also updated (hopefully all) docs to list this extension as being an
option on WebGL 2 as well.
pull/525/head
Vladimír Vondruš 4 years ago
parent
commit
b8815582ce
  1. 2
      doc/opengl-support.dox
  2. 2
      src/Magnum/GL/Context.cpp
  3. 2
      src/Magnum/GL/Extensions.h
  4. 15
      src/Magnum/GL/PixelFormat.h
  5. 25
      src/Magnum/GL/RenderbufferFormat.h
  6. 5
      src/Magnum/GL/Test/ContextTest.cpp
  7. 30
      src/Magnum/GL/TextureFormat.h

2
doc/opengl-support.dox

@ -524,7 +524,6 @@ namespace on @ref MAGNUM_TARGET_GLES2 "WebGL 2.0 builds".
Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
@webgl_extension{ANGLE,instanced_arrays} | done @webgl_extension{ANGLE,instanced_arrays} | done
@webgl_extension{EXT,color_buffer_half_float} | |
@webgl_extension{EXT,frag_depth} | done (shading language only) @webgl_extension{EXT,frag_depth} | done (shading language only)
@webgl_extension{EXT,sRGB} | done @webgl_extension{EXT,sRGB} | done
@webgl_extension{EXT,blend_minmax} | done @webgl_extension{EXT,blend_minmax} | done
@ -553,6 +552,7 @@ Extension | Status
Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
@webgl_extension{EXT,texture_filter_anisotropic} | done @webgl_extension{EXT,texture_filter_anisotropic} | done
@webgl_extension{EXT,color_buffer_half_float} | |
@webgl_extension{EXT,disjoint_timer_query} | only time elapsed query @webgl_extension{EXT,disjoint_timer_query} | only time elapsed query
@webgl_extension{EXT,disjoint_timer_query_webgl2} | [missing support in Emscripten](https://github.com/emscripten-core/emscripten/pull/9652) @webgl_extension{EXT,disjoint_timer_query_webgl2} | [missing support in Emscripten](https://github.com/emscripten-core/emscripten/pull/9652)
@webgl_extension{EXT,color_buffer_float} | | @webgl_extension{EXT,color_buffer_float} | |

2
src/Magnum/GL/Context.cpp

@ -271,6 +271,7 @@ constexpr Extension ExtensionList[]{
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Extensions::EXT::color_buffer_float{}, Extensions::EXT::color_buffer_float{},
#endif #endif
Extensions::EXT::color_buffer_half_float{},
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
Extensions::EXT::disjoint_timer_query{}, Extensions::EXT::disjoint_timer_query{},
#endif #endif
@ -311,7 +312,6 @@ constexpr Extension ExtensionListES300[]{
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
Extensions::ANGLE::instanced_arrays{}, Extensions::ANGLE::instanced_arrays{},
Extensions::EXT::blend_minmax{}, Extensions::EXT::blend_minmax{},
Extensions::EXT::color_buffer_half_float{},
Extensions::EXT::frag_depth{}, Extensions::EXT::frag_depth{},
Extensions::EXT::sRGB{}, Extensions::EXT::sRGB{},
Extensions::EXT::shader_texture_lod{}, Extensions::EXT::shader_texture_lod{},

2
src/Magnum/GL/Extensions.h

@ -275,9 +275,7 @@ namespace ANGLE {
#endif #endif
} namespace EXT { } namespace EXT {
_extension( 2,EXT,texture_filter_anisotropic, GLES200, None) // #11 _extension( 2,EXT,texture_filter_anisotropic, GLES200, None) // #11
#ifdef MAGNUM_TARGET_GLES2
_extension( 3,EXT,color_buffer_half_float, GLES200, None) // #14 _extension( 3,EXT,color_buffer_half_float, GLES200, None) // #14
#endif
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
_extension( 4,EXT,frag_depth, GLES200, GLES300) // #16 _extension( 4,EXT,frag_depth, GLES200, GLES300) // #16
_extension( 5,EXT,sRGB, GLES200, GLES300) // #17 _extension( 5,EXT,sRGB, GLES200, GLES300) // #17

15
src/Magnum/GL/PixelFormat.h

@ -433,8 +433,10 @@ enum class PixelType: GLenum {
* use for texture reading in WebGL 1.0. * use for texture reading in WebGL 1.0.
* @requires_webgl20 Extension @webgl_extension{OES,texture_half_float_linear} * @requires_webgl20 Extension @webgl_extension{OES,texture_half_float_linear}
* for filtering the texture using @ref SamplerFilter::Linear. * for filtering the texture using @ref SamplerFilter::Linear.
* @requires_webgl_extension Extension @webgl_extension{EXT,color_buffer_half_float} * @requires_webgl_extension Extension
* to use the texture as a render target. * @webgl_extension{EXT,color_buffer_half_float} in WebGL 1.0 and 2.0
* or @webgl_extension{EXT,color_buffer_float} in WebGL 2.0 to use the
* texture as a render target.
*/ */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Half = GL_HALF_FLOAT, Half = GL_HALF_FLOAT,
@ -462,9 +464,10 @@ enum class PixelType: GLenum {
* for texture reading in WebGL 1.0. * for texture reading in WebGL 1.0.
* @requires_webgl_extension Extension @webgl_extension{OES,texture_float_linear} * @requires_webgl_extension Extension @webgl_extension{OES,texture_float_linear}
* for filtering the texture using @ref SamplerFilter::Linear. * for filtering the texture using @ref SamplerFilter::Linear.
* @requires_webgl_extension Extension @webgl_extension{WEBGL,color_buffer_float} * @requires_webgl_extension Extension
* in WebGL 1.0 or @webgl_extension{EXT,color_buffer_float} in WebGL * @webgl_extension{WEBGL,color_buffer_float} in WebGL 1.0 or
* 2.0 to use the texture as a render target. * @webgl_extension{EXT,color_buffer_float} in WebGL 2.0 to use the
* texture as a render target.
*/ */
Float = GL_FLOAT, Float = GL_FLOAT,
@ -593,6 +596,8 @@ enum class PixelType: GLenum {
* @requires_gles30 Only 8bit and 16bit types are available in OpenGL ES * @requires_gles30 Only 8bit and 16bit types are available in OpenGL ES
* 2.0. * 2.0.
* @requires_webgl20 Only 8bit and 16bit types are available in WebGL 1.0. * @requires_webgl20 Only 8bit and 16bit types are available in WebGL 1.0.
* @requires_webgl_extension @webgl_extension{EXT,color_buffer_float} in
* WebGL 2.0 to use the texture as a render target.
*/ */
UnsignedInt5999Rev = GL_UNSIGNED_INT_5_9_9_9_REV, UnsignedInt5999Rev = GL_UNSIGNED_INT_5_9_9_9_REV,
#endif #endif

25
src/Magnum/GL/RenderbufferFormat.h

@ -408,9 +408,11 @@ enum class RenderbufferFormat: GLenum {
* @requires_webgl20 Not defined in WebGL 1.0 builds. Only four-component * @requires_webgl20 Not defined in WebGL 1.0 builds. Only four-component
* half-float formats can be ised as a render target in WebGL 1.0, see * half-float formats can be ised as a render target in WebGL 1.0, see
* @ref RenderbufferFormat::RGBA16F for more information. * @ref RenderbufferFormat::RGBA16F for more information.
* @requires_webgl_extension Extension @webgl_extension{EXT,color_buffer_float} * @requires_webgl_extension Extension
* in WebGL 2.0. Use @ref RenderbufferFormat::R16UI or * @webgl_extension{EXT,color_buffer_half_float} or
* @ref RenderbufferFormat::R16I instead if not available. * @webgl_extension{EXT,color_buffer_float} in WebGL 2.0. Use
* @ref RenderbufferFormat::R16UI or @ref RenderbufferFormat::R16I
* instead if not available.
*/ */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
R16F = GL_R16F, R16F = GL_R16F,
@ -427,9 +429,11 @@ enum class RenderbufferFormat: GLenum {
* @requires_webgl20 Not defined in WebGL 1.0 builds. Only four-component * @requires_webgl20 Not defined in WebGL 1.0 builds. Only four-component
* half-float formats can be ised as a render target in WebGL 1.0, see * half-float formats can be ised as a render target in WebGL 1.0, see
* @ref RenderbufferFormat::RGBA16F for more information. * @ref RenderbufferFormat::RGBA16F for more information.
* @requires_webgl_extension Extension @webgl_extension{EXT,color_buffer_float} * @requires_webgl_extension Extension
* in WebGL 2.0. Use @ref RenderbufferFormat::RG16UI or * @webgl_extension{EXT,color_buffer_half_float} or
* @ref RenderbufferFormat::RG16I instead if not available. * @webgl_extension{EXT,color_buffer_float} in WebGL 2.0. Use
* @ref RenderbufferFormat::RG16UI or @ref RenderbufferFormat::RG16I
* instead if not available.
*/ */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
RG16F = GL_RG16F, RG16F = GL_RG16F,
@ -444,10 +448,11 @@ enum class RenderbufferFormat: GLenum {
* @requires_gles32 Extension @gl_extension{EXT,color_buffer_half_float}. Use * @requires_gles32 Extension @gl_extension{EXT,color_buffer_half_float}. Use
* @ref RenderbufferFormat::RGBA16UI or @ref RenderbufferFormat::RGBA16I * @ref RenderbufferFormat::RGBA16UI or @ref RenderbufferFormat::RGBA16I
* instead if not available. * instead if not available.
* @requires_webgl_extension Extension @webgl_extension{EXT,color_buffer_half_float} * @requires_webgl_extension Extension
* in WebGL 1.0, @webgl_extension{EXT,color_buffer_half_float} in * @webgl_extension{EXT,color_buffer_half_float} in WebGL 1.0 and 2.0
* WebGL 2.0. Use @ref RenderbufferFormat::RGBA16UI or * or @webgl_extension{EXT,color_buffer_float} in WebGL 2.0. Use
* @ref RenderbufferFormat::RGBA16I instead if not available. * @ref RenderbufferFormat::RGBA16UI or @ref RenderbufferFormat::RGBA16I
* instead if not available.
*/ */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
RGBA16F = GL_RGBA16F, RGBA16F = GL_RGBA16F,

5
src/Magnum/GL/Test/ContextTest.cpp

@ -421,9 +421,8 @@ void ContextTest::extensions() {
CORRADE_VERIFY(Int(e.coreVersion()) >= Int(e.requiredVersion())); CORRADE_VERIFY(Int(e.coreVersion()) >= Int(e.requiredVersion()));
bool coreVersionMismatch = e.coreVersion() != version bool coreVersionMismatch = e.coreVersion() != version
#if defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL) #if defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)
/* These two are replaced by EXT_color_buffer_float for 2.0, /* Replaced by EXT_color_buffer_float for 2.0 but not core in
but aren't core in WebGL 2 */ WebGL 2 */
&& e.index() != Extensions::EXT::color_buffer_half_float::Index
&& e.index() != Extensions::WEBGL::color_buffer_float::Index && e.index() != Extensions::WEBGL::color_buffer_float::Index
#endif #endif
; ;

30
src/Magnum/GL/TextureFormat.h

@ -739,9 +739,11 @@ enum class TextureFormat: GLenum {
* in WebGL 1.0. * in WebGL 1.0.
* @requires_webgl20 Extension @webgl_extension{OES,texture_half_float_linear} * @requires_webgl20 Extension @webgl_extension{OES,texture_half_float_linear}
* for filtering using @ref SamplerFilter::Linear in WebGL 1.0. * for filtering using @ref SamplerFilter::Linear in WebGL 1.0.
* @requires_webgl_extension Extension @webgl_extension{EXT,color_buffer_float} * @requires_webgl_extension Extension
* to use as a render target in WebGL 2.0; use @ref TextureFormat::R16UI * @webgl_extension{EXT,color_buffer_half_float} or
* or @ref TextureFormat::R16I instead if not available. Only three- * @webgl_extension{EXT,color_buffer_float} to use as a render target
* in WebGL 2.0; use @ref TextureFormat::R16UI or
* @ref TextureFormat::R16I instead if not available. Only three-
* and four-component half-float texture formats can be used as * and four-component half-float texture formats can be used as
* a render target in WebGL 1.0, see @ref TextureFormat::RGBA16F for * a render target in WebGL 1.0, see @ref TextureFormat::RGBA16F for
* more information. * more information.
@ -767,9 +769,11 @@ enum class TextureFormat: GLenum {
* in WebGL 1.0 instead. * in WebGL 1.0 instead.
* @requires_webgl20 Extension @webgl_extension{OES,texture_half_float_linear} * @requires_webgl20 Extension @webgl_extension{OES,texture_half_float_linear}
* for filtering using @ref SamplerFilter::Linear in WebGL 1.0. * for filtering using @ref SamplerFilter::Linear in WebGL 1.0.
* @requires_webgl_extension Extension @webgl_extension{EXT,color_buffer_float} * @requires_webgl_extension Extension
* to use as a render target in WebGL 2.0; use @ref TextureFormat::RG16UI * @webgl_extension{EXT,color_buffer_half_float} or
* or @ref TextureFormat::RG16I instead if not available. Only three- * @webgl_extension{EXT,color_buffer_float} to use as a render target
* in WebGL 2.0; use @ref TextureFormat::RG16UI or
* @ref TextureFormat::RG16I instead if not available. Only three-
* and four-component half-float texture formats can be used as * and four-component half-float texture formats can be used as
* a render target in WebGL 1.0, see @ref TextureFormat::RGBA16F for * a render target in WebGL 1.0, see @ref TextureFormat::RGBA16F for
* more information. * more information.
@ -813,11 +817,14 @@ enum class TextureFormat: GLenum {
* @requires_webgl20 Use @ref TextureFormat::RGBA in combination with * @requires_webgl20 Use @ref TextureFormat::RGBA in combination with
* @ref PixelType::Half (@webgl_extension{OES,texture_half_float}) in * @ref PixelType::Half (@webgl_extension{OES,texture_half_float}) in
* WebGL 1.0 instead. * WebGL 1.0 instead.
* @requires_webgl_extension Extension @webgl_extension{EXT,color_buffer_float} * @requires_webgl_extension Extension
* to use as a render target in WebGL 2.0. Use @ref TextureFormat::RGBA16UI * @webgl_extension{EXT,color_buffer_half_float} or
* or @ref TextureFormat::RGBA16I instead if not available. Use * @webgl_extension{EXT,color_buffer_float} to use as a render target
* in WebGL 2.0. Use @ref TextureFormat::RGBA16UI or
* @ref TextureFormat::RGBA16I instead if not available. Use
* @ref TextureFormat::RGBA in combination with @ref PixelType::Half * @ref TextureFormat::RGBA in combination with @ref PixelType::Half
* (@webgl_extension{EXT,color_buffer_half_float}) in WebGL 1.0 instead. * (@webgl_extension{EXT,color_buffer_half_float}) in WebGL 1.0
* instead.
*/ */
RGBA16F = GL_RGBA16F, RGBA16F = GL_RGBA16F,
@ -1014,6 +1021,9 @@ enum class TextureFormat: GLenum {
* OpenGL ES 2.0. * OpenGL ES 2.0.
* @requires_webgl20 Only normalized integral formats are available in * @requires_webgl20 Only normalized integral formats are available in
* WebGL 1.0. * WebGL 1.0.
* @requires_webgl_extension Extension
* @webgl_extension{EXT,color_buffer_float} to use as a render target
* in WebGL 2.0.
*/ */
R11FG11FB10F = GL_R11F_G11F_B10F, R11FG11FB10F = GL_R11F_G11F_B10F,

Loading…
Cancel
Save