diff options
author | Vladimir Agafonkin <agafonkin@gmail.com> | 2018-02-09 13:54:29 +0200 |
---|---|---|
committer | Vladimir Agafonkin <agafonkin@gmail.com> | 2018-02-09 13:54:29 +0200 |
commit | 6aaf46aab14c0e34242b5b06cb72da475c373d18 (patch) | |
tree | 89b5d1b3bcee13a206a8506a2f26942b23c6223b | |
parent | 1607181c0da1d8d2cc3b5dc10636ac4595d2c8e0 (diff) | |
download | qtlocation-mapboxgl-6aaf46aab14c0e34242b5b06cb72da475c373d18.tar.gz |
fallback gracefully on bad half float texture support
-rw-r--r-- | src/mbgl/renderer/layers/render_heatmap_layer.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp index 8845670014..4717c224c8 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp @@ -55,10 +55,24 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) { const auto size = Size{viewportSize.width / 4, viewportSize.height / 4}; if (!renderTexture || renderTexture->getSize() != size) { - const auto textureType = parameters.context.supportsHalfFloatTextures() ? - gl::TextureType::HalfFloat : gl::TextureType::UnsignedByte; - - renderTexture = OffscreenTexture(parameters.context, size, textureType); + if (parameters.context.supportsHalfFloatTextures()) { + renderTexture = OffscreenTexture(parameters.context, size, gl::TextureType::HalfFloat); + + try { + renderTexture->bind(); + } catch (const std::runtime_error& ex) { + // can't render to a half-float texture; falling back to unsigned byte one + renderTexture = nullopt; + } + } + + if (!renderTexture) { + renderTexture = OffscreenTexture(parameters.context, size, gl::TextureType::UnsignedByte); + renderTexture->bind(); + } + + } else { + renderTexture->bind(); } if (!colorRampTexture) { @@ -67,8 +81,6 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) { gl::TextureType::UnsignedByte, colorRamp.data()); } - renderTexture->bind(); - parameters.context.clear(Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {}); for (const RenderTile& tile : renderTiles) { |