tsupinie / autumnplot-gl

Hardware-accelerated geospatial data plotting in the browser
MIT License
18 stars 4 forks source link

Half Float Textures: Fixed behavior of Float32 and Float16 array type support logic for both WebGL 1 and 2 APIs #2

Closed keltonhalbert closed 11 months ago

keltonhalbert commented 11 months ago

This was a bit of a beast to figure out, but I feel mostly confident it works.

The crux of the issue came down to WebGL 1 vs WebGL2 behavior. If in a WebGL1 rendering context, then loading these extensions (I corrected the half-float one) is a reasonable way to check for support, since Safari/WebKit returns null for OES_texture_float_linear on iOS and iPadOS. However, in WebGL2, many of these extensions were baselined into the standard. This means getExtension returns null, and all extension checks are only valid in the case of WebGL 1. Unfortunately, safari lies to the API and says it supports float textures, so the only way I knew how to fix it was to do an OS check. This OS check also works in the case a client has "request desktop website" enabled, so that it gracefully fails as intended.

keltonhalbert commented 11 months ago

I'll also add that I have tested this in production for both Float32 and Float16, with WebGL 1 and 2, and on the following systems: Linux Desktop, MacBook, iPhone, iPad