summaryrefslogtreecommitdiff
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-14 11:13:43 -0700
commita64828218a3934c036f7fb256b6799723c30830a (patch)
tree248e588bf04f29d6244bc14fadeeeddfd5d27ad6
parentcf85873f365e5baee73de0fb33113cd7bb134a47 (diff)
downloadqtlocation-mapboxgl-a64828218a3934c036f7fb256b6799723c30830a.tar.gz
[core] add constant DDS values as uniforms
-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 7eec15e755..420d2e1397 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 46f532e5c4..1b7232c9e4 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 3e53bcc884..a4bea24bbf 100644
--- a/src/mbgl/renderer/paint_property_binder.hpp
+++ b/src/mbgl/renderer/paint_property_binder.hpp
@@ -88,6 +88,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);
@@ -118,6 +119,10 @@ public:
return 0.0f;
}
+ T uniformValue(const PossiblyEvaluatedPropertyValue<T>& currentValue) const override {
+ return currentValue.constantOr(constant);
+ }
+
private:
T constant;
};
@@ -165,6 +170,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;
@@ -220,6 +230,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;
@@ -306,14 +321,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>())
}...
};
}