maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.03k stars 299 forks source link

Vulkan renderer backend #2564

Closed adrian-cojocaru closed 2 months ago

adrian-cojocaru commented 3 months ago

Rough implementation of a Vulkan renderer backend (tested on Windows).

image

Notes:

List of working shaders (and associated functionality):

github-actions[bot] commented 3 months ago

Bloaty Results (iOS) šŸ‹

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0% +1.27Ki  [ = ]       0    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results-ios/pr-2564-compared-to-main.txt

github-actions[bot] commented 3 months ago

Bloaty Results šŸ‹

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0% +20.7Ki  +0.0% +3.88Ki    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-2564-compared-to-main.txt

Compared to d38709084a9865fe0bb8300aec70ebf8243b3d43 (legacy)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +21% +24.7Mi  +411% +24.6Mi    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-2564-compared-to-legacy.txt

github-actions[bot] commented 3 months ago

Benchmark Results āš”

Benchmark                                                     Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------
OVERALL_GEOMEAN                                            +0.0019         +0.0017             0             0             0             0

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/benchmark-results/pr-2564-compared-to-main.txt

louwers commented 2 months ago

As discussed, let's not add any tests to CI yet for the Vulkan backend, but make sure it builds for Linux on CI.

@adrian-cojocaru If you can share some build instructions I am happy to add it to linux-ci.yml.

adrian-cojocaru commented 2 months ago

Windows: cmake -B build -G "Visual Studio 17 2022" DCMAKE_BUILD_TYPE=RelWithDebInfo -DMLN_DRAWABLE_RENDERER=ON -DMLN_LEGACY_RENDERER=OFF -DMLN_WITH_VULKAN=ON -DMLN_WITH_OPENGL=OFF

Linux: cmake -B build -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMLN_DRAWABLE_RENDERER=ON -DMLN_LEGACY_RENDERER=OFF -DMLN_WITH_VULKAN=ON -DMLN_WITH_OPENGL=OFF

Tested for mbgl-glfw, mbgl-render and mbgl-render-test-runner

jwinarske commented 2 months ago

Fails to build with clang 10 and gcc 9.4. This is a lowest common denominator build config for us.

Clang 10
CXX=/usr/bin/clang++ CC=/usr/bin/clang cmake .. -GNinja -DMMLN_WITH_X11=OFF -DMLN_WITH_WAYLAND=ON -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DMLN_DRAWABLE_RENDERER=ON -DMLN_LEGACY_RENDERER=OFF -DMLN_WITH_VULKAN=ON -DMLN_WITH_OPENGL=OFF

configure_log.txt build_log.txt

GCC 9.4
cmake .. -GNinja -DMMLN_WITH_X11=OFF -DMLN_WITH_WAYLAND=ON -DMLN_DRAWABLE_RENDERER=ON -DMLN_LEGACY_RENDERER=OFF -DMLN_WITH_VULKAN=ON -DMLN_WITH_OPENGL=OFF

gcc_build_log.txt gcc_configure_log.txt

louwers commented 2 months ago

@jwinarske The same errors show up on the CI build, so they will be addressed.

jwinarske commented 2 months ago

Has anyone ran this with molten-vk? Curious what the Delta with metal is.

adrian-cojocaru commented 2 months ago

@mwilsnd The OOM when allocating descriptor sets is a limitation at the moment. This will be fixed in a future PR with an abstraction layer for descriptors and resizable descriptor pools. This will also fully implement RenderPass::bindVertex / RenderPass::bindFragment functions and their calls. I think I found a similar issue on Android with flickering symbols with long/smooth camera movements. Seems to be sync related

jwinarske commented 2 months ago

I am able to build and run mbgl-glfw built with clang 10 as well as GCC 9.4 with attached patch.

Lots of clang-tidy issues; some are directly related to the compiler errors.

Build flags:

-DMLN_WITH_VULKAN=ON
-DMLN_WITH_X11=OFF
-DMLN_WITH_WAYLAND=OFF
-DMLN_DRAWABLE_RENDERER=ON
-DMLN_LEGACY_RENDERER=OFF
-DMLN_WITH_VULKAN=ON
-DMLN_WITH_OPENGL=OFF
-DMLN_WITH_EGL=OFF

0001-Changes-to-build-GCC-9.4-Clang-10.zip

louwers commented 2 months ago

@jwinarske Could you share your clang-tidy config? Here is ours: https://github.com/maplibre/maplibre-native/blob/main/.clang-tidy

Any chance you could upstream your patch as a PR?

adrian-cojocaru commented 2 months ago

@jwinarske Seems to compile without any issue on clang 10/GCC 9.4. As @louwers suggested the difference is probably in clang-tidy config.