Skip to content

Commit 5be80b1

Browse files
committed
Prepare groundwork for 0.5 dev post
1 parent 8591a03 commit 5be80b1

File tree

1 file changed

+114
-0
lines changed
  • website/content/dev/05-update-wip

1 file changed

+114
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
+++
2+
# Copyright (c) godot-rust; Bromeon and contributors.
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
6+
7+
title = "0.5 dev update WIP"
8+
authors = ["Bromeon", "godot-rust contributors"]
9+
10+
[extra]
11+
summary = "v0.5 WIP"
12+
tags = ["dev-update"]
13+
+++
14+
15+
This is WIP for **0.5** update!
16+
17+
Existence of this PR doesn't mean that we want to release 0.5 anytime soon – it just makes documenting changes easier and less taxing.
18+
19+
20+
# Performance
21+
22+
## The Paranoid, The Balanced and Very Unsafe
23+
24+
Godot-rust now supports three tiers that differ in the amount of runtime checks and validations that are performed:
25+
26+
### 🛡️ **Strict**
27+
28+
Default for dev builds. Performs lots of additional, sometimes expensive checks, but allows to detect many bugs during development.
29+
30+
- Gd::bind/bind_mut() provides extensive diagnostics to locate runtime borrow errors.
31+
- Array safe conversion checks (for types like Array<i8>).
32+
- RTTI checks on object access (protect against type mismatch edge cases).
33+
- Geometric invariants (e.g. normalized quaternions).
34+
- Access to engine APIs outside valid scope.
35+
36+
### ⚖️ Balanced
37+
38+
Default for release builds. Performs basic validity and invariant checks, reasonably fast.
39+
Within this level you should not be able to encounter undefined behavior (UB) in safe Rust code.
40+
Invariant violations may however cause panics and logic errors.
41+
42+
- Object liveness checks.
43+
- Gd::bind/bind_mut() cause panics on borrow errors.
44+
45+
### ☣️ Disengaged
46+
47+
Disables most checks, sacrificing safety for raw speed.
48+
This renders a large part of the godot-rust API `unsafe` without polluting the code; you opt in via `unsafe impl ExtensionLibrary`.
49+
50+
Before using this, measure to ensure you truly need the last bit of performance (balanced should be fast enough for most cases; if not, consider bringing it up).
51+
Also test your code thoroughly using the other levels first. Undefined behavior and crashes arising from using this level are your full responsibility.
52+
When reporting a bug, make sure you can reproduce it under the balanced level.
53+
54+
- Unchecked object access -> instant UB if an object is dead.
55+
- Gd::bind/bind_mut() are unchecked -> UB if mutable aliasing occurs.
56+
57+
### Cargo features
58+
59+
You can downgrade 1 level in each `dev` (Debug) and `release` Cargo profiles, with following features:
60+
61+
- `safeguards-dev-balanced`: for `dev`, use ⚖️ **balanced** instead of the default strict level.
62+
- `safeguards-release-disengaged`: for `release`, use ☣️ **disengaged** instead of the default balanced level.
63+
64+
Thanks to @beicause for making bulk work for this feature! [#1278]
65+
66+
[#1278]: https://github.com/godot-rust/gdext/pull/1278
67+
68+
## Faster calls for Callables
69+
70+
Thanks to @lyonbeckers Rust Callables received significant improvement – making calling `Callable::from_fn` twice as fast as it was in `0.4`!
71+
72+
[#1331]: https://github.com/godot-rust/gdext/pull/1331
73+
74+
## Simple API to cache and fetch Autoloads
75+
76+
Godot [autoloads][godot-docs-autoload] can be now fetched and cached using higher-level convenience function – `get_autoload_by_name`.
77+
Thanks to it Godot autoloads can be easily accessed anywhere in the scope, even outside the scene tree – including calls from Callables and Objects.
78+
79+
To create rust autoload firstly create a scene with your rust Node in it and add it as an autoload in project settings.
80+
Afterward it can be accessed via its name and will be cached on the very first use.
81+
82+
```rust
83+
pub fn stage() -> Gd<Stage> {
84+
get_autoload_by_name("StageAutoload")
85+
}
86+
87+
#[derive(GodotClass)]
88+
#[class(init, base = Node)]
89+
pub struct Stage {
90+
#[var]
91+
level: Option<Gd<Level>>,
92+
}
93+
```
94+
95+
Thanks to @bromeon for implementing this feature and @ValorZard for testing it! ([#1381])
96+
97+
98+
[#1381]: https://github.com/godot-rust/gdext/pull/1381
99+
100+
## Improvements for macro-generated signatures
101+
102+
Multiple improvements for macro-generated signatures has been implemented:
103+
104+
- Docs for signals are now being preserved, allowing to inspect them in IDEs ([#1353]).
105+
- Docs in `#[godot_api(secondary)]` blocks are now properly preserved and registered ([#1355]).
106+
- Compile errors caused by wrong signature in `InterfaceTraits` now properly point to user code ([#1370], [#1373], [#1382]).
107+
108+
[#1353]: https://github.com/godot-rust/gdext/pull/1353
109+
[#1355]: https://github.com/godot-rust/gdext/pull/1355
110+
[#1370]: https://github.com/godot-rust/gdext/pull/1370
111+
[#1373]: https://github.com/godot-rust/gdext/pull/1373
112+
[#1382]: https://github.com/godot-rust/gdext/pull/1382
113+
114+
[godot-docs-autoload]: https://docs.godotengine.org/en/latest/tutorials/scripting/singletons_autoload.html

0 commit comments

Comments
 (0)