Browse Source

Text: add comments in DistanceFieldGlyphCacheGL re temporary GL objects.

At first I was like "ugh this is BAD" and made the texture and output
framebuffer resident. Then I realized that for the upcoming array
variant I need to reattach the output texture every time, so having a
resident framebuffer was not that useful anymore, and then I realized
that having a resident texture but calling setImage() on it is not any
better than making a temporary one every time, and making the resident
texture significantly larger just to accomodate any size that could
possibly be processed was even worse. So, ultimately it's just these
comments.
pull/674/head
Vladimír Vondruš 1 year ago
parent
commit
bb5c161123
  1. 9
      src/Magnum/Text/DistanceFieldGlyphCacheGL.cpp

9
src/Magnum/Text/DistanceFieldGlyphCacheGL.cpp

@ -109,6 +109,11 @@ void DistanceFieldGlyphCacheGL::doSetImage(const Vector2i&
, const ImageView2D& image) {
auto& state = static_cast<State&>(*_state);
/* Creating a temporary input texture that's deleted right after because I
assume it's better than having a persistent one which would just occupy
memory that was only ever used once. This way it can also be scaled to
just exactly the input size being processed, not the whole unprocessed
cache size, which can be quite big. */
GL::Texture2D input;
input
/* In order to have correctly processed output, the input has to be
@ -171,6 +176,10 @@ void DistanceFieldGlyphCacheGL::doSetImage(const Vector2i&
paddedMaxRounded - paddedMinRounded,
image.data()};
/** @todo investigate if using setStorage() + setSubImage() is any
faster or better, the assumption is that since the texture is
temporary it doesn't matter much anyway; similarly with the
temporary framebuffer created inside */
input.setImage(0, GL::textureFormat(paddedImage.format()), paddedImage);
state.distanceField(input, texture(), {paddedMinRounded/ratio, paddedMaxRounded/ratio}, paddedImage.size());
}

Loading…
Cancel
Save