Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: wgpu rendering rewrite #5124

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

pollend
Copy link
Member

@pollend pollend commented Jul 24, 2023

Contains

starting POC looking into using a rust backend for handling critical rendering code.

There is still a lot missing so at the moment it will take a while before this gets to a playable state. The basic gist is to move a lot of the critical rendering code to a separate rust library. will still use lwjgl mainly for GLFW basically just supplies the window and most of the handling will still happen in java code land.

Setup

@github-actions github-actions bot added the Type: Improvement Request for or addition/enhancement of a feature label Jul 24, 2023
@skaldarnar
Copy link
Member

I tried again to run this on my Linux machine, but could not get the game to start / a window to show up.

workspace
  engine ts-rusty                          feature/wgpu-ren… 221e454e
libs
     lib TeraRusty                         main              467e5232

I does compile some Rust code and the loading bar banner image briefly shows up before the process crashes.

RUST_BACKTRACE=1 gradlew clean extractNatives jar game

...
> Task :TeraRusty:core-rust:native_x86_64-unknown-linux-gnu
warning: unused import: `std::marker::PhantomData`
 --> src/java_util.rs:3:5
  |
3 | use std::marker::PhantomData;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default
...
19:33:26.021 [main] INFO  o.t.e.c.s.lwjgl.LwjglGraphics - Initializing display (if last line in log then likely the game crashed from an issue with your video card)
19:33:26.024 [main] INFO  o.t.engine.rust.NativeSupport - Loading JNBullet Library:core_rust
19:33:26.025 [main] INFO  o.t.engine.rust.NativeSupport -       Loaded from java.library.path: /home/skaldarnar/Code/movingblocks/ts-rusty/natives/linux/libcore_rust-linux-amd64.so
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/khronos-egl-4.1.0/src/lib.rs:961:42
stack backtrace:
   0: rust_begin_unwind
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:117:5
   3: core::option::Option<T>::unwrap
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/option.rs:935:21
   4: khronos_egl::egl1_0::<impl khronos_egl::Instance<T>>::make_current
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/khronos-egl-4.1.0/src/lib.rs:961:10
   5: wgpu_hal::gles::egl::EglContext::make_current
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.16.1/src/gles/egl.rs:297:9
   6: <wgpu_hal::gles::egl::Instance as wgpu_hal::Instance<wgpu_hal::gles::Api>>::enumerate_adapters
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.16.1/src/gles/egl.rs:893:9
   7: wgpu_core::instance::<impl wgpu_core::hub::Global<G>>::request_adapter::gather
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.16.1/src/instance.rs:767:49
   8: wgpu_core::instance::<impl wgpu_core::hub::Global<G>>::request_adapter
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.16.1/src/instance.rs:839:36
   9: <wgpu::backend::direct::Context as wgpu::context::Context>::instance_request_adapter
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.16.2/src/backend/direct.rs:568:18
  10: <T as wgpu::context::DynContext>::instance_request_adapter
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.16.2/src/context.rs:1935:47
  11: wgpu::Instance::request_adapter
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.16.2/src/lib.rs:1441:23
  12: core_rust::window_surface::WindowSurface::create::{{closure}}
             at ./libs/TeraRusty/core-rust/natives/src/window_surface.rs:102:23
  13: futures_executor::local_pool::block_on::{{closure}}
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-executor-0.3.28/src/local_pool.rs:317:23
  14: futures_executor::local_pool::run_executor::{{closure}}
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-executor-0.3.28/src/local_pool.rs:90:37
  15: std::thread::local::LocalKey<T>::try_with
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/thread/local.rs:270:16
  16: std::thread::local::LocalKey<T>::with
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/thread/local.rs:246:9
  17: futures_executor::local_pool::run_executor
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-executor-0.3.28/src/local_pool.rs:86:5
  18: futures_executor::local_pool::block_on
             at /home/skaldarnar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-executor-0.3.28/src/local_pool.rs:317:5
  19: core_rust::engine_kernel::EngineKernel::new
             at ./libs/TeraRusty/core-rust/natives/src/engine_kernel.rs:37:23
  20: Java_org_terasology_engine_rust_EngineKernel_00024JNI_create
             at ./libs/TeraRusty/core-rust/natives/src/jni/jni_engine_kernel.rs:49:45
  21: <unknown>

I tested this with

openjdk 11.0.15 2022-04-19 LTS
OpenJDK Runtime Environment (build 11.0.15+10-LTS)
OpenJDK 64-Bit Server VM (build 11.0.15+10-LTS, mixed mode)

and

rustc 1.71.0 (8ede3aae2 2023-07-12)

@pollend
Copy link
Member Author

pollend commented Aug 13, 2023

why is it running egl that is very strange.

pollend and others added 13 commits September 25, 2023 18:04
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
@pollend pollend force-pushed the feature/wgpu-rendering-refactor branch from 221e454 to f3efca5 Compare September 26, 2023 01:06
@jdrueckert jdrueckert added the Status: Needs Author Input Requires more information by the author on the reported issue or provided changes label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Author Input Requires more information by the author on the reported issue or provided changes Type: Improvement Request for or addition/enhancement of a feature
Projects
Status: Next Milestone
Development

Successfully merging this pull request may close these issues.

4 participants