[SlimDX] DirectX11 InputLayout failure..

Started by
2 comments, last by BigWordFree 12 years, 8 months ago
I'm trying my first DX11 SlimDX render engine, and followed the example on the SlimDX site, but it failes at the InputLayout and says, invalid argument passed to return function:

E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)

Any help is appreciated! I've included the verticie creation portion

-Andrew


this.vertices = new DataStream(12 * 3, true, true);
vertices.Write(new Vector3(0.0f, 0.5f, 0.5f));
vertices.Write(new Vector3(0.5f, -0.5f, 0.5f));
vertices.Write(new Vector3(-0.5f, -0.5f, 0.5f));
vertices.Position = 0;

this.vertexBuffer = new SlimDX.Direct3D11.Buffer(this.device, vertices, 12 * 3, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);

this.elements = new InputElement[] { new InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0) };
this.inputSignature = new SlimDX.D3DCompiler.ShaderSignature(this.vertices);
this.inputSignature.Data.Position = 0;
this.layout = new InputLayout(this.device, this.inputSignature, this.elements);



And here's the shader code


float4 VShader(float4 position : POSITION) : SV_POSITION
{
return position;
}

float4 PShader(float4 position : SV_POSITION) : SV_Target
{
return float4(1.0f, 1.0f, 0.0f, 1.0f);
}



Advertisement
An input layout requires the input signature of the vertex shader you're going to use. I'm not too familiar with SlimDX, but it looks like you're using the ShaderSignature class wrong by giving it a reference to your vertex buffer.
Giving the shader signature a data stream that contains your vertex buffer doesn't make any sense, as it's just a chunk of bytes. The signature isn't data, it specifies how that data is laid out per vertex. The shader signature needs to be taken from the shader you'll be using.

E.g. Using the effect classes, each effect pass will have a signature (for the vertex shader used) in its effect description you can use to create the input layout.

You can re-use these layouts with other shaders that have identical signatures.
Thanks, that helps, I was following the tutorials on the SlimDX web site and got a little lost. I didn't know Effects existed for DX11 SlimDX.

-Andrew

This topic is closed to new replies.

Advertisement