-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Some work on double-precision support #21922
Conversation
Haven't had time to look and compile the patch, but thank you for continuing with the work. Currently looking at the driver side of this which is dependent on Opengl4 or Vulkan. Since Vulkan is in the roadmap, I'm focusing on that. This is the dmat4 type for the position. |
23be3ec
to
e4cf53e
Compare
This is great! Besides ensuring that everything is using real_t, there is some significant piece of work missing which is making sure that binary serialization uses doubles instead of floats when compiling in this mode (yet keeping compat). One of the places that needs to be modified is: https://github.com/godotengine/godot/blob/master/core/io/marshalls.cpp As you can see I added a tiny bit of support for encoding as 64 bits like here: but needs to be:
Similar work needs to be done here: https://github.com/godotengine/godot/blob/master/core/io/resource_format_binary.cpp |
f134837
to
2aa68b7
Compare
Remember the code to turn on 64bit float is in: https://github.com/godotengine/godot/blob/2d3f6945ee7de9bf37139799b15e24c34b1e5a0b/platform/windows/detect.py#L207 godot/platform/windows/detect.py
Edited: I had cascading errors when turning that on. |
@fire Isn't that just for Windows? It's in the platform/windows folder. EDIT: Done, see code here, I also made it exit if you try to compile 64-bit floats on a 32-bit CPU, even if it works it would be slow and it's not a good idea. |
You can move it out into SConstruct, but the main point you need to
So that real_t is defined as double. |
when compiled with double precision, is important that even bullet is compiled with double precision. btScalar is the type def of floating point variables inside bullet. |
26a931c
to
f6070c9
Compare
9d147a1
to
efee149
Compare
I was blocked when I realize to fully convert the code, I need to touch the float in the position shader and gles3 version of our code didn't double precision matrixes. However, not doing still gives us more precision. I'm not sure how to calculate it, but it's better converting from double to a float on render than using a float directly. |
@fire Perhaps it would be best to worry about the rendering code after Vulkan is added. Since GPUs work with floats, it would be best to use floats there. The most important thing is for all math (including physics etc) to be in doubles. I can move the world around the player so that the "global" positions of what need to be rendered are within the precision range of floats. Or, it would be really cool if this could be done automatically by the renderer (some kind of "camera-centric" rendering where all objects are |
This change will be a game-changer for Godot! No more '#50251's! |
d07c125
to
46cf773
Compare
bba7dbd
to
f6f7d5b
Compare
3afa13c
to
5d198d3
Compare
Thanks! |
Thank you!!!!!!!!!!!!!!! |
Please see this proposal for the eventual goals this PR is a part of: godotengine/godot-proposals#892
This PR does a lot of work on double-precision support. I have previously split this PR up into smaller ones that are easier to review/merge and now those have been merged. It's small enough now that I don't think splitting this further would help much, the majority of the code that can be reviewed/merged separately has been reviewed/merged. Note that the rest of this PR changes things like arrays/vectors which are a bit more tricky so keep that in mind when reviewing.
In its current state things are mostly working except for a binding issue with integer vector multiplication/division that causes this PR to not compile. I previously had #44441 included in this PR's list of commits but now I've removed it so that this can be merged, and then the integer vector multiplication/division issue can be solved separately.