General purpose compute with Vertex/Pixel shaders (Open GL / DirectX)

混江龙づ霸主 提交于 2019-12-03 15:22:18
darius

is there anyway I can use OpenGL vertex shaders for GPGPU programming?

The stuff that goes out of the vertex shader is generally interpolated at the raserization stage. In old versions of openGL you could specify if such interpolation should or should not happen for specific variables. I don't know if you can still do that... Yes you still can (thx to datenwolf for the tip)... but a better approach, in my opinion, is to use fragment shaders. Render to a full frame, using a simple vertex shader that renders two triangles that cover the whole frame (a quad), as for any post process effect, and do your computation in the fragment shader. Put the data you want to use as input in textures, and render your results to other textures using frame buffer objects (FBO).

Is there anyway I can prevent the data to be going through whole of the graphics pipleline, or can I intercept after vertex shader is done with executing, and somehow read the values and time taken for execution?

Yes.
Potentially you could use the vertex shader for your computations, turn off the tessellations stages and geometry shader and intercept the results from the transform feedback.

Below is the OpenGL Rendering Pipeline.

The optional stages have a striped border.
The programmable stages are blue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!