Skip to content

Commit

Permalink
Merge branch 'trunk' into dependabot/cargo/encase-0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald authored Mar 3, 2024
2 parents 4cfae53 + d475555 commit ea1d1be
Show file tree
Hide file tree
Showing 25 changed files with 98 additions and 147 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
os: "ubuntu-latest"
target: "x86_64-unknown-linux-gnu"
- name: "mac"
os: ["macOS", "gpu"]
os: "macos-14"
target: "aarch64-apple-darwin"
- name: "windows"
os: "windows-latest"
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Set up Rust toolchain
id: setup-rust
run: |
rustup toolchain install 1.72 -c clippy -t ${{ matrix.target }}
rustup toolchain install 1.76 -c clippy -t ${{ matrix.target }}
- name: Install cargo-nextest and cargo-llvm-cov
uses: taiki-e/install-action@v2
Expand All @@ -56,32 +56,32 @@ jobs:

- name: build
run: |
cargo +1.72 build --target ${{ matrix.target }} --profile ci
cargo +1.76 build --target ${{ matrix.target }} --profile ci
if: matrix.target != 'wasm32-unknown-unknown'

- name: clippy (rend3-gltf featureless)
run: |
cargo +1.72 clippy --target ${{ matrix.target }} --profile ci -p rend3-gltf --no-default-features
cargo +1.76 clippy --target ${{ matrix.target }} --profile ci -p rend3-gltf --no-default-features
- name: clippy
run: |
cargo +1.72 clippy --target ${{ matrix.target }} --profile ci
cargo +1.76 clippy --target ${{ matrix.target }} --profile ci
if: matrix.target != 'wasm32-unknown-unknown'

- name: doc
run: |
cargo +1.72 doc --target ${{ matrix.target }} --profile ci --no-deps
cargo +1.76 doc --target ${{ matrix.target }} --profile ci --no-deps
if: matrix.target != 'wasm32-unknown-unknown'

- name: download test resources
if: matrix.os[1] == 'gpu'
if: matrix.os != 'macos-14'
run: |
bash ./build.bash download-assets
- name: test
if: matrix.os != 'macos-14' && matrix.target != 'wasm32-unknown-unknown'
run: |
cargo +1.72 nextest run --target ${{ matrix.target }} --cargo-profile ci --no-fail-fast
if: matrix.target != 'wasm32-unknown-unknown'
cargo +1.76 nextest run --target ${{ matrix.target }} --cargo-profile ci --no-fail-fast
- uses: actions/upload-artifact@v4
# always run
Expand All @@ -101,11 +101,11 @@ jobs:
- name: Set up Rust toolchain
id: setup-rust
run: |
rustup toolchain install 1.72 -c rustfmt
rustup toolchain install 1.76 -c rustfmt
- name: format
run: |
cargo +1.72 fmt --check
cargo +1.76 fmt --check
cargo-deny:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ Per Keep a Changelog there are 6 main categories of changes:
- rend3: Added basic (no shadow maps, no clustering) point light support to the renderer API. @marceline-cramer

### Changes
- rend3: Update to wgpu 0.13, naga 0.9 @garyttierney
- rend3: Update to wgpu 0.19, naga 0.14 @garyttierney @kpreid
- rend3: Convert all shaders to WGSL using a custom preprocessing solution @cwfitzgerald
- rend3: Update to winit 0.29.4 @pillowtrucker
- rend3-framework: Consolidate many arguments into single `SetupContext`, `EventContext`, and `RedrawContext` structs. @cwfitzgerald
- rend3-framework: Surfaces are now handled amost entirely by the framework, including acquiring frames and presenting. Redraws now happen in a dedicated `handle_redraw` callback. @cwfitzgerald
- rend3-egui: Update to egui 0.26. @Elabajaba

### Fixes
- Fixed renderpass compatibility checks to avoid issues when RODS is used. @OptimisticPeach
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rend3

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/BVE-Reborn/rend3/CI)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/BVE-Reborn/rend3/ci.yml)
[![Crates.io](https://img.shields.io/crates/v/rend3)](https://crates.io/crates/rend3)
[![Documentation](https://docs.rs/rend3/badge.svg)](https://docs.rs/rend3)
![License](https://img.shields.io/crates/l/rend3)
Expand Down
10 changes: 5 additions & 5 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ path = "src/main.rs"
# error handling
anyhow = "1"
# The egui immediate mode gui library
egui = {git = "https://github.com/emilk/egui.git", branch="master"}
egui = "0.26"
# Winit integration with egui (turn off the clipboard feature)
egui-winit = { git = "https://github.com/emilk/egui.git", branch="master", default-features = false, features = ["links", "wayland"] }
egui-winit = { version = "0.26", default-features = false, features = ["links", "wayland"] }
# logging
env_logger = { version = "0.10", default-features = false, features = ["auto-color", "humantime"] }
# Linear algebra library
Expand Down Expand Up @@ -66,15 +66,15 @@ web-time = "0.2"
# windowing
winit = "0.29.4"
# Integration with wgpu
wgpu = "0.18"
wgpu = "0.19.0"
# Profiling with wgpu
wgpu-profiler = "0.15"
wgpu-profiler = "0.16.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_log = "1"
console_error_panic_hook = "0.1"
js-sys = "0.3"
web-sys = "0.3"
web-sys = "0.3.67"
wasm-bindgen = "0.2.83"
wasm-bindgen-futures = "0.4"

Expand Down
2 changes: 1 addition & 1 deletion examples/src/cube_no_framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ winit = "0.29.4"
console_log = "1"
console_error_panic_hook = "0.1"
js-sys = "0.3"
web-sys = "0.3"
web-sys = "0.3.67"
wasm-bindgen = "0.2.83"
wasm-bindgen-futures = "0.4"
2 changes: 1 addition & 1 deletion examples/src/cube_no_framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn main() {
// SAFETY: this surface _must_ not be used after the `window` dies. Both the
// event loop and the renderer are owned by the `run` closure passed to winit,
// so rendering work will stop after the window dies.
let surface = Arc::new(unsafe { iad.instance.create_surface(&window) }.unwrap());
let surface = Arc::new(iad.instance.create_surface(&window).unwrap());
// Get the preferred format for the surface.
let caps = surface.get_capabilities(&iad.adapter);
let preferred_format = caps.formats[0];
Expand Down
6 changes: 2 additions & 4 deletions examples/src/scene_viewer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ use rend3::{
Backend, Camera, CameraProjection, DirectionalLight, DirectionalLightHandle, SampleCount, Texture,
TextureFormat,
},
util::typedefs::FastHashMap,
util::typedefs::{FastHashMap, RendererStatistics},
Renderer, RendererProfile,
};
use rend3_framework::{lock, AssetPath, Mutex};
use rend3_gltf::{GltfLoadSettings, GltfSceneInstance, LoadedGltfScene};
use rend3_routine::{pbr::NormalTextureYDirection, skybox::SkyboxRoutine};
use web_time::Instant;
use wgpu_profiler::GpuTimerScopeResult;
use winit::{
event::{DeviceEvent, ElementState, Event, KeyEvent, MouseButton, WindowEvent},
keyboard::{KeyCode, PhysicalKey},
Expand Down Expand Up @@ -135,7 +134,6 @@ fn extract_backend(value: &str) -> Result<Backend, &'static str> {
Ok(match value.to_lowercase().as_str() {
"vulkan" | "vk" => Backend::Vulkan,
"dx12" | "12" => Backend::Dx12,
"dx11" | "11" => Backend::Dx11,
"metal" | "mtl" => Backend::Metal,
"opengl" | "gl" => Backend::Gl,
_ => return Err("unknown backend"),
Expand Down Expand Up @@ -301,7 +299,7 @@ pub struct SceneViewer {
camera_pitch: f32,
camera_yaw: f32,
camera_location: Vec3A,
previous_profiling_stats: Option<Vec<GpuTimerScopeResult>>,
previous_profiling_stats: Option<RendererStatistics>,
last_mouse_delta: Option<DVec2>,

scene: Option<LoadedGltfScene>,
Expand Down
8 changes: 4 additions & 4 deletions rend3-egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ categories = ["game-development", "graphics", "rendering", "rendering::engine",
rust-version = "1.71"

[dependencies]
egui = {git = "https://github.com/emilk/egui.git", branch="master"}
egui-wgpu = {git = "https://github.com/emilk/egui.git", branch="master"}
egui = "0.26"
egui-wgpu = "0.26"
glam = "0.24"
rend3 = { version = "^0.3.0", path = "../rend3" }
wgpu = "0.18.0"
wgpu-types = "0.18.0"
wgpu = "0.19.0"
wgpu-types = "0.19.0"
8 changes: 4 additions & 4 deletions rend3-egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use wgpu::TextureFormat;

pub struct EguiRenderRoutine {
pub internal: egui_wgpu::Renderer,
screen_descriptor: egui_wgpu::renderer::ScreenDescriptor,
screen_descriptor: egui_wgpu::ScreenDescriptor,
textures_to_free: Vec<egui::TextureId>,
}

Expand All @@ -36,7 +36,7 @@ impl EguiRenderRoutine {

Self {
internal: rpass,
screen_descriptor: egui_wgpu::renderer::ScreenDescriptor {
screen_descriptor: egui_wgpu::ScreenDescriptor {
size_in_pixels: [width, height],
pixels_per_point: scale_factor,
},
Expand All @@ -45,7 +45,7 @@ impl EguiRenderRoutine {
}

pub fn resize(&mut self, new_width: u32, new_height: u32, new_scale_factor: f32) {
self.screen_descriptor = egui_wgpu::renderer::ScreenDescriptor {
self.screen_descriptor = egui_wgpu::ScreenDescriptor {
size_in_pixels: [new_width, new_height],
pixels_per_point: new_scale_factor,
};
Expand Down Expand Up @@ -137,7 +137,7 @@ impl EguiRenderRoutine {
image_rgba,
dimensions,
format.block_dimensions(),
format.block_size(None).unwrap(),
format.block_copy_size(None).unwrap(),
)
}

Expand Down
5 changes: 2 additions & 3 deletions rend3-framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rend3-routine = { version = "0.3.0", path = "../rend3-routine" }
thiserror = { version = "1" }
web-time = "0.2"
winit = { version = "0.29.4", features = ["rwh_05"] }
wgpu = "0.18.0"
wgpu = "0.19.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# logging
Expand All @@ -34,11 +34,10 @@ pollster = "0.3"
console_error_panic_hook = "0.1"
console_log = "1"
js-sys = "0.3"
reqwest = "0.11"
once_cell = "1.8"
wasm-bindgen = "0.2.87"
wasm-bindgen-futures = "0.4"
web-sys = "0.3"
web-sys = "0.3.67"

[target.'cfg(target_os = "android")'.dependencies]
ndk-glue = "0.7"
13 changes: 0 additions & 13 deletions rend3-framework/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ pub enum AssetError {
#[source]
error: std::io::Error,
},
#[error("Could not read {path} from the network")]
#[cfg(target_arch = "wasm32")]
NetworkError {
path: SsoString,
#[source]
error: reqwest::Error,
},
#[error("Reading {path} from the network returned non-success status code {status}")]
#[cfg(target_arch = "wasm32")]
NetworkStatusError {
path: SsoString,
status: reqwest::StatusCode,
},
}

pub enum AssetPath<'a> {
Expand Down
29 changes: 23 additions & 6 deletions rend3-framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ pub trait App<T: 'static = ()> {
console_log::init().unwrap();

#[cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))]
env_logger::builder()
if let Err(e) = env_logger::builder()
.filter_module("rend3", log::LevelFilter::Info)
.parse_default_env()
.init();
.try_init()
{
eprintln!("Error registering logger from Rend3 framework: {:?}", e);
// probably ran two runs in sequence and initialized twice
};
}

fn register_panic_hook(&mut self) {
Expand Down Expand Up @@ -134,15 +138,27 @@ pub trait App<T: 'static = ()> {
1.0
}

/// Set up the rendering environment. Called once at startup.
fn setup(&mut self, context: SetupContext<'_, T>) {
let _ = context;
}

/// Handle a non-redraw event.
fn handle_event(&mut self, context: EventContext<'_, T>, event: Event<T>) {
let _ = (context, event);
}

/// Handle a redraw event.
fn handle_redraw(&mut self, context: RedrawContext<'_, T>);

/// Called after each redraw for post-processing, if needed.
/// By default, this queues another redraw.
/// That behavior is not appropriate on some platforms.
/// Ref: Issue 570.
/// This gives the application the option of overriding that behavior.
fn handle_redraw_done(&mut self, window: &Window) {
window.request_redraw(); // just queue a redraw.
}
}

pub fn lock<T>(lock: &parking_lot::Mutex<T>) -> parking_lot::MutexGuard<'_, T> {
Expand All @@ -166,6 +182,7 @@ pub async fn async_start<A: App<T> + 'static, T: 'static>(mut app: A, window_bui

// Create the window invisible until we are rendering
let (event_loop, window) = app.create_window(window_builder.with_visible(false)).unwrap();
let window = Arc::new(window);
let window_size = window.inner_size();

let iad = app.create_iad().await.unwrap();
Expand All @@ -178,7 +195,7 @@ pub async fn async_start<A: App<T> + 'static, T: 'static>(mut app: A, window_bui
let mut surface = if cfg!(target_os = "android") {
None
} else {
Some(Arc::new(unsafe { iad.instance.create_surface(&window) }.unwrap()))
Some(Arc::new(iad.instance.create_surface(window.clone()).unwrap()))
};

// Make us a renderer.
Expand Down Expand Up @@ -368,7 +385,7 @@ pub async fn async_start<A: App<T> + 'static, T: 'static>(mut app: A, window_bui

surface_texture.present();

window.request_redraw();
app.handle_redraw_done(&window); // standard action is to redraw, but that can be overridden.
} else {
app.handle_event(
EventContext {
Expand Down Expand Up @@ -401,7 +418,7 @@ struct StoredSurfaceInfo {
#[allow(clippy::too_many_arguments)]
fn handle_surface<A: App<T>, T: 'static>(
app: &A,
window: &Window,
window: &Arc<Window>,
event: &Event<T>,
instance: &Instance,
surface: &mut Option<Arc<Surface>>,
Expand All @@ -411,7 +428,7 @@ fn handle_surface<A: App<T>, T: 'static>(
match *event {
Event::Resumed => {
if surface.is_none() {
*surface = Some(Arc::new(unsafe { instance.create_surface(window) }.unwrap()));
*surface = Some(Arc::new(instance.create_surface(window.clone()).unwrap()));
}
Some(false)
}
Expand Down
Loading

0 comments on commit ea1d1be

Please sign in to comment.