Muad'Dib
Muad'Dib

Reputation: 47

SharpDX instancing with D3D11

Could anybody provide a working code which uses SharpDX with D3D11, does instancing and uses SharpDX's content pipeline? I have several problems there. I came to understand, that one should use a SharpDX.Direct3D11.InputLayout to describe the input of the vertex shader. There I already have a problem. I use SharpDX's content pipeline, so the shaders are compiled in compile time and not in runtime. Where do I get the shader's byte code then? It shouldn't be that hard, but it seems that it's inaccessable from the effect object. My other question is, that how can I set the created SharpDX.Direct3D11.InputLayout before the current DrawIndexedInstanced call?

Upvotes: 0

Views: 595

Answers (1)

Muad'Dib
Muad'Dib

Reputation: 47

Already solved, there are some nice pitfalls, one should avoid:

  • For getting the shader's byte code, one must recompile the shader.
  • To set the input layout, one should cast the device to a SharpDX.Direct3D11.Device and use it's immediate context. Note that existing vertex buffer layout can be used to create the begining of the input layout.
  • One must also call the DrawIndexedInstanced method on the immediate context itself. Calling this method on a SharpDX.Toolkit.Graphics.GraphicsDevice will result in an incorrect parameter exception.

Upvotes: -3

Related Questions