One vertex buffer, multiple vertex shaders

Started by
3 comments, last by e.s. 11 years, 2 months ago

Okay, so I've finally started switching from D3D9 to D3D11.

One thing that confuses me is ID3D11Device::CreateInputLayout().

I have to supply my input element definition, so far so good. But it also requires the compiled vertex shader code.

What if I want to draw a mesh with different vertex shaders? Will I have to create a different input layout for each combination or can I just use one for every shader?

Advertisement

I'm regurgitating what i've read here(less then a week ago actually).

In dx9 flexible vertex formats, or their shader equivelents, had to be checked against the shaders each time a shader was bound, and this is why changing shaders was such a huge performance factor. In DX11, the input layouts are checked against a shader at creation time, so switching shaders has much less overhead in the newer api. As long as the semantics in a layout match the semantics in the shaders to be used, then a single layout can be used for multiple shaders afaik.

You can re-use an input layout for multiple vertex shaders only if those vertex shaders have the same exact input signature. This means that those shader must take the same set of input parameters, with the same semantics.

Ah okay that makes sense.

Thanks for your answers.

You can re-use an input layout for multiple vertex shaders only if those vertex shaders have the same exact input signature. This means that those shader must take the same set of input parameters, with the same semantics.

Do the other shaders have to have the same exact byte size? How do you load the other shaders into the DeviceContext and associate them with specific models in the VertexBuffer?

This topic is closed to new replies.

Advertisement