# What is the minimum of shader I need to use to run basic calculation on GPU?

I read, that the Hull Shader, Domain Shader, Geometry Shader and Pixel Shader can be used optional. So, is the Vertex Shader optional too? If no: What does a basic Vertex Shader look like? Just like a simple pass through? Is the Vertex Shader necessary to tell what kind of datastructure (Van Stripes or Meshes) are used? What can I do, with just the vertex shader? Are the fixed functions working without any help of programming a programmable stage?

The vertex shader stage must always be active for the pipeline to execute. If no vertex modification or transformation is required, a pass-through vertex shader must be created and set to the pipeline.

From this you can infer that a vertex shader is absolutely required to write SV_Position but that's all, so the most basic possible vertex shader will just write an arbitrary value to SV_Position; in the pass-through case this just means copying over the input position to output, but (since D3D10+ allows drawing without input buffers) you can set it to any value you like if you wish (this is commonly seen in code for drawing full-screen quads).

If you use compute shaders, or a GPU compute API like CUDA or OpenCL, then you don't need any of the graphics pipeline shaders. Depending on your application, GPU compute may be a better fit for you, e.g. if what you're doing has nothing to do with rasterizing triangles. Compute allows you to simply launch a large block of GPU "threads" running in parallel, and what they do is up to your program.

As for the graphics pipeline, you can't do much with just a vertex shader. You can rasterize triangles to the depth buffer, and that's about it. If you want to do some computation at each pixel of an image, a common approach is to put the computation in a pixel shader, and do a "full-screen pass" by drawing a single triangle that covers the entire image. This requires a very simple vertex shader, but the real work is done by the pixel shader.

• I agree with what you said, but to be honest I am still not sure what he is trying to ask, exactly ? Nov 11, 2013 at 18:50
• @concept3d Yeah, I agree the question is not very clear as it stands. Nov 11, 2013 at 18:50

Vertex shaders are iirc not optional.

They tend to be used to transform vertices from world to view space and then project them onto a 2d plane (screenspace).

Vertex shaders doesn't know what kind of data structure it is, merely that you're taking in a vertex with some input data.

The vertex shader outputs the projected position and any optional data you want to pass along.