diff --git a/include/mbgl/shaders/gl/drawable_line_basic.hpp b/include/mbgl/shaders/gl/drawable_line_basic.hpp new file mode 100644 index 00000000000..46b66fd7932 --- /dev/null +++ b/include/mbgl/shaders/gl/drawable_line_basic.hpp @@ -0,0 +1,151 @@ +// Generated code, do not modify this file! +#pragma once +#include + +namespace mbgl { +namespace shaders { + +template <> +struct ShaderSource { + static constexpr const char* name = "LineBasicShader"; + static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 +// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is +// stored in a byte (-128..127). we scale regular normals up to length 63, but +// there are also "special" normals that have a bigger length (of up to 126 in +// this case). +// #define scale 63.0 +#define scale 0.015873016 + +layout (location = 0) in vec2 a_pos_normal; +layout (location = 1) in vec4 a_data; + +layout (std140) uniform LineBasicUBO { + highp mat4 u_matrix; + highp vec2 u_units_to_pixels; + mediump float u_ratio; + lowp float u_device_pixel_ratio; +}; + +layout (std140) uniform LineBasicPropertiesUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + + highp float pad1; + highp vec2 pad2; +}; + +out vec2 v_normal; +out vec2 v_width2; +out float v_gamma_scale; +out highp float v_linesofar; + +void main() { + highp vec4 color = u_color; + lowp float blur = u_blur; + lowp float opacity = u_opacity; + mediump float gapwidth = u_gapwidth; + lowp float offset = u_offset; + mediump float width = u_width; + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + + vec2 a_extrude = a_data.xy - 128.0; + float a_direction = mod(a_data.z, 4.0) - 1.0; + + v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0; + + vec2 pos = floor(a_pos_normal * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + mediump vec2 normal = a_pos_normal - 2.0 * pos; + normal.y = normal.y * 2.0 - 1.0; + v_normal = normal; + + // these transformations used to be applied in the JS and native code bases. + // moved them into the shader for clarity and simplicity. + gapwidth = gapwidth / 2.0; + float halfwidth = width / 2.0; + offset = -1.0 * offset; + + float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width + // of this vertex. + mediump vec2 dist = outset * a_extrude * scale; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + mediump float u = 0.5 * a_direction; + mediump float t = 1.0 - abs(u); + mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); + + vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); + gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; + + // calculate how much the perspective view squishes or stretches the extrude + float extrude_length_without_perspective = length(dist); + float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); + v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; + + v_width2 = vec2(outset, inset); +} +)"; + static constexpr const char* fragment = R"(layout (std140) uniform LineBasicUBO { + highp mat4 u_matrix; + highp vec2 u_units_to_pixels; + mediump float u_ratio; + lowp float u_device_pixel_ratio; +}; + +layout (std140) uniform LineBasicPropertiesUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + + highp float pad1; + highp vec2 pad2; +}; + +in vec2 v_width2; +in vec2 v_normal; +in float v_gamma_scale; + +void main() { + highp vec4 color = u_color; + lowp float blur = u_blur; + lowp float opacity = u_opacity; + + // Calculate the distance of the pixel from the line in pixels. + float dist = length(v_normal) * v_width2.s; + + // Calculate the antialiasing fade factor. This is either when fading in + // the line in case of an offset line (v_width2.t) or when fading out + // (v_width2.s) + float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); + + fragColor = color * (alpha * opacity); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/line_layer_ubo.hpp b/include/mbgl/shaders/line_layer_ubo.hpp index 4255eab7ee2..f46c7ae7047 100644 --- a/include/mbgl/shaders/line_layer_ubo.hpp +++ b/include/mbgl/shaders/line_layer_ubo.hpp @@ -84,6 +84,19 @@ struct alignas(16) LineSDFPropertiesUBO { }; static_assert(sizeof(LineSDFPropertiesUBO) % 16 == 0); +using LineBasicUBO = LineUBO; + +struct alignas(16) LineBasicPropertiesUBO { + Color color; + float blur; + float opacity; + float gapwidth; + float offset; + float width; + float pad1, pad2, pad3; +}; +static_assert(sizeof(LineBasicPropertiesUBO) % 16 == 0); + /// Property interpolation UBOs struct alignas(16) LineInterpolationUBO { float color_t; diff --git a/include/mbgl/shaders/mtl/common.hpp b/include/mbgl/shaders/mtl/common.hpp index de61c8a0c6d..4599ac2e520 100644 --- a/include/mbgl/shaders/mtl/common.hpp +++ b/include/mbgl/shaders/mtl/common.hpp @@ -123,6 +123,13 @@ struct alignas(16) LineUBO { float device_pixel_ratio; }; +struct alignas(16) LineBasicUBO { + float4x4 matrix; + float2 units_to_pixels; + float ratio; + float device_pixel_ratio; +}; + struct alignas(16) LineGradientUBO { float4x4 matrix; float2 units_to_pixels; @@ -140,6 +147,16 @@ struct alignas(16) LinePropertiesUBO { float pad1, pad2, pad3; }; +struct alignas(16) LineBasicPropertiesUBO { + float4 color; + float blur; + float opacity; + float gapwidth; + float offset; + float width; + float pad1, pad2, pad3; +}; + struct alignas(16) LineGradientPropertiesUBO { float blur; float opacity; diff --git a/include/mbgl/shaders/mtl/line.hpp b/include/mbgl/shaders/mtl/line.hpp index 298812252ec..27b560748e8 100644 --- a/include/mbgl/shaders/mtl/line.hpp +++ b/include/mbgl/shaders/mtl/line.hpp @@ -480,5 +480,118 @@ half4 fragment fragmentMain(FragmentStage in [[stage_in]], )"; }; +template <> +struct ShaderSource { + static constexpr auto name = "LineBasicShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static const std::array attributes; + static const std::array uniforms; + static const std::array textures; + + static constexpr auto source = R"( + +struct VertexStage { + short2 pos_normal [[attribute(0)]]; + uchar4 data [[attribute(1)]]; + float4 color [[attribute(2)]]; + float2 blur [[attribute(3)]]; + float2 opacity [[attribute(4)]]; + float2 gapwidth [[attribute(5)]]; + float2 offset [[attribute(6)]]; + float2 width [[attribute(7)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; + float2 width2; + float2 normal; + float gamma_scale; + float4 color; + float blur; + float opacity; +}; + +FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], + device const LineBasicUBO& line [[buffer(8)]], + device const LineBasicPropertiesUBO& props [[buffer(9)]], + device const LinePermutationUBO& permutation [[buffer(10)]], + device const ExpressionInputsUBO& expr [[buffer(11)]]) { + + const auto color = colorFor(permutation.color, props.color, vertx.color, 0, expr); + const auto blur = valueFor(permutation.blur, props.blur, vertx.blur, 0, expr); + const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, 0, expr); + const auto gapwidth = valueFor(permutation.gapwidth, props.gapwidth, vertx.gapwidth, 0, expr) / 2; + const auto offset = valueFor(permutation.offset, props.offset, vertx.offset, 0, expr) * -1; + const auto width = valueFor(permutation.width, props.width, vertx.width, 0, expr); + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + const float ANTIALIASING = 1.0 / line.device_pixel_ratio / 2.0; + + const float2 a_extrude = float2(vertx.data.xy) - 128.0; + const float a_direction = fmod(float(vertx.data.z), 4.0) - 1.0; + const float2 pos = floor(float2(vertx.pos_normal) * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + const float2 normal = float2(vertx.pos_normal) - 2.0 * pos; + const float2 v_normal = float2(normal.x, normal.y * 2.0 - 1.0); + + const float halfwidth = width / 2.0; + const float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + const float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width of this vertex. + const float2 dist = outset * a_extrude * LINE_NORMAL_SCALE; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + const float u = 0.5 * a_direction; + const float t = 1.0 - abs(u); + const float2 offset2 = offset * a_extrude * LINE_NORMAL_SCALE * v_normal.y * float2x2(t, -u, u, t); + + const float4 projected_extrude = line.matrix * float4(dist / line.ratio, 0.0, 0.0); + const float4 position = line.matrix * float4(pos + offset2 / line.ratio, 0.0, 1.0) + projected_extrude; + + // calculate how much the perspective view squishes or stretches the extrude + const float extrude_length_without_perspective = length(dist); + const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * line.units_to_pixels); + + return { + .position = position, + .width2 = float2(outset, inset), + .normal = v_normal, + .gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective, + .color = color, + .blur = blur, + .opacity = opacity, + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const LineBasicUBO& line [[buffer(8)]], + device const LinePermutationUBO& permutation [[buffer(10)]]) { + if (permutation.overdrawInspector) { + return half4(1.0); + } + + // Calculate the distance of the pixel from the line in pixels. + const float dist = length(in.normal) * in.width2.x; + + // Calculate the antialiasing fade factor. This is either when fading in the + // line in case of an offset line (v_width2.y) or when fading out (v_width2.x) + const float blur2 = (in.blur + 1.0 / line.device_pixel_ratio) * in.gamma_scale; + const float alpha = clamp(min(dist - (in.width2.y - blur2), in.width2.x - dist) / blur2, 0.0, 1.0); + + return half4(in.color * (alpha * in.opacity)); +} +)"; +}; + } // namespace shaders } // namespace mbgl diff --git a/include/mbgl/shaders/shader_manifest.hpp b/include/mbgl/shaders/shader_manifest.hpp index 561c34557e0..d769192e296 100644 --- a/include/mbgl/shaders/shader_manifest.hpp +++ b/include/mbgl/shaders/shader_manifest.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/include/mbgl/shaders/shader_source.hpp b/include/mbgl/shaders/shader_source.hpp index ca6519a4035..8f44c1eec88 100644 --- a/include/mbgl/shaders/shader_source.hpp +++ b/include/mbgl/shaders/shader_source.hpp @@ -21,6 +21,7 @@ enum class BuiltIn { LinePatternShader, LineSDFShader, LineShader, + LineBasicShader, FillPatternShader, FillOutlinePatternShader, FillExtrusionShader, diff --git a/shaders/drawable.line_basic.fragment.glsl b/shaders/drawable.line_basic.fragment.glsl new file mode 100644 index 00000000000..0a649f5fdb7 --- /dev/null +++ b/shaders/drawable.line_basic.fragment.glsl @@ -0,0 +1,43 @@ +layout (std140) uniform LineBasicUBO { + highp mat4 u_matrix; + highp vec2 u_units_to_pixels; + mediump float u_ratio; + lowp float u_device_pixel_ratio; +}; + +layout (std140) uniform LineBasicPropertiesUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + + highp float pad1; + highp vec2 pad2; +}; + +in vec2 v_width2; +in vec2 v_normal; +in float v_gamma_scale; + +void main() { + highp vec4 color = u_color; + lowp float blur = u_blur; + lowp float opacity = u_opacity; + + // Calculate the distance of the pixel from the line in pixels. + float dist = length(v_normal) * v_width2.s; + + // Calculate the antialiasing fade factor. This is either when fading in + // the line in case of an offset line (v_width2.t) or when fading out + // (v_width2.s) + float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; + float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); + + fragColor = color * (alpha * opacity); + +#ifdef OVERDRAW_INSPECTOR + fragColor = vec4(1.0); +#endif +} diff --git a/shaders/drawable.line_basic.vertex.glsl b/shaders/drawable.line_basic.vertex.glsl new file mode 100644 index 00000000000..5f6915d6fd0 --- /dev/null +++ b/shaders/drawable.line_basic.vertex.glsl @@ -0,0 +1,92 @@ +// floor(127 / 2) == 63.0 +// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is +// stored in a byte (-128..127). we scale regular normals up to length 63, but +// there are also "special" normals that have a bigger length (of up to 126 in +// this case). +// #define scale 63.0 +#define scale 0.015873016 + +layout (location = 0) in vec2 a_pos_normal; +layout (location = 1) in vec4 a_data; + +layout (std140) uniform LineBasicUBO { + highp mat4 u_matrix; + highp vec2 u_units_to_pixels; + mediump float u_ratio; + lowp float u_device_pixel_ratio; +}; + +layout (std140) uniform LineBasicPropertiesUBO { + highp vec4 u_color; + lowp float u_blur; + lowp float u_opacity; + mediump float u_gapwidth; + lowp float u_offset; + mediump float u_width; + + highp float pad1; + highp vec2 pad2; +}; + +out vec2 v_normal; +out vec2 v_width2; +out float v_gamma_scale; +out highp float v_linesofar; + +void main() { + highp vec4 color = u_color; + lowp float blur = u_blur; + lowp float opacity = u_opacity; + mediump float gapwidth = u_gapwidth; + lowp float offset = u_offset; + mediump float width = u_width; + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + + vec2 a_extrude = a_data.xy - 128.0; + float a_direction = mod(a_data.z, 4.0) - 1.0; + + v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0; + + vec2 pos = floor(a_pos_normal * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + mediump vec2 normal = a_pos_normal - 2.0 * pos; + normal.y = normal.y * 2.0 - 1.0; + v_normal = normal; + + // these transformations used to be applied in the JS and native code bases. + // moved them into the shader for clarity and simplicity. + gapwidth = gapwidth / 2.0; + float halfwidth = width / 2.0; + offset = -1.0 * offset; + + float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width + // of this vertex. + mediump vec2 dist = outset * a_extrude * scale; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + mediump float u = 0.5 * a_direction; + mediump float t = 1.0 - abs(u); + mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t); + + vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0); + gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude; + + // calculate how much the perspective view squishes or stretches the extrude + float extrude_length_without_perspective = length(dist); + float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels); + v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective; + + v_width2 = vec2(outset, inset); +} diff --git a/shaders/manifest.json b/shaders/manifest.json index 6f17f74a8e0..331f3eac248 100644 --- a/shaders/manifest.json +++ b/shaders/manifest.json @@ -83,6 +83,13 @@ "glsl_frag": "drawable.line.fragment.glsl", "uses_ubos": true }, + { + "name": "LineBasicShader", + "header": "drawable_line_basic", + "glsl_vert": "drawable.line_basic.vertex.glsl", + "glsl_frag": "drawable.line_basic.fragment.glsl", + "uses_ubos": true + }, { "name": "FillPatternShader", "header": "drawable_fill_pattern", diff --git a/src/mbgl/gl/renderer_backend.cpp b/src/mbgl/gl/renderer_backend.cpp index 89fa4a0229c..f84d0021218 100644 --- a/src/mbgl/gl/renderer_backend.cpp +++ b/src/mbgl/gl/renderer_backend.cpp @@ -101,6 +101,7 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar shaders::BuiltIn::DebugShader, shaders::BuiltIn::FillShader, shaders::BuiltIn::FillOutlineShader, + shaders::BuiltIn::LineBasicShader, shaders::BuiltIn::LineShader, shaders::BuiltIn::LineSDFShader, shaders::BuiltIn::LinePatternShader, diff --git a/src/mbgl/mtl/renderer_backend.cpp b/src/mbgl/mtl/renderer_backend.cpp index 2b29e1592ed..982a63534b2 100644 --- a/src/mbgl/mtl/renderer_backend.cpp +++ b/src/mbgl/mtl/renderer_backend.cpp @@ -138,6 +138,7 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar shaders::BuiltIn::HeatmapTextureShader, shaders::BuiltIn::HillshadeShader, shaders::BuiltIn::HillshadePrepareShader, + shaders::BuiltIn::LineBasicShader, shaders::BuiltIn::LineShader, shaders::BuiltIn::LineGradientShader, shaders::BuiltIn::LineSDFShader, diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index a118276ffb0..cd69a208be5 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -43,7 +43,7 @@ namespace { #if MLN_DRAWABLE_RENDERER constexpr auto FillShaderName = "FillShader"; -constexpr auto FillOutlineShaderName = "LineShader"; +constexpr auto FillOutlineShaderName = "LineBasicShader"; constexpr auto FillPatternShaderName = "FillPatternShader"; constexpr auto FillOutlinePatternShaderName = "FillOutlinePatternShader"; @@ -339,12 +339,12 @@ class OutlineDrawableTweaker : public gfx::DrawableTweaker { const auto zoom = parameters.state.getZoom(); auto& uniforms = drawable.mutableUniformBuffers(); - static const StringIdentity idLineUBOName = stringIndexer().get("LineUBO"); + static const StringIdentity idLineUBOName = stringIndexer().get("LineBasicUBO"); { const auto matrix = LayerTweaker::getTileMatrix( tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, false); - const shaders::LineUBO lineUBO{ + const shaders::LineBasicUBO lineUBO{ /*matrix = */ util::cast(matrix), /*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, /*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom), @@ -353,9 +353,9 @@ class OutlineDrawableTweaker : public gfx::DrawableTweaker { } uniforms.addOrReplace(idLineUBOName, lineUniformBuffer); - static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO"); + static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LineBasicPropertiesUBO"); if (!linePropertiesUniformBuffer) { - const shaders::LinePropertiesUBO linePropertiesUBO{/*color =*/color, + const shaders::LineBasicPropertiesUBO linePropertiesUBO{/*color =*/color, /*blur =*/0.f, /*opacity =*/opacity, /*gapwidth =*/0.f, @@ -370,22 +370,6 @@ class OutlineDrawableTweaker : public gfx::DrawableTweaker { uniforms.addOrReplace(idLinePropertiesUBOName, linePropertiesUniformBuffer); } - static const StringIdentity idLineInterpolationUBOName = stringIndexer().get("LineInterpolationUBO"); - if (!lineInterpolationUniformBuffer) { - const shaders::LineInterpolationUBO lineInterpolationUBO{/*color_t =*/0.f, - /*blur_t =*/0.f, - /*opacity_t =*/0.f, - /*gapwidth_t =*/0.f, - /*offset_t =*/0.f, - /*width_t =*/0.f, - 0, - 0}; - parameters.context.emplaceOrUpdateUniformBuffer(lineInterpolationUniformBuffer, &lineInterpolationUBO); - } - if (!uniforms.get(idLineInterpolationUBOName)) { - uniforms.addOrReplace(idLineInterpolationUBOName, lineInterpolationUniformBuffer); - } - #if MLN_RENDER_BACKEND_METAL static const StringIdentity idExpressionInputsUBOName = stringIndexer().get("ExpressionInputsUBO"); if (!expressionUniformBuffer) { @@ -427,7 +411,6 @@ class OutlineDrawableTweaker : public gfx::DrawableTweaker { gfx::UniformBufferPtr lineUniformBuffer; gfx::UniformBufferPtr linePropertiesUniformBuffer; - gfx::UniformBufferPtr lineInterpolationUniformBuffer; #if MLN_RENDER_BACKEND_METAL gfx::UniformBufferPtr expressionUniformBuffer; diff --git a/src/mbgl/shaders/mtl/line.cpp b/src/mbgl/shaders/mtl/line.cpp index 778e3be8d47..b0398f83f3c 100644 --- a/src/mbgl/shaders/mtl/line.cpp +++ b/src/mbgl/shaders/mtl/line.cpp @@ -67,5 +67,23 @@ const std::array ShaderSource ShaderSource::attributes = { + AttributeInfo{0, gfx::AttributeDataType::Short2, 1, "a_pos_normal"}, + AttributeInfo{1, gfx::AttributeDataType::UByte4, 1, "a_data"}, + AttributeInfo{2, gfx::AttributeDataType::Float4, 1, "a_color"}, + AttributeInfo{3, gfx::AttributeDataType::Float2, 1, "a_blur"}, + AttributeInfo{4, gfx::AttributeDataType::Float2, 1, "a_opacity"}, + AttributeInfo{5, gfx::AttributeDataType::Float2, 1, "a_gapwidth"}, + AttributeInfo{6, gfx::AttributeDataType::Float2, 1, "a_offset"}, + AttributeInfo{7, gfx::AttributeDataType::Float2, 1, "a_width"}, +}; +const std::array ShaderSource::uniforms = { + UniformBlockInfo{8, true, true, sizeof(LineBasicUBO), "LineBasicUBO"}, + UniformBlockInfo{9, true, false, sizeof(LineBasicPropertiesUBO), "LineBasicPropertiesUBO"}, + UniformBlockInfo{10, true, true, sizeof(LinePermutationUBO), "LinePermutationUBO"}, + UniformBlockInfo{11, true, false, sizeof(ExpressionInputsUBO), "ExpressionInputsUBO"}, +}; +const std::array ShaderSource::textures = {}; + } // namespace shaders } // namespace mbgl