Browse Source

GL: advertise fake MAGNUM_compressed_texture_astc_{ldr,hdr}.

Because everything is a trash fire. Ugh.
pull/650/head
Vladimír Vondruš 2 years ago
parent
commit
8da46ef9dc
  1. 1
      doc/opengl-support.dox
  2. 2
      src/Magnum/GL/Context.cpp
  3. 3
      src/Magnum/GL/Extensions.h
  4. 46
      src/Magnum/GL/Implementation/driverSpecific.cpp

1
doc/opengl-support.dox

@ -580,6 +580,7 @@ Extension | Status
@webgl_extension{EXT,depth_clamp} | done
@webgl_extension{EXT,texture_mirror_clamp_to_edge} | done
@webgl_extension{KHR,parallel_shader_compile} | done
`MAGNUM_compressed_texture_astc_ldr`, \n `MAGNUM_compressed_texture_astc_hdr` \n @m_span{m-text m-dim} Pseudo-extension denoting support for \n @webgl_extension{WEBGL,compressed_texture_astc} LDR and HDR profile @m_endspan | done
@webgl_extension{NV,shader_noperspective_interpolation} | done (shading language only)
@webgl_extension{OES,texture_float_linear} | done
@webgl_extension{OES,draw_buffers_indexed} \n (originally named `EXT_draw_buffers_indexed`) | done

2
src/Magnum/GL/Context.cpp

@ -300,6 +300,8 @@ constexpr Extension ExtensionList[]{
Extensions::EXT::texture_norm16{},
#endif
Extensions::KHR::parallel_shader_compile{},
Extensions::MAGNUM::compressed_texture_astc_hdr{},
Extensions::MAGNUM::compressed_texture_astc_ldr{},
#ifndef MAGNUM_TARGET_GLES2
Extensions::NV::shader_noperspective_interpolation{},
Extensions::OES::draw_buffers_indexed{},

3
src/Magnum/GL/Extensions.h

@ -365,6 +365,7 @@ namespace ANGLE {
/* WEBGL_compressed_texture_etc1 (24) not exposed as the ES
OES_compressed_ETC1_RGB8_texture extension isn't exposed either */
_extension(49,WEBGL,compressed_texture_etc, GLES200, None) // #29
/* Also MAGNUM_compressed_texture_astc{_ldr,_hdr} below */
_extension(50,WEBGL,compressed_texture_astc, GLES200, None) // #30
_extension(51,WEBGL,compressed_texture_s3tc_srgb, GLES200, None) // #32
_extension(52,WEBGL,multi_draw, GLES200, None) // #40
@ -390,6 +391,8 @@ namespace ANGLE {
#ifndef MAGNUM_TARGET_GLES2
_extension(61,MAGNUM,shader_vertex_id, GLES300, GLES300)
#endif
_extension(62,MAGNUM,compressed_texture_astc_ldr,GLES200, None)
_extension(63,MAGNUM,compressed_texture_astc_hdr,GLES200, None)
}
#else
namespace ANDROID {

46
src/Magnum/GL/Implementation/driverSpecific.cpp

@ -762,6 +762,52 @@ void Context::setupDriverWorkarounds() {
#endif
#endif
/* WEBGL_compressed_texture_astc has an extremely silly way of reporting
whether the LDR or HDR profile is supported. All other platforms simply
expose a _hdr / _ldr variants of the extension, here I have to call some
fucking getter. Restore sanity and provide this info in fake
Magnum-specific MAGNUM_compressed_texture_astc_ldr / _hdr extensions
instead.
What's the most funny about this is that the extension at
https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
explicitly says that
The intent of the getSupportedProfiles function is to allow easy
reconstruction of the underlying OpenGL or OpenGL ES extension strings
for environments like Emscripten, by prepending the string GL_KHR_texture_compression_astc_ to the returned profile names.
Which ... is a noble _intent_, but it only misses one small thing, to
have someone actually TELL THE EMSCRIPTEN DEVS TO IMPLEMENT SUCH A
THING!!! Which of course never happened. Since 2015. Goddamit.
And even then, still, why couldn't you just do it like ALL OTHER
PLATFORMS? WHY SUCH A STUPID SPECIAL CASE?! */
#ifdef MAGNUM_TARGET_WEBGL
if(isExtensionSupported<Extensions::WEBGL::compressed_texture_astc>()) {
/* Unlike other EM_ASM() macros, this one isn't put into a JS library
as it neither has any dependencies nor has code that may benefit
from settings-based preprocessing done for minification */
#pragma GCC diagnostic push
/* Fun. It's either -Wdollar-in-identifier-extension if an argument is
used, or -Wgnu-zero-variadic-macro-arguments if not, OR
-Wc++20-extensions if it's a different Clang version. TRASH FIRE. */
#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
const UnsignedInt which = EM_ASM_INT({
/* If this feels like peeking into some undocumented Emscripten
internals that are likely going to change randomly at some point
in the future, it's because it's indeed peeking into some
undocumented Emscripten internals that are likely going to
change randomly at some point in the future. HAVE FUN. */
var supported = GL.contexts[$0].GLctx.getExtension('WEBGL_compressed_texture_astc').getSupportedProfiles();
return
(supported.indexOf('ldr') >= 0 ? 1 : 0)|
(supported.indexOf('hdr') >= 0 ? 2 : 0);
}, emscripten_webgl_get_current_context());
#pragma GCC diagnostic pop
_extensionStatus.set(Extensions::MAGNUM::compressed_texture_astc_ldr::Index, which & 0x01);
_extensionStatus.set(Extensions::MAGNUM::compressed_texture_astc_hdr::Index, which & 0x02);
}
#endif
#undef _setRequiredVersion
#ifndef MAGNUM_TARGET_GLES

Loading…
Cancel
Save