Skip to content

Commit

Permalink
Symbol UBOs fixes (#2331)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcristici authored Apr 26, 2024
1 parent 51a77b4 commit 84ec4f8
Show file tree
Hide file tree
Showing 13 changed files with 10 additions and 68 deletions.
9 changes: 0 additions & 9 deletions include/mbgl/shaders/gl/drawable_symbol_icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,6 @@ lowp float opacity = u_opacity;
)";
static constexpr const char* fragment = R"(uniform sampler2D u_texture;
layout (std140) uniform SymbolInterpolateUBO {
highp float u_fill_color_t;
highp float u_halo_color_t;
highp float u_opacity_t;
highp float u_halo_width_t;
highp float u_halo_blur_t;
highp float interp_pad1, interp_pad2,interp_pad3;
};
layout (std140) uniform SymbolTilePropsUBO {
bool u_is_text;
bool u_is_halo;
Expand Down
9 changes: 0 additions & 9 deletions include/mbgl/shaders/gl/drawable_symbol_sdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,6 @@ layout (std140) uniform SymbolTilePropsUBO {
bool tileprops_pad1;
};
layout (std140) uniform SymbolInterpolateUBO {
highp float u_fill_color_t;
highp float u_halo_color_t;
highp float u_opacity_t;
highp float u_halo_width_t;
highp float u_halo_blur_t;
highp float interp_pad1, interp_pad2, interp_pad3;
};
layout (std140) uniform SymbolEvaluatedPropsUBO {
highp vec4 u_text_fill_color;
highp vec4 u_text_halo_color;
Expand Down
9 changes: 0 additions & 9 deletions include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,6 @@ layout (std140) uniform SymbolTilePropsUBO {
bool tileprops_pad1;
};
layout (std140) uniform SymbolInterpolateUBO {
highp float u_fill_color_t;
highp float u_halo_color_t;
highp float u_opacity_t;
highp float u_halo_width_t;
highp float u_halo_blur_t;
highp float interp_pad1, interp_pad2,interp_pad3;
};
layout (std140) uniform SymbolEvaluatedPropsUBO {
highp vec4 u_text_fill_color;
highp vec4 u_text_halo_color;
Expand Down
4 changes: 1 addition & 3 deletions include/mbgl/shaders/mtl/symbol_icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
device const GlobalPaintParamsUBO& paintParams [[buffer(0)]],
device const SymbolDrawableUBO& drawable [[buffer(1)]],
device const SymbolTilePropsUBO& tileprops [[buffer(2)]],
device const SymbolInterpolateUBO& interp [[buffer(3)]],
device const SymbolEvaluatedPropsUBO& paint [[buffer(4)]]) {
device const SymbolInterpolateUBO& interp [[buffer(3)]]) {
const float2 a_pos = vertx.pos_offset.xy;
const float2 a_offset = vertx.pos_offset.zw;
Expand Down Expand Up @@ -123,7 +122,6 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
}
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
device const SymbolDrawableUBO& drawable [[buffer(1)]],
device const SymbolTilePropsUBO& tileprops [[buffer(2)]],
device const SymbolEvaluatedPropsUBO& props [[buffer(4)]],
texture2d<float, access::sample> image [[texture(0)]],
Expand Down
3 changes: 1 addition & 2 deletions include/mbgl/shaders/mtl/symbol_sdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
device const GlobalPaintParamsUBO& paintParams [[buffer(0)]],
device const SymbolDrawableUBO& drawable [[buffer(1)]],
device const SymbolTilePropsUBO& tileprops [[buffer(2)]],
device const SymbolInterpolateUBO& interp [[buffer(3)]],
device const SymbolEvaluatedPropsUBO& props [[buffer(4)]]) {
device const SymbolInterpolateUBO& interp [[buffer(3)]]) {
const float2 a_pos = vertx.pos_offset.xy;
const float2 a_offset = vertx.pos_offset.zw;
Expand Down
3 changes: 1 addition & 2 deletions include/mbgl/shaders/mtl/symbol_text_and_icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
device const GlobalPaintParamsUBO& paintParams [[buffer(0)]],
device const SymbolDrawableUBO& drawable [[buffer(1)]],
device const SymbolTilePropsUBO& tileprops [[buffer(2)]],
device const SymbolInterpolateUBO& interp [[buffer(3)]],
device const SymbolEvaluatedPropsUBO& props [[buffer(4)]]) {
device const SymbolInterpolateUBO& interp [[buffer(3)]]) {
const float2 a_pos = vertx.pos_offset.xy;
const float2 a_offset = vertx.pos_offset.zw;
Expand Down
9 changes: 0 additions & 9 deletions shaders/drawable.symbol_icon.fragment.glsl
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
uniform sampler2D u_texture;

layout (std140) uniform SymbolInterpolateUBO {
highp float u_fill_color_t;
highp float u_halo_color_t;
highp float u_opacity_t;
highp float u_halo_width_t;
highp float u_halo_blur_t;
highp float interp_pad1, interp_pad2,interp_pad3;
};

layout (std140) uniform SymbolTilePropsUBO {
bool u_is_text;
bool u_is_halo;
Expand Down
9 changes: 0 additions & 9 deletions shaders/drawable.symbol_sdf.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ layout (std140) uniform SymbolTilePropsUBO {
bool tileprops_pad1;
};

layout (std140) uniform SymbolInterpolateUBO {
highp float u_fill_color_t;
highp float u_halo_color_t;
highp float u_opacity_t;
highp float u_halo_width_t;
highp float u_halo_blur_t;
highp float interp_pad1, interp_pad2, interp_pad3;
};

layout (std140) uniform SymbolEvaluatedPropsUBO {
highp vec4 u_text_fill_color;
highp vec4 u_text_halo_color;
Expand Down
9 changes: 0 additions & 9 deletions shaders/drawable.symbol_text_and_icon.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ layout (std140) uniform SymbolTilePropsUBO {
bool tileprops_pad1;
};

layout (std140) uniform SymbolInterpolateUBO {
highp float u_fill_color_t;
highp float u_halo_color_t;
highp float u_opacity_t;
highp float u_halo_width_t;
highp float u_halo_blur_t;
highp float interp_pad1, interp_pad2,interp_pad3;
};

layout (std140) uniform SymbolEvaluatedPropsUBO {
highp vec4 u_text_fill_color;
highp vec4 u_text_halo_color;
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/renderer/layers/render_symbol_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,8 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
auto addCollisionDrawables = [&](const bool isText, const bool hasCollisionBox, const bool hasCollisionCircle) {
if (!hasCollisionBox && !hasCollisionCircle) return;

const auto& group = getCollisionTileLayerGroup();
if (!group) {
const auto& collisionGroup = getCollisionTileLayerGroup();
if (!collisionGroup) {
return;
}

Expand Down Expand Up @@ -1132,7 +1132,7 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,

auto drawData = std::make_unique<gfx::CollisionDrawableData>(values.translate, values.translateAnchor);
drawable->setData(std::move(drawData));
group->addDrawable(passes, tileID, std::move(drawable));
collisionGroup->addDrawable(passes, tileID, std::move(drawable));
++stats.drawablesAdded;
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/shaders/mtl/symbol_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace shaders {

const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(SymbolDrawableUBO), idSymbolDrawableUBO},
UniformBlockInfo{true, false, sizeof(SymbolDrawableUBO), idSymbolDrawableUBO},
UniformBlockInfo{true, true, sizeof(SymbolTilePropsUBO), idSymbolTilePropsUBO},
UniformBlockInfo{true, false, sizeof(SymbolInterpolateUBO), idSymbolInterpolateUBO},
UniformBlockInfo{true, true, sizeof(SymbolEvaluatedPropsUBO), idSymbolEvaluatedPropsUBO},
UniformBlockInfo{false, true, sizeof(SymbolEvaluatedPropsUBO), idSymbolEvaluatedPropsUBO},
};
const std::array<AttributeInfo, 6> ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Metal>::attributes = {
// always attributes
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/shaders/mtl/symbol_sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::SymbolSDFIconShader,
UniformBlockInfo{true, true, sizeof(SymbolDrawableUBO), idSymbolDrawableUBO},
UniformBlockInfo{true, true, sizeof(SymbolTilePropsUBO), idSymbolTilePropsUBO},
UniformBlockInfo{true, false, sizeof(SymbolInterpolateUBO), idSymbolInterpolateUBO},
UniformBlockInfo{true, true, sizeof(SymbolEvaluatedPropsUBO), idSymbolEvaluatedPropsUBO},
UniformBlockInfo{false, true, sizeof(SymbolEvaluatedPropsUBO), idSymbolEvaluatedPropsUBO},
};
const std::array<AttributeInfo, 10> ShaderSource<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::Metal>::attributes =
{
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/shaders/mtl/symbol_text_and_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const std::array<UniformBlockInfo, 5>
UniformBlockInfo{true, true, sizeof(SymbolDrawableUBO), idSymbolDrawableUBO},
UniformBlockInfo{true, true, sizeof(SymbolTilePropsUBO), idSymbolTilePropsUBO},
UniformBlockInfo{true, false, sizeof(SymbolInterpolateUBO), idSymbolInterpolateUBO},
UniformBlockInfo{true, true, sizeof(SymbolEvaluatedPropsUBO), idSymbolEvaluatedPropsUBO},
UniformBlockInfo{false, true, sizeof(SymbolEvaluatedPropsUBO), idSymbolEvaluatedPropsUBO},
};
const std::array<AttributeInfo, 9>
ShaderSource<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::Metal>::attributes = {
Expand Down

0 comments on commit 84ec4f8

Please sign in to comment.