Comments (3)
I believe the main rationale behind it was:
Everything that touches the GPU tends to be float32
because its accuracy is "good enough" whilst needing only half the memory bandwidth. This means moving things from RAM into the GPU becomes way cheaper.
When you then want to multiply dt
within your Update
function with something (a coordinate, for example), it's easier if everything is float32
rather than converting to float64
first.
Whether this should stay or not: I don't know. I'm not familiar enough with game development. But that was the rationale 6-8 years ago.
Guesstimating here: when running on let's say 144 FPS, that is about one frame every 0.007 seconds. For the dt
to be able to distinguish between that, it needs three digits of "accuracy". For float32
that leaves roughly 4 digits of accuracy before the decimal. Meaning loss of accuracy after about 3 hours of gaming (9999 seconds). One might argue that float64
makes more sense.
from ecs.
Do you think this is something that maybe should be part of the Roadmap to v1.1? If nothing else, we could perhaps create benchmarks around measuring systems consuming float32
and then re-benchmark with float64
? I once heard, anecdotally, from a C++ developer that a 64 bit processor handles 64 bit lengthed primitives more efficiently because it doesn't need to perform two read or write operations and instead only performs one. That was over ten years ago though, and I never had the opportunity to test that, it could be false.
I would not mind creating that benchmark. I could probably create a contrived example, but what but what would you expect a system that needs to be performance tested to look like?
from ecs.
The rationale is exactly as @EtienneBruines said: since the GPU only uses float32, we just kept everything in float32. My thought there is, if you can only position things with float32 accuracy anyway, why bother working with higher accuracy float64 only to end up converting it to a float32 for things like Position, Width, etc anyway. If time were a float64, you'd end up with systems where you'd have to convert it to float32 every time anyway. What's the point of having dt float64
if I have to do var dx = speed * float32(dt)
every time I use it anyway.
That said, I could see the advantages of keeping everything (Position, etc) as float64s and only converting before sending to the GPU. At higher frame rates, the better accuracy could really be worth it, and if it benchmarks better then that's even better. I'd be for adding it to the roadmap.
from ecs.
Related Issues (20)
- `...string` instead of `[]string` for NewEntity HOT 3
- Idiomatic Go - biggest breaking change yet HOT 4
- Consider unexporting the Systems type HOT 2
- Sync/atom instead of sync.Mutex in ecs.NewBasic
- Add Identifier interface, targeted at BasicEntity HOT 1
- Add a CONTRIBUTING.md
- move tests into their own package where possible
- Feature Request: Allow more than one interface in `World.AddSystemInterface` in and ex.
- Extensify tests HOT 3
- Update to GitHub actions
- Add a go mod
- example that uses ecs.BasicFace HOT 2
- ecs.BasicFace does not exist HOT 3
- Update readme to utilize multiple interfaces
- Duplicate Entities HOT 1
- Mistake in README
- World System "auto-register" HOT 1
- Require tests to succeed before merging HOT 1
- Exclusion interface only matches if all components are present
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ecs.