Since 98a676ef65, on ES2 and WebGL1 the
Texture::setStorage() emulation passes the pixel format to both <format>
and <internalFormat> of glTexImage() APIs. On desktop the go-to way to
create a sRGB texture is by passing GL_SRGB to <internalFormat> and
GL_RGB to <format>, but here GL_RGB was passed to both and thus the
information about sRGB was lost.
With the new PixelFormat::SRGB and PixelFormat::SRGBAlpha enums that
are present only on ES2/WebGL1 this case is fixed -- sRGB texture format
will get translated to sRGB pixel format and that used for both
<format> and <internalFormat>.
Another case is when EXT_texture_storage is available -- passing unsized
GL_SRGB_EXT or GL_SRGB_ALPHA_EXT to glTexStorageEXT() is an error and
there's apparently no mention of this in any extension, making it
impossible to create sRGB textures using EXT_texture_storage. I bit the
bullet and tried passing the (numerical value of) GL_SRGB8 and
GL_SRGB8_ALPHA8 to it. At least on my NV it worked, so I enabled these
two in TextureFormat for ES2. No EXT_texture_storage is on WebGL1, so
they are only on ES2.
These two sized TextureFormat::SRGB8 and TextureFormat::SRGB8Alpha8
formats are translated to GL_SRGB and GL_SRGB_ALPHA and so using them
unconditionally for all platforms (except WebGL1) "just works".
There's a new DynamicAttribute class that is very similar to Attribute,
but it has the location and base type as runtime properties instead of
them being a part of template. This allows for more flexibility, but
OTOH also more typing and more responsibility on the user. See
MeshGLTest for details and usage comparison to the Attribute API.
Fails. Problem spotted on WebGL 2 and is an unfortunate consequence of
these events:
1. Neither EXT_DSA nor ARB_DSA is available, but VAOs are available,
which means virtually all ES 3 and WebGL 2 implementations and also
ES 2 / WebGL 1 with OES_VAO available.
2. Index buffer gets created with TargetHint::ElementArray, bound to
GL_ELEMENT_ARRAY_BUFFER and filled with data.
3. Mesh object with VAO inside is created and the index buffer from
above gets bound to GL_ELEMENT_ARRAY_BUFFER again to attach it to the
VAO.
4. Another index buffer, possibly for another mesh, gets created with
TargetHint::ElementArray and bound to GL_ELEMENT_ARRAY_BUFFER in
order to be filled with data. But because the VAO from above is still
bound, the index buffer attachment is then stomped on.
5. Rendering such mesh will use a different index buffer, most probably
causing some out-of-range GL error and nothing rendered.
DetectedDriver::AMD is now DetectedDriver::Amd,
DetectedDriver::ProbablyAngle is now just DetectedDriver::Angle. The old
names are still present, but deprecated and will be removed in the
future.
The GL queries are needed only if the user-provided pixel storage
doesn't contain enough information, in particular dimensions and byte
size of compression block.
So in case they are present, no query for compressed image size is done
for full image queries (just saving one API call) and no queries for
block dimensions and byte size for subimage queries (saving four API
calls and not requiring ARB_internalformat_query2).
The documentation was fixed and tests were updated to take the
ARB_internalformat_query2 requirement into account.
There were various issues with the tests at the moment:
* In order to test non-default pixel storage parameters, out-of-bound
array slices were passed to GL functions. That of course cause ASan
to complain (and maybe also some drivers to crash).
* Only the non-default pixel storage parameters were tested.
Unfortunately this is a heavily buggy area in all the drivers, so
when such a test failed, it was not immediately clear whether the
failure is related just to driver not understanding pixel storage
properly or something deeper and made debugging much much harder than
it should be.
* For compressed textures, default and non-default pixel storage has
grossly different code paths and these should be tested both by
default.
* Some test cases had a patched-in code testing for both default and
non-default pixel storage, but the code was so hidden that I didn't
even know it was there -- it should be separate test cases.
All the tests are now instanced, testing both the simple case and
some pixel storage case, they are also reordered and cleaned up a bit.
There will be numerous additions to this one so it made sense to make it
a static library instead of a header-only library. That also allows
CMake users to just link to Magnum::OpenGLTester instead of going
through the pain of a huge branching in order to find a correct
windowless application just to run their tests. It could have been done
even without the static library using a INTERFACE target, but that
wouldn't work on CMake < 3.0 (which, unfortunately, quite a few people
are still stuck with).
Unfortunately it's already heavily used elsewhere so I had to go through
the pain of deprecating the old implementation. The old implementation
was header-only so it can't be just typedef'd to the new one as there
would be linker failures. So the old header is just kept as it was, with
only the macros reduced.
To be more consistent with GLSL naming. Also, the original naming was
quite misleading, as normalize() is used in GLSL for something
completely different.
If building with deprecated APIs, the Functions.h header includes the
new Packing.h header and the {de,}normalize() functions are defined as
deprecated aliases to the new functions. This will be removed at some
point in the future.