Jump to content

  • Log In with Google      Sign In   
  • Create Account


Putting everything on the Compute Shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 mrheisenberg   Members   -  Reputation: 356

Like
0Likes
Like

Posted 27 October 2012 - 12:41 PM

My lighting so far heavily involves using a compute shader at the end of the frame,however I also want to use it for frustum and occlusion culling,and physics calculations at the beginning of the frame.I'll probably have to use another one for particles.Will it cause some performance issues if I use the compute shader so many times?From what I understand it invokes a different pipeline from the other shaders and a is a heavy state change.Can all of this be done in a single compute shader execution?Or is culling and physics still viable on the CPU side?

EDIT: another thing that bugs me is that I'm planning to implement multithreaded rendering with deferred contexts later,so I'll have to split the frame processing into 2 parts: 1.sends stuff to compute shader,process culling,collision data,etc,send them back to cpu,and after that do the command list building.

Edited by mrheisenberg, 27 October 2012 - 12:45 PM.


Sponsor:

#2 MJP   Moderators   -  Reputation: 10832

Like
0Likes
Like

Posted 27 October 2012 - 03:24 PM

Switching between compute and graphics can cause a flush of all pending shader executions, so it's not recommended that you switch between the two many times during a frame. There shouldn't be a problem if you dispatch a lot of compute shaders, as long as you don't invoke the graphics pipeline in between each dispatch.

Performing culling and physics is doable on the GPU, but for that to be truly efficient you need to keep everything on the GPU with no CPU readback. Reading results on the CPU requires potentially absorbing a lot of latency between when the command is issued and when the GPU copies the result back to CPU-accessible memory. If you can't absorb it the CPU will have to stall and wait for the GPU to finish. So it's not impossible, but it can be difficult depending on what you're doing.

#3 mhagain   Crossbones+   -  Reputation: 7803

Like
0Likes
Like

Posted 27 October 2012 - 03:54 PM

I did some experiments in a similar direction earlier this year for some dynamic texture updates I was doing. The usage pattern was to dispatch a bunch of CS invocations, switch back to normal, draw, more CS, and so on a few times per frame. The performance wasn't horrible but it was certainly a good deal slower than just doing the calculations on the CPU and incurring the overhead of updating a texture that may be currently in use for drawing.

The conclusion I came to is that really general GPU computing of a class that you can just arbitrarily switch back and forth to and from as often as you like just isn't here yet. On current hardware it's best to think of CS as a separate "mode" that your GPU can run in - and it can only run in one "mode" at a time, with overhead from switching "mode"s.

It's also worth bearing in mind that loading everything on the GPU is probably not a wise idea. The CPU is still a very capable processor, and is better than the GPU at the kind of branchy recursive code you seem to have in mind. The GPU also risks ending up having fewer resources available for it's real job of transforming vertexes and shading pixels. You need to choose and distribute your workloads wisely, as the key to performance is balancing load across both processors.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#4 mrheisenberg   Members   -  Reputation: 356

Like
0Likes
Like

Posted 27 October 2012 - 03:57 PM

yeah,the whole GPU culling idea got stuck in my head after reading this http://rastergrid.com/blog/2010/02/instance-culling-using-geometry-shaders/ but I guess it would get overly complicated if I attempt to implement such techniques at my current level




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS