Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 15, 2024
1 parent 0fe9fee commit edcabc7
Show file tree
Hide file tree
Showing 24 changed files with 106 additions and 64 deletions.
5 changes: 4 additions & 1 deletion include/mbgl/gfx/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ class Context {
/// @param data The data to copy, may be `nullptr`
/// @param size The size of the buffer
/// @param persistent Performance hint, optimize for few or many uses
virtual UniformBufferPtr createUniformBuffer(const void* data, std::size_t size, bool persistent = false, bool ssbo = false) = 0;
virtual UniformBufferPtr createUniformBuffer(const void* data,
std::size_t size,
bool persistent = false,
bool ssbo = false) = 0;

/// Get the generic shader with the specified name
virtual gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) = 0;
Expand Down
5 changes: 4 additions & 1 deletion include/mbgl/mtl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ class Context final : public gfx::Context {
void reduceMemoryUsage() override {}

gfx::UniqueDrawableBuilder createDrawableBuilder(std::string name) override;
gfx::UniformBufferPtr createUniformBuffer(const void* data, std::size_t size, bool persistent = false, bool ssbo = false) override;
gfx::UniformBufferPtr createUniformBuffer(const void* data,
std::size_t size,
bool persistent = false,
bool ssbo = false) override;

gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;

Expand Down
5 changes: 4 additions & 1 deletion include/mbgl/vulkan/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ class Context final : public gfx::Context {
void reduceMemoryUsage() override {}

gfx::UniqueDrawableBuilder createDrawableBuilder(std::string name) override;
gfx::UniformBufferPtr createUniformBuffer(const void* data, std::size_t size, bool persistent, bool ssbo = false) override;
gfx::UniformBufferPtr createUniformBuffer(const void* data,
std::size_t size,
bool persistent,
bool ssbo = false) override;

gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;

Expand Down
5 changes: 4 additions & 1 deletion include/mbgl/vulkan/descriptor_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ class UniformDescriptorSet : public DescriptorSet {
UniformDescriptorSet(Context& context_, DescriptorSetType type_);
virtual ~UniformDescriptorSet() = default;

void update(const gfx::UniformBufferArray& uniforms, uint32_t descriptorStartIndex, uint32_t descriptorStorageCount, uint32_t descriptorUniformCount);
void update(const gfx::UniformBufferArray& uniforms,
uint32_t descriptorStartIndex,
uint32_t descriptorStorageCount,
uint32_t descriptorUniformCount);
};

class ImageDescriptorSet : public DescriptorSet {
Expand Down
5 changes: 4 additions & 1 deletion src/mbgl/gl/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,10 @@ gfx::UniqueDrawableBuilder Context::createDrawableBuilder(std::string name) {
return std::make_unique<gl::DrawableGLBuilder>(std::move(name));
}

gfx::UniformBufferPtr Context::createUniformBuffer(const void* data, std::size_t size, bool /*persistent*/, bool /*ssbo*/) {
gfx::UniformBufferPtr Context::createUniformBuffer(const void* data,
std::size_t size,
bool /*persistent*/,
bool /*ssbo*/) {
MLN_TRACE_FUNC();

return std::make_shared<gl::UniformBufferGL>(data, size, *uboAllocator);
Expand Down
5 changes: 4 additions & 1 deletion src/mbgl/gl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ class Context final : public gfx::Context {

#if MLN_DRAWABLE_RENDERER
gfx::UniqueDrawableBuilder createDrawableBuilder(std::string name) override;
gfx::UniformBufferPtr createUniformBuffer(const void* data, std::size_t size, bool persistent = false, bool ssbo = false) override;
gfx::UniformBufferPtr createUniformBuffer(const void* data,
std::size_t size,
bool persistent = false,
bool ssbo = false) override;

gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;

Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/renderer/layers/background_layer_tweaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintPara
#if MLN_UBO_CONSOLIDATION
const size_t drawableUBOVectorSize = sizeof(BackgroundDrawableUnionUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/renderer/layers/circle_layer_tweaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
#if MLN_UBO_CONSOLIDATION
const size_t drawableUBOVectorSize = sizeof(CircleDrawableUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}
Expand Down
6 changes: 4 additions & 2 deletions src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,16 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP
#if MLN_UBO_CONSOLIDATION
const size_t drawableUBOVectorSize = sizeof(FillExtrusionDrawableUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}

const size_t tilePropsUBOVectorSize = sizeof(FillExtrusionTilePropsUBO) * tilePropsUBOVector.size();
if (!tilePropsUniformBuffer || tilePropsUniformBuffer->getSize() < tilePropsUBOVectorSize) {
tilePropsUniformBuffer = context.createUniformBuffer(tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
tilePropsUniformBuffer = context.createUniformBuffer(
tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
} else {
tilePropsUniformBuffer->update(tilePropsUBOVector.data(), tilePropsUBOVectorSize);
}
Expand Down
6 changes: 4 additions & 2 deletions src/mbgl/renderer/layers/fill_layer_tweaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,16 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
#if MLN_UBO_CONSOLIDATION
const size_t drawableUBOVectorSize = sizeof(FillDrawableUnionUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}

const size_t tilePropsUBOVectorSize = sizeof(FillTilePropsUnionUBO) * tilePropsUBOVector.size();
if (!tilePropsUniformBuffer || tilePropsUniformBuffer->getSize() < tilePropsUBOVectorSize) {
tilePropsUniformBuffer = context.createUniformBuffer(tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
tilePropsUniformBuffer = context.createUniformBuffer(
tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
} else {
tilePropsUniformBuffer->update(tilePropsUBOVector.data(), tilePropsUBOVectorSize);
}
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ void HeatmapLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamet
#if MLN_UBO_CONSOLIDATION
const size_t drawableUBOVectorSize = sizeof(HeatmapDrawableUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}
Expand Down
6 changes: 4 additions & 2 deletions src/mbgl/renderer/layers/hillshade_layer_tweaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ void HillshadeLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParam
auto& context = parameters.context;
const size_t drawableUBOVectorSize = sizeof(HillshadeDrawableUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}

const size_t tilePropsUBOVectorSize = sizeof(HillshadeTilePropsUBO) * tilePropsUBOVector.size();
if (!tilePropsUniformBuffer || tilePropsUniformBuffer->getSize() < tilePropsUBOVectorSize) {
tilePropsUniformBuffer = context.createUniformBuffer(tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
tilePropsUniformBuffer = context.createUniformBuffer(
tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
} else {
tilePropsUniformBuffer->update(tilePropsUBOVector.data(), tilePropsUBOVectorSize);
}
Expand Down
6 changes: 4 additions & 2 deletions src/mbgl/renderer/layers/line_layer_tweaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,16 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
#if MLN_UBO_CONSOLIDATION
const size_t drawableUBOVectorSize = sizeof(LineDrawableUnionUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}

const size_t tilePropsUBOVectorSize = sizeof(LineTilePropsUnionUBO) * tilePropsUBOVector.size();
if (!tilePropsUniformBuffer || tilePropsUniformBuffer->getSize() < tilePropsUBOVectorSize) {
tilePropsUniformBuffer = context.createUniformBuffer(tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
tilePropsUniformBuffer = context.createUniformBuffer(
tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
} else {
tilePropsUniformBuffer->update(tilePropsUBOVector.data(), tilePropsUBOVectorSize);
}
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/renderer/layers/raster_layer_tweaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ void RasterLayerTweaker::execute([[maybe_unused]] LayerGroupBase& layerGroup,
auto& context = parameters.context;
const size_t drawableUBOVectorSize = sizeof(RasterDrawableUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}
Expand Down
6 changes: 4 additions & 2 deletions src/mbgl/renderer/layers/symbol_layer_tweaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,16 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
#if MLN_UBO_CONSOLIDATION
const size_t drawableUBOVectorSize = sizeof(SymbolDrawableUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}

const size_t tilePropsUBOVectorSize = sizeof(SymbolTilePropsUBO) * tilePropsUBOVector.size();
if (!tilePropsUniformBuffer || tilePropsUniformBuffer->getSize() < tilePropsUBOVectorSize) {
tilePropsUniformBuffer = context.createUniformBuffer(tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
tilePropsUniformBuffer = context.createUniformBuffer(
tilePropsUBOVector.data(), tilePropsUBOVectorSize, false, true);
} else {
tilePropsUniformBuffer->update(tilePropsUBOVector.data(), tilePropsUBOVectorSize);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/renderer/renderer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void Renderer::Impl::render(const RenderTree& renderTree,

// Update the debug layer groups
orchestrator.updateDebugLayerGroups(renderTree, parameters);

// Tweakers are run in the upload pass so they can set up uniforms.
parameters.currentLayer = 0;
orchestrator.visitLayerGroups([&](LayerGroupBase& layerGroup) {
Expand Down
23 changes: 12 additions & 11 deletions src/mbgl/renderer/sources/render_tile_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class PolylineLayerTweaker : public LayerTweaker {
/* .floorWidth = */ nullptr,
};
layerUniforms.createOrUpdate(idLineExpressionUBO, &exprUBO, context);

#if MLN_UBO_CONSOLIDATION
int i = 0;
std::vector<LineDrawableUnionUBO> drawableUBOVector(layerGroup.getDrawableCount());
Expand Down Expand Up @@ -140,7 +140,8 @@ class PolylineLayerTweaker : public LayerTweaker {
/* .gapwidth_t = */ 0.f,
/* .offset_t = */ 0.f,
/* .width_t = */ 0.f,
/* .pad1 = */ 0};
/* .pad1 = */ 0
};

#if MLN_UBO_CONSOLIDATION
drawable.setUBOIndex(i++);
Expand All @@ -153,7 +154,8 @@ class PolylineLayerTweaker : public LayerTweaker {
#if MLN_UBO_CONSOLIDATION
const size_t drawableUBOVectorSize = sizeof(LineDrawableUnionUBO) * drawableUBOVector.size();
if (!drawableUniformBuffer || drawableUniformBuffer->getSize() < drawableUBOVectorSize) {
drawableUniformBuffer = context.createUniformBuffer(drawableUBOVector.data(), drawableUBOVectorSize, false, true);
drawableUniformBuffer = context.createUniformBuffer(
drawableUBOVector.data(), drawableUBOVectorSize, false, true);
} else {
drawableUniformBuffer->update(drawableUBOVector.data(), drawableUBOVectorSize);
}
Expand Down Expand Up @@ -336,7 +338,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
drawable->setTileID(tile.getOverscaledTileID());
tileLayerGroup->addDrawable(renderPass, tile.getOverscaledTileID(), std::move(drawable));
}

if (!layerTweaker) {
layerTweaker = std::make_shared<PolylineLayerTweaker>(linePropertiesUBO);
tileLayerGroup->addLayerTweaker(layerTweaker);
Expand Down Expand Up @@ -428,13 +430,12 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
addPolylineDrawable(tileLayerGroup, tile);
}
#else
const DebugUBO debugUBO = {
/* .matrix = */ util::cast<float>(tile.matrix),
/* .color = */ Color::red(),
/* .overlay_scale = */ 1.0f,
/* .pad1 = */ 0,
/* .pad2 = */ 0,
/* .pad3 = */ 0};
const DebugUBO debugUBO = {/* .matrix = */ util::cast<float>(tile.matrix),
/* .color = */ Color::red(),
/* .overlay_scale = */ 1.0f,
/* .pad1 = */ 0,
/* .pad2 = */ 0,
/* .pad3 = */ 0};

if (0 == updateDrawables(tileLayerGroup, tileID, debugUBO) && tile.getNeedsRendering()) {
addDrawable(tileLayerGroup,
Expand Down
20 changes: 9 additions & 11 deletions src/mbgl/style/layers/custom_drawable_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class LineDrawableTweaker : public gfx::DrawableTweaker {
#endif
/* .matrix = */ util::cast<float>(matrix),
/* .ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),

/* .color_t = */ 0.f,
/* .blur_t = */ 0.f,
/* .opacity_t = */ 0.f,
Expand All @@ -131,7 +131,7 @@ class LineDrawableTweaker : public gfx::DrawableTweaker {

// We would need to set up `idLineExpressionUBO` if the expression mask isn't empty
assert(propsUBO.expressionMask == LineExpressionMask::None);

const LineExpressionUBO exprUBO = {
/* .color = */ nullptr,
/* .blur = */ nullptr,
Expand Down Expand Up @@ -241,21 +241,19 @@ class FillDrawableTweaker : public gfx::DrawableTweaker {
const shaders::FillDrawableUBO drawableUBO = {
#endif
/* .matrix = */ util::cast<float>(matrix),

/* .color_t = */ 0.f,
/* .opacity_t = */ 0.f,
/* .pad1 = */ 0,
/* .pad2 = */ 0
};

const shaders::FillEvaluatedPropsUBO propsUBO = {
/* .color = */ color,
/* .outline_color = */ Color::white(),
/* .opacity = */ opacity,
/* .fade = */ 0.f,
/* .from_scale = */ 0.f,
/* .to_scale = */ 0.f
};
const shaders::FillEvaluatedPropsUBO propsUBO = {/* .color = */ color,
/* .outline_color = */ Color::white(),
/* .opacity = */ opacity,
/* .fade = */ 0.f,
/* .from_scale = */ 0.f,
/* .to_scale = */ 0.f};
auto& drawableUniforms = drawable.mutableUniformBuffers();
drawableUniforms.createOrUpdate(idFillDrawableUBO, &drawableUBO, parameters.context);
drawableUniforms.createOrUpdate(idFillEvaluatedPropsUBO, &propsUBO, parameters.context);
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/vulkan/buffer_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BufferResource::BufferResource(
const auto& align = deviceProps.limits.minUniformBufferOffsetAlignment;
bufferWindowSize = (size + align - 1) & ~(align - 1);

//assert(bufferWindowSize != 0);
// assert(bufferWindowSize != 0);

totalSize = bufferWindowSize * backend.getMaxFrames();
}
Expand Down
Loading

0 comments on commit edcabc7

Please sign in to comment.