General purpose compute with Vertex/Pixel shaders

2019-03-29 11:07发布

I have a question regarding compute shaders. are compute shaders available in DX 9? would it be still possible to use a compute shader with a DX9 driver if there is no compute shader fragment on the GPU? ( SGX 545 does not have it, but SGX 6X generation is going to have it), as far as what IMG says. I would like to know If i can do some simple general purpose programming on SGXs GPUs with DirectX9 or OpenGL drivers.

Also, is there anyway I can use OpenGL vertex shaders for GPGPU programming? Here is what I am thinking: I will load my Matrices/ data into the vertex buffer, and bind them to the program context. I will load some other static variables into the uniform variables, and my actual compute program into vertex shader. It looks feisible till this point ( does it? ) but the output from the vertex shader will go through rasterization and will be fed to fragment shader ( according to how things go in openGL). 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?

2条回答
我想做一个坏孩纸
2楼-- · 2019-03-29 11:44

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).

查看更多
一纸荒年 Trace。
3楼-- · 2019-03-29 11:59

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.

OpenGL Rendering Pipeline

查看更多
登录 后发表回答