Sign in to follow this  
XVincentX

D3D10 - Add a buffer in ID3DXMesh10

Recommended Posts

I already made Geometry Instancing examples throught ID3D10Buffer interfaces. Now i would like make it via ID3DX10Mesh interface. I look at all methods and functions: i found that interface supports multiple vertexbuffers (as you can see in SetVertexData) and also Instanced drawing, but i'm not able to found a way to create another vertex buffer in the interface Mesh10 in which i would store instancing data (it's just a float value), neither in creation, neither after. So, how can i make it?

Share this post


Link to post
Share on other sites

I found a way: the cloneMesh function. It, infact, gave him a new array of Input Element Desc, creates me 2 vertex buffers. The first one it's already filled, but when i try to fill the second using SetVertexData(1,buffer) it gives me error. The only way to fill it it's to lock it using GetVertexBuffer with ID3DX10MeshBuffer and copy values.

Ok, no problem, but when i try to make DrawSubsetInstanced it gives me INFO about "No second vertex buffer bound to pipeline"
Using PIX it effectively does not bound second vertex buffer, but makes a redundant bound of first vertex buffer, so i'm not able to draw instanced.
Can have you got some suggestions??

Share this post


Link to post
Share on other sites
Mabye i've found a bug in the ID3DX10Mesh interface.
It supports natively the instancing feature using DrawSubsetInstanced function, but also a lot of tries, it did not worked.

I'm using an InputLayout that has got 2 input slots and it works becouse the function GetVertexBufferCount() gives me 2 that it's ok (my intention is to make a vertex buffer for position and other informations, another one for a float value that will be used via instancing.)

So, using this simple code

float *bufdata = new float[LayerNum];
for (int i = 0; i < LayerNum; i++)
bufdata[i] = static_cast<float>(i) / LayerNum;

ID3DX10MeshBuffer *Mbuf;
void *bdata;
SIZE_T bsize;

geometry->Mesh->GetVertexBuffer(1,&Mbuf);

Mbuf->Map(&bdata,&bsize);
memcpy(bdata,bufdata,sizeof(float) * LayerNum);
Mbuf->Unmap();

Mbuf->Release();

delete[] bufdata;

i fill the second buffer.

The drawsubsetfunction gives me an INFO that say me that the input element 3 has got a input slot = 1 but no vertex buffer is bound at slot 1. So i opened PIX and started to make a debug, and i found this:

::IASetVertexBuffers 0,1,0xabce,0xabcde,0xabcde1
::IASetVertexBuffers 0,1,0xabce,0xabcde,0xabcde2

The second buffer REPLACE the first one, and so i remain with an unbound buffer at input slot 1. Should not it be

::IASetVertexBuffers 0,1,0xabce,0xabcde,0xabcde1
::IASetVertexBuffers 1,1,0xabce,0xabcde,0xabcde2

or

::IASetVertexBuffers 0,2,0xabce,0xabcde,0xabcdeBUFFERARRAY?

Thank you for your attention. I'm always ready to give you code or simply more informations.

Share this post


Link to post
Share on other sites

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