Device pixel ratio send as define instead of UBO field (#1936)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -15,8 +15,7 @@ static_assert(sizeof(CircleDrawableUBO) == 5 * 16);
|
||||
|
||||
struct alignas(16) CirclePaintParamsUBO {
|
||||
/* 0 */ float camera_to_center_distance;
|
||||
/* 4 */ float device_pixel_ratio;
|
||||
/* 8 */ float pad1, pad2;
|
||||
/* 4 */ float pad1, pad2, pad3;
|
||||
/* 16 */
|
||||
};
|
||||
static_assert(sizeof(CirclePaintParamsUBO) == 1 * 16);
|
||||
|
||||
@@ -19,8 +19,8 @@ layout (std140) uniform CircleDrawableUBO {
|
||||
|
||||
layout (std140) uniform CirclePaintParamsUBO {
|
||||
highp float u_camera_to_center_distance;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp vec2 pad3_;
|
||||
lowp float pad3_;
|
||||
lowp vec2 pad4_;
|
||||
};
|
||||
|
||||
layout (std140) uniform CircleEvaluatedPropsUBO {
|
||||
@@ -145,7 +145,7 @@ lowp float stroke_opacity = u_stroke_opacity;
|
||||
// This is a minimum blur distance that serves as a faux-antialiasing for
|
||||
// the circle. since blur is a ratio of the circle's size and the intent is
|
||||
// to keep the blur at roughly 1px, the two are inversely related.
|
||||
lowp float antialiasblur = 1.0 / u_device_pixel_ratio / (radius + stroke_width);
|
||||
lowp float antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width);
|
||||
|
||||
v_data = vec3(extrude.x, extrude.y, antialiasblur);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ layout (std140) uniform LineUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -110,7 +110,7 @@ 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
@@ -162,7 +162,7 @@ mediump float width = u_width;
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -219,7 +219,7 @@ lowp float opacity = u_opacity;
|
||||
// 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 blur2 = (blur + 1.0 / 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);
|
||||
|
||||
@@ -23,7 +23,7 @@ layout (std140) uniform LineBasicUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineBasicPropertiesUBO {
|
||||
@@ -42,7 +42,7 @@ out highp float v_linesofar;
|
||||
void main() {
|
||||
// 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
|
||||
@@ -81,7 +81,7 @@ void main() {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineBasicPropertiesUBO {
|
||||
@@ -103,7 +103,7 @@ void main() {
|
||||
// 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 = (1.0 / u_device_pixel_ratio) * v_gamma_scale;
|
||||
float blur2 = (1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist + blur2, v_width - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
fragColor = u_color * (alpha * u_opacity);
|
||||
|
||||
@@ -27,7 +27,7 @@ layout (std140) uniform LineGradientUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -104,7 +104,7 @@ 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
@@ -156,7 +156,7 @@ mediump float width = u_width;
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -209,7 +209,7 @@ lowp float opacity = u_opacity;
|
||||
// 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 blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
// For gradient lines, v_lineprogress is the ratio along the entire line,
|
||||
|
||||
@@ -29,9 +29,9 @@ layout (std140) uniform LinePatternUBO {
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
@@ -133,7 +133,7 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
|
||||
// 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
@@ -187,9 +187,9 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
@@ -278,7 +278,7 @@ lowp float opacity = u_opacity;
|
||||
// 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 blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
float x_a = mod(v_linesofar / pattern_size_a.x, 1.0);
|
||||
|
||||
@@ -29,11 +29,12 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
highp float u_tex_y_a;
|
||||
highp float u_tex_y_b;
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -132,7 +133,7 @@ lowp float floorwidth = u_floorwidth;
|
||||
|
||||
// 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
@@ -189,11 +190,12 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
highp float u_tex_y_a;
|
||||
highp float u_tex_y_b;
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -267,7 +269,7 @@ lowp float floorwidth = u_floorwidth;
|
||||
// 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 blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
float sdfdist_a = texture(u_image, v_tex_a).a;
|
||||
|
||||
@@ -30,8 +30,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
|
||||
@@ -38,8 +38,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
@@ -209,8 +209,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
@@ -280,7 +280,7 @@ lowp float halo_width = u_halo_width;
|
||||
lowp float halo_blur = u_halo_blur;
|
||||
#endif
|
||||
|
||||
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
|
||||
float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO;
|
||||
|
||||
vec2 tex = v_data0.xy;
|
||||
float gamma_scale = v_data1.x;
|
||||
|
||||
@@ -37,8 +37,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
@@ -212,8 +212,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
@@ -299,7 +299,7 @@ lowp float halo_blur = u_halo_blur;
|
||||
|
||||
vec2 tex = v_data0.xy;
|
||||
|
||||
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
|
||||
float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO;
|
||||
|
||||
float gamma_scale = v_data1.x;
|
||||
float size = v_data1.y;
|
||||
|
||||
@@ -26,7 +26,11 @@ public:
|
||||
|
||||
// We could cache these by key here to avoid creating a string key each time, but we
|
||||
// would need another mutex. We could also push string IDs down into `ShaderGroup`.
|
||||
const std::string shaderName = getShaderName(name, propertyHash(propertiesAsUniforms));
|
||||
std::size_t seed = 0;
|
||||
mbgl::util::hash_combine(seed, propertyHash(propertiesAsUniforms));
|
||||
mbgl::util::hash_combine(seed, programParameters.getDefinesHash());
|
||||
const std::string shaderName = getShaderName(name, seed);
|
||||
|
||||
auto shader = get<gl::ShaderProgramGL>(shaderName);
|
||||
if (shader) {
|
||||
return shader;
|
||||
|
||||
@@ -9,7 +9,7 @@ struct alignas(16) LineUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
float ratio;
|
||||
float device_pixel_ratio;
|
||||
float pad;
|
||||
};
|
||||
static_assert(sizeof(LineUBO) % 16 == 0);
|
||||
|
||||
@@ -42,9 +42,8 @@ struct alignas(16) LinePatternUBO {
|
||||
std::array<float, 2> texsize;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
float ratio;
|
||||
float device_pixel_ratio;
|
||||
float fade;
|
||||
float pad1;
|
||||
float pad1, pad2;
|
||||
};
|
||||
static_assert(sizeof(LinePatternUBO) % 16 == 0);
|
||||
|
||||
@@ -64,11 +63,11 @@ struct alignas(16) LineSDFUBO {
|
||||
std::array<float, 2> patternscale_a;
|
||||
std::array<float, 2> patternscale_b;
|
||||
float ratio;
|
||||
float device_pixel_ratio;
|
||||
float tex_y_a;
|
||||
float tex_y_b;
|
||||
float sdfgamma;
|
||||
float mix;
|
||||
float pad;
|
||||
};
|
||||
static_assert(sizeof(LineSDFUBO) % 16 == 0);
|
||||
|
||||
|
||||
@@ -80,8 +80,7 @@ struct alignas(16) CircleDrawableUBO {
|
||||
};
|
||||
struct alignas(16) CirclePaintParamsUBO {
|
||||
float camera_to_center_distance;
|
||||
float device_pixel_ratio;
|
||||
float pad1,pad2;
|
||||
float pad1,pad2,pad3;
|
||||
};
|
||||
struct alignas(16) CircleEvaluatedPropsUBO {
|
||||
float4 color;
|
||||
@@ -157,7 +156,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
// This is a minimum blur distance that serves as a faux-antialiasing for
|
||||
// the circle. since blur is a ratio of the circle's size and the intent is
|
||||
// to keep the blur at roughly 1px, the two are inversely related.
|
||||
const half antialiasblur = 1.0 / params.device_pixel_ratio / (radius + stroke_width);
|
||||
const half antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width);
|
||||
|
||||
return {
|
||||
.position = position,
|
||||
|
||||
@@ -58,21 +58,21 @@ struct alignas(16) LineUBO {
|
||||
float4x4 matrix;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float device_pixel_ratio;
|
||||
float pad;
|
||||
};
|
||||
|
||||
struct alignas(16) LineBasicUBO {
|
||||
float4x4 matrix;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float device_pixel_ratio;
|
||||
float pad;
|
||||
};
|
||||
|
||||
struct alignas(16) LineGradientUBO {
|
||||
float4x4 matrix;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float device_pixel_ratio;
|
||||
float pad;
|
||||
};
|
||||
|
||||
struct alignas(16) LinePropertiesUBO {
|
||||
@@ -159,8 +159,8 @@ static_assert(sizeof(SymbolDrawableUBO) == 14 * 16, "unexpected padding");
|
||||
struct alignas(16) SymbolDynamicUBO {
|
||||
float fade_change;
|
||||
float camera_to_center_distance;
|
||||
float device_pixel_ratio;
|
||||
float aspect_ratio;
|
||||
float pad;
|
||||
};
|
||||
static_assert(sizeof(SymbolDynamicUBO) == 16, "unexpected padding");
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// 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 float ANTIALIASING = 1.0 / 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;
|
||||
@@ -163,7 +163,7 @@ half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
|
||||
// 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 = (blur + 1.0 / line.device_pixel_ratio) * in.gamma_scale;
|
||||
const float blur2 = (blur + 1.0 / 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(color * (alpha * opacity));
|
||||
@@ -236,9 +236,8 @@ struct alignas(16) LinePatternUBO {
|
||||
float2 texsize;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float device_pixel_ratio;
|
||||
float fade;
|
||||
float pad1;
|
||||
float pad1, pad2;
|
||||
};
|
||||
|
||||
struct alignas(16) LinePatternPropertiesUBO {
|
||||
@@ -290,7 +289,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// 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 float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
const float LINE_DISTANCE_SCALE = 2.0;
|
||||
|
||||
const float2 a_extrude = float2(vertx.data.xy) - 128.0;
|
||||
@@ -490,11 +489,11 @@ struct alignas(16) LineSDFUBO {
|
||||
float2 patternscale_a;
|
||||
float2 patternscale_b;
|
||||
float ratio;
|
||||
float device_pixel_ratio;
|
||||
float tex_y_a;
|
||||
float tex_y_b;
|
||||
float sdfgamma;
|
||||
float mix;
|
||||
float pad;
|
||||
};
|
||||
|
||||
struct alignas(16) LineSDFPropertiesUBO {
|
||||
@@ -547,7 +546,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// 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 float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
const float LINE_DISTANCE_SCALE = 2.0;
|
||||
|
||||
const float2 a_extrude = float2(vertx.data.xy) - 128.0;
|
||||
@@ -638,7 +637,7 @@ half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
|
||||
// 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 = (blur + 1.0 / line.device_pixel_ratio) * in.gamma_scale;
|
||||
const float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * in.gamma_scale;
|
||||
|
||||
const float sdfdist_a = image0.sample(image0_sampler, in.tex_a).a;
|
||||
const float sdfdist_b = image0.sample(image0_sampler, in.tex_b).a;
|
||||
@@ -681,7 +680,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// 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 float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
const float2 a_extrude = float2(vertx.data.xy) - 128.0;
|
||||
const float2 pos = floor(float2(vertx.pos_normal) * 0.5);
|
||||
@@ -722,7 +721,7 @@ half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
|
||||
// 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 = (1.0 / line.device_pixel_ratio) * in.gamma_scale;
|
||||
const float blur2 = (1.0 / DEVICE_PIXEL_RATIO) * in.gamma_scale;
|
||||
const float alpha = clamp(min(dist + blur2, in.width2 - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
return half4(props.color * (alpha * props.opacity));
|
||||
|
||||
@@ -73,7 +73,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// 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 float ANTIALIASING = 1.0 / 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;
|
||||
@@ -148,7 +148,7 @@ half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
|
||||
// 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 = (blur + 1.0 / line.device_pixel_ratio) * in.gamma_scale;
|
||||
const float blur2 = (blur + 1.0 / 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);
|
||||
|
||||
// For gradient lines, v_lineprogress is the ratio along the entire line,
|
||||
|
||||
@@ -25,10 +25,7 @@ protected:
|
||||
|
||||
using DefinesMap = mbgl::unordered_map<std::string, std::string>;
|
||||
void addAdditionalDefines(const StringIDSet& propertiesAsUniforms, DefinesMap& additionalDefines) {
|
||||
additionalDefines.reserve(propertiesAsUniforms.size() + 1);
|
||||
if (programParameters.getOverdrawInspectorEnabled()) {
|
||||
additionalDefines.insert(std::make_pair(overdrawName, std::string()));
|
||||
}
|
||||
additionalDefines.reserve(propertiesAsUniforms.size());
|
||||
for (const auto nameID : propertiesAsUniforms) {
|
||||
// We expect the names to be prefixed by "a_", but we need just the base here.
|
||||
const auto name = stringIndexer().get(nameID);
|
||||
@@ -41,7 +38,6 @@ protected:
|
||||
|
||||
private:
|
||||
static constexpr auto uniformPrefix = "HAS_UNIFORM_u_";
|
||||
static constexpr auto overdrawName = "OVERDRAW_INSPECTOR";
|
||||
};
|
||||
|
||||
template <shaders::BuiltIn ShaderID>
|
||||
@@ -60,7 +56,10 @@ public:
|
||||
constexpr auto& vertMain = ShaderSource::vertexMainFunction;
|
||||
constexpr auto& fragMain = ShaderSource::fragmentMainFunction;
|
||||
|
||||
const std::string shaderName = getShaderName(name, propertyHash(propertiesAsUniforms));
|
||||
std::size_t seed = 0;
|
||||
mbgl::util::hash_combine(seed, propertyHash(propertiesAsUniforms));
|
||||
mbgl::util::hash_combine(seed, programParameters.getDefinesHash());
|
||||
const std::string shaderName = getShaderName(name, seed);
|
||||
|
||||
auto shader = get<mtl::ShaderProgram>(shaderName);
|
||||
if (!shader) {
|
||||
|
||||
@@ -200,7 +200,7 @@ half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
const float halo_blur = in.halo_blur;
|
||||
#endif
|
||||
|
||||
const float EDGE_GAMMA = 0.105 / dynamic.device_pixel_ratio;
|
||||
const float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO;
|
||||
const float fontGamma = in.fontScale * drawable.gamma_scale;
|
||||
const half4 color = props.is_halo ? halo_color : fill_color;
|
||||
const float gamma = ((props.is_halo ? (halo_blur * 1.19 / SDF_PX) : 0) + EDGE_GAMMA) / fontGamma;
|
||||
|
||||
@@ -217,7 +217,7 @@ half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
return half4(icon_image.sample(icon_sampler, float2(in.tex)) * alpha);
|
||||
}
|
||||
|
||||
const float EDGE_GAMMA = 0.105 / dynamic.device_pixel_ratio;
|
||||
const float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO;
|
||||
const half4 color = props.is_halo ? halo_color : fill_color;
|
||||
const float fontGamma = in.fontScale * drawable.gamma_scale;
|
||||
const float gamma = ((props.is_halo ? (halo_blur * 1.19 / SDF_PX) : 0) + EDGE_GAMMA) / fontGamma;
|
||||
|
||||
@@ -51,8 +51,8 @@ static_assert(sizeof(SymbolDrawableUBO) == 14 * 16);
|
||||
struct alignas(16) SymbolDynamicUBO {
|
||||
/* 0 */ float fade_change;
|
||||
/* 4 */ float camera_to_center_distance;
|
||||
/* 8 */ float device_pixel_ratio;
|
||||
/* 12 */ float aspect_ratio;
|
||||
/* 8 */ float aspect_ratio;
|
||||
/* 12 */ float pad;
|
||||
/* 16 */
|
||||
};
|
||||
static_assert(sizeof(SymbolDynamicUBO) == 16);
|
||||
|
||||
@@ -9,8 +9,8 @@ layout (std140) uniform CircleDrawableUBO {
|
||||
|
||||
layout (std140) uniform CirclePaintParamsUBO {
|
||||
highp float u_camera_to_center_distance;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp vec2 pad3_;
|
||||
lowp float pad3_;
|
||||
lowp vec2 pad4_;
|
||||
};
|
||||
|
||||
layout (std140) uniform CircleEvaluatedPropsUBO {
|
||||
@@ -86,7 +86,7 @@ void main(void) {
|
||||
// This is a minimum blur distance that serves as a faux-antialiasing for
|
||||
// the circle. since blur is a ratio of the circle's size and the intent is
|
||||
// to keep the blur at roughly 1px, the two are inversely related.
|
||||
lowp float antialiasblur = 1.0 / u_device_pixel_ratio / (radius + stroke_width);
|
||||
lowp float antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width);
|
||||
|
||||
v_data = vec3(extrude.x, extrude.y, antialiasblur);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ layout (std140) uniform LineUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -47,7 +47,7 @@ void main() {
|
||||
// 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 blur2 = (blur + 1.0 / 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);
|
||||
|
||||
@@ -13,7 +13,7 @@ layout (std140) uniform LineUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -61,7 +61,7 @@ void main() {
|
||||
|
||||
// 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
|
||||
@@ -2,7 +2,7 @@ layout (std140) uniform LineBasicUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineBasicPropertiesUBO {
|
||||
@@ -24,7 +24,7 @@ void main() {
|
||||
// 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 = (1.0 / u_device_pixel_ratio) * v_gamma_scale;
|
||||
float blur2 = (1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist + blur2, v_width - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
fragColor = u_color * (alpha * u_opacity);
|
||||
|
||||
@@ -13,7 +13,7 @@ layout (std140) uniform LineBasicUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineBasicPropertiesUBO {
|
||||
@@ -32,7 +32,7 @@ out highp float v_linesofar;
|
||||
void main() {
|
||||
// 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ layout (std140) uniform LineGradientUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -47,7 +47,7 @@ void main() {
|
||||
// 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 blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
// For gradient lines, v_lineprogress is the ratio along the entire line,
|
||||
|
||||
@@ -17,7 +17,7 @@ layout (std140) uniform LineGradientUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -62,7 +62,7 @@ void main() {
|
||||
|
||||
// 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
|
||||
@@ -4,9 +4,9 @@ layout (std140) uniform LinePatternUBO {
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
@@ -79,7 +79,7 @@ void main() {
|
||||
// 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 blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
float x_a = mod(v_linesofar / pattern_size_a.x, 1.0);
|
||||
|
||||
@@ -19,9 +19,9 @@ layout (std140) uniform LinePatternUBO {
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ void main() {
|
||||
|
||||
// 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
|
||||
@@ -5,11 +5,12 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
highp float u_tex_y_a;
|
||||
highp float u_tex_y_b;
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -63,7 +64,7 @@ void main() {
|
||||
// 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 blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
float sdfdist_a = texture(u_image, v_tex_a).a;
|
||||
|
||||
@@ -19,11 +19,12 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
lowp float u_device_pixel_ratio;
|
||||
highp float u_tex_y_a;
|
||||
highp float u_tex_y_b;
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -75,7 +76,7 @@ void main() {
|
||||
|
||||
// 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;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
|
||||
@@ -20,8 +20,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
|
||||
@@ -16,8 +16,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
@@ -67,7 +67,7 @@ void main() {
|
||||
#pragma mapbox: initialize lowp float halo_width
|
||||
#pragma mapbox: initialize lowp float halo_blur
|
||||
|
||||
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
|
||||
float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO;
|
||||
|
||||
vec2 tex = v_data0.xy;
|
||||
float gamma_scale = v_data1.x;
|
||||
|
||||
@@ -28,8 +28,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
|
||||
@@ -19,8 +19,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
@@ -86,7 +86,7 @@ void main() {
|
||||
|
||||
vec2 tex = v_data0.xy;
|
||||
|
||||
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
|
||||
float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO;
|
||||
|
||||
float gamma_scale = v_data1.x;
|
||||
float size = v_data1.y;
|
||||
|
||||
@@ -27,8 +27,8 @@ layout (std140) uniform SymbolDrawableUBO {
|
||||
layout (std140) uniform SymbolDynamicUBO {
|
||||
highp float u_fade_change;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_device_pixel_ratio;
|
||||
highp float u_aspect_ratio;
|
||||
highp float pad0;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawablePaintUBO {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
|
||||
#include <mbgl/util/hash.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
|
||||
#include <string_view>
|
||||
@@ -14,6 +15,7 @@ ProgramParameters::ProgramParameters(const float pixelRatio, const bool overdraw
|
||||
if (overdraw) {
|
||||
defines["OVERDRAW_INSPECTOR"] = std::string();
|
||||
}
|
||||
definesHash = util::hash(getDefinesString());
|
||||
}
|
||||
|
||||
ProgramParameters ProgramParameters::withShaderSource(const ProgramSource& source) const noexcept {
|
||||
|
||||
@@ -62,9 +62,11 @@ public:
|
||||
const std::string& fragmentSource(gfx::Backend::Type backend) const;
|
||||
|
||||
bool getOverdrawInspectorEnabled() const { return overdrawInspector; }
|
||||
std::uint64_t getDefinesHash() const { return definesHash; }
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> defines;
|
||||
std::uint64_t definesHash;
|
||||
|
||||
// cached value of `defines` converted to string format
|
||||
mutable std::string definesStr;
|
||||
|
||||
@@ -42,8 +42,8 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
|
||||
// Updated every frame, but shared across drawables
|
||||
const CirclePaintParamsUBO paintParamsUBO = {
|
||||
/* .camera_to_center_distance = */ parameters.state.getCameraToCenterDistance(),
|
||||
/* .device_pixel_ratio = */ parameters.pixelRatio,
|
||||
/* .padding = */ 0,
|
||||
0,
|
||||
0};
|
||||
|
||||
if (!paintParamsUniformBuffer) {
|
||||
|
||||
@@ -130,7 +130,7 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
/*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)),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
uniforms.createOrUpdate(idLineUBOName, &lineUBO, context);
|
||||
|
||||
// properties UBO
|
||||
@@ -142,7 +142,7 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
/*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)),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
uniforms.createOrUpdate(idLineGradientUBOName, &lineGradientUBO, context);
|
||||
|
||||
// properties UBO
|
||||
@@ -165,8 +165,8 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
/*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)),
|
||||
/*device_pixel_ratio =*/parameters.pixelRatio,
|
||||
/*fade =*/crossfade.t,
|
||||
0,
|
||||
0};
|
||||
uniforms.createOrUpdate(idLinePatternUBOName, &linePatternUBO, context);
|
||||
|
||||
@@ -208,12 +208,12 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
-posB.height / 2.0f},
|
||||
/* ratio = */ 1.0f /
|
||||
tileID.pixelsToTileUnits(1.0f, static_cast<float>(parameters.state.getZoom())),
|
||||
/* device_pixel_ratio = */ parameters.pixelRatio,
|
||||
/* 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};
|
||||
/* mix = */ crossfade.t,
|
||||
0};
|
||||
uniforms.createOrUpdate(idLineSDFUBOName, &lineSDFUBO, context);
|
||||
|
||||
// properties UBO
|
||||
|
||||
@@ -374,7 +374,7 @@ public:
|
||||
/*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),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
parameters.context.emplaceOrUpdateUniformBuffer(lineUniformBuffer, &lineUBO);
|
||||
}
|
||||
uniforms.addOrReplace(idLineUBOName, lineUniformBuffer);
|
||||
|
||||
@@ -94,8 +94,8 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
|
||||
|
||||
const SymbolDynamicUBO dynamicUBO = {/*.fade_change=*/parameters.symbolFadeChange,
|
||||
/*.camera_to_center_distance=*/camDist,
|
||||
/*.device_pixel_ratio=*/parameters.pixelRatio,
|
||||
/*.aspect_ratio=*/state.getSize().aspectRatio()};
|
||||
/*.aspect_ratio=*/state.getSize().aspectRatio(),
|
||||
0};
|
||||
|
||||
if (!dynamicBuffer) {
|
||||
dynamicBuffer = parameters.context.createUniformBuffer(&dynamicUBO, sizeof(dynamicUBO));
|
||||
|
||||
@@ -215,7 +215,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
/*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),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
|
||||
static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO");
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
/*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),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
|
||||
static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user