Use wgpu and link C++ library using wgpu-native

1 week ago 18
ARTICLE AD BOX

maplibre-native-rs is a Rust project creating a Rust interface to the C++ library maplibre-native.

Maplibre-native-rs is using the cxx crate to create the interface to the C++ library. Maplibre-native can use wgpu-native a wrapper library around wgpu which is written in Rust.

Currently the images rendered by maplibre with wgpu are copied to the Ram and then rendered again using the GPU with wgpu on the Rust side.

The idea is to avoid this step and using the rendered texture directly in Rust, because both sides are using wgpu.

For this the wgpu device from Rust must be passed to the C++ library so that maplibre-native can use it to create the texture handler which is then passed back to the Rust side.

How do I get a C++ wgpu device from Rust?

And the second problem is to avoid linking wgpu two times. Once into maplibre-native-rs and once indirectly into maplibre-native because of wgpu-native?

Probably there are much more problems I will have, but maybe someone has experience how to handle such a case in general?

Read Entire Article