It's faster that way because it doesn't involve a linear lookup, if the
resource is already imported it's a constant-time check and it becomes a
no-op.
Technically speaking there are many more opportunities to mark things as
C++14 constexpr, such as various operators, but doing so would make them
impossible to optimize with various (SIMD) intrisnics unless basically
providing two separate implementations for them, one scalar, slow and
constexpr and the other fast but not compile time, and dispatching with
std::is_constant_evaluated() or some such from C++20.
In other words, such functions cannot and will not be marked as
constexpr in C++17 or older anyway, because the preference is and still
should be runtime perf rather than doing excessive work at compile time,
where it's hard to debug or reasonably test etc etc., and the more you
rebuild the more you'll hate the cost of extra compile time caused by
that.
Co-authored-by: Stanislaw Halik <sthalik@misaki.pl>
So line code coverage reports which branches weren't taken by tests.
Other libraries need similar treatment but there's too many cases to fix
so I'm doing it just here for now.
With ARB_DSA disabled, the test added in previous commit would assert
already during bind(), and not later in label(). This was due to the
state tracker being updated too early here.
This happened to me from time to time and I always treated it as user
error. But when thinking more about it, calling wrap() without actually
knowing if the object was already created or not, is a completely valid
use case, especially in cases of making non-owning references to
existing GL objects that might only get created at some point after.
These tests now cause assertions in all cases on GLES, on desktop
some only if ARB_direct_state_access is disabled. In all cases the
assertion is triggered by querying object label (which is a no-op if no
debug extension is present, but it calls createIfNotAlready() always),
because that's the simplest, the real-world cases are usually some
texture bind() calls.
Fix in the next commits.
I'm giving up there. Both Clang-cl and MinGW GCC report a far bigger
set of lines than their Linux / Mac counterparts (block ends, lines
containing just `else`, etc etc.), which wouldn't be a problem on its
own, if those lines would be covered. But on Windows there isn't a
single CI job that runs through GL/Vk codepaths -- as Mesa isn't easy to
get there and SwiftShader is utter crap -- which means there are extra
lines in GL/Vk codepaths that are reported as uncovered from Windows CI
jobs, while the same lines on Linux and Mac arere excluded and thus
there isn't anything that could make them green as well.
Yet another broken behavior with compressed textures on NVidia unearthed
by the recent changes with compressed block properties being set almost
always.
They are all using desktop-only APIs and most of the compressed variants
likely suffer from the same NVidia bug, so it's useful to have them
next to each other.
And make resetState() aware of ARB_compressed_texture_pixel_storage so
when it's not supported, it doesn't cause the very next compressed image
upload or download to fire a GL error due to an unknown state being set.