Jump to content
  • Advertisement
Hexaa

Multiple devices for each control

Recommended Posts

Hey,

I have a rather general question.

I have several controls that I need to draw scenes to. So far I set up my object structure so that each control has it's own renderer and objects, like own device, swapchain, thus context, shader etc...

Now I wonder if I could optimize my setup and objects to reuse, for example, the shaders to only be compiled once (which for example takes a lot of time), because all the instances of the windows need the same shaders. So I faced the issue that I cannot have the shader objects static and reuse with another instance since that instance has it's own Device and there is a policy that says that the objects needs to be created from the same Device or whatever, which makes sense to me.

I ask though, If my approach is wrong in the first place and I should rebuild my structure a bit to have only one device, and so I can reuse the objects and don't have to do work twice or can save memory. Or is it valid? I am new to Windows programming and GPU programming, so I apologize.

If I use a single static device I run into strang behavior in my code, because the context state maybe gets corrupted. I am not sure though, because I thought only the GUI Thread will work them, but maybe I can't say that it always works on the same control and finishes before it handles the next. So it would corrupted and mix states, which would maybe explain the issues I face now.

Would the solution be some kind of referred contexts? And schedule them to draw when the state is finished?

I don't want to optimize my runtime performance, this seems to be very well, even with the multi device approach, but maybe I can optimize the memory and setup time.

I have a hard time finding any good advice online, so thanks for any suggestions or hints :-)

Edited by Hexaa

Share this post


Link to post
Share on other sites
Advertisement

Which API are you using to render on the GPU? It sounds like you're using Direct3D, but the various versions have different behavior when it comes to device states and multithreading. Either way you almost certainly don't want to use multiple devices, especially if you're sharing the same content among your various windows.

Share this post


Link to post
Share on other sites

I use Direct3D11 via SharpDX.

I don't use the same content, just logic among my windows. This way all windows have their own context, so it gets not corrupted. I want to improve that structure though, because I feel like it's wrong a bit.

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

  • 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!