Arcen Games

General Category => AI War II - Gameplay Ideas => AI War II => AI War II - Ideas For Maybe Later => : BlackCobra September 06, 2016, 11:03:40 PM

: Question/Idea about offloading targeting calculations
: BlackCobra September 06, 2016, 11:03:40 PM
I was just reading in the AI War II Design Document and came to the collision checks and autotargeting and i was curious if they couldn't be done on the GPU instead?
Since from what i understand the calculations are basically vector based offloading them to the GPU (completly or partially) would increase the available CPU performance substantially.
: Re: Question/Idea about offloading targeting calculations
: chemical_art September 06, 2016, 11:16:35 PM
From what I have read, the design is to first remove the checks entirely if at all possible. For example, ships are made into squads. Secondly, squads on the AI side are held into pods if they are not actively deployed, etc.

: Re: Question/Idea about offloading targeting calculations
: PokerChen September 07, 2016, 04:46:16 AM
GPU-based computing is not something to be done lightly, it turns out. :) In other words, unless Unity itself provides extensive support, it is definitely not worth the initial investment. FYI, OpenCL/CUDA are the current specifications behind how to "offload" things to the GPU. Both deep rabbit-holes.
: Re: Question/Idea about offloading targeting calculations
: BlackCobra September 07, 2016, 10:38:10 AM
I wasn't aware the unity itself didn't had it implememted. I did find "compute shader" which unity has implememted and afaik it can be used like that too. It's written in HLSL though.
If autotargeting and colision checks can be done with that, it should free up more cpu resources.
: Re: Question/Idea about offloading targeting calculations
: Draco18s September 07, 2016, 01:40:28 PM
I wasn't aware the unity itself didn't had it implememted. I did find "compute shader" which unity has implememted and afaik it can be used like that too. It's written in HLSL though.
If autotargeting and colision checks can be done with that, it should free up more cpu resources.

I doubt it.
You'd have to encode the input and output information in separate render textures, which would be a pain in the arse.
: Re: Question/Idea about offloading targeting calculations
: x4000 September 07, 2016, 03:49:20 PM
Compute shaders could in theory do this.  However, there are a number of fundamental flaws here:

1. The bus between the GPU and the CPU would have to pass a TON of data, which would harm framerate.
2. The calculations would all be in floating-point math, which would cause desyncs between different cards (we use fixed-int math normally)
3. Overall this ties together more hardware components, not fewer, and it also only would work on pretty modern hardware, meaning that our supported group of customers is far lower.