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

Resync with WGPU 0.20. #601

Open
wants to merge 89 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
8ac4cef
Updated to WGPU 0.20, plus updates to Winit and Egui as necessary
John-Nagle Jul 4, 2024
95c1e15
Format only
John-Nagle Jul 4, 2024
a846beb
Bump version to 0.20.0
John-Nagle Jul 4, 2024
97ca985
Fix remaining warnings
John-Nagle Jul 5, 2024
4811046
Fix problems detected by CI system
John-Nagle Jul 6, 2024
1450746
Default scene render does not match exactly. Minor diffeerences in da…
John-Nagle Jul 6, 2024
87f88eb
IN PROGRESS - conversion to wgpu 22.0 stalled because egui-wgpu not r…
John-Nagle Jul 19, 2024
529c4ca
In progress conversion to WGPU 21. Does not compile.
John-Nagle Aug 2, 2024
29d462e
Finally compiles with WGPU 22
John-Nagle Aug 7, 2024
71aeb3a
BAD - can't compile closure in rend3-egui after using new egui
John-Nagle Oct 10, 2024
fb29afb
Begin development notes
John-Nagle Oct 13, 2024
e81aed6
Plan for fixing conflicts and removing unsafe code
John-Nagle Oct 14, 2024
f8f7c5b
Working on conversion to winit30. WGPU usage not fully converted yet …
John-Nagle Oct 16, 2024
0414cd0
Converting window creation to new WGPU WindowAttributes form. Unfinished
John-Nagle Oct 16, 2024
8528c5f
Converting examples to new WGPU. Unfinished
John-Nagle Oct 16, 2024
fcd0ab7
BAD - part way through converting Encoder and RenderPass to Rc<RefCel…
John-Nagle Oct 17, 2024
adb3006
BAD - part way through converting Encoder and RenderPass to Rc<RefCel…
John-Nagle Oct 17, 2024
5926fe4
BAD - still converting
John-Nagle Oct 17, 2024
d4dff95
Examples are running
John-Nagle Oct 17, 2024
7c5e3f0
Some cleanup. Tests pass
John-Nagle Oct 18, 2024
eab48a8
Fixed egui example warnings
John-Nagle Oct 18, 2024
919a64e
Add more profiling
John-Nagle Oct 22, 2024
ed59194
Add more profiling temp
John-Nagle Oct 22, 2024
1c94aa1
Comment out very detailed profiling that slowed down binding
John-Nagle Oct 23, 2024
18bad97
BAD - changes to bind group semantics broke code
John-Nagle Nov 2, 2024
63bb58f
BAD - changes to bind group semantics broke code
John-Nagle Nov 2, 2024
5558455
BAD - changes to bind group semantics can't be fixed by just adding '…
John-Nagle Nov 2, 2024
6a6d059
BAD - got past bind API change, though
John-Nagle Nov 2, 2024
554159b
BAD - one more change to fix
John-Nagle Nov 2, 2024
51693c8
BAD - panics every time in buffer.rs
John-Nagle Nov 2, 2024
3290911
Tests passing except for ones that need content files
John-Nagle Nov 3, 2024
7b23a87
Upgrade everything to WGPU 23, crates from crates.io
John-Nagle Dec 21, 2024
1e85cd0
Upgrade everything to WGPU 23, crates from crates.io
John-Nagle Dec 21, 2024
fd670d4
Support Tracy profiling
John-Nagle Dec 22, 2024
484e47c
Use Expect to catch unwrap problem
John-Nagle Dec 23, 2024
2f9c896
BAD - lifetime problems
John-Nagle Dec 25, 2024
de6c70f
BAD - lifetime problems
John-Nagle Dec 26, 2024
57e5eff
BAD - lifetime problems
John-Nagle Dec 26, 2024
6b2bed1
BAD - lifetime problems
John-Nagle Dec 26, 2024
781fd43
Runs well enough to do basic Rend3 examples. Further testing needed
John-Nagle Dec 27, 2024
46c7bc8
Advance version
John-Nagle Dec 27, 2024
6bfc50d
Update all items to version 0.23.1
John-Nagle Dec 28, 2024
1532272
Turn on asserts for free list errors. Possible race condition
John-Nagle Dec 29, 2024
6339cc6
Add check for delete/add sequence in instructions
John-Nagle Dec 31, 2024
5da9240
Add patch to use fixed version of range-alloc
John-Nagle Jan 2, 2025
4c2108b
Don't use obsolete rwh_05 feature
John-Nagle Jan 3, 2025
5c14ae2
Turn off instruction check that never failed but may affect timing
John-Nagle Jan 4, 2025
db0a958
Update changelog for new release
John-Nagle Jan 6, 2025
3f18dd1
Update changelog for new release
John-Nagle Jan 6, 2025
dea88fb
Working towards non-copyable RawResourceHandle
John-Nagle Jan 7, 2025
beffd87
Moving away from copying raw handles
John-Nagle Jan 7, 2025
e170df4
More cleanup of raw handles
John-Nagle Jan 7, 2025
2de30c0
More checking of handles
John-Nagle Jan 7, 2025
182bcd1
Fix checker - meshes and objects have disjoint handle spaces
John-Nagle Jan 7, 2025
1be637b
Use range-alloc 0.1.4 which should not need patching
John-Nagle Jan 17, 2025
b405e48
BAD - working on moving to new winit framework
John-Nagle Jan 19, 2025
9987ed8
BAD - still working on moving to new winit framework
John-Nagle Jan 19, 2025
98bf566
BAD - still working on moving to new winit framework
John-Nagle Jan 19, 2025
99d4bba
BAD - still working on winit conversion
John-Nagle Jan 20, 2025
53d4bf8
BAD - still working on winit conversion
John-Nagle Jan 20, 2025
0765a75
BAD - still working on winit conversion
John-Nagle Jan 20, 2025
3a6efbf
Still having troubles with handedness
John-Nagle Jan 20, 2025
5313059
Struggling with handedness issue
John-Nagle Jan 21, 2025
da46eb5
Most of 'new' for App
John-Nagle Jan 21, 2025
7ac603e
Workaround for unnecessary async
John-Nagle Jan 21, 2025
6e0ca1f
Async workaround
John-Nagle Jan 22, 2025
86fde7b
Compiles and runs again, but not using new code. Minor breaking chang…
John-Nagle Jan 23, 2025
6b5c2e6
Compiles and runs again, but not using new code. Minor breaking chang…
John-Nagle Jan 23, 2025
3e77b76
Dummies for other required methods
John-Nagle Jan 23, 2025
43977e2
Fill in some dummies
John-Nagle Jan 23, 2025
00e2fc7
Got Rend3Application lifetime under control
John-Nagle Jan 25, 2025
a8fa831
More generic fixing
John-Nagle Jan 25, 2025
53dc01d
More prep for new framework Winit use
John-Nagle Jan 25, 2025
22b0e71
async_start_new implemented but untested
John-Nagle Jan 26, 2025
37f5091
Animation test runs. Some actions stubbed out
John-Nagle Jan 26, 2025
b89e357
Fixing up more event types at Winit->Rend3 interface
John-Nagle Jan 27, 2025
338dbc3
More event cases covered
John-Nagle Jan 27, 2025
cd4e672
More event cases covered
John-Nagle Jan 27, 2025
09ca7a0
More event cases covered
John-Nagle Jan 27, 2025
35c7930
More paths in event passthrough fixed
John-Nagle Jan 27, 2025
cf3a23d
Cleaning up - bump version, make all subprojects follow workspace ver…
John-Nagle Jan 28, 2025
ef7f9cf
BAD - out of sync wgpu versions
John-Nagle Feb 1, 2025
95ac87e
BAD - getting imports right
John-Nagle Feb 2, 2025
7d80924
BAD - getting imports right
John-Nagle Feb 2, 2025
14978bb
BAD - still getting imports right after refactoring
John-Nagle Feb 2, 2025
7d7a552
Integrating new EGUI - works, but warnings
John-Nagle Feb 4, 2025
275b3d0
More conversion to newer WGPU/EGUI
John-Nagle Feb 5, 2025
4f85105
More conversion to newer WGPU/EGUI
John-Nagle Feb 5, 2025
6e686ba
Beginnings of workaround for more winit changes
John-Nagle Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Per Keep a Changelog there are 6 main categories of changes:

## Versions

- [v0.20.0] (#v0.20.0)
- [Unreleased](#unreleased)
- [v0.3.0](#v030)
- [v0.2.0](#v020)
Expand All @@ -29,6 +30,27 @@ Per Keep a Changelog there are 6 main categories of changes:
- [v0.0.1](#v001)
- [Diffs](#diffs)

## v0.23.1

### Major Changes
None

### Changes
- Upgraded dependent packages to WGPU 0.23, and appropriate versions of Egui and Winit.
### Fixes
- Probably fixed issue 3: https://github.com/John-Nagle/rend3-hp/issues/3
- Fixed issue 4: https://github.com/John-Nagle/rend3-hp/issues/4

## v0.20.0

### Major Changes
There will be basic maintenance to keep Rend3 alive. (JN).

### Changes
- Version number advanced to 0.20. From now on, the version will generally follow WGPU.
- Incorporated all items listed as "Unreleased".
- Upgraded dependent packages to WGPU 0.20, and appropriate versions of Egui and Winit.

## Unreleased

### Major Changes
Expand Down
23 changes: 9 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ members = [
"rend3-types",
]

[workspace.package]
version = "0.24.2"

[workspace.dependencies]
wgpu = "^24.0.1"
wgpu-types = "^24.0.0"
wgpu-profiler = "^0.21.0"
glam = "^0.29"

[profile.ci]
inherits = "dev"
debug = false
Expand All @@ -26,17 +35,3 @@ opt-level = 3
[profile.release]
debug = true
lto = "thin"

[patch.crates-io]
# wgpu = { git = "https://github.com/gfx-rs/wgpu.git", rev = "fac4731288117d951d0944d96cf0b00fa006dd6c" }
# wgpu-core = { git = "https://github.com/gfx-rs/wgpu.git", rev = "fac4731288117d951d0944d96cf0b00fa006dd6c" }
# wgpu-hal = { git = "https://github.com/gfx-rs/wgpu.git", rev = "fac4731288117d951d0944d96cf0b00fa006dd6c" }
# wgpu-types = { git = "https://github.com/gfx-rs/wgpu.git", rev = "fac4731288117d951d0944d96cf0b00fa006dd6c" }
# wgpu = { git = "https://github.com/cwfitzgerald/wgpu.git", rev = "bda861f77e0ca0b97697850ad19d19a8b8f1cc9c" }
# wgpu-core = { git = "https://github.com/cwfitzgerald/wgpu.git", rev = "bda861f77e0ca0b97697850ad19d19a8b8f1cc9c" }
# wgpu-hal = { git = "https://github.com/cwfitzgerald/wgpu.git", rev = "bda861f77e0ca0b97697850ad19d19a8b8f1cc9c" }
# wgpu-types = { git = "https://github.com/cwfitzgerald/wgpu.git", rev = "bda861f77e0ca0b97697850ad19d19a8b8f1cc9c" }
# wgpu = { path = "../wgpu/wgpu" }
# wgpu-core = { path = "../wgpu/wgpu-core" }
# wgpu-hal = { path = "../wgpu/wgpu-hal" }
# wgpu-types = { path = "../wgpu/wgpu-types" }
136 changes: 136 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Development notes
John Nagle
[email protected]

Reviving Rend3 after its abandonment.

## 2024-10-12

Changes to WGPU have broken Rend3. The worst change is

https://github.com/gfx-rs/wgpu/pull/5884

which changes the lifetime of "RenderPass" and Encoder to 'static

which generates this problem:

https://users.rust-lang.org/t/unexpected-borrowed-data-escapes-outside-of-closure-for-generic/119501/4

RenderPass and Controller ownership is currently manipulated by unsafe code.
That needs to be figured out.

###Trouble spot: take_rpass

https://github.com/BVE-Reborn/rend3/blob/d088a841b0469d07d5a7ff3f4d784e97b4a194d5/rend3/src/graph/encpass.rs#L74

pub(super) enum RenderGraphEncoderOrPassInner<'a, 'pass> {
Encoder(&'a mut CommandEncoder),
RenderPass(&'a mut RenderPass<'pass>),
#[default]
None,
}

pub struct RenderGraphEncoderOrPass<'a, 'pass>(pub(super) RenderGraphEncoderOrPassInner<'a, 'pass>);
...
pub fn take_rpass(&mut self, _handle: DeclaredDependency<RenderPassHandle>) -> &'a mut RenderPass<'pass> {
match mem::take(&mut self.0) {

This in itself seems legit, i.e. safe. Except that it's taking a mutable reference, not the object itself.
There can only be one such mutable reference. Where does this come from?

Around here:

https://github.com/BVE-Reborn/rend3/blob/d088a841b0469d07d5a7ff3f4d784e97b4a194d5/rend3/src/graph/graph.rs#L451

where there is unsafe code to seemingly allow two mutable references to the same object to exist simultaneously.

// SAFETY: There is no active renderpass to borrow this. This reference lasts for the duration of
// the call to exec.
None => RenderGraphEncoderOrPassInner::Encoder(unsafe { &mut *encoder_cell.get() }),

Note that this is not an assertion that the code here is safe.
It is an unchecked constraint on the rest of the program.

Why is this not done with a RefCell and .borrow_mut?

Other than the mess around RenderPass, there's not that much unsafe code in rend3.
This might be fixable.

Maybe if we pass around something that has a RefCell<RenderGraphEncoderOrPassInner>
to everybody who needs that...
But that encapsulates a mutable reference. Who actually *owns* the thing?
Question: if we put RenderPass and Encoder inside an Rc<RefCell<>>, will that work?
Or will we panic at borrows?
Worth a try.

## 2024-10-13

Who actually owns RenderPass and Encoder?

RenderGraphEncoderOrPassInner holds an &mut of CommandEncoder or RenderPass

Who actually creates RenderGraphEncoderOrPassInner?
* Created in graph.rs execute

https://github.com/BVE-Reborn/rend3/blob/d088a841b0469d07d5a7ff3f4d784e97b4a194d5/rend3/src/graph/graph.rs#L451

RenderGraphEncoderOrPassInner::RenderPass(rpass)

https://github.com/BVE-Reborn/rend3/blob/d088a841b0469d07d5a7ff3f4d784e97b4a194d5/rend3/src/graph/graph.rs#L455

None => RenderGraphEncoderOrPassInner::Encoder(unsafe { &mut *encoder_cell.get() }),

Unsafe code. Is this really necessary?

https://github.com/BVE-Reborn/rend3/blob/d088a841b0469d07d5a7ff3f4d784e97b4a194d5/rend3/src/graph/graph.rs#L484

Same situation.

That's a get from an UnsafeCell. That's probably what should be a RefCell.
The UnsafeCell actually owns the encoder.
Who owns the RenderPass?
The caller of
create_rpass_from_desc

### First cut at design:

create_rpass_from_desc

returns an Rc<RefCell<RenderPass>>.

At line 391 in graph.rs,
encoder_cell becomes an Rc<RefCell>> of a new command encoder.

Similarly for rpass_temps_cell.

RenderGraphEncoderOrPassInner must hold an Rc<RefCell<>> for each item.

So where do we do the borrows?

At the unsafe points? Probably.

What about take_rpass?
Do the borrow at self.internal.render in lib.rs?

This will probably all compile and it's all safe code. If the comments about safety are true,
the borrow_mut calls should not fail. We will see.

## 2024-10-14

Fix all other compile errors from Winit changes. [DONE]

## 2024-10-16

Completed fixing Winit problems, with event loop disabled.
Time to do the above changes to Rend3.

Most of it now compiles.

Trouble at line 507 of graph.rs







37 changes: 20 additions & 17 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rend3-examples-package"
license = "MIT OR Apache-2.0 OR Zlib"
version = "0.3.0"
version.workspace = true
authors = ["The rend3 Developers"]
edition = "2021"
publish = false
Expand All @@ -14,19 +14,21 @@ crate-type = ["lib", "cdylib"]
name = "rend3-examples"
path = "src/main.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
# Enable Tracy tracing for scene-viewer
tracy = ["tracy-client"]

[dependencies]
# error handling
anyhow = "1"
# The egui immediate mode gui library
egui = "0.26"
egui = "0.31"
# Winit integration with egui (turn off the clipboard feature)
egui-winit = { version = "0.26", default-features = false, features = ["links", "wayland"] }
egui-winit = { version = "0.31", default-features = false, features = ["links", "wayland"] }
# logging
env_logger = { version = "0.11", default-features = false, features = ["auto-color", "humantime"] }
# Linear algebra library
glam = "0.25"
glam = { workspace = true }
# gltf model loading
gltf = "1.4"
# Channel
Expand All @@ -36,7 +38,7 @@ log = "0.4"
# Inline string
indoc = "2"
# Importing images
image = { version = "0.24", default-features = false, features = [
image = { version = "0.25", default-features = false, features = [
"png",
"jpeg",
"tiff",
Expand All @@ -48,27 +50,28 @@ pico-args = "0.5"
# block on async functions
pollster = "0.3"
# Renderer core
rend3 = { version = "^0.3.0", path = "../rend3" }
rend3 = { path = "../rend3" }
# Play animations on imported gltf models
rend3-anim = { version = "^0.3.0", path = "../rend3-anim" }
rend3-anim = { path = "../rend3-anim" }
# Egui integration with rend3
rend3-egui = { version = "^0.3.0", path = "../rend3-egui" }
rend3-egui = { path = "../rend3-egui" }
# Programmable render list that dictates how the scene renders
rend3-routine = { version = "^0.3.0", path = "../rend3-routine" }
rend3-routine = { path = "../rend3-routine" }
# Framework that deals with the event loop, setting up the renderer, and platform differences.
rend3-framework = { version = "^0.3.0", path = "../rend3-framework" }
rend3-framework = { path = "../rend3-framework" }
# Import gltf models
rend3-gltf = { version = "^0.3.0", path = "../rend3-gltf" }
rend3-gltf = { path = "../rend3-gltf" }
# Opening URL's
webbrowser = "0.8.2"
webbrowser = "1"
# Instant but portable to the web
web-time = "1.1"
# windowing
winit = "0.29.4"
winit = "0.30"
# Integration with wgpu
wgpu = "0.19.0"
wgpu = { workspace = true }
# Profiling with wgpu
wgpu-profiler = "0.16.0"
wgpu-profiler = { workspace = true }
tracy-client = { version = "0.17", optional=true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_log = "1"
Expand All @@ -83,7 +86,7 @@ wasm-bindgen-futures = "0.4"
ndk-glue = { version = "0.7", features = ["logger"] }

[dev-dependencies]
rend3-test = { version = "^0.3.0", path = "../rend3-test" }
rend3-test = { path = "../rend3-test" }
tokio = "1"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
Expand Down
10 changes: 7 additions & 3 deletions examples/src/animation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ fn update(renderer: &rend3::Renderer, delta: f32, animated_object: &mut Animated
}

impl rend3_framework::App for AnimationExample {
const HANDEDNESS: rend3::types::Handedness = rend3::types::Handedness::Left;
/// Set handedness of coordinate system
fn get_handedness(&self) -> rend3::types::Handedness {
rend3::types::Handedness::Left // default
}


fn sample_count(&self) -> rend3::types::SampleCount {
SAMPLE_COUNT
Expand Down Expand Up @@ -106,7 +110,7 @@ impl rend3_framework::App for AnimationExample {
self.animated_objects = vec![animated_object, animated_object2];
}

fn handle_redraw(&mut self, context: rend3_framework::RedrawContext<'_, ()>) {
fn handle_redraw(&mut self, context: rend3_framework::RedrawContext<'_>) {
self.animated_objects.iter_mut().for_each(|animated_object| {
update(context.renderer, context.delta_t_seconds, animated_object);
});
Expand Down Expand Up @@ -161,7 +165,7 @@ pub fn main() {
let app = AnimationExample::default();
rend3_framework::start(
app,
winit::window::WindowBuilder::new().with_title("animation-example").with_maximized(true),
winit::window::WindowAttributes::default().with_title("animation-example").with_maximized(true),
);
}

Expand Down
10 changes: 7 additions & 3 deletions examples/src/cube/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ pub struct CubeExample {
}

impl rend3_framework::App for CubeExample {
const HANDEDNESS: rend3::types::Handedness = rend3::types::Handedness::Left;
//////const HANDEDNESS: rend3::types::Handedness = rend3::types::Handedness::Left;
/// Set handedness of coordinate system
fn get_handedness(&self) -> rend3::types::Handedness {
rend3::types::Handedness::Left // default
}

fn sample_count(&self) -> rend3::types::SampleCount {
SAMPLE_COUNT
Expand Down Expand Up @@ -134,7 +138,7 @@ impl rend3_framework::App for CubeExample {
}
}

fn handle_redraw(&mut self, context: rend3_framework::RedrawContext<'_, ()>) {
fn handle_redraw(&mut self, context: rend3_framework::RedrawContext<'_>) {
// Swap the instruction buffers so that our frame's changes can be processed.
context.renderer.swap_instruction_buffers();
// Evaluate our frame's world-change instructions
Expand Down Expand Up @@ -183,7 +187,7 @@ impl rend3_framework::App for CubeExample {

pub fn main() {
let app = CubeExample::default();
rend3_framework::start(app, winit::window::WindowBuilder::new().with_title("cube-example").with_maximized(true));
rend3_framework::start(app, winit::window::WindowAttributes::default().with_title("cube-example").with_maximized(true));
}

#[cfg(test)]
Expand Down
7 changes: 4 additions & 3 deletions examples/src/cube_no_framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ pub fn main() {
// Create event loop and window
let event_loop = winit::event_loop::EventLoop::new().unwrap();
let window = {
let mut builder = winit::window::WindowBuilder::new();
builder = builder.with_title("rend3 cube");
builder.build(&event_loop).expect("Could not build window")
let mut window_attributes = winit::window::WindowAttributes::default();
window_attributes = window_attributes.with_title("rend3 cube");
//////builder.build(&event_loop).expect("Could not build window")
event_loop.create_window(window_attributes).expect("Could not build window") // (JN) for winit 0.30
};

let window_size = window.inner_size();
Expand Down
Loading