diff --git a/CMakeLists.txt b/CMakeLists.txt index f36cb26dc..d6bb697b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1437,21 +1437,11 @@ include(${PROJECT_SOURCE_DIR}/vendor/polylabel.cmake) include(${PROJECT_SOURCE_DIR}/vendor/protozero.cmake) include(${PROJECT_SOURCE_DIR}/vendor/tracy.cmake) include(${PROJECT_SOURCE_DIR}/vendor/unique_resource.cmake) +include(${PROJECT_SOURCE_DIR}/vendor/unordered_dense.cmake) include(${PROJECT_SOURCE_DIR}/vendor/vector-tile.cmake) include(${PROJECT_SOURCE_DIR}/vendor/wagyu.cmake) include(${PROJECT_SOURCE_DIR}/vendor/metal-cpp.cmake) - -add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/unordered_dense) -set_target_properties( - unordered_dense - PROPERTIES - INTERFACE_MAPBOX_NAME "unordered_dense" - INTERFACE_MAPBOX_URL "https://github.com/martinus/unordered_dense" - INTERFACE_MAPBOX_AUTHOR "Martin Leitner-Ankerl" - INTERFACE_MAPBOX_LICENSE ${PROJECT_SOURCE_DIR}/vendor/unordered_dense/LICENSE -) - target_link_libraries( mbgl-core PRIVATE diff --git a/include/mbgl/actor/established_actor.hpp b/include/mbgl/actor/established_actor.hpp index 6cfa755f3..1e948e3b5 100644 --- a/include/mbgl/actor/established_actor.hpp +++ b/include/mbgl/actor/established_actor.hpp @@ -29,11 +29,9 @@ template class EstablishedActor { public: // Construct the Object from a parameter pack `args` (i.e. `Object(args...)`) - template || - std::is_constructible_v, Args...>>* = nullptr> + template EstablishedActor(Scheduler& scheduler, AspiringActor& parent_, Args&&... args) + requires(std::is_constructible_v || std::is_constructible_v, Args...>) : parent(parent_) { emplaceObject(std::forward(args)...); parent.mailbox->open(scheduler); diff --git a/include/mbgl/gfx/context.hpp b/include/mbgl/gfx/context.hpp index 652deb3cb..a27c9fd88 100644 --- a/include/mbgl/gfx/context.hpp +++ b/include/mbgl/gfx/context.hpp @@ -148,9 +148,9 @@ public: /// `emplaceOrUpdateUniformBuffer` with type inference template - std::enable_if_t, bool> emplaceOrUpdateUniformBuffer(gfx::UniformBufferPtr& ptr, - const T* data, - bool persistent = false) { + bool emplaceOrUpdateUniformBuffer(gfx::UniformBufferPtr& ptr, const T* data, bool persistent = false) + requires(!std::is_pointer_v) + { return emplaceOrUpdateUniformBuffer(ptr, data, sizeof(T), persistent); } diff --git a/include/mbgl/gfx/shader.hpp b/include/mbgl/gfx/shader.hpp index fe63787b0..3aa28e7f7 100644 --- a/include/mbgl/gfx/shader.hpp +++ b/include/mbgl/gfx/shader.hpp @@ -33,8 +33,10 @@ public: /// @brief Downcast to a type /// @tparam T Derived type /// @return Type or nullptr if type info was not a match - template , bool>* = nullptr> - T* to() noexcept { + template + T* to() noexcept + requires(is_shader_v) + { if (typeName() != T::Name) { return nullptr; } diff --git a/include/mbgl/gfx/shader_group.hpp b/include/mbgl/gfx/shader_group.hpp index 89fc2cfc3..26ba0082e 100644 --- a/include/mbgl/gfx/shader_group.hpp +++ b/include/mbgl/gfx/shader_group.hpp @@ -93,8 +93,10 @@ public: /// This variant looks up shaders only by type name. /// @tparam T Derived type, inheriting `gfx::Shader` /// @return T or nullptr if not found in the group - template , bool>* = nullptr> - std::shared_ptr get() noexcept { + template + std::shared_ptr get() noexcept + requires(is_shader_v) + { auto shader = getShader(std::string(T::Name)); if (!shader || shader->typeName() != T::Name) { return nullptr; diff --git a/include/mbgl/gfx/uniform_buffer.hpp b/include/mbgl/gfx/uniform_buffer.hpp index 5ae273563..1aecd064b 100644 --- a/include/mbgl/gfx/uniform_buffer.hpp +++ b/include/mbgl/gfx/uniform_buffer.hpp @@ -64,10 +64,9 @@ public: void createOrUpdate(const size_t id, const std::vector& data, gfx::Context&, bool persistent = false); void createOrUpdate(const size_t id, const void* data, std::size_t size, gfx::Context&, bool persistent = false); template - std::enable_if_t> createOrUpdate(const size_t id, - const T* data, - gfx::Context& context, - bool persistent = false) { + void createOrUpdate(const size_t id, const T* data, gfx::Context& context, bool persistent = false) + requires(!std::is_pointer_v) + { createOrUpdate(id, data, sizeof(T), context, persistent); } diff --git a/include/mbgl/gfx/vertex_attribute.hpp b/include/mbgl/gfx/vertex_attribute.hpp index fefb7f624..7733eda1c 100644 --- a/include/mbgl/gfx/vertex_attribute.hpp +++ b/include/mbgl/gfx/vertex_attribute.hpp @@ -191,12 +191,12 @@ public: } template - inline typename std::enable_if::type set(std::size_t, std::tuple, std::size_t) {} + inline typename std::enable_if_t set(std::size_t, std::tuple, std::size_t) {} /// Set item value template - inline typename std::enable_if < - I::type set(std::size_t i, std::tuple tuple, std::size_t tupleIndex) { + inline typename std::enable_if_t < + I set(std::size_t i, std::tuple tuple, std::size_t tupleIndex) { if (tupleIndex == 0) { set(i, std::get(tuple).a1); } else { diff --git a/include/mbgl/math/minmax.hpp b/include/mbgl/math/minmax.hpp index da6ba2096..a60c25dff 100644 --- a/include/mbgl/math/minmax.hpp +++ b/include/mbgl/math/minmax.hpp @@ -8,32 +8,44 @@ namespace mbgl { namespace util { template -typename std::enable_if_t, T> max(T a, T b) { +T max(T a, T b) + requires(std::is_integral_v) +{ return std::max(a, b); } template -typename std::enable_if_t, T> max(T a, T b) { +T max(T a, T b) + requires(std::is_floating_point_v) +{ return ::fmax(a, b); } template -typename std::enable_if_t, T> max(T a, T b, Ts... args) { +T max(T a, T b, Ts... args) + requires(std::is_arithmetic_v) +{ return max(a, max(b, args...)); } template -typename std::enable_if_t, T> min(T a, T b) { +T min(T a, T b) + requires(std::is_integral_v) +{ return std::min(a, b); } template -typename std::enable_if_t, T> min(T a, T b) { +T min(T a, T b) + requires(std::is_floating_point_v) +{ return ::fmin(a, b); } template -typename std::enable_if_t, T> min(T a, T b, Ts... args) { +T min(T a, T b, Ts... args) + requires(std::is_arithmetic_v) +{ return min(a, min(b, args...)); } diff --git a/include/mbgl/style/expression/expression.hpp b/include/mbgl/style/expression/expression.hpp index 3ff25e720..3c8616e82 100644 --- a/include/mbgl/style/expression/expression.hpp +++ b/include/mbgl/style/expression/expression.hpp @@ -282,9 +282,11 @@ protected: return *lhs == *rhs; } - template >> + template static bool childEqual(const std::pair>& lhs, - const std::pair>& rhs) noexcept { + const std::pair>& rhs) noexcept + requires(std::is_scalar_v) + { return lhs.first == rhs.first && *(lhs.second) == *(rhs.second); } @@ -294,9 +296,11 @@ protected: return lhs.first == rhs.first && *(lhs.second) == *(rhs.second); } - template >> + template static bool childEqual(const std::pair>& lhs, - const std::pair>& rhs) noexcept { + const std::pair>& rhs) noexcept + requires(!std::is_scalar_v) + { #if __clang_major__ > 16 // On older compilers, this assignment doesn't do overload resolution // in the same way that `lhs==rhs` does and produces ambiguity errors. diff --git a/include/mbgl/style/expression/format_section_override.hpp b/include/mbgl/style/expression/format_section_override.hpp index abdc042cd..0d9847d80 100644 --- a/include/mbgl/style/expression/format_section_override.hpp +++ b/include/mbgl/style/expression/format_section_override.hpp @@ -35,7 +35,7 @@ public: defaultValue.match([&fn](const style::PropertyExpression& e) { fn(e.getExpression()); }, [](const T&) {}); } - bool operator==(const Expression& e) const final override { + bool operator==(const Expression& e) const final { if (e.getKind() == Kind::FormatSectionOverride) { const auto* other = static_cast(&e); diff --git a/include/mbgl/style/property_expression.hpp b/include/mbgl/style/property_expression.hpp index f645442d0..d91f1c6da 100644 --- a/include/mbgl/style/property_expression.hpp +++ b/include/mbgl/style/property_expression.hpp @@ -90,7 +90,9 @@ public: const expression::EvaluationResult result = expression->evaluate(context); if (result) { const std::optional typed = expression::fromExpressionValue(*result); - return typed ? *typed : defaultValue ? *defaultValue : finalDefaultValue; + if (typed) { + return *typed; + } } return defaultValue ? *defaultValue : finalDefaultValue; } diff --git a/include/mbgl/util/bitmask_operations.hpp b/include/mbgl/util/bitmask_operations.hpp index e2c64de8d..322b2851d 100644 --- a/include/mbgl/util/bitmask_operations.hpp +++ b/include/mbgl/util/bitmask_operations.hpp @@ -7,25 +7,25 @@ namespace mbgl { template constexpr Enum operator|(Enum a, Enum b) { - static_assert(std::is_enum::value, "Enum must be an enum type"); + static_assert(std::is_enum_v, "Enum must be an enum type"); return Enum(mbgl::underlying_type(a) | mbgl::underlying_type(b)); } template constexpr Enum& operator|=(Enum& a, Enum b) { - static_assert(std::is_enum::value, "Enum must be an enum type"); + static_assert(std::is_enum_v, "Enum must be an enum type"); return (a = a | b); } template constexpr bool operator&(Enum a, Enum b) { - static_assert(std::is_enum::value, "Enum must be an enum type"); + static_assert(std::is_enum_v, "Enum must be an enum type"); return bool(mbgl::underlying_type(a) & mbgl::underlying_type(b)); } template constexpr Enum operator~(Enum value) { - static_assert(std::is_enum::value, "Enum must be an enum type"); + static_assert(std::is_enum_v, "Enum must be an enum type"); return Enum(~mbgl::underlying_type(value)); } diff --git a/include/mbgl/util/chrono.hpp b/include/mbgl/util/chrono.hpp index 77dd49bb1..de4f7d7d5 100644 --- a/include/mbgl/util/chrono.hpp +++ b/include/mbgl/util/chrono.hpp @@ -46,11 +46,10 @@ _NODISCARD constexpr std::chrono::duration<_Rep, _Period> abs(const std::chrono: : _Dur; } #else -template < - class Rep, - class Period, - class = std::enable_if_t::min() < std::chrono::duration::zero()>> -constexpr std::chrono::duration abs(std::chrono::duration d) { +template +constexpr std::chrono::duration abs(std::chrono::duration d) + requires(std::chrono::duration::min() < std::chrono::duration::zero()) +{ return d >= d.zero() ? d : -d; } #endif diff --git a/include/mbgl/util/convert.hpp b/include/mbgl/util/convert.hpp index 3536cb8ec..fce64f952 100644 --- a/include/mbgl/util/convert.hpp +++ b/include/mbgl/util/convert.hpp @@ -11,15 +11,19 @@ namespace mbgl { namespace util { -template >> -constexpr std::array convert(const std::array& from) { +template +constexpr std::array convert(const std::array& from) + requires(std::is_convertible_v) +{ std::array to{{}}; std::copy(std::begin(from), std::end(from), std::begin(to)); return to; } -template >> -constexpr std::array cast(const std::array& from) { +template +constexpr std::array cast(const std::array& from) + requires(std::is_assignable_v) +{ std::array to{{}}; std::transform(std::begin(from), std::end(from), std::begin(to), [](From x) { return static_cast(x); }); return to; diff --git a/include/mbgl/util/size.hpp b/include/mbgl/util/size.hpp index 13777ebe7..ef833fab9 100644 --- a/include/mbgl/util/size.hpp +++ b/include/mbgl/util/size.hpp @@ -22,11 +22,11 @@ public: uint32_t height = 0; }; -constexpr inline bool operator==(const Size& a, const Size& b) noexcept { +constexpr bool operator==(const Size& a, const Size& b) noexcept { return a.width == b.width && a.height == b.height; } -constexpr inline bool operator!=(const Size& a, const Size& b) noexcept { +constexpr bool operator!=(const Size& a, const Size& b) noexcept { return !(a == b); } diff --git a/include/mbgl/util/traits.hpp b/include/mbgl/util/traits.hpp index b0fda1566..a2b587758 100644 --- a/include/mbgl/util/traits.hpp +++ b/include/mbgl/util/traits.hpp @@ -25,13 +25,12 @@ struct is_utf16char_like : std::true_type {}; template using is_utf16char_like_pointer = - std::integral_constant && is_utf16char_like::type>::value>; + std::integral_constant && is_utf16char_like>::value>; template -typename std::enable_if::value && is_utf16char_like_pointer::value, - OutPointer>::type -utf16char_cast(InChar *in) { +OutPointer utf16char_cast(InChar *in) + requires(is_utf16char_like::value && is_utf16char_like_pointer::value) +{ return reinterpret_cast(in); } diff --git a/src/mbgl/actor/mailbox.cpp b/src/mbgl/actor/mailbox.cpp index 63ee6aa06..6c5a7dfb4 100644 --- a/src/mbgl/actor/mailbox.cpp +++ b/src/mbgl/actor/mailbox.cpp @@ -20,7 +20,7 @@ Mailbox::Mailbox(const TaggedScheduler& scheduler_) void Mailbox::open(const TaggedScheduler& scheduler_) { assert(!weakScheduler); schedulerTag = scheduler_.tag; - return open(*scheduler_.get()); + open(*scheduler_.get()); } void Mailbox::open(Scheduler& scheduler_) { diff --git a/src/mbgl/actor/scheduler.cpp b/src/mbgl/actor/scheduler.cpp index 9eea6fcd3..f2f70bd79 100644 --- a/src/mbgl/actor/scheduler.cpp +++ b/src/mbgl/actor/scheduler.cpp @@ -13,10 +13,12 @@ std::function Scheduler::bindOnce(std::function fn) { }; } -static auto& current() { +namespace { +auto& current() { static util::ThreadLocal scheduler; return scheduler; } +} // namespace void Scheduler::SetCurrent(Scheduler* scheduler) { current().set(scheduler); diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 31f088907..7fc948dd1 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -234,12 +234,16 @@ void AnnotationManager::removeTile(AnnotationTile& tile) { tiles.erase(&tile); } +namespace { + // To ensure that annotation images do not collide with images from the style, // we prefix input image IDs with "org.maplibre.annotations". -static std::string prefixedImageID(const std::string& id) { +std::string prefixedImageID(const std::string& id) { return AnnotationManager::SourceID + "." + id; } +} // namespace + void AnnotationManager::addImage(std::unique_ptr image) { CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); std::lock_guard lock(mutex); diff --git a/src/mbgl/gfx/vertex_vector.hpp b/src/mbgl/gfx/vertex_vector.hpp index 9fedaadc5..abce21736 100644 --- a/src/mbgl/gfx/vertex_vector.hpp +++ b/src/mbgl/gfx/vertex_vector.hpp @@ -70,7 +70,7 @@ public: : VertexVectorBase(other), v(other.v) {} VertexVector(VertexVector&& other) - : VertexVectorBase(std::move(other)), + : VertexVectorBase(static_cast(other)), v(std::move(other.v)) {} ~VertexVector() override = default; diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp index 024479566..f07ff37b9 100644 --- a/src/mbgl/layout/symbol_instance.cpp +++ b/src/mbgl/layout/symbol_instance.cpp @@ -193,15 +193,15 @@ const std::optional& SymbolInstance::iconQuads() const { } bool SymbolInstance::hasText() const { - return static_cast(symbolContent & SymbolContent::Text); + return symbolContent & SymbolContent::Text; } bool SymbolInstance::hasIcon() const { - return static_cast(symbolContent & SymbolContent::IconRGBA) || hasSdfIcon(); + return symbolContent & SymbolContent::IconRGBA || hasSdfIcon(); } bool SymbolInstance::hasSdfIcon() const { - return static_cast(symbolContent & SymbolContent::IconSDF); + return symbolContent & SymbolContent::IconSDF; } const std::optional& SymbolInstance::verticalIconQuads() const { diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index bee82a066..5366bd658 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -266,8 +266,7 @@ std::array evaluateRadialOffset(style::SymbolAnchorType anchor, float std::array result{{0.0f, 0.0f}}; if (radialOffset < 0.0f) radialOffset = 0.0f; // Ignore negative offset. // solve for r where r^2 + r^2 = radialOffset^2 - const float sqrt2 = 1.41421356237f; - const float hypotenuse = radialOffset / sqrt2; + const float hypotenuse = radialOffset / std::numbers::sqrt2_v; switch (anchor) { case SymbolAnchorType::TopRight: diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index d4e05534b..9bad545b1 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -314,7 +314,7 @@ void Map::setBounds(const BoundOptions& options) { impl->transform.setMinZoom(*options.minZoom); if (impl->transform.getZoom() < *options.minZoom) { changeCamera = true; - cameraOptions.withZoom(*options.minZoom); + cameraOptions.withZoom(options.minZoom); } } @@ -322,7 +322,7 @@ void Map::setBounds(const BoundOptions& options) { impl->transform.setMaxZoom(*options.maxZoom); if (impl->transform.getZoom() > *options.maxZoom) { changeCamera = true; - cameraOptions.withZoom(*options.maxZoom); + cameraOptions.withZoom(options.maxZoom); } } @@ -330,7 +330,7 @@ void Map::setBounds(const BoundOptions& options) { impl->transform.setMaxPitch(*options.maxPitch); if (impl->transform.getPitch() > impl->transform.getState().getMaxPitch()) { changeCamera = true; - cameraOptions.withPitch(*options.maxPitch); + cameraOptions.withPitch(options.maxPitch); } } @@ -338,7 +338,7 @@ void Map::setBounds(const BoundOptions& options) { impl->transform.setMinPitch(*options.minPitch); if (impl->transform.getPitch() < impl->transform.getState().getMinPitch()) { changeCamera = true; - cameraOptions.withPitch(*options.minPitch); + cameraOptions.withPitch(options.minPitch); } } diff --git a/src/mbgl/mtl/context.cpp b/src/mbgl/mtl/context.cpp index bccf388a4..1d79df551 100644 --- a/src/mbgl/mtl/context.cpp +++ b/src/mbgl/mtl/context.cpp @@ -240,7 +240,6 @@ const BufferResource& Context::getEmptyBuffer() { const BufferResource& Context::getTileVertexBuffer() { if (!tileVertexBuffer) { const auto vertices = RenderStaticData::tileVertices(); - constexpr auto vertexSize = sizeof(decltype(vertices)::Vertex::a1); tileVertexBuffer.emplace(createBuffer(vertices.data(), vertices.bytes(), gfx::BufferUsageType::StaticDraw, diff --git a/src/mbgl/mtl/drawable.cpp b/src/mbgl/mtl/drawable.cpp index d139f023c..17f04cfe9 100644 --- a/src/mbgl/mtl/drawable.cpp +++ b/src/mbgl/mtl/drawable.cpp @@ -364,7 +364,6 @@ void Drawable::bindAttributes(RenderPass& renderPass) const noexcept { assert(binding->vertexStride * impl->vertexCount <= getBufferSize(binding->vertexBufferResource)); renderPass.bindVertex(buffer->get(), /*offset=*/0, attributeIndex); } else { - const auto* shaderMTL = static_cast(shader.get()); auto& context = renderPass.getCommandEncoder().getContext(); renderPass.bindVertex(context.getEmptyBuffer(), /*offset=*/0, attributeIndex); } @@ -382,7 +381,6 @@ void Drawable::bindInstanceAttributes(RenderPass& renderPass) const noexcept { if (buffer && buffer->get()) { renderPass.bindVertex(buffer->get(), /*offset=*/0, attributeIndex); } else { - const auto* shaderMTL = static_cast(shader.get()); auto& context = renderPass.getCommandEncoder().getContext(); renderPass.bindVertex(context.getEmptyBuffer(), /*offset=*/0, attributeIndex); } diff --git a/src/mbgl/mtl/renderer_backend.cpp b/src/mbgl/mtl/renderer_backend.cpp index 8579ef076..dbeba9674 100644 --- a/src/mbgl/mtl/renderer_backend.cpp +++ b/src/mbgl/mtl/renderer_backend.cpp @@ -61,47 +61,23 @@ std::unique_ptr RendererBackend::createContext() { PremultipliedImage RendererBackend::readFramebuffer(const Size& size) { return PremultipliedImage(size); - // return getContext().readFramebuffer(size); } -void RendererBackend::assumeFramebufferBinding(const mtl::FramebufferID fbo) { - /*getContext().bindFramebuffer.setCurrentValue(fbo); - if (fbo != ImplicitFramebufferBinding) { - assert(mtl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); - }*/ -} +void RendererBackend::assumeFramebufferBinding(const mtl::FramebufferID fbo) {} -void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) { - /*getContext().viewport.setCurrentValue({x, y, size}); - assert(mtl::value::Viewport::Get() == getContext().viewport.getCurrentValue());*/ -} +void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) {} -void RendererBackend::assumeScissorTest(bool enabled) { - /*getContext().scissorTest.setCurrentValue(enabled); - assert(mtl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue());*/ -} +void RendererBackend::assumeScissorTest(bool enabled) {} bool RendererBackend::implicitFramebufferBound() { return false; - // return getContext().bindFramebuffer.getCurrentValue() == ImplicitFramebufferBinding; } -void RendererBackend::setFramebufferBinding(const mtl::FramebufferID fbo) { - /*getContext().bindFramebuffer = fbo; - if (fbo != ImplicitFramebufferBinding) { - assert(mtl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); - }*/ -} +void RendererBackend::setFramebufferBinding(const mtl::FramebufferID fbo) {} -void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) { - /*getContext().viewport = {x, y, size}; - assert(mtl::value::Viewport::Get() == getContext().viewport.getCurrentValue());*/ -} +void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) {} -void RendererBackend::setScissorTest(bool enabled) { - /*getContext().scissorTest = enabled; - assert(mtl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue());*/ -} +void RendererBackend::setScissorTest(bool enabled) {} /// @brief Register a list of types with a shader registry instance /// @tparam ...ShaderID Pack of BuiltIn:: shader IDs diff --git a/src/mbgl/renderer/layer_group.cpp b/src/mbgl/renderer/layer_group.cpp index 49e869fc2..c657274b7 100644 --- a/src/mbgl/renderer/layer_group.cpp +++ b/src/mbgl/renderer/layer_group.cpp @@ -1,6 +1,5 @@ #include -#include #include #include #include diff --git a/src/mbgl/renderer/layer_tweaker.cpp b/src/mbgl/renderer/layer_tweaker.cpp index 2c1b7701d..2f6a5a686 100644 --- a/src/mbgl/renderer/layer_tweaker.cpp +++ b/src/mbgl/renderer/layer_tweaker.cpp @@ -9,7 +9,6 @@ #include #if MLN_RENDER_BACKEND_METAL -#include #include #include #endif // MLN_RENDER_BACKEND_METAL diff --git a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp index 6c6642147..4ea3b4f38 100644 --- a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp @@ -16,10 +16,6 @@ #include #include -#if MLN_RENDER_BACKEND_METAL -#include -#endif - namespace mbgl { using namespace style; diff --git a/src/mbgl/renderer/layers/line_layer_tweaker.cpp b/src/mbgl/renderer/layers/line_layer_tweaker.cpp index a42671112..f73f2c340 100644 --- a/src/mbgl/renderer/layers/line_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/line_layer_tweaker.cpp @@ -35,9 +35,10 @@ constexpr bool diff(Color actual, Color expected, float e = 1.0e-6) { #if MLN_RENDER_BACKEND_METAL && !defined(NDEBUG) template -std::optional LineLayerTweaker::gpuEvaluate(const LinePaintProperties::PossiblyEvaluated& evaluated, - const PaintParameters& parameters, - const std::size_t index) const { +std::optional LineLayerTweaker::gpuEvaluate( + [[maybe_unused]] const LinePaintProperties::PossiblyEvaluated& evaluated, + const PaintParameters& parameters, + const std::size_t index) const { if (const auto& gpu = gpuExpressions[index]) { const float effectiveZoom = (gpu->options & gfx::GPUOptions::IntegerZoom) ? parameters.state.getIntegerZoom() diff --git a/src/mbgl/renderer/layers/raster_layer_tweaker.cpp b/src/mbgl/renderer/layers/raster_layer_tweaker.cpp index 78f83955c..42db54bd6 100644 --- a/src/mbgl/renderer/layers/raster_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/raster_layer_tweaker.cpp @@ -24,8 +24,10 @@ void RasterLayerTweaker::execute([[maybe_unused]] LayerGroupBase& layerGroup, spin = util::deg2radf(spin); const float s = std::sin(spin); const float c = std::cos(spin); - std::array spin_weights = { - {(2 * c + 1) / 3, (-std::sqrt(3.0f) * s - c + 1) / 3, (std::sqrt(3.0f) * s - c + 1) / 3, 0}}; + std::array spin_weights = {{(2 * c + 1) / 3, + (-std::numbers::sqrt3_v * s - c + 1) / 3, + (std::numbers::sqrt3_v * s - c + 1) / 3, + 0}}; return spin_weights; }; const auto saturationFactor = [](float saturation) -> float { diff --git a/src/mbgl/renderer/tile_layer_group.cpp b/src/mbgl/renderer/tile_layer_group.cpp index ea0a607e8..303a14774 100644 --- a/src/mbgl/renderer/tile_layer_group.cpp +++ b/src/mbgl/renderer/tile_layer_group.cpp @@ -1,8 +1,6 @@ #include #include -#include -#include #include #include diff --git a/src/mbgl/util/hash.hpp b/src/mbgl/util/hash.hpp index 94d7344ec..72e4b41d1 100644 --- a/src/mbgl/util/hash.hpp +++ b/src/mbgl/util/hash.hpp @@ -22,7 +22,7 @@ std::size_t hash(Args&&... args) noexcept { namespace detail { template -using TIterVal = std::enable_if_t::value, typename TIter::value_type>; +using TIterVal = std::enable_if_t, typename TIter::value_type>; } // namespace detail template diff --git a/src/mbgl/util/mat3.hpp b/src/mbgl/util/mat3.hpp index 893a8f635..6c1a9b5f6 100644 --- a/src/mbgl/util/mat3.hpp +++ b/src/mbgl/util/mat3.hpp @@ -32,15 +32,15 @@ namespace mbgl { using mat3 = std::array; -constexpr inline vec3 vec3Cross(const vec3& a, const vec3& b) noexcept { +constexpr vec3 vec3Cross(const vec3& a, const vec3& b) noexcept { return vec3{{a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]}}; } -constexpr inline double vec3Dot(const vec3& a, const vec3& b) noexcept { +constexpr double vec3Dot(const vec3& a, const vec3& b) noexcept { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } -constexpr inline double vec3LengthSq(const vec3& a) noexcept { +constexpr double vec3LengthSq(const vec3& a) noexcept { return vec3Dot(a, a); } @@ -48,7 +48,7 @@ inline double vec3Length(const vec3& a) noexcept { return std::sqrt(vec3LengthSq(a)); } -constexpr inline vec3 vec3Scale(const vec3& a, double s) noexcept { +constexpr vec3 vec3Scale(const vec3& a, double s) noexcept { return vec3{{a[0] * s, a[1] * s, a[2] * s}}; } @@ -58,7 +58,7 @@ inline vec3 vec3Normalize(const vec3& a) noexcept { return vec3Scale(a, 1.0 / length); } -constexpr inline vec3 vec3Sub(const vec3& a, const vec3& b) noexcept { +constexpr vec3 vec3Sub(const vec3& a, const vec3& b) noexcept { return vec3{{a[0] - b[0], a[1] - b[1], a[2] - b[2]}}; } diff --git a/test/text/get_anchors.test.cpp b/test/text/get_anchors.test.cpp index 063ec58d9..625a3e10a 100644 --- a/test/text/get_anchors.test.cpp +++ b/test/text/get_anchors.test.cpp @@ -8,7 +8,7 @@ using namespace mbgl; using namespace std::numbers; namespace mbgl { -constexpr inline bool operator==(const Anchor& rhs, const Anchor& lhs) { +constexpr bool operator==(const Anchor& rhs, const Anchor& lhs) { return rhs.point == lhs.point && rhs.angle == lhs.angle && rhs.segment == lhs.segment; } } // namespace mbgl diff --git a/vendor/unordered_dense.cmake b/vendor/unordered_dense.cmake new file mode 100644 index 000000000..a393c0dbe --- /dev/null +++ b/vendor/unordered_dense.cmake @@ -0,0 +1,14 @@ +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25") + add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/unordered_dense SYSTEM) +else() + add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/unordered_dense) +endif() + +set_target_properties( + unordered_dense + PROPERTIES + INTERFACE_MAPBOX_NAME "unordered_dense" + INTERFACE_MAPBOX_URL "https://github.com/martinus/unordered_dense" + INTERFACE_MAPBOX_AUTHOR "Martin Leitner-Ankerl" + INTERFACE_MAPBOX_LICENSE ${PROJECT_SOURCE_DIR}/vendor/unordered_dense/LICENSE +) \ No newline at end of file diff --git a/vendor/vulkan.cmake b/vendor/vulkan.cmake index 59859b5f8..81a275a19 100644 --- a/vendor/vulkan.cmake +++ b/vendor/vulkan.cmake @@ -35,7 +35,12 @@ set(ENABLE_HLSL OFF) set(ENABLE_GLSLANG_BINARIES OFF) set(GLSLANG_TESTS_DEFAULT OFF) set(ENABLE_PCH OFF) -add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/glslang SYSTEM) + +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25") + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/glslang SYSTEM) +else() + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/glslang) +endif() get_target_property(glslang_inc glslang INTERFACE_INCLUDE_DIRECTORIES) set_target_properties(glslang PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${glslang_inc})