Jump to content
  • Advertisement
Sign in to follow this  
MarcinWSB

DX11 Multithreading with diferred context and CommandLists

This topic is 1324 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,

 

I have the following scenario. I am integrating my DX11 plugin with a game application providing open interface for mods.

 

One thread is generating dynamic textures stored as Texture2D in ResourceShaderView. Once the bitmap bits are prepared on the deffered context I call Map(), then memcpy to GPU memory, then do UnMap() and call FinishCommandList() on the deffered context.

 

In the main thread I have a Render callback function that is called by the 3D game application every visual frame and providing me a target view where my plugin is attached to, In this callback I call ExecuteCommandList with the latest commandlist generated by my working thread. It work pretty well.

 

Now the problem statement is the following. As those threads are asynchronous, the working thread from time to time prepares the bitmaps more often than the main thread is rendering a frame. It means thet per each frame I might have 2-3 commandlists that are never executed as the rendering thread only needs the last snapshot of the texture. In the main thread I only call Release() of the CommanList I executed and do nothing with the previous command lists. Propbably this is not a good approach, however I run the tests with 50 FPS on the working thread and more less 25 FPS on the main thread which means every frame I created two commandlist where only one was executed and released, however I have not noticed any increase of GPU memory as there were not any leaks. Why is that ? Could someone explain. I run the test for 30 minutes with a video rendered on the working thread that was shown in the main scene. Is there any "smart" memory management when the CommandList is bound to the same texture ? Should I change my algorythm and manage the unexecuted command list. The thing is when I tried to do it I had some crashed from time to time and could not figure it why. On the other hand not releasing this "idle" commndlist created no issue ...

 

 

Share this post


Link to post
Share on other sites
Advertisement
You won't see a GPU memory increase, but a system/CPU memory leak.
IIRC, there's a way to enumerate/query which D3D objects exist, and also check for object leaks at shutdown. You should be seeing a huge pile of leaked command lists...

Share this post


Link to post
Share on other sites

ok, I will take a close look at the CPU memory. I would expect a leak at GPU as I memcpy to GPU memory and then create the commandlist... I thought a commandlist is just a kind of handler for GPU resource... though I am still an newbe in dx11.

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!