diff --git a/include/mbgl/shaders/circle_layer_ubo.hpp b/include/mbgl/shaders/circle_layer_ubo.hpp index f98dfe89e..9c347b807 100644 --- a/include/mbgl/shaders/circle_layer_ubo.hpp +++ b/include/mbgl/shaders/circle_layer_ubo.hpp @@ -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); diff --git a/include/mbgl/shaders/gl/drawable_circle.hpp b/include/mbgl/shaders/gl/drawable_circle.hpp index d55b883d0..169c5691d 100644 --- a/include/mbgl/shaders/gl/drawable_circle.hpp +++ b/include/mbgl/shaders/gl/drawable_circle.hpp @@ -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); } diff --git a/include/mbgl/shaders/gl/drawable_line.hpp b/include/mbgl/shaders/gl/drawable_line.hpp index 186c394ca..6645eded1 100644 --- a/include/mbgl/shaders/gl/drawable_line.hpp +++ b/include/mbgl/shaders/gl/drawable_line.hpp @@ -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); diff --git a/include/mbgl/shaders/gl/drawable_line_basic.hpp b/include/mbgl/shaders/gl/drawable_line_basic.hpp index e7f4e1256..acdbef93c 100644 --- a/include/mbgl/shaders/gl/drawable_line_basic.hpp +++ b/include/mbgl/shaders/gl/drawable_line_basic.hpp @@ -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); diff --git a/include/mbgl/shaders/gl/drawable_line_gradient.hpp b/include/mbgl/shaders/gl/drawable_line_gradient.hpp index c1c44aa5a..a41f945e4 100644 --- a/include/mbgl/shaders/gl/drawable_line_gradient.hpp +++ b/include/mbgl/shaders/gl/drawable_line_gradient.hpp @@ -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, diff --git a/include/mbgl/shaders/gl/drawable_line_pattern.hpp b/include/mbgl/shaders/gl/drawable_line_pattern.hpp index 391df59c9..6fe186c5b 100644 --- a/include/mbgl/shaders/gl/drawable_line_pattern.hpp +++ b/include/mbgl/shaders/gl/drawable_line_pattern.hpp @@ -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); diff --git a/include/mbgl/shaders/gl/drawable_line_sdf.hpp b/include/mbgl/shaders/gl/drawable_line_sdf.hpp index 37c641081..eecdcd5cc 100644 --- a/include/mbgl/shaders/gl/drawable_line_sdf.hpp +++ b/include/mbgl/shaders/gl/drawable_line_sdf.hpp @@ -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; diff --git a/include/mbgl/shaders/gl/drawable_symbol_icon.hpp b/include/mbgl/shaders/gl/drawable_symbol_icon.hpp index 9c62bb798..fe648f653 100644 --- a/include/mbgl/shaders/gl/drawable_symbol_icon.hpp +++ b/include/mbgl/shaders/gl/drawable_symbol_icon.hpp @@ -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 { diff --git a/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp b/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp index be2b56a39..9a6b3d0a7 100644 --- a/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp +++ b/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp @@ -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; diff --git a/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp b/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp index 9589b057b..7d0f6abe8 100644 --- a/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp +++ b/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp @@ -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; diff --git a/include/mbgl/shaders/gl/shader_group_gl.hpp b/include/mbgl/shaders/gl/shader_group_gl.hpp index a1c2367df..8a517470d 100644 --- a/include/mbgl/shaders/gl/shader_group_gl.hpp +++ b/include/mbgl/shaders/gl/shader_group_gl.hpp @@ -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(shaderName); if (shader) { return shader; diff --git a/include/mbgl/shaders/line_layer_ubo.hpp b/include/mbgl/shaders/line_layer_ubo.hpp index e1959e97f..43859adf7 100644 --- a/include/mbgl/shaders/line_layer_ubo.hpp +++ b/include/mbgl/shaders/line_layer_ubo.hpp @@ -9,7 +9,7 @@ struct alignas(16) LineUBO { std::array matrix; std::array 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 texsize; std::array 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 patternscale_a; std::array 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); diff --git a/include/mbgl/shaders/mtl/circle.hpp b/include/mbgl/shaders/mtl/circle.hpp index 9bf0b1b25..9f1079853 100644 --- a/include/mbgl/shaders/mtl/circle.hpp +++ b/include/mbgl/shaders/mtl/circle.hpp @@ -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, diff --git a/include/mbgl/shaders/mtl/common.hpp b/include/mbgl/shaders/mtl/common.hpp index 8a3c2586e..da318e2cf 100644 --- a/include/mbgl/shaders/mtl/common.hpp +++ b/include/mbgl/shaders/mtl/common.hpp @@ -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"); diff --git a/include/mbgl/shaders/mtl/line.hpp b/include/mbgl/shaders/mtl/line.hpp index 09bae7178..c96569cb7 100644 --- a/include/mbgl/shaders/mtl/line.hpp +++ b/include/mbgl/shaders/mtl/line.hpp @@ -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)); diff --git a/include/mbgl/shaders/mtl/line_gradient.hpp b/include/mbgl/shaders/mtl/line_gradient.hpp index 9c0eb3b84..b8cf813fc 100644 --- a/include/mbgl/shaders/mtl/line_gradient.hpp +++ b/include/mbgl/shaders/mtl/line_gradient.hpp @@ -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, diff --git a/include/mbgl/shaders/mtl/shader_group.hpp b/include/mbgl/shaders/mtl/shader_group.hpp index 06c987ed1..a3b8e9904 100644 --- a/include/mbgl/shaders/mtl/shader_group.hpp +++ b/include/mbgl/shaders/mtl/shader_group.hpp @@ -25,10 +25,7 @@ protected: using DefinesMap = mbgl::unordered_map; 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 @@ -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(shaderName); if (!shader) { diff --git a/include/mbgl/shaders/mtl/symbol_sdf.hpp b/include/mbgl/shaders/mtl/symbol_sdf.hpp index b080edd96..1d5e5b813 100644 --- a/include/mbgl/shaders/mtl/symbol_sdf.hpp +++ b/include/mbgl/shaders/mtl/symbol_sdf.hpp @@ -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; diff --git a/include/mbgl/shaders/mtl/symbol_text_and_icon.hpp b/include/mbgl/shaders/mtl/symbol_text_and_icon.hpp index f21d3386d..4fc259c3e 100644 --- a/include/mbgl/shaders/mtl/symbol_text_and_icon.hpp +++ b/include/mbgl/shaders/mtl/symbol_text_and_icon.hpp @@ -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; diff --git a/include/mbgl/shaders/symbol_layer_ubo.hpp b/include/mbgl/shaders/symbol_layer_ubo.hpp index d01868870..7c93fb567 100644 --- a/include/mbgl/shaders/symbol_layer_ubo.hpp +++ b/include/mbgl/shaders/symbol_layer_ubo.hpp @@ -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); diff --git a/shaders/drawable.circle.vertex.glsl b/shaders/drawable.circle.vertex.glsl index ac7612bb9..5e6c784c6 100644 --- a/shaders/drawable.circle.vertex.glsl +++ b/shaders/drawable.circle.vertex.glsl @@ -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); } diff --git a/shaders/drawable.line.fragment.glsl b/shaders/drawable.line.fragment.glsl index 88167104f..a8e354c96 100644 --- a/shaders/drawable.line.fragment.glsl +++ b/shaders/drawable.line.fragment.glsl @@ -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); diff --git a/shaders/drawable.line.vertex.glsl b/shaders/drawable.line.vertex.glsl index e68edd525..169564ab8 100644 --- a/shaders/drawable.line.vertex.glsl +++ b/shaders/drawable.line.vertex.glsl @@ -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; diff --git a/shaders/drawable.line_basic.fragment.glsl b/shaders/drawable.line_basic.fragment.glsl index 681a5ed3c..a7b006377 100644 --- a/shaders/drawable.line_basic.fragment.glsl +++ b/shaders/drawable.line_basic.fragment.glsl @@ -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); diff --git a/shaders/drawable.line_basic.vertex.glsl b/shaders/drawable.line_basic.vertex.glsl index a73879f78..74b4ca7e5 100644 --- a/shaders/drawable.line_basic.vertex.glsl +++ b/shaders/drawable.line_basic.vertex.glsl @@ -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; diff --git a/shaders/drawable.line_gradient.fragment.glsl b/shaders/drawable.line_gradient.fragment.glsl index 1f1465b9d..4e3c6856d 100644 --- a/shaders/drawable.line_gradient.fragment.glsl +++ b/shaders/drawable.line_gradient.fragment.glsl @@ -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, diff --git a/shaders/drawable.line_gradient.vertex.glsl b/shaders/drawable.line_gradient.vertex.glsl index d56c52a0e..e41ca7901 100644 --- a/shaders/drawable.line_gradient.vertex.glsl +++ b/shaders/drawable.line_gradient.vertex.glsl @@ -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; diff --git a/shaders/drawable.line_pattern.fragment.glsl b/shaders/drawable.line_pattern.fragment.glsl index a6548afb9..30b5a7c0c 100644 --- a/shaders/drawable.line_pattern.fragment.glsl +++ b/shaders/drawable.line_pattern.fragment.glsl @@ -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); diff --git a/shaders/drawable.line_pattern.vertex.glsl b/shaders/drawable.line_pattern.vertex.glsl index 21b2d3e00..600e8f3af 100644 --- a/shaders/drawable.line_pattern.vertex.glsl +++ b/shaders/drawable.line_pattern.vertex.glsl @@ -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; diff --git a/shaders/drawable.line_sdf.fragment.glsl b/shaders/drawable.line_sdf.fragment.glsl index c15478885..64b2c406d 100644 --- a/shaders/drawable.line_sdf.fragment.glsl +++ b/shaders/drawable.line_sdf.fragment.glsl @@ -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; diff --git a/shaders/drawable.line_sdf.vertex.glsl b/shaders/drawable.line_sdf.vertex.glsl index 879857830..cc41cf61b 100644 --- a/shaders/drawable.line_sdf.vertex.glsl +++ b/shaders/drawable.line_sdf.vertex.glsl @@ -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; diff --git a/shaders/drawable.symbol_icon.vertex.glsl b/shaders/drawable.symbol_icon.vertex.glsl index eebbe2c27..bd902925f 100644 --- a/shaders/drawable.symbol_icon.vertex.glsl +++ b/shaders/drawable.symbol_icon.vertex.glsl @@ -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 { diff --git a/shaders/drawable.symbol_sdf.fragment.glsl b/shaders/drawable.symbol_sdf.fragment.glsl index 980d30251..a96bc3c25 100644 --- a/shaders/drawable.symbol_sdf.fragment.glsl +++ b/shaders/drawable.symbol_sdf.fragment.glsl @@ -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; diff --git a/shaders/drawable.symbol_sdf.vertex.glsl b/shaders/drawable.symbol_sdf.vertex.glsl index 6c6287f15..e7a5d85c5 100644 --- a/shaders/drawable.symbol_sdf.vertex.glsl +++ b/shaders/drawable.symbol_sdf.vertex.glsl @@ -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 { diff --git a/shaders/drawable.symbol_text_and_icon.fragment.glsl b/shaders/drawable.symbol_text_and_icon.fragment.glsl index 44c4931d2..c956d4daa 100644 --- a/shaders/drawable.symbol_text_and_icon.fragment.glsl +++ b/shaders/drawable.symbol_text_and_icon.fragment.glsl @@ -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; diff --git a/shaders/drawable.symbol_text_and_icon.vertex.glsl b/shaders/drawable.symbol_text_and_icon.vertex.glsl index 4c8156c40..9390c584a 100644 --- a/shaders/drawable.symbol_text_and_icon.vertex.glsl +++ b/shaders/drawable.symbol_text_and_icon.vertex.glsl @@ -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 { diff --git a/src/mbgl/programs/program_parameters.cpp b/src/mbgl/programs/program_parameters.cpp index bacbfdb48..197f14e44 100644 --- a/src/mbgl/programs/program_parameters.cpp +++ b/src/mbgl/programs/program_parameters.cpp @@ -1,5 +1,6 @@ #include +#include #include #include @@ -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 { diff --git a/src/mbgl/programs/program_parameters.hpp b/src/mbgl/programs/program_parameters.hpp index 52d696d5d..a4936a972 100644 --- a/src/mbgl/programs/program_parameters.hpp +++ b/src/mbgl/programs/program_parameters.hpp @@ -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 defines; + std::uint64_t definesHash; // cached value of `defines` converted to string format mutable std::string definesStr; diff --git a/src/mbgl/renderer/layers/circle_layer_tweaker.cpp b/src/mbgl/renderer/layers/circle_layer_tweaker.cpp index 17cee3ff8..2b450e31d 100644 --- a/src/mbgl/renderer/layers/circle_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/circle_layer_tweaker.cpp @@ -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) { diff --git a/src/mbgl/renderer/layers/line_layer_tweaker.cpp b/src/mbgl/renderer/layers/line_layer_tweaker.cpp index 3136dd8d9..4f46e255e 100644 --- a/src/mbgl/renderer/layers/line_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/line_layer_tweaker.cpp @@ -130,7 +130,7 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters /*matrix = */ util::cast(matrix), /*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, /*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(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(matrix), /*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, /*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(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(textureSize.width), static_cast(textureSize.height)}, /*units_to_pixels =*/{1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, /*ratio =*/1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(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(parameters.state.getZoom())), - /* device_pixel_ratio = */ parameters.pixelRatio, /* tex_y_a = */ posA.y, /* tex_y_b = */ posB.y, /* sdfgamma = */ static_cast(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 diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index 8c61a5853..d3bd88c67 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -374,7 +374,7 @@ public: /*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), - /*device_pixel_ratio = */ parameters.pixelRatio}; + 0}; parameters.context.emplaceOrUpdateUniformBuffer(lineUniformBuffer, &lineUBO); } uniforms.addOrReplace(idLineUBOName, lineUniformBuffer); diff --git a/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp b/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp index feee50e54..715bc738a 100644 --- a/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp @@ -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)); diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp index a0a8d9b5f..da7e2b2d6 100644 --- a/src/mbgl/renderer/sources/render_tile_source.cpp +++ b/src/mbgl/renderer/sources/render_tile_source.cpp @@ -215,7 +215,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr /*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), - /*device_pixel_ratio = */ parameters.pixelRatio}; + 0}; static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO"); diff --git a/src/mbgl/style/layers/custom_drawable_layer.cpp b/src/mbgl/style/layers/custom_drawable_layer.cpp index e4037550f..5984e2093 100644 --- a/src/mbgl/style/layers/custom_drawable_layer.cpp +++ b/src/mbgl/style/layers/custom_drawable_layer.cpp @@ -102,7 +102,7 @@ public: /*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), - /*device_pixel_ratio = */ parameters.pixelRatio}; + 0}; static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO");