summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-06-04 23:58:02 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-13 12:21:50 -0700
commit1708b297a7c4eb6287e36837fd1cfe1220c5d97b (patch)
tree549d2ad2a2529ce1d9c626af585aae62f2247512 /src
parent2c6fcd9f44ff93593a3f21c9f993a1eb4b299bb4 (diff)
downloadqtlocation-mapboxgl-1708b297a7c4eb6287e36837fd1cfe1220c5d97b.tar.gz
[core] add constant DDS values as uniforms
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/programs/program.hpp2
-rw-r--r--src/mbgl/programs/symbol_program.hpp2
-rw-r--r--src/mbgl/renderer/paint_property_binder.hpp23
3 files changed, 23 insertions, 4 deletions
diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp
index a5db5cf8dc..3351f5eeae 100644
--- a/src/mbgl/programs/program.hpp
+++ b/src/mbgl/programs/program.hpp
@@ -62,7 +62,7 @@ public:
std::move(stencilMode),
std::move(colorMode),
uniformValues
- .concat(paintPropertyBinders.uniformValues(currentZoom)),
+ .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)),
LayoutAttributes::allVariableBindings(layoutVertexBuffer)
.concat(paintPropertyBinders.attributeBindings(currentProperties)),
indexBuffer,
diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp
index f466a076ef..087d3a4567 100644
--- a/src/mbgl/programs/symbol_program.hpp
+++ b/src/mbgl/programs/symbol_program.hpp
@@ -377,7 +377,7 @@ public:
std::move(colorMode),
uniformValues
.concat(symbolSizeBinder.uniformValues(currentZoom))
- .concat(paintPropertyBinders.uniformValues(currentZoom)),
+ .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)),
LayoutAttributes::allVariableBindings(layoutVertexBuffer)
.concat(symbolSizeBinder.attributeBindings(currentSizeValue))
.concat(paintPropertyBinders.attributeBindings(currentProperties)),
diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp
index 14934fb6bd..8291301d33 100644
--- a/src/mbgl/renderer/paint_property_binder.hpp
+++ b/src/mbgl/renderer/paint_property_binder.hpp
@@ -89,6 +89,7 @@ public:
virtual void upload(gl::Context& context) = 0;
virtual AttributeBinding attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const = 0;
virtual float interpolationFactor(float currentZoom) const = 0;
+ virtual T uniformValue(const PossiblyEvaluatedPropertyValue<T>& currentValue) const = 0;
static std::unique_ptr<PaintPropertyBinder> create(const PossiblyEvaluatedPropertyValue<T>& value, float zoom, T defaultValue);
@@ -119,6 +120,10 @@ public:
return 0.0f;
}
+ T uniformValue(const PossiblyEvaluatedPropertyValue<T>& currentValue) const override {
+ return currentValue.constantOr(constant);
+ }
+
private:
T constant;
};
@@ -166,6 +171,11 @@ public:
return 0.0f;
}
+ T uniformValue(const PossiblyEvaluatedPropertyValue<T>&) const override {
+ // Uniform values for vertex attribute arrays are unused.
+ return {};
+ }
+
private:
style::SourceFunction<T> function;
T defaultValue;
@@ -221,6 +231,11 @@ public:
return util::interpolationFactor(1.0f, std::get<0>(coveringRanges), currentZoom);
}
+ T uniformValue(const PossiblyEvaluatedPropertyValue<T>&) const override {
+ // Uniform values for vertex attribute arrays are unused.
+ return {};
+ }
+
private:
using InnerStops = typename style::CompositeFunction<T>::InnerStops;
style::CompositeFunction<T> function;
@@ -307,14 +322,18 @@ public:
};
}
- using Uniforms = gl::Uniforms<InterpolationUniform<typename Ps::Attribute>...>;
+ using Uniforms = gl::Uniforms<InterpolationUniform<typename Ps::Attribute>..., typename Ps::Uniform...>;
using UniformValues = typename Uniforms::Values;
- UniformValues uniformValues(float currentZoom) const {
+ template <class EvaluatedProperties>
+ UniformValues uniformValues(float currentZoom, const EvaluatedProperties& currentProperties) const {
(void)currentZoom; // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56958
return UniformValues {
typename InterpolationUniform<typename Ps::Attribute>::Value {
binders.template get<Ps>()->interpolationFactor(currentZoom)
+ }...,
+ typename Ps::Uniform::Value {
+ binders.template get<Ps>()->uniformValue(currentProperties.template get<Ps>())
}...
};
}