Jump to content
  • Advertisement
Sign in to follow this  
Mathy

Better ways to modify transforms in hardware instancing?

This topic is 2953 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there.

Currently I am using hardware instancing to draw a lot of triangles, and as the secondary stream also attach information about their transforms.

I have a list defined with the transform data:

public static List<Morbus2D4.Shaders.Instancing.instanceData> virusInstanceDataListV2;

This list is where I change all the transform data for every frame to make the objects move, and then when I need to put them into the hardware instancing shader stream, I do the following:

dataStream.WriteRange(virusInstanceDataListV2.ToArray(), 0, amountOfInstances);

I believe this may be causing a performance overload.

I was thinking if there would be a way to modify the transforms directly inside the stream, so that I would only have to set the stream once, and then keep drawing the primitives.

Is that possible? Or is there another approach to boost performance?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Mathy
I use SlimDX, which I wouldn't call old.


Slim DX is just a wrapper (albeit a slim one, hence the name). DirectX still supports a fixed function pipeline but it's generally considered far better to use your own shaders.

Are you calling fixed functions from the CPU or are you passing data to a shader and writing that yourself?

Share this post


Link to post
Share on other sites
Quote:
Original post by Mathy
I use SlimDX, which I wouldn't call old.


No offend. It is just sometimes hard to see what managed API is in use from a little piece of code.

First of all you should make sure that your buffer for the instance data is created as a dynamic buffer. Other types can cause a stall every time you lock them.

I am not exactly sure how the WriteRange is implemented but I sure it’s done in the most efficient way. What you can do is using an array of Morbus2D4.Shaders.Instancing.instanceData instead of a list. This way you can safe the additional ToArray call. You might although create this array once and reuse it every frame.

Share this post


Link to post
Share on other sites
The problem here however then lies in the fact that objects constantly get removed and added from the list. They are all triangles, and they have a specific lifespan.

Share this post


Link to post
Share on other sites
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!