• Create Account

### #Actuallipsryme

Posted 02 April 2013 - 02:35 PM

Got it working perfectly thanks !

So the only way is to define a constant max size for this buffer inside the code...?

Worst case would be 3 x numInstances which could add up to quite a lot.

By the way I'm currently assigning each instance the 3 float4's inside a loop. I assume it would be more efficient to add them inside a structure which I then copy once using memcopy or is that neglectable?

I'm only doing map / unmap once, but I'm filling the data like this:

// Update buffer
for(int u = 0; u < 3; u++)
{
XMStoreFloat4(&pInstanceData[(numInstances * 3) + u], worldTransform.r[u]);
}


basically in the loop that goes through every instance and counts them to do the instanced draw call at the end.

Also am I correct in thinking that I am restricted to one specific material (texture and properties from const buffer) for every unique instance group ?

update: Just read about putting them inside a Texture2DArray...so for specific material properties would it make sense to also store them inside a buffer like I did with the transforms ? Might be overkill for e.g. booleans but still...

### #11lipsryme

Posted 02 April 2013 - 02:35 PM

Got it working perfectly thanks !

So the only way is to define a constant max size for this buffer inside the code...?

Worst case would be 3 x numInstances which could add up to quite a lot.

By the way I'm currently assigning each instance the 3 float4's inside a loop. I assume it would be more efficient to add them inside a structure which I then copy once using memcopy or is that neglectable?

I'm only doing map / unmap once, but I'm filling the data like this:

// Update buffer
for(int u = 0; u < 3; u++)
{
XMStoreFloat4(&pInstanceData[(numInstances * 3) + u], worldTransform.r[u]);
}


basically in the loop that goes through every instance and counts them to do the instanced draw call at the end.

Also am I correct in thinking that I am restricted to one specific material (texture and properties from const buffer) for every unique instance group ?

update: Just read about putting them inside a Texture2DArray...so for specific material properties would it make sense to also store them inside a buffer like I did with the transforms ? Might be overkill for e.g. booleans still...

### #10lipsryme

Posted 02 April 2013 - 11:33 AM

Got it working perfectly thanks !

So the only way is to define a constant max size for this buffer inside the code...?

Worst case would be 3 x numInstances which could add up to quite a lot.

By the way I'm currently assigning each instance the 3 float4's inside a loop. I assume it would be more efficient to add them inside a structure which I then copy once using memcopy or is that neglectable?

I'm only doing map / unmap once, but I'm filling the data like this:

// Update buffer
for(int u = 0; u < 3; u++)
{
XMStoreFloat4(&pInstanceData[(numInstances * 3) + u], worldTransform.r[u]);
}


basically in the loop that goes through every instance and counts them to do the instanced draw call at the end.

Also am I correct in thinking that I am restricted to one specific material (texture and properties from const buffer) for every unique instance group ?

### #9lipsryme

Posted 02 April 2013 - 11:32 AM

Got it working perfectly thanks !

So the only way is to define a constant max size for this buffer inside the code...?

Worst case would be 3 x numInstances which could add up to quite a lot.

By the way I'm currently assigning each instance the 3 float4's inside a loop. I assume it would be more efficient to add them inside a structure which I then copy once using memcopy or is that neglectable?

I'm only doing map / unmap once, but I'm filling the data like this:

// Update buffer
for(int u = 0; u < 3; u++)
{
XMStoreFloat4(&pInstanceData[(numInstances * 3) + u], worldTransform.r[u]);
}


basically in the loop that goes through every instance and counts them to do the instanced draw call at the end.

Also am I correct in thinking that I am restricted to one specific material for every unique instance group ?

### #8lipsryme

Posted 02 April 2013 - 08:42 AM

Got it working perfectly thanks !

So the only way is to define a constant max size for this buffer inside the code...?

Worst case would be 3 x numInstances which could add up to quite a lot.

By the way I'm currently assigning each instance the 3 float4's inside a loop. I assume it would be more efficient to add them inside a structure which I then copy once using memcopy or is that neglectable?

I'm only doing map / unmap once, but I'm filling the data like this:

// Update buffer
for(int u = 0; u < 3; u++)
{
XMStoreFloat4(&pInstanceData[(numInstances * 3) + u], worldTransform.r[u]);
}


basically in the loop that goes through every instance and counts them to do the instanced draw call at the end.

### #7lipsryme

Posted 02 April 2013 - 08:42 AM

Got it working perfectly thanks !

So the only way is to define a constant max size for this buffer inside the code...?

Worst case would be 3 x numInstances which could add up to quite a lot.

By the way I'm currently assigning each instance the 3 float4's inside a loop. I assume it would be more efficient to add them inside a structure which I then copy once using memcopy or is that neglectable?

I'm only doing map / unmap once, but I'm filling the data like this:

// Update buffer