- Home /
How can I speed up ComputeBuffer.GetData() ?
Since Texture2D.readpixels is awfully slow, I tried using ComputeBuffers instead. Currently I'm writing the colors of certain pixels into a RWStructuredBuffer in a custom ImageEffect i fill wiht Graphics.Blit. I get no performance hit whatsoever. As soon as I read the data, my performance drops down to about 50%.
I've read that the performance hit might be caused due to the GPU having to finish all processes so that the CPU can read (so both wait kinda).
Since I'm currently using a "normal" shader, I was wondering if writing an actual ComputeShader might speed the process up, however I lack the experience with ComputeShaders. Is reading from a ComputeShader quicker?
Thanks in advance!
Answer by Torigas · Jul 15, 2015 at 09:29 PM
I actually implemented a ComputeShader for the data transfer to an array-- and the speed difference seems to be huge. Well, at least I can't see an FPS difference between the code with and without the GetData() part.
So I guess the message is: Avoid reading from shaders in the graphics pipeline.
Your answer
Follow this Question
Related Questions
Swapping Compute Shaders 1 Answer
Using compute shader to return whether texture has certain colour 0 Answers
Direct X 11 - What if the user doesn't have it? 1 Answer
How do I disable DX11? 2 Answers