Problems with compute-shader-fork

I am currently using https://github.com/cpt-max/MonoGame for my project, and in general it works’ very fine.
But now I am running into a performance issue: When trying to execute two different compute-shaders for the same texture3d object, GPU utilization goes up to 100% and my entire pc lags crazy.

I dont upload any new object to the gpu, it’s the same exact texture3d-object, but it must pass two different compute-shader (to simplify my aim: generate a sphere in compute-shader A, then pass it to another compute-shader B that does some additional calculations, both dispatch 512/4 thread groups on every axis).

How can I pass an texture3d-object (of size 512^3) to different compute-shaders without perfomance loss?

Best regards

Are you saying that each shader separately runs fine, and only when you chain them together the problems start?

512^3 is a lot of pixels. 134 Mio pixels per shader, and 268 Mio in total.
To give you an idea, a 4K texture has 8 Mio pixels. You are effectively updating 32 4K textures.

1 Like

This, 512^3 is insane size and there are not many GPUs that can operate with this in realtime even for pretty simple operations.

1 Like

Yes, each shader separately runs fine, chaining them together, meaning calling .DispatchCompute(…) in succession makes things worse, but I guess it’s pretty obvious that this is not very efficient.

What I initially assumed is that calling .DispatchCompute(…) many times doesn’t execute it as many times, but batch it to some extend and run two or more shaders in one call one after another, meaning: For pixel (x, y, z), it calls the first CS-function, then after that the second CS-function, but what it really does is call for all pixels first CS-technique, then dispatch again and call for all pixels the second applied CS-technique.

The reason I wanted to achieve a “pipe”-like behaviour is simply due to the code-overhead which happens if I put all the compute-logic in one effect-file.

Best regards