Home

Awesome

deck.gl-native

This is an open-source C++ implementation of deck.gl.

This project is no longer active. It was an experiment to understand what it would take to build a native version of deck.gl. There are discussions about restarting a deck.gl-native effort (this time probably in Rust instead of C++) to help us integrate more non-JavaScript code, better support mobile platforms, and collaborate better with basemaps like maplibre-gl. If you have more than a passing interest in this topic you are welcome to join us at https://www.openvisualization.org/#get-involved.

<br /> <table style="border: 0;" align="center"> <thead> <tr> <th colspan="3" style="text-align: center;"> Layer examples running on an iOS device </td> </tr> </thead> <tbody> <tr> <td> <img style="max-height:200px" src="https://raw.githubusercontent.com/UnfoldedInc/deck.gl-data/master/images/line-scatterplot-demo.gif" /> <p><i>LineLayer + ScatterplotLayer</i></p> </td> <td> <img style="max-height:200px" src="https://raw.githubusercontent.com/UnfoldedInc/deck.gl-data/master/images/polygon-demo.gif" /> <p><i>SolidPolygonLayer</i></p> </td> <td> <img style="max-height:200px" src="https://raw.githubusercontent.com/UnfoldedInc/deck.gl-data/master/images/scatterplot-demo.gif" /> <p><i>ScatterplotLayer</i></p> </td> </tr> </tbody> </table>

This project targeted a minimal, proof-of-concept prototype. This initial deck.gl-native release is unlikely to meet the requirements of most applications.

Scope

Not Planned

Many features normally considered fundamental by deck.gl applications are not even being addressed at this stage

Supported Platforms

iOS

macOS

Linux

Software Architecture

To get oriented on the deck.gl software architecture:

API Design Principles and Cross-Platform Concerns

A primary concern for the deck.gl-native port, especially once it matures, is how to keep it develop in sync with the various implementations and variants of the deck.gl API, such as the core JavaScript codebase, the pydeck Python API etc.

Currently the two main guidelines are:

Beyond the above rules, it is certainly acceptable C++ and JavaScript APIs to diverge, as long as it makes sense, to ensure they are both natural to use for programmers with backgrounds in the respective programming language. (E.g. functional style UI programming is common in the JS community while C++ programmers on the balance are likely favor a more imperative API style).

Top-level API also includes exception-less counterparts for core functionality across the modules.

C++ Module Structure

The deck.gl-native code bases exposes a set of C++ "module header files" following a <framework>/<module>.h structure.

ModuleDescription
probe.gl/core.hPlatform/Compiler detection, assertions, logging and timers
math.gl/core.hVectors and Matrices
math.gl/web-mercator.hGeospatial math for Web Mercator projection
loaders.gl/csv.h.A CSV table loader
loaders.gl/json.h.A JSON table loader
luma.gl/core.hModel, AnimationLoop etc implemented on dawn API
luma.gl/webgpu.hInternal utilities for working with the WebGPU API (adaptions from the dawn repo)
luma.gl/garrow.hGPU-based implementation of Arrow-like API
deck.gl/core.hThe core deck.gl classes:\ Deck, Layer, View, etc.
deck.gl/layers.hThe initial layer catalog
deck.gl/json.hClasses for parsing (deck.gl) JSON into C++ objects

Remarks:

Apache Arrow

All in-memory table processing is based on the Apache Arrow C++ API. This will be almost invisible to applications if they use the provided loaders, however for more advanced table processing applications may need to work directly with the Arrow API.

To get started with Arrow, useful resources might be:

CSV and JSON table loaders are provided as part of the deck.gl library. To support additional table formats, the envisioned approach is to implement additional "loaders" that load various formats and "convert" the loaded tables to Arrow representation.

Graphics Backend: dawn/WebGPU

deck.gl-native is being built on top of the C++ WebGPU API using the dawn framework.

The dawn framework is a compelling choice for deck.gl:

Note that Dawn is still a work in progress (with different levels of support for different platforms - the prototype is only being tested on iOS) and there is some risk with this technology choice. However, given the momentum behind WebGPU in browsers, we feel that the prospects are currently looking good.

Supporting this Effort

This porting project is led by Unfolded, Inc, and currently relies on initial funding provided by a customer as well as external contributions. At this stage, this is not an fully or independenly resourced project. It only targets a proof-of-concept prototype, it does not have a maintenance plan and is not set up to address feature requests etc.

Our hope is to see this project quickly grow into a living part of the core deck.gl project. If this project reaches a sufficient level of completeness / critical mass, the ambition is to make this project part of the main deck.gl project and transfer it to an open governance setup.

Setting up a Development Environment

Development can be done on macOS which is the primary environment, or Linux, which is supported mainly for CI testing. (Windows is not a supported dev env.)

NOTE: Building using gcc currently doesn't work, this is to be updated

Quickstart

Xcode (macOS only)

If you haven't already configured Xcode:

clang

For macOS:

brew install clang cmake clang-format lcov

gcc

For macOS:

brew install gcc cmake clang-format lcov

Dependencies

All the dependencies for macOS and Linux are bundled in a dependency repository that's being used as a submodule. Running scripts/bootstrap.sh, among other things, fetches all the submodules. Alternatively, you can fetch them by running git submodule update --init --recursive.

DependencyDescription
Google TestTesting framework
jsoncppJSON parser
arrowColumnar in-memory storage
dawnC++ WebGPU implementation with a maturing list of backends for most platforms
shadercGLSL shader compilation
glfwPortable library for creating OS windows to render graphics in, and handling events

Building

mkdir build
cd build
cmake ..
make -j 16

To use different compilers, set the build options CMAKE_C_COMPILER and CMAKE_CXX_COMPILER on the cmake command line. There is a number of build scripts for different compilers available in scripts directory.

Testing

For Google Test formatted output, run ./deckgl-bundle-tests. For CTest formatted output, run ctest.