From a64828218a3934c036f7fb256b6799723c30830a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Sun, 4 Jun 2017 23:58:02 +0200 Subject: [core] add constant DDS values as uniforms --- src/mbgl/programs/program.hpp | 2 +- src/mbgl/programs/symbol_program.hpp | 2 +- src/mbgl/renderer/paint_property_binder.hpp | 23 +++++++++++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src') 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& currentValue) const = 0; virtual float interpolationFactor(float currentZoom) const = 0; + virtual T uniformValue(const PossiblyEvaluatedPropertyValue& currentValue) const = 0; static std::unique_ptr create(const PossiblyEvaluatedPropertyValue& value, float zoom, T defaultValue); @@ -118,6 +119,10 @@ public: return 0.0f; } + T uniformValue(const PossiblyEvaluatedPropertyValue& currentValue) const override { + return currentValue.constantOr(constant); + } + private: T constant; }; @@ -165,6 +170,11 @@ public: return 0.0f; } + T uniformValue(const PossiblyEvaluatedPropertyValue&) const override { + // Uniform values for vertex attribute arrays are unused. + return {}; + } + private: style::SourceFunction function; T defaultValue; @@ -220,6 +230,11 @@ public: return util::interpolationFactor(1.0f, std::get<0>(coveringRanges), currentZoom); } + T uniformValue(const PossiblyEvaluatedPropertyValue&) const override { + // Uniform values for vertex attribute arrays are unused. + return {}; + } + private: using InnerStops = typename style::CompositeFunction::InnerStops; style::CompositeFunction function; @@ -306,14 +321,18 @@ public: }; } - using Uniforms = gl::Uniforms...>; + using Uniforms = gl::Uniforms..., typename Ps::Uniform...>; using UniformValues = typename Uniforms::Values; - UniformValues uniformValues(float currentZoom) const { + template + 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::Value { binders.template get()->interpolationFactor(currentZoom) + }..., + typename Ps::Uniform::Value { + binders.template get()->uniformValue(currentProperties.template get()) }... }; } -- cgit v1.2.1