

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer

This tutorial (msdn) gives a description of a vertex layout.

This is an example of a input layout:

UINT numElements = ARRAYSIZE(layout);

It seems to me that it would be easier to bypass this and simply consider data sent to the vertex shader/pixel shader as a block of floats and allow the vertex or pixel shader to interpret it as it wants.

My question is this:

  • What is the purpose of a vertex layout?
  • Is a vertex layout optional in Direct3D 11?
share|improve this question
up vote 4 down vote accepted

The example reasons why a vertex layout is needed:

We now have a structure that represents our vertex. That takes care of storing vertex information in system memory in our application. However, when we feed the GPU the vertex buffer containing our vertices, we are just feeding it a chunk of memory. The GPU must also know about the vertex layout in order to extract correct attributes out from the buffer. To accomplish this requires the use of an input layout.

Take into account that the vertex shader is just a step in the rendering pipeline, so is the responsibility of the GPU to issue the correct data as parameters in the shader. Yes, you could just define a "data size" and receive an array with that size in the shader and then process it, but that would require more code in the shader, and also could disallow GPU internal optimizations.

I haven't work with DX11, but in OpenGl, DX9 and other graphical APIs, you must define some kind of vertex layout

share|improve this answer

'A block of floats' wouldn't quite work, as

1) GPUs generally deal with vectors, usually 4-element vectors - and a vertex declaration defines how the floats are grouped into vectors (3-element position, 2-element UV set, etc)

2) Non-float data formats can be used, such as a 32-bit RGBA (which gets expanded into a vector of floats). The GPU needs to know about this

share|improve this answer
+1 for point no.2. – Groky Aug 30 '11 at 20:30

Your Answer


