- Home /
How do you see the results of compute shaders in the debugger?
I'm trying to write some particularly complex functionality on the gpu that would be really good if I could at least see the raw data but I have no idea how.
Initially i thought my code was broken which led me to post this on stack exchange ...
... I now think its possible that unity has some sort of wierd bug that prevents me looking at the result of populating a 3d array from a compute shader result.
The code in this example isn't complex so there's no reason why it shouldn't behave just like debugging any other cpu code as all I want to do is put some values in to the buffer on the gpu then download and view them by putting a breakpoint in after my buffer.GetData(cpuArray) call.
Does anyone know if there's a work around or something for this?
It's worth noting that in the edit where I generate a 3,3,3 array of voxels where all but the center one are "empty" (-1 values) and the center is full (1 value) the array in the debugger tells me all elements are 0 values (apparently not populated) but the cpu meshing code is then able to generate the correct cube mesh from it after (not included in the question).
So what must I do to inspect arrays populated from the GPU?
I have tried the following with 0 success ...
Normal VS debugging (breapoint look at value / add to watch window to see value)
Load solution in to MonoDev and repeat the VS procedure
Debug.Log(values)
Answer by npatch · Feb 09, 2016 at 07:13 AM
GPU space isn't visible by the common debugger in VS. To view data in GPU mem you have to launch some kind of Graphics Debugger. There is a way to do that but just for DX11 shaders for now: DebuggingD3D11ShadersWithVS.
It requires the Graphics Debugger in VS2015.
Now, I haven't checked Compute Shaders out in the graphics debugger but it's the only place, you might get to see gpu mem. I've successfully debugged fragment shaders though.
On other solutions, you might want to try RenderDoc by Baldur Karlsson who works at Unity.
So even if i take the gpu generated results and put them in to a cpu based array I still can't read that array in the debugger?
To be clear: I'm not trying to directly read from the gpu's ram in the debugger only the downloaded result of a GetData() call on a buffer.
I also just found this: http://answers.unity3d.com/questions/890356/debugging-tools-for-unity-compute-shaders.html which goes to this: http://forum.unity3d.com/threads/debugging-shaders-in-visual-studio.322186/ ... much more detailed on working with debugging code on the GPU directly ... surely I don't need all this to view the contents of an array in c# after the gpu code has run and the results been downloaded back in to c# though?
Your answer
![](https://koobas.hobune.stream/wayback/20220612063517im_/https://answers.unity.com/themes/thub/images/avi.jpg)