diff --git a/src/mbgl/renderer/layers/line_layer_tweaker.cpp b/src/mbgl/renderer/layers/line_layer_tweaker.cpp index 6a0e42cb8..9c1f72693 100644 --- a/src/mbgl/renderer/layers/line_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/line_layer_tweaker.cpp @@ -17,6 +17,7 @@ #if MLN_RENDER_BACKEND_METAL #include +#include #endif // MLN_RENDER_BACKEND_METAL namespace mbgl { @@ -110,30 +111,6 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters }; #if MLN_RENDER_BACKEND_METAL - if (permutationUpdated) { - const LinePermutationUBO permutationUBO = { - /* .color = */ {/*.source=*/getAttributeSource(2), /*.expression=*/{}}, - /* .blur = */ {/*.source=*/getAttributeSource(3), /*.expression=*/{}}, - /* .opacity = */ {/*.source=*/getAttributeSource(4), /*.expression=*/{}}, - /* .gapwidth = */ {/*.source=*/getAttributeSource(5), /*.expression=*/{}}, - /* .offset = */ {/*.source=*/getAttributeSource(6), /*.expression=*/{}}, - /* .width = */ {/*.source=*/getAttributeSource(7), /*.expression=*/{}}, - /* .floorwidth = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, - /* .pattern_from = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, - /* .pattern_to = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, - /* .overdrawInspector = */ overdrawInspector, - /* .pad = */ 0, - 0, - 0, - 0}; - - if (permutationUniformBuffer) { - permutationUniformBuffer->update(&permutationUBO, sizeof(permutationUBO)); - } else { - permutationUniformBuffer = context.createUniformBuffer(&permutationUBO, sizeof(permutationUBO)); - } - permutationUpdated = false; - } if (!expressionUniformBuffer) { const auto expressionUBO = buildExpressionUBO(zoom, parameters.frameCount); expressionUniformBuffer = context.createUniformBuffer(&expressionUBO, sizeof(expressionUBO)); @@ -168,6 +145,29 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters // properties UBO uniforms.addOrReplace(idLinePropertiesUBOName, getLinePropsBuffer()); + +#if MLN_RENDER_BACKEND_METAL + if (permutationUpdated) { + const LinePermutationUBO permutationUBO = { + /* .color = */ {/*.source=*/getAttributeSource(2), /*.expression=*/{}}, + /* .blur = */ {/*.source=*/getAttributeSource(3), /*.expression=*/{}}, + /* .opacity = */ {/*.source=*/getAttributeSource(4), /*.expression=*/{}}, + /* .gapwidth = */ {/*.source=*/getAttributeSource(5), /*.expression=*/{}}, + /* .offset = */ {/*.source=*/getAttributeSource(6), /*.expression=*/{}}, + /* .width = */ {/*.source=*/getAttributeSource(7), /*.expression=*/{}}, + /* .floorwidth = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .pattern_from = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .pattern_to = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + /* .pad = */ 0, + 0, + 0, + 0}; + + context.emplaceOrUpdateUniformBuffer(permutationUniformBuffer, &permutationUBO); + permutationUpdated = false; + } +#endif } break; case LineType::Gradient: { @@ -180,6 +180,34 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters // properties UBO uniforms.addOrReplace(idLineGradientPropertiesUBOName, getLineGradientPropsBuffer()); + +#if MLN_RENDER_BACKEND_METAL + if (permutationUpdated) { + const LinePermutationUBO permutationUBO = { + /* .color = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .blur = */ + {/*.source=*/getAttributeSource(2), /*.expression=*/{}}, + /* .opacity = */ + {/*.source=*/getAttributeSource(3), /*.expression=*/{}}, + /* .gapwidth = */ + {/*.source=*/getAttributeSource(4), /*.expression=*/{}}, + /* .offset = */ + {/*.source=*/getAttributeSource(5), /*.expression=*/{}}, + /* .width = */ + {/*.source=*/getAttributeSource(6), /*.expression=*/{}}, + /* .floorwidth = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .pattern_from = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .pattern_to = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + /* .pad = */ 0, + 0, + 0, + 0}; + + context.emplaceOrUpdateUniformBuffer(permutationUniformBuffer, &permutationUBO); + permutationUpdated = false; + } +#endif } break; case LineType::Pattern: { @@ -205,6 +233,36 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters // properties UBO uniforms.addOrReplace(idLinePatternPropertiesUBOName, getLinePatternPropsBuffer()); + +#if MLN_RENDER_BACKEND_METAL + if (permutationUpdated) { + const LinePermutationUBO permutationUBO = { + /* .color = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .blur = */ + {/*.source=*/getAttributeSource(2), /*.expression=*/{}}, + /* .opacity = */ + {/*.source=*/getAttributeSource(3), /*.expression=*/{}}, + /* .gapwidth = */ + {/*.source=*/getAttributeSource(4), /*.expression=*/{}}, + /* .offset = */ + {/*.source=*/getAttributeSource(5), /*.expression=*/{}}, + /* .width = */ + {/*.source=*/getAttributeSource(6), /*.expression=*/{}}, + /* .floorwidth = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .pattern_from = */ + {/*.source=*/getAttributeSource(7), /*.expression=*/{}}, + /* .pattern_to = */ + {/*.source=*/getAttributeSource(8), /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + /* .pad = */ 0, + 0, + 0, + 0}; + + context.emplaceOrUpdateUniformBuffer(permutationUniformBuffer, &permutationUBO); + permutationUpdated = false; + } +#endif } break; case LineType::SDF: { @@ -251,6 +309,32 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters // properties UBO uniforms.addOrReplace(idLineSDFPropertiesUBOName, getLineSDFPropsBuffer()); } + +#if MLN_RENDER_BACKEND_METAL + if (permutationUpdated) { + const LinePermutationUBO permutationUBO = { + /* .color = */ {/*.source=*/getAttributeSource(2), /*.expression=*/{}}, + /* .blur = */ {/*.source=*/getAttributeSource(3), /*.expression=*/{}}, + /* .opacity = */ + {/*.source=*/getAttributeSource(4), /*.expression=*/{}}, + /* .gapwidth = */ + {/*.source=*/getAttributeSource(5), /*.expression=*/{}}, + /* .offset = */ {/*.source=*/getAttributeSource(6), /*.expression=*/{}}, + /* .width = */ {/*.source=*/getAttributeSource(7), /*.expression=*/{}}, + /* .floorwidth = */ + {/*.source=*/getAttributeSource(8), /*.expression=*/{}}, + /* .pattern_from = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .pattern_to = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + /* .pad = */ 0, + 0, + 0, + 0}; + + context.emplaceOrUpdateUniformBuffer(permutationUniformBuffer, &permutationUBO); + permutationUpdated = false; + } +#endif } break; default: {