Replies: 1 comment 2 replies
-
Interesting: I wonder if we could insert a pointer into the ECS to a global constant. The API for this wouldn't be too terrible, but I worry that it may not actually result in the performance improvements you're looking for. The general concept doesn't sound like it should be purely restricted to resources: component data would benefit from this too. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It's fairly typical for games to have a subset of assets/resources which represent configuration data. These are often only exposed as assets to allow them to be tuned during development, but in a release build they represent constant data. In some cases, it may be a worthwhile optimisation to inline and fold these as constants during compilation. Should Bevy have some concept of a "constant resource" to address this?
An example might be the player controller that I'm currently working on in Unity. It's grown to have more than 20 configurable values, from simple floats to Bezier splines, all of which control the feel of the controller and are exposed for tweaking in the editor. There are a few instances where constant folding even the floats would make a significant difference to performance, and the Bezier splines in particular could be handled much faster if they were inlined as constant polynomial splines with constant numbers of points. I may manually inline these things when I'm confident that I won't need to tweak any further.
As a very rough sketch, I'm imagining that these resources could somehow be
const
loaded in a release build, and fed into systems in a way that allows the system bodies to inline the resource values if LLVM wants to. In a future Bevy Editor, an editor build might compile these systems to have two paths; a fast path that behaves like release, and a slow path that falls back to a dynamic resource if it has been changed in the editor since the last recompile.I see a number of things that make this hard. Among them, the types of assets that are likely to benefit from this most (the Bezier splines in my example) don't inline naturally in Rust. In my limited Rust experience, I understand that the unsized types restrictions mean that the natural way to implement something like an editable Bezier spline is with
Vec<ControlPoint>
, and I'm not sure how one would go about persuading the compiler to inline that as constant data.Is this something worth considering? Is it feasible?
Beta Was this translation helpful? Give feedback.
All reactions