On June, 22nd I was speaker in a while42 meetup. My topic was : 3D optimizations. Here are the slides of the presentation. Sorry, it's only in French :x
Few weeks ago, I decided to work with DirectX 11 to be able to render lots of objects in the same scene. I used the helper classes of DirectX Toolkit to help me at first and then I decided to wrap them in my own DirectX library. I included in this library a wrapper for DirectX initialization. One of the best feature of DirectX 11 is multithreaded rendering, that is to say divide your scene into different parts that will be rendered “at the same time”. All my research was made in the context of my job in 3D R&D at Daneel. Multithreaded rendering, a new feature of DirectX 11 DirectX 11 is the first version of DirectX which supports full multithreading for objects creation and rendering. I will not talk about creation of objects but only multithreaded rendering in this article. The principle is quite simple. To draw objects on the screen, you should use a Direct3D device context. With other versions of Direct3D, you had just one type of device context, which directly draws vertices on the screen as soon as we tell it to do it: this is the immediate context. In DirectX 11, a new kind of device context exists : the deferred context. This device context was created only to answer to the problematic of multithreaded rendering. Deferred contexts are used to record draw actions to play back later. Deferred contexts can record actions simultaneously. Source: http://www.gamasutra.com/view/feature/3759/sponsored_feature_introducing_.php?print=1 To be able to have a multithreaded rendering, you should really understand how work deferred contexts and immediate context. Environment setup for multithreading First of all, I strongly recommend that you work with a Win32 project and not a Windows 8 application (or even DirectX11 application for Windows). Indeed, I began to work with a template of Visual Studio: DirectX11 application. I implemented multithreaded architecture for rendering, and the rendering was working but I couldn't see any change in the performance: not better, not worse, exactly the same. I realized that's because of the project setup. I suppose that the application is forcing few DirectX 11 settings because of the compatibility with other devices like tablets. Secondly, you should check for driver support. Here is a how-to that explains it step by step. Rendering algorithm Many algorithms are possible. However, I decided to use the technique recommended in the book Practical rendering and computation with Direct3D 11. For each thread, we create a corresponding deferred context and command list with ID3D11Device::CreateDeferredContext(). So 12 threads, 12 deferred contexts, 12 command lists for instance. I divided my objects to render into as many groups as there are threads. Each command list is recorded, that is to say, we make rendering actions (like drawing) not on the immediate context like we used to do but on a deferred context previously created. Finally, we call ID3D11DeviceContext::FinishCommandList() in order to "close" the command list. It basically says that we no longer have actions to record for this command list. Here is the tutorial from MSDN to record a command list. After recording command lists, we have to execute them. This job is ONLY the immediate context's. When we want to execute command lists (for instance, at the end of your render function), we just have to call ID3D11DeviceContext::ExecuteCommandList() with the immediate context. That's it, we have a multithreaded rendering. Example In order to check if my algorithm was working, I decided to do an application with a bunch of settings you can change: number of threads, number of objects, CPU burn, rendering mode, and so on. I read an excellent article about multithreaded rendering in which Alexandre MUTEL talks about DirectX 11 and make some benchmarks with SharpDX, which is a DirectX11 framework made in C#. His sample was pertinent so I decided to do the same but in C++. My configuration was the next one: Windows 8, NVIDIA GeForce GTX950, 16Go RAM, up to 12 threads, Release x64. Here are the results I had: Limitations/best practices As we can see on the first chart above, performance of multithreaded rendering is not magical. It depends a lot on how it was implemented, but also about the number of objects to draw, etc. Here are best practices that can help you have better performance:
BinaryYou can download the sample I developed here.
References While doing tests about multithreading, I did a lot of research. Lots of articles, papers and books helped me to find the right way to do it.
My current job is 3D R&D developer at Azzimov Mobilité Inc. Azzimov is developing a virtual cognitive system, a real robot in the cloud: Daneel. My job is actually to visualize the brain of Daneel in a 3D space. I provide an interactive interface in which you can move, display information about nodes, edit these informations and the last but not the least, an interface in which you can see the brain's activation. This project is called Nebula.
Few days ago, we released 5 videos introducing Daneel and Nebula here. Here is one of the video showing Nebula (2'20''): Daneel : Vision Perspectives from Daneel on Vimeo. Our end-of-study project is almost finished ! Indeed, we had our last technical oral defense last Saturday and we're proud of our project. We're fixing last bugs and finishing the last level. We did great improvements thanks to our play tests in the Forum EIP and the Paris Games Week in December. Checkout the website spcmn.fr to be aware of the release date ! Tonight, a member of the Facebook team from San Francisco, Colin Creitz (@ccreitz), came to Montreal to introduce Facebook SDK for Unity. The event took place in Execution Labs in Montreal. Colin Creitz explained why use the Facebook SDK (portable on all platforms in one click), how it works and answered to our questions. He did a demonstration of a game portable in web browser, Android, iOS, and so on and showed us tips when we develop a game with the Facebook SDK, how to enable Facebook features like access to contacts information, share post on wall of the players, and so on.
We learned lots of things about the SDK and we got some Facebook goodies \o/ You can download the SDK here. Some other useful links here : - Stack overflow tag : "unity-facebook-sdk" - Blog for events and announcements - Learn about Parse's Unity integration - Learn about the Parse API To have some information about other meetups Hi everyone ! Spcmn is my end-of-study project, a video game developed with Unity3D. You can have more details about it in the Projects section. I decided to write regularly articles about it because I like this project and I want to show you the progress, week by week. To make a long story short, we are a team of 7 developers and 2 graphic artists and we are not in the same time zone this year (6 in 3 different cities of Canada, 1 in the USA, 1 in South Korea and finally 1 in France). So, the communication is not so easy and we need to be very organized to progress on our project. We decided to meet this weekend with one purpose: progress on our understanding of what we want for this game to be, and develop together, help each other with some issues that we can have. We were 4 in Quebec, and the others were on Hangouts. Clearly, this weekend was very helpful, we change our way to see the project and everyone has now a much clear vision of what we want to do, together. We changed the way that we want to implement physics (collisions for the most part) in our game. Indeed, we really would like to have a fluidity of movement and collisions for our player like the game Dustforce. It allows us to have a gameplay that is very interesting and not so basic. Moreover, it will allow us to play a lot with the level design in our game. So we begin to implement this type of physics, an editor for it inside Unity. We also begin menus implementation with the plugin NGUI. For now, we have the online scoring, a level editor, the loading system of the levels and prototypes of cutscenes system. Moreover, we have the first version of the character design of our player, Spaceman. I'll post more visuals as soon as I'll get it !
|
Archives
September 2015
Categories |