Author Topic: Question/Idea about offloading targeting calculations  (Read 6427 times)

Offline BlackCobra

  • Newbie Mark II
  • *
  • Posts: 11
Question/Idea about offloading targeting calculations
« on: 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.

Offline chemical_art

  • Core Member Mark IV
  • *****
  • Posts: 3,952
  • Fabulous
Re: Question/Idea about offloading targeting calculations
« Reply #1 on: 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.

Life is short. Have fun.

Offline PokerChen

  • Hero Member Mark III
  • *****
  • Posts: 1,088
Re: Question/Idea about offloading targeting calculations
« Reply #2 on: 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.

Offline BlackCobra

  • Newbie Mark II
  • *
  • Posts: 11
Re: Question/Idea about offloading targeting calculations
« Reply #3 on: 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.

Offline Draco18s

  • Resident Velociraptor
  • Core Member Mark V
  • *****
  • Posts: 4,251
Re: Question/Idea about offloading targeting calculations
« Reply #4 on: 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.

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Question/Idea about offloading targeting calculations
« Reply #5 on: 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.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!