Jump to content

  • Log In with Google      Sign In   
  • Create Account

Update instance data


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Dieselhead   Members   -  Reputation: 107

Like
0Likes
Like

Posted 08 March 2014 - 08:56 AM

Hello,

 

I am looking for feedback and information on how one should handle instance data. I am using DirectX 11, but it's the theory I'm interesting in and not the actual implementation.

 

This is my current setup:

 

  1. Game class with Update() and Draw() methods.'
  2. An array with GameObjects
  3. GameObject has Update() to recalculate a transform matrix and Draw() to pass the matrix and a mesh name to a RenderManager
  4. RenderManager has a list of mesh names, each name has its own list of transform matrices (one matrix per instance to draw)
  5. For each name I loop through all matrices and copy their data to an array of type InstanceData
  6. This InstanceData array is a subresource of an ID3D11Buffer
  7. After all copying is done the buffer is updated with Map/Unmap and memcpy
  8. I then DrawIndexedInstanced() using the mesh VertexBuffer, IndexBuffer and the InstanceDataBuffer 

 

This is what I came up with on my own using the knowledge I already had on the subject and looking up things when I needed to. Now I'm interested in hearing what I've done wrong and how to improve it. I'm interested in your opinions and any recommended reading on the subject.

 

I am mostly concerned with point number 5, which at the moment is a constant reorganizing of an array. How should I go about in improving this?

 

Thanks for reading



Sponsor:

#2 Krypt0n   Crossbones+   -  Reputation: 2570

Like
1Likes
Like

Posted 08 March 2014 - 04:48 PM

it sounds ok'ish, there is nothing particularly bad.

 

some improvements:

-instead of having a temporary copy of the transform matrices, you could rather group your game objects already by the render mesh name. then you'd process those in one go, fill immediately the InstanceData and when you're done with them, you'd invoke the drawcall.

-it's common in games to have most of the data unchanged, just some objects are dynamic, if you could figure out which objects don't change, you could just re-use the instancedata buffer from the last frame with no update etc. needed



#3 Dieselhead   Members   -  Reputation: 107

Like
0Likes
Like

Posted 10 March 2014 - 02:40 PM

Thanks a lot for your input, I will definitely try your suggestion of processing objects based on mesh or in other groups that makes sense. It's good to know I'm not completely off the mark so I will build on what I have for now.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS