Display algorithm in Fragment Shader
I am new in OpenGL, recently, I am using OpenGL ES to process real time video frame(frame size if about 800 * 600, target GPU is PowerVR SGX543/266 MHz). In this project, we anlyse data of pixel cluster and display the pixel with an algorithm (for example, make a Gaussian Blur algorithm). In my design, the algorithm is implemented in the Fragment Shader（Time Complexity is O(n*n)）, it works, but the frame rate is too low, The normal frame rate is about 60 fpt, when enable the algorithm, frame rate become to 2 fpt.
My question is: "algorithm implemented in the Fragment Shader", is this pattern correct? It seems absolute to fall down the frame rate.
Yes, you should use fragment shader, especially because your target GPU doesn't support compute shaders (which could be an alternative).
Your problem is that you use n*n fetches in your fragment shader. But this is not the most efficient way.
You should use a 2-pass separable Gaussian filter then you can reduce the number of fetches to 2*n. Also there are other techniques to reduce the fetch count.
For more information check this article.
Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
Technical Blog: http://www.rastergrid.com/blog/
aqueous, thanks your reply, it's very helpful for me.