Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

DX11 Solved - DrawInstanced Input Layout ?

Recommended Posts

Hi guys,

I am setting up instanced drawing (non-indexed) like this:

	struct d3d_vertex
{
 float x, y, z;
 float nx, ny, nz;
 float u, v, w;
};
	struct d3d_instance
{
 float x, y, z;
};
	D3D11_INPUT_ELEMENT_DESC layout[4];
	layout[0] = { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 };
layout[1] = {   "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 };
layout[2] = { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 };
layout[3] = { "TEXCOORD", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 36, D3D11_INPUT_PER_VERTEX_DATA, 0 };
	...
	UINT buffer_strides[2];
buffer_strides[0] = sizeof(d3d_vertex);
buffer_strides[1] = sizeof(d3d_instance);
	d3d_context->IASetVertexBuffers(0, 2, bufferPointers, buffer_strides, buffer_offsets);
	...
	d3d_context->DrawInstanced(tree_model.buffer_size, 1, 0, 0);
	

I am getting this error:

ID3D11DeviceContext::DrawInstanced: Input vertex slot 0 has stride 36 which is less than the minimum stride logically expected from the current Input Layout (48 bytes).

What am I missing ?

Thanks.

****

solved part:

	layout[0] = { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 };
layout[1] = {   "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 };
layout[2] = { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 };
layout[3] = { "TEXCOORD", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 };
	

 

 

 

 

 

Edited by Endemoniada

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!