summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Agafonkin <agafonkin@gmail.com>2018-02-09 22:44:36 +0200
committerVladimir Agafonkin <agafonkin@gmail.com>2018-02-09 22:44:36 +0200
commit3726c5886e338811e504962959e5cfaf59ab204e (patch)
tree8dc5b23c08b3cfdb7fa122220a74b2aa2132f5d3
parentd2fb1d9ca1a375fa2d1ccf199173ffc3fc181ea8 (diff)
downloadqtlocation-mapboxgl-3726c5886e338811e504962959e5cfaf59ab204e.tar.gz
better half-float fallback handling
-rw-r--r--src/mbgl/gl/context.cpp6
-rw-r--r--src/mbgl/gl/context.hpp5
-rw-r--r--src/mbgl/renderer/layers/render_heatmap_layer.cpp3
3 files changed, 5 insertions, 9 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index 7ba8a2167e..f40cfa1f2c 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -136,7 +136,7 @@ void Context::initializeExtensions(const std::function<gl::ProcAddress(const cha
if (strstr(extensions, halfFloatExtensionName) != nullptr &&
strstr(extensions, halfFloatColorBufferExtensionName) != nullptr) {
- halfFloat = true;
+ supportsHalfFloatTextures = true;
}
if (!supportsVertexArrays()) {
@@ -294,10 +294,6 @@ bool Context::supportsVertexArrays() const {
vertexArray->deleteVertexArrays;
}
-bool Context::supportsHalfFloatTextures() const {
- return halfFloat;
-}
-
#if MBGL_HAS_BINARY_PROGRAMS
bool Context::supportsProgramBinaries() const {
if (!programBinary || !programBinary->programBinary || !programBinary->getProgramBinary) {
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index 5c6d0bc793..67624288e2 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -53,8 +53,6 @@ public:
UniqueTexture createTexture();
VertexArray createVertexArray();
- bool supportsHalfFloatTextures() const;
-
#if MBGL_HAS_BINARY_PROGRAMS
bool supportsProgramBinaries() const;
#else
@@ -217,7 +215,6 @@ private:
#if MBGL_HAS_BINARY_PROGRAMS
std::unique_ptr<extension::ProgramBinary> programBinary;
#endif
- bool halfFloat = false;
public:
State<value::ActiveTextureUnit> activeTextureUnit;
@@ -241,6 +238,8 @@ public:
State<value::PixelTransferStencil> pixelTransferStencil;
#endif // MBGL_USE_GLES2
+ bool supportsHalfFloatTextures = false;
+
private:
State<value::StencilFunc> stencilFunc;
State<value::StencilMask> stencilMask;
diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
index a451843340..0f9e3239ef 100644
--- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp
+++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
@@ -55,7 +55,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
const auto size = Size{viewportSize.width / 4, viewportSize.height / 4};
if (!renderTexture || renderTexture->getSize() != size) {
- if (parameters.context.supportsHalfFloatTextures()) {
+ if (parameters.context.supportsHalfFloatTextures) {
renderTexture = OffscreenTexture(parameters.context, size, gl::TextureType::HalfFloat);
try {
@@ -63,6 +63,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
} catch (const std::runtime_error& ex) {
// can't render to a half-float texture; falling back to unsigned byte one
renderTexture = nullopt;
+ parameters.context.supportsHalfFloatTextures = false;
}
}