Line layer UBO improvements (#1946)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -19,11 +19,15 @@ struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -34,8 +38,8 @@ layout (std140) uniform LinePropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineInterpolationUBO {
|
||||
@@ -46,7 +50,7 @@ layout (std140) uniform LineInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp vec2 pad3;
|
||||
highp vec2 pad7;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
@@ -160,9 +164,8 @@ mediump float width = u_width;
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -173,8 +176,8 @@ layout (std140) uniform LinePropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineInterpolationUBO {
|
||||
@@ -185,7 +188,7 @@ layout (std140) uniform LineInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp vec2 pad3;
|
||||
highp vec2 pad7;
|
||||
};
|
||||
|
||||
in vec2 v_width2;
|
||||
|
||||
@@ -23,11 +23,15 @@ struct ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -37,8 +41,8 @@ layout (std140) uniform LineGradientPropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientInterpolationUBO {
|
||||
@@ -48,8 +52,8 @@ layout (std140) uniform LineGradientInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp float pad3;
|
||||
highp vec2 pad4;
|
||||
highp float pad7;
|
||||
highp vec2 pad8;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
@@ -154,9 +158,8 @@ mediump float width = u_width;
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineGradientUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -166,8 +169,8 @@ layout (std140) uniform LineGradientPropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientInterpolationUBO {
|
||||
@@ -177,8 +180,8 @@ layout (std140) uniform LineGradientInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp float pad3;
|
||||
highp vec2 pad4;
|
||||
highp float pad7;
|
||||
highp vec2 pad8;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
@@ -23,16 +23,17 @@ struct ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternPropertiesUBO {
|
||||
@@ -185,12 +186,8 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
highp mat4 u_matrix;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternPropertiesUBO {
|
||||
|
||||
@@ -23,9 +23,13 @@ struct ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
@@ -33,8 +37,7 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp float u_tex_y_b;
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -46,7 +49,7 @@ layout (std140) uniform LineSDFPropertiesUBO {
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
|
||||
highp vec2 pad1;
|
||||
highp vec2 pad5;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFInterpolationUBO {
|
||||
@@ -58,7 +61,7 @@ layout (std140) uniform LineSDFInterpolationUBO {
|
||||
lowp float u_width_t;
|
||||
lowp float u_floorwidth_t;
|
||||
|
||||
highp float pad2;
|
||||
highp float pad6;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
@@ -186,7 +189,6 @@ lowp float floorwidth = u_floorwidth;
|
||||
static constexpr const char* fragment = R"(
|
||||
layout (std140) uniform LineSDFUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
@@ -195,7 +197,7 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -207,7 +209,7 @@ layout (std140) uniform LineSDFPropertiesUBO {
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
|
||||
highp vec2 pad1;
|
||||
highp vec2 pad5;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFInterpolationUBO {
|
||||
@@ -219,7 +221,7 @@ layout (std140) uniform LineSDFInterpolationUBO {
|
||||
lowp float u_width_t;
|
||||
lowp float u_floorwidth_t;
|
||||
|
||||
highp float pad2;
|
||||
highp float pad6;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
@@ -5,11 +5,17 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
struct alignas(16) LineDynamicUBO {
|
||||
/* 0 */ std::array<float, 2> units_to_pixels;
|
||||
/* 8 */ float pad1, pad2;
|
||||
/* 16 */
|
||||
};
|
||||
static_assert(sizeof(LineDynamicUBO) == 16);
|
||||
|
||||
struct alignas(16) LineUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
float ratio;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
static_assert(sizeof(LineUBO) % 16 == 0);
|
||||
|
||||
@@ -40,10 +46,8 @@ struct alignas(16) LinePatternUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 4> scale;
|
||||
std::array<float, 2> texsize;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
float ratio;
|
||||
float fade;
|
||||
float pad1, pad2;
|
||||
};
|
||||
static_assert(sizeof(LinePatternUBO) % 16 == 0);
|
||||
|
||||
@@ -59,7 +63,6 @@ static_assert(sizeof(LinePatternPropertiesUBO) % 16 == 0);
|
||||
|
||||
struct alignas(16) LineSDFUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
std::array<float, 2> patternscale_a;
|
||||
std::array<float, 2> patternscale_b;
|
||||
float ratio;
|
||||
@@ -67,7 +70,7 @@ struct alignas(16) LineSDFUBO {
|
||||
float tex_y_b;
|
||||
float sdfgamma;
|
||||
float mix;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
static_assert(sizeof(LineSDFUBO) % 16 == 0);
|
||||
|
||||
@@ -83,7 +86,13 @@ struct alignas(16) LineSDFPropertiesUBO {
|
||||
};
|
||||
static_assert(sizeof(LineSDFPropertiesUBO) % 16 == 0);
|
||||
|
||||
using LineBasicUBO = LineUBO;
|
||||
struct alignas(16) LineBasicUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
float ratio;
|
||||
float pad;
|
||||
};
|
||||
static_assert(sizeof(LineBasicUBO) % 16 == 0);
|
||||
|
||||
struct alignas(16) LineBasicPropertiesUBO {
|
||||
Color color;
|
||||
|
||||
@@ -54,11 +54,15 @@ float4 unpack_mix_color(const float4 packedColors, const float t) {
|
||||
decode_color(float2(packedColors[2], packedColors[3])), t);
|
||||
}
|
||||
|
||||
struct alignas(16) LineDynamicUBO {
|
||||
float2 units_to_pixels;
|
||||
float pad1, pad2;
|
||||
};
|
||||
|
||||
struct alignas(16) LineUBO {
|
||||
float4x4 matrix;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
|
||||
struct alignas(16) LineBasicUBO {
|
||||
@@ -70,9 +74,8 @@ struct alignas(16) LineBasicUBO {
|
||||
|
||||
struct alignas(16) LineGradientUBO {
|
||||
float4x4 matrix;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
|
||||
struct alignas(16) LinePropertiesUBO {
|
||||
|
||||
@@ -15,7 +15,7 @@ struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal> {
|
||||
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||
|
||||
static const std::array<AttributeInfo, 8> attributes;
|
||||
static const std::array<UniformBlockInfo, 3> uniforms;
|
||||
static const std::array<UniformBlockInfo, 4> uniforms;
|
||||
static const std::array<TextureInfo, 0> textures;
|
||||
|
||||
static constexpr auto source = R"(
|
||||
@@ -61,9 +61,10 @@ struct FragmentStage {
|
||||
};
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const LineUBO& line [[buffer(8)]],
|
||||
device const LinePropertiesUBO& props [[buffer(9)]],
|
||||
device const LineInterpolationUBO& interp [[buffer(10)]]) {
|
||||
device const LineDynamicUBO& dynamic [[buffer(8)]],
|
||||
device const LineUBO& line [[buffer(9)]],
|
||||
device const LinePropertiesUBO& props [[buffer(10)]],
|
||||
device const LineInterpolationUBO& interp [[buffer(11)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_gapwidth)
|
||||
const auto gapwidth = props.gapwidth / 2;
|
||||
@@ -115,7 +116,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// 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);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * dynamic.units_to_pixels);
|
||||
|
||||
return {
|
||||
.position = position,
|
||||
@@ -136,8 +137,8 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const LineUBO& line [[buffer(8)]],
|
||||
device const LinePropertiesUBO& props [[buffer(9)]]) {
|
||||
device const LineUBO& line [[buffer(9)]],
|
||||
device const LinePropertiesUBO& props [[buffer(10)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
return half4(1.0);
|
||||
#endif
|
||||
@@ -178,7 +179,7 @@ struct ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Metal> {
|
||||
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||
|
||||
static const std::array<AttributeInfo, 9> attributes;
|
||||
static const std::array<UniformBlockInfo, 4> uniforms;
|
||||
static const std::array<UniformBlockInfo, 5> uniforms;
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto source = R"(
|
||||
@@ -234,10 +235,8 @@ struct alignas(16) LinePatternUBO {
|
||||
float4x4 matrix;
|
||||
float4 scale;
|
||||
float2 texsize;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float fade;
|
||||
float pad1, pad2;
|
||||
};
|
||||
|
||||
struct alignas(16) LinePatternPropertiesUBO {
|
||||
@@ -266,10 +265,11 @@ struct alignas(16) LinePatternTilePropertiesUBO {
|
||||
};
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const LinePatternUBO& line [[buffer(9)]],
|
||||
device const LinePatternPropertiesUBO& props [[buffer(10)]],
|
||||
device const LinePatternInterpolationUBO& interp [[buffer(11)]],
|
||||
device const LinePatternTilePropertiesUBO& tileProps [[buffer(12)]]) {
|
||||
device const LineDynamicUBO& dynamic [[buffer(9)]],
|
||||
device const LinePatternUBO& line [[buffer(10)]],
|
||||
device const LinePatternPropertiesUBO& props [[buffer(11)]],
|
||||
device const LinePatternInterpolationUBO& interp [[buffer(12)]],
|
||||
device const LinePatternTilePropertiesUBO& tileProps [[buffer(13)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_gapwidth)
|
||||
const auto gapwidth = props.gapwidth / 2;
|
||||
@@ -323,7 +323,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// 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);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * dynamic.units_to_pixels);
|
||||
|
||||
return {
|
||||
.position = position,
|
||||
@@ -348,9 +348,9 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const LinePatternUBO& line [[buffer(9)]],
|
||||
device const LinePatternPropertiesUBO& props [[buffer(10)]],
|
||||
device const LinePatternTilePropertiesUBO& tileProps [[buffer(12)]],
|
||||
device const LinePatternUBO& line [[buffer(10)]],
|
||||
device const LinePatternPropertiesUBO& props [[buffer(11)]],
|
||||
device const LinePatternTilePropertiesUBO& tileProps [[buffer(13)]],
|
||||
texture2d<float, access::sample> image0 [[texture(0)]],
|
||||
sampler image0_sampler [[sampler(0)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
@@ -430,7 +430,7 @@ struct ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Metal> {
|
||||
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||
|
||||
static const std::array<AttributeInfo, 9> attributes;
|
||||
static const std::array<UniformBlockInfo, 3> uniforms;
|
||||
static const std::array<UniformBlockInfo, 4> uniforms;
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto source = R"(
|
||||
@@ -485,7 +485,6 @@ struct FragmentStage {
|
||||
|
||||
struct alignas(16) LineSDFUBO {
|
||||
float4x4 matrix;
|
||||
float2 units_to_pixels;
|
||||
float2 patternscale_a;
|
||||
float2 patternscale_b;
|
||||
float ratio;
|
||||
@@ -493,7 +492,7 @@ struct alignas(16) LineSDFUBO {
|
||||
float tex_y_b;
|
||||
float sdfgamma;
|
||||
float mix;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
|
||||
struct alignas(16) LineSDFPropertiesUBO {
|
||||
@@ -519,9 +518,10 @@ struct alignas(16) LineSDFInterpolationUBO {
|
||||
};
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const LineSDFUBO& line [[buffer(9)]],
|
||||
device const LineSDFPropertiesUBO& props [[buffer(10)]],
|
||||
device const LineSDFInterpolationUBO& interp [[buffer(11)]]) {
|
||||
device const LineDynamicUBO& dynamic [[buffer(9)]],
|
||||
device const LineSDFUBO& line [[buffer(10)]],
|
||||
device const LineSDFPropertiesUBO& props [[buffer(11)]],
|
||||
device const LineSDFInterpolationUBO& interp [[buffer(12)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_gapwidth)
|
||||
const auto gapwidth = props.gapwidth / 2;
|
||||
@@ -580,7 +580,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// 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);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * dynamic.units_to_pixels);
|
||||
|
||||
return {
|
||||
.position = position,
|
||||
@@ -606,8 +606,8 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const LineSDFUBO& line [[buffer(9)]],
|
||||
device const LineSDFPropertiesUBO& props [[buffer(10)]],
|
||||
device const LineSDFUBO& line [[buffer(10)]],
|
||||
device const LineSDFPropertiesUBO& props [[buffer(11)]],
|
||||
texture2d<float, access::sample> image0 [[texture(0)]],
|
||||
sampler image0_sampler [[sampler(0)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
|
||||
@@ -15,7 +15,7 @@ struct ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Metal> {
|
||||
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||
|
||||
static const std::array<AttributeInfo, 7> attributes;
|
||||
static const std::array<UniformBlockInfo, 3> uniforms;
|
||||
static const std::array<UniformBlockInfo, 4> uniforms;
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto source = R"(
|
||||
@@ -45,9 +45,10 @@ struct FragmentStage {
|
||||
};
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const LineGradientUBO& line [[buffer(7)]],
|
||||
device const LineGradientPropertiesUBO& props [[buffer(8)]],
|
||||
device const LineGradientInterpolationUBO& interp [[buffer(9)]]) {
|
||||
device const LineDynamicUBO& dynamic [[buffer(7)]],
|
||||
device const LineGradientUBO& line [[buffer(8)]],
|
||||
device const LineGradientPropertiesUBO& props [[buffer(9)]],
|
||||
device const LineGradientInterpolationUBO& interp [[buffer(10)]]) {
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_blur)
|
||||
const auto blur = unpack_mix_float(vertx.blur, interp.blur_t);
|
||||
@@ -106,7 +107,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// 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);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * dynamic.units_to_pixels);
|
||||
|
||||
return {
|
||||
.position = position,
|
||||
@@ -125,8 +126,8 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const LineGradientUBO& line [[buffer(7)]],
|
||||
device const LineGradientPropertiesUBO& props [[buffer(8)]],
|
||||
device const LineGradientUBO& line [[buffer(8)]],
|
||||
device const LineGradientPropertiesUBO& props [[buffer(9)]],
|
||||
texture2d<float, access::sample> gradientTexture [[texture(0)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
return half4(1.0);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
layout (std140) uniform LineUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -13,8 +12,8 @@ layout (std140) uniform LinePropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineInterpolationUBO {
|
||||
@@ -25,7 +24,7 @@ layout (std140) uniform LineInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp vec2 pad3;
|
||||
highp vec2 pad7;
|
||||
};
|
||||
|
||||
in vec2 v_width2;
|
||||
|
||||
@@ -9,11 +9,15 @@
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -24,8 +28,8 @@ layout (std140) uniform LinePropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineInterpolationUBO {
|
||||
@@ -36,7 +40,7 @@ layout (std140) uniform LineInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp vec2 pad3;
|
||||
highp vec2 pad7;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
layout (std140) uniform LineGradientUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -12,8 +11,8 @@ layout (std140) uniform LineGradientPropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientInterpolationUBO {
|
||||
@@ -23,8 +22,8 @@ layout (std140) uniform LineGradientInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp float pad3;
|
||||
highp vec2 pad4;
|
||||
highp float pad7;
|
||||
highp vec2 pad8;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
@@ -13,11 +13,15 @@
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -27,8 +31,8 @@ layout (std140) uniform LineGradientPropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientInterpolationUBO {
|
||||
@@ -38,8 +42,8 @@ layout (std140) uniform LineGradientInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp float pad3;
|
||||
highp vec2 pad4;
|
||||
highp float pad7;
|
||||
highp vec2 pad8;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
|
||||
@@ -2,12 +2,8 @@ layout (std140) uniform LinePatternUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternPropertiesUBO {
|
||||
|
||||
@@ -13,16 +13,17 @@
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternPropertiesUBO {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
layout (std140) uniform LineSDFUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
@@ -10,7 +9,7 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -22,7 +21,7 @@ layout (std140) uniform LineSDFPropertiesUBO {
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
|
||||
highp vec2 pad1;
|
||||
highp vec2 pad5;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFInterpolationUBO {
|
||||
@@ -34,7 +33,7 @@ layout (std140) uniform LineSDFInterpolationUBO {
|
||||
lowp float u_width_t;
|
||||
lowp float u_floorwidth_t;
|
||||
|
||||
highp float pad2;
|
||||
highp float pad6;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
@@ -13,9 +13,13 @@
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
@@ -23,8 +27,7 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp float u_tex_y_b;
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -36,7 +39,7 @@ layout (std140) uniform LineSDFPropertiesUBO {
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
|
||||
highp vec2 pad1;
|
||||
highp vec2 pad5;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFInterpolationUBO {
|
||||
@@ -48,7 +51,7 @@ layout (std140) uniform LineSDFInterpolationUBO {
|
||||
lowp float u_width_t;
|
||||
lowp float u_floorwidth_t;
|
||||
|
||||
highp float pad2;
|
||||
highp float pad6;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
|
||||
@@ -33,6 +33,7 @@ static const StringIdentity idLinePatternUBOName = stringIndexer().get("LinePatt
|
||||
static const StringIdentity idLinePatternPropertiesUBOName = stringIndexer().get("LinePatternPropertiesUBO");
|
||||
static const StringIdentity idLineSDFUBOName = stringIndexer().get("LineSDFUBO");
|
||||
static const StringIdentity idLineSDFPropertiesUBOName = stringIndexer().get("LineSDFPropertiesUBO");
|
||||
static const StringIdentity idLineDynamicUBOName = stringIndexer().get("LineDynamicUBO");
|
||||
static const StringIdentity idTexImageName = stringIndexer().get("u_image");
|
||||
|
||||
void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters& parameters) {
|
||||
@@ -107,6 +108,15 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
return lineSDFPropertiesBuffer;
|
||||
};
|
||||
|
||||
const LineDynamicUBO dynamicUBO = {
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, 0, 0};
|
||||
|
||||
if (!dynamicBuffer) {
|
||||
dynamicBuffer = parameters.context.createUniformBuffer(&dynamicUBO, sizeof(dynamicUBO));
|
||||
} else {
|
||||
dynamicBuffer->update(&dynamicUBO, sizeof(dynamicUBO));
|
||||
}
|
||||
|
||||
visitLayerGroupDrawables(layerGroup, [&](gfx::Drawable& drawable) {
|
||||
const auto shader = drawable.getShader();
|
||||
if (!drawable.getTileID() || !shader || !checkTweakDrawable(drawable)) {
|
||||
@@ -122,15 +132,16 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
|
||||
const auto matrix = getTileMatrix(tileID, parameters, translation, anchor, nearClipped, inViewportPixelUnits);
|
||||
|
||||
const LineType type = static_cast<LineType>(drawable.getType());
|
||||
uniforms.addOrReplace(idLineDynamicUBOName, dynamicBuffer);
|
||||
|
||||
const LineType type = static_cast<LineType>(drawable.getType());
|
||||
switch (type) {
|
||||
case LineType::Simple: {
|
||||
const LineUBO lineUBO{
|
||||
/*matrix = */ util::cast<float>(matrix),
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast<float>(zoom)),
|
||||
0};
|
||||
const LineUBO lineUBO{/*matrix = */ util::cast<float>(matrix),
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast<float>(zoom)),
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
uniforms.createOrUpdate(idLineUBOName, &lineUBO, context);
|
||||
|
||||
// properties UBO
|
||||
@@ -140,8 +151,9 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
case LineType::Gradient: {
|
||||
const LineGradientUBO lineGradientUBO{
|
||||
/*matrix = */ util::cast<float>(matrix),
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast<float>(zoom)),
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
uniforms.createOrUpdate(idLineGradientUBOName, &lineGradientUBO, context);
|
||||
|
||||
@@ -158,16 +170,14 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
}
|
||||
const LinePatternUBO linePatternUBO{
|
||||
/*matrix =*/util::cast<float>(matrix),
|
||||
/*scale =*/
|
||||
{parameters.pixelRatio,
|
||||
1 / tileID.pixelsToTileUnits(1, parameters.state.getIntegerZoom()),
|
||||
crossfade.fromScale,
|
||||
crossfade.toScale},
|
||||
/*texsize =*/{static_cast<float>(textureSize.width), static_cast<float>(textureSize.height)},
|
||||
/*units_to_pixels =*/{1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio =*/1.0f / tileID.pixelsToTileUnits(1.0f, static_cast<float>(zoom)),
|
||||
/*fade =*/crossfade.t,
|
||||
0,
|
||||
0};
|
||||
/*fade =*/crossfade.t};
|
||||
uniforms.createOrUpdate(idLinePatternUBOName, &linePatternUBO, context);
|
||||
|
||||
// properties UBO
|
||||
@@ -200,19 +210,20 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
const float widthB = posB.width * crossfade.toScale;
|
||||
const LineSDFUBO lineSDFUBO{
|
||||
/* matrix = */ util::cast<float>(matrix),
|
||||
{1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/* patternscale_a = */
|
||||
{1.0f / tileID.pixelsToTileUnits(widthA, parameters.state.getIntegerZoom()),
|
||||
-posA.height / 2.0f},
|
||||
/* patternscale_b = */
|
||||
{1.0f / tileID.pixelsToTileUnits(widthB, parameters.state.getIntegerZoom()),
|
||||
-posB.height / 2.0f},
|
||||
/* ratio = */ 1.0f /
|
||||
tileID.pixelsToTileUnits(1.0f, static_cast<float>(parameters.state.getZoom())),
|
||||
/* ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast<float>(zoom)),
|
||||
/* tex_y_a = */ posA.y,
|
||||
/* tex_y_b = */ posB.y,
|
||||
/* sdfgamma = */ static_cast<float>(dashPatternTexture.getSize().width) /
|
||||
(std::min(widthA, widthB) * 256.0f * parameters.pixelRatio) / 2.0f,
|
||||
/* mix = */ crossfade.t,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
uniforms.createOrUpdate(idLineSDFUBOName, &lineSDFUBO, context);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ protected:
|
||||
gfx::UniformBufferPtr lineGradientPropertiesBuffer;
|
||||
gfx::UniformBufferPtr linePatternPropertiesBuffer;
|
||||
gfx::UniformBufferPtr lineSDFPropertiesBuffer;
|
||||
gfx::UniformBufferPtr dynamicBuffer;
|
||||
|
||||
#if MLN_RENDER_BACKEND_METAL
|
||||
gfx::UniformBufferPtr permutationUniformBuffer;
|
||||
|
||||
@@ -210,13 +210,19 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
const auto matrix = LayerTweaker::getTileMatrix(
|
||||
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, false);
|
||||
|
||||
static const StringIdentity idLineUBOName = stringIndexer().get("LineUBO");
|
||||
const shaders::LineUBO lineUBO{
|
||||
/*matrix = */ util::cast<float>(matrix),
|
||||
static const StringIdentity idLineDynamicUBOName = stringIndexer().get("LineDynamicUBO");
|
||||
const shaders::LineDynamicUBO dynamicUBO = {
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
|
||||
0,
|
||||
0};
|
||||
|
||||
static const StringIdentity idLineUBOName = stringIndexer().get("LineUBO");
|
||||
const shaders::LineUBO lineUBO{/*matrix = */ util::cast<float>(matrix),
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
|
||||
static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO");
|
||||
|
||||
static const StringIdentity idLineInterpolationUBOName = stringIndexer().get("LineInterpolationUBO");
|
||||
@@ -229,6 +235,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
0,
|
||||
0};
|
||||
auto& uniforms = drawable.mutableUniformBuffers();
|
||||
uniforms.createOrUpdate(idLineDynamicUBOName, &dynamicUBO, parameters.context);
|
||||
uniforms.createOrUpdate(idLineUBOName, &lineUBO, parameters.context);
|
||||
uniforms.createOrUpdate(idLinePropertiesUBOName, &linePropertiesUBO, parameters.context);
|
||||
uniforms.createOrUpdate(idLineInterpolationUBOName, &lineInterpolationUBO, parameters.context);
|
||||
|
||||
@@ -13,10 +13,11 @@ const std::array<AttributeInfo, 8> ShaderSource<BuiltIn::LineShader, gfx::Backen
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, 1, "a_offset"},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float2, 1, "a_width"},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{8, true, true, sizeof(LineUBO), "LineUBO"},
|
||||
UniformBlockInfo{9, true, true, sizeof(LinePropertiesUBO), "LinePropertiesUBO"},
|
||||
UniformBlockInfo{10, true, false, sizeof(LineInterpolationUBO), "LineInterpolationUBO"},
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{8, true, false, sizeof(LineGradientUBO), "LineDynamicUBO"},
|
||||
UniformBlockInfo{9, true, true, sizeof(LineUBO), "LineUBO"},
|
||||
UniformBlockInfo{10, true, true, sizeof(LinePropertiesUBO), "LinePropertiesUBO"},
|
||||
UniformBlockInfo{11, true, false, sizeof(LineInterpolationUBO), "LineInterpolationUBO"},
|
||||
};
|
||||
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal>::textures = {};
|
||||
|
||||
@@ -31,11 +32,12 @@ const std::array<AttributeInfo, 9> ShaderSource<BuiltIn::LinePatternShader, gfx:
|
||||
AttributeInfo{7, gfx::AttributeDataType::UShort4, 1, "a_pattern_from"},
|
||||
AttributeInfo{8, gfx::AttributeDataType::UShort4, 1, "a_pattern_to"},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{9, true, true, sizeof(LinePatternUBO), "LinePatternUBO"},
|
||||
UniformBlockInfo{10, true, true, sizeof(LinePatternPropertiesUBO), "LinePatternPropertiesUBO"},
|
||||
UniformBlockInfo{11, true, false, sizeof(LinePatternInterpolationUBO), "LinePatternInterpolationUBO"},
|
||||
UniformBlockInfo{12, true, true, sizeof(LinePatternTilePropertiesUBO), "LinePatternTilePropertiesUBO"},
|
||||
const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{9, true, false, sizeof(LineGradientUBO), "LineDynamicUBO"},
|
||||
UniformBlockInfo{10, true, true, sizeof(LinePatternUBO), "LinePatternUBO"},
|
||||
UniformBlockInfo{11, true, true, sizeof(LinePatternPropertiesUBO), "LinePatternPropertiesUBO"},
|
||||
UniformBlockInfo{12, true, false, sizeof(LinePatternInterpolationUBO), "LinePatternInterpolationUBO"},
|
||||
UniformBlockInfo{13, true, true, sizeof(LinePatternTilePropertiesUBO), "LinePatternTilePropertiesUBO"},
|
||||
};
|
||||
const std::array<TextureInfo, 1> ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Metal>::textures = {
|
||||
TextureInfo{0, "u_image"},
|
||||
@@ -52,10 +54,11 @@ const std::array<AttributeInfo, 9> ShaderSource<BuiltIn::LineSDFShader, gfx::Bac
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float2, 1, "a_width"},
|
||||
AttributeInfo{8, gfx::AttributeDataType::Float2, 1, "a_floorwidth"},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{9, true, true, sizeof(LineSDFUBO), "LineSDFUBO"},
|
||||
UniformBlockInfo{10, true, true, sizeof(LineSDFPropertiesUBO), "LineSDFPropertiesUBO"},
|
||||
UniformBlockInfo{11, true, false, sizeof(LineSDFInterpolationUBO), "LineSDFInterpolationUBO"},
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{9, true, false, sizeof(LineGradientUBO), "LineDynamicUBO"},
|
||||
UniformBlockInfo{10, true, true, sizeof(LineSDFUBO), "LineSDFUBO"},
|
||||
UniformBlockInfo{11, true, true, sizeof(LineSDFPropertiesUBO), "LineSDFPropertiesUBO"},
|
||||
UniformBlockInfo{12, true, false, sizeof(LineSDFInterpolationUBO), "LineSDFInterpolationUBO"},
|
||||
};
|
||||
const std::array<TextureInfo, 1> ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Metal>::textures = {
|
||||
TextureInfo{0, "u_image"},
|
||||
|
||||
@@ -12,10 +12,11 @@ const std::array<AttributeInfo, 7> ShaderSource<BuiltIn::LineGradientShader, gfx
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float2, 1, "a_offset"},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, 1, "a_width"},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{7, true, true, sizeof(LineGradientUBO), "LineGradientUBO"},
|
||||
UniformBlockInfo{8, true, true, sizeof(LineGradientPropertiesUBO), "LineGradientPropertiesUBO"},
|
||||
UniformBlockInfo{9, true, false, sizeof(LineGradientInterpolationUBO), "LineGradientInterpolationUBO"},
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{7, true, false, sizeof(LineGradientUBO), "LineDynamicUBO"},
|
||||
UniformBlockInfo{8, true, true, sizeof(LineGradientUBO), "LineGradientUBO"},
|
||||
UniformBlockInfo{9, true, true, sizeof(LineGradientPropertiesUBO), "LineGradientPropertiesUBO"},
|
||||
UniformBlockInfo{10, true, false, sizeof(LineGradientInterpolationUBO), "LineGradientInterpolationUBO"},
|
||||
};
|
||||
const std::array<TextureInfo, 1> ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Metal>::textures = {
|
||||
TextureInfo{0, "u_image"},
|
||||
|
||||
@@ -97,12 +97,16 @@ public:
|
||||
const auto matrix = LayerTweaker::getTileMatrix(
|
||||
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, false);
|
||||
|
||||
static const StringIdentity idLineDynamicUBOName = stringIndexer().get("LineDynamicUBO");
|
||||
const shaders::LineDynamicUBO dynamicUBO = {
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, 0, 0};
|
||||
|
||||
static const StringIdentity idLineUBOName = stringIndexer().get("LineUBO");
|
||||
const shaders::LineUBO lineUBO{
|
||||
/*matrix = */ util::cast<float>(matrix),
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
|
||||
0};
|
||||
const shaders::LineUBO lineUBO{/*matrix = */ util::cast<float>(matrix),
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
|
||||
static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO");
|
||||
|
||||
@@ -116,6 +120,7 @@ public:
|
||||
0,
|
||||
0};
|
||||
auto& uniforms = drawable.mutableUniformBuffers();
|
||||
uniforms.createOrUpdate(idLineDynamicUBOName, &dynamicUBO, parameters.context);
|
||||
uniforms.createOrUpdate(idLineUBOName, &lineUBO, parameters.context);
|
||||
uniforms.createOrUpdate(idLinePropertiesUBOName, &linePropertiesUBO, parameters.context);
|
||||
uniforms.createOrUpdate(idLineInterpolationUBOName, &lineInterpolationUBO, parameters.context);
|
||||
|
||||
Reference in New Issue
Block a user