A Preliminary Study of Bevy, Rust Game Engine

That day, I happened to see a game engine written in Rust (actually I found it deliberately, it’s so self-abuse), and I instantly became interested in fucking and playing, but I was tossed by it before Xiaoni could laugh at him. Changed the kernel. What's going on, let me talk slowly.

I downloaded the Bevy project and tried to run the example game, and an error was reported:


tianlang@tianlang:rust$ git clone https://github.com/bevyengine/bevy
is cloning to'bevy'...
remote: Enumerating objects: 292, done.
remote: Counting objects: 100% (292/292), done.
remote: Compressing objects: 100% (231/231), done.
remote: Total 29614 (delta 126), reused 161 (delta 60), pack-reused 29322
Receiving objects: 100% (29614/29614), 32.77 MiB | 157.00 KiB/s, complete.
Processing delta: 100% (18934/18934), complete.


tianlang@tianlang:rust$ cd bevy/


tianlang@tianlang:bevy$ cargo run --example breakout
...
Compiling ab_glyph v0.2.10
error: failed to run custom build command for `libudev-sys v0.1.4`

Caused by:
  process didn't exit successfully: `/data/code/github/rust/bevy/target/debug/build/libudev-sys-ee6a5de081f0ae93/build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBUDEV_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=LIBUDEV_STATIC
  cargo:rerun-if-env-changed=LIBUDEV_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "`\"pkg-config\" \"--libs\" \"--cflags\" \"libudev\"` did not exit successfully: exit code: 1\n--- stderr\nPackage libudev was not found in the pkg-config search path.\nPerhaps you should add the directory containing `libudev.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'libudev\' found\n"', /home/tianlang/.cargo/registry/src/github.com-1ecc6299db9ec823/libudev-sys-0.1.4/build.rs:38:41
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

Checking the official documentation of bevy is that there is no system dependency installed, I am using ubuntu18, and execute the installation command:

sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev

sudo apt-get install clang

After the installation is complete, you can compile the example normally, but it fails to run:

tianlang@tianlang:bevy$ cargo run --example breakout
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/examples/breakout`
thread 'main' panicked at 'Unable to query surface formats: ERROR_UNKNOWN', /home/tianlang/.cargo/registry/src/github.com-1ecc6299db9ec823/gfx-backend-vulkan-0.7.0/src/window.rs:315:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Mar 30 22:08:25.706 ERROR gpu_descriptor::allocator: `DescriptorAllocator` is dropped while some descriptor sets were not deallocated
Mar 30 22:08:25.706 ERROR gpu_alloc::block: Memory block wasn't deallocated
Mar 30 22:08:25.706 ERROR gpu_alloc::block: Memory block wasn't deallocated
段错误

According to the error message, Vulcan has a problem. After executing vulkaninfo to confirm, it turned out that this kid has an abnormality:

$vulkaninfo
/build/vulkan-tools-136mCR/vulkan-tools-1.1.126.0+dfsg1/vulkaninfo/vulkaninfo.h:803: failed with UNKNOWN_VkResult
段错误

$ dmsg

[ 2016.528891] nvidia-modeset: Version mismatch: nvidia.ko(460.67) nvidia-modeset.ko(460.56)
[ 2016.933217] PKCS#7 signature not signed with a trusted key
[ 2016.935729] nvidia-modeset: Version mismatch: nvidia.ko(460.67) nvidia-modeset.ko(460.56)
[ 2017.344852] PKCS#7 signature not signed with a trusted key
[ 2017.346405] nvidia-modeset: Version mismatch: nvidia.ko(460.67) nvidia-modeset.ko(460.56)
[ 2017.460432] vulkaninfo[6255]: segfault at 6b6e696c678d ip 00007f703abf8fd0 sp 00007ffc7ba2c218 error 4 in libpthread-2.27.so[7f703abef000+1a000]
[ 2223.351496] traps: vulkaninfo[7640] general protection ip:7f568663ffd0 sp:7ffc4afb7b68 error:0 in libpthread-2.27.so[7f5686636000+1a000]

Guessing from the dmsg error message should be related to the library mismatch, re- download the vulcan sdk and   refer to the blog installation. Still the same error, the sound of the sound is still there.

It seems that you have to zoom in and upgrade the kernel. Since the elementary os I used is developed based on ubuntu18, you can refer to here to upgrade the kernel. The original kernel is:

$ uname -r
4.15.0-36-generic

After upgrading:

tianlang@tianlang$ uname -r
5.4.0-71-generic

After restarting, execute vulkaninfo again to display information that is very different from before. Executing vkcube can actually see the legendary cube:

It's not easy! Run the bevy example after winning the chase, and it's finally normal.

Oops, is this running interface a bit similar to the table tennis game in our Rust course, let’s close!!!


Guess you like

Origin blog.51cto.com/14256460/2678976