Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 600
sai pallavi Avatar asked Sep 06 '13 19:09

sai pallavi


People also ask

What is the purpose of a vertex shader?

The vertex shader is used to transform the attributes of vertices (points of a triangle) such as color, texture, position and direction from the original color space to the display space. It allows the original objects to be distorted or reshaped in any manner.

What is a vertex shader in OpenGL?

The Vertex Shader is the programmable Shader stage in the rendering pipeline that handles the processing of individual vertices. Vertex shaders are fed Vertex Attribute data, as specified from a vertex array object by a drawing command.

What are vertex and pixel shaders?

Shaders are simple programs that describe the traits of either a vertex or a pixel. Vertex shaders describe the attributes (position, texture coordinates, colors, etc.) of a vertex, while pixel shaders describe the traits (color, z-depth and alpha value) of a pixel.

Does OpenGL support compute shaders?

Compute Shader Stage. To make GPU computing easier accessible especially for graphics applications while sharing common memory mappings, the OpenGL standard introduced the compute shader in OpenGL version 4.3 as a shader stage for computing arbitrary information.


2 Answers

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

like image 75
darius Avatar answered Sep 17 '22 20:09

darius


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

like image 38
Dylan Holmes Avatar answered Sep 20 '22 20:09

Dylan Holmes