Goombert
|
|
Posted on: July 26, 2013, 02:13:24 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Well I was doing some thinking after converting graphics systems to use float precision. Now Box2D has a built in scalar type that can be used to switch the precision at runtime between double and float. I was wondering if it would make sense for us to do this for graphics and collision systems by providing a built in scalar type for ENIGMA. Josh, forthevin, Harri, what you guys think?
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
|
Goombert
|
|
Reply #2 Posted on: July 26, 2013, 03:34:38 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
That is what I am planning Harri, cs_scalar, gs_scalar, but the question I am pondering on is whether to make a generic scalar and then a separate one purely for coordinate space.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
Josh @ Dreamland
|
|
Reply #3 Posted on: July 27, 2013, 06:33:24 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
The coordinate space uses the collision system/physics system scalar.
This seems to universally be float.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
Goombert
|
|
Reply #4 Posted on: July 27, 2013, 01:40:58 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Coordinate space, x, y, z, for graphics and audio functions don't use the collision system scalar.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
Goombert
|
|
Reply #5 Posted on: July 27, 2013, 06:27:50 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Scalar types have been mostly implemented to major systems. I have written a Wiki article explaining the new scalar parameters. http://enigma-dev.org/docs/Wiki/ScalarCollision systems, paths, and instance system should utilize cs_scalar or the collision system scalar. Graphics systems, particles, and other rendering should utilize gs_scalar or the graphics system scalar. Audio systems with sound positioning should utilize as_scalar or audio system scalar. These make it very easy to switch the entire engine between double and floating point precision, increasing the portability of our code and reducing unnecessary casts. Everyone please do your best to implement them where necessary. We may also add a math_radii and graphics_radii for controling radius precision, but for angles we will stick to double because that is the C and C++ standard for functions of a circle.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
TheExDeus
|
|
Reply #6 Posted on: July 28, 2013, 04:47:44 am |
|
|
Joined: Apr 2008
Posts: 1860
|
Most graphics hardware do not support double point precision for rendering even by emulation, really only a few Nvidia cards do. You make this hardware support mistake a lot. Just like you thought cards for some reason doesn't support primitive AA. So I'll just clarify - Nvidia supports non-emulated double precision since GTX2xx and it is supported on all cards since. The speed of course is lower and there was even a performance hit going from GTX5xx to 6xx as the architecture changed and no longer was tied to Tesla. But it still is supported. ATI has support for double precision since Radeon HD 3xxx, but it sadly changes between low end <x700 which doesn't support it and >=x700 which do. So only ATI min-end/high-end ATI cards support it and all Nvidia cards. Other than that I agree that graphics by default should be float. We also use glVertex2f which actually is float. So even when you change that scalar type to double nothing will really change on GPU side. It will just take more casting. For double it should be glVertex2d. So unless later we also make overloads/abstractions for all of the GL functions, then that scalar cannot impact GPU speed or precision in any way.
|
|
|
Logged
|
|
|
|
Goombert
|
|
Reply #7 Posted on: July 28, 2013, 01:19:41 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Immediate mode functions only take float because they are obsolete, VBO's do take GLdouble, and it is less optimal because your model becomes 2x as much being sent to the GPU. Again, even if rendering on a planetary scale, and using double, I still think your doing something wrong.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
TheExDeus
|
|
Reply #8 Posted on: July 28, 2013, 03:04:37 pm |
|
|
Joined: Apr 2008
Posts: 1860
|
Immediate mode functions only take float because they are obsolete, VBO's do take GLdouble, and it is less optimal because your model becomes 2x as much being sent to the GPU. Your first sentence seemed like a statement about something I said, but I didn't say that they only take float. I even gave you a function name which needs to be used to use doubles in immediate mode (glVertex2d). I just said that we didn't (and shouldn't). So just changing that scalar type will do nothing, because you basically do: double x, y; glVertex2f((float)x,(float)y); Where only speed impact is cast to float. We would also need to abstract the glVertex function and then redeclare them the same place we declare the scalar. But I don't think that is really that needed.
|
|
|
Logged
|
|
|
|
|
Goombert
|
|
Reply #10 Posted on: July 31, 2013, 05:36:49 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Do you mean why didn't I? I thought I avoided making alpha gs_scalar like the plague.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
Josh @ Dreamland
|
|
Reply #11 Posted on: July 31, 2013, 06:06:07 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
I'm not sure what to do with alpha, Harri. It's not a typical metric... Angles are also a special exception, as they're passed to trigonometry. Alpha only exists as a float long enough to cast to a byte for glColor4c. However, it might be wise to do the casting the other way, depending on where the float conversion is done. I'm not familiar with that part of the pipeline. The question is whether it's better on overall performance to do three float divs on the CPU, or one float mul on the CPU and four float divs on the GPU. Assuming that's what's happening.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|
|