Are games with large worlds compiled with fp:/fast?

Started by
9 comments, last by Steer 7 years, 6 months ago

I actually have a couple of very specific questions.

1) In general, nowadays are games compiled with fp:/fast or with fp:/precise flags turned on?

2) And what about games with large worlds, that usually have to deal with floating accuracy issues due to long distances from the camera: in those cases, the usual tricks like floating-origin and using doubles for calculating changes in transforms before reconverting back to float are used together with fp:/fast or even with them fp:/is needed?

Thanks for your insights.

Advertisement
I can't vouch for actual released AAA games, but if I was to create a large world, i wouldn't make all the world be part of the same numerical "space".

E.g. You might have a local level where your character is, and then a grid of larger areas which aren't loaded if you aren't in them.

Doing this, each part of the grid could safely fit into your accuracy level needed.

Hope this helps!
In my experience, fast is pretty common, the common alternative to fast would be strict, which would be used by anything that needs deterministic floating point results across multiple platforms.

Yeah if I was doing a large world, I'd use a floating origin for local coordinates, perhaps combined with 64bit integer / fixed point global coordinates. Using double precision anywhere is often a code smell honestly :wink:

AAA is a chaotic world. For instance the first releases of Skyrim were built without optimizations.

Yeah if I was doing a large world, I'd use a floating origin for local coordinates, perhaps combined with 64bit integer / fixed point global coordinates. Using double precision anywhere is often a code smell honestly :wink:

I used to think like this as well, but most recently I changed my opinion on this. There are a places where doubles really make sense. In particular for large worlds and numerical sensitive operations double is the right choice in my opinion. Why 64bit integer / fixed point and not just double. What does this buy you? Because of memory? On modern machines double performance is nearly as good as float from my experience. I would argue if doubles are an option for your problem on your target machine use them.

I also spent quite some time implementing robust versions of Quickhull and Mesh Simplification (QEM) which needed to compile our entire asset database (15 years of models!) and I did it in 32 bit floating point. What a waste of time! With doubles it all just works and with float32 I spend lots of time debugging and tweaking epsilons. Sure I gained some great insight into the algorithms and numerical analysis from this, but in retrospect I could have spend this time with much more valuable things.

Why 64bit integer / fixed point and not just double. What does this buy you?

Yeah fair enough on just using doubles when they solve your problems :)
As for the "why int?" thing though:
Floats/double's have the property of extreme precision near zero (your world's origin), which seems like a very silly thing to want in a world representation format.

If you need millimeter precision and work in metres as your units, then floats let you have objects up to about 4km from the origin in a particular axis.
On the other hand, 32-bit fixed point lets you have objects over 2000km from the origin in a particular axis. So for the same fixed precision target, fixed point gives you much better range.

Going to doubles will also solve the issue for any planet-sized game world -- doubles let you have objects over 1AU (over 100 million km) from the origin while maintaining millimeter precision, so, yeah that does seem easier than a hierarchical position format with a floating/local origin...
On the point of fixed-point vs floating-point though -- a 64-bit int will let objects be over approx 1 lightyear from the origin while maintaining millimeter precision, so it's still way better than double :D

For a space game world that's larger than a few light-years but requires extreme precision at any location in the world, a hierarchical format would be a requirement -- so sure, for anything smaller than that, "just use double" will work just fine.

caveman 3.0

fp fast

2500x2500 mile game world, divided into map squares 5 miles across.

locations are given by integer map square coords (mx,mz), and floating point coords in that map sq (x,z). x and z are limited to 0.0f to 26400.0f

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

so sure, for anything smaller than that, "just use double" will work just fine

This is for precision. But what about quickness ? I highly suppose that CPUs can still compute 32-bits floating point calculations faster than with 64-bits floating points. Even on 64-bits architectures. Am I wrong ?

Also, as far as I remember, floats ruled on the GPU some years ago. Do you think that nowadays GPUs can operate on 64-bits float as fast as 32-bits floats ?

so sure, for anything smaller than that, "just use double" will work just fine

This is for precision. But what about quickness ? I highly suppose that CPUs can still compute 32-bits floating point calculations faster than with 64-bits floating points. Even on 64-bits architectures. Am I wrong ?

Also, as far as I remember, floats ruled on the GPU some years ago. Do you think that nowadays GPUs can operate on 64-bits float as fast as 32-bits floats ?

On GPU, double is possible these days but is a big no-no for performance reasons. IIRC on some GPU's it's 4x slower than float.

On x86, double and float are the same speed with fp:/fast (as the FPU internally uses 80-bit floating point) and float is actually slower with fp:/strict (not accounting for memory bandwidth -- in bandwidth-bottlenecked situations, float is twice as fast as double)!

On x64, double and float are the same speed... unless your code is vectorizable (SIMD-able, SSE/AVX...), in which case float can be twice as fast.

so sure, for anything smaller than that, "just use double" will work just fine

This is for precision. But what about quickness ? I highly suppose that CPUs can still compute 32-bits floating point calculations faster than with 64-bits floating points. Even on 64-bits architectures. Am I wrong ?

Also, as far as I remember, floats ruled on the GPU some years ago. Do you think that nowadays GPUs can operate on 64-bits float as fast as 32-bits floats ?

On GPU, double is possible these days but is a big no-no for performance reasons. IIRC on some GPU's it's 4x slower than float.

On x86, double and float are the same speed with fp:/fast (as the FPU internally uses 80-bit floating point) and float is actually slower with fp:/strict (not accounting for memory bandwidth -- in bandwidth-bottlenecked situations, float is twice as fast as double)!

On x64, double and float are the same speed... unless your code is vectorizable (SIMD-able, SSE/AVX...), in which case float can be twice as fast.

Thank you a lot. So these things did not improve that much on the GPU side since the years 2000...

This topic is closed to new replies.

Advertisement