Fix line properties on Metal
This commit is contained in:
@@ -41,32 +41,33 @@ using StringIdentity = std::size_t;
|
||||
class LayerTweaker {
|
||||
protected:
|
||||
LayerTweaker(std::string id, Immutable<style::LayerProperties> properties);
|
||||
|
||||
|
||||
public:
|
||||
LayerTweaker() = delete;
|
||||
virtual ~LayerTweaker() = default;
|
||||
|
||||
|
||||
const std::string& getID() const { return id; }
|
||||
|
||||
|
||||
#if MLN_RENDER_BACKEND_METAL
|
||||
/// Build the common expression inupts UBO
|
||||
static shaders::ExpressionInputsUBO buildExpressionUBO(double zoom, uint64_t frameCount);
|
||||
|
||||
|
||||
/// @brief Check whether a property name exists within the previously set collection.
|
||||
bool hasPropertyAsUniform(StringIdentity) const;
|
||||
shaders::AttributeSource getAttributeSource(StringIdentity) const;
|
||||
|
||||
|
||||
template <shaders::BuiltIn ShaderType>
|
||||
shaders::AttributeSource getAttributeSource(size_t index) {
|
||||
using ShaderClass = shaders::ShaderSource<ShaderType, gfx::Backend::Type::Metal>;
|
||||
return getAttributeSource(ShaderClass::attributes[index].nameID);
|
||||
}
|
||||
#endif // MLN_RENDER_BACKEND_METAL
|
||||
|
||||
|
||||
/// @brief Set the collection of attribute names which will be provided at uniform values rather than per-vertex
|
||||
/// attributes.
|
||||
/// @details These values should not have "a_" prefixes, as produced by `readDataDrivenPaintProperties`.
|
||||
void setPropertiesAsUniforms(const std::unordered_set<StringIdentity>&);
|
||||
const std::unordered_set<StringIdentity>& getPropertiesAsUniforms() const;
|
||||
|
||||
void enableOverdrawInspector(bool);
|
||||
|
||||
|
||||
@@ -85,6 +85,20 @@ void LayerTweaker::setPropertiesAsUniforms([[maybe_unused]] const std::unordered
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !MLN_RENDER_BACKEND_METAL
|
||||
namespace {
|
||||
const std::unordered_set<StringIdentity> emptyIDSet;
|
||||
}
|
||||
#endif
|
||||
|
||||
const std::unordered_set<StringIdentity>& LayerTweaker::getPropertiesAsUniforms() const {
|
||||
#if MLN_RENDER_BACKEND_METAL
|
||||
return propertiesAsUniforms;
|
||||
#else
|
||||
return emptyIDSet;
|
||||
#endif
|
||||
}
|
||||
|
||||
void LayerTweaker::enableOverdrawInspector(bool value) {
|
||||
if (overdrawInspector != value) {
|
||||
overdrawInspector = value;
|
||||
|
||||
@@ -83,6 +83,12 @@ void RenderLineLayer::evaluate(const PropertyEvaluationParameters& parameters) {
|
||||
#if MLN_DRAWABLE_RENDERER
|
||||
if (layerGroup) {
|
||||
auto newTweaker = std::make_shared<LineLayerTweaker>(getID(), evaluatedProperties);
|
||||
|
||||
// propertiesAsUniforms isn't recalculated every update, so carry it over
|
||||
if (layerTweaker) {
|
||||
newTweaker->setPropertiesAsUniforms(layerTweaker->getPropertiesAsUniforms());
|
||||
}
|
||||
|
||||
replaceTweaker(layerTweaker, std::move(newTweaker), {layerGroup});
|
||||
}
|
||||
#endif
|
||||
@@ -566,6 +572,8 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
else if (shaderUniforms.get(idLineSDFInterpolationUBOName)) {
|
||||
drawableUniforms.createOrUpdate(idLineSDFInterpolationUBOName, &lineSDFInterpolationUBO, context);
|
||||
}
|
||||
|
||||
// TODO: vertex attributes or `propertiesAsUniforms` updated, is that needed?
|
||||
});
|
||||
|
||||
if (tileLayerGroup->getDrawableCount(renderPass, tileID) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user