PhysX SDK 4.0, an Open-Source Physics Engine
news.developer.nvidia.com
news.developer.nvidia.com
When you replay a series of inputs, you want the accompanying physics to come out the same. Solvers that use randomness in your engine will either need to have their RNG seeded with the same value or have the rng removed.
Another thing causing problems might be how your engine handles time or when it iterates over objects in a specific order relative to how they were added (might not have preserved that order in your snapshot).
There's many things that can go wrong.
Knowing only how much Army of Two stressed its cooperative network play nature (including in its title), that's my best lay guess of the strong reason the game wanted deterministic simulations.
The impression I got from dev team discussions/features on The Halo Channel/Master Chief Collection was that Halo was built that way: its network engine wanted rock solid deterministic physics, so all the replay/recap features added to later games were a "free" bonus they were able to build on top from that earlier netcode requirement.
That also has the advantage of being able to "fake" events with effects until the server can resolve them meaning a latent connection can 'feel' faster.
Kudos to you for shipping a lockstep solution, we could never flush out the determinism bugs on our titles so we always just used dead-reckoning unless it was some dumb turn based game.
Another thing to consider about a replay system is that you don't have to be perfect. What you as a player see isn't what the server(if you have one) sees, and it's not what the other player sees. Your view is only a best guess at that, and for most replay systems in games, they will also be best guesses.
In terms of this game in particular, it's a multiplayer coop action shooter so you want everything the behave the same way on both players machines. The player models should be in consistent places in the world, bullets should fly in the same direction on both, grenades and other physics objects should bounce the same way.
If these things do not happen then you will have diverging realities on each of the machines.
Sounds like a potential GDC or Gamasutra writeup.
Otherwise you run into situation where large deltaV, or very small deltaV completely break the physics calculations. The next is that rounding issue and precision with double still creep in and having a physicist engine that is deterministic for a given hz and float/double speeds up development time.
Havok was once the leader in this area, but they were refinanced in a down round, acquired by Intel, and then sold off to Microsoft. Now they don't seem to be very active. Their web site announces the new 2013 version.
(I used to work on this stuff. I'm responsible for the ragdoll-falling-downstairs cliche, first shown in 1997.)
Disclaimer: I work there.
The position based dynamics code is in a separate SDK called Nvidia Flex ( https://developer.nvidia.com/flex). Flex is closed source, runs on the GPU and is implemented in CUDA (Nvidia only).
Scrawk converted the code to C# in order to support Unity and implemented a Unity based version of the fluid dynamics code that runs on the GPU (using portable compute shaders instead of CUDA) as well.
https://github.com/Scrawk/Position-Based-Dynamics https://github.com/Scrawk/PBD-Fluid-in-Unity
The only game that I'm aware of that uses position based dynamics on the GPU is Claybook (https://twvideo01.ubm-us.net/o1/vault/gdc2018/presentations/...). Because PDB is basically an extension of Jakobsen style verlet physics (http://www.cs.cmu.edu/afs/cs/academic/class/15462-s13/www/le...) which is used in a lot of games (Fantastic contraption, Gish, World of Goo, various Bridge builders, etc.) In all cases the developers are using custom physics code and not using a library. This is very different than rigid body dynamics where most shipping games use a licensed physics engine (Havok, PhysX, Bullet, ODE, etc.)
Flex 1.0 did require CUDA hardware, but with 1.1 they added a Direct3D backend that runs on any DX11-class GPU.
Discrete GPU's aren't going anywhere though, PC gaming has been going through a huge resurgence and their deployment in enterprise workloads is ever increasing. Warranty costs alone (you don't want to replace a 400+ mm2 GPU die when a motherboard capacitor dies or the CPU it's attached to fails) dictate that they remain add-in boards, then you have the upgradability argument.
Personally, I detest laptops as anything but machines for on-the-go productivity - I don't want to replace a full system just to swap a CPU or GPU, or pay a huge premium for the benefits of portability that I simply don't need in a gaming system (not to mention the performance compromises that you ALWAYS make with lower power or thermally limited components). I can see an argument being made for students or other people with more mobile lifestyles, but in my house there's three desks with gaming rigs right next to each other in the family room for my wife, my daughter, and myself - the need for portability simply isn't there.
The discrete GPU still isn't going anywhere :)
I use a tower myself currently, but I had an (early) gaming laptop in college and lately have been considering a return to laptop gaming with all the progress that has been made since the last time I tried it. Partly, because it's one of the few ways to differentiate today between PC and Console gaming is having the freedom of more mobile gaming experiences. (Nintendo's Switch, of course, says "hello" with its docking-based approach to the console. If Nintendo is right, the future of even Console gaming is probably mobile, too.)
Anyway, yes the discrete GPU is still around today. I'm just suggesting it might not be guaranteed to stay. As someone that has been using PCs since the 386 era, there are past versions of me that would have been surprised that the Sound Card was reintegrated into motherboards, even for use cases like 5.1+ speaker setups. Dolby Atmos support on the Windows PC is a "free" "app" you download, that asks your video bus (!) to pass through certain sound data over its HDMI port(s) (or that supports existing 5.1+ mainboard outputs if you pay the license fee, or that supports headphones if you pay the license fee). There's a PC world where that would seem unimaginable without an extra expansion board or three and some weird cable juggling. With the diminishing returns of discrete GPU cards over time (despite AMD and nVidia marketing), it does feel like the importance, even to gamers, of discrete GPU cards could similarly come to an end as it did for sound cards.
Why should the design stay as it is?
The GPU is already a parallel design, it just needs to be able to handle generic current CPU tasks and connect to existing media such as hard drives etc. Integrate system memory onto the card, and add on sound features etc.
The traditional selling speech from Intel for GPA is going to games done for discrete GPUs and kind of making it run on their integrated ones.
And they now even sell chips with AMD GPUs on them, as they really aren't good for anything beyond accelerated 2D graphics.
This strategy did let them down in that it caused them to miss the opportunities for AI, cryptocoin, ML, and other such markets.
Its the same thing that leaves IBM sitting on the sidelines. An unwillingness to take a chance and invest in things where the margins aren't evident. Eventually someone shows up and invents a whole market (AWS for example) and makes a killing leaving them sitting on the side lines.
That said, not that many games use the GPU-accelerated parts of it; for a lot of gameplay physics CPU code path of PhysX works just fine and does not have special hardware requirements.
The visual-only portion of GPU physics is not really that compelling which is why there isn't huge uptake. There would need to be a revolution in how games work on a fundamental level where basic game logic is calculated on the GPU to make true GPU physics happen. We might see that eventually but not anytime soon.
https://docs.nvidia.com/gameworks/content/gameworkslibrary/p...
Says: The GPU rigid body feature provides GPU-accelerated implementations of:
- Broad Phase
- Contact generation
- Shape and body management
- Constraint solver
These are absolutely not only used for the visual effects, they are the fundamentals of a physics engine.
Raycasting for game logic is cpu based as you mention because the game logic itself is on the cpu. Yet solvers and the true heavy lifting does work well on gpu.
Except, and this is the true reason we see little gpu physics, no one has spare gpu room. Thus cpu side physics wins for most games. Outside specific physics focused games giving up graphics for faster physics is not a profitable trade.
I say this as a gamedev myself who has several times made this exact decision.
Many games do have spare GPU room to spare, but since there are no good GPU-accelerated solutions for physics they don't have much of a choice.
This is a completely meaningless statement.
> you'll run into compatibility issues between the hardware vendors
Those compatibility issues already exist in the form of DX or OpenGL drivers, and most games have to face them. Writing a sim in OpenCL would work on both Nvidia and AMD, and even on Integrated GPUs.
> Many games do have spare GPU room to spare
Many smaller games mighy but most big games do not. And those games with GPU room to spare normally have CPU to spare.
>since there are no good GPU-accelerated solutions for physics
There is - PhysX.
How is "difficult to implement" a meaningless statement?
>Those compatibility issues already exist in the form of DX or OpenGL drivers, and most games have to face them. Writing a sim in OpenCL would work on both Nvidia and AMD, and even on Integrated GPUs.
With completely different performance characteristics and very difficult to diagnose bugs.
>Many smaller games mighy but most big games do not. And those games with GPU room to spare normally have CPU to spare.
Maybe if you're talking about mainstream AAA single player titles, but many multiplayer titles tend to have CPU limits instead.
>There is - PhysX.
Which only works on nvidia hardware and is thus a useless solution.
That's not true - UE4 games can be (and are) built against other physics engines.
See the other link currently on the front page: https://blogs.nvidia.com/blog/2018/12/03/physx-high-fidelity.... Gives some ideas of the rationale.
"Unreal Engine 4 uses the PhysX 3.3 physics engine to drive its physical simulation calculations and perform all collision calculations. "
https://docs.unrealengine.com/en-us/Engine/Physics
"As announced at GDC’14, Unity 5.0 features an upgrade to PhysX 3.3. Let’s give it a closer look."
https://blogs.unity3d.com/2014/07/08/high-performance-physic...
Most of the stats I can find say unity is 50-60%, and UE is about 10%:
https://www.linkedin.com/pulse/unity-vs-unreal-engine-more-c...
"He said that Unity powers more than 50 percent of mobile games and about half of all PC games."
https://venturebeat.com/2017/05/25/why-unity-was-able-to-rai...
Vast majority of the time, most game engine's to solve this problem just let non interactive objects (cloud's, waves, lighting) to be calculated by the phyx sub-system, and only poking it now and then to prevent the phyx hardware from swamping to the CPU.
PhysX keeps two copies of the simulation, you read from one while PhysX is updating the other, and then they swap the pointers. You don't cross the PCI bus to get every position/velocity, that info is transferred in bulk at every step.
https://github.com/NVIDIAGameWorks/PhysX-3.4/blob/master/Phy...
Does this actually work? If it has tangible benefits then perhaps the AOSP could do the same.
Come to think of it, it reduces the number of stat() system calls quite significantly, that can make a difference in large builds.
So far it looks more like a way to advance CUDA usage even further, by giving a free higher level library that's locked into it.
Assuming by hardware you mean GPU acceleration, then yes. It's not really a push for Cuda usage, most games that use physx don't use the GPU acceleration (not everyone has PhysX cards, and those that do are usually busy using the GPU for rendering), so in practice for 99% of use cases, it is open.
The point is that these two are completely orthogonal. It's like saying: what's the point of writing open source software for an x86 when the x86 RTL is closed source.
With an open source PhysX library, you can make PhysX work in any environment.
Not if their drivers on other environments dont support it. Consoles are all AMD, and NVIDIA only has 3-4% more market share on PC, while intel has around 70% of the market share. That's a really low number of platforms for a proprietary piece of tech.
Have you a source for this? Plenty of AAA games ship with CPU PhysX only. My experience with GPU PhysX is that it's not worth the resource usage, and the overhead and limitations (e.g. to do with collision filtering) make it not really suitable for general purpose use.
> There's many more physics engines that arent proprietary to certain hardware that run way better than physx
Again, PhysX isn't locked to any hardware. The GPU acceleration (which most games don't use) is locked to an NVidia GPU, but the CPU physics engine isn't. There is Havok and Bullet physics, both of which have pros and cons but aren't necessarily "better" than PhysX. If you have any numbers or sources to prove otherwise, I'd love to see them.
Currently Nvidia are complete jerks when it comes to helping nouveau with documenting their hardware.
The sad thing is that this experience is typical and expected for me by now. Nearly every time I install or upgrade Linux, I have to spend hours troubleshooting Nvidia driver issues. Cumulatively, several days of my life have been wasted on this. People are angry because Nvidia has made and continues to make bad decisions that result in a poor experience on Linux.
this is more complicated than I can really comment on, but from my understanding it was not an issue of nvidia's refusal to work on it so much as it was an issue of nvidia not being allowed a seat at the table to discuss it. the wayland protocol was effectively demanding a ground up rewrite with no ability for compromise purely because nvidia being closed source meant they weren't entitled to an opinion. which is... wow
I'm sorry that's the typical experience you've had with the driver, though I'm a little surprised by that actually. I don't run x on ubuntu, but I know there were some issues in the past where they were attempting to "smartly" configure the driver for certain setups and instead end up causing headaches. Though that is really my main issue with ubuntu in general, that they try to "help" you because they know best, and also one of the reasons I don't run it. I just use the runfile installer and let it auto-generate the base xconfig.
And it's not baseless. Where is their documentation on reclocking for desktop GPUs? Once they hid it behind signed firmware, doing it from nouveau became a major pain, because it requires complete blind reverse engineering. All this effort could be spent on making the drivers better instead, if Nvidia would have provided documentation.
It's the reason you can't use nouveau for gaming today on anything recent.
that said, youre right that it's not good that the nouveau driver is so far behind the proprietary one, and Im not trying to say that nvidia isn't at fault for that, just that it's a more complicated issue that people tend to portray it as.
also:
http://download.nvidia.com/open-gpu-doc/MemoryTweakTable/1/M...
http://download.nvidia.com/open-gpu-doc/MemoryClockTable/1/M...
As Nouveau developers put it:
> Reclocking must be done in firmware. NVIDIA now requires signed firmware to access a lot of useful functionality. They will never release the firmware in a nice redistributable manner, so the avenues for implementing it become much harder:
> (a) Figure out a way to extract the firmware from their released drivers (harder than it sounds) and how to operate it to do the things we need
> (b) Find a bug in their firmware to use to load our own code into the secure environment (any such exploit would be patched, but once we have a version of the firmware that's exploitable with signatures, we can just keep loading it instead of whatever's the latest)
> Of course all that gets us is ... firmware which can toggle stuff GPU-side. Then we have to develop the scripts to actually perform the reclocking to pass on to the firmware. This is the hard part -- due to the wide variety of hardware, ram chips, etc there can be a lot of variation in those scripts. A single developer might only have 1% of the boards out there, but by fuzzing the vbios and seeing how the blob driver reacts, we can get much more significant coverage.
> As part of the signed-everything logic, the blob driver now also verifies that the VBIOS hasn't been tampered with, which means that developing reclocking scripts will require different techniques.
> Moral of the story... just get an Intel or AMD board and move on with life. NVIDIA has no interest in supporting open-source, and so if you want to support open-source, pick a company that aligns with this.
In the end, crippling reclocking can easily be seen as an anti-competitive stance against nouveau, to prevent it from competing with the blob.
2) The contribution was actually not very helpful for nouveau, much of the information was already known. nvidia has done practically nothing since then to support nouveau in any meaningful way, with the exception of a one-off patchset to implement some support for Tegra.
I suspect you just found the first link that seemed to validate the point you are trying to make, without actually understanding what is actually (not) going on.
http://download.nvidia.com/open-gpu-doc/DCB/1/DCB-4.0-Specif...
> nvidia has done practically nothing since then to support nouveau in any meaningful way
There's an awful lot of stuff in that directory for that to be the case.
> suspect you just found the first link that seemed to validate the point you are trying to make, without actually understanding what is actually (not) going on.
Funny, I think the same thing when people say "nvidia never helps nouveau."
multiple docs have been updated in this past year
Cutting through the sarcasm, here's some Volta info: https://download.nvidia.com/open-gpu-doc/Display-Ref-Manuals...
As reported on in phoronix:
https://www.phoronix.com/scan.php?page=news_item&px=NVIDIA-V...
https://www.phoronix.com/scan.php?page=news_item&px=NVIDIA-V...
I think that sums it up nicely. Nvidia want the opensource driver to work just well enough that you can get a picture to install the proprietary one.